You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
The text was updated successfully, but these errors were encountered:
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
The text was updated successfully, but these errors were encountered: