libclang python bindings, and functionproto.argument_types() vs functionproto.get_declaration().get_arguments()

Hi,

I'm trying to parse existing C headers with the python bindings for libclang.

I'm failing to get the argument type of a anonymous function.

My mock header looks like this:

typedef struct {
   int somefield;
} struct_to_receive;

typedef struct {
   int (*getter)(const struct_to_receive **rv);
} factory_t;

The python code I use to inspect his is

from clang.cindex import Index, CursorKind, TypeKind

index = Index.create()

tu = index.parse(None, ['structs_parsing.h'])

typedef = list(tu.cursor.get_children())[-1]

print typedef.kind, typedef.spelling # typedef_decl, factory_t

structdecl = list(typedef.get_children())[0]
print structdecl.type.kind # Record

fielddecl = list(structdecl.get_children())[0]
print fielddecl.kind # field_decl
print fielddecl.type.kind # pointer to the abstract function

# fielddecl has one child
print list(c.kind for c in fielddecl.get_children()) # parm_decl ?

unexposed = fielddecl.type.get_pointee()
print unexposed.kind
print unexposed.get_canonical().kind # function_proto

functionproto = unexposed.get_canonical()

print list(functionproto.argument_types())
print list(functionproto.get_declaration().get_arguments())

In other parts of the code, I use get_arguments() to get to arg.spelling(), but in this case the code above prints:

[<clang.cindex.Type object at 0x109ae07a0>]

I.e., I have argument_types(), but not .get_declaration().get_arguments()

Am I doing something wrong or am I trying to do the wrong thing, or is this a bug?

Axel