Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Defines and flags #17

Open
3 of 4 tasks
Aurel300 opened this issue Sep 28, 2019 · 0 comments
Open
3 of 4 tasks

Defines and flags #17

Aurel300 opened this issue Sep 28, 2019 · 0 comments
Labels
enhancement New feature or request

Comments

@Aurel300
Copy link
Owner

Aurel300 commented Sep 28, 2019

(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:

  • defines on hl, cpp
  • make defines read-only
  • int enum specialisation
  • bitwise flags specialisation
@Aurel300 Aurel300 added the enhancement New feature or request label Sep 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant