Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add TMap implementation to lua #755

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 79 additions & 0 deletions UE4SS/include/LuaType/LuaTMap.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#pragma once

#include <LuaType/LuaUObject.hpp>

#include <Unreal/Core/UObject/UObjectHierarchyFwd.hpp>

namespace RC::Unreal
{

}

namespace RC::LuaType
{
struct TMapName
{
constexpr static const char* ToString()
{
return "TMap";
}
};

class TMap : public RemoteObjectBase<Unreal::FScriptMap, TMapName>
{
private:
Unreal::UObject* m_base;

Unreal::FMapProperty* m_property;
Unreal::FProperty* m_key_property;
Unreal::FProperty* m_value_property;

private:
explicit TMap(const PusherParams&);

public:
TMap() = delete;

auto static construct(const PusherParams&) -> const LuaMadeSimple::Lua::Table;
auto static construct(const LuaMadeSimple::Lua&, BaseObject&) -> const LuaMadeSimple::Lua::Table;

private:
auto static setup_metamethods(BaseObject&) -> void;

private:
template <LuaMadeSimple::Type::IsFinal is_final>
auto static setup_member_functions(const LuaMadeSimple::Lua::Table&) -> void;

enum class MapOperation
{
Find,
Add,
Contains,
Remove,
Empty,
};

auto static prepare_to_handle(MapOperation, const LuaMadeSimple::Lua&) -> void;
};

struct FScriptMapInfo
{
Unreal::FProperty* key{};
Unreal::FProperty* value{};

Unreal::FName key_fname{};
Unreal::FName value_fname{};

Unreal::FScriptMapLayout layout{};

FScriptMapInfo(Unreal::FProperty* key, Unreal::FProperty* value);

/**
* Validates existence of lua pushers for this key/values in this structure.
* Throws if a pusher for a key/value was not found
*
* @param lua Lua state to throw against.
*/
void validate_pushers(const LuaMadeSimple::Lua& lua);
};
}
1 change: 1 addition & 0 deletions UE4SS/include/LuaType/LuaUObject.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@ namespace RC::LuaType
RC_UE4SS_API auto push_uint64property(const PusherParams&) -> void;
RC_UE4SS_API auto push_structproperty(const PusherParams&) -> void;
RC_UE4SS_API auto push_arrayproperty(const PusherParams&) -> void;
RC_UE4SS_API auto push_mapproperty(const PusherParams&) -> void;
RC_UE4SS_API auto push_floatproperty(const PusherParams&) -> void;
RC_UE4SS_API auto push_doubleproperty(const PusherParams&) -> void;
RC_UE4SS_API auto push_boolproperty(const PusherParams&) -> void;
Expand Down
Loading
Loading