Git Product home page Git Product logo

haxe-c-bridge's Introduction

Haxe C Bridge

HaxeCBridge is a @:build macro that enables calling haxe code from C by exposing classes via an automatically generated C header. This makes it possible to build your user interfaces using native platform tools (like Swift and Java) and call into haxe code for the main app work like rendering

Requires haxe 4.0 or newer and hxcpp

Quick Start

Install with haxelib install haxe-c-bridge (or simply copy the HaxeCBridge.hx file into your root class-path)

Haxe-side:

  • Add --library haxe-c-bridge to your hxml
  • Add -D dll_link or -D static_link to your hxml to compile your haxe program into a native library binary
  • Add @:build(HaxeCBridge.expose()) to classes that you want to expose to C (you can add this to as many classes as you like – all functions are combined into a single header file)
  • HaxeCBridge will then generate a header file in your build output directory named after your --main class (however a --main class is not required to use HaxeCBridge)

C-side:

  • #include the generated header and link with the hxcpp generated library binary
  • Before calling any haxe functions you must start the haxe thread: call YourLibName_initializeHaxeThread(onHaxeException)
  • Now interact with your haxe library thread by calling the exposed functions
  • When your program exits call YourLibName_stopHaxeThread(true)

See test/unit for a complete example

Minimal Example

Main.hx

class Main {
	static function main() {
		trace("haxe thread started!");
	}
}

@:build(HaxeCBridge.expose())
class UseMeFromC {

	final callback: cpp.Callable<(num: Int) -> Void>;

	public function new(nativeCallback: cpp.Callable<(num: Int) -> Void>) {
		this.callback = nativeCallback;
	}

	public function add(a: Int, b: Int) {
		var result = a + b;
		callback(result);
		return result;
	}

	static public function exampleStaticFunction() {
		return "here's a string from haxe! In C this will be represented as a const char*. When passing haxe object to C, the object will be retained so it's not garbage collected while it's being used in C. When finished with haxe objects, you can call releaseHaxeString() or releaseHaxeObject()";
	}

}

build.hxml

--main Main
--cpp bin
--dce full
-D dll_link

Then run haxe build.hxml to compile the haxe code into a native library binary

This will generate a header file: bin/Main.h with our haxe function exposed as:

HaxeObject Main_UseMeFromC_new(function_Int_Void exampleCallback);
int Main_UseMeFromC_add(HaxeObject instance, int a, int b);
HaxeString Main_UseMeFromC_exampleStaticFunction();

We can use our class from C like so:

void onHaxeException(const char* info) {
	printf("Haxe exception: \"%s\"\n", info);
	// stop the haxe thread immediately
	Main_stopHaxeThreadIfRunning(false);
}

void exampleCallback(int num) {
	printf("exampleCallback(%d)\n", num);
}

int main(void) {
	// start the haxe thread
	Main_initializeHaxeThread(onHaxeException);

	// create an instance of our haxe class
	HaxeObject instance = Main_UseMeFromC_new(exampleCallback);
	// to call members of instance, we pass the instance in as the first argument
	int result = Main_UseMeFromC_add(instance, 1, 2);
	// when we're done with our object we can tell the haxe-gc we're finished
	Main_releaseHaxeObject(instance);

	// call a static function
	HaxeString cStr = Main_UseMeFromC_exampleStaticFunction();
	printf("%s\n", cStr);
	Main_releaseHaxeString(cStr);

	// stop the haxe thread but wait for any scheduled events to complete
	Main_stopHaxeThreadIfRunning(true);

	return 0;
}

Background

C is a common language many platforms use to glue to one another. It's always been relatively easy to call C code from haxe using haxe C++ externs (or simply untyped __cpp__('c-code')) but it's much harder to call haxe code from C: while hxcpp can generate C++ declarations with @:nativeGen, you need to manually create adaptors for these to use with C. Additionally you have to take care to manage the haxe event loop and interaction with the haxe garbage collector.

This library plugs that gap by automatically generating safe function bindings, managing the event loop and taking care of converting exposed types to be C compatible and GC-safe.

A separate thread is used to host the haxe execution and the haxe event loop so events scheduled in haxe will continue running in parallel to the rest of your native app. When calling haxe functions from C, the haxe code will be executed synchronously on this haxe thread so it's safe for functions exposed to C to interact with the rest of your haxe code. You can disable haxe thread synchronization by adding @externalThread however this is less safe and you must then perform main thread synchronization yourself.

