gobject-introspection r724 - in trunk: gir girepository giscanner tests tests/scanner tests/types tools
- From: walters svn gnome org
- To: svn-commits-list gnome org
- Subject: gobject-introspection r724 - in trunk: gir girepository giscanner tests tests/scanner tests/types tools
- Date: Thu, 16 Oct 2008 01:40:30 +0000 (UTC)
Author: walters
Date: Thu Oct 16 01:40:29 2008
New Revision: 724
URL: http://svn.gnome.org/viewvc/gobject-introspection?rev=724&view=rev
Log:
Merge branch 'bug556331-includecleanup'
Modified:
trunk/gir/Makefile.am
trunk/girepository/girepository.c
trunk/girepository/girparser.c
trunk/giscanner/ast.py
trunk/giscanner/girparser.py
trunk/giscanner/girwriter.py
trunk/giscanner/transformer.py
trunk/tests/object.gir
trunk/tests/scanner/Makefile.am
trunk/tests/scanner/annotation-1.0-expected.gir
trunk/tests/scanner/drawable-1.0-expected.gir
trunk/tests/scanner/foo-1.0-expected.gir
trunk/tests/scanner/foo.h
trunk/tests/scanner/utility-1.0-expected.gir
trunk/tests/scanner/utility.h
trunk/tests/types/Makefile.am
trunk/tools/g-ir-scanner
Modified: trunk/gir/Makefile.am
==============================================================================
--- trunk/gir/Makefile.am (original)
+++ trunk/gir/Makefile.am Thu Oct 16 01:40:29 2008
@@ -17,6 +17,7 @@
GLib-2.0.gir: $(G_IR_SCANNER) $(G_IR_SCANNER_FILES) Makefile
PYTHONPATH=$(top_builddir):$$PYTHONPATH $(G_IR_SCANNER) \
-v --namespace GLib --nsversion=2.0 \
+ --add-include-path=. \
--noclosure \
--output $@ \
--strip-prefix=g \
@@ -45,10 +46,11 @@
GObject-2.0.gir: GLib-2.0.gir $(G_IR_SCANNER) $(G_IR_SCANNER_FILES) Makefile
PYTHONPATH=$(top_builddir):$$PYTHONPATH $(G_IR_SCANNER) \
-v --namespace GObject --nsversion=2.0 \
+ --add-include-path=. \
--noclosure \
--output $@ \
--strip-prefix=g \
- --include=$(top_builddir)/gir/GLib-2.0.gir \
+ --include=GLib-2.0 \
--library=$(GOBJECT_LIBRARY) \
-I$(GOBJECT_INCLUDEDIR) \
-I$(GOBJECT_LIBDIR)/glib-2.0/include \
@@ -70,10 +72,11 @@
GModule-2.0.gir: GLib-2.0.gir $(G_IR_SCANNER) $(G_IR_SCANNER_FILES)
PYTHONPATH=$(top_builddir):$$PYTHONPATH $(G_IR_SCANNER) \
-v --namespace GModule --nsversion=2.0 \
+ --add-include-path=. \
--noclosure \
--output $@ \
--strip-prefix=g \
- --include=$(top_builddir)/gir/GLib-2.0.gir \
+ --include=GLib-2.0 \
--library=$(GMODULE_LIBRARY) \
-I$(GMODULE_INCLUDEDIR) \
-I$(GMODULE_LIBDIR)/glib-2.0/include \
@@ -94,10 +97,11 @@
Gio-2.0.gir: GObject-2.0.gir $(G_IR_SCANNER) $(G_IR_SCANNER_FILES) Makefile
PYTHONPATH=$(top_builddir):$$PYTHONPATH $(G_IR_SCANNER) \
-v --namespace Gio --nsversion=2.0 \
+ --add-include-path=. \
--noclosure \
--output $@ \
--strip-prefix=g \
- --include=$(top_builddir)/gir/GObject-2.0.gir \
+ --include=GObject-2.0 \
--library=$(GIO_LIBRARY) \
-I$(GIO_INCLUDEDIR) \
-I$(GIO_LIBDIR)/glib-2.0/include \
Modified: trunk/girepository/girepository.c
==============================================================================
--- trunk/girepository/girepository.c (original)
+++ trunk/girepository/girepository.c Thu Oct 16 01:40:29 2008
@@ -1060,7 +1060,7 @@
if (version != NULL)
g_set_error (error, G_IREPOSITORY_ERROR,
G_IREPOSITORY_ERROR_TYPELIB_NOT_FOUND,
- "Typelib file %s for namespace '%s', version '%s' not found",
+ "Typelib file for namespace '%s', version '%s' not found",
namespace, version);
else
g_set_error (error, G_IREPOSITORY_ERROR,
Modified: trunk/girepository/girparser.c
==============================================================================
--- trunk/girepository/girparser.c (original)
+++ trunk/girepository/girparser.c Thu Oct 16 01:40:29 2008
@@ -130,7 +130,7 @@
};
static char *
-locate_gir (const char *name, const char * const* extra_paths)
+locate_gir (const char *name, const char *version, const char * const* extra_paths)
{
const gchar *const *datadirs;
const gchar *const *dir;
@@ -141,7 +141,7 @@
datadirs = g_get_system_data_dirs ();
- girname = g_strdup_printf ("%s.gir", name);
+ girname = g_strdup_printf ("%s-%s.gir", name, version);
for (dir = datadirs; *dir; dir++)
{
@@ -981,7 +981,6 @@
{
key = g_strdup (name);
}
-
g_hash_table_insert (ctx->aliases, key, value);
return TRUE;
@@ -2048,6 +2047,7 @@
parse_include (GMarkupParseContext *context,
ParseContext *ctx,
const char *name,
+ const char *version,
GError **error)
{
ParseContext sub_ctx = { 0 };
@@ -2056,7 +2056,7 @@
gsize length;
char *girpath;
- girpath = locate_gir (name, ctx->includes);
+ girpath = locate_gir (name, version, ctx->includes);
if (girpath == NULL)
{
@@ -2231,19 +2231,27 @@
ctx->state == STATE_REPOSITORY)
{
const gchar *name;
-
+ const gchar *version;
+
name = find_attribute ("name", attribute_names, attribute_values);
+ version = find_attribute ("version", attribute_names, attribute_values);
if (name == NULL)
{
MISSING_ATTRIBUTE (context, error, element_name, "name");
break;
}
+ if (version == NULL)
+ {
+ MISSING_ATTRIBUTE (context, error, element_name, "version");
+ break;
+ }
- if (!parse_include (context, ctx, name, error))
+ if (!parse_include (context, ctx, name, version, error))
break;
- ctx->dependencies = g_list_prepend (ctx->dependencies, g_strdup (name));
+ ctx->dependencies = g_list_prepend (ctx->dependencies,
+ g_strdup_printf ("%s-%s", name, version));
state_switch (ctx, STATE_INCLUDE);
Modified: trunk/giscanner/ast.py
==============================================================================
--- trunk/giscanner/ast.py (original)
+++ trunk/giscanner/ast.py Thu Oct 16 01:40:29 2008
@@ -155,6 +155,32 @@
self.version, self.nodes)
+class Include(Node):
+
+ def __init__(self, name, version):
+ Node.__init__(self, 'include')
+ self.name = name
+ self.version = version
+
+ @classmethod
+ def from_string(self, string):
+ return Include(*string.split('-', 1))
+
+ def __cmp__(self, other):
+ if not isinstance(other, Include):
+ return cmp(self, other)
+ namecmp = cmp(self.name, other.name)
+ if namecmp != 0:
+ return namecmp
+ return cmp(self.version, other.version)
+
+ def __hash__(self):
+ return hash((self.name, self.version))
+
+ def __str__(self):
+ return '%s-%s' % (self.name, self.version)
+
+
class Function(Node):
def __init__(self, name, retval, parameters, symbol):
Modified: trunk/giscanner/girparser.py
==============================================================================
--- trunk/giscanner/girparser.py (original)
+++ trunk/giscanner/girparser.py Thu Oct 16 01:40:29 2008
@@ -22,7 +22,7 @@
from .ast import (Alias, Array, Callback, Constant, Enum, Function, Field,
Namespace, Parameter, Property, Return, Union, Struct, Type,
- Varargs)
+ Varargs, Include)
from .glibast import (GLibEnum, GLibEnumMember, GLibFlags,
GLibInterface, GLibObject, GLibBoxedStruct,
GLibBoxedUnion, GLibBoxedOther)
@@ -85,7 +85,9 @@
assert root.tag == _corens('repository')
for node in root.getchildren():
if node.tag == _corens('include'):
- self._includes.add((node.attrib['name']))
+ include = Include(node.attrib['name'],
+ node.attrib['version'])
+ self._includes.add(include)
ns = root.find(_corens('namespace'))
assert ns is not None
self._namespace = Namespace(ns.attrib['name'], ns.attrib['version'])
Modified: trunk/giscanner/girwriter.py
==============================================================================
--- trunk/giscanner/girwriter.py (original)
+++ trunk/giscanner/girwriter.py Thu Oct 16 01:40:29 2008
@@ -48,7 +48,7 @@
self._write_namespace(namespace, shlibs)
def _write_include(self, include):
- attrs = [('name', include)]
+ attrs = [('name', include.name), ('version', include.version)]
self.write_tag('include', attrs)
def _write_namespace(self, namespace, shlibs):
Modified: trunk/giscanner/transformer.py
==============================================================================
--- trunk/giscanner/transformer.py (original)
+++ trunk/giscanner/transformer.py Thu Oct 16 01:40:29 2008
@@ -96,24 +96,15 @@
self._add_node(node)
return self._namespace
- def register_include(self, filename):
- (dirname, basename) = os.path.split(filename)
- if dirname:
- path = filename
- (name, suffix) = os.path.splitext(basename)
- else:
- path = None
- name = filename
- if name.endswith('.gir'):
- (name, suffix) = os.path.splitext(name)
- if name in self._includes:
- return
- source = filename
+ def set_include_paths(self, paths):
+ self._includepaths = list(paths)
+
+ def register_include(self, include, path=None):
if path is None:
- girname = name + '.gir'
- searchdirs = [os.path.join(d, 'gir') for d \
- in _xdg_data_dirs]
- searchdirs.extend(self._includepaths)
+ girname = '%s-%s.gir' % (include.name, include.version)
+ searchdirs = list(self._includepaths)
+ searchdirs.extend([os.path.join(d, 'gir')
+ for d in _xdg_data_dirs])
for d in searchdirs:
path = os.path.join(d, girname)
if os.path.exists(path):
@@ -123,9 +114,7 @@
raise ValueError("Couldn't find include %r (search path: %r)"\
% (girname, searchdirs))
d = os.path.dirname(path)
- if d not in self._includepaths:
- self._includepaths.append(d)
- self._includes.add(name)
+ self._includes.add(include)
from .girparser import GIRParser
parser = GIRParser(path)
for include in parser.get_includes():
Modified: trunk/tests/object.gir
==============================================================================
--- trunk/tests/object.gir (original)
+++ trunk/tests/object.gir Thu Oct 16 01:40:29 2008
@@ -3,7 +3,7 @@
xmlns="http://www.gtk.org/introspection/core/1.0"
xmlns:c="http://www.gtk.org/introspection/c/1.0"
xmlns:glib="http://www.gtk.org/introspection/glib/1.0">
- <include name="GObject-2.0"/>
+ <include name="GObject" version="2.0"/>
<namespace name="Foo" version="1.0">
<interface name="IFace1" glib:type-name="IFace1" glib:get-type="iface1_get_type"/>
<class name="Object1" parent="Object2" glib:type-name="Object1" glib:get-type="object1_get_type">
Modified: trunk/tests/scanner/Makefile.am
==============================================================================
--- trunk/tests/scanner/Makefile.am (original)
+++ trunk/tests/scanner/Makefile.am Thu Oct 16 01:40:29 2008
@@ -36,8 +36,9 @@
annotation-1.0.gir: libannotation.la annotation.c annotation.h utility-1.0.gir $(SCANNER) $(SCANNER_LIBS) Makefile
PYTHONPATH=$(top_builddir):$$PYTHONPATH $(CHECK_DEBUG) $(SCANNER) -v \
- --include=$(top_srcdir)/gir/GObject-2.0.gir \
- --include=$(top_builddir)/tests/scanner/utility-1.0.gir \
+ --add-include-path=$(top_builddir)/gir --add-include-path=. \
+ --include=GObject-2.0 \
+ --include=utility-1.0 \
--library=annotation \
--namespace=annotation \
--nsversion=1.0 \
@@ -48,8 +49,9 @@
drawable-1.0.gir: libdrawable.la drawable.c drawable.h utility-1.0.gir $(SCANNER) $(SCANNER_LIBS) Makefile
PYTHONPATH=$(top_builddir):$$PYTHONPATH $(CHECK_DEBUG) $(SCANNER) -v \
- --include=$(top_srcdir)/gir/GObject-2.0.gir \
- --include=$(top_builddir)/tests/scanner/utility-1.0.gir \
+ --add-include-path=$(top_builddir)/gir --add-include-path=. \
+ --include=GObject-2.0 \
+ --include=utility-1.0 \
--library=drawable \
--namespace=drawable \
--nsversion=1.0 \
@@ -60,8 +62,9 @@
foo-1.0.gir: libfoo.la foo.c foo.h utility-1.0.gir $(SCANNER) $(SCANNER_LIBS) Makefile
PYTHONPATH=$(top_builddir):$$PYTHONPATH $(CHECK_DEBUG) $(SCANNER) -v \
- --include=$(top_srcdir)/gir/GObject-2.0.gir \
- --include=$(top_builddir)/tests/scanner/utility-1.0.gir \
+ --add-include-path=$(top_builddir)/gir --add-include-path=. \
+ --include=GObject-2.0 \
+ --include=utility-1.0 \
--library=foo \
--namespace=foo \
--nsversion=1.0 \
@@ -72,7 +75,8 @@
utility-1.0.gir: libutility.la utility.h $(SCANNER) $(SCANNER_LIBS) Makefile
PYTHONPATH=$(top_builddir):$$PYTHONPATH $(CHECK_DEBUG) $(SCANNER) -v \
- --include=$(top_srcdir)/gir/GObject-2.0.gir \
+ --add-include-path=$(top_builddir)/gir --add-include-path=. \
+ --include=GObject-2.0 \
--library=utility \
--namespace=utility \
--nsversion=1.0 \
Modified: trunk/tests/scanner/annotation-1.0-expected.gir
==============================================================================
--- trunk/tests/scanner/annotation-1.0-expected.gir (original)
+++ trunk/tests/scanner/annotation-1.0-expected.gir Thu Oct 16 01:40:29 2008
@@ -3,9 +3,9 @@
xmlns="http://www.gtk.org/introspection/core/1.0"
xmlns:c="http://www.gtk.org/introspection/c/1.0"
xmlns:glib="http://www.gtk.org/introspection/glib/1.0">
- <include name="GLib-2.0"/>
- <include name="GObject-2.0"/>
- <include name="utility-1.0"/>
+ <include name="GLib" version="2.0"/>
+ <include name="GObject" version="2.0"/>
+ <include name="utility" version="1.0"/>
<namespace name="annotation" version="1.0" shared-library="annotation">
<class name="Object"
c:type="AnnotationObject"
Modified: trunk/tests/scanner/drawable-1.0-expected.gir
==============================================================================
--- trunk/tests/scanner/drawable-1.0-expected.gir (original)
+++ trunk/tests/scanner/drawable-1.0-expected.gir Thu Oct 16 01:40:29 2008
@@ -3,9 +3,9 @@
xmlns="http://www.gtk.org/introspection/core/1.0"
xmlns:c="http://www.gtk.org/introspection/c/1.0"
xmlns:glib="http://www.gtk.org/introspection/glib/1.0">
- <include name="GLib-2.0"/>
- <include name="GObject-2.0"/>
- <include name="utility-1.0"/>
+ <include name="GLib" version="2.0"/>
+ <include name="GObject" version="2.0"/>
+ <include name="utility" version="1.0"/>
<namespace name="drawable" version="1.0" shared-library="drawable">
<class name="TestDrawable"
c:type="TestDrawable"
Modified: trunk/tests/scanner/foo-1.0-expected.gir
==============================================================================
--- trunk/tests/scanner/foo-1.0-expected.gir (original)
+++ trunk/tests/scanner/foo-1.0-expected.gir Thu Oct 16 01:40:29 2008
@@ -3,9 +3,9 @@
xmlns="http://www.gtk.org/introspection/core/1.0"
xmlns:c="http://www.gtk.org/introspection/c/1.0"
xmlns:glib="http://www.gtk.org/introspection/glib/1.0">
- <include name="GLib-2.0"/>
- <include name="GObject-2.0"/>
- <include name="utility-1.0"/>
+ <include name="GLib" version="2.0"/>
+ <include name="GObject" version="2.0"/>
+ <include name="utility" version="1.0"/>
<namespace name="foo" version="1.0" shared-library="foo">
<alias name="List" target="GLib.SList" c:type="FooList"/>
<alias name="XEvent" target="none" c:type="FooXEvent"/>
@@ -123,6 +123,16 @@
<type name="utf8" c:type="char*"/>
</return-value>
</method>
+ <method name="handle_glyph" c:identifier="foo_object_handle_glyph">
+ <return-value>
+ <type name="none" c:type="void"/>
+ </return-value>
+ <parameters>
+ <parameter name="glyph">
+ <type name="utility.Glyph" c:type="UtilityGlyph"/>
+ </parameter>
+ </parameters>
+ </method>
<property name="string" writable="1">
<type name="utf8" c:type="gchararray"/>
</property>
Modified: trunk/tests/scanner/foo.h
==============================================================================
--- trunk/tests/scanner/foo.h (original)
+++ trunk/tests/scanner/foo.h Thu Oct 16 01:40:29 2008
@@ -70,6 +70,8 @@
char * foo_object_dup_name (FooObject *object);
+void foo_object_handle_glyph (FooObject *object, UtilityGlyph glyph);
+
struct _FooSubobject
{
FooObject parent_instance;
Modified: trunk/tests/scanner/utility-1.0-expected.gir
==============================================================================
--- trunk/tests/scanner/utility-1.0-expected.gir (original)
+++ trunk/tests/scanner/utility-1.0-expected.gir Thu Oct 16 01:40:29 2008
@@ -3,9 +3,10 @@
xmlns="http://www.gtk.org/introspection/core/1.0"
xmlns:c="http://www.gtk.org/introspection/c/1.0"
xmlns:glib="http://www.gtk.org/introspection/glib/1.0">
- <include name="GLib-2.0"/>
- <include name="GObject-2.0"/>
+ <include name="GLib" version="2.0"/>
+ <include name="GObject" version="2.0"/>
<namespace name="utility" version="1.0" shared-library="utility">
+ <alias name="Glyph" target="uint32" c:type="UtilityGlyph"/>
<class name="Object"
c:type="UtilityObject"
parent="GObject.Object"
Modified: trunk/tests/scanner/utility.h
==============================================================================
--- trunk/tests/scanner/utility.h (original)
+++ trunk/tests/scanner/utility.h Thu Oct 16 01:40:29 2008
@@ -20,6 +20,9 @@
GObjectClass parent_class;
};
+/* This one is similar to Pango.Glyph */
+typedef guint32 UtilityGlyph;
+
GType utility_object_get_type (void) G_GNUC_CONST;
typedef enum
Modified: trunk/tests/types/Makefile.am
==============================================================================
--- trunk/tests/types/Makefile.am (original)
+++ trunk/tests/types/Makefile.am Thu Oct 16 01:40:29 2008
@@ -30,7 +30,8 @@
gitesttypes-1.0.gir: libgitesttypes.la gitesttypes.c gitesttypes.h $(SCANNER) $(SCANNER_LIBS)
PYTHONPATH=$(top_builddir):$$PYTHONPATH $(CHECK_DEBUG) $(SCANNER) -v \
- --include=$(top_srcdir)/gir/GObject-2.0.gir \
+ --add-include-path=$(top_builddir)/gir \
+ --include=GObject-2.0 \
--library=gitesttypes \
--namespace=gitesttypes --nsversion=1.0 \
--pkg gobject-2.0 \
Modified: trunk/tools/g-ir-scanner
==============================================================================
--- trunk/tools/g-ir-scanner (original)
+++ trunk/tools/g-ir-scanner Thu Oct 16 01:40:29 2008
@@ -38,6 +38,7 @@
from giscanner.glibtransformer import GLibTransformer
from giscanner.sourcescanner import SourceScanner
from giscanner.transformer import Transformer
+from giscanner.ast import Include
from giscanner.minixpath import myxpath, xpath_assert
@@ -50,6 +51,9 @@
parser.add_option("-i", "--include",
action="append", dest="includes", default=[],
help="include types for other gidls")
+ parser.add_option("--add-include-path",
+ action="append", dest="include_paths", default=[],
+ help="include paths for other GIR files")
parser.add_option("-l", "--library",
action="append", dest="libraries", default=[],
help="libraries of this unit")
@@ -249,8 +253,13 @@
# Transform the C symbols into AST nodes
transformer = Transformer(ss, options.namespace_name, options.namespace_version)
transformer.set_strip_prefix(options.strip_prefix)
+ transformer.set_include_paths(options.include_paths)
+ shown_include_warning = False
for include in options.includes:
- transformer.register_include(include)
+ if os.sep in include:
+ raise ValueError("Invalid include path %r" % (include, ))
+ include_obj = Include.from_string(include)
+ transformer.register_include(include_obj)
# Transform the C AST nodes into higher level
# GLib/GObject nodes
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]