-
Notifications
You must be signed in to change notification settings - Fork 42
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
Possible to get a list of enum names from a header file? #180
Comments
Not really sure that I understand the question ... a "header file" isn't a coherent unit as seen by the compiler (certainly not something that persists). Would if they all live in the same namespace, though. Otherwise, any such approach simply identifies all enums seen so far, including ones you may not be interested in. Specific to the given code, |
When I try to read But I would like to avoid calling 30 imports for the 30 enums that exist in my file. The enums in my file are not anonymous and each have a specific name like Enum1, Enum2, etc.... |
Can you post the file so that I can reproduce? A basic
shows that enum just fine:
|
I cannot post the full file but here is a portion to give you an idea. There are about 30 or so enums in the file and all have the same syntax as below, just different names and values:
|
It does show up for me:
If it doesn't give you the same result, what version/platform are we speaking here? |
But I don't think it has to do with the version. The C++ project I am dealing with is quite large and I have many other include paths involved besides just the enums.h file. |
Closed by mistake, Here is my dir output...
|
Interesting, so I created my own local test-enums.h with a single enum and that showed up in dir. So then I made a copy of my enums.h and moved it over to my python project repository, but dir() of that local enums.h is not showing the enums still... Is there a limit to what dir() can show? Maybe there are too many enums for it to show? |
AHHHH I am such an idiot, the enums are all under a namespace. If I import the namespace then all the enums show up. Man thank you so much for the help @wlav and thank you again for this package. |
Greetings,
First of thank you so much for this package. I have a c++ header file which has about 30 or so enums declared in it, and instead of importing all 30 manually I'd like to import all the enums dynamically and save them to a variable.
The problem is that I cannot seem to find the name of the enums to import from cppyy, I have tried something like below but unfortunately the class names are only of the type such as uint8_t or int8_t.
I was wondering if it was possible to get the names of all the enums in a header file so I can dynamically import them.
The text was updated successfully, but these errors were encountered: