[scanner] Remove support for xpath assertions
authorJohan Dahlin <johan@gnome.org>
Thu, 2 Sep 2010 00:34:44 +0000 (21:34 -0300)
committerJohan Dahlin <johan@gnome.org>
Thu, 2 Sep 2010 00:34:44 +0000 (21:34 -0300)
It has been broken for a while and nobody uses it.

gir/GLib-2.0.xpath [deleted file]
gir/GObject-2.0.xpath [deleted file]
gir/Makefile.am
giscanner/Makefile.am
giscanner/minixpath.py [deleted file]
giscanner/scannermain.py

diff --git a/gir/GLib-2.0.xpath b/gir/GLib-2.0.xpath
deleted file mode 100644 (file)
index 0d26271..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-/namespace/alias[@name='Quark']
-/namespace/record[@name='PtrArray']
-/namespace/callback[@name='ThreadFunc']/return-value/type[@name='any']
diff --git a/gir/GObject-2.0.xpath b/gir/GObject-2.0.xpath
deleted file mode 100644 (file)
index 3a97543..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-/namespace/class[@name='Object']/field[@name='g_type_instance']
-/namespace/class[@name='Object']/field[@name='ref_count']
-/namespace/class[@name='Object']/field[@name='qdata']
index f08af00ded6d76524b37532e6b4b2c2853973fbc..8f5708793a110cfa0bd16cb0e6910277b47106ae 100644 (file)
@@ -41,14 +41,12 @@ GLib_2_0_gir_CFLAGS = \
             -DGETTEXT_PACKAGE=Dummy \
             -DGLIB_COMPILATION \
             -D__G_I18N_LIB_H__
