I'm trying to create JS externs to use
Gibberish in my HTML5 game.
Gibberish has a rather unorthodox structure, and I'm having trouble properly reflecting that with my extern definitions.
Here is the basic hello world example in JS:
Gibberish.init();
a = new Gibberish.Sine().connect();
The Gibberish class here is purely static, and it contains a static reference to the class Sine, which is instanced, and then the connect method of Sine is called.
Here is my attempt at building an extern for this:
extern class Gibberish {
static public function init(?bufferSize:Int):Void;
static public var Sine:Sine;
}
extern class Sine {
public function new();
public function connect():Sine;
}
Which does compile my haxe code
Gibberish.init();
var a = new Gibberish.Sine().connect();
but the JS output is wrong:
Gibberish.init();
var a = new Sine().connect();
This gives me an error that Sine is not defined, since it doesn't exist in the global scope, only under Gibberish.Sine.
So, what can I do to avoid this problem? I really don't want to port the entire library to Haxe, or heavily restructure the JS code to play well with the externs.