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

wrapper添加 MakeConstVariable #1867

Open
wants to merge 1 commit into
base: master
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
3 changes: 3 additions & 0 deletions unreal/Puerts/Source/JsEnv/Public/ScriptBackend.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
::PUERTS_NAMESPACE::PropertyWrapper<PUERTS_NAMESPACE::PUERTS_BINDING_IMPL::API, decltype(M), M>::info()
#define MakeVariable(M) MakeProperty(M)
#define MakeReadonlyVariable(M) MakeReadonlyProperty(M)
#define MakeConstVariable(M) \
&(::PUERTS_NAMESPACE::ConstVariableWrapper<PUERTS_NAMESPACE::PUERTS_BINDING_IMPL::API, decltype(M), M>::getter), nullptr, \
::PUERTS_NAMESPACE::ConstVariableWrapper<PUERTS_NAMESPACE::PUERTS_BINDING_IMPL::API, decltype(M), M>::info()
#define MakeFunction(M, ...) \
[](::PUERTS_NAMESPACE::PUERTS_BINDING_IMPL::API::CallbackInfoType info) \
{ \
Expand Down
19 changes: 19 additions & 0 deletions unreal/Puerts/Source/JsEnv/Public/StaticCall.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1457,6 +1457,25 @@ struct PropertyWrapper<API, Ret*, Variable>
return CTypeInfoImpl<Ret, false>::get();
}
};
template <typename API, typename Ret, Ret Variable>
struct ConstVariableWrapper
{
template <typename T>
using DecayTypeConverter = typename API::template Converter<typename internal::ConverterDecay<T>::type>;

static void getter(typename API::CallbackInfoType info)
{
auto context = API::GetContext(info);
API::SetReturn(info, DecayTypeConverter<Ret>::toScript(context, Variable));
}

static void setter(typename API::CallbackInfoType info) { }

static const CTypeInfo* info()
{
return CTypeInfoImpl<Ret, false>::get();
}
};

template <typename T, typename API, typename RegisterAPI>
class ClassDefineBuilder
Expand Down
Loading