Re: GObject Introspection Enum details

Hi Aleksey,

Perhaps a solution is to prefix the name returned by
with the namespace's C prefix returned by
I think this will reconstruct the C name because (somebody correct me if I'm wrong) the names in the GIR metadata are derived by stripping the prefix from the C names in the first place. (For functions, you can get the name with g_function_info_get_symbol.)

On a different note, I was using the GIRepository library to generate binding code and found that it wasn't possible to generate one binding library for all platforms because information about platform-dependent C types, e.g. glong, was not available. Calling g_base_info_get_name on a TypeInfo gave
ERROR:girepository/gibaseinfo.c:366:g_base_info_get_name: code should not be reached instead of the type name present in the GIR file, e.g. "glong". The information provided by the GITypeTag enum type has integer sizes resolved for the platform in use. So seeing e.g. INT64 on a 64 bit platform doesn't tell you whether that was gint64 or glong in C. That was an issue for me, so I thought I'd mention it.

17/11/13 17:42, Aleksey wrote:
Thanks Jasper

I've somehow overlooked that GIEnumInfo is inherited
GIRegisteredTypeInfo, not directly from GIBaseInfo.

Unfortunately, g_registered_type_info_get_type_name() returns NULL. I've
also tried g_registered_type_info_get_g_type & g_type_name:

GType type = g_registered_type_info_get_g_type(info);

const gchar * name = g_type_name(type);

but it returns "void".

 > mind asking why you want to know?

I am trying to automate binding generation for Swi-Prolog
( Currently I am working on datatype
conversion, for example, following (generated) function takes Prolog
data structure (term) and converts it to C enum-integer:

BookmarkFileError convert_term_to_BookmarkFileError(term_t var)


const char * value = convert_term_to_cstring(var);

if (strcmp(value, "invalid_uri") == 0) {

return invalid_uri;

} else if (strcmp(value, "invalid_value") == 0) {

return invalid_value;

} else if (strcmp(value, "app_not_registered") == 0) {

return app_not_registered;

} else if (strcmp(value, "uri_not_found") == 0) {

return uri_not_found;

} else if (strcmp(value, "read") == 0) {

return read;

} else if (strcmp(value, "unknown_encoding") == 0) {

return unknown_encoding;

} else if (strcmp(value, "write") == 0) {

return write;

} else if (strcmp(value, "file_not_found") == 0) {

return file_not_found;


printf("Error in convert_term_to_BookmarkFileError while converting

return (BookmarkFileError)0;


But I need to get exact names for enum (and enum values, but this is
another problem I hadn't investigated yet).

On Sunday 17 November 2013 11:51:24 Jasper St. Pierre wrote:

 > You can try g_registered_type_info_get_type_name(), but mind asking
why you

 > want to know?


gtk-devel-list mailing list
gtk-devel-list gnome org

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