summaryrefslogtreecommitdiff
path: root/giscanner
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2009-02-20 17:34:20 -0500
committerColin Walters <walters@verbum.org>2009-02-25 17:31:49 -0500
commit251de52b083d3e0e42f25cb164a46865c2c2b9a9 (patch)
tree99db442fd1bb299466f5d277561becfca4b220ee /giscanner
parent0b9dda0e725446882dca84b6a64688c8f0e5a4e3 (diff)
downloadgobject-introspection-251de52b083d3e0e42f25cb164a46865c2c2b9a9.tar.gz
Bug 572434 - Associate interfaces with their C structures
Similar to GObject class structs, we pair up GInterfaces with their C structures. Also, move some GLib-specific things into glibast.py, and make the naming more generic.
Diffstat (limited to 'giscanner')
-rw-r--r--giscanner/ast.py8
-rw-r--r--giscanner/girwriter.py16
-rw-r--r--giscanner/glibast.py18
-rw-r--r--giscanner/glibtransformer.py12
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