void rpmluaSetVar(rpmlua _lua, rpmluav var) { INITSTATE(_lua, lua); lua_State *L = lua->L; if (var->listmode && lua->pushsize > 0) { if (var->keyType != RPMLUAV_NUMBER || var->key.num == (double)0) { var->keyType = RPMLUAV_NUMBER; var->key.num = (double) luaL_getn(L, -1); } var->key.num++; } if (!var->listmode || lua->pushsize > 0) { #if defined(LUA_GLOBALSINDEX) if (lua->pushsize == 0) lua_pushvalue(L, LUA_GLOBALSINDEX); #endif if (pushvar(L, var->keyType, &var->key) != -1) { if (pushvar(L, var->valueType, &var->value) != -1) lua_rawset(L, -3); else lua_pop(L, 1); } if (lua->pushsize == 0) lua_pop(L, 1); } }
void rpmluaPop(rpmlua _lua) { INITSTATE(_lua, lua); assert(lua->pushsize > 0); lua->pushsize--; lua_pop(lua->L, 1); }
void rpmluaSetPrintBuffer(rpmlua _lua, int flag) { INITSTATE(_lua, lua); lua->storeprint = flag; lua->printbuf = _free(lua->printbuf); lua->printbufsize = 0; lua->printbufused = 0; }
void rpmluaDelVar(rpmlua _lua, const char *key, ...) { INITSTATE(_lua, lua); va_list va; va_start(va, key); (void) findkey(lua->L, FINDKEY_REMOVE, key, va); va_end(va); }
void rpmluaPushTable(rpmlua _lua, const char *key, ...) { INITSTATE(_lua, lua); va_list va; va_start(va, key); (void) findkey(lua->L, FINDKEY_CREATE, key, va); lua->pushsize++; va_end(va); }
void rpmluaPushPrintBuffer(rpmlua _lua) { INITSTATE(_lua, lua); rpmluapb prbuf = xcalloc(1, sizeof(*prbuf)); prbuf->buf = NULL; prbuf->alloced = 0; prbuf->used = 0; prbuf->next = lua->printbuf; lua->printbuf = prbuf; }
void rpmluaSetData(rpmlua _lua, const char *key, const void *data) { INITSTATE(_lua, lua); lua_State *L = lua->L; lua_pushliteral(L, "rpm_"); lua_pushstring(L, key); lua_concat(L, 2); if (data == NULL) lua_pushnil(L); else lua_pushlightuserdata(L, (void *)data); lua_rawset(L, LUA_REGISTRYINDEX); }
char *rpmluaPopPrintBuffer(rpmlua _lua) { INITSTATE(_lua, lua); rpmluapb prbuf = lua->printbuf; char *ret = NULL; if (prbuf) { ret = prbuf->buf; lua->printbuf = prbuf->next; free(prbuf); } return ret; }
int rpmluaVarExists(rpmlua _lua, const char *key, ...) { INITSTATE(_lua, lua); lua_State *L = lua->L; int ret = 0; va_list va; va_start(va, key); if (findkey(L, FINDKEY_RETURN, key, va) == 0) { if (!lua_isnil(L, -1)) ret = 1; lua_pop(L, 1); } va_end(va); return ret; }
int rpmluaCheckScript(rpmlua _lua, const char *script, const char *name) { INITSTATE(_lua, lua); lua_State *L = lua->L; int ret = 0; if (name == NULL) name = "<lua>"; if (luaL_loadbuffer(L, script, strlen(script), name) != 0) { rpmlog(RPMLOG_ERR, _("invalid syntax in Lua scriptlet: %s\n"), lua_tostring(L, -1)); ret = -1; } lua_pop(L, 1); /* Error or chunk. */ return ret; }
int rpmluaRunScriptFile(rpmlua _lua, const char *filename) { INITSTATE(_lua, lua); lua_State *L = lua->L; int ret = 0; if (luaL_loadfile(L, filename) != 0) { rpmlog(RPMLOG_ERR, _("invalid syntax in Lua file: %s\n"), lua_tostring(L, -1)); lua_pop(L, 1); ret = -1; } else if (lua_pcall(L, 0, 0, 0) != 0) { rpmlog(RPMLOG_ERR, _("Lua script failed: %s\n"), lua_tostring(L, -1)); lua_pop(L, 1); ret = -1; } return ret; }
void rpmluaGetVar(rpmlua _lua, rpmluav var) { INITSTATE(_lua, lua); lua_State *L = lua->L; if (!var->listmode) { if (lua->pushsize == 0) lua_pushvalue(L, LUA_GLOBALSINDEX); if (pushvar(L, var->keyType, &var->key) != -1) { lua_rawget(L, -2); popvar(L, &var->valueType, &var->value); } if (lua->pushsize == 0) lua_pop(L, 1); } else if (lua->pushsize > 0) { (void) pushvar(L, var->keyType, &var->key); if (lua_next(L, -2) != 0) popvar(L, &var->valueType, &var->value); } }
int rpmluaRunScript(rpmlua _lua, const char *script, const char *name) { INITSTATE(_lua, lua); lua_State *L = lua->L; int ret = 0; if (name == NULL) name = "<lua>"; if (luaL_loadbuffer(L, script, strlen(script), name) != 0) { rpmlog(RPMLOG_ERR, _("invalid syntax in Lua script: %s\n"), lua_tostring(L, -1)); lua_pop(L, 1); ret = -1; } else if (lua_pcall(L, 0, 0, 0) != 0) { rpmlog(RPMLOG_ERR, _("Lua script failed: %s\n"), lua_tostring(L, -1)); lua_pop(L, 1); ret = -1; } return ret; }
MainDialog::MainDialog(BOOL &optionPlaceStructs, BOOL &optionProcessStatic, BOOL &optionOverwriteComments, BOOL &optionAudioOnDone, BOOL &optionClean, BOOL &optionFullClear) : QDialog(QApplication::activeWindow(), 0) { // Required for static library resources Q_INIT_RESOURCE(QtResource); setupUi(this); setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); buttonBox->addButton("CONTINUE", QDialogButtonBox::AcceptRole); buttonBox->addButton("CANCEL", QDialogButtonBox::RejectRole); #define INITSTATE(obj,state) obj->setCheckState((state == TRUE) ? Qt::Checked : Qt::Unchecked); INITSTATE(checkBox1, optionPlaceStructs); INITSTATE(checkBox2, optionProcessStatic); INITSTATE(checkBox3, optionOverwriteComments); INITSTATE(checkBox4, optionAudioOnDone); INITSTATE(checkBox5, optionClean); INITSTATE(checkBox6, optionFullClear); #undef INITSTATE // Apply style sheet QFile file(STYLE_PATH"style.qss"); if (file.open(QFile::ReadOnly | QFile::Text)) setStyleSheet(QTextStream(&file).readAll()); }
/*@-mods@*/ void rpmluaInteractive(rpmlua _lua) { INITSTATE(_lua, lua); _rpmluaInteractive(lua->L); }
rpmlua rpmluaGetGlobalState(void) { INITSTATE(NULL, lua); return lua; }
const char *rpmluaGetPrintBuffer(rpmlua _lua) { INITSTATE(_lua, lua); return lua->printbuf; }
void *rpmluaGetData(rpmlua _lua, const char *key) { INITSTATE(_lua, lua); return getdata(lua->L, key); }