Re: GObject Introspection Enum details
- From: Phil Clayton <phil clayton lineone net>
- To: Aleksey <prolog hermit gmail com>
- Cc: gtk-devel-list <gtk-devel-list gnome org>
- Subject: Re: GObject Introspection Enum details
- Date: Mon, 18 Nov 2013 01:48:16 +0000
Hi Aleksey,
Perhaps a solution is to prefix the name returned by
g_base_info_get_name
with the namespace's C prefix returned by
g_irepository_get_c_prefix
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
(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?
>
_______________________________________________
gtk-devel-list mailing list
gtk-devel-list gnome org
https://mail.gnome.org/mailman/listinfo/gtk-devel-list
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]