Using Haxe @: classCode

I can not find a single example of how it is @:classCodeused (to embed the native member directly in the file). This fails with Unexpected untypedat compile time:

@:classCode
untyped __java__("public void paintComponent(Graphics g) {doStuff();}"); 

I can't just use standard Haxe code to have a method paintComponent()because of how Haxe eats methods @:overload(and primarily forces use @:overload).

+4
source share
1 answer

There are several examples of this in the Haxe standard library , for example:

@:classCode('override public string Message { get { return this.toString(); } }\n\n')
@:nativeGen @:keep @:native("haxe.lang.HaxeException")
private class HaxeException extends Exception

It seems that the class code metadata has a string argument containing the code to insert, and should be used in the class declaration.

+2
source

All Articles