summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJasper St. Pierre <jstpierre@mecheye.net>2013-01-31 21:42:32 -0500
committerJasper St. Pierre <jstpierre@mecheye.net>2013-02-01 19:20:35 -0500
commit0f5f94ed8a86355003533452a2d6cc8077d27535 (patch)
treeb3551d2692fe51336223659db0f886a01a032eed
parentf027b6841164fc5c712236b3c40a90808e1b7428 (diff)
downloadgobject-introspection-0f5f94ed8a86355003533452a2d6cc8077d27535.tar.gz
giscanner: Apply standard annotations to constant values
While there's no particular reason I need to do this, there really isn't any reason to not do this, and it helps with doctool or whatever in the future if we want to document when a constant showed up. g-ir-compiler also keeps track of constant deprecations, so this fixes constants not ever being deprecated. https://bugzilla.gnome.org/show_bug.cgi?id=693040
-rw-r--r--giscanner/girwriter.py3
-rw-r--r--giscanner/maintransformer.py9
-rw-r--r--giscanner/transformer.py5
-rw-r--r--tests/scanner/Annotation-1.0-expected.gir5
-rw-r--r--tests/scanner/annotation.h2
5 files changed, 16 insertions, 8 deletions
diff --git a/giscanner/girwriter.py b/giscanner/girwriter.py
index 7344488b..e9910d47 100644
--- a/giscanner/girwriter.py
+++ b/giscanner/girwriter.py
@@ -370,7 +370,10 @@ and/or use gtk-doc annotations. ''')
attrs = [('name', constant.name),
('value', constant.value),
('c:type', constant.ctype)]
+ self._append_version(constant, attrs)
+ self._append_node_generic(constant, attrs)
with self.tagcontext('constant', attrs):
+ self._write_generic(constant)
self._write_type(constant.value_type)
def _write_class(self, node):
diff --git a/giscanner/maintransformer.py b/giscanner/maintransformer.py
index 67168d6b..d149f30a 100644
--- a/giscanner/maintransformer.py
+++ b/giscanner/maintransformer.py
@@ -192,7 +192,7 @@ usage is void (*_gtk_reserved1)(void);"""
def _get_annotation_name(self, node):
if isinstance(node, (ast.Class, ast.Interface, ast.Record,
ast.Union, ast.Enum, ast.Bitfield,
- ast.Callback, ast.Alias)):
+ ast.Callback, ast.Alias, ast.Constant)):
if node.ctype is not None:
return node.ctype
elif isinstance(node, ast.Registered) and node.gtype_name is not None:
@@ -815,9 +815,12 @@ usage is void (*_gtk_reserved1)(void);"""
self._apply_annotations_return(signal, signal.retval, block)
def _apply_annotations_constant(self, node):
- block = self._blocks.get(node.ctype)
- if not block:
+ block = self._get_block(node)
+ if block is None:
return
+
+ self._apply_annotations_annotated(node, block)
+
tag = block.get_tag(TAG_VALUE)
if tag:
node.value = tag.value
diff --git a/giscanner/transformer.py b/giscanner/transformer.py
index 67367999..ba7afb93 100644
--- a/giscanner/transformer.py
+++ b/giscanner/transformer.py
@@ -338,10 +338,7 @@ raise ValueError."""
elif stype == CSYMBOL_TYPE_UNION:
return self._create_union(symbol)
elif stype == CSYMBOL_TYPE_CONST:
- # Don't parse constants which are marked (skip)
- docblock = self._annotations.get(symbol.ident)
- if not docblock or not 'skip' in docblock.options:
- return self._create_const(symbol)
+ return self._create_const(symbol)
# Ignore variable declarations in the header
elif stype == CSYMBOL_TYPE_OBJECT:
pass
diff --git a/tests/scanner/Annotation-1.0-expected.gir b/tests/scanner/Annotation-1.0-expected.gir
index 73d982dd..0be91d6d 100644
--- a/tests/scanner/Annotation-1.0-expected.gir
+++ b/tests/scanner/Annotation-1.0-expected.gir
@@ -29,12 +29,15 @@ and/or use gtk-doc annotations. -->
</constant>
<constant name="CALCULATED_LARGE"
value="10000000000UL"
- c:type="ANNOTATION_CALCULATED_LARGE">
+ c:type="ANNOTATION_CALCULATED_LARGE"
+ version="1.4">
+ <doc xml:whitespace="preserve">Constant to define a calculated large value</doc>
<type name="gint" c:type="gint"/>
</constant>
<constant name="CALCULATED_LARGE_DIV"
value="1000000UL"
c:type="ANNOTATION_CALCULATED_LARGE_DIV">
+ <doc xml:whitespace="preserve">Constant to define a calculated large value</doc>
<type name="gint" c:type="gint"/>
</constant>
<callback name="Callback" c:type="AnnotationCallback">
diff --git a/tests/scanner/annotation.h b/tests/scanner/annotation.h
index b3b4bd4c..09d4f4f2 100644
--- a/tests/scanner/annotation.h
+++ b/tests/scanner/annotation.h
@@ -180,6 +180,8 @@ GObject * annotation_transfer_floating(void);
* Constant to define a calculated large value
*
* Value: 10000000000UL
+ *
+ * Since: 1.4
*/
#define ANNOTATION_CALCULATED_LARGE (1000 * G_GINT64_CONSTANT (10000000))