Note! Created a repo to replace this gist: https://github.com/cambiata/Haxe-Cppia-Basics Easier to testrun, fork and pr! Thanks, @PDeveloper!
This is a simple testproject created for the single purpose of learning how to use cppia, the scripable "cpp subtarget" for Haxe, created by Hugh Sanderson.
Info about cppia can be found in Hugh's WWX2015 talk (cppia part starts around 15:45).
Please note that this is WORK IN PROGRESS, and that I haven't yet found out to create a working cppia host..! Please step in with discussion and contributions!
A cppia script is a "instructions assembly" script that can be run by inside a cppia host, and gives you Neko JIT runtime speed at near-zero compilation time. It also lets add performance critical code to the host, wich gives you full cpp runtime speed for those parts.
The script.hxml file below should be compiled as follows:
> haxe script.hxml
Please note the -D cppia
compilation flag that tells the compiler to output a cppia script (bin/script.cppia) instead of a standard cpp executable.
The bin/script.cppia can be tested by using the cppia host included with the standard haxelib hxcpp installation, as follows:
> cd bin
> haxelib run hxcpp script.cppia
This should output the following:
> Main.hx:4: Hello from cppia SCRIPT
The host.hxml file below should be compiled as follows:
> haxe host.hxml
Please note the -D scriptable
compilation flag that tells the compiler to include what's needed to act like a cppia host (bin/Main.exe).
##Problem!
The line Main.hx:9 is my attempt to load and run the script.cppia into the Main.exe host. Unfortunately, it doesn't work. The only thing that happens is that some kind of loop is kicked of wich prints out the host line 7 multiple times:
> Main.hx:7: Hello from cppia HOST!
> Main.hx:7: Hello from cppia HOST!
> Main.hx:7: Hello from cppia HOST!
etc. without sign that the script code is ever run.
Thank, you, @PDeveloper! Sure, I'll create a repo!