more general generator / register concpt
There are a few issues with the current generator/register concept. It should be possible to customize the code generation for a given implementation of a concept Foo. So given a database entry for MyFoo, the free standing function template cls_ registerFoo() is called that registers the class + all default method. The following should be possible:
- use of a special holder for MyFoo
- registering additional "non interface" method for MyFoo
- changing the default registration for an "interface method" (i.e. wrapping it in a lambda)
- tell the default registration to not register an interface method (e.g. the method is not implemented by MyFoo or has a different signature)
Suggestion: split the registerFoo method into two part, one registering the class the other adding the method: We would have the following default implementations:
template <class DuneType, class Holder>
void registerFoo(cls<DuneType,Holder> &cls)
{ register methods on cls }
template <class DuneType>
registerFoo(const const DuneType *, char* name = "Default") {
{ auto cls = pybind11::cls_<MyFoo>(mame); registerFoo(cls); }
For MyFoo one can overload the second free standing function:
registerFoo( MyFoo*, char *name = "Default" )
{ // possibly use a special holder (solves (1))
auto cls = pybind11::cls<MyFoo, MyHolder>(name);
// add special implementations of interface methode (solves (3))
cls.def(....);
// do default part of registration
registerFoo( cls );
// add some additional non interface methods (solve (2))
cls.def(....);
}
Solving (4) is more difficult. One could implement the default registration using SINAF, i.e., have a speical def method that is empty if the method with the expected signature does not exist.... Or have some user defined way of telling the register method which methods not to use...