Re: GObject Introspection: array type too unspecific?



Hey,

2011/7/6 Michael Kappert <michael kappert gmx net>
g_type_info_get_array_type returns a GIArrayType which only distinguishes "C", ptr, byte and nested arrays. This does not seem to be enough to generate wrappers automatically. The exact array element type needs to be known.  (Or doesn't it? I'm using CLISP's FFI that does the wrapping for me, I'm not too familiar with C.)

 I think you are misunderstanding GIArrayType. It doesn't tell anything about the "content" (read: element type) of the array, but describes the data type itself. As native C arrays often suck, Glib provides higher-level array types which are more convenient - unfortunately that means that "array" is ambiguous, it may be either a native C array (e.g. char[]) or one of the Glib array types (GArray, GPtrArray, GByteArray).

To determine the actual element type, you can use something along the lines of

GITypeInfo *element_info = g_type_info_get_param_type (type_info, 0);
GITypeTag element_type = g_type_info_get_tag (element_info);

Florian



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]