Skip to content

Commit

Permalink
1、LuaWrapper支持生成不同版本的inc文件,并以inc文件区分开不同版本方便维护
Browse files Browse the repository at this point in the history
2、更新LuaWrapper工具集和配置
  • Loading branch information
zjhongxian committed Jul 6, 2023
1 parent f713a45 commit ea8f61b
Show file tree
Hide file tree
Showing 15 changed files with 30,910 additions and 11,121 deletions.
28 changes: 18 additions & 10 deletions Plugins/slua_unreal/Source/slua_unreal/Private/LuaObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
#include "lstate.h"
#include "LuaBlueprintLibrary.h" // Comment For PUBG Mobile
#include "LuaFunctionAccelerator.h"
#include "LuaProfiler.h"
#include "LuaOverrider.h"
#include "Engine/UserDefinedEnum.h"

Expand Down Expand Up @@ -1410,6 +1409,22 @@ namespace NS_SLUA {
return 3;
}

int instanceStructClone(lua_State* L) {
LuaStruct* luaStruct = LuaObject::checkValue<LuaStruct*>(L, 1);
auto uss = luaStruct->uss;

uint32 size = luaStruct->size;
uint8* buf = (uint8*)FMemory::Malloc(size);
uss->InitializeStruct(buf);
uss->CopyScriptStruct(buf, luaStruct->buf);

LuaStruct* luaStructCopy = new LuaStruct();
luaStructCopy->Init(buf, size, uss, false);
int ret = LuaObject::push(L, luaStructCopy);
LuaObject::addLink(L,buf);
return ret;
}

int instanceIndexSelf(lua_State* L) {
lua_getmetatable(L,1);

Expand Down Expand Up @@ -1526,14 +1541,6 @@ namespace NS_SLUA {
return LuaObject::push(L, v);
}

int pushUSoftObjectProperty(lua_State *L, FProperty* prop, uint8* parms, NewObjectRecorder* objRecorder) {
auto p = CastField<FSoftObjectProperty>(prop);
ensure(p);
FSoftObjectPtr v = p->GetPropertyValue(parms);
FSoftObjectPtr* softObjectPtr = new FSoftObjectPtr(v);
return LuaObject::push<FSoftObjectPtr>(L, "FSoftObjectPtr", softObjectPtr, UD_AUTOGC | UD_VALUETYPE);
}

void* checkUArrayProperty(lua_State* L,FProperty* prop,uint8* parms,int i,bool bForceCopy) {
auto p = CastField<FArrayProperty>(prop);
ensure(p);
Expand Down Expand Up @@ -2409,7 +2416,6 @@ namespace NS_SLUA {
regPusher(FEnumProperty::StaticClass(), pushEnumProperty);
regPusher(FClassProperty::StaticClass(), pushUClassProperty);
regPusher(FWeakObjectProperty::StaticClass(), pushUWeakProperty);
regPusher(FSoftObjectProperty::StaticClass(), pushUSoftObjectProperty);

regChecker<FIntProperty>();
regChecker<FUInt32Property>();
Expand Down Expand Up @@ -2660,6 +2666,8 @@ namespace NS_SLUA {
lua_setfield(L, -2, "__next");
lua_pushcfunction(L, instanceStructPairs);
lua_setfield(L, -2, "__pairs");
lua_pushcfunction(L, instanceStructClone);
lua_setfield(L, -2, "clone");
return 0;
}
}
Expand Down
Loading

0 comments on commit ea8f61b

Please sign in to comment.