diff options
Diffstat (limited to 'giscanner')
-rw-r--r-- | giscanner/ast.py | 8 | ||||
-rw-r--r-- | giscanner/girwriter.py | 16 | ||||
-rw-r--r-- | giscanner/glibast.py | 18 | ||||
-rw-r--r-- | giscanner/glibtransformer.py | 12 |
4 files changed, 36 insertions, 18 deletions
diff --git a/giscanner/ast.py b/giscanner/ast.py index ff65312c..e708258c 100644 --- a/giscanner/ast.py +++ b/giscanner/ast.py @@ -1,6 +1,7 @@ # -*- Mode: Python -*- # GObject-Introspection - a framework for introspecting GObject libraries # Copyright (C) 2008 Johan Dahlin +# Copyright (C) 2008, 2009 Red Hat, Inc. # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -366,11 +367,7 @@ class Record(Node): self.symbol = symbol self.disguised = disguised self.doc = None - self.constructors = [] self.methods = [] - # If true, this record defines the FooClass C structure - # for some Foo GObject - self.is_gobject_struct_for = False # BW compat, remove Struct = Record @@ -410,7 +407,7 @@ class Class(Node): Node.__init__(self, name) self.ctype = name self.parent = parent - self.class_struct = None + self.glib_type_struct = None self.is_abstract = is_abstract self.methods = [] self.static_methods = [] @@ -432,6 +429,7 @@ class Interface(Node): Node.__init__(self, name) self.parent = parent self.methods = [] + self.glib_type_struct = None self.properties = [] self.fields = [] self.prerequisites = [] diff --git a/giscanner/girwriter.py b/giscanner/girwriter.py index 4742840d..df527090 100644 --- a/giscanner/girwriter.py +++ b/giscanner/girwriter.py @@ -1,6 +1,7 @@ # -*- Mode: Python -*- # GObject-Introspection - a framework for introspecting GObject libraries # Copyright (C) 2008 Johan Dahlin +# Copyright (C) 2008, 2009 Red Hat, Inc. # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -27,7 +28,8 @@ from .ast import (Alias, Array, Bitfield, Callback, Class, Constant, Enum, Function, Interface, List, Map, Member, Struct, Union, Varargs) from .glibast import (GLibBoxed, GLibEnum, GLibEnumMember, - GLibFlags, GLibObject, GLibInterface) + GLibFlags, GLibObject, GLibInterface, + GLibRecord) from .xmlwriter import XMLWriter @@ -330,9 +332,8 @@ and/or use gtk-doc annotations. ''') attrs.append(('glib:type-name', node.type_name)) if node.get_type: attrs.append(('glib:get-type', node.get_type)) - if isinstance(node, GLibObject): - if node.class_struct: - attrs.append(('glib:class-struct', node.class_struct.name)) + if node.glib_type_struct: + attrs.append(('glib:type-struct', node.glib_type_struct.name)) with self.tagcontext(tag_name, attrs): if isinstance(node, GLibObject): for iface in node.interfaces: @@ -408,9 +409,10 @@ and/or use gtk-doc annotations. ''') attrs.append(('c:type', record.symbol)) if record.disguised: attrs.append(('disguised', '1')) - if record.is_gobject_struct_for: - attrs.append(('glib:is-class-struct-for', - record.is_gobject_struct_for)) + if isinstance(record, GLibRecord): + if record.is_gtype_struct_for: + attrs.append(('glib:is-gtype-struct-for', + record.is_gtype_struct_for)) if record.doc: attrs.append(('doc', record.doc)) self._append_version(record, attrs) diff --git a/giscanner/glibast.py b/giscanner/glibast.py index f61cd5f3..e2a9d5b2 100644 --- a/giscanner/glibast.py +++ b/giscanner/glibast.py @@ -19,7 +19,7 @@ # from .ast import (Bitfield, Class, Enum, Interface, Member, Node, - Property, Struct, Union) + Property, Struct, Union, Record) from .ast import ( type_names, default_array_types, TYPE_STRING, TYPE_INT8, TYPE_UINT8, TYPE_INT16, TYPE_UINT16, @@ -62,6 +62,22 @@ type_names['gushort'] = TYPE_UINT16 default_array_types['guint8*'] = TYPE_UINT8 default_array_types['gchar**'] = TYPE_STRING +class GLibRecord(Record): + def __init__(self, *args, **kwargs): + Record.__init__(self, *args, **kwargs) + + @classmethod + def from_record(cls, record): + obj = cls(record.name, record.symbol) + obj.fields = record.fields + obj.constructors = record.constructors + obj.disguised = record.disguised + obj.doc = record.doc + obj.methods = record.methods + # If true, this record defines the FooClass C structure + # for some Foo GObject (or similar for GInterface) + obj.is_gtype_struct_for = False + return obj class GLibEnum(Enum): diff --git a/giscanner/glibtransformer.py b/giscanner/glibtransformer.py index e5dd3a18..5a7a96d2 100644 --- a/giscanner/glibtransformer.py +++ b/giscanner/glibtransformer.py @@ -32,7 +32,7 @@ from .ast import (Alias, Bitfield, Callback, Constant, Enum, Function, Member, from .transformer import Names from .glibast import (GLibBoxed, GLibEnum, GLibEnumMember, GLibFlags, GLibInterface, GLibObject, GLibSignal, GLibBoxedStruct, - GLibBoxedUnion, GLibBoxedOther, type_names) + GLibBoxedUnion, GLibBoxedOther, GLibRecord, type_names) from .utils import to_underscores, to_underscores_noprefix default_array_types['guchar*'] = TYPE_UINT8 @@ -573,13 +573,15 @@ class GLibTransformer(object): for field in maybe_class.fields: if isinstance(field, Field): field.writable = False + # TODO: remove this, we should be computing vfuncs instead if isinstance(pair_class, GLibInterface): for field in maybe_class.fields[1:]: pair_class.fields.append(field) - return - elif isinstance(pair_class, GLibObject): - pair_class.class_struct = class_struct - class_struct.is_gobject_struct_for = name + gclass_struct = GLibRecord.from_record(class_struct) + self._remove_attribute(class_struct.name) + self._add_attribute(gclass_struct, True) + pair_class.glib_type_struct = gclass_struct + gclass_struct.is_gtype_struct_for = name # Introspection |