summaryrefslogtreecommitdiff
path: root/giscanner/ast.py
diff options
context:
space:
mode:
authorJohan Dahlin <johan@gnome.org>2010-09-02 23:35:09 -0300
committerJohan Dahlin <johan@gnome.org>2010-09-02 23:45:33 -0300
commite9684fcc96c2de2ad1337e368cdb642cd6e58e4c (patch)
treeb956e4d203b3a204d0657821411f623a022c77cc /giscanner/ast.py
parentd9f8c0002c9dbd9154b49d3b23c1bd85423760ab (diff)
downloadgobject-introspection-e9684fcc96c2de2ad1337e368cdb642cd6e58e4c.tar.gz
[scanner] Move a function from transformer to ast
It doesn't use any internal state, so it can easily be moved over to the type as a factory function
Diffstat (limited to 'giscanner/ast.py')
-rw-r--r--giscanner/ast.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/giscanner/ast.py b/giscanner/ast.py
index c819d024..5267aef9 100644
--- a/giscanner/ast.py
+++ b/giscanner/ast.py
@@ -30,7 +30,7 @@ class Type(object):
If none are specified, then it's in an "unresolved" state. An
unresolved type can have two data sources; a "ctype" which comes
from a C type string, or a gtype_name (from g_type_name()).
-"""
+""" # '''
def __init__(self,
ctype=None,
@@ -79,6 +79,17 @@ from a C type string, or a gtype_name (from g_type_name()).
else:
assert False
+ @classmethod
+ def create_from_gtype_name(cls, gtype_name):
+ """Parse a GType name (as from g_type_name()), and return a
+Type instance. Note that this function performs namespace lookup,
+in contrast to the other create_type() functions."""
+ # First, is it a fundamental?
+ fundamental = type_names.get(gtype_name)
+ if fundamental is not None:
+ return cls(target_fundamental=fundamental.target_fundamental)
+ return cls(gtype_name=gtype_name)
+
def get_giname(self):
assert self.target_giname is not None
return self.target_giname.split('.')[1]