Skip to content

Commit dd64245

Browse files
Corporalwill123UE4SS
authored andcommitted
fix(Lua): UFunction and UClass properly inherit from UStruct
Mostly affects UFunction, as UClass had already directly inherited the member functions now possible to iterate over function properties in Lua
1 parent 918d935 commit dd64245

File tree

6 files changed

+9
-10
lines changed

6 files changed

+9
-10
lines changed

UE4SS/include/LuaType/LuaUClass.hpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@ namespace RC::LuaType
2020
};
2121
class UClass : public UObjectBase<Unreal::UClass, UClassName>
2222
{
23-
public:
24-
using Super = LuaType::UStruct;
25-
2623
private:
2724
explicit UClass(Unreal::UClass* object);
2825

UE4SS/include/LuaType/LuaUFunction.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#include <LuaMadeSimple/LuaMadeSimple.hpp>
66
#include <LuaType/LuaUObject.hpp>
7+
#include <LuaType/LuaUStruct.hpp>
78

89
namespace RC::Unreal
910
{

UE4SS/src/LuaType/LuaUClass.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ namespace RC::LuaType
2121
if (lua.is_nil(-1))
2222
{
2323
lua.discard_value(-1);
24-
LuaType::UObject::construct(lua, lua_object);
24+
LuaType::UStruct::construct(lua, lua_object);
2525
setup_metamethods(lua_object);
2626
setup_member_functions<LuaMadeSimple::Type::IsFinal::Yes>(table);
2727
lua.new_metatable<LuaType::UClass>(metatable_name, lua_object.get_metamethods());
@@ -35,7 +35,7 @@ namespace RC::LuaType
3535

3636
auto UClass::construct(const LuaMadeSimple::Lua& lua, BaseObject& construct_to) -> const LuaMadeSimple::Lua::Table
3737
{
38-
LuaMadeSimple::Lua::Table table = UObject::construct(lua, construct_to);
38+
LuaMadeSimple::Lua::Table table = UStruct::construct(lua, construct_to);
3939

4040
setup_member_functions<LuaMadeSimple::Type::IsFinal::No>(table);
4141

@@ -52,8 +52,6 @@ namespace RC::LuaType
5252
template <LuaMadeSimple::Type::IsFinal is_final>
5353
auto UClass::setup_member_functions(const LuaMadeSimple::Lua::Table& table) -> void
5454
{
55-
Super::setup_member_functions<LuaMadeSimple::Type::IsFinal::No>(table);
56-
5755
// CDO = ClassDefaultObject
5856
table.add_pair("GetCDO", [](const LuaMadeSimple::Lua& lua) -> int {
5957
const auto& lua_object = lua.get_userdata<UClass>();

UE4SS/src/LuaType/LuaUFunction.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ namespace RC::LuaType
4242
if (lua.is_nil(-1))
4343
{
4444
lua.discard_value(-1);
45-
LuaType::UObject::construct(lua, lua_object);
45+
LuaType::UStruct::construct(lua, lua_object);
4646
setup_metamethods(lua_object);
4747
setup_member_functions<LuaMadeSimple::Type::IsFinal::Yes>(table);
4848
lua.new_metatable<LuaType::UFunction>(metatable_name, lua_object.get_metamethods());
@@ -56,7 +56,7 @@ namespace RC::LuaType
5656

5757
auto UFunction::construct(const LuaMadeSimple::Lua& lua, BaseObject& construct_to) -> const LuaMadeSimple::Lua::Table
5858
{
59-
LuaMadeSimple::Lua::Table table = UObject::construct(lua, construct_to);
59+
LuaMadeSimple::Lua::Table table = UStruct::construct(lua, construct_to);
6060

6161
setup_member_functions<LuaMadeSimple::Type::IsFinal::No>(table);
6262

assets/Changelog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,9 @@ Types with `get` or `Get` functions now have both variants. ([UE4SS #877](https:
348348

349349
Improved error messages when improperly indexing into `LocalUnrealParam`, and `RemoteUnrealParam` without first calling `Get`. ([UE4SS #1154](https://github.com/UE4SS-RE/RE-UE4SS/pull/1154))
350350

351+
Fixed UFunction and UClass properly inheriting from UStruct in Lua. ([UE4SS #1154](https://github.com/UE4SS-RE/RE-UE4SS/pull/1158))
352+
Corporalwill123
353+
351354
#### UEHelpers [UE4SS #650](https://github.com/UE4SS-RE/RE-UE4SS/pull/650)
352355
- Increased version to 3
353356

docs/lua-api/classes/ufunction.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# UFunction
22

33
## Inheritance
4-
[UObject](./uobject.md)
4+
[UStruct](./ustruct.md)
55

66
## Metamethods
77

0 commit comments

Comments
 (0)