-GLib_2_0_gir_ASSERTIONS = GLib-2.0.xpath
 GLib_2_0_gir_FILES =  \
                 $(GLIB_LIBDIR)/glib-2.0/include/glibconfig.h \
        $(GLIB_INCLUDEDIR)/glib/*.h \
                 glib-2.0.c
 
 INTROSPECTION_GIRS += GLib-2.0.gir
-EXTRA_DIST += glib-2.0.c GLib-2.0.xpath
 
 DBusGLib-1.0.typelib: GObject-2.0.gir
 
@@ -72,11 +70,9 @@ GObject_2_0_gir_CFLAGS = \
             -DGOBJECT_COMPILATION \
                 -I$(GOBJECT_INCLUDEDIR) \
             -I$(GOBJECT_LIBDIR)/glib-2.0/include
-GObject_2_0_gir_ASSERTIONS = GObject-2.0.xpath
 GObject_2_0_gir_FILES = $(GLIB_INCLUDEDIR)/gobject/*.h gobject-2.0.c
 
 INTROSPECTION_GIRS += GObject-2.0.gir
-EXTRA_DIST += gobject-2.0.c GObject-2.0.xpath
 
 # gmodule
 GMODULE_INCLUDEDIR=$(shell pkg-config --variable=includedir gmodule-2.0)/glib-2.0
index 5f3d09448b1d895aa36543d579adb4ab08c9b5f1..c01599f933fbb210346e5791b02b0166c653bef2 100644 (file)
@@ -45,7 +45,6 @@ pkgpyexec_PYTHON =            \
        glibast.py              \
        gdumpparser.py  \
        libtoolimporter.py      \
-       minixpath.py            \
        odict.py                \
        maintransformer.py      \
        shlibs.py               \
diff --git a/giscanner/minixpath.py b/giscanner/minixpath.py
deleted file mode 100644 (file)
index 5313a86..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-# -*- Mode: Python -*-
-# GObject-Introspection - a framework for introspecting GObject libraries
-# Copyright (C) 2008 Colin Walters
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2 of the License, or (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the
-# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-# Boston, MA 02111-1307, USA.
-#
-
-from .girparser import C_NS, GLIB_NS
-from .girparser import _corens
-
-_nsmap = {'c': C_NS,
-          'glib': GLIB_NS}
-
-
-def myxpath(node, expr):
-    """I Can't Believe It's Not XPath!"""
-    elts = expr.split('/')
-    curnode = node
-    for elt in elts:
-        if elt == '':
-            continue
-        try:
-            (elt, qual) = elt.split('[', 1)
-            qual = qual[1:-1]
-            pairs = [x.split('=', 1) for x in qual.split(',')]
-            exp_attrs = [(x[0], x[1][1:-1]) for x in pairs]
-        except ValueError, e:
-            (elt, exp_attrs) = (elt, [])
-        try:
-            (ns, elt) = elt.split(':', 1)
-            ns = _nsmap[ns]
-            elt = '{%s}%s' % (ns, elt)
-        except ValueError, e:
-            elt = _corens(elt)
-        curnodes = curnode.findall(elt)
-        if not curnodes:
-            return None
-        found = True
-        #print "LOOKING %d nodes" % (len(curnodes), )
-        for node in curnodes:
-            #print "LOOKING: %r expecting: %r attrib: %r" \
-            #    % (node, exp_attrs, node.attrib)
-            passes = True
-            for name, val in exp_attrs:
-                a = node.attrib.get(name)
-                if not a or a != val:
-                    #print "ATTR FAIL: %r=%r" % (val, a)
-                    passes = False
-                    break
-            if passes:
-                found = True
-                #print 'ATTR PASS: %r' % (node, )
-                curnode = node
-                break
-            found = False
-        if not found:
-            return None
-    return curnode
-
-
-def xpath_assert(node, path, attribs=[]):
-    elt = myxpath(node, path)
-    if elt is None:
-        raise AssertionError("Failed to find %r" % (path, ))
-    for (name, expvalue) in attribs:
-        value = elt.attrib.get(name)
-        if not value:
-            raise AssertionError("Failed to find attibute %r" +
-                                 "in node %r" % (name, elt, ))
-        if value != expvalue:
-            raise AssertionError("Attibute %r in node %r has " +
-                                 "unexpected value %r" % (name, elt, expvalue))
index 3bf2249c04da5b0983afc3d5b5443506ea5eb0c5..cbd237303ae917eddc629c49773157e539e13b15 100644 (file)
@@ -34,7 +34,6 @@ from giscanner.cachestore import CacheStore
 from giscanner.dumper import compile_introspection_binary
 from giscanner.gdumpparser import GDumpParser, IntrospectionBinary
 from giscanner.maintransformer import MainTransformer
-from giscanner.minixpath import xpath_assert
 from giscanner.introspectablepass import IntrospectablePass
 from giscanner.girparser import GIRParser
 from giscanner.girwriter import GIRWriter
@@ -118,9 +117,6 @@ match the namespace prefix.""")
     parser.add_option("-v", "--verbose",
                       action="store_true", dest="verbose",
                       help="be verbose")
-    parser.add_option("", "--xpath-assertions",
-                      action="store", dest="xpath_assertions",
-            help="Use given file to create assertions on GIR content")
     parser.add_option("", "--c-include",
                       action="append", dest="c_includes", default=[],
                       help="headers which should be included in C programs")
@@ -179,18 +175,6 @@ def test_codegen(optstring):
         _error("Invaild namespace %r" % (namespace, ))
     return 0
 
-def validate(assertions, path):
-    from xml.etree.cElementTree import parse
-    doc = parse(open(path))
-    root = doc.getroot()
-    f = open(assertions)
-    assertions_list = f.readlines()
-    for assertion in assertions_list:
-        assertion = assertion.strip()
-        xpath_assert(root, assertion)
-    f.close()
-    return 0
-
 def process_options(output, allowed_flags):
     for option in output.split():
         for flag in allowed_flags:
@@ -239,9 +223,6 @@ def scanner_main(args):
     if len(args) <= 1:
         _error('Need at least one filename')
 
-    if options.xpath_assertions:
-        return validate(options.xpath_assertions, args[1])
-
     if not options.namespace_name:
         _error('Namespace name missing')