New issue 27 by l...@segv.dk: enum types issue
http://code.google.com/p/ctypesgen/issues/detail?id=27
Consider the following header:
---------------------
enum testenum_e {
dummy0=0,
dummy1,
};
struct teststruct_s {
int dummy;
};
---------------------
This will give me the following object types in python:
enum_testenum_e
struct_teststruct_s
teststruct_s
But no "testenum_e" object type. To get "testenum_e" I need to typedef the
enum. I think it would be an good idea if the above header would produce
an "testenum_e = enum_testenum_e" without having to specify the typedef
(btw ctypeslib behaves like this).
If someone could point me in the right direction I'll be happy to provide a
patch.
This is tested on Ubuntu 11.10 x86_64 with Python 2.7.2+ and ctypesgen r137.
Tim
I poked around ctypesgen a bit and made a small patch that solves my issue.
Comments?
Attachments:
add.enum.typedef.patch 738 bytes
Other than the obvious typo, it looks good. I would also rename
the "struct" variable to "object" and "automatically_typedef_structs()"
to "automatically_typedef_structs_and_enums()", but that's a matter of
taste. Also, I didn't test it; I assume you did.
I agree. My first patch was just to check if I was on the right track with
this fix.
I also fixed the: # XXX Check if it has already been aliased in the C code.
New patch attached.
Attachments:
add.enum.typedef.v2.patch 2.3 KB
I have been running with the attached patch for a while and all looks good.
Changes since v2 is the removal of a debug print.
Please apply.
Attachments:
add.enum.typedef.v3.patch 2.3 KB