Meta

  • @HaxeCBridge.name – Can be used on functions and classes. On classes it sets the class prefix for each generated function and on functions it sets the complete function name (overriding prefixes)
  • @externalThread – Can be used on functions. When calling a haxe function with this metadata from C that function will be executed in the haxe calling thread, rather than the haxe main thread. This is faster but less safe – you cannot interact with any other haxe code without first synchronizing with the haxe main thread (or your app is likely to crash)

Compiler Defines

  • -D HaxeCBridge.name=YourLibName – Set the name of the generated header file as well as the prefix to all generated C types and functions
  • -D dll_link – A hxcpp define to compile your haxe code into a dynamic library (.dll, .dylib or .so on windows, mac and linux)
  • -D static_link – A hxcpp define to compile your haxe code into a static library (.lib on windows or .a on mac and linux)

haxe-c-bridge's People

Contributors

haxiomic avatar ilir-liburn avatar pxshadow avatar skylerparr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

haxe-c-bridge's Issues

Why does EventLoop reset the wake lock?

So that event loop doesn't spin needlessly; every call to queue an event wakes the lock, but we only need one lock release to process all events. So the wait loop internal counter is cleared to 0 prior to processing the events

This causes a hang (which could be resolved by acquiring the mutex but that requires attaching to haxe thread)

Support ADT enums

  • Detect if enum data is not used and expose c-style enum in this case

build failure

Hello,

run.win from test/unit is giving me error on hxcpp 4.2.1. What I'm doing wrong?

Error: GcRegCapture.cpp
C:/HaxeToolkit/haxe/lib/haxe-c-bridge/0,7,0/test/unit/.haxelib/hxcpp/4,2,1/src/hx/gc/GcRegCapture.cpp(53): error C2039: 'Rbx': is not a member of '_CONTEXT'
C:\Program Files (x86)\Windows Kits\10\include\10.0.14393.0\um\winnt.h(7243): note: see declaration of '_CONTEXT'
C:/HaxeToolkit/haxe/lib/haxe-c-bridge/0,7,0/test/unit/.haxelib/hxcpp/4,2,1/src/hx/gc/GcRegCapture.cpp(54): error C2039: 'Rbp': is not a member of '_CONTEXT'
C:\Program Files (x86)\Windows Kits\10\include\10.0.14393.0\um\winnt.h(7243): note: see declaration of '_CONTEXT'
C:/HaxeToolkit/haxe/lib/haxe-c-bridge/0,7,0/test/unit/.haxelib/hxcpp/4,2,1/src/hx/gc/GcRegCapture.cpp(55): error C2039: 'Rdi': is not a member of '_CONTEXT'
C:\Program Files (x86)\Windows Kits\10\include\10.0.14393.0\um\winnt.h(7243): note: see declaration of '_CONTEXT'
C:/HaxeToolkit/haxe/lib/haxe-c-bridge/0,7,0/test/unit/.haxelib/hxcpp/4,2,1/src/hx/gc/GcRegCapture.cpp(56): error C2039: 'R12': is not a member of '_CONTEXT'
C:\Program Files (x86)\Windows Kits\10\include\10.0.14393.0\um\winnt.h(7243): note: see declaration of '_CONTEXT'
C:/HaxeToolkit/haxe/lib/haxe-c-bridge/0,7,0/test/unit/.haxelib/hxcpp/4,2,1/src/hx/gc/GcRegCapture.cpp(57): error C2039: 'R13': is not a member of '_CONTEXT'
C:\Program Files (x86)\Windows Kits\10\include\10.0.14393.0\um\winnt.h(7243): note: see declaration of '_CONTEXT'
C:/HaxeToolkit/haxe/lib/haxe-c-bridge/0,7,0/test/unit/.haxelib/hxcpp/4,2,1/src/hx/gc/GcRegCapture.cpp(58): error C2039: 'R14': is not a member of '_CONTEXT'
C:\Program Files (x86)\Windows Kits\10\include\10.0.14393.0\um\winnt.h(7243): note: see declaration of '_CONTEXT'
C:/HaxeToolkit/haxe/lib/haxe-c-bridge/0,7,0/test/unit/.haxelib/hxcpp/4,2,1/src/hx/gc/GcRegCapture.cpp(59): error C2039: 'R15': is not a member of '_CONTEXT'
C:\Program Files (x86)\Windows Kits\10\include\10.0.14393.0\um\winnt.h(7243): note: see declaration of '_CONTEXT'
C:/HaxeToolkit/haxe/lib/haxe-c-bridge/0,7,0/test/unit/.haxelib/hxcpp/4,2,1/src/hx/gc/GcRegCapture.cpp(60): error C2039: 'Xmm0': is not a member of '_CONTEXT'
C:\Program Files (x86)\Windows Kits\10\include\10.0.14393.0\um\winnt.h(7243): note: see declaration of '_CONTEXT'
C:/HaxeToolkit/haxe/lib/haxe-c-bridge/0,7,0/test/unit/.haxelib/hxcpp/4,2,1/src/hx/gc/GcRegCapture.cpp(60): error C2660: 'memcpy': function does not take 2 arguments

