Permalink
Browse files

Major rewrite

One of the first big changes in this rewrite is changing the Type
object to have separate target_fundamental and target_giname properties,
rather than just being strings.  Previously in the scanner, it was
awful because we used heuristics around strings.

The ast.py is refactored so that not everything is a Node - that
was a rather useless abstraction.  Now, only things which can have
a GIName are Node.  E.g. Type and Field are no longer Node.

More things were merged from glibast.py into ast.py, since it isn't
a very useful split.

transformer.py gains more intelligence and will e.g. turn GLib.List
into a List() object earlier.  The namespace processing is a lot
cleaner now; since we parse the included .girs, we know the C
prefix for each namespace, and have functions to parse both
C type names (GtkFooBar) and symbols gtk_foo_bar into their
symbols cleanly.  Type resolution is much, much saner because
we know Type(target_giname=Gtk.Foo) maps to the namespace Gtk.

glibtransformer.py now just handles the XML processing from the dump,
and a few miscellaneous things.

The major heavy lifting now lives in primarytransformer.py, which
is a combination of most of annotationparser.py and half of
glibtransformer.py.

annotationparser.py now literally just parses annotations; it's
no longer in the business of e.g. guessing transfer too.

finaltransformer.py is a new file which does post-analysis for
"introspectability" mainly.

girparser.c is fixed for some introspectable=0 processing.
  • Loading branch information...
1 parent 552c1f1 commit 36aa515f1036978ced8d4ffb808260844f7229e0 @cgwalters cgwalters committed Jul 27, 2010
Showing with 3,696 additions and 3,200 deletions.
  1. +21 −39 docs/g-ir-scanner.1
  2. +1 −1 gir/DBus-1.0.gir
  3. +1 −1 gir/DBusGLib-1.0.gir
  4. +1 −1 gir/GL-1.0.gir
  5. +7 −5 gir/Makefile.am
  6. +3 −2 gir/cairo-1.0.gir
  7. +1 −1 gir/fontconfig-2.0.gir
  8. +1 −1 gir/freetype2-2.0.gir
  9. +1 −1 gir/libxml2-2.0.gir
  10. +1 −1 gir/xfixes-4.0.gir
  11. +1 −1 gir/xft-2.0.gir
  12. +1 −1 gir/xlib-2.0.gir
  13. +1 −1 gir/xrandr-1.3.gir
  14. +1 −1 girepository/girmodule.c
  15. +71 −38 girepository/girparser.c
  16. +2 −2 girepository/gitypelib.c
  17. +5 −1 giscanner/Makefile.am
  18. +5 −729 giscanner/annotationparser.py
  19. +490 −262 giscanner/ast.py
  20. +137 −0 giscanner/codegen.py
  21. +1 −1 giscanner/dumper.py
  22. +455 −0 giscanner/gdumpparser.py
  23. +323 −164 giscanner/girparser.py
  24. +125 −110 giscanner/girwriter.py
  25. +53 −38 giscanner/glibast.py
  26. +0 −1,205 giscanner/glibtransformer.py
  27. +159 −0 giscanner/introspectablepass.py
  28. +933 −0 giscanner/maintransformer.py
  29. +80 −89 giscanner/scannermain.py
  30. +8 −2 giscanner/sourcescanner.py
  31. +119 −0 giscanner/testcodegen.py
  32. +399 −350 giscanner/transformer.py
  33. +13 −0 giscanner/utils.py
  34. +1 −1 tests/Makefile.am
  35. +68 −41 tests/scanner/Annotation-1.0-expected.gir
  36. +7 −2 tests/scanner/Bar-1.0-expected.gir
  37. +89 −36 tests/scanner/Foo-1.0-expected.gir
  38. +3 −2 tests/scanner/GtkFrob-1.0-expected.gir
  39. +1 −1 tests/scanner/Makefile.am
  40. +93 −59 tests/scanner/Regress-1.0-expected.gir
  41. +4 −2 tests/scanner/TestInherit-1.0-expected.gir
  42. +10 −8 tests/scanner/Utility-1.0-expected.gir
