summaryrefslogtreecommitdiff
path: root/girepository
diff options
context:
space:
mode:
authorJohan Dahlin <jdahlin@litl.com>2010-03-25 23:12:12 -0300
committerJohan Dahlin <johan@gnome.org>2010-03-25 23:12:12 -0300
commitd65f65cef8996e3dc1c305a6606930a061f2a99b (patch)
tree1ee6aa1b22f3663ed76c641ade614cc240a725a4 /girepository
parentd8a304b16bd285b671f144687d6fbe4a1d2bd43c (diff)
downloadgobject-introspection-d65f65cef8996e3dc1c305a6606930a061f2a99b.tar.gz
Add support for foreign structs
Foreign structs are special in the sense that there might be native bindings (for instance PyCairo for PyGI) that provides the same functionallity as the introspected variant. https://bugzilla.gnome.org/show_bug.cgi?id=610357
Diffstat (limited to 'girepository')
-rw-r--r--girepository/ginfo.c9
-rw-r--r--girepository/girepository.h1
-rw-r--r--girepository/girnode.c1
-rw-r--r--girepository/girnode.h1
-rw-r--r--girepository/girparser.c4
-rw-r--r--girepository/gtypelib.h5
6 files changed, 20 insertions, 1 deletions
diff --git a/girepository/ginfo.c b/girepository/ginfo.c
index e3936179..724109fe 100644
--- a/girepository/ginfo.c
+++ b/girepository/ginfo.c
@@ -1392,6 +1392,15 @@ g_struct_info_get_alignment (GIStructInfo *info)
return blob->alignment;
}
+gboolean
+g_struct_info_is_foreign (GIStructInfo *info)
+{
+ GIRealInfo *rinfo = (GIRealInfo *)info;
+ StructBlob *blob = (StructBlob *)&rinfo->typelib->data[rinfo->offset];
+
+ return blob->foreign;
+}
+
/**
* g_struct_info_is_gtype_struct:
* @info: GIStructInfo
diff --git a/girepository/girepository.h b/girepository/girepository.h
index 083b11c0..cfa5b390 100644
--- a/girepository/girepository.h
+++ b/girepository/girepository.h
@@ -461,6 +461,7 @@ GIFunctionInfo * g_struct_info_find_method (GIStructInfo *info,
gsize g_struct_info_get_size (GIStructInfo *info);
gsize g_struct_info_get_alignment (GIStructInfo *info);
gboolean g_struct_info_is_gtype_struct (GIStructInfo *info);
+gboolean g_struct_info_is_foreign (GIStructInfo *info);
/* GIRegisteredTypeInfo */
diff --git a/girepository/girnode.c b/girepository/girnode.c
index 456ab738..1694406d 100644
--- a/girepository/girnode.c
+++ b/girepository/girnode.c
@@ -1885,6 +1885,7 @@ g_ir_node_build_typelib (GIrNode *node,
GList *members;
blob->blob_type = BLOB_TYPE_STRUCT;
+ blob->foreign = struct_->foreign;
blob->deprecated = struct_->deprecated;
blob->is_gtype_struct = struct_->is_gtype_struct;
blob->reserved = 0;
diff --git a/girepository/girnode.h b/girepository/girnode.h
index 14848847..7fe235b8 100644
--- a/girepository/girnode.h
+++ b/girepository/girnode.h
@@ -312,6 +312,7 @@ struct _GIrNodeStruct
gboolean deprecated;
gboolean disguised;
gboolean is_gtype_struct;
+ gboolean foreign;
gchar *gtype_name;
gchar *gtype_init;
diff --git a/girepository/girparser.c b/girepository/girparser.c
index 12c1d989..5b24604a 100644
--- a/girepository/girparser.c
+++ b/girepository/girparser.c
@@ -2201,6 +2201,7 @@ start_struct (GMarkupParseContext *context,
const gchar *gtype_name;
const gchar *gtype_init;
const gchar *gtype_struct;
+ const gchar *foreign;
GIrNodeStruct *struct_;
name = find_attribute ("name", attribute_names, attribute_values);
@@ -2209,6 +2210,7 @@ start_struct (GMarkupParseContext *context,
gtype_name = find_attribute ("glib:type-name", attribute_names, attribute_values);
gtype_init = find_attribute ("glib:get-type", attribute_names, attribute_values);
gtype_struct = find_attribute ("glib:is-gtype-struct-for", attribute_names, attribute_values);
+ foreign = find_attribute ("foreign", attribute_names, attribute_values);
if (name == NULL && ctx->node_stack == NULL)
{
@@ -2242,6 +2244,8 @@ start_struct (GMarkupParseContext *context,
struct_->gtype_name = g_strdup (gtype_name);
struct_->gtype_init = g_strdup (gtype_init);
+ struct_->foreign = (g_strcmp0 (foreign, "1") == 0);
+
if (ctx->node_stack == NULL)
ctx->current_module->entries =
g_list_append (ctx->current_module->entries, struct_);
diff --git a/girepository/gtypelib.h b/girepository/gtypelib.h
index a69bccf0..14edc984 100644
--- a/girepository/gtypelib.h
+++ b/girepository/gtypelib.h
@@ -669,6 +669,8 @@ typedef struct {
* @unregistered: If this is set, the type is not registered with GType.
* @alignment: The byte boundary that the struct is aligned to in memory
* @is_gtype_struct: Whether this structure is the class or interface layout for a GObject
+ * @foreign: If the type is foreign, eg if it's expected to be overridden by
+ * a native language binding instead of relying of introspected bindings.
* @size: The size of the struct in bytes.
* @gtype_name: String name of the associated #GType
* @gtype_init: String naming the symbol which gets the runtime #GType
@@ -685,7 +687,8 @@ typedef struct {
guint16 unregistered : 1;
guint16 is_gtype_struct : 1;
guint16 alignment : 6;
- guint16 reserved : 7;
+ guint16 foreign : 1;
+ guint16 reserved : 6;
guint32 name;