summaryrefslogtreecommitdiff
path: root/giscanner
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.van.berkom@gmail.com>2008-12-09 00:07:08 +0000
committerJohan Dahlin <johan@src.gnome.org>2008-12-09 00:07:08 +0000
commitc1eb0a1670b41ffaa254310284a025ddc25c11a1 (patch)
tree559da38d33d7d84a649f39d3b9f6625d239846b4 /giscanner
parent076bf783f0a4e1362f08cbc2dd986f85a8afaf5f (diff)
downloadgobject-introspection-c1eb0a1670b41ffaa254310284a025ddc25c11a1.tar.gz
Bug 563742 – introspection should record the introduced version of
2008-12-08 Tristan Van Berkom <tristan.van.berkom@gmail.com> Bug 563742 – introspection should record the introduced version of symbols marked with the "Since:" tag reviewed by: Johan * giscanner/ast.py: * giscanner/girwriter.py: * giscanner/scannerlexer.l: * giscanner/transformer.py: * tests/scanner/annotation-1.0-expected.gir: * tests/scanner/annotation-1.0-expected.tgir: * tests/scanner/annotation.c (annotation_versioned): * tests/scanner/annotation.h: svn path=/trunk/; revision=988
Diffstat (limited to 'giscanner')
-rw-r--r--giscanner/ast.py1
-rw-r--r--giscanner/girwriter.py14
-rw-r--r--giscanner/scannerlexer.l13
-rw-r--r--giscanner/transformer.py23
4 files changed, 49 insertions, 2 deletions
diff --git a/giscanner/ast.py b/giscanner/ast.py
index 8b78634d..92ec47d8 100644
--- a/giscanner/ast.py
+++ b/giscanner/ast.py
@@ -148,6 +148,7 @@ class Node(object):
self.name = name
self.deprecated = None
self.deprecated_version = None
+ self.version = None
def __repr__(self):
return '%s(%r)' % (self.__class__.__name__, self.name)
diff --git a/giscanner/girwriter.py b/giscanner/girwriter.py
index 23d3a927..4468e25b 100644
--- a/giscanner/girwriter.py
+++ b/giscanner/girwriter.py
@@ -92,6 +92,10 @@ class GIRWriter(XMLWriter):
else:
print 'WRITER: Unhandled node', node
+ def _append_version(self, node, attrs):
+ if node.version:
+ attrs.append(('version', node.version))
+
def _append_deprecated(self, node, attrs):
if node.deprecated:
attrs.append(('deprecated', node.deprecated))
@@ -112,6 +116,7 @@ class GIRWriter(XMLWriter):
def _write_function(self, func, tag_name='function'):
attrs = [('name', func.name),
('c:identifier', func.symbol)]
+ self._append_version(func, attrs)
self._append_deprecated(func, attrs)
self._append_throws(func, attrs)
with self.tagcontext(tag_name, attrs):
@@ -208,6 +213,7 @@ class GIRWriter(XMLWriter):
def _write_enum(self, enum):
attrs = [('name', enum.name)]
+ self._append_version(enum, attrs)
self._append_deprecated(enum, attrs)
if isinstance(enum, GLibFlags):
tag_name = 'bitfield'
@@ -240,6 +246,7 @@ class GIRWriter(XMLWriter):
def _write_class(self, node):
attrs = [('name', node.name),
('c:type', node.ctype)]
+ self._append_version(node, attrs)
self._append_deprecated(node, attrs)
if isinstance(node, Class):
tag_name = 'class'
@@ -283,6 +290,8 @@ class GIRWriter(XMLWriter):
def _write_property(self, prop):
attrs = [('name', prop.name)]
+ self._append_version(prop, attrs)
+ self._append_deprecated(prop, attrs)
# Properties are assumed to be readable (see also generate.c)
if not prop.readable:
attrs.append(('readable', '0'))
@@ -298,6 +307,7 @@ class GIRWriter(XMLWriter):
def _write_callback(self, callback):
# FIXME: reuse _write_function
attrs = [('name', callback.name), ('c:type', callback.ctype)]
+ self._append_version(callback, attrs)
self._append_deprecated(callback, attrs)
self._append_throws(callback, attrs)
with self.tagcontext('callback', attrs):
@@ -319,6 +329,7 @@ class GIRWriter(XMLWriter):
('c:type', record.symbol)]
if record.disguised:
attrs.append(('disguised', '1'))
+ self._append_version(record, attrs)
self._append_deprecated(record, attrs)
if isinstance(record, GLibBoxed):
attrs.extend(self._boxed_attrs(record))
@@ -332,6 +343,7 @@ class GIRWriter(XMLWriter):
def _write_union(self, union):
attrs = [('name', union.name),
('c:type', union.symbol)]
+ self._append_version(union, attrs)
self._append_deprecated(union, attrs)
if isinstance(union, GLibBoxed):
attrs.extend(self._boxed_attrs(union))
@@ -365,6 +377,8 @@ class GIRWriter(XMLWriter):
def _write_signal(self, signal):
attrs = [('name', signal.name)]
+ self._append_version(signal, attrs)
+ self._append_deprecated(signal, attrs)
with self.tagcontext('glib:signal', attrs):
self._write_return_type(signal.retval)
self._write_parameters(signal.parameters)
diff --git a/giscanner/scannerlexer.l b/giscanner/scannerlexer.l
index 22894d18..27072cd4 100644
--- a/giscanner/scannerlexer.l
+++ b/giscanner/scannerlexer.l
@@ -261,6 +261,15 @@ parse_gtkdoc (GISourceScanner *scanner,
name = parts[0];
value = NULL;
}
+ else if (g_ascii_strcasecmp (parts[0], "ince") == 0)
+ {
+ if (n_parts == 2)
+ options = g_slist_prepend (options, g_strdup (parts[1]));
+ else
+ options = g_slist_prepend (options, g_strdup (""));
+ name = parts[0];
+ value = NULL;
+ }
else if (n_parts >= 2)
{
name = parts[0];
@@ -306,6 +315,8 @@ parse_gtkdoc (GISourceScanner *scanner,
rname = "return";
else if (g_ascii_strncasecmp ("eprecated", name, 9) == 0)
rname = "deprecated";
+ else if (g_ascii_strncasecmp ("ince", name, 4) == 0)
+ rname = "since";
else
rname = name;
@@ -358,7 +369,7 @@ parse_comment (GISourceScanner *scanner)
if ((c1 != '*' && c1 != ' '))
startofline = FALSE;
- if (startofline && (c1 == ' ') && (c2 == '@' || (c2 == 'r') || (c2 == 'R') || (c2 == 'D')))
+ if (startofline && (c1 == ' ') && ((c2 == '@') || (c2 == 'r') || (c2 == 'R') || (c2 == 'D') || (c2 == 'S')))
{
c1 = c2;
c2 = input();
diff --git a/giscanner/transformer.py b/giscanner/transformer.py
index 70a08498..f9807eab 100644
--- a/giscanner/transformer.py
+++ b/giscanner/transformer.py
@@ -211,6 +211,7 @@ class Transformer(object):
def _create_enum(self, symbol):
members = []
+ directives = symbol.directives()
for child in symbol.base_type.child_list:
name = strip_common_prefix(symbol.ident, child.ident).lower()
members.append(Member(name,
@@ -219,6 +220,7 @@ class Transformer(object):
enum_name = self.remove_prefix(symbol.ident)
enum = Enum(enum_name, symbol.ident, members)
+ self._parse_version(enum, directives)
self._names.type_names[symbol.ident] = (None, enum)
return enum
@@ -238,6 +240,12 @@ class Transformer(object):
# No version, just include str
node.deprecated = deprecated_value.strip()
+ def _parse_version(self, node, directives):
+ version = directives.get('since', False)
+ if version:
+ version_value = version[0]
+ node.version = version_value.strip()
+
def _pair_array(self, params, array):
if not array.type.length_param_name:
return
@@ -283,6 +291,7 @@ class Transformer(object):
self._pair_annotations(parameters, return_)
name = self._strip_namespace_func(symbol.ident)
func = Function(name, return_, parameters, symbol.ident)
+ self._parse_version(func, directives)
self._parse_deprecated(func, directives)
return func
@@ -314,6 +323,8 @@ class Transformer(object):
dirs_for = set(dirs)
dirs_for = dirs_for.difference(param_names)
dirs_for.discard('return')
+ dirs_for.discard('deprecated')
+ dirs_for.discard('since')
if dirs_for:
print 'Unexpected annotations for %s, parameters are %s' % (
list(dirs_for), list(param_names), )
@@ -633,6 +644,7 @@ class Transformer(object):
return union
def _create_struct(self, symbol):
+ directives = symbol.directives()
struct = self._typedefs_ns.get(symbol.ident, None)
if struct is None:
# This is a bit of a hack; really we should try
@@ -650,9 +662,12 @@ class Transformer(object):
if field:
struct.fields.append(field)
+ self._parse_version(struct, directives)
+
return struct
def _create_union(self, symbol):
+ directives = symbol.directives()
union = self._typedefs_ns.get(symbol.ident, None)
if union is None:
# This is a bit of a hack; really we should try
@@ -670,6 +685,8 @@ class Transformer(object):
if field:
union.fields.append(field)
+ self._parse_version(union, directives)
+
return union
def _create_callback(self, symbol):
@@ -682,7 +699,11 @@ class Transformer(object):
name = self.remove_prefix(symbol.ident, True)
else:
name = self.remove_prefix(symbol.ident)
- return Callback(name, retval, list(parameters), symbol.ident)
+ callback = Callback(name, retval, list(parameters), symbol.ident)
+
+ self._parse_version(callback, directives)
+
+ return callback
def _typepair_to_str(self, item):
nsname, item = item