View
@@ -82,21 +82,30 @@ to pass the argument to this function to g_irepository_dump.
.B \--program-arg=ARG
Additional argument to pass to program for introspection.
.TP
-.B \--strip-prefix=PREFIX
-If this option is specified a prefix will be stripped from all functions.
-If not specified, the lower case version of the namespace will be used.
-Eg, a strip prefix of
-.B g_
-and a namespace set to
-.B GLib
-will export the function
-.B g_type_name
-as
-.B GLib.type_name.
+.B \--identifier-prefix=PREFIX
+This option may be specified multiple times. Each one
+gives a prefix that will be stripped from all C identifiers.
+If none specified, the namespace will be used.
+Eg, an identifier prefix of
+.B Foo
+will export the identifier
+.B typdef struct _FooBar FooBar;
+as
+.B Foo.Bar.
+.TP
+.B \--symbol-prefix=PREFIX
+This option may be specified multiple times. Each one
+gives a prefix that will be stripped from all C symbols.
+Eg, an symbol prefix of
+.B foo
+will export the symbol
+.B foo_bar_do_something
+as
+.B Foo.Bar.do_something.
.TP
.B \--output=FILENAME
Name of the file to output. Normally namespace + format extension.
-Eg, GLib.gir.
+Eg, GLib-2.0.gir.
.TP
.B \--pkg=PACKAGE
List of pkg-config packages to get compiler and linker flags from.
@@ -112,33 +121,6 @@ If not specified, the packages specified with --pkg= will be used.
.B \--verbose
Be verbose, include some debugging information.
.TP
-.B \--typelib-xml
-Convert the resulting xml to only output the types relevant
-to the typelib compiler. This is mainly useful for verifying the
-correctness of the typelib itself.
-.TP
-.B \--inject=FILENAME
-Injects a variant of a GIR file into the scanner. This is used to add
-custom functions to a GIR wrapping a library without modifying the upstream
-library itself. The Format of the inject file is similar to a GIR,
-but the root node is <injections> rather than <repository> and
-<inject path="..."> where ... is an xpath expression.
-
-Example:
-
- <inject path="namespace/class[@name='TestDrawable']">
- <method name="get_width" c:identifier="girepo_test_drawable_get_width">
- <return-value transfer-ownership="none">
- <type name="int" c:type="gint"/>
- </return-value>
- </method>
- </inject>
-
-The example above will add a new method called get_with to the TestDrawable class.
-.TP
-.B \--xpath-assertions=FILENAME
-Loads a list xpath assertions from FILENAME, this is useful for verifying
-that the GIR itself is properly generated.
.SH ENVIRONMENT VARIABLES
The g-ir-scanner uses the XDG_DATA_DIRS variable to check for dirs,
the gir's are located in XDG_DATA_DIRS/share/gir-1.0. It is normally
View
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
-<repository version="1.1"
+<repository version="1.2"
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">
View
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
-<repository version="1.1"
+<repository version="1.2"
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">
View
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
-<repository version="1.1"
+<repository version="1.2"
xmlns="http://www.gtk.org/introspection/core/1.0"
xmlns:c="http://www.gtk.org/introspection/c/1.0">
<namespace name="GL" version="1.0">
View
@@ -33,7 +33,7 @@ GLIB_LIBRARY=glib-2.0
endif
GLib_2_0_gir_LIBS = $(GLIB_LIBRARY)
-GLib_2_0_gir_SCANNERFLAGS = --strip-prefix=G --c-include="glib.h"
+GLib_2_0_gir_SCANNERFLAGS = --reparse-validate --identifier-prefix=G --symbol-prefix=g --symbol-prefix=glib --c-include="glib.h"
GLib_2_0_gir_PACKAGES = glib-2.0
GLib_2_0_gir_CFLAGS = \
-I$(GLIB_INCLUDEDIR) \
@@ -65,7 +65,7 @@ endif
GObject-2.0.gir: GLib-2.0.gir
GObject_2_0_gir_LIBS = $(GOBJECT_LIBRARY)
-GObject_2_0_gir_SCANNERFLAGS = --strip-prefix=G --c-include="glib-object.h" --add-include-path=.
+GObject_2_0_gir_SCANNERFLAGS = --reparse-validate --identifier-prefix=G --c-include="glib-object.h" --add-include-path=.
GObject_2_0_gir_PACKAGES = gobject-2.0
GObject_2_0_gir_INCLUDES = GLib-2.0
GObject_2_0_gir_CFLAGS = \
@@ -91,7 +91,7 @@ endif
GModule-2.0.gir: GLib-2.0.gir
GModule_2_0_gir_LIBS = $(GMODULE_LIBRARY)
-GModule_2_0_gir_SCANNERFLAGS = --strip-prefix=G --c-include="gmodule.h" --add-include-path=.
+GModule_2_0_gir_SCANNERFLAGS = --identifier-prefix=G --c-include="gmodule.h" --add-include-path=.
GModule_2_0_gir_PACKAGES = gmodule-2.0
GModule_2_0_gir_INCLUDES = GLib-2.0
GModule_2_0_gir_CFLAGS = \
@@ -122,7 +122,7 @@ endif
Gio-2.0.gir: GObject-2.0.gir
Gio_2_0_gir_LIBS = $(GIO_LIBRARY)
-Gio_2_0_gir_SCANNERFLAGS = --warn-all --strip-prefix=G --c-include="gio/gio.h" --add-include-path=.
+Gio_2_0_gir_SCANNERFLAGS = --reparse-validate --warn-all --identifier-prefix=G --c-include="gio/gio.h" --add-include-path=.
Gio_2_0_gir_PACKAGES = gio-2.0 $(GIO_UNIX_PACKAGES)
Gio_2_0_gir_INCLUDES = GObject-2.0
Gio_2_0_gir_CFLAGS = \
@@ -141,7 +141,9 @@ GIRepository-2.0.gir: GObject-2.0.gir $(top_builddir)/girepository/libgireposito
GIRepository_2_0_gir_LIBS = girepository-1.0
GIRepository_2_0_gir_SCANNERFLAGS = \
- --strip-prefix=g \
+ --warn-all \
+ --identifier-prefix=GI \
+ --symbol-prefix=g \
--c-include="girepository.h" \
--add-include-path=.
GIRepository_2_0_gir_PACKAGES = gobject-2.0
View
@@ -1,9 +1,10 @@
<?xml version="1.0"?>
-<repository version="1.1"
+<repository version="1.2"
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">
- <namespace name="cairo" version="1.0">
+ <namespace name="cairo" version="1.0"
+ c:prefix="cairo">
<record name="Context" c:type="cairo_t" foreign="1"/>
<record name="Surface" c:type="cairo_surface_t" foreign="1"/>
<record name="Matrix" c:type="cairo_matrix_t" foreign="1"/>
View
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
-<repository version="1.1"
+<repository version="1.2"
xmlns="http://www.gtk.org/introspection/core/1.0"
xmlns:c="http://www.gtk.org/introspection/c/1.0">
<namespace name="fontconfig" version="2.0">
View
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
-<repository version="1.1"
+<repository version="1.2"
xmlns="http://www.gtk.org/introspection/core/1.0"
xmlns:c="http://www.gtk.org/introspection/c/1.0">
<namespace name="freetype2" version="2.0">
View
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
-<repository version="1.1"
+<repository version="1.2"
xmlns="http://www.gtk.org/introspection/core/1.0"
xmlns:c="http://www.gtk.org/introspection/c/1.0">
<namespace name="libxml2" version="2.0">
View
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
-<repository version="1.1"
+<repository version="1.2"
xmlns="http://www.gtk.org/introspection/core/1.0"
xmlns:c="http://www.gtk.org/introspection/c/1.0">
<namespace name="xfixes" version="4.0">
View
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
-<repository version="1.1"
+<repository version="1.2"
xmlns="http://www.gtk.org/introspection/core/1.0"
xmlns:c="http://www.gtk.org/introspection/c/1.0">
<namespace name="xft" version="2.0">
View
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
-<repository version="1.1"
+<repository version="1.2"
xmlns="http://www.gtk.org/introspection/core/1.0"
xmlns:c="http://www.gtk.org/introspection/c/1.0">
<namespace name="xlib" version="2.0">
View
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
-<repository version="1.1"
+<repository version="1.2"
xmlns="http://www.gtk.org/introspection/core/1.0"
xmlns:c="http://www.gtk.org/introspection/c/1.0">
<namespace name="xrandr" version="1.3">
View
@@ -309,7 +309,7 @@ g_ir_module_build_typelib (GIrModule *module)
/* fill in header */
header = (Header *)data;
memcpy (header, G_IR_MAGIC, 16);
- header->major_version = 3;
+ header->major_version = 4;
header->minor_version = 0;
header->reserved = 0;
header->n_entries = n_entries;
Oops, something went wrong.

0 comments on commit 36aa515

Please sign in to comment.