ammer
ammer copied to clipboard
Defines and flags
(heavily inspired by libuv/asys work of course)
It should be possible to easily declare constants which would normally be accessible in C by including the headers of the library. A specialisation for "flags" fields, i.e. integer constants meant to combined with bitwise-OR would be useful.
Something like:
class Foobar extends ammer.Library<"foobar"> {
@:ammer.native("FOOBAR_EXAMPLE") public static var example:Int;
@:ammer.native("FOOBAR_ELPMAXE") public static var elpmaxe:Int;
}
Should create a glue method in the C stubs that will be called during static initialisation. The method will simply return an array of the required values.
int *glue_foobar_ints(void) {
return {
FOOBAR_EXAMPLE,
FOOBAR_ELPMAXE
};
}
And then:
class Foobar_Impl {
static function __init__():Void {
var ints = glue_foobar_ints();
Foobar.example = ints[0];
Foobar.elpmaxe = ints[1];
}
}
Status:
- [x] defines on hl, cpp
- [x] make defines read-only
- [x] int enum specialisation
- [ ] bitwise flags specialisation