| 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 | } |
no test coverage detected