diff --git a/Source/LuaMachine/Private/LuaState.cpp b/Source/LuaMachine/Private/LuaState.cpp index 645b575..bca0089 100644 --- a/Source/LuaMachine/Private/LuaState.cpp +++ b/Source/LuaMachine/Private/LuaState.cpp @@ -863,6 +863,16 @@ int ULuaState::MetaTableFunction__call(lua_State* L) void* Parameters = FMemory_Alloca(LuaCallContext->Function->ParmsSize); FMemory::Memzero(Parameters, LuaCallContext->Function->ParmsSize); + for (TFieldIterator It(LuaCallContext->Function.Get()); (It && It->HasAnyPropertyFlags(CPF_Parm)); ++It) + { + UProperty* Prop = *It; + if (!Prop->HasAnyPropertyFlags(CPF_ZeroConstructor)) + { + Prop->InitializeValue_InContainer(Parameters); + } + } + + if (bImplicitSelf) { NArgs--; @@ -984,6 +994,12 @@ int ULuaState::MetaTableFunction__call(lua_State* L) } } + for (TFieldIterator It(LuaCallContext->Function.Get()); (It && It->HasAnyPropertyFlags(CPF_Parm)); ++It) + { + It->DestroyValue_InContainer(Parameters); + } + + if (ReturnedValues > 0) return ReturnedValues; @@ -1361,6 +1377,11 @@ void ULuaState::Len(int Index) lua_len(L, Index); } +int32 ULuaState::ILen(int Index) +{ + return luaL_len(L, Index); +} + int32 ULuaState::ToInteger(int Index) { return lua_tointeger(L, Index); diff --git a/Source/LuaMachine/Public/LuaState.h b/Source/LuaMachine/Public/LuaState.h index f2086c5..5139152 100644 --- a/Source/LuaMachine/Public/LuaState.h +++ b/Source/LuaMachine/Public/LuaState.h @@ -279,6 +279,8 @@ class LUAMACHINE_API ULuaState : public UObject void Len(int Index); + int32 ILen(int Index); + void RawGetI(int Index, int N); void RawSetI(int Index, int N); diff --git a/Source/LuaMachineEditor/Private/LuaMachineEditor.cpp b/Source/LuaMachineEditor/Private/LuaMachineEditor.cpp index 510e285..61a08c6 100644 --- a/Source/LuaMachineEditor/Private/LuaMachineEditor.cpp +++ b/Source/LuaMachineEditor/Private/LuaMachineEditor.cpp @@ -89,7 +89,6 @@ class SLuaMachineDebugger : public SCompoundWidget, public FGCObject return; SelectedLuaState->PushGlobalTable(); - FLuaValue CurrentLuaTableOwner = SelectedLuaState->ToLuaValue(-1); SelectedLuaState->PushNil(); // first key while (SelectedLuaState->Next(-2)) { @@ -212,7 +211,10 @@ class SLuaMachineDebugger : public SCompoundWidget, public FGCObject if (LuaState->GetInternalLuaState()) { - DebugTextContext += FString::Printf(TEXT("%s at 0x%p (used memory: %dk) (top of the stack: %d) (uobject refs: %d) (tracked user data: %d)\n"), *LuaState->GetName(), LuaState, LuaState->GC(LUA_GCCOUNT), LuaState->GetTop(), Referencers.Num(), LuaState->TrackedLuaUserDataObjects.Num()); + LuaState->PushRegistryTable(); + int32 RegistrySize = LuaState->ILen(-1); + LuaState->Pop(); + DebugTextContext += FString::Printf(TEXT("%s at 0x%p (used memory: %dk) (top of the stack: %d) (registry size: %d) (uobject refs: %d) (tracked user data: %d)\n"), *LuaState->GetName(), LuaState, LuaState->GC(LUA_GCCOUNT), LuaState->GetTop(), RegistrySize, Referencers.Num(), LuaState->TrackedLuaUserDataObjects.Num()); } else {