Consider converting instance fields

class Example {
    public function new(str: String);
    public function method(x: Int): Example;
}

Would generate the following C functions

HaxeObject Example_new();
HaxeObject Example_method(HaxeObject instance, int x);

And automatically apply the retainer wrapping/unwrapping

Is not work for Haxe 4.3.3?

Is not work for Haxe 4.3.3?

-cp src
-D analyzer-optimize
Main
-cpp bin/cpp
-D static_link
--dce full
-D HaxeCBridge.name=HaxeLib

there is no HaxeLib.h gen in bin/cpp forlder. but 4.2.4 have.

C++ and Objective-C dependencies into C?

Hey
I got great instructions in the Haxe community forums, and it worked out well for Haxe code to compile and be used in a watchOS project in swift (via an Objective-C bridging header file).
I wonder though when it come to dependencies - is it restricted strictly C - or can Cpp be used like LucenePlusPlus in the watchOS projects as well?
My understanding so far about haxe in general is that the project becomes tied and dependent to for instance Java - if you use a Java dependency in Haxe. But I am inexperienced in the realm of C, C++ and Objective-C, and HaxeCBridge for that matter.
So can I pick out C++ and Objective C dependencies, and have it compiled into C still?

How to make GC not recycle a variable

Hi, this question has nothing to do with the haxe-c-bridge, but I'd like to know the answer. I'm using the static library file (. A) on the openfl thread now, but I find that the address error often occurs. I guess it's caused by GC, so is there a way not to be recycled by GC. @haxiomic

Not generating code on Linux

It seems like target-name != cpp is failing even though I am building in CPP mode... any ideas if this is a linux limitation of haxe or what?

Consider automatic retainers

All haxe object types that have no C equivalent could be automatically wrapped with Retainer at the interface – what are the reasons not to do this?

  • Obscures useful hints, for example if the user uses a haxe callback or haxe Array, it'll just generate HaxeObject in C rather than hint about cpp.Callable and cpp.Pointer
    • Can still hint this case
    • Maybe we can convert Array to a C struct with length and array pointer
  • Perhaps unclear returned objects are retained until manual release

Refcount for retainHaxeObject ?

Right now there is no refcount with retainHaxeObject. That means that if two methods are called which both return the same object (or the same method twice, etc) by different parts of the C code, then one part of the C code calls release the GC may free it even though there is still a reference on the C side.

Dynamic type

Hello,

I tried using Dynamic type via haxe-c-bridge and it works! The most interesting part is happening due to memory alignment ( see printDynamicType function ).

Now I wonder if there is a better way to get ValueType ( outside of the Haxe code or by reducing the Haxe code ).

Edit:

I tested this using Win32 because I don't have 64 bit version of cl, can't compile 64bit version even gcc 64 bit version is used ( see #38 )

[ add to src/Main.hx at Main class ]

	static public function getDynamicInt() {
		var val:Int = -1; 
		var dyn:Any = val;
		return dyn;
	}

	static public function getDynamicFloat() {
		var val:Float = 99234234.99234234; 
		var dyn:Any = val;
		return dyn;
	}

	static public function getDynamicType(dyn:Any) {
		var idx = Type.typeof(dyn).getIndex();
		var arr = Type.getEnumConstructs(Type.ValueType);
		trace("HaxeEnumType = " + arr[idx]);
		return idx; 
	}

[ add to App.c ]

enum HaxeValueType
{
	TNull = 0,
	TInt = 1,
	TFloat = 2,
	TBool = 3,
	TObject = 4,
	TFunction = 5,
	TClass = 6,
	TEnum = 7,
	TUnknown = 8
};

void printDynamicType(enum HaxeValueType en,HaxeObject *obj) {
	switch (en) {
		default :
			printf("HaxeDynamicValue = Unknown (temporary:)\n");
			break ;
		case TInt :
			printf("HaxeDynamicValue = %d\n",((int *)obj)[1]);
			break ;
		case TFloat :
			printf("HaxeDynamicValue = %f\n",((double *)obj)[1]);
			break ;
	}
}

	HaxeObject int_obj = HaxeLib_Main_getDynamicInt();
	enum HaxeValueType int_en = HaxeLib_Main_getDynamicType(int_obj);
	printDynamicType(int_en,int_obj);

	HaxeObject float_obj = HaxeLib_Main_getDynamicFloat();
	enum HaxeValueType float_en = HaxeLib_Main_getDynamicType(float_obj);
	printDynamicType(float_en,float_obj);

Build errors when using README example

Hello. This is a really cool project. This is something I really need. Unfortunately, I'm running into some build errors on the example and I'm currently stuck.

here's my setup:
Windows 10

$ haxe --version
4.2.3

build.hxml

-cp src
-cp deps/haxe-c-bridge
-main Main
-cpp out
--dce full
-D dll_link

deps/haxe-c-bridge is a clone of master

hxcpp version:

  haxelib install hxcpp
You already have hxcpp version 4.2.1 installed

Main.hx code:

package;

class Main {
    public static function main():Void {
        trace("hello world");
    }
}

@:build(HaxeCBridge.expose())
class UseMeFromC {

    final callback: cpp.Callable<(num: Int) -> Void>;

    public function new(nativeCallback: cpp.Callable<(num: Int) -> Void>) {
        this.callback = nativeCallback;
    }

    public function add(a: Int, b: Int) {
        var result = a + b;
        callback(result);
        return result;
    }

    static public function exampleStaticFunction() {
        return "here's a string from haxe! In C this will be represented as a const char*. When passing haxe object to C, the object will be retained so it's not garbage collected while it's being used in C. When finished with haxe objects, you can call releaseHaxeString() or releaseHaxeObject()";
    }

}

My build error

Error: __HaxeCBridgeBindings__.cpp
./src/__HaxeCBridgeBindings__.cpp(30): error C2086: 'void *param': redefinition
./src/__HaxeCBridgeBindings__.cpp(33): error C2065: 'pthread_t': undeclared identifier
./src/__HaxeCBridgeBindings__.cpp(33): error C2146: syntax error: missing ')' before identifier 'handle'
./src/__HaxeCBridgeBindings__.cpp(33): error C2143: syntax error: missing ';' before '{'
./src/__HaxeCBridgeBindings__.cpp(33): error C2447: '{': missing function header (old-style formal list?)
./src/__HaxeCBridgeBindings__.cpp(150): error C7555: use of designated initializers requires at least '/std:c++latest'
./src/__HaxeCBridgeBindings__.cpp(200): error C2039: 'waitForThreadExit': is not a member of 'HaxeCBridgeInternal'
./src/__HaxeCBridgeBindings__.cpp(22): note: see declaration of 'HaxeCBridgeInternal'
./src/__HaxeCBridgeBindings__.cpp(200): error C3861: 'waitForThreadExit': identifier not found

Error: Build failed

Getting a build error on Linux too, but I'm less concerned about Linux not working, but here it is anyway:

Error: ./src/__HaxeCBridgeBindings__.cpp:38:37: error: cannot convert ‘std::nullptr_t’ to ‘pthread_t’ {aka ‘long unsigned int’} in initialization
   38 |  pthread_t haxeThreadNativeHandle = nullptr;
      |                                     ^~~~~~~
Error: Build failed

LMK if you have any clues. I'll be trying to debug on my end and if I find something I'll push up a PR.

Thanks again for the cool library.

./src/UseMeFromC.cpp(164): error C2065: 'Person': undeclared identifier

hello ,I need inlucde extra head files to my cpp .\

@:include("D:/vcpkg/vcpkg/packages/fmt_x64-windows/include/fmt/core.h")
@:include("D:/projects/testdll/usedll/usedll/Person.cpp")
@:native("Person*")


extern class Person {
	@:native("new Person") public static function create():Person;

    @:native("setName") public function setName(name:String):Void;
	@:native("sayGreeting") public function sayHello():Void;
	@:native("test2022") public function test2022():Void;

}  

and my cpp

#include "Person.h"


#include <cstdio>

#include "fmt/core.h"

void Person::setName(const char* str)
{
	name = str;
}
void Person::sayGreeting()
{

	printf("Hello, my name is %s\n", name);
	
}

void Person::test2022()
{
	printf("test2022\n");

	fmt::print("test2022\n");
	
}

and got this error.

./src/UseMeFromC.cpp(164): error C2065: 'Person': undeclared identifier
./src/UseMeFromC.cpp(164): error C2065: 'p': undeclared identifier
./src/UseMeFromC.cpp(164): error C2061: syntax error: identifier 'Person'
./src/UseMeFromC.cpp(165): error C2065: 'p': undeclared identifier
./src/UseMeFromC.cpp(166): error C2065: 'p': undeclared identifier
./src/UseMeFromC.cpp(167): error C2065: 'p': undeclared identifier

Extern generator for C

need to be able to call into C code from haxe with automatically generated externs and bindings

ideally as a macro but otherwise as a command line tool

dynamic linking

Hello,

I use dynamic linking (-D dll_link) to link haxe-c-bridge dynamic library to my dynamic library.

Linking works, haxe-c-bridge extern C functions are called successfully in my dynamic library, but app is crashing at exit (detected using post-mortem debugger feature).

I tried using exit(0) at the end, hoping system gets another route for cleanup, but that doesn't solve the issue. Any idea?

ASAN Crash

app.c:55: Hello From C
app.c:60: Starting haxe thread
app.c:67: Testing calls to haxe code
Main.hx:26: main()
app.c:69: GC Memory: 0
app.c:111: sleeping 1s to let the haxe thread event loop run (each loop waits 1ms)
app.c:113: -> HaxeLib_Main_getLoopCount() => 722
app.c:117: Trying loads of calls into the haxe main thread to measure synchronization and memory costs ...
AddressSanitizer:DEADLYSIGNAL
=================================================================
==33120==ERROR: AddressSanitizer: BUS on unknown address 0x000104d22118 (pc 0x000104d6c193 bp 0x7000022956d0 sp 0x700002294e60 T1)
    #0 0x104d6c192 in sys::thread::EventLoop_obj::loop() EventLoop.cpp
    #1 0x104d5c1d4 in sys::thread::_Thread::Thread_Impl__obj::processEvents() Thread_Impl_.cpp:65
    #2 0x104db7c4a in __hxcpp_main __main__.cpp:31
    #3 0x104d55aee in HaxeEmbed::runUserMain(cpp::Function<void ()>, cpp::Function<void (char const*)>) HaxeEmbed.cpp:71
    #4 0x104da61dd in haxeMainThreadFunc(void*) __HaxeLib__.cpp:70
    #5 0x7fff79a512ea in _pthread_body (libsystem_pthread.dylib:x86_64+0x32ea)
    #6 0x7fff79a54248 in _pthread_start (libsystem_pthread.dylib:x86_64+0x6248)
    #7 0x7fff79a5040c in thread_start (libsystem_pthread.dylib:x86_64+0x240c)

==33120==Register values:
rax = 0x0000000104d22118  rbx = 0x0000700002295120  rcx = 0x00001000209a4423  rdx = 0x0000100000000000  
rdi = 0x0000700002294f40  rsi = 0x0000100000000000  rbp = 0x00007000022956d0  rsp = 0x0000700002294e60  
 r8 = 0x0000700002294d00   r9 = 0x0000617000010000  r10 = 0x0000617000010048  r11 = 0x00001c2e00002009  
r12 = 0x0000700002294fd0  r13 = 0x0000700002294ff0  r14 = 0x0000700002294fa0  r15 = 0x0000700002294fc0  
AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: BUS EventLoop.cpp in sys::thread::EventLoop_obj::loop()
Thread T1 created by T0 here:
    #0 0x10517978d in wrap_pthread_create (libclang_rt.asan_osx_dynamic.dylib:x86_64h+0x5978d)
    #1 0x104da6db0 in HxCreateDetachedThread(void* (*)(void*), void*) Thread.h:229
    #2 0x104da6943 in HaxeLib_initializeHaxeThread __HaxeLib__.cpp:97
    #3 0x1048b3f69 in main app.c:61
    #4 0x7fff7985d3d4 in start (libdyld.dylib:x86_64+0x163d4)

==33120==ABORTING
make: *** [run] Abort trap: 6
The terminal process "/bin/bash '-c', 'make -f Makefile.mac run'" terminated with exit code: 2.

programPath "Bind failed"

programPath "Bind failed"

is this hxcpp error or c-bridge issue?

var currentFolder = Sys.programPath;

		trace('current folder: ' + currentFolder);


		var env=currentFolder+"/3.1/datafiles/colormanagement/config.ocio";

		Sys.putEnv("OCIO",env);

Return Array<T>

I am noticing I get a message from setting the return type to Array<String> of a method, when compiling:

Array is not supported for C export, try using cpp.Pointer instead

When try to walk around using a List<T> I can compile, but the method's return type is given as HaxeObject

Is there some way I can construct a suitable array to be returned - and receiving array or list out from the haxe environment?

Trying to get this working with Unreal Engine : MT / MD mismatch?

So - the haxe-c-bridge sounds really awesome. I would love to add lib or dll files built from Haxe to use in Unreal Engine.
For now i am experimenting a bit here - trying to build a .lib file (win64) to do just that.

But im stuck here with this build error in Unreal when adding the .h and .lib file from the haxe-c-bridge output:
mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease'

Guess there is a mismatch with MT / MD here.
Havent found a good way to make it work yet - Unreal wont accept MT it seems and Haxe-C-Bridge / hxcpp complains when i try to set /MD.

Any good suggestions on how to approach this?

Prep for release

  • convert to C after typing
  • fix Main_Main_name() problem
  • stop could have the option to wait for scheduled events
    • waitUntilEventLoop empty is nice but new events can be scheduled afterwards before a stop call
    • stopHaxeThreadAfterPendingEvents() ?
    • stopHaxeThreadIfRunning(bool waitOnScheduledEvents)?
  • stop should be clear it can be called many times safely: stopHaxeThreadIfRunning()?
  • test options for returning a haxe object, maybe Pointer is the right approach here because it may increment the reference count
  • check for content change before saving implementation cpp since this will be faster
  • [ ] allow haxe thread to start again
    • unresolved issues with the hxcpp GC – seems to hang (see test branch)
  • HaxeObject wrapper to enable returning any object to C while retaining a GC reference (also add new C function releaseHaxeObject())
  • consider renaming to C.hx or HaxeC.hx
  • add metadata like @c.name
  • docs
    • update C function docs
    • header comment
    • what types can be used with C
      • GC safe haxe object passing example
    • worked example from scratch
    • minimal OpenGL example
  • license

Review non-trivial type convesion

Types

  • Strings
  • cpp.Pointer
  • cpp.Callable
  • cpp.Function
  • int enums because enum T -> int is implicit but int -> enum T requires explicit cast

  • fine as plain arguments?
  • disallowed as secondary types, ie Pointer(T) and FunctionType(...)

Expose functions generated by another @:build / @:autobuild macro?

Hi!
So, i have a build macro that generates some functions for me on a class
and im trying to get this exposed to haxe-c-bridge.

I'm getting code completion on the generated functions and looking at the source they are there too.
But they are not being picked up and exposed in the generated .h file from haxe-c-bridge...
So would this be an issue of autobuild order problems? - i've tried several ways of doing it but its not really helping.

Any good ideas here ? :)

Is this not support Map?

I want to put all callback function input a map,and recall that by map key ,I do a test,but not work

var cameraFunctionMap:Map<String, cpp.Callable<(x:Float, y:Float, z:Float) -> Void>> = [];

Main_UseMeFromC_regeditCallbackFunction(instance ,"camera_move", onCameraMove);
Main_UseMeFromC_regeditCallbackFunction(instance, "camera_rotate", onCameraRotate);
Main_UseMeFromC_regeditCallbackFunction(instance, "camera_zoom", onCameraZoom);

and haxe call

cameraFunctionMap["camera_move"](1,2,3);//not work?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.