aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2015-09-30 07:15:25 +0200
committerThomas Martitz <kugel@rockbox.org>2015-09-30 07:15:25 +0200
commit8de54ce5954362d9b5eecb0629aeb9daa69cd688 (patch)
tree3c980ed25598ad9532f15dc4e5665436ee1af0f9
parent1a398b4fafcf859a56765e595d264837d432ff9a (diff)
downloadscintilla-mirror-8de54ce5954362d9b5eecb0629aeb9daa69cd688.tar.gz
Add a test suite to check gobject-introspection data
The test suite acts also as an example for downstream projects to generate gobject-introspection data. A known-good .gir file is checked in for checking results in the future. Lastly, a small python uses the gobject-introspection data to create a small editor window. The change to gtk/makefile is because scintilla needs to be in a shared library for the python program. Therefore scintilla.a has to be compiled with -fPIC.
-rw-r--r--test/gi/Scintilla-0.1.gir.good138
-rw-r--r--test/gi/gi-test.py11
-rw-r--r--test/gi/makefile35
3 files changed, 184 insertions, 0 deletions
diff --git a/test/gi/Scintilla-0.1.gir.good b/test/gi/Scintilla-0.1.gir.good
new file mode 100644
index 000000000..6c9595121
--- /dev/null
+++ b/test/gi/Scintilla-0.1.gir.good
@@ -0,0 +1,138 @@
+<?xml version="1.0"?>
+<!-- This file was automatically generated from C sources - DO NOT EDIT!
+To affect the contents of this file, edit the original C definitions,
+and/or use gtk-doc annotations. -->
+<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">
+ <include name="Gtk" version="3.0"/>
+ <c:include name="Scintilla.h"/>
+ <c:include name="ScintillaWidget.h"/>
+ <namespace name="Scintilla"
+ version="0.1"
+ shared-library="libscintilla.so"
+ c:identifier-prefixes="Scintilla"
+ c:symbol-prefixes="scintilla">
+ <constant name="NOTIFY" value="sci-notify" c:type="SCINTILLA_NOTIFY">
+ <type name="utf8" c:type="gchar*"/>
+ </constant>
+ <class name="Object"
+ c:symbol-prefix="object"
+ c:type="ScintillaObject"
+ parent="Gtk.Container"
+ glib:type-name="ScintillaObject"
+ glib:get-type="scintilla_object_get_type"
+ glib:type-struct="ObjectClass">
+ <implements name="Atk.ImplementorIface"/>
+ <implements name="Gtk.Buildable"/>
+ <constructor name="new" c:identifier="scintilla_object_new">
+ <return-value transfer-ownership="none">
+ <type name="Gtk.Widget" c:type="GtkWidget*"/>
+ </return-value>
+ </constructor>
+ <virtual-method name="command">
+ <return-value transfer-ownership="none">
+ <type name="none" c:type="void"/>
+ </return-value>
+ <parameters>
+ <instance-parameter name="ttt" transfer-ownership="none">
+ <type name="Object" c:type="ScintillaObject*"/>
+ </instance-parameter>
+ </parameters>
+ </virtual-method>
+ <virtual-method name="notify">
+ <return-value transfer-ownership="none">
+ <type name="none" c:type="void"/>
+ </return-value>
+ <parameters>
+ <instance-parameter name="ttt" transfer-ownership="none">
+ <type name="Object" c:type="ScintillaObject*"/>
+ </instance-parameter>
+ </parameters>
+ </virtual-method>
+ <method name="send_message" c:identifier="scintilla_object_send_message">
+ <return-value transfer-ownership="none">
+ <type name="glong" c:type="long"/>
+ </return-value>
+ <parameters>
+ <instance-parameter name="sci" transfer-ownership="none">
+ <type name="Object" c:type="ScintillaObject*"/>
+ </instance-parameter>
+ <parameter name="iMessage" transfer-ownership="none">
+ <type name="guint" c:type="unsigned int"/>
+ </parameter>
+ <parameter name="wParam" transfer-ownership="none">
+ <type name="guintptr" c:type="guintptr"/>
+ </parameter>
+ <parameter name="lParam" transfer-ownership="none">
+ <type name="gintptr" c:type="gintptr"/>
+ </parameter>
+ </parameters>
+ </method>
+ <field name="cont">
+ <type name="Gtk.Container" c:type="GtkContainer"/>
+ </field>
+ <field name="pscin">
+ <type name="gpointer" c:type="void*"/>
+ </field>
+ <glib:signal name="command" when="last" action="1">
+ <return-value transfer-ownership="none">
+ <type name="none" c:type="void"/>
+ </return-value>
+ <parameters>
+ <parameter name="object" transfer-ownership="none">
+ <type name="gint" c:type="gint"/>
+ </parameter>
+ <parameter name="p0" transfer-ownership="none">
+ <type name="gpointer" c:type="gpointer"/>
+ </parameter>
+ </parameters>
+ </glib:signal>
+ <glib:signal name="sci-notify" when="last" action="1">
+ <return-value transfer-ownership="none">
+ <type name="none" c:type="void"/>
+ </return-value>
+ <parameters>
+ <parameter name="object" transfer-ownership="none">
+ <type name="gint" c:type="gint"/>
+ </parameter>
+ <parameter name="p0" transfer-ownership="none">
+ <type name="gpointer" c:type="gpointer"/>
+ </parameter>
+ </parameters>
+ </glib:signal>
+ </class>
+ <record name="ObjectClass"
+ c:type="ScintillaObjectClass"
+ glib:is-gtype-struct-for="Object">
+ <field name="parent_class">
+ <type name="Gtk.ContainerClass" c:type="GtkContainerClass"/>
+ </field>
+ <field name="command">
+ <callback name="command">
+ <return-value transfer-ownership="none">
+ <type name="none" c:type="void"/>
+ </return-value>
+ <parameters>
+ <parameter name="ttt" transfer-ownership="none">
+ <type name="Object" c:type="ScintillaObject*"/>
+ </parameter>
+ </parameters>
+ </callback>
+ </field>
+ <field name="notify">
+ <callback name="notify">
+ <return-value transfer-ownership="none">
+ <type name="none" c:type="void"/>
+ </return-value>
+ <parameters>
+ <parameter name="ttt" transfer-ownership="none">
+ <type name="Object" c:type="ScintillaObject*"/>
+ </parameter>
+ </parameters>
+ </callback>
+ </field>
+ </record>
+ </namespace>
+</repository>
diff --git a/test/gi/gi-test.py b/test/gi/gi-test.py
new file mode 100644
index 000000000..10cee8bc6
--- /dev/null
+++ b/test/gi/gi-test.py
@@ -0,0 +1,11 @@
+#!/usr/bin/python
+from gi.repository import Gtk
+from gi.repository import Scintilla
+
+win = Gtk.Window()
+win.connect("delete-event", Gtk.main_quit)
+sci = Scintilla.Object()
+win.add(sci)
+win.show_all()
+win.resize(400,300)
+Gtk.main()
diff --git a/test/gi/makefile b/test/gi/makefile
new file mode 100644
index 000000000..41d200653
--- /dev/null
+++ b/test/gi/makefile
@@ -0,0 +1,35 @@
+all: Scintilla-0.1.typelib
+
+ifdef GTK3
+GTKVERSION=gtk+-3.0
+else
+GTKVERSION=gtk+-2.0
+endif
+
+GI_SCANNER = g-ir-scanner
+GI_COMPILER = g-ir-compiler
+GTK_LIBS = $(shell pkg-config --libs $(GTKVERSION))
+
+FORCE:
+
+../../bin/scintilla.a: FORCE
+ $(MAKE) -C ../../gtk all
+
+libscintilla.so: ../../bin/scintilla.a
+ $(CXX) -shared -o $@ -Wl,--whole-archive $^ -Wl,--no-whole-archive $(GTK_LIBS)
+
+Scintilla-0.1.gir: libscintilla.so
+ LDFLAGS=-Wl,-rpath=$(shell pwd) CFLAGS="-include gtk/gtk.h" \
+ $(GI_SCANNER) --warn-all -i Gtk-3.0 -DG_IR_SCANNING -DGTK \
+ --c-include Scintilla.h --c-include ScintillaWidget.h \
+ -n Scintilla --nsversion 0.1 --library scintilla ../../include/ScintillaWidget.h \
+ -o $@
+ @echo Verifing Scintilla-0.1.gir file
+ @diff $@.good $@ || (echo "GIR FILE MISMATCH!"; exit 1)
+
+
+Scintilla-0.1.typelib: Scintilla-0.1.gir
+ $(GI_COMPILER) $^ -o $@
+
+clean:
+ rm -f libscintilla.so Scintilla-0.1.gir Scintilla-0.1.typelib