move getParent to LuaEngine Core

This commit is contained in:
Syping 2018-09-15 01:56:50 +02:00
parent 8a6f7311ca
commit 44d8d73877
3 changed files with 17 additions and 18 deletions

View file

@ -29,7 +29,8 @@ LuaEngine::LuaEngine(QObject *parent, bool loadBaseLibraries) : QObject(parent)
pushPointer("__LuaEngine", (void*)this);
pushVariant("DeleteInstant", 0);
pushVariant("DeleteLater", 1);
pushFunction("delete", luaDeletePointer_p);
pushFunction("delete", luaObjectDelete_p);
pushFunction("getParent", luaObjectParent_p);
pushFunction("connect", luaTriggerConnect_p);
pushFunction("disconnect", luaTriggerDisconnect_p);
pushFunction("luaEngineVersion", luaEngineVersion_p);
@ -315,7 +316,7 @@ int LuaEngine::getArgumentCount(lua_State *L_p)
return lua_gettop(L_p);
}
int LuaEngine::luaDeletePointer_p(lua_State *L_p)
int LuaEngine::luaObjectDelete_p(lua_State *L_p)
{
if (getArgumentCount(L_p) >= 1) {
void *pointer = getPointer(L_p, 1);
@ -333,6 +334,18 @@ int LuaEngine::luaDeletePointer_p(lua_State *L_p)
return 0;
}
int LuaEngine::luaObjectParent_p(lua_State *L_p)
{
if (getArgumentCount(L_p) >= 1) {
void *pointer = getPointer(L_p, 1);
if (pointer != NULL) {
pushPointer(L_p, ((QObject*)pointer)->parent());
return 1;
}
}
return 0;
}
int LuaEngine::luaTriggerConnect_p(lua_State *L_p)
{
if (getArgumentCount(L_p) >= 3) {

View file

@ -76,7 +76,8 @@ private:
lua_State *L;
static int luaEngineVersion_p(lua_State *L_p);
static int luaEnginePlatform_p(lua_State *L_p);
static int luaDeletePointer_p(lua_State *L_p);
static int luaObjectDelete_p(lua_State *L_p);
static int luaObjectParent_p(lua_State *L_p);
static int luaTriggerConnect_p(lua_State *L_p);
static int luaTriggerDisconnect_p(lua_State *L_p);

View file

@ -131,9 +131,6 @@ void LuaEngineGui::pushClass(lua_State *L_p)
pushVariant(L_p, "SizePolicyPreferred", (int)QSizePolicy::Preferred);
pushVariant(L_p, "SizePolicyExpanding", (int)QSizePolicy::Expanding);
pushVariant(L_p, "SizePolicyIgnored", (int)QSizePolicy::Ignored);
// Object functions
pushFunction(L_p, "getParent", getParent);
}
void LuaEngineGui::pushClass(LuaEngine *luaEngine)
@ -799,18 +796,6 @@ int LuaEngineGui::createTextEdit(lua_State *L_p)
return 1;
}
int LuaEngineGui::getParent(lua_State *L_p)
{
if (getArgumentCount(L_p) >= 1) {
void *pointer = getPointer(L_p, 1);
if (pointer != NULL) {
pushPointer(L_p, ((QObject*)pointer)->parent());
return 1;
}
}
return 0;
}
int LuaEngineGui::getWidgetText(lua_State *L_p)
{
if (getArgumentCount(L_p) >= 1) {