3
votes

I want to have specific methods with a specific pattern recognized at compile time and registered along with a specified id trough mixins in a parent class.

ex.: take a method 'X' from a class with a predetermined id:5, what I want is that, in a mixin in a parent class, method X will be registered as a delegate with its id to be called later on by its id.

What would be the best way to specify the Id considering I want the id to be of type int and only the specified methods to be registered?

should I (if it is even possible) do it with a custom annotation pretty much like the @property but with an argument, like:

@autoregister(id)
void method(...)

if it is possible to do it this way, an example or a link to the documentation on how to do it would be nice since I didn't find it in the documentation.

if it is not possible I'll use the function's signature as a string instead but I really want to do it with a numeric identifier instead of a possibly quite long string as much as possible.

1

1 Answers

1
votes

Making custom annotations is not possible at the moment (but it will be in the future).

However, you can make your own method-naming convention that will allow you to do something similar to what you have described. I do not have time to think deeply how to accomplish this, but I would start with having a method like:

public void id30_doSomething(/* params */) {
  // body
} 
alias id30_doSomething doSomething;

// finally, lets do something with all these methods
// and generate mixin...

After this you could probably list all methods and find if their names match id([0-9]*)_.*, if so, then you generate mixin to register them in the parent...