gobject-introspection r193 - in trunk: . giscanner tools
- From: johan svn gnome org
- To: svn-commits-list gnome org
- Subject: gobject-introspection r193 - in trunk: . giscanner tools
- Date: Mon, 21 Apr 2008 19:05:19 +0100 (BST)
Author: johan
Date: Mon Apr 21 18:05:18 2008
New Revision: 193
URL: http://svn.gnome.org/viewvc/gobject-introspection?rev=193&view=rev
Log:
2008-04-21 Johan Dahlin <johan gnome org>
* giscanner/gidlwriter.py:
* giscanner/gobjecttreebuilder.py:
* giscanner/treebuilder.py:
Add basic support for interfaces
* tools/g-ir-scanner:
Add -o/--output for writing to a file
Modified:
trunk/ChangeLog
trunk/giscanner/gidlwriter.py
trunk/giscanner/gobjecttreebuilder.py
trunk/giscanner/treebuilder.py
trunk/tools/g-ir-scanner
Modified: trunk/giscanner/gidlwriter.py
==============================================================================
--- trunk/giscanner/gidlwriter.py (original)
+++ trunk/giscanner/gidlwriter.py Mon Apr 21 18:05:18 2008
@@ -1,8 +1,8 @@
from __future__ import with_statement
from .gobjecttreebuilder import (GLibEnum, GLibEnumMember, GLibFlags,
- GLibObject)
-from .treebuilder import Class, Enum, Function
+ GLibObject, GLibInterface)
+from .treebuilder import Class, Enum, Function, Interface
from .xmlwriter import XMLWriter
@@ -27,6 +27,8 @@
self._write_enum(node)
elif isinstance(node, Class):
self._write_class(node)
+ elif isinstance(node, Interface):
+ self._write_interface(node)
else:
print 'WRITER: Unhandled node', node
@@ -83,3 +85,11 @@
with self.tagcontext('object', attrs):
for method in class_.methods:
self._write_method(method)
+
+ def _write_interface(self, interface):
+ attrs = [('name', interface.name)]
+ if isinstance(interface, GLibInterface):
+ attrs.append(('get-type', interface.get_type))
+ with self.tagcontext('interface', attrs):
+ for method in interface.methods:
+ self._write_method(method)
Modified: trunk/giscanner/gobjecttreebuilder.py
==============================================================================
--- trunk/giscanner/gobjecttreebuilder.py (original)
+++ trunk/giscanner/gobjecttreebuilder.py Mon Apr 21 18:05:18 2008
@@ -3,7 +3,7 @@
import os
from . import cgobject
-from .treebuilder import Class, Enum, Function, Member, Struct
+from .treebuilder import Class, Enum, Function, Interface, Member, Struct
from .odict import odict
@@ -59,6 +59,13 @@
Class.__init__(self, name, parent, methods)
self.get_type = get_type
+
+class GLibInterface(Interface):
+ def __init__(self, name, methods, get_type):
+ Interface.__init__(self, name, methods)
+ self.get_type = get_type
+
+
class GObjectTreeBuilder(object):
def __init__(self, namespace_name):
self._namespace_name = namespace_name
@@ -181,6 +188,8 @@
self._introspect_enum(fundamental_type_id, type_id, symbol)
elif fundamental_type_id == cgobject.TYPE_OBJECT:
self._introspect_object(type_id, symbol)
+ elif fundamental_type_id == cgobject.TYPE_INTERFACE:
+ self._introspect_interface(type_id, symbol)
else:
print 'unhandled GType: %s' % (cgobject.type_name(type_id),)
@@ -204,3 +213,8 @@
parent_name = cgobject.type_name(cgobject.type_parent(type_id))
node = GLibObject(type_name, parent_name, [], symbol)
self._add_attribute(node, replace=True)
+
+ def _introspect_interface(self, type_id, symbol):
+ type_name = cgobject.type_name(type_id)
+ node = GLibInterface(type_name, [], symbol)
+ self._add_attribute(node, replace=True)
Modified: trunk/giscanner/treebuilder.py
==============================================================================
--- trunk/giscanner/treebuilder.py (original)
+++ trunk/giscanner/treebuilder.py Mon Apr 21 18:05:18 2008
@@ -67,7 +67,17 @@
self.methods = methods
def __repr__(self):
- return 'Class(%r, %r)' % (self.name, self.methods)
+ return 'Class(%r, %r, %r)' % (
+ self.name, self.parent, self.methods)
+
+
+class Interface(Node):
+ def __init__(self, name, methods):
+ self.name = name
+ self.methods = methods
+
+ def __repr__(self):
+ return 'Interface(%r, %r)' % (self.name, self.methods)
class TreeBuilder(object):
Modified: trunk/tools/g-ir-scanner
==============================================================================
--- trunk/tools/g-ir-scanner (original)
+++ trunk/tools/g-ir-scanner Mon Apr 21 18:05:18 2008
@@ -18,6 +18,9 @@
parser.add_option("-n", "--namespace",
action="store", dest="namespace",
help="namespace of this unit")
+ parser.add_option("-o", "--output",
+ action="store", dest="output",
+ help="output to writeout, defaults to stdout")
parser.add_option("", "--pkg",
action="append", dest="packages", default=[],
help="pkg-config packages to get cflags from")
@@ -70,7 +73,12 @@
builder.parse(TreeBuilder(ss).get_nodes())
writer = GIDLWriter(options.namespace, builder.get_nodes())
- print writer.get_xml()
+ data = writer.get_xml()
+ if options.output:
+ fd = open(options.output, "w")
+ fd.write(data)
+ else:
+ print data
sys.exit(main(sys.argv))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]