den-run-ai / ctypesgen

Automatically exported from code.google.com/p/ctypesgen
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

enum types issue #27

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
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.

Original issue reported on code.google.com by l...@segv.dk on 13 Feb 2012 at 1:43

GoogleCodeExporter commented 9 years ago
I poked around ctypesgen a bit and made a small patch that solves my issue. 
Comments?

Original comment by l...@segv.dk on 21 Mar 2012 at 6:22

Attachments:

GoogleCodeExporter commented 9 years ago
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.

Original comment by TimM...@gmail.com on 22 Mar 2012 at 4:40

GoogleCodeExporter commented 9 years ago
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.

Original comment by l...@segv.dk on 22 Mar 2012 at 7:32

Attachments:

GoogleCodeExporter commented 9 years ago
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.

Original comment by l...@segv.dk on 3 Apr 2012 at 8:58

Attachments: