[gobject-introspection] Bug 556628 – (skip) annotation



commit 7549c8053d0229a12d9196cc8abae54a01a555d0
Author: Dan Winship <danw gnome org>
Date:   Sat Mar 28 10:07:37 2009 -0400

    Bug 556628 â?? (skip) annotation
    
    Adds a (skip) option that can be added to the header of any doc comment
    to cause that symbol to be skipped in the .gir output

 giscanner/annotationparser.py |    7 +++++++
 giscanner/ast.py              |    1 +
 giscanner/girwriter.py        |    3 ++-
 tests/scanner/foo.c           |   21 +++++++++++++++++++++
 tests/scanner/foo.h           |    7 +++++++
 5 files changed, 38 insertions(+), 1 deletions(-)
---
diff --git a/giscanner/annotationparser.py b/giscanner/annotationparser.py
index 79cbfe8..1cedfb9 100644
--- a/giscanner/annotationparser.py
+++ b/giscanner/annotationparser.py
@@ -63,6 +63,7 @@ OPT_TRANSFER = 'transfer'
 OPT_TYPE = 'type'
 OPT_CLOSURE = 'closure'
 OPT_DESTROY = 'destroy'
+OPT_SKIP = 'skip'
 
 # Specific option values
 OPT_VAL_BITFIELD = 'bitfield'
@@ -697,6 +698,7 @@ class AnnotationApplier(object):
         self._parse_version(node, block)
         self._parse_deprecated(node, block)
         self._parse_attributes(node, block)
+        self._parse_skip(node, block)
 
     def _parse_version(self, node, block):
         since_tag = self._get_tag(block, TAG_SINCE)
@@ -725,6 +727,11 @@ class AnnotationApplier(object):
         for key, value in annos_tag.options.iteritems():
             node.attributes.append((key, value.one()))
 
+    def _parse_skip(self, node, block):
+        if block is not None:
+            if OPT_SKIP in block.options:
+                node.skip = 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 911cc2b..5e2a010 100644
--- a/giscanner/ast.py
+++ b/giscanner/ast.py
@@ -152,6 +152,7 @@ class Node(object):
     def __init__(self, name=None):
         self.name = name
         self.attributes = [] # (key, value)*
+        self.skip = False
         self.deprecated = None
         self.deprecated_version = None
         self.version = None
diff --git a/giscanner/girwriter.py b/giscanner/girwriter.py
index 7725a38..7697a2d 100644
--- a/giscanner/girwriter.py
+++ b/giscanner/girwriter.py
@@ -96,7 +96,8 @@ and/or use gtk-doc annotations. ''')
                 else:
                     return cmp(a, b)
             for node in sorted(namespace.nodes, cmp=nscmp):
-                self._write_node(node)
+                if not node.skip:
+                    self._write_node(node)
 
     def _write_node(self, node):
         if isinstance(node, Function):
diff --git a/tests/scanner/foo.c b/tests/scanner/foo.c
index 6cb1f3f..e810b52 100644
--- a/tests/scanner/foo.c
+++ b/tests/scanner/foo.c
@@ -579,3 +579,24 @@ foo_buffer_some_method (FooBuffer *buffer)
 }
 
 #define FOO_DEFINE_SHOULD_NOT_BE_EXPOSED "should not be exposed"
+
+/**
+ * FooSkippable: (skip)
+ * @FOO_SKIPPABLE_ONE: a skippable enum value
+ * @FOO_SKIPPABLE_TWO: another skippable enum value
+ *
+ * Some type that is only interesting from C and should not be
+ * exposed to language bindings.
+ */
+
+/**
+ * foo_skip_me: (skip)
+ * @fs: a #FooSkippable
+ *
+ * Does something that's only interesting from C and should not be
+ * exposed to language bindings.
+ */
+void
+foo_skip_me (FooSkippable fs)
+{
+}
diff --git a/tests/scanner/foo.h b/tests/scanner/foo.h
index be3a955..2e018ce 100644
--- a/tests/scanner/foo.h
+++ b/tests/scanner/foo.h
@@ -363,4 +363,11 @@ typedef enum
 void foo_some_variant (guint x, va_list args);
 void foo_some_variant_ptr (guint x, va_list *args);
 
+/* Should be skipped due to annotations */
+typedef enum {
+  FOO_SKIPPABLE_ONE,
+  FOO_SKIPPABLE_TWO
+} FooSkippable;
+void foo_skip_me (FooSkippable fs);
+
 #endif /* __FOO_OBJECT_H__ */



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