Skip to content
Merged
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
9 changes: 7 additions & 2 deletions include/Array.h
Original file line number Diff line number Diff line change
Expand Up @@ -1411,7 +1411,7 @@ namespace hx
template<class ELEM_> \
::hx::Callable<value(args_list)> Array_obj<ELEM_>::name##_dyn() \
{ \
struct _hx_array_##name : public ::hx::AutoCallable_obj<value(args_list)> \
struct _hx_array_##name final : public ::hx::AutoCallable_obj<value(args_list)> \
{ \
Array<ELEM_> mThis; \
_hx_array_##name(Array<ELEM_> inThis) : mThis(inThis) \
Expand All @@ -1422,6 +1422,7 @@ namespace hx
{ \
ret mThis->name(args_call); \
} \
void *__GetHandle() const override { return mThis.GetPtr(); } \
void __Mark(hx::MarkContext *__inCtx) { HX_MARK_MEMBER(mThis); } \
ARRAY_VISIT_FUNC \
int __Compare(const ::hx::Object* inRhs) const override \
Expand Down Expand Up @@ -1460,7 +1461,7 @@ template<class ELEM_>
template<class TO>
::hx::Callable<Array<TO>(::hx::Callable<TO(ELEM_)>)> Array_obj<ELEM_>::map_dyn()
{
struct _hx_array_map : public ::hx::AutoCallable_obj<Array<TO>(::hx::Callable<TO(ELEM_)>)>
struct _hx_array_map final : public ::hx::AutoCallable_obj<Array<TO>(::hx::Callable<TO(ELEM_)>)>
{
Array<ELEM_> mThis;
_hx_array_map(Array<ELEM_> inThis) : mThis(inThis)
Expand All @@ -1483,6 +1484,10 @@ ::hx::Callable<Array<TO>(::hx::Callable<TO(ELEM_)>)> Array_obj<ELEM_>::map_dyn()
if (mThis != casted->mThis) return -1;
return 0;
}
void* __GetHandle() const override
{
return mThis.GetPtr();
}
};

return new _hx_array_map(this);
Expand Down
25 changes: 25 additions & 0 deletions include/hx/Functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,11 @@ namespace hx
return wrapped(args...);
}

void* __GetHandle() const override
{
return wrapped.GetPtr();
}

inline void __Mark(hx::MarkContext* __inCtx) override
{
HX_MARK_MEMBER(wrapped);
Expand Down Expand Up @@ -165,6 +170,11 @@ namespace hx
return null();
}

void* __GetHandle() const override
{
return wrapped.GetPtr();
}

inline void __Mark(hx::MarkContext* __inCtx) override
{
HX_MARK_MEMBER(wrapped);
Expand Down Expand Up @@ -206,6 +216,11 @@ namespace hx
return wrapped(args...);
}

void* __GetHandle() const override
{
return wrapped.GetPtr();
}

inline void __Mark(hx::MarkContext* __inCtx) override
{
HX_MARK_MEMBER(wrapped);
Expand Down Expand Up @@ -295,6 +310,11 @@ namespace hx
wrapped(args...);
}

void* __GetHandle() const override
{
return wrapped.GetPtr();
}

inline void __Mark(hx::MarkContext* __inCtx) override
{
HX_MARK_MEMBER(wrapped);
Expand Down Expand Up @@ -336,6 +356,11 @@ namespace hx
wrapped(args...);
}

void* __GetHandle() const override
{
return wrapped.GetPtr();
}

inline void __Mark(hx::MarkContext* __inCtx) override
{
HX_MARK_MEMBER(wrapped);
Expand Down
15 changes: 13 additions & 2 deletions src/Array.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,7 @@ namespace cpp
#if (HXCPP_API_LEVEL>=500)
::hx::Callable<bool()> IteratorBase::hasNext_dyn()
{
struct _hx_iterator_hasNext : public ::hx::AutoCallable_obj<bool()>
struct _hx_iterator_hasNext final : public ::hx::AutoCallable_obj<bool()>
{
::hx::ObjectPtr<IteratorBase> __this;

Expand All @@ -704,6 +704,11 @@ namespace cpp
return __this->hasNext();
}

void* __GetHandle() const override
{
return __this.GetPtr();
}

void __Mark(hx::MarkContext* __inCtx) final override
{
HX_MARK_MEMBER(__this);
Expand Down Expand Up @@ -736,6 +741,11 @@ namespace cpp
return __this->_dynamicNext();
}

void* __GetHandle() const override
{
return __this.GetPtr();
}

void __Mark(hx::MarkContext* __inCtx) final override
{
HX_MARK_MEMBER(__this);
Expand Down Expand Up @@ -800,7 +810,7 @@ namespace cpp
#define HX_VARRAY_FUNC(ret, value, name, args_list, func_list, args_call) \
::hx::Callable<value(args_list)> VirtualArray_obj::name##_dyn() \
{ \
struct _hx_virtualarray_##name : public ::hx::AutoCallable_obj<value(args_list)> \
struct _hx_virtualarray_##name final : public ::hx::AutoCallable_obj<value(args_list)> \
{ \
VirtualArray mThis; \
_hx_virtualarray_##name(::cpp::VirtualArray inThis) : mThis(inThis) \
Expand All @@ -811,6 +821,7 @@ namespace cpp
{ \
ret mThis->name(args_call); \
} \
void* __GetHandle() const override { return mThis.GetPtr(); } \
void __Mark(hx::MarkContext *__inCtx) { HX_MARK_MEMBER(mThis); } \
ARRAY_VISIT_FUNC \
int __Compare(const ::hx::Object* inRhs) const override \
Expand Down
2 changes: 1 addition & 1 deletion src/Math.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ double Math_obj::POSITIVE_INFINITY = std::numeric_limits<double>::infinity();
#define HX_MATHS_FUNC(value, name, args_list, func_list, args_call) \
::hx::Callable<value(args_list)> Math_obj::name##_dyn() \
{ \
struct _hx_maths_##name : public ::hx::AutoCallable_obj<value(args_list)> \
struct _hx_maths_##name final : public ::hx::AutoCallable_obj<value(args_list)> \
{ \
value HX_LOCAL_RUN(func_list) override \
{ \
Expand Down
3 changes: 2 additions & 1 deletion src/String.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2275,7 +2275,7 @@ String &String::operator+=(const String &inRHS)
#define HX_STRING_FUNC(value, name, args_list, func_list, args_call) \
::hx::Callable<value(args_list)> String::name##_dyn() \
{ \
struct _hx_string_##name : public ::hx::AutoCallable_obj<value(args_list)> \
struct _hx_string_##name final : public ::hx::AutoCallable_obj<value(args_list)> \
{ \
::String mThis; \
_hx_string_##name(const ::String& inThis) : mThis(inThis) \
Expand All @@ -2290,6 +2290,7 @@ String &String::operator+=(const String &inRHS)
{ \
mThis = inThis; \
} \
void* __GetHandle() const override { return const_cast<char *>(mThis.raw_ptr()); } \
void __Mark(hx::MarkContext *__inCtx) { HX_MARK_MEMBER(mThis); } \
STRING_VISIT_FUNC \
int __Compare(const ::hx::Object* inRhs) const override \
Expand Down
16 changes: 12 additions & 4 deletions test/haxe/gc/TestGC.hx
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,18 @@ class TestGC extends Test {
return clearStack(count-1);
}

// NOTE : previously the objects below were created in the same thread as the assertions and the clear
// stack function above attempted to remove references to it so it was eligable for collection.
// With the callable changes it seems clang can do some more aggressive optimisations which broke these tests,
// so now the objects are created on a separate thread and we sleep for 1s to give time for the threads to exit and unregister from the GC.

function createAbc():Void {
var object = { test: "abc" };
Gc.doNotKill(object);
}
public function testObject():Void {
create(createAbc);
sys.thread.Thread.create(createAbc);
Sys.sleep(1);
var zombie:Dynamic = gc();
Assert.notNull(zombie);
Assert.equals("abc", zombie.test);
Expand Down Expand Up @@ -68,7 +73,8 @@ class TestGC extends Test {
Gc.doNotKill(object);
};
public function testFunc():Void {
create(createFunction);
sys.thread.Thread.create(createFunction);
Sys.sleep(1);
var zombie:Dynamic = gc();
Assert.notNull(zombie);
Assert.equals("abc", zombie());
Expand All @@ -80,7 +86,8 @@ class TestGC extends Test {
Gc.doNotKill(object);
};
public function testCustomObject():Void {
create(createCustom);
sys.thread.Thread.create(createCustom);
Sys.sleep(1);
var zombie = gc();
Assert.notNull(zombie);
Assert.isOfType(zombie, CustomObject);
Expand All @@ -92,7 +99,8 @@ class TestGC extends Test {
Gc.doNotKill(object);
};
public function testBytes():Void {
create(createBytes);
sys.thread.Thread.create(createBytes);
Sys.sleep(1);
var zombie = gc();
Assert.notNull(zombie);
Assert.isOfType(zombie, Bytes);
Expand Down