Skip to content

Commit 915a151

Browse files
author
Aidan Lee
committed
re-introduce intermediate object for haxe generated callables
1 parent 4f28398 commit 915a151

File tree

7 files changed

+29
-20
lines changed

7 files changed

+29
-20
lines changed

include/Array.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1407,7 +1407,7 @@ namespace hx
14071407
template<class ELEM_> \
14081408
::hx::Callable<value(args_list)> Array_obj<ELEM_>::name##_dyn() \
14091409
{ \
1410-
struct _hx_array_##name : public ::hx::Callable_obj<value(args_list)> \
1410+
struct _hx_array_##name : public ::hx::AutoCallable_obj<value(args_list)> \
14111411
{ \
14121412
Array<ELEM_> mThis; \
14131413
_hx_array_##name(Array<ELEM_> inThis) : mThis(inThis) \
@@ -1456,7 +1456,7 @@ template<class ELEM_>
14561456
template<class TO>
14571457
::hx::Callable<Array<TO>(::hx::Callable<TO(ELEM_)>)> Array_obj<ELEM_>::map_dyn()
14581458
{
1459-
struct _hx_array_map : public ::hx::Callable_obj<Array<TO>(::hx::Callable<TO(ELEM_)>)>
1459+
struct _hx_array_map : public ::hx::AutoCallable_obj<Array<TO>(::hx::Callable<TO(ELEM_)>)>
14601460
{
14611461
Array<ELEM_> mThis;
14621462
_hx_array_map(Array<ELEM_> inThis) : mThis(inThis)

include/cpp/VirtualArray.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ class HXCPP_EXTERN_CLASS_ATTRIBUTES VirtualArray_obj : public hx::ArrayCommon
574574
template<typename T>
575575
::hx::Callable<int(T)> push_dyn()
576576
{
577-
struct _hx_virtualarray_push : public ::hx::Callable_obj<int(T)>
577+
struct _hx_virtualarray_push : public ::hx::AutoCallable_obj<int(T)>
578578
{
579579
::cpp::VirtualArray mThis;
580580

include/hx/Functions.h

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,22 @@ namespace hx
4747
return sizeof...(TArgs);
4848
}
4949

50-
Dynamic __Run(const Array<Dynamic>& inArgs) override final;
50+
Dynamic __Run(const Array<Dynamic>& inArgs) = 0;
5151

5252
virtual TReturn _hx_run(TArgs... args) = 0;
5353
};
5454

55+
template<class TReturn, class... TArgs>
56+
class HXCPP_EXTERN_CLASS_ATTRIBUTES AutoCallable_obj;
57+
58+
template<class TReturn, class... TArgs>
59+
class HXCPP_EXTERN_CLASS_ATTRIBUTES AutoCallable_obj<TReturn(TArgs...)> : public ::hx::Callable_obj<TReturn(TArgs...)>
60+
{
61+
Dynamic __Run(const Array<Dynamic>& inArgs) override final;
62+
};
63+
64+
// ::hx::ObjectPtr overloads
65+
5566
template<class TReturn, class... TArgs>
5667
class HXCPP_EXTERN_CLASS_ATTRIBUTES Callable;
5768

@@ -83,7 +94,7 @@ namespace hx
8394
Callable(::cpp::Function<TReturn(TArgs...)> inFunction)
8495
: super(nullptr)
8596
{
86-
struct FunctionCallable final : public Callable_obj<TReturn(TArgs...)>
97+
struct FunctionCallable final : public AutoCallable_obj<TReturn(TArgs...)>
8798
{
8899
::cpp::Function<TReturn(TArgs...)> func;
89100

@@ -105,7 +116,7 @@ namespace hx
105116
Callable(const Callable<TOtherReturn(TOtherArgs...)>& inCallable)
106117
: super(nullptr)
107118
{
108-
struct AdapterCallable final : public Callable_obj<TReturn(TArgs...)>
119+
struct AdapterCallable final : public AutoCallable_obj<TReturn(TArgs...)>
109120
{
110121
Callable<TOtherReturn(TOtherArgs...)> wrapped;
111122

@@ -138,7 +149,7 @@ namespace hx
138149
Callable(const Callable<void(TOtherArgs...)>& inCallable)
139150
: super(nullptr)
140151
{
141-
struct AdapterCallable final : public Callable_obj<TReturn(TArgs...)>
152+
struct AdapterCallable final : public AutoCallable_obj<TReturn(TArgs...)>
142153
{
143154
Callable<void(TOtherArgs...)> wrapped;
144155

@@ -181,7 +192,7 @@ namespace hx
181192
{
182193
if (::hx::IsNotNull(inDynamic) && inDynamic->__GetType() == vtFunction)
183194
{
184-
struct DynamicCallable final : public Callable_obj<TReturn(TArgs...)>
195+
struct DynamicCallable final : public AutoCallable_obj<TReturn(TArgs...)>
185196
{
186197
Dynamic wrapped;
187198

@@ -223,8 +234,6 @@ namespace hx
223234
}
224235
};
225236

226-
//
227-
228237
template<class... TArgs>
229238
class Callable<void(TArgs...)> : public ObjectPtr<Callable_obj<void(TArgs...)>>
230239
{
@@ -253,7 +262,7 @@ namespace hx
253262
Callable(::cpp::Function<void(TArgs...)> inFunction)
254263
: super(nullptr)
255264
{
256-
struct FunctionCallable final : public Callable_obj<void(TArgs... )>
265+
struct FunctionCallable final : public AutoCallable_obj<void(TArgs... )>
257266
{
258267
::cpp::Function<void(TArgs...)> func;
259268

@@ -272,7 +281,7 @@ namespace hx
272281
Callable(const Callable<TOtherReturn(TOtherArgs...)>& inCallable)
273282
: super(nullptr)
274283
{
275-
struct AdapterCallable final : public Callable_obj<void(TArgs...)>
284+
struct AdapterCallable final : public AutoCallable_obj<void(TArgs...)>
276285
{
277286
Callable<TOtherReturn(TOtherArgs...)> wrapped;
278287

@@ -313,7 +322,7 @@ namespace hx
313322
{
314323
if (::hx::IsNotNull(inDynamic) && inDynamic->__GetType() == vtFunction)
315324
{
316-
struct DynamicCallable final : public Callable_obj<void(TArgs...)>
325+
struct DynamicCallable final : public AutoCallable_obj<void(TArgs...)>
317326
{
318327
Dynamic wrapped;
319328

include/hx/Invoker.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ ::Dynamic cpp::Variant::operator()(const TArgs & ...args)
208208
}
209209

210210
template<class TReturn, class... TArgs>
211-
::Dynamic hx::Callable_obj<TReturn(TArgs...)>::__Run(const Array<Dynamic>& inArgs)
211+
::Dynamic hx::AutoCallable_obj<TReturn(TArgs...)>::__Run(const Array<Dynamic>& inArgs)
212212
{
213213
return invoker::Invoker<std::is_void<TReturn>::value, TReturn, TArgs...>::call(this, inArgs, invoker::index::Helper::index_sequence_for<TArgs...>());
214214
}

src/Array.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,7 @@ namespace cpp
690690
#if (HXCPP_API_LEVEL>=500)
691691
::hx::Callable<bool()> IteratorBase::hasNext_dyn()
692692
{
693-
struct _hx_iterator_hasNext : public ::hx::Callable_obj<bool()>
693+
struct _hx_iterator_hasNext : public ::hx::AutoCallable_obj<bool()>
694694
{
695695
::hx::ObjectPtr<IteratorBase> __this;
696696

@@ -722,7 +722,7 @@ namespace cpp
722722

723723
::hx::Callable<::Dynamic()> IteratorBase::next_dyn()
724724
{
725-
struct _hx_iterator_next : public ::hx::Callable_obj<::Dynamic()>
725+
struct _hx_iterator_next : public ::hx::AutoCallable_obj<::Dynamic()>
726726
{
727727
::hx::ObjectPtr<IteratorBase> __this;
728728

@@ -800,7 +800,7 @@ namespace cpp
800800
#define HX_VARRAY_FUNC(ret, value, name, args_list, func_list, args_call) \
801801
::hx::Callable<value(args_list)> VirtualArray_obj::name##_dyn() \
802802
{ \
803-
struct _hx_virtualarray_##name : public ::hx::Callable_obj<value(args_list)> \
803+
struct _hx_virtualarray_##name : public ::hx::AutoCallable_obj<value(args_list)> \
804804
{ \
805805
VirtualArray mThis; \
806806
_hx_virtualarray_##name(::cpp::VirtualArray inThis) : mThis(inThis) \

src/Math.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ double Math_obj::POSITIVE_INFINITY = std::numeric_limits<double>::infinity();
5757
#define HX_MATHS_FUNC(value, name, args_list, func_list, args_call) \
5858
::hx::Callable<value(args_list)> Math_obj::name##_dyn() \
5959
{ \
60-
struct _hx_maths_##name : public ::hx::Callable_obj<value(args_list)> \
60+
struct _hx_maths_##name : public ::hx::AutoCallable_obj<value(args_list)> \
6161
{ \
6262
value HX_LOCAL_RUN(func_list) override \
6363
{ \

src/String.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2126,7 +2126,7 @@ String &String::operator+=(const String &inRHS)
21262126
#define HX_STRING_FUNC(value, name, args_list, func_list, args_call) \
21272127
::hx::Callable<value(args_list)> String::name##_dyn() \
21282128
{ \
2129-
struct _hx_string_##name : public ::hx::Callable_obj<value(args_list)> \
2129+
struct _hx_string_##name : public ::hx::AutoCallable_obj<value(args_list)> \
21302130
{ \
21312131
::String mThis; \
21322132
_hx_string_##name(const ::String& inThis) : mThis(inThis) \
@@ -2167,7 +2167,7 @@ String &String::operator+=(const String &inRHS)
21672167

21682168
::hx::Callable<::String(int)> String::fromCharCode_dyn()
21692169
{
2170-
struct _hx_string_fromCharCode : public ::hx::Callable_obj<::String(HX_STRING_ARG_LIST1(int))>
2170+
struct _hx_string_fromCharCode : public ::hx::AutoCallable_obj<::String(HX_STRING_ARG_LIST1(int))>
21712171
{
21722172
::String HX_LOCAL_RUN(HX_STRING_FUNC_LIST1(int)) override
21732173
{

0 commit comments

Comments
 (0)