Hi Filip. IDK if you've figured this out or not. So here's an answer for you. From haxe you can pass the function pointer to your ExternalInterface.cpp:
public function callbackTest(onCallback:Void -> Void):Void {
myextension(onCallback);
}
static var myextension= Lib.load("extensions","myextensiontest",1);
Then the method that receives it in your ExternalInterface.cpp will receive the argument and passed into a new instance of AutoGCRoot:
AutoGCRoot * myCallback = 0;
value myextensiontest(value onComplete) {
myCallback = new AutoGCRoot(onComplete);
return alloc_null();
}
DEFINE_PRIM(myextensiontest, 1);
Then when you want to invoke the callback you use the val_call function with the number of arguments you need and invoke the callback with get():
void notifyTheHaxeCodeImDone() {
val_call0(myCallback->get());
}
if you want to pass argument back you call the appropriate val_call:
//1 arg
val_call1(myCallback->get(), someArg);
//2 args
val_call2(myCallback->get(), someArg1, someArg2);
//etc...
Hope this answers your question.