Description
Hi,
One of the very nice features of cpp2py is the conversion of python dictionaries into a cpp class (e.g. for passing parameters). As far as I can tell, the only way to specifying that such a converter should be generated is with the keyword CPP2PY_ARG_AS_DICT.
This is somewhat inconvenient, since it is a keyword that applies to a function (rather then the parameter class itself) and that function is only allowed to take one parameter (the paramter class).
Consider an example:
class CPP2PY_IGNORE parameter_list {
public:
double param = 1.0;
};
void my_wrapped_function(parameter_list plist, int extra_key);
CPP2PY_ARG_AS_DICT inline void fake(parameter_list const &temp){};
The CPP2PY_IGNORE
keyword on the parameter_list
class stops cpp2py from directly wrapping the class in python. The my_wrapped_fuction
is what we want to use, but it takes two arguments and therefore the CPP2PY_ARG_AS_DICT
can't be applied. So we are left with defining the fake
function whose only purpose is to trick cpp2py to make a converter.
I propose adding a new keyword that is applied to the data class itself. E.g. CPP2PY_CONVERT_TO_DICT
. This seems to be the right place to put it logically (why does it matter which and how many functions in cpp we pass the class to?) and avoids the issues mentioned above.
Thoughts? Concerns?