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

better dictionary-class converter #30

Open
phdum opened this issue Jan 20, 2020 · 0 comments
Open

better dictionary-class converter #30

phdum opened this issue Jan 20, 2020 · 0 comments

Comments

@phdum
Copy link
Member

phdum commented Jan 20, 2020

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant