[gobject-introspection] Add support for the 'foreign' annotation to g-i-scanner



commit 1edeccd204ac39743523275cfc50639a63a949cb
Author: Tomeu Vizoso <tomeu vizoso collabora co uk>
Date:   Sun May 23 20:38:55 2010 +0200

    Add support for the 'foreign' annotation to g-i-scanner
    
    https://bugzilla.gnome.org/show_bug.cgi?id=619450

 giscanner/annotationparser.py       |    7 +++++++
 giscanner/ast.py                    |    1 +
 giscanner/girwriter.py              |    2 ++
 tests/scanner/foo-1.0-expected.gir  |    5 +++++
 tests/scanner/foo-1.0-expected.tgir |    5 +++++
 tests/scanner/foo.c                 |    5 +++++
 tests/scanner/foo.h                 |    7 +++++++
 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__ */



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