summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomeu Vizoso <tomeu.vizoso@collabora.co.uk>2010-05-23 20:38:55 +0200
committerTomeu Vizoso <tomeu.vizoso@collabora.co.uk>2010-05-23 20:41:36 +0200
commit1edeccd204ac39743523275cfc50639a63a949cb (patch)
treee20654f964adf5217dae06cd6f04bfd1301c3109
parentf05406e92beede4357d74233d51aa3db45d709ae (diff)
Add support for the 'foreign' annotation to g-i-scannerGOBJECT_INTROSPECTION_0_6_12
https://bugzilla.gnome.org/show_bug.cgi?id=619450
-rw-r--r--giscanner/annotationparser.py7
-rw-r--r--giscanner/ast.py1
-rw-r--r--giscanner/girwriter.py2
-rw-r--r--tests/scanner/foo-1.0-expected.gir5
-rw-r--r--tests/scanner/foo-1.0-expected.tgir5
-rw-r--r--tests/scanner/foo.c5
-rw-r--r--tests/scanner/foo.h7
7 files changed, 32 insertions, 0 deletions
diff --git a/giscanner/annotationparser.py b/giscanner/annotationparser.py
index 19a5b35..93e4184 100644
--- a/giscanner/annotationparser.py
+++ b/giscanner/annotationparser.py
@@ -67,6 +67,7 @@ OPT_TYPE = 'type'
OPT_CLOSURE = 'closure'
OPT_DESTROY = 'destroy'
OPT_SKIP = 'skip'
+OPT_FOREIGN = 'foreign'
# Specific option values
OPT_VAL_BITFIELD = 'bitfield'
@@ -787,6 +788,7 @@ class AnnotationApplier(object):
self._parse_deprecated(node, block)
self._parse_attributes(node, block)
self._parse_skip(node, block)
+ self._parse_foreign(node, block)
def _parse_version(self, node, block):
since_tag = self._get_tag(block, TAG_SINCE)
@@ -821,6 +823,11 @@ class AnnotationApplier(object):
if OPT_SKIP in block.options:
node.skip = True
+ def _parse_foreign(self, node, block):
+ if block is not None:
+ if OPT_FOREIGN in block.options:
+ node.foreign = True
+
def _parse_rename_to_func(self, node, block):
rename_to_tag = self._get_tag(block, TAG_RENAME_TO)
if rename_to_tag is None:
diff --git a/giscanner/ast.py b/giscanner/ast.py
index ef476eb..042f7b1 100644
--- a/giscanner/ast.py
+++ b/giscanner/ast.py
@@ -176,6 +176,7 @@ class Node(object):
self.deprecated = None
self.deprecated_version = None
self.version = None
+ self.foreign = False
def __cmp__(self, other):
return cmp(self.name, other.name)
diff --git a/giscanner/girwriter.py b/giscanner/girwriter.py
index 8d625c7..e1a1f02 100644
--- a/giscanner/girwriter.py
+++ b/giscanner/girwriter.py
@@ -427,6 +427,8 @@ and/or use gtk-doc annotations. ''')
attrs.append(('c:type', record.symbol))
if record.disguised:
attrs.append(('disguised', '1'))
+ if record.foreign:
+ attrs.append(('foreign', '1'))
if isinstance(record, GLibRecord):
if record.is_gtype_struct_for:
is_gtype_struct = True
diff --git a/tests/scanner/foo-1.0-expected.gir b/tests/scanner/foo-1.0-expected.gir
index 3d209e3..20eb437 100644
--- a/tests/scanner/foo-1.0-expected.gir
+++ b/tests/scanner/foo-1.0-expected.gir
@@ -241,6 +241,11 @@ and/or use gtk-doc annotations. -->
c:identifier="FOO_FLAGS_THIRD"
glib:nick="third"/>
</bitfield>
+ <record name="ForeignStruct" c:type="FooForeignStruct" foreign="1">
+ <field name="foo" writable="1">
+ <type name="int" c:type="int"/>
+ </field>
+ </record>
<interface name="Interface"
c:type="FooInterface"
glib:type-name="FooInterface"
diff --git a/tests/scanner/foo-1.0-expected.tgir b/tests/scanner/foo-1.0-expected.tgir
index 29753af..c0bedbe 100644
--- a/tests/scanner/foo-1.0-expected.tgir
+++ b/tests/scanner/foo-1.0-expected.tgir
@@ -170,6 +170,11 @@
<member name="second" value="2"/>
<member name="third" value="4"/>
</bitfield>
+ <record name="ForeignStruct" foreign="1">
+ <field name="foo" writable="1">
+ <type name="int"/>
+ </field>
+ </record>
<interface name="Interface" glib:type-name="FooInterface" glib:get-type="foo_interface_get_type" glib:type-struct="InterfaceIface">
<method name="do_foo" c:identifier="foo_interface_do_foo">
<return-value transfer-ownership="none">
diff --git a/tests/scanner/foo.c b/tests/scanner/foo.c
index a404aac..6239bfa 100644
--- a/tests/scanner/foo.c
+++ b/tests/scanner/foo.c
@@ -621,3 +621,8 @@ void
foo_skip_me (FooSkippable fs)
{
}
+
+/**
+ * FooForeignStruct: (foreign)
+ *
+ */
diff --git a/tests/scanner/foo.h b/tests/scanner/foo.h
index 0ebcca2..fb4bc5c 100644
--- a/tests/scanner/foo.h
+++ b/tests/scanner/foo.h
@@ -393,5 +393,12 @@ typedef enum {
} FooSkippable;
void foo_skip_me (FooSkippable fs);
+typedef struct _FooForeignStruct FooForeignStruct;
+
+struct _FooForeignStruct
+{
+ int foo;
+};
+
#endif /* __FOO_OBJECT_H__ */