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

C++11 scoped enums and pybindgen #10

Open
jmikeowen opened this issue Mar 1, 2017 · 0 comments
Open

C++11 scoped enums and pybindgen #10

jmikeowen opened this issue Mar 1, 2017 · 0 comments

Comments

@jmikeowen
Copy link

I ran into issues trying to use C++11 scoped enums with pybindgen, but found a relatively simple workaround that required one modification of the source in enum.py. Basically the line creating "PyModule_AddIntConstant" needs to detect if a C++ compiler is being used, and if so use "static_cast" on the enum value. It is also necessary to add the enum values in the pybindgen input code (i.e., "add_enum") using the tuple form (in order to provide a valid python name as well as the fully scoped C++ value), but that is already possible in the current interface.

I'm attaching the modified source for "enum.py" as well as the diff file to this issue. I'm welcome to better suggestions as to how this issue should be handled too! Clearly it would be nicer to properly support scoped enums as more than just integers from python, since this is the whole point of using scoped enums in C++. However, this workaround is a minimal change that at least allows them to be bound and used via the current enum support.
enum_source.zip

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