I am working on some D links for an existing C library, and I have a bunch of function definitions and a set of bindings for them. For instance:
// Functions void function(int) funcA; long function() funcB; bool function(bool) funcC; char function(string) funcD; // etc... // Bindings if(!presentInLibrary("func")) return false; if(!bindFunction(funcA, "funcA")) return false; if(!bindFunction(funcB, "funcB")) return false; if(!bindFunction(funcC, "funcC")) return false; if(!bindFunction(funcD, "funcD")) return false; // etc...
This model is very similar to how Derelict handles OpenGL loading. However, this is similar to over typing. I would really like to express the "binding" part above:
BINDGROUP("func", "funcA", "funcB", "funcC", "funcD", ...); // Name of function group, then variable list of function names.
Is this something you can do with mixins?
source share