Skip to content
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
5 changes: 4 additions & 1 deletion src/generators/cpp/cppContext.ml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,10 @@ let hash_keys hash =
!key_list

let is_gc_element ctx member_type =
Gctx.defined ctx.ctx_common Define.HxcppGcGenerational && (is_object_element member_type)
Gctx.defined ctx.ctx_common Define.HxcppGcGenerational &&
match member_type with
| CppAst.TCppFunction _ -> false
| _ -> is_object_element member_type

let strip_file ctx file = match Gctx.defined ctx Define.AbsolutePath with
| true -> Path.get_full_path file
Expand Down
20 changes: 20 additions & 0 deletions tests/misc/cpp/projects/Issue13001/Main.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
class Main {
static function main():Void {
var holder = new NativeCallbackHolder(cpp.Callable.fromStaticFunction(increment));
if (holder.callback.call(41) != 42) {
throw "Invalid native callback result";
}
}

static function increment(value:Int):Int {
return value + 1;
}
}

class NativeCallbackHolder {
public var callback:cpp.Function<Int->Int, cpp.abi.Abi>;

public function new(callback:cpp.Function<Int->Int, cpp.abi.Abi>) {
this.callback = callback;
}
}
3 changes: 3 additions & 0 deletions tests/misc/cpp/projects/Issue13001/compile.hxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-main Main
-D HXCPP_GC_GENERATIONAL
-cpp out