Re: GObject Introspection Enum details



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 (http://www.swi-prolog.org/). 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 value\n");

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?

>



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