Conversation
|
Hi Xavier, thanks for offering this possibility to expose enum values. I am curious what is the advantage you see in this change? I once thought about this, but I fear some problems that could arise: enum values could get inconsistent if the header file is changed (don't know whether cython actually makes use of the enum values). To be on the safe side, I would prefer putting the values into comments, and only for values which have been explicitly set in the header file. |
|
Hi Gregor, In my header I have enums like this enum name { So it the enum start from 0 in Cython it leads to incompatibility. right ? I agree with you values should only be there is explicitly set in C header file but I didn't no how to know it as the value field is always filled. Have a nice day, XL.
|
|
Hi Xavier, if you have explicitly defined enum values in your C header file, then it is not necessary to repeat them in the pxd file. So it seems your patch is not necessary to create correct cython code. It is true that the value field is always filled, but if you find an INTEGER_LITERAL child of an ENUM_CONST_DECL, you know it has been explicitly set. You can observe this if you run python libclang_show_ast.py tests/test_enums.h Gregor |
|
Hi Gregor, I'm not familiar with Cython, sorry... So you can forget my pull request as it's not needed. Thanks again, XL.
|
Hello,
In our C code we give values to our enum entries, I modified cwrap so that it takes those values.
This code break some tests but I think it's not a big deal, it just add values to enum where there wasn't.
eg.:
enum toto {
enum1,
enum2,
enum3
};
will give
ctypedef enum toto:
enum1 = 0
enum2 = 1
enum3 = 2
Thanks for all your work,
XL.