[haXe] haxe/neko libraries

Nicolas Cannasse ncannasse at motion-twin.com
Sun Apr 23 20:00:13 CEST 2006


daniel fischer wrote:
> hi nicholas,
> 
> is it possible to somehow create/use precompiled haxe/neko libraries to speed up compilation and loading?
> 
> suppose i have a large C library which i want to wrap into a haxe class, i think maybe i could produce a wrapper interface (or external class) that defines the haxe class, and an implementation class that does all the neko.Lib.load() stuff and wrapper functioning. can i compile the implementing class into a .n module so that new code only has to lookup/type the wrapper? if yes, how would i load it?
> 
> i'm trying to do an OpenGL binding, and my initial (stupid?) approach results in tediously long haxe compile times. startup of the resulting neko program also takes a significant amount of time...
> 
> -dan

Hello Dan,

Yes it's possible, you have to use a neko module loaders for that (see 
http://nekovm.org/doc/vm#loaders). Please note that right now haXe 
classes are not exported, so you'll have to export them by-hand :

// in library
class MyClass {

     // code
	
     static function __init__() {
	untyped __dollar__exports.MyClass = MyClass;
     }
}

// on client side :
extern class MyClass {

     // declarations....

     static function __init__() {
	var loader = untyped __dollar__loader;
         MyClass = untyped loader.loadmodule("mylib.n",loader).MyClass;
     }

}

Nicolas



More information about the Haxe mailing list