MCPcopy Create free account
hub / github.com/Tencent/UnLua / CheckPropertyOwner

Function CheckPropertyOwner

Plugins/UnLua/Source/UnLua/Public/LowLevel.cpp:139–169  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

137 }
138
139 bool CheckPropertyOwner(lua_State* L, ITypeOps* InProperty, void* InContainerPtr)
140 {
141#if ENABLE_TYPE_CHECK == 1
142 if (InProperty->StaticExported)
143 return true;
144
145 ITypeInterface* TypeInterface = (ITypeInterface*)InProperty;
146 if (!TypeInterface->IsValid())
147 {
148 luaL_error(L, TCHAR_TO_UTF8(*FString::Printf(TEXT("Access invalid property %s."), *TypeInterface->GetName())));
149 return false;
150 }
151
152 FProperty* Property = TypeInterface->GetUProperty();
153 if (!Property)
154 return true;
155
156 UObject* Object = (UObject*)InContainerPtr;
157 UClass* OwnerClass = Property->GetOwnerClass();
158 if (!OwnerClass)
159 return true;
160
161 if (Object->IsA(OwnerClass))
162 return true;
163
164 luaL_error(L, TCHAR_TO_UTF8(*FString::Printf(TEXT("Access property from invalid owner. %s should be a %s."), *Object->GetName(), *OwnerClass->GetName())));
165 return false;
166#else
167 return true;
168#endif
169 }
170 }
171}

Callers 4

GetUPropertyFunction · 0.85
SetUPropertyFunction · 0.85
Class_IndexFunction · 0.85
Class_NewIndexFunction · 0.85

Calls 4

luaL_errorFunction · 0.85
IsValidMethod · 0.45
GetNameMethod · 0.45
GetUPropertyMethod · 0.45

Tested by

no test coverage detected