You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
cpp.Function fields don't compile with HXCPP_GC_GENERATIONAL #167
With HXCPP_GC_GENERATIONAL, Haxe treats a cpp.Function field as an object and writes a barrier on _hx_v.mPtr in its setter:
inline ::cpp::Function< int (int) > _hx_set_callback(::hx::StackContext *_hx_ctx,::cpp::Function< int (int) > _hx_v) { HX_OBJ_WB(this,_hx_v.mPtr) return callback=_hx_v; }
cpp::Function (include/cpp/Pointer.h) has no mPtr, so any class with a cpp.Function field fails to compile in a generational build:
error: 'class cpp::Function<int(int)>' has no member named 'mPtr'
The generator is at fault (HaxeFoundation/haxe#13001), and HaxeFoundation/haxe#13002 fixes it, but that fix is still open and only helps future compilers. HaxeFoundation/hxcpp#1425 works around it in the runtime: under HXCPP_GC_GENERATIONAL, cpp::Function gets a static null mPtr, so the barrier current compilers emit compiles and does nothing. That's correct, since a function pointer isn't a GC object, and HX_OBJ_WB already skips a null value.
libhxcpp has the same cpp::Function. The plan is to take HaxeFoundation/hxcpp#1425 with its test: a cpp.Function field in test/haxe/TestTypes.hx, which already builds with HXCPP_GC_GENERATIONAL.
Activity