diff options
author | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2014-04-22 15:54:29 +0100 |
---|---|---|
committer | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2014-04-22 15:54:29 +0100 |
commit | 6f6f47012ec23a50dd71efed10cc235276492f6a (patch) | |
tree | 85e7deb6e3cf6ad0d87585fa65c1d7693440cafb | |
parent | 5f70154ceb1b8d0bdd9ac27dffd6835f1cb2004f (diff) |
Remove codegengdbus-object
We no longer need it.
-rw-r--r-- | 0001-Adapt-for-GVariant-based-tp_group_mixin_change_membe.patch | 70 | ||||
-rw-r--r-- | Makefile.am | 2 | ||||
-rw-r--r-- | configure.ac | 1 | ||||
-rw-r--r-- | extensions/Connection_Interface_IRC_Command1.xml | 53 | ||||
-rw-r--r-- | extensions/Makefile.am | 68 | ||||
-rw-r--r-- | extensions/all.xml | 32 | ||||
-rw-r--r-- | extensions/extensions.h | 10 | ||||
-rw-r--r-- | src/Makefile.am | 3 | ||||
-rw-r--r-- | src/idle-connection.c | 2 | ||||
-rw-r--r-- | src/server-tls-channel.h | 2 | ||||
-rw-r--r-- | src/server-tls-manager.c | 2 | ||||
-rw-r--r-- | src/server-tls-manager.h | 2 | ||||
-rw-r--r-- | tools/Makefile.am | 12 | ||||
-rw-r--r-- | tools/c-constants-generator.xsl | 257 | ||||
-rw-r--r-- | tools/c-interfaces-generator.xsl | 84 | ||||
-rw-r--r-- | tools/doc-generator.xsl | 689 | ||||
-rw-r--r-- | tools/glib-ginterface-gen.py | 849 | ||||
-rw-r--r-- | tools/identity.xsl | 7 | ||||
-rw-r--r-- | tools/libglibcodegen.py | 344 | ||||
-rw-r--r-- | tools/libtpcodegen.py | 257 | ||||
-rw-r--r-- | tools/ls-interfaces.xsl | 35 | ||||
-rw-r--r-- | tools/make-all-async.xsl | 43 | ||||
-rw-r--r-- | tools/spec-to-introspect.xsl | 51 |
23 files changed, 71 insertions, 2804 deletions
diff --git a/0001-Adapt-for-GVariant-based-tp_group_mixin_change_membe.patch b/0001-Adapt-for-GVariant-based-tp_group_mixin_change_membe.patch new file mode 100644 index 0000000..876dbc0 --- /dev/null +++ b/0001-Adapt-for-GVariant-based-tp_group_mixin_change_membe.patch @@ -0,0 +1,70 @@ +From e09ea00091c776c58b0063af7aaa93275d7ea024 Mon Sep 17 00:00:00 2001 +From: Simon McVittie <simon.mcvittie@collabora.co.uk> +Date: Wed, 9 Apr 2014 19:18:28 +0100 +Subject: [PATCH] Adapt for GVariant-based tp_group_mixin_change_members + +This means we need GLib 2.40 for GVariantDict. Enable GLib 2.28 +deprecations, but not 2.30 because we still use GValueArray. +--- + configure.ac | 6 +++--- + src/idle-muc-channel.c | 20 +++++++++++--------- + 2 files changed, 14 insertions(+), 12 deletions(-) + +diff --git a/configure.ac b/configure.ac +index b378afb..1c79d50 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -86,11 +86,11 @@ fi + AC_HEADER_STDC([]) + AC_C_INLINE + +-AC_DEFINE(GLIB_VERSION_MIN_REQUIRED, GLIB_VERSION_2_28, [Ignore post 2.28 deprecations]) +-AC_DEFINE(GLIB_VERSION_MAX_ALLOWED, GLIB_VERSION_2_34, [Prevent post 2.34 APIs]) ++AC_DEFINE(GLIB_VERSION_MIN_REQUIRED, GLIB_VERSION_2_30, [Ignore post 2.30 deprecations]) ++AC_DEFINE(GLIB_VERSION_MAX_ALLOWED, GLIB_VERSION_2_40, [Prevent post 2.40 APIs]) + + PKG_CHECK_MODULES([GLIB], +- [glib-2.0 >= 2.34.0, gobject-2.0 >= 2.34.0, gio-2.0 >= 2.34.0 ]) ++ [glib-2.0 >= 2.40, gobject-2.0 >= 2.40, gio-2.0 >= 2.40 ]) + + PKG_CHECK_MODULES([DBUS], [dbus-1 >= 0.51, dbus-glib-1 >= 0.51]) + +diff --git a/src/idle-muc-channel.c b/src/idle-muc-channel.c +index 4fc2091..7ee6313 100644 +--- a/src/idle-muc-channel.c ++++ b/src/idle-muc-channel.c +@@ -196,20 +196,22 @@ change_members (GObject *obj, + TpHandle actor, + TpChannelGroupChangeReason reason) + { +- GHashTable *details; ++ GVariantDict details; + +- details = tp_asv_new ( +- "actor", G_TYPE_UINT, actor, +- "change-reason", G_TYPE_UINT, reason, +- NULL); ++ g_variant_dict_init (&details, NULL); ++ ++ g_variant_dict_insert_value (&details, "actor", ++ g_variant_new_uint32 (actor)); ++ g_variant_dict_insert_value (&details, "change-reason", ++ g_variant_new_uint32 (reason)); + + if (message != NULL) +- tp_asv_set_string (details, "message", message); ++ g_variant_dict_insert_value (&details, "message", ++ g_variant_new_string (message)); + + tp_group_mixin_change_members (obj, +- add, del, add_local_pending, add_remote_pending, details); +- +- g_hash_table_unref (details); ++ add, del, add_local_pending, add_remote_pending, ++ g_variant_dict_end (&details)); + } + + static void +-- +1.9.1 + diff --git a/Makefile.am b/Makefile.am index 9742752..48dc6fd 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,6 +1,6 @@ ACLOCAL_AMFLAGS = -I m4 -SUBDIRS = tools extensions src data m4 tests +SUBDIRS = tools src data m4 tests check-twisted : all $(MAKE) -C tests/twisted check-twisted diff --git a/configure.ac b/configure.ac index 1c79d50..5ff6903 100644 --- a/configure.ac +++ b/configure.ac @@ -142,7 +142,6 @@ AC_CHECK_FUNCS(strnlen) AC_OUTPUT( Makefile \ data/Makefile \ - extensions/Makefile \ m4/Makefile \ src/Makefile \ tests/Makefile \ diff --git a/extensions/Connection_Interface_IRC_Command1.xml b/extensions/Connection_Interface_IRC_Command1.xml deleted file mode 100644 index 4b38bdb..0000000 --- a/extensions/Connection_Interface_IRC_Command1.xml +++ /dev/null @@ -1,53 +0,0 @@ -<?xml version="1.0" ?> -<node name="/Connection_Interface_IRC_Command1" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0"> - <tp:copyright> Copyright (C) 2013 Collabora Limited </tp:copyright> - <tp:license xmlns="http://www.w3.org/1999/xhtml"> - <p>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.1 of the License, or (at your option) any later version.</p> - -<p>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.</p> - -<p>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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.</p> - </tp:license> - <interface name="im.telepathy.v1.Connection.Interface.IRCCommand1" - tp:causes-havoc='not well-tested'> - <tp:requires interface="im.telepathy.v1.Connection"/> - <method name="Send" tp:name-for-bindings="Send"> - <arg direction="in" name="Command" type="s"> - <tp:docstring> - The command followed by its arguments. - </tp:docstring> - </arg> - <tp:docstring xmlns="http://www.w3.org/1999/xhtml"> - <p>Send an arbitrary IRC command to the server.</p> - <p>For example, an IRC client receiving <code>/bip blreset</code> from - the user might call this method with <code>BIP blreset</code> as - argument which will send <code>BIP blreset</code> to the server.</p> - <p>The command is supplied in UTF-8 (because strings on D-Bus are - always UTF-8). It is transcoded into the connection's configured - character set, if different, before sending to the server.</p> - </tp:docstring> - <tp:possible-errors> - <tp:error name="im.telepathy.v1.Error.Disconnected"/> - <tp:error name="im.telepathy.v1.Error.NetworkError"/> - <tp:error name="im.telepathy.v1.Error.InvalidArgument"> - <tp:docstring> - The connection manager MAY raise this error for commands that - have a more appropriate D-Bus API. - </tp:docstring> - </tp:error> - </tp:possible-errors> - </method> - <tp:docstring> - An interface to send arbitrary IRC commands to the server. - </tp:docstring> - </interface> -</node> -<!-- vim:set sw=2 sts=2 et ft=xml: --> diff --git a/extensions/Makefile.am b/extensions/Makefile.am deleted file mode 100644 index b4d67f8..0000000 --- a/extensions/Makefile.am +++ /dev/null @@ -1,68 +0,0 @@ -tools_dir = $(top_srcdir)/tools - -EXTRA_DIST = \ - all.xml \ - Connection_Interface_IRC_Command1.xml \ - $(NULL) - -noinst_LTLIBRARIES = libidle-extensions.la - -libidle_extensions_la_SOURCES = \ - extensions.h - -nodist_libidle_extensions_la_SOURCES = \ - _gen/enums.h \ - _gen/interfaces.h \ - _gen/svc-gtk-doc.h \ - _gen/svc.h \ - _gen/svc.c - -BUILT_SOURCES = \ - _gen/all.xml \ - $(nodist_libidle_extensions_la_SOURCES) \ - extensions.html - -CLEANFILES = $(BUILT_SOURCES) - -AM_CFLAGS = $(ERROR_CFLAGS) @DBUS_CFLAGS@ @GLIB_CFLAGS@ @TELEPATHY_CFLAGS@ -AM_LDFLAGS = @DBUS_LIBS@ @GLIB_LIBS@ @TELEPATHY_LIBS@ - -# Generated stuff - -DROP_NAMESPACE = sed -e 's@xmlns:tp="http://telepathy\.freedesktop\.org/wiki/DbusSpec.extensions-v0"@@g' -XSLTPROCFLAGS = --nonet --novalid - -_gen/all.xml: all.xml $(wildcard $(srcdir)/*.xml) - @$(MKDIR_P) _gen - $(AM_V_GEN)$(XSLTPROC) $(XSLTPROCFLAGS) \ - --xinclude $(tools_dir)/identity.xsl \ - $< > $@ - -extensions.html: _gen/all.xml $(tools_dir)/doc-generator.xsl - $(AM_V_GEN)$(XSLTPROC) $(XSLTPROCFLAGS) \ - $(tools_dir)/doc-generator.xsl \ - $< > $@ - -_gen/svc.h: _gen/svc.c -_gen/svc-gtk-doc.h: _gen/svc.c - -_gen/svc.c: _gen/all.xml \ - $(tools_dir)/glib-ginterface-gen.py - $(AM_V_GEN)$(PYTHON) $(tools_dir)/glib-ginterface-gen.py \ - --filename=_gen/svc --signal-marshal-prefix=_idle_ext \ - --include='<telepathy-glib/telepathy-glib.h>' \ - --not-implemented-func='tp_dbus_g_method_return_not_implemented' \ - --allow-unstable \ - $< Idle_Svc_ - -_gen/enums.h: _gen/all.xml $(tools_dir)/c-constants-generator.xsl - $(AM_V_GEN)$(XSLTPROC) $(XSLTPROCFLAGS) \ - --stringparam mixed-case-prefix Idle \ - $(tools_dir)/c-constants-generator.xsl \ - $< > $@ - -_gen/interfaces.h: _gen/all.xml $(tools_dir)/c-interfaces-generator.xsl - $(AM_V_GEN)$(XSLTPROC) $(XSLTPROCFLAGS) \ - --stringparam mixed-case-prefix Idle \ - $(tools_dir)/c-interfaces-generator.xsl \ - $< > $@ diff --git a/extensions/all.xml b/extensions/all.xml deleted file mode 100644 index 6b76837..0000000 --- a/extensions/all.xml +++ /dev/null @@ -1,32 +0,0 @@ -<tp:spec - xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0" - xmlns:xi="http://www.w3.org/2001/XInclude"> - -<tp:title>Idle-specific extensions to the Telepathy interfaces</tp:title> - -<tp:copyright>Copyright (C) 2007 Collabora Limited</tp:copyright> - -<tp:license xmlns="http://www.w3.org/1999/xhtml"> -<p>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.1 of the License, or (at your option) any later version.</p> - -<p>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 -Library General Public License for more details.</p> - -<p>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</p> -</tp:license> - -<xi:include href="Connection_Interface_IRC_Command1.xml"/> - -<tp:generic-types> - <tp:external-type name="Contact_Handle" type="u" - from="Telepathy specification"/> -</tp:generic-types> - -</tp:spec> diff --git a/extensions/extensions.h b/extensions/extensions.h deleted file mode 100644 index 839fc4e..0000000 --- a/extensions/extensions.h +++ /dev/null @@ -1,10 +0,0 @@ - -#ifndef _IDLE_EXTENSIONS_H -#define _IDLE_EXTENSIONS_H - -#include "extensions/_gen/svc.h" -#include "extensions/_gen/enums.h" -#include "extensions/_gen/interfaces.h" - -#endif /* _IDLE_EXTENSIONS_H */ - diff --git a/src/Makefile.am b/src/Makefile.am index c43c50c..0ef56d3 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -49,9 +49,6 @@ libidle_convenience_la_SOURCES = \ nodist_libidle_convenience_la_SOURCES = \ $(BUILT_SOURCES) -libidle_convenience_la_LIBADD = \ - $(top_builddir)/extensions/libidle-extensions.la - telepathy_idle_1_SOURCES = \ idle.c diff --git a/src/idle-connection.c b/src/idle-connection.c index c0e7bc4..31dab9c 100644 --- a/src/idle-connection.c +++ b/src/idle-connection.c @@ -41,8 +41,6 @@ #include "idle-server-connection.h" #include "server-tls-manager.h" -#include "extensions/extensions.h" /* IRCCommand */ - #define DEFAULT_KEEPALIVE_INTERVAL 30 /* sec */ #define MISSED_KEEPALIVES_BEFORE_DISCONNECTING 3 diff --git a/src/server-tls-channel.h b/src/server-tls-channel.h index 47b8474..fc47380 100644 --- a/src/server-tls-channel.h +++ b/src/server-tls-channel.h @@ -25,8 +25,6 @@ #include <telepathy-glib/telepathy-glib.h> -#include <extensions/extensions.h> - #include "tls-certificate.h" G_BEGIN_DECLS diff --git a/src/server-tls-manager.c b/src/server-tls-manager.c index a6f6c12..314e8d8 100644 --- a/src/server-tls-manager.c +++ b/src/server-tls-manager.c @@ -29,8 +29,6 @@ #include "idle-connection.h" #include "server-tls-channel.h" -#include "extensions/extensions.h" - static void channel_manager_iface_init (gpointer, gpointer); G_DEFINE_TYPE_WITH_CODE (IdleServerTLSManager, idle_server_tls_manager, diff --git a/src/server-tls-manager.h b/src/server-tls-manager.h index 9e33753..54a6625 100644 --- a/src/server-tls-manager.h +++ b/src/server-tls-manager.h @@ -24,8 +24,6 @@ #include <glib-object.h> #include <telepathy-glib/telepathy-glib.h> -#include "extensions/extensions.h" - G_BEGIN_DECLS typedef struct _IdleServerTLSManager IdleServerTLSManager; diff --git a/tools/Makefile.am b/tools/Makefile.am index 7b4106d..8fdb87b 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -1,14 +1,2 @@ EXTRA_DIST = \ - c-constants-generator.xsl \ - c-interfaces-generator.xsl \ - doc-generator.xsl \ - glib-ginterface-gen.py \ - identity.xsl \ - libglibcodegen.py \ - libtpcodegen.py \ make-release-mail.py - -CLEANFILES = libglibcodegen.pyc libglibcodegen.pyo - -glib-ginterface-gen.py: libglibcodegen.py libtpcodegen.py - touch $@ diff --git a/tools/c-constants-generator.xsl b/tools/c-constants-generator.xsl deleted file mode 100644 index 2838ee1..0000000 --- a/tools/c-constants-generator.xsl +++ /dev/null @@ -1,257 +0,0 @@ -<!-- Stylesheet to extract C enumerations from the Telepathy spec. -The master copy of this stylesheet is in telepathy-glib - please make any -changes there. - -Copyright (C) 2006, 2007 Collabora Limited - -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.1 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 -Library 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ---> - -<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" - xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0" - exclude-result-prefixes="tp"> - - <xsl:output method="text" indent="no" encoding="ascii"/> - - <xsl:param name="mixed-case-prefix" select="''"/> - - <xsl:variable name="upper" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/> - <xsl:variable name="lower" select="'abcdefghijklmnopqrstuvwxyz'"/> - - <xsl:variable name="upper-case-prefix" select="concat(translate($mixed-case-prefix, $lower, $upper), '_')"/> - <xsl:variable name="lower-case-prefix" select="concat(translate($mixed-case-prefix, $upper, $lower), '_')"/> - - - <xsl:template match="tp:flags"> - <xsl:variable name="name"> - <xsl:choose> - <xsl:when test="@plural"> - <xsl:value-of select="@plural"/> - </xsl:when> - <xsl:otherwise> - <xsl:value-of select="@name"/> - </xsl:otherwise> - </xsl:choose> - </xsl:variable> - <xsl:variable name="value-prefix"> - <xsl:choose> - <xsl:when test="@singular"> - <xsl:value-of select="@singular"/> - </xsl:when> - <xsl:when test="@value-prefix"> - <xsl:value-of select="@value-prefix"/> - </xsl:when> - <xsl:otherwise> - <xsl:value-of select="@name"/> - </xsl:otherwise> - </xsl:choose> - </xsl:variable> -/** - * <xsl:value-of select="translate(concat($mixed-case-prefix, $name), '_', '')"/>: -<xsl:apply-templates mode="flag-or-enumvalue-gtkdoc"> - <xsl:with-param name="value-prefix" select="$value-prefix"/> -</xsl:apply-templates> * -<xsl:if test="tp:docstring"> - * <![CDATA[<xsl:value-of select="translate(string (tp:docstring), ' ', ' ')"/>]]> - * -</xsl:if> * Bitfield/set of flags generated from the Telepathy specification. - */ -typedef enum { -<xsl:apply-templates> - <xsl:with-param name="value-prefix" select="$value-prefix"/> -</xsl:apply-templates>} <xsl:value-of select="translate(concat($mixed-case-prefix, $name), '_', '')"/>; - -</xsl:template> - - <xsl:template match="text()" mode="flag-or-enumvalue-gtkdoc"/> - - <xsl:template match="tp:enumvalue" mode="flag-or-enumvalue-gtkdoc"> - <xsl:param name="value-prefix"/> - <xsl:text> * @</xsl:text> - <xsl:value-of select="translate(concat($upper-case-prefix, $value-prefix, '_', @suffix), $lower, $upper)"/> - <xsl:text>: <![CDATA[</xsl:text> - <xsl:value-of select="translate(string(tp:docstring), ' ', ' ')"/> - <xsl:text>]]> </xsl:text> - </xsl:template> - - <xsl:template match="tp:flag" mode="flag-or-enumvalue-gtkdoc"> - <xsl:param name="value-prefix"/> - <xsl:text> * @</xsl:text> - <xsl:value-of select="translate(concat($upper-case-prefix, $value-prefix, '_', @suffix), $lower, $upper)"/> - <xsl:text>: <![CDATA[</xsl:text> - <xsl:value-of select="translate(string(tp:docstring), ' ', ' ')"/> - <xsl:text>]]> </xsl:text> - </xsl:template> - - <xsl:template match="tp:enum"> - <xsl:variable name="name"> - <xsl:choose> - <xsl:when test="@singular"> - <xsl:value-of select="@singular"/> - </xsl:when> - <xsl:otherwise> - <xsl:value-of select="@name"/> - </xsl:otherwise> - </xsl:choose> - </xsl:variable> - <xsl:variable name="value-prefix"> - <xsl:choose> - <xsl:when test="@singular"> - <xsl:value-of select="@singular"/> - </xsl:when> - <xsl:when test="@value-prefix"> - <xsl:value-of select="@value-prefix"/> - </xsl:when> - <xsl:otherwise> - <xsl:value-of select="@name"/> - </xsl:otherwise> - </xsl:choose> - </xsl:variable> - <xsl:variable name="name-plural"> - <xsl:choose> - <xsl:when test="@plural"> - <xsl:value-of select="@plural"/> - </xsl:when> - <xsl:otherwise> - <xsl:value-of select="@name"/><xsl:text>s</xsl:text> - </xsl:otherwise> - </xsl:choose> - </xsl:variable> -/** - * <xsl:value-of select="translate(concat($mixed-case-prefix, $name), '_', '')"/>: -<xsl:apply-templates mode="flag-or-enumvalue-gtkdoc"> - <xsl:with-param name="value-prefix" select="$value-prefix"/> -</xsl:apply-templates> * -<xsl:if test="tp:docstring"> - * <![CDATA[[<xsl:value-of select="translate(string (tp:docstring), ' ', ' ')"/>]]> - * -</xsl:if> * Enumeration generated from the Telepathy specification. - */ -typedef enum { -<xsl:apply-templates> - <xsl:with-param name="value-prefix" select="$value-prefix"/> -</xsl:apply-templates>} <xsl:value-of select="translate(concat($mixed-case-prefix, $name), '_', '')"/>; - -/** - * NUM_<xsl:value-of select="translate(concat($upper-case-prefix, $name-plural), $lower, $upper)"/>: - * - * 1 higher than the highest valid value of #<xsl:value-of select="translate(concat($mixed-case-prefix, $name), '_', '')"/>. - */ -#define NUM_<xsl:value-of select="translate(concat($upper-case-prefix, $name-plural), $lower, $upper)"/> (<xsl:value-of select="tp:enumvalue[position() = last()]/@value"/>+1) - -</xsl:template> - - <xsl:template match="tp:flags/tp:flag"> - <xsl:param name="value-prefix"/> - <xsl:variable name="suffix"> - <xsl:choose> - <xsl:when test="@suffix"> - <xsl:value-of select="@suffix"/> - </xsl:when> - <xsl:otherwise> - <xsl:value-of select="@name"/> - </xsl:otherwise> - </xsl:choose> - </xsl:variable> - <xsl:variable name="name" select="translate(concat($upper-case-prefix, $value-prefix, '_', $suffix), $lower, $upper)"/> - - <xsl:if test="@name and @suffix and @name != @suffix"> - <xsl:message terminate="yes">Flag name <xsl:value-of select="@name"/> != suffix <xsl:value-of select="@suffix"/> -</xsl:message> - </xsl:if> - <xsl:text> </xsl:text><xsl:value-of select="$name"/> = <xsl:value-of select="@value"/>, -</xsl:template> - - <xsl:template match="tp:enum/tp:enumvalue"> - <xsl:param name="value-prefix"/> - <xsl:variable name="suffix"> - <xsl:choose> - <xsl:when test="@suffix"> - <xsl:value-of select="@suffix"/> - </xsl:when> - <xsl:otherwise> - <xsl:value-of select="@name"/> - </xsl:otherwise> - </xsl:choose> - </xsl:variable> - <xsl:variable name="name" select="translate(concat($upper-case-prefix, $value-prefix, '_', $suffix), $lower, $upper)"/> - - <xsl:if test="@name and @suffix and @name != @suffix"> - <xsl:message terminate="yes">Flag name <xsl:value-of select="@name"/> != suffix <xsl:value-of select="@suffix"/> -</xsl:message> - </xsl:if> - - <xsl:if test="preceding-sibling::tp:enumvalue and number(preceding-sibling::tp:enumvalue[1]/@value) > number(@value)"> - <xsl:message terminate="yes">Enum values must be in ascending numeric order, -but <xsl:value-of select="$name"/> is less than the previous value -</xsl:message> - </xsl:if> - - <xsl:text> </xsl:text><xsl:value-of select="$name"/> = <xsl:value-of select="@value"/>, -</xsl:template> - - <xsl:template match="tp:flag"> - <xsl:message terminate="yes">tp:flag found outside tp:flags -</xsl:message> - </xsl:template> - - <xsl:template match="tp:enumvalue"> - <xsl:message terminate="yes">tp:enumvalue found outside tp:enum -</xsl:message> - </xsl:template> - - <xsl:template match="text()"/> - - <xsl:template match="/tp:spec"> - <xsl:if test="$mixed-case-prefix = ''"> - <xsl:message terminate="yes"> - <xsl:text>mixed-case-prefix param must be set </xsl:text> - </xsl:message> - </xsl:if> - - <xsl:text>/* Generated from </xsl:text> - <xsl:value-of select="tp:title"/> - <xsl:if test="tp:version"> - <xsl:text>, version </xsl:text> - <xsl:value-of select="tp:version"/> - </xsl:if> - <xsl:text> </xsl:text> - <xsl:for-each select="tp:copyright"> - <xsl:value-of select="."/> - <xsl:text> </xsl:text> - </xsl:for-each> - <xsl:value-of select="tp:license"/> - <xsl:text> </xsl:text> - <xsl:value-of select="tp:docstring"/> - <xsl:text> */ - -#ifdef __cplusplus -extern "C" { -#endif - -</xsl:text> - <xsl:apply-templates/> - <xsl:text> - -#ifdef __cplusplus -} -#endif - -</xsl:text> - </xsl:template> - -</xsl:stylesheet> - -<!-- vim:set sw=2 sts=2 et noai noci: --> diff --git a/tools/c-interfaces-generator.xsl b/tools/c-interfaces-generator.xsl deleted file mode 100644 index 38cbd7e..0000000 --- a/tools/c-interfaces-generator.xsl +++ /dev/null @@ -1,84 +0,0 @@ -<!-- Stylesheet to extract C enumerations from the Telepathy spec. -The master copy of this stylesheet is in telepathy-glib - please make any -changes there. - -Copyright (C) 2006, 2007 Collabora Limited - -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.1 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 -Library 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ---> - -<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" - xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0" - exclude-result-prefixes="tp"> - - <xsl:param name="mixed-case-prefix" select="''"/> - - <xsl:variable name="PREFIX" - select="translate($mixed-case-prefix, $lower, $upper)"/> - <xsl:variable name="Prefix" select="$mixed-case-prefix"/> - <xsl:variable name="prefix" - select="translate($mixed-case-prefix, $upper, $lower)"/> - - <xsl:output method="text" indent="no" encoding="ascii"/> - - <xsl:variable name="upper" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/> - <xsl:variable name="lower" select="'abcdefghijklmnopqrstuvwxyz'"/> - - <xsl:template match="interface"> - <xsl:text>/** * </xsl:text> - <xsl:value-of select="$PREFIX"/> - <xsl:text>_IFACE_</xsl:text> - <xsl:value-of select="translate(../@name, concat($lower, '/'), $upper)"/> - <xsl:text>: * * The interface name "</xsl:text> - <xsl:value-of select="@name"/> - <xsl:text>" */ #define </xsl:text> - <xsl:value-of select="$PREFIX"/> - <xsl:text>_IFACE_</xsl:text> - <xsl:value-of select="translate(../@name, concat($lower, '/'), $upper)"/> - <xsl:text> \ "</xsl:text> - <xsl:value-of select="@name"/> - <xsl:text>" </xsl:text> - </xsl:template> - - <xsl:template match="text()"/> - - <xsl:template match="/tp:spec"> - <xsl:if test="$mixed-case-prefix = ''"> - <xsl:message terminate="yes"> - <xsl:text>mixed-case-prefix param must be set </xsl:text> - </xsl:message> - </xsl:if> - - <xsl:text>/* Generated from: </xsl:text> - <xsl:value-of select="tp:title"/> - <xsl:if test="tp:version"> - <xsl:text> version </xsl:text> - <xsl:value-of select="tp:version"/> - </xsl:if> - <xsl:text> </xsl:text> - <xsl:for-each select="tp:copyright"> - <xsl:value-of select="."/> - <xsl:text> </xsl:text> - </xsl:for-each> - <xsl:text> </xsl:text> - <xsl:value-of select="tp:license"/> - <xsl:value-of select="tp:docstring"/> - <xsl:text> */ </xsl:text> - <xsl:apply-templates/> - </xsl:template> - -</xsl:stylesheet> - -<!-- vim:set sw=2 sts=2 et noai noci: --> diff --git a/tools/doc-generator.xsl b/tools/doc-generator.xsl deleted file mode 100644 index 83b42dc..0000000 --- a/tools/doc-generator.xsl +++ /dev/null @@ -1,689 +0,0 @@ -<!-- Generate HTML documentation from the Telepathy specification. -The master copy of this stylesheet is in the Telepathy spec repository - -please make any changes there. - -Copyright (C) 2006, 2007 Collabora Limited - -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.1 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 -Library 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 ---> - -<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" - xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0" - exclude-result-prefixes="tp"> - <!--Don't move the declaration of the HTML namespace up here - XMLNSs - don't work ideally in the presence of two things that want to use the - absence of a prefix, sadly. --> - - <xsl:template match="*" mode="identity"> - <xsl:copy> - <xsl:apply-templates mode="identity"/> - </xsl:copy> - </xsl:template> - - <xsl:template match="tp:docstring"> - <xsl:apply-templates select="node()" mode="identity"/> - </xsl:template> - - <xsl:template match="tp:errors"> - <h1 xmlns="http://www.w3.org/1999/xhtml">Errors</h1> - <xsl:apply-templates/> - </xsl:template> - - <xsl:template match="tp:generic-types"> - <h1 xmlns="http://www.w3.org/1999/xhtml">Generic types</h1> - <xsl:call-template name="do-types"/> - </xsl:template> - - <xsl:template name="do-types"> - <xsl:if test="tp:simple-type"> - <h2 xmlns="http://www.w3.org/1999/xhtml">Simple types</h2> - <xsl:apply-templates select="tp:simple-type"/> - </xsl:if> - - <xsl:if test="tp:enum"> - <h2 xmlns="http://www.w3.org/1999/xhtml">Enumerated types:</h2> - <xsl:apply-templates select="tp:enum"/> - </xsl:if> - - <xsl:if test="tp:flags"> - <h2 xmlns="http://www.w3.org/1999/xhtml">Sets of flags:</h2> - <xsl:apply-templates select="tp:flags"/> - </xsl:if> - - <xsl:if test="tp:struct"> - <h2 xmlns="http://www.w3.org/1999/xhtml">Structure types</h2> - <xsl:apply-templates select="tp:struct"/> - </xsl:if> - - <xsl:if test="tp:mapping"> - <h2 xmlns="http://www.w3.org/1999/xhtml">Mapping types</h2> - <xsl:apply-templates select="tp:mapping"/> - </xsl:if> - - <xsl:if test="tp:external-type"> - <h2 xmlns="http://www.w3.org/1999/xhtml">Types defined elsewhere</h2> - <dl><xsl:apply-templates select="tp:external-type"/></dl> - </xsl:if> - </xsl:template> - - <xsl:template match="tp:error"> - <h2 xmlns="http://www.w3.org/1999/xhtml"><a name="{concat(../@namespace, '.', translate(@name, ' ', ''))}"></a><xsl:value-of select="concat(../@namespace, '.', translate(@name, ' ', ''))"/></h2> - <xsl:apply-templates select="tp:docstring"/> - </xsl:template> - - <xsl:template match="/tp:spec/tp:copyright"> - <div xmlns="http://www.w3.org/1999/xhtml"> - <xsl:apply-templates/> - </div> - </xsl:template> - <xsl:template match="/tp:spec/tp:license"> - <div xmlns="http://www.w3.org/1999/xhtml" class="license"> - <xsl:apply-templates mode="identity"/> - </div> - </xsl:template> - - <xsl:template match="tp:copyright"/> - <xsl:template match="tp:license"/> - - <xsl:template match="interface"> - <h1 xmlns="http://www.w3.org/1999/xhtml"><a name="{@name}"></a><xsl:value-of select="@name"/></h1> - - <xsl:if test="@tp:causes-havoc"> - <p xmlns="http://www.w3.org/1999/xhtml" class="causes-havoc"> - This interface is <xsl:value-of select="@tp:causes-havoc"/> - and is likely to cause havoc to your API/ABI if bindings are generated. - Don't include it in libraries that care about compatibility. - </p> - </xsl:if> - - <xsl:if test="tp:requires"> - <p>Implementations of this interface must also implement:</p> - <ul xmlns="http://www.w3.org/1999/xhtml"> - <xsl:for-each select="tp:requires"> - <li><code><a href="#{@interface}"><xsl:value-of select="@interface"/></a></code></li> - </xsl:for-each> - </ul> - </xsl:if> - - <xsl:apply-templates select="tp:docstring" /> - - <xsl:choose> - <xsl:when test="method"> - <h2 xmlns="http://www.w3.org/1999/xhtml">Methods:</h2> - <xsl:apply-templates select="method"/> - </xsl:when> - <xsl:otherwise> - <p xmlns="http://www.w3.org/1999/xhtml">Interface has no methods.</p> - </xsl:otherwise> - </xsl:choose> - - <xsl:choose> - <xsl:when test="signal"> - <h2 xmlns="http://www.w3.org/1999/xhtml">Signals:</h2> - <xsl:apply-templates select="signal"/> - </xsl:when> - <xsl:otherwise> - <p xmlns="http://www.w3.org/1999/xhtml">Interface has no signals.</p> - </xsl:otherwise> - </xsl:choose> - - <xsl:choose> - <xsl:when test="tp:property"> - <h2 xmlns="http://www.w3.org/1999/xhtml">Properties:</h2> - <dl xmlns="http://www.w3.org/1999/xhtml"> - <xsl:apply-templates select="tp:property"/> - </dl> - </xsl:when> - <xsl:otherwise> - <p xmlns="http://www.w3.org/1999/xhtml">Interface has no properties.</p> - </xsl:otherwise> - </xsl:choose> - - <xsl:call-template name="do-types"/> - - </xsl:template> - - <xsl:template match="tp:flags"> - <h3> - <a name="type-{@name}"> - <xsl:value-of select="@name"/> - </a> - </h3> - <xsl:apply-templates select="tp:docstring" /> - <dl xmlns="http://www.w3.org/1999/xhtml"> - <xsl:variable name="value-prefix"> - <xsl:choose> - <xsl:when test="@value-prefix"> - <xsl:value-of select="@value-prefix"/> - </xsl:when> - <xsl:otherwise> - <xsl:value-of select="@name"/> - </xsl:otherwise> - </xsl:choose> - </xsl:variable> - <xsl:for-each select="tp:flag"> - <dt xmlns="http://www.w3.org/1999/xhtml"><code><xsl:value-of select="concat($value-prefix, '_', @suffix)"/> = <xsl:value-of select="@value"/></code></dt> - <xsl:choose> - <xsl:when test="tp:docstring"> - <dd xmlns="http://www.w3.org/1999/xhtml"><xsl:apply-templates select="tp:docstring" /></dd> - </xsl:when> - <xsl:otherwise> - <dd xmlns="http://www.w3.org/1999/xhtml">(Undocumented)</dd> - </xsl:otherwise> - </xsl:choose> - </xsl:for-each> - </dl> - </xsl:template> - - <xsl:template match="tp:enum"> - <h3 xmlns="http://www.w3.org/1999/xhtml"> - <a name="type-{@name}"> - <xsl:value-of select="@name"/> - </a> - </h3> - <xsl:apply-templates select="tp:docstring" /> - <dl xmlns="http://www.w3.org/1999/xhtml"> - <xsl:variable name="value-prefix"> - <xsl:choose> - <xsl:when test="@value-prefix"> - <xsl:value-of select="@value-prefix"/> - </xsl:when> - <xsl:otherwise> - <xsl:value-of select="@name"/> - </xsl:otherwise> - </xsl:choose> - </xsl:variable> - <xsl:for-each select="tp:enumvalue"> - <dt xmlns="http://www.w3.org/1999/xhtml"><code><xsl:value-of select="concat($value-prefix, '_', @suffix)"/> = <xsl:value-of select="@value"/></code></dt> - <xsl:choose> - <xsl:when test="tp:docstring"> - <dd xmlns="http://www.w3.org/1999/xhtml"><xsl:apply-templates select="tp:docstring" /></dd> - </xsl:when> - <xsl:otherwise> - <dd xmlns="http://www.w3.org/1999/xhtml">(Undocumented)</dd> - </xsl:otherwise> - </xsl:choose> - </xsl:for-each> - </dl> - </xsl:template> - - <xsl:template match="tp:property"> - <dt xmlns="http://www.w3.org/1999/xhtml"> - <xsl:if test="@name"> - <code><xsl:value-of select="@name"/></code> - - </xsl:if> - <code><xsl:value-of select="@type"/></code> - </dt> - <dd xmlns="http://www.w3.org/1999/xhtml"> - <xsl:apply-templates select="tp:docstring"/> - </dd> - </xsl:template> - - <xsl:template match="tp:mapping"> - <div xmlns="http://www.w3.org/1999/xhtml" class="struct"> - <h3> - <a name="type-{@name}"> - <xsl:value-of select="@name"/> - </a> - a{ - <xsl:for-each select="tp:member"> - <xsl:value-of select="@type"/> - <xsl:text>: </xsl:text> - <xsl:value-of select="@name"/> - <xsl:if test="position() != last()"> → </xsl:if> - </xsl:for-each> - } - </h3> - <div class="docstring"> - <xsl:apply-templates select="tp:docstring"/> - </div> - <div> - <h4>Members</h4> - <dl> - <xsl:apply-templates select="tp:member" mode="members-in-docstring"/> - </dl> - </div> - </div> - </xsl:template> - - <xsl:template match="tp:docstring" mode="in-index"/> - - <xsl:template match="tp:simple-type | tp:enum | tp:flags | tp:external-type" - mode="in-index"> - - <xsl:value-of select="@type"/> - </xsl:template> - - <xsl:template match="tp:simple-type"> - <div xmlns="http://www.w3.org/1999/xhtml" class="simple-type"> - <h3> - <a name="type-{@name}"> - <xsl:value-of select="@name"/> - </a> - <xsl:value-of select="@type"/> - </h3> - <div class="docstring"> - <xsl:apply-templates select="tp:docstring"/> - </div> - </div> - </xsl:template> - - <xsl:template match="tp:external-type"> - <div xmlns="http://www.w3.org/1999/xhtml" class="external-type"> - <dt> - <a name="type-{@name}"> - <xsl:value-of select="@name"/> - </a> - <xsl:value-of select="@type"/> - </dt> - <dd>Defined by: <xsl:value-of select="@from"/></dd> - </div> - </xsl:template> - - <xsl:template match="tp:struct" mode="in-index"> - - ( <xsl:for-each select="tp:member"> - <xsl:value-of select="@type"/> - <xsl:if test="position() != last()">, </xsl:if> - </xsl:for-each> ) - </xsl:template> - - <xsl:template match="tp:mapping" mode="in-index"> - - a{ <xsl:for-each select="tp:member"> - <xsl:value-of select="@type"/> - <xsl:if test="position() != last()"> → </xsl:if> - </xsl:for-each> } - </xsl:template> - - <xsl:template match="tp:struct"> - <div xmlns="http://www.w3.org/1999/xhtml" class="struct"> - <h3> - <a name="type-{@name}"> - <xsl:value-of select="@name"/> - </a> - ( - <xsl:for-each select="tp:member"> - <xsl:value-of select="@type"/> - <xsl:text>: </xsl:text> - <xsl:value-of select="@name"/> - <xsl:if test="position() != last()">, </xsl:if> - </xsl:for-each> - ) - </h3> - <div class="docstring"> - <xsl:apply-templates select="tp:docstring"/> - </div> - <xsl:choose> - <xsl:when test="string(@array-name) != ''"> - <p>In bindings that need a separate name, arrays of - <xsl:value-of select="@name"/> should be called - <xsl:value-of select="@array-name"/>.</p> - </xsl:when> - <xsl:otherwise> - <p>Arrays of <xsl:value-of select="@name"/> don't generally - make sense.</p> - </xsl:otherwise> - </xsl:choose> - <div> - <h4>Members</h4> - <dl> - <xsl:apply-templates select="tp:member" mode="members-in-docstring"/> - </dl> - </div> - </div> - </xsl:template> - - <xsl:template match="method"> - <div xmlns="http://www.w3.org/1999/xhtml" class="method"> - <h3 xmlns="http://www.w3.org/1999/xhtml"> - <a name="{concat(../@name, concat('.', @name))}"> - <xsl:value-of select="@name"/> - </a> ( - <xsl:for-each xmlns="" select="arg[@direction='in']"> - <xsl:value-of select="@type"/>: <xsl:value-of select="@name"/> - <xsl:if test="position() != last()">, </xsl:if> - </xsl:for-each> - ) → - <xsl:choose> - <xsl:when test="arg[@direction='out']"> - <xsl:for-each xmlns="" select="arg[@direction='out']"> - <xsl:value-of select="@type"/> - <xsl:if test="position() != last()">, </xsl:if> - </xsl:for-each> - </xsl:when> - <xsl:otherwise>nothing</xsl:otherwise> - </xsl:choose> - </h3> - <div xmlns="http://www.w3.org/1999/xhtml" class="docstring"> - <xsl:apply-templates select="tp:docstring" /> - </div> - - <xsl:if test="arg[@direction='in']"> - <div xmlns="http://www.w3.org/1999/xhtml"> - <h4>Parameters</h4> - <dl xmlns="http://www.w3.org/1999/xhtml"> - <xsl:apply-templates select="arg[@direction='in']" - mode="parameters-in-docstring"/> - </dl> - </div> - </xsl:if> - - <xsl:if test="arg[@direction='out']"> - <div xmlns="http://www.w3.org/1999/xhtml"> - <h4>Returns</h4> - <dl xmlns="http://www.w3.org/1999/xhtml"> - <xsl:apply-templates select="arg[@direction='out']" - mode="returns-in-docstring"/> - </dl> - </div> - </xsl:if> - - <xsl:if test="tp:possible-errors"> - <div xmlns="http://www.w3.org/1999/xhtml"> - <h4>Possible errors</h4> - <dl xmlns="http://www.w3.org/1999/xhtml"> - <xsl:apply-templates select="tp:possible-errors/tp:error"/> - </dl> - </div> - </xsl:if> - - </div> - </xsl:template> - - <xsl:template name="parenthesized-tp-type"> - <xsl:if test="@tp:type"> - <xsl:variable name="tp-type" select="@tp:type"/> - <xsl:variable name="single-type"> - <xsl:choose> - <xsl:when test="contains($tp-type, '[]')"> - <xsl:value-of select="substring-before($tp-type, '[]')"/> - </xsl:when> - <xsl:otherwise> - <xsl:value-of select="$tp-type"/> - </xsl:otherwise> - </xsl:choose> - </xsl:variable> - <xsl:choose> - <xsl:when test="//tp:simple-type[@name=$tp-type]" /> - <xsl:when test="//tp:simple-type[concat(@name, '[]')=$tp-type]" /> - <xsl:when test="//tp:struct[concat(@name, '[]')=$tp-type][string(@array-name) != '']" /> - <xsl:when test="//tp:struct[@name=$tp-type]" /> - <xsl:when test="//tp:enum[@name=$tp-type]" /> - <xsl:when test="//tp:enum[concat(@name, '[]')=$tp-type]" /> - <xsl:when test="//tp:flags[@name=$tp-type]" /> - <xsl:when test="//tp:flags[concat(@name, '[]')=$tp-type]" /> - <xsl:when test="//tp:mapping[@name=$tp-type]" /> - <xsl:when test="//tp:external-type[concat(@name, '[]')=$tp-type]" /> - <xsl:when test="//tp:external-type[@name=$tp-type]" /> - <xsl:otherwise> - <xsl:message terminate="yes"> - <xsl:text>ERR: Unable to find type '</xsl:text> - <xsl:value-of select="$tp-type"/> - <xsl:text>' </xsl:text> - </xsl:message> - </xsl:otherwise> - </xsl:choose> - (<a href="#type-{$single-type}"><xsl:value-of select="$tp-type"/></a>) - </xsl:if> - </xsl:template> - - <xsl:template match="tp:member" mode="members-in-docstring"> - <dt xmlns="http://www.w3.org/1999/xhtml"> - <code><xsl:value-of select="@name"/></code> - - <code><xsl:value-of select="@type"/></code> - <xsl:call-template name="parenthesized-tp-type"/> - </dt> - <dd xmlns="http://www.w3.org/1999/xhtml"> - <xsl:choose> - <xsl:when test="tp:docstring"> - <xsl:apply-templates select="tp:docstring" /> - </xsl:when> - <xsl:otherwise> - <em>(undocumented)</em> - </xsl:otherwise> - </xsl:choose> - </dd> - </xsl:template> - - <xsl:template match="arg" mode="parameters-in-docstring"> - <dt xmlns="http://www.w3.org/1999/xhtml"> - <code><xsl:value-of select="@name"/></code> - - <code><xsl:value-of select="@type"/></code> - <xsl:call-template name="parenthesized-tp-type"/> - </dt> - <dd xmlns="http://www.w3.org/1999/xhtml"> - <xsl:apply-templates select="tp:docstring" /> - </dd> - </xsl:template> - - <xsl:template match="arg" mode="returns-in-docstring"> - <dt xmlns="http://www.w3.org/1999/xhtml"> - <xsl:if test="@name"> - <code><xsl:value-of select="@name"/></code> - - </xsl:if> - <code><xsl:value-of select="@type"/></code> - <xsl:call-template name="parenthesized-tp-type"/> - </dt> - <dd xmlns="http://www.w3.org/1999/xhtml"> - <xsl:apply-templates select="tp:docstring"/> - </dd> - </xsl:template> - - <xsl:template match="tp:possible-errors/tp:error"> - <dt xmlns="http://www.w3.org/1999/xhtml"> - <code><xsl:value-of select="@name"/></code> - </dt> - <dd xmlns="http://www.w3.org/1999/xhtml"> - <xsl:variable name="name" select="@name"/> - <xsl:choose> - <xsl:when test="tp:docstring"> - <xsl:apply-templates select="tp:docstring"/> - </xsl:when> - <xsl:when test="//tp:errors/tp:error[concat(../@namespace, '.', translate(@name, ' ', ''))=$name]/tp:docstring"> - <xsl:apply-templates select="//tp:errors/tp:error[concat(../@namespace, '.', translate(@name, ' ', ''))=$name]/tp:docstring"/> <em xmlns="http://www.w3.org/1999/xhtml">(generic description)</em> - </xsl:when> - <xsl:otherwise> - (Undocumented.) - </xsl:otherwise> - </xsl:choose> - </dd> - </xsl:template> - - <xsl:template match="signal"> - <div xmlns="http://www.w3.org/1999/xhtml" class="signal"> - <h3 xmlns="http://www.w3.org/1999/xhtml"> - <a name="{concat(../@name, concat('.', @name))}"> - <xsl:value-of select="@name"/> - </a> ( - <xsl:for-each xmlns="" select="arg"> - <xsl:value-of select="@type"/>: <xsl:value-of select="@name"/> - <xsl:if test="position() != last()">, </xsl:if> - </xsl:for-each> - )</h3> - <div xmlns="http://www.w3.org/1999/xhtml" class="docstring"> - <xsl:apply-templates select="tp:docstring"/> - </div> - - <xsl:if test="arg"> - <div xmlns="http://www.w3.org/1999/xhtml"> - <h4>Parameters</h4> - <dl xmlns="http://www.w3.org/1999/xhtml"> - <xsl:apply-templates select="arg" mode="parameters-in-docstring"/> - </dl> - </div> - </xsl:if> - </div> - </xsl:template> - - <xsl:output method="xml" indent="no" encoding="ascii" - omit-xml-declaration="yes" - doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" - doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" /> - - <xsl:template match="/tp:spec"> - <html xmlns="http://www.w3.org/1999/xhtml"> - <head> - <title> - <xsl:value-of select="tp:title"/> - <xsl:if test="tp:version"> - <xsl:text> version </xsl:text> - <xsl:value-of select="tp:version"/> - </xsl:if> - </title> - <style type="text/css"> - - body { - font-family: sans-serif; - margin: 2em; - height: 100%; - font-size: 1.2em; - } - h1 { - padding-top: 5px; - padding-bottom: 5px; - font-size: 1.6em; - background: #dadae2; - } - h2 { - font-size: 1.3em; - } - h3 { - font-size: 1.2em; - } - a:link, a:visited, a:link:hover, a:visited:hover { - font-weight: bold; - } - .topbox { - padding-top: 10px; - padding-left: 10px; - border-bottom: black solid 1px; - padding-bottom: 10px; - background: #dadae2; - font-size: 2em; - font-weight: bold; - color: #5c5c5c; - } - .topnavbox { - padding-left: 10px; - padding-top: 5px; - padding-bottom: 5px; - background: #abacba; - border-bottom: black solid 1px; - font-size: 1.2em; - } - .topnavbox a{ - color: black; - font-weight: normal; - } - .sidebar { - float: left; - /* width:9em; - border-right:#abacba solid 1px; - border-left: #abacba solid 1px; - height:100%; */ - border: #abacba solid 1px; - padding-left: 10px; - margin-left: 10px; - padding-right: 10px; - margin-right: 10px; - color: #5d5d5d; - background: #dadae2; - } - .sidebar a { - text-decoration: none; - border-bottom: #e29625 dotted 1px; - color: #e29625; - font-weight: normal; - } - .sidebar h1 { - font-size: 1.2em; - color: black; - } - .sidebar ul { - padding-left: 25px; - padding-bottom: 10px; - border-bottom: #abacba solid 1px; - } - .sidebar li { - padding-top: 2px; - padding-bottom: 2px; - } - .sidebar h2 { - font-style:italic; - font-size: 0.81em; - padding-left: 5px; - padding-right: 5px; - font-weight: normal; - } - .date { - font-size: 0.6em; - float: right; - font-style: italic; - } - .method { - margin-left: 1em; - margin-right: 4em; - } - .signal { - margin-left: 1em; - margin-right: 4em; - } - - </style> - </head> - <body> - <h1 class="topbox"> - <xsl:value-of select="tp:title" /> - </h1> - <xsl:if test="tp:version"> - <h2>Version <xsl:apply-templates select="tp:version"/></h2> - </xsl:if> - <xsl:apply-templates select="tp:copyright"/> - <xsl:apply-templates select="tp:license"/> - <xsl:apply-templates select="tp:docstring"/> - - <h2>Interfaces</h2> - <ul> - <xsl:for-each select="node/interface"> - <li><code><a href="#{@name}"><xsl:value-of select="@name"/></a></code></li> - </xsl:for-each> - </ul> - - <xsl:apply-templates select="node"/> - <xsl:apply-templates select="tp:generic-types"/> - <xsl:apply-templates select="tp:errors"/> - - <h1>Index</h1> - <h2>Index of interfaces</h2> - <ul> - <xsl:for-each select="node/interface"> - <li><code><a href="#{@name}"><xsl:value-of select="@name"/></a></code></li> - </xsl:for-each> - </ul> - <h2>Index of types</h2> - <ul> - <xsl:for-each select="//tp:simple-type | //tp:enum | //tp:flags | //tp:mapping | //tp:struct | //tp:external-type"> - <xsl:sort select="@name"/> - <li> - <code> - <a href="#type-{@name}"> - <xsl:value-of select="@name"/> - </a> - </code> - <xsl:apply-templates mode="in-index" select="."/> - </li> - </xsl:for-each> - </ul> - </body> - </html> - </xsl:template> - -</xsl:stylesheet> - -<!-- vim:set sw=2 sts=2 et: --> diff --git a/tools/glib-ginterface-gen.py b/tools/glib-ginterface-gen.py deleted file mode 100644 index 184476d..0000000 --- a/tools/glib-ginterface-gen.py +++ /dev/null @@ -1,849 +0,0 @@ -#!/usr/bin/python - -# glib-ginterface-gen.py: service-side interface generator -# -# Generate dbus-glib 0.x service GInterfaces from the Telepathy specification. -# The master copy of this program is in the telepathy-glib repository - -# please make any changes there. -# -# Copyright (C) 2006, 2007 Collabora Limited -# -# 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.1 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -import sys -import os.path -import xml.dom.minidom - -from libtpcodegen import file_set_contents, key_by_name, u, get_emits_changed -from libglibcodegen import (Signature, type_to_gtype, - NS_TP, dbus_gutils_wincaps_to_uscore, value_getter, - GDBusInterfaceInfo) - - -NS_TP = "http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0" - -class Generator(object): - - def __init__(self, dom, prefix, basename, signal_marshal_prefix, - headers, end_headers, not_implemented_func, - allow_havoc, allow_single_include): - self.dom = dom - self.__header = [] - self.__body = [] - self.__docs = [] - - assert prefix.endswith('_') - assert not signal_marshal_prefix.endswith('_') - - # The main_prefix, sub_prefix thing is to get: - # FOO_ -> (FOO_, _) - # FOO_SVC_ -> (FOO_, _SVC_) - # but - # FOO_BAR/ -> (FOO_BAR_, _) - # FOO_BAR/SVC_ -> (FOO_BAR_, _SVC_) - - if '/' in prefix: - main_prefix, sub_prefix = prefix.upper().split('/', 1) - prefix = prefix.replace('/', '_') - else: - main_prefix, sub_prefix = prefix.upper().split('_', 1) - - self.MAIN_PREFIX_ = main_prefix + '_' - self._SUB_PREFIX_ = '_' + sub_prefix - - self.Prefix_ = prefix - self.Prefix = prefix.replace('_', '') - self.prefix_ = prefix.lower() - self.PREFIX_ = prefix.upper() - - self.basename = basename - self.signal_marshal_prefix = signal_marshal_prefix - self.headers = headers - self.end_headers = end_headers - self.not_implemented_func = not_implemented_func - self.allow_havoc = allow_havoc - self.allow_single_include = allow_single_include - - def h(self, s): - self.__header.append(s) - - def b(self, s): - self.__body.append(s) - - def d(self, s): - self.__docs.append(s) - - def do_node(self, node): - node_name = node.getAttribute('name').replace('/', '') - node_name_mixed = self.node_name_mixed = node_name.replace('_', '') - node_name_lc = self.node_name_lc = node_name.lower() - node_name_uc = self.node_name_uc = node_name.upper() - - interfaces = node.getElementsByTagName('interface') - assert len(interfaces) == 1, interfaces - interface = interfaces[0] - self.iface_name = interface.getAttribute('name') - - tmp = interface.getAttribute('tp:implement-service') - if tmp == "no": - return - - tmp = interface.getAttribute('tp:causes-havoc') - if tmp and not self.allow_havoc: - raise AssertionError('%s is %s' % (self.iface_name, tmp)) - - iface_emits_changed = get_emits_changed(interface) - - methods = interface.getElementsByTagName('method') - signals = interface.getElementsByTagName('signal') - properties = interface.getElementsByTagName('property') - - self.b('struct _%s%sClass {' % (self.Prefix, node_name_mixed)) - self.b(' GTypeInterface parent_class;') - for method in methods: - self.b(' %s %s;' % self.get_method_impl_names(method)) - self.b('};') - self.b('') - - if signals: - self.b('enum {') - for signal in signals: - self.b(' %s,' % self.get_signal_const_entry(signal)) - self.b(' N_%s_SIGNALS' % node_name_uc) - self.b('};') - self.b('static guint %s_signals[N_%s_SIGNALS] = {0};' - % (node_name_lc, node_name_uc)) - self.b('') - - self.b('static void %s%s_base_init (gpointer klass);' - % (self.prefix_, node_name_lc)) - self.b('') - - self.b('GType') - self.b('%s%s_get_type (void)' - % (self.prefix_, node_name_lc)) - self.b('{') - self.b(' static GType type = 0;') - self.b('') - self.b(' if (G_UNLIKELY (type == 0))') - self.b(' {') - self.b(' static const GTypeInfo info = {') - self.b(' sizeof (%s%sClass),' % (self.Prefix, node_name_mixed)) - self.b(' %s%s_base_init, /* base_init */' - % (self.prefix_, node_name_lc)) - self.b(' NULL, /* base_finalize */') - self.b(' NULL, /* class_init */') - self.b(' NULL, /* class_finalize */') - self.b(' NULL, /* class_data */') - self.b(' 0,') - self.b(' 0, /* n_preallocs */') - self.b(' NULL /* instance_init */') - self.b(' };') - self.b('') - self.b(' type = g_type_register_static (G_TYPE_INTERFACE,') - self.b(' "%s%s", &info, 0);' % (self.Prefix, node_name_mixed)) - self.b(' }') - self.b('') - self.b(' return type;') - self.b('}') - self.b('') - - self.d('/**') - self.d(' * %s%s:' % (self.Prefix, node_name_mixed)) - self.d(' *') - self.d(' * Dummy typedef representing any implementation of this ' - 'interface.') - self.d(' */') - - self.h('typedef struct _%s%s %s%s;' - % (self.Prefix, node_name_mixed, self.Prefix, node_name_mixed)) - self.h('') - - self.d('/**') - self.d(' * %s%sClass:' % (self.Prefix, node_name_mixed)) - self.d(' *') - self.d(' * The class of %s%s.' % (self.Prefix, node_name_mixed)) - - if methods: - self.d(' *') - self.d(' * In a full implementation of this interface (i.e. all') - self.d(' * methods implemented), the interface initialization') - self.d(' * function used in G_IMPLEMENT_INTERFACE() would') - self.d(' * typically look like this:') - self.d(' *') - self.d(' * <programlisting>') - self.d(' * static void') - self.d(' * implement_%s (gpointer klass,' % self.node_name_lc) - self.d(' * gpointer unused G_GNUC_UNUSED)') - self.d(' * {') - self.d(' * #define IMPLEMENT(x) %s%s_implement_##x (\\' - % (self.prefix_, self.node_name_lc)) - self.d(' * klass, my_object_##x)') - - for method in methods: - class_member_name = method.getAttribute('tp:name-for-bindings') - class_member_name = class_member_name.lower() - self.d(' * IMPLEMENT (%s);' % class_member_name) - - self.d(' * #undef IMPLEMENT') - self.d(' * }') - self.d(' * </programlisting>') - else: - self.d(' * This interface has no D-Bus methods, so an') - self.d(' * implementation can typically pass %NULL to') - self.d(' * G_IMPLEMENT_INTERFACE() as the interface') - self.d(' * initialization function.') - - self.d(' */') - self.d('') - - self.h('typedef struct _%s%sClass %s%sClass;' - % (self.Prefix, node_name_mixed, self.Prefix, node_name_mixed)) - self.h('') - self.h('GType %s%s_get_type (void);' - % (self.prefix_, node_name_lc)) - - gtype = self.current_gtype = \ - self.MAIN_PREFIX_ + 'TYPE' + self._SUB_PREFIX_ + node_name_uc - classname = self.Prefix + node_name_mixed - - self.h('#define %s \\\n (%s%s_get_type ())' - % (gtype, self.prefix_, node_name_lc)) - self.h('#define %s%s(obj) \\\n' - ' (G_TYPE_CHECK_INSTANCE_CAST((obj), %s, %s))' - % (self.PREFIX_, node_name_uc, gtype, classname)) - self.h('#define %sIS%s%s(obj) \\\n' - ' (G_TYPE_CHECK_INSTANCE_TYPE((obj), %s))' - % (self.MAIN_PREFIX_, self._SUB_PREFIX_, node_name_uc, gtype)) - self.h('#define %s%s_GET_CLASS(obj) \\\n' - ' (G_TYPE_INSTANCE_GET_INTERFACE((obj), %s, %sClass))' - % (self.PREFIX_, node_name_uc, gtype, classname)) - self.h('') - - base_init_code = [] - method_call_code = [] - - for method in methods: - self.do_method(method, method_call_code) - - signal_table = [ - 'static const gchar * const _gsignals_%s[] = {' % - self.node_name_lc - ] - - for signal in signals: - # we rely on this being in the same order as the interface info - self.do_signal(signal, in_base_init=base_init_code, - in_signal_table=signal_table) - - signal_table.append(' NULL') - signal_table.append('};') - signal_table.append('') - for line in signal_table: - self.b(line) - - # e.g. _interface_info_connection_interface_contact_info1 - for line in GDBusInterfaceInfo(node_name, interface, - '_interface_info_%s' % node_name_lc).to_lines(linkage='static'): - self.b(line) - - self.b('') - self.b('static void') - self.b('_method_call_%s (GDBusConnection *connection,' % node_name_lc) - self.b(' const gchar *sender,') - self.b(' const gchar *object_path,') - self.b(' const gchar *interface_name,') - self.b(' const gchar *method_name,') - self.b(' GVariant *parameters,') - self.b(' GDBusMethodInvocation *invocation,') - self.b(' gpointer user_data)') - self.b('{') - - for line in method_call_code: - self.b(line) - - # Deliberately not using self.not_implemented_func here so that callers - # can distinguish between "you called Protocol.NormalizeContact() but - # that isn't implemented here" and "you called Protocol.Badger() - # which isn't even in the spec" if required. - self.b(' g_dbus_method_invocation_return_error (invocation,') - self.b(' G_DBUS_ERROR,') - self.b(' G_DBUS_ERROR_UNKNOWN_METHOD,') - self.b(' "Method not implemented");') - self.b('}') - self.b('') - self.b('static const GDBusInterfaceVTable _vtable_%s = {' % - node_name_lc) - self.b(' _method_call_%s,' % node_name_lc) - self.b(' NULL, /* get property */') - self.b(' NULL /* set property */') - self.b('};') - self.b('') - self.b('static const TpSvcInterfaceInfo _tp_interface_info_%s = {' % - node_name_lc) - self.b(' -1,') - self.b(' (GDBusInterfaceInfo *) &_interface_info_%s,' % node_name_lc) - self.b(' (GDBusInterfaceVTable *) &_vtable_%s,' % node_name_lc) - self.b(' (gchar **) _gsignals_%s' % node_name_lc) - self.b(' /* _future is implicitly zero-filled */') - self.b('};') - self.b('') - self.b('static inline void') - self.b('%s%s_base_init_once (gpointer klass G_GNUC_UNUSED)' - % (self.prefix_, node_name_lc)) - self.b('{') - - if properties: - self.b(' static TpDBusPropertiesMixinPropInfo properties[%d] = {' - % (len(properties) + 1)) - - for m in properties: - access = m.getAttribute('access') - assert access in ('read', 'write', 'readwrite') - - if access == 'read': - flags = 'TP_DBUS_PROPERTIES_MIXIN_FLAG_READ' - elif access == 'write': - flags = 'TP_DBUS_PROPERTIES_MIXIN_FLAG_WRITE' - else: - flags = ('TP_DBUS_PROPERTIES_MIXIN_FLAG_READ | ' - 'TP_DBUS_PROPERTIES_MIXIN_FLAG_WRITE') - - prop_emits_changed = get_emits_changed(m) - - if prop_emits_changed is None: - prop_emits_changed = iface_emits_changed - - if prop_emits_changed == 'true': - flags += ' | TP_DBUS_PROPERTIES_MIXIN_FLAG_EMITS_CHANGED' - elif prop_emits_changed == 'invalidates': - flags += ' | TP_DBUS_PROPERTIES_MIXIN_FLAG_EMITS_INVALIDATED' - - self.b(' { 0, %s, "%s", 0, NULL, NULL }, /* %s */' - % (flags, m.getAttribute('type'), m.getAttribute('name'))) - - self.b(' { 0, 0, NULL, 0, NULL, NULL }') - self.b(' };') - self.b(' static TpDBusPropertiesMixinIfaceInfo interface =') - self.b(' { 0, properties, NULL, NULL };') - self.b('') - - if properties: - self.b(' interface.dbus_interface = g_quark_from_static_string ' - '("%s");' % self.iface_name) - - for i, m in enumerate(properties): - self.b(' properties[%d].name = g_quark_from_static_string ("%s");' - % (i, m.getAttribute('name'))) - self.b(' properties[%d].type = %s;' - % (i, type_to_gtype(m.getAttribute('type'))[1])) - - self.b(' tp_svc_interface_set_dbus_properties_info (%s, &interface);' - % self.current_gtype) - - self.b('') - - self.b(' tp_svc_interface_set_dbus_interface_info (%s,' - % (self.current_gtype)) - self.b(' &_tp_interface_info_%s);' % node_name_lc) - - for s in base_init_code: - self.b(s) - self.b('}') - - self.b('static void') - self.b('%s%s_base_init (gpointer klass)' - % (self.prefix_, node_name_lc)) - self.b('{') - self.b(' static gboolean initialized = FALSE;') - self.b('') - self.b(' if (!initialized)') - self.b(' {') - self.b(' initialized = TRUE;') - self.b(' %s%s_base_init_once (klass);' - % (self.prefix_, node_name_lc)) - self.b(' }') - # insert anything we need to do per implementation here - self.b('}') - - self.h('') - - self.node_name_mixed = None - self.node_name_lc = None - self.node_name_uc = None - - def get_method_impl_names(self, method): - dbus_method_name = method.getAttribute('name') - - class_member_name = method.getAttribute('tp:name-for-bindings') - if dbus_method_name != class_member_name.replace('_', ''): - raise AssertionError('Method %s tp:name-for-bindings (%s) does ' - 'not match' % (dbus_method_name, class_member_name)) - class_member_name = class_member_name.lower() - - stub_name = (self.prefix_ + self.node_name_lc + '_' + - class_member_name) - return (stub_name + '_impl', class_member_name + '_cb') - - def do_method(self, method, method_call_code): - assert self.node_name_mixed is not None - - # Examples refer to Thing.DoStuff (su) -> ii - - # DoStuff - dbus_method_name = method.getAttribute('name') - # do_stuff - class_member_name = method.getAttribute('tp:name-for-bindings') - if dbus_method_name != class_member_name.replace('_', ''): - raise AssertionError('Method %s tp:name-for-bindings (%s) does ' - 'not match' % (dbus_method_name, class_member_name)) - class_member_name = class_member_name.lower() - - # tp_svc_thing_do_stuff (signature of GDBusInterfaceMethodCallFunc) - stub_name = (self.prefix_ + self.node_name_lc + '_' + - class_member_name) - # typedef void (*tp_svc_thing_do_stuff_impl) (TpSvcThing *, - # const char *, guint, GDBusMethodInvocation); - impl_name = stub_name + '_impl' - # void tp_svc_thing_return_from_do_stuff (GDBusMethodInvocation *, - # gint, gint); - ret_name = (self.prefix_ + self.node_name_lc + '_return_from_' + - class_member_name) - - # Gather arguments - in_args = [] - in_arg_value_getters = [] - out_args = [] - for i in method.getElementsByTagName('arg'): - name = i.getAttribute('name') - direction = i.getAttribute('direction') or 'in' - dtype = i.getAttribute('type') - - assert direction in ('in', 'out') - - if name: - name = direction + '_' + name - elif direction == 'in': - name = direction + str(len(in_args)) - else: - name = direction + str(len(out_args)) - - ctype, gtype, marshaller, pointer = type_to_gtype(dtype) - - if pointer: - ctype = 'const ' + ctype - - struct = (ctype, name) - - if direction == 'in': - in_args.append((ctype, name)) - in_arg_value_getters.append(value_getter(gtype, marshaller)) - else: - out_args.append((gtype, ctype, name)) - - # bits of _method_call_myiface - method_call_code.extend([ - ' if (g_strcmp0 (method_name, "%s") == 0)' % dbus_method_name, - ' {', - ' %s (connection, sender, object_path, interface_name, ' % - stub_name, - ' method_name, parameters, invocation, user_data);', - ' return;', - ' }', - '' - ]) - - # Implementation type declaration (in header, docs separated) - self.d('/**') - self.d(' * %s:' % impl_name) - self.d(' * @self: The object implementing this interface') - for (ctype, name) in in_args: - self.d(' * @%s: %s (FIXME, generate documentation)' - % (name, ctype)) - self.d(' * @invocation: Used to return values or throw an error') - self.d(' *') - self.d(' * The signature of an implementation of the D-Bus method') - self.d(' * %s on interface %s.' % (dbus_method_name, self.iface_name)) - self.d(' */') - - self.h('typedef void (*%s) (%s%s *self,' - % (impl_name, self.Prefix, self.node_name_mixed)) - for (ctype, name) in in_args: - self.h(' %s%s,' % (ctype, name)) - self.h(' GDBusMethodInvocation *invocation);') - - # Stub definition (in body only - it's static) - self.b('static void') - self.b('%s (GDBusConnection *connection,' % stub_name) - self.b(' const gchar *sender,') - self.b(' const gchar *object_path,') - self.b(' const gchar *interface_name,') - self.b(' const gchar *method_name,') - self.b(' GVariant *parameters,') - self.b(' GDBusMethodInvocation *invocation,') - self.b(' gpointer user_data)') - self.b('{') - self.b(' %s%s *self = %s%s (user_data);' - % (self.Prefix, self.node_name_mixed, self.PREFIX_, - self.node_name_uc)) - self.b(' %s%sClass *cls = %s%s_GET_CLASS (self);' - % (self.Prefix, self.node_name_mixed, self.PREFIX_, - self.node_name_uc)) - self.b(' %s impl = cls->%s_cb;' % (impl_name, class_member_name)) - self.b('') - self.b(' if (impl != NULL)') - tmp = ['self'] + [name for (ctype, name) in in_args] + ['invocation'] - self.b(' {') - - if in_args: - self.b(' GValue args_val = G_VALUE_INIT;') - self.b(' GValueArray *va;') - self.b('') - self.b(' dbus_g_value_parse_g_variant (parameters, &args_val);') - self.b(' va = g_value_get_boxed (&args_val);') - self.b('') - - self.b(' (impl) (self,') - - for i, getter in enumerate(in_arg_value_getters): - self.b(' %s (va->values + %d),' % (getter, i)) - - self.b(' invocation);') - - if in_args: - self.b(' g_value_unset (&args_val);') - - self.b(' }') - self.b(' else') - self.b(' {') - if self.not_implemented_func: - self.b(' %s (invocation);' % self.not_implemented_func) - else: - self.b(' g_dbus_method_invocation_return_error (invocation,') - self.b(' G_DBUS_ERROR,') - self.b(' G_DBUS_ERROR_UNKNOWN_METHOD,') - self.b(' "Method not implemented");') - self.b(' }') - self.b('}') - self.b('') - - # Implementation registration (in both header and body) - self.h('void %s%s_implement_%s (%s%sClass *klass, %s impl);' - % (self.prefix_, self.node_name_lc, class_member_name, - self.Prefix, self.node_name_mixed, impl_name)) - - self.d('/**') - self.d(' * %s%s_implement_%s:' - % (self.prefix_, self.node_name_lc, class_member_name)) - self.d(' * @klass: A class whose instances implement this interface') - self.d(' * @impl: A callback used to implement the %s D-Bus method' - % dbus_method_name) - self.d(' *') - self.d(' * Register an implementation for the %s method in the vtable' - % dbus_method_name) - self.d(' * of an implementation of this interface. To be called from') - self.d(' * the interface init function.') - self.d(' */') - - self.b('void') - self.b('%s%s_implement_%s (%s%sClass *klass, %s impl)' - % (self.prefix_, self.node_name_lc, class_member_name, - self.Prefix, self.node_name_mixed, impl_name)) - self.b('{') - self.b(' klass->%s_cb = impl;' % class_member_name) - self.b('}') - self.b('') - - # Return convenience function - self.d('/**') - self.d(' * %s:' % ret_name) - self.d(' * @invocation: The D-Bus method invocation context') - for (gtype, ctype, name) in out_args: - self.d(' * @%s: %s (FIXME, generate documentation)' - % (name, ctype)) - self.d(' *') - self.d(' * Return successfully by calling g_dbus_method_invocation_return_value().') - self.d(' */') - self.d('') - - tmp = (['GDBusMethodInvocation *invocation'] + - [ctype + name for (gtype, ctype, name) in out_args]) - self.h(('void %s (' % ret_name) + (',\n '.join(tmp)) + ');') - - self.b('void') - self.b(('%s (' % ret_name) + (',\n '.join(tmp)) + ')') - self.b('{') - self.b(' GValueArray *tmp = tp_value_array_build (%d,' % len(out_args)) - - for (gtype, ctype, name) in out_args: - self.b(' %s, %s,' % (gtype, name)) - - self.b(' G_TYPE_INVALID);') - self.b(' GValue args_val = G_VALUE_INIT;') - self.b('') - - self.b(' g_value_init (&args_val, ' - 'dbus_g_type_get_struct ("GValueArray",') - - for (gtype, ctype, name) in out_args: - self.b(' %s,' % gtype) - - self.b(' G_TYPE_INVALID));') - - self.b(' g_value_take_boxed (&args_val, tmp);') - - self.b(' g_dbus_method_invocation_return_value (invocation,') - self.b(' /* consume floating ref */') - self.b(' dbus_g_value_build_g_variant (&args_val));') - self.b(' g_value_unset (&args_val);') - self.b('}') - self.b('') - - def get_signal_const_entry(self, signal): - assert self.node_name_uc is not None - return ('SIGNAL_%s_%s' - % (self.node_name_uc, signal.getAttribute('name'))) - - def do_signal(self, signal, in_base_init, in_signal_table): - assert self.node_name_mixed is not None - - # for signal: Thing::StuffHappened (s, u) - # we want to emit: - # void tp_svc_thing_emit_stuff_happened (gpointer instance, - # const char *arg0, guint arg1); - - dbus_name = signal.getAttribute('name') - - ugly_name = signal.getAttribute('tp:name-for-bindings') - if dbus_name != ugly_name.replace('_', ''): - raise AssertionError('Signal %s tp:name-for-bindings (%s) does ' - 'not match' % (dbus_name, ugly_name)) - - stub_name = (self.prefix_ + self.node_name_lc + '_emit_' + - ugly_name.lower()) - - const_name = self.get_signal_const_entry(signal) - - # Gather arguments - args = [] - for i in signal.getElementsByTagName('arg'): - name = i.getAttribute('name') - dtype = i.getAttribute('type') - tp_type = i.getAttribute('tp:type') - - if name: - name = 'arg_' + name - else: - name = 'arg' + str(len(args)) - - ctype, gtype, marshaller, pointer = type_to_gtype(dtype) - - if pointer: - ctype = 'const ' + ctype - - struct = (ctype, name, gtype) - args.append(struct) - - tmp = (['gpointer instance'] + - [ctype + name for (ctype, name, gtype) in args]) - - self.h(('void %s (' % stub_name) + (',\n '.join(tmp)) + ');') - - # FIXME: emit docs - - self.d('/**') - self.d(' * %s:' % stub_name) - self.d(' * @instance: The object implementing this interface') - for (ctype, name, gtype) in args: - self.d(' * @%s: %s (FIXME, generate documentation)' - % (name, ctype)) - self.d(' *') - self.d(' * Type-safe wrapper around g_signal_emit to emit the') - self.d(' * %s signal on interface %s.' - % (dbus_name, self.iface_name)) - self.d(' */') - - self.b('void') - self.b(('%s (' % stub_name) + (',\n '.join(tmp)) + ')') - self.b('{') - self.b(' g_assert (instance != NULL);') - self.b(' g_assert (G_TYPE_CHECK_INSTANCE_TYPE (instance, %s));' - % (self.current_gtype)) - tmp = (['instance', '%s_signals[%s]' % (self.node_name_lc, const_name), - '0'] + [name for (ctype, name, gtype) in args]) - self.b(' g_signal_emit (' + ',\n '.join(tmp) + ');') - self.b('}') - self.b('') - - signal_name = dbus_gutils_wincaps_to_uscore(dbus_name).replace('_', - '-') - - self.d('/**') - self.d(' * %s%s::%s:' - % (self.Prefix, self.node_name_mixed, signal_name)) - self.d(' * @self: an object') - for (ctype, name, gtype) in args: - self.d(' * @%s: %s (FIXME, generate documentation)' - % (name, ctype)) - self.d(' *') - self.d(' * The %s D-Bus signal is emitted whenever ' - 'this GObject signal is.' % dbus_name) - self.d(' */') - self.d('') - - in_base_init.append(' %s_signals[%s] =' - % (self.node_name_lc, const_name)) - in_base_init.append(' g_signal_new ("%s",' % signal_name) - in_base_init.append(' G_OBJECT_CLASS_TYPE (klass),') - in_base_init.append(' G_SIGNAL_RUN_LAST|G_SIGNAL_DETAILED,') - in_base_init.append(' 0,') - in_base_init.append(' NULL, NULL,') - in_base_init.append(' g_cclosure_marshal_generic,') - in_base_init.append(' G_TYPE_NONE,') - tmp = ['%d' % len(args)] + [gtype for (ctype, name, gtype) in args] - in_base_init.append(' %s);' % ',\n '.join(tmp)) - in_base_init.append('') - - in_signal_table.append(' "%s",' % signal_name) - - def have_properties(self, nodes): - for node in nodes: - interface = node.getElementsByTagName('interface')[0] - if interface.getElementsByTagName('property'): - return True - return False - - def __call__(self): - nodes = self.dom.getElementsByTagName('node') - nodes.sort(key=key_by_name) - - self.h('#include <glib-object.h>') - self.h('#include <gio/gio.h>') - self.h('#include <dbus/dbus-glib.h>') - - self.h('') - self.h('G_BEGIN_DECLS') - self.h('') - - self.b('#include "%s.h"' % self.basename) - self.b('') - - if self.allow_single_include: - self.b('#include <telepathy-glib/dbus.h>') - self.b('#include <telepathy-glib/dbus-properties-mixin.h>') - self.b('#include <telepathy-glib/svc-interface.h>') - self.b('#include <telepathy-glib/util.h>') - self.b('#include <telepathy-glib/value-array.h>') - else: - self.b('#include <telepathy-glib/telepathy-glib.h>') - self.b('#include <telepathy-glib/telepathy-glib-dbus.h>') - self.b('') - - for header in self.headers: - self.b('#include %s' % header) - self.b('') - - for node in nodes: - self.do_node(node) - - self.h('') - self.h('G_END_DECLS') - - self.b('') - for header in self.end_headers: - self.b('#include %s' % header) - - self.h('') - self.b('') - file_set_contents(self.basename + '.h', u('\n').join(self.__header).encode('utf-8')) - file_set_contents(self.basename + '.c', u('\n').join(self.__body).encode('utf-8')) - file_set_contents(self.basename + '-gtk-doc.h', u('\n').join(self.__docs).encode('utf-8')) - -def cmdline_error(): - print("""\ -usage: - gen-ginterface [OPTIONS] xmlfile Prefix_ -options: - --include='<header.h>' (may be repeated) - --include='"header.h"' (ditto) - --include-end='"header.h"' (ditto) - Include extra headers in the generated .c file - --signal-marshal-prefix='prefix' - Use the given prefix on generated signal marshallers (default is - prefix.lower()). - --filename='BASENAME' - Set the basename for the output files (default is prefix.lower() - + 'ginterfaces') - --not-implemented-func='symbol' - Set action when methods not implemented in the interface vtable are - called. symbol must have signature - void symbol (GDBusMethodInvocation *invocation) - and return some sort of "not implemented" error via - e.g. g_dbus_method_invocation_return_error -""") - sys.exit(1) - - -if __name__ == '__main__': - from getopt import gnu_getopt - - options, argv = gnu_getopt(sys.argv[1:], '', - ['filename=', 'signal-marshal-prefix=', - 'include=', 'include-end=', - 'allow-unstable', - 'not-implemented-func=', - "allow-single-include"]) - - try: - prefix = argv[1] - except IndexError: - cmdline_error() - - basename = prefix.lower() + 'ginterfaces' - signal_marshal_prefix = prefix.lower().rstrip('_') - headers = [] - end_headers = [] - not_implemented_func = '' - allow_havoc = False - allow_single_include = False - - for option, value in options: - if option == '--filename': - basename = value - elif option == '--signal-marshal-prefix': - signal_marshal_prefix = value - elif option == '--include': - if value[0] not in '<"': - value = '"%s"' % value - headers.append(value) - elif option == '--include-end': - if value[0] not in '<"': - value = '"%s"' % value - end_headers.append(value) - elif option == '--not-implemented-func': - not_implemented_func = value - elif option == '--allow-unstable': - allow_havoc = True - elif option == '--allow-single-include': - allow_single_include = True - - try: - dom = xml.dom.minidom.parse(argv[0]) - except IndexError: - cmdline_error() - - Generator(dom, prefix, basename, signal_marshal_prefix, headers, - end_headers, not_implemented_func, allow_havoc, - allow_single_include)() diff --git a/tools/identity.xsl b/tools/identity.xsl deleted file mode 100644 index 6630f84..0000000 --- a/tools/identity.xsl +++ /dev/null @@ -1,7 +0,0 @@ -<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> - <xsl:template match="@*|node()"> - <xsl:copy> - <xsl:apply-templates select="@*|node()"/> - </xsl:copy> - </xsl:template> -</xsl:stylesheet> diff --git a/tools/libglibcodegen.py b/tools/libglibcodegen.py deleted file mode 100644 index 5cd0058..0000000 --- a/tools/libglibcodegen.py +++ /dev/null @@ -1,344 +0,0 @@ -"""Library code for GLib/D-Bus-related code generation. - -The master copy of this library is in the telepathy-glib repository - -please make any changes there. -""" - -# Copyright (C) 2006-2008 Collabora Limited -# -# 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.1 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - -from libtpcodegen import NS_TP, \ - Signature, \ - cmp_by_name, \ - escape_as_identifier, \ - get_by_path, \ - get_descendant_text, \ - get_docstring, \ - xml_escape, \ - get_deprecated - -def dbus_gutils_wincaps_to_uscore(s): - """Bug-for-bug compatible Python port of _dbus_gutils_wincaps_to_uscore - which gets sequences of capital letters wrong in the same way. - (e.g. in Telepathy, SendDTMF -> send_dt_mf) - """ - ret = '' - for c in s: - if c >= 'A' and c <= 'Z': - length = len(ret) - if length > 0 and (length < 2 or ret[length-2] != '_'): - ret += '_' - ret += c.lower() - else: - ret += c - return ret - -def type_to_gtype(s): - if s == 'y': #byte - return ("guchar ", "G_TYPE_UCHAR","UCHAR", False) - elif s == 'b': #boolean - return ("gboolean ", "G_TYPE_BOOLEAN","BOOLEAN", False) - elif s == 'n': #int16 - return ("gint ", "G_TYPE_INT","INT", False) - elif s == 'q': #uint16 - return ("guint ", "G_TYPE_UINT","UINT", False) - elif s == 'i': #int32 - return ("gint ", "G_TYPE_INT","INT", False) - elif s == 'u': #uint32 - return ("guint ", "G_TYPE_UINT","UINT", False) - elif s == 'x': #int64 - return ("gint64 ", "G_TYPE_INT64","INT64", False) - elif s == 't': #uint64 - return ("guint64 ", "G_TYPE_UINT64","UINT64", False) - elif s == 'd': #double - return ("gdouble ", "G_TYPE_DOUBLE","DOUBLE", False) - elif s == 's': #string - return ("gchar *", "G_TYPE_STRING", "STRING", True) - elif s == 'g': #signature - FIXME - return ("gchar *", "DBUS_TYPE_G_SIGNATURE", "STRING", True) - elif s == 'o': #object path - return ("gchar *", "DBUS_TYPE_G_OBJECT_PATH", "BOXED", True) - elif s == 'v': #variant - return ("GValue *", "G_TYPE_VALUE", "BOXED", True) - elif s == 'as': #array of strings - return ("gchar **", "G_TYPE_STRV", "BOXED", True) - elif s == 'ay': #byte array - return ("GArray *", - "dbus_g_type_get_collection (\"GArray\", G_TYPE_UCHAR)", "BOXED", - True) - elif s == 'au': #uint array - return ("GArray *", "DBUS_TYPE_G_UINT_ARRAY", "BOXED", True) - elif s == 'ai': #int array - return ("GArray *", "DBUS_TYPE_G_INT_ARRAY", "BOXED", True) - elif s == 'ax': #int64 array - return ("GArray *", "DBUS_TYPE_G_INT64_ARRAY", "BOXED", True) - elif s == 'at': #uint64 array - return ("GArray *", "DBUS_TYPE_G_UINT64_ARRAY", "BOXED", True) - elif s == 'ad': #double array - return ("GArray *", "DBUS_TYPE_G_DOUBLE_ARRAY", "BOXED", True) - elif s == 'ab': #boolean array - return ("GArray *", "DBUS_TYPE_G_BOOLEAN_ARRAY", "BOXED", True) - elif s == 'ao': #object path array - return ("GPtrArray *", - 'dbus_g_type_get_collection ("GPtrArray",' - ' DBUS_TYPE_G_OBJECT_PATH)', - "BOXED", True) - elif s == 'a{ss}': #hash table of string to string - return ("GHashTable *", "DBUS_TYPE_G_STRING_STRING_HASHTABLE", "BOXED", False) - elif s[:2] == 'a{': #some arbitrary hash tables - if s[2] not in ('y', 'b', 'n', 'q', 'i', 'u', 's', 'o', 'g'): - raise Exception("can't index a hashtable off non-basic type " + s) - first = type_to_gtype(s[2]) - second = type_to_gtype(s[3:-1]) - return ("GHashTable *", "(dbus_g_type_get_map (\"GHashTable\", " + first[1] + ", " + second[1] + "))", "BOXED", False) - elif s[:2] in ('a(', 'aa'): # array of structs or arrays, recurse - gtype = type_to_gtype(s[1:])[1] - return ("GPtrArray *", "(dbus_g_type_get_collection (\"GPtrArray\", "+gtype+"))", "BOXED", True) - elif s[:1] == '(': #struct - gtype = "(dbus_g_type_get_struct (\"GValueArray\", " - for subsig in Signature(s[1:-1]): - gtype = gtype + type_to_gtype(subsig)[1] + ", " - gtype = gtype + "G_TYPE_INVALID))" - return ("GValueArray *", gtype, "BOXED", True) - - # we just don't know .. - raise Exception("don't know the GType for " + s) - -def value_getter(gtype, marshaller): - if marshaller == 'BOXED': - return 'g_value_get_boxed' - elif gtype == 'G_TYPE_STRING': - return 'g_value_get_string' - elif gtype == 'G_TYPE_UCHAR': - return 'g_value_get_uchar' - elif gtype == 'G_TYPE_BOOLEAN': - return 'g_value_get_boolean' - elif gtype == 'G_TYPE_UINT': - return 'g_value_get_uint' - elif gtype == 'G_TYPE_INT': - return 'g_value_get_int' - elif gtype == 'G_TYPE_UINT64': - return 'g_value_get_uint64' - elif gtype == 'G_TYPE_INT64': - return 'g_value_get_int64' - elif gtype == 'G_TYPE_DOUBLE': - return 'g_value_get_double' - else: - raise AssertionError("Don't know how to get %s from a GValue" % marshaller) - -class GDBusInterfaceInfo(object): - def __init__(self, ugly_name, iface_element, c_name): - self.ugly_name = ugly_name - self.mixed_name = ugly_name.replace('_', '') - self.lc_name = ugly_name.lower() - self.uc_name = ugly_name.upper() - self.c_name = c_name - self.iface_element = iface_element - - self.method_elements = iface_element.getElementsByTagName('method') - self.signal_elements = iface_element.getElementsByTagName('signal') - self.property_elements = iface_element.getElementsByTagName('property') - - def do_methods(self): - method_args = [ - ] - method_in_arg_pointers = [ - ] - method_out_arg_pointers = [ - ] - methods = [ - ] - method_pointers = [ - 'static const GDBusMethodInfo *const method_pointers_%s[] = {' - % self.c_name, - ] - - for meth in self.method_elements: - lc_name = meth.getAttribute('tp:name-for-bindings') - if meth.getAttribute('name') != lc_name.replace('_', ''): - raise AssertionError('Method %s tp:name-for-bindings (%s) ' - 'does not match' % - (meth.getAttribute('name'), lc_name)) - lc_name = lc_name.lower() - - c_name = 'method_%s_%s' % (self.c_name, lc_name) - - method_in_arg_pointers.append('static const GDBusArgInfo *const ' - 'method_in_arg_pointers_%s_%s[] = {' % - (self.c_name, lc_name)) - method_out_arg_pointers.append('static const GDBusArgInfo *const ' - 'method_out_arg_pointers_%s_%s[] = {' - % (self.c_name, lc_name)) - - for i, arg in enumerate(meth.getElementsByTagName('arg')): - name = arg.getAttribute('name') - if not name: - name = 'arg%d' % i - - method_args.append('static const GDBusArgInfo ' - 'method_arg_%s_%s_%d = {' % (self.c_name, lc_name, i)) - method_args.append(' -1, /* refcount */') - method_args.append(' "%s",' % name) - method_args.append(' "%s",' % arg.getAttribute('type')) - method_args.append(' NULL /* annotations */') - method_args.append('};') - - if arg.getAttribute('direction') == 'out': - method_out_arg_pointers.append(' &method_arg_%s_%s_%d,' % - (self.c_name, lc_name, i)) - else: - method_in_arg_pointers.append(' &method_arg_%s_%s_%d,' % - (self.c_name, lc_name, i)) - - method_in_arg_pointers.append(' NULL') - method_in_arg_pointers.append('};') - method_out_arg_pointers.append(' NULL') - method_out_arg_pointers.append('};') - - methods.append('static const GDBusMethodInfo %s = {' % c_name) - methods.append(' -1, /* refcount */') - methods.append(' "%s",' % meth.getAttribute("name")) - methods.append(' (GDBusArgInfo **) method_in_arg_pointers_%s_%s,' - % (self.c_name, lc_name)) - methods.append(' (GDBusArgInfo **) method_out_arg_pointers_%s_%s,' - % (self.c_name, lc_name)) - methods.append(' NULL /* annotations */') - methods.append('};') - - method_pointers.append(' &%s,' % c_name) - - method_pointers.append(' NULL') - method_pointers.append('};') - - return (method_args + method_in_arg_pointers + - method_out_arg_pointers + methods + method_pointers) - - def do_signals(self): - signal_args = [ - ] - signal_arg_pointers = [ - ] - signals = [ - ] - signal_pointers = [ - 'static const GDBusSignalInfo *const signal_pointers_%s[] = {' - % self.c_name, - ] - - for sig in self.signal_elements: - lc_name = sig.getAttribute('tp:name-for-bindings') - if sig.getAttribute('name') != lc_name.replace('_', ''): - raise AssertionError('Signal %s tp:name-for-bindings (%s) ' - 'does not match' % - (sig.getAttribute('name'), lc_name)) - lc_name = lc_name.lower() - - c_name = 'signal_%s_%s' % (self.c_name, lc_name) - - signal_arg_pointers.append('static const GDBusArgInfo *const ' - 'signal_arg_pointers_%s_%s[] = {' % (self.c_name, lc_name)) - - for i, arg in enumerate(sig.getElementsByTagName('arg')): - name = arg.getAttribute('name') - if not name: - name = 'arg%d' % i - - signal_args.append('static const GDBusArgInfo ' - 'signal_arg_%s_%s_%d = {' % (self.c_name, lc_name, i)) - signal_args.append(' -1, /* refcount */') - signal_args.append(' "%s",' % name) - signal_args.append(' "%s",' % arg.getAttribute('type')) - signal_args.append(' NULL /* annotations */') - signal_args.append('};') - - signal_arg_pointers.append(' &signal_arg_%s_%s_%d,' % - (self.c_name, lc_name, i)) - - signal_arg_pointers.append(' NULL') - signal_arg_pointers.append('};') - - signals.append('static const GDBusSignalInfo %s = {' % c_name) - signals.append(' -1, /* refcount */') - signals.append(' "%s",' % sig.getAttribute("name")) - signals.append(' (GDBusArgInfo **) signal_arg_pointers_%s_%s,' - % (self.c_name, lc_name)) - signals.append(' NULL /* annotations */') - signals.append('};') - - signal_pointers.append(' &%s,' % c_name) - - signal_pointers.append(' NULL') - signal_pointers.append('};') - - return signal_args + signal_arg_pointers + signals + signal_pointers - - def do_properties(self): - properties = [ - ] - property_pointers = [ - 'static const GDBusPropertyInfo *const property_pointers_%s[] = {' - % self.c_name, - ] - - for prop in self.property_elements: - access = prop.getAttribute('access') - flags = { - 'read': 'G_DBUS_PROPERTY_INFO_FLAGS_READABLE', - 'write': 'G_DBUS_PROPERTY_INFO_FLAGS_WRITABLE', - 'readwrite': - 'G_DBUS_PROPERTY_INFO_FLAGS_READABLE | ' - 'G_DBUS_PROPERTY_INFO_FLAGS_WRITABLE', - }[access] - - lc_name = prop.getAttribute('tp:name-for-bindings') - if prop.getAttribute('name') != lc_name.replace('_', ''): - raise AssertionError('Property %s tp:name-for-bindings (%s) ' - 'does not match' % - (prop.getAttribute('name'), lc_name)) - lc_name = lc_name.lower() - - c_name = 'property_%s_%s' % (self.c_name, lc_name) - - properties.append('static const GDBusPropertyInfo %s = {' % c_name) - properties.append(' -1, /* refcount */') - properties.append(' "%s",' % prop.getAttribute("name")) - properties.append(' "%s",' % prop.getAttribute("type")) - properties.append(' %s,' % flags) - # FIXME: add annotations? - properties.append(' NULL /* annotations */') - properties.append('};') - - property_pointers.append(' &%s,' % c_name) - - property_pointers.append(' NULL') - property_pointers.append('};') - - return properties + property_pointers - - def to_lines(self, linkage='static'): - return (self.do_methods() + - self.do_signals() + - self.do_properties() + [ - '%s const GDBusInterfaceInfo %s = {' % (linkage, self.c_name), - ' -1, /* refcount */', - ' "%s",' % self.iface_element.getAttribute('name'), - ' (GDBusMethodInfo **) method_pointers_%s,' % self.c_name, - ' (GDBusSignalInfo **) signal_pointers_%s,' % self.c_name, - ' (GDBusPropertyInfo **) property_pointers_%s,' % self.c_name, - ' NULL /* annotations */', - '};' - ]) diff --git a/tools/libtpcodegen.py b/tools/libtpcodegen.py deleted file mode 100644 index 021a82b..0000000 --- a/tools/libtpcodegen.py +++ /dev/null @@ -1,257 +0,0 @@ -"""Library code for language-independent D-Bus-related code generation. - -The master copy of this library is in the telepathy-glib repository - -please make any changes there. -""" - -# Copyright (C) 2006-2008 Collabora Limited -# -# 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.1 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -import os -import sys -from string import ascii_letters, digits - - -NS_TP = "http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0" - -_ASCII_ALNUM = ascii_letters + digits - -if sys.version_info[0] >= 3: - def u(s): - """Return s, which must be a str literal with no non-ASCII characters. - This is like a more restricted form of the Python 2 u'' syntax. - """ - return s.encode('ascii').decode('ascii') -else: - def u(s): - """Return a Unicode version of s, which must be a str literal - (a bytestring) in which each byte is an ASCII character. - This is like a more restricted form of the u'' syntax. - """ - return s.decode('ascii') - -def file_set_contents(filename, contents): - try: - os.remove(filename) - except OSError: - pass - try: - os.remove(filename + '.tmp') - except OSError: - pass - - open(filename + '.tmp', 'wb').write(contents) - os.rename(filename + '.tmp', filename) - -def cmp_by_name(node1, node2): - return cmp(node1.getAttributeNode("name").nodeValue, - node2.getAttributeNode("name").nodeValue) - -def key_by_name(node): - return node.getAttributeNode("name").nodeValue - -def escape_as_identifier(identifier): - """Escape the given string to be a valid D-Bus object path or service - name component, using a reversible encoding to ensure uniqueness. - - The reversible encoding is as follows: - - * The empty string becomes '_' - * Otherwise, each non-alphanumeric character is replaced by '_' plus - two lower-case hex digits; the same replacement is carried out on - the first character, if it's a digit - """ - # '' -> '_' - if not identifier: - return '_' - - # A bit of a fast path for strings which are already OK. - # We deliberately omit '_' because, for reversibility, that must also - # be escaped. - if (identifier.strip(_ASCII_ALNUM) == '' and - identifier[0] in ascii_letters): - return identifier - - # The first character may not be a digit - if identifier[0] not in ascii_letters: - ret = ['_%02x' % ord(identifier[0])] - else: - ret = [identifier[0]] - - # Subsequent characters may be digits or ASCII letters - for c in identifier[1:]: - if c in _ASCII_ALNUM: - ret.append(c) - else: - ret.append('_%02x' % ord(c)) - - return ''.join(ret) - - -def get_by_path(element, path): - branches = path.split('/') - branch = branches[0] - - # Is the current branch an attribute, if so, return the attribute value - if branch[0] == '@': - return element.getAttribute(branch[1:]) - - # Find matching children for the branch - children = [] - if branch == '..': - children.append(element.parentNode) - else: - for x in element.childNodes: - if x.localName == branch: - children.append(x) - - ret = [] - # If this is not the last path element, recursively gather results from - # children - if len(branches) > 1: - for x in children: - add = get_by_path(x, '/'.join(branches[1:])) - if isinstance(add, list): - ret += add - else: - return add - else: - ret = children - - return ret - - -def get_docstring(element): - docstring = None - for x in element.childNodes: - if x.namespaceURI == NS_TP and x.localName == 'docstring': - docstring = x - if docstring is not None: - docstring = docstring.toxml().replace('\n', ' ').strip() - if docstring.startswith('<tp:docstring>'): - docstring = docstring[14:].lstrip() - if docstring.endswith('</tp:docstring>'): - docstring = docstring[:-15].rstrip() - if docstring in ('<tp:docstring/>', ''): - docstring = '' - return docstring - -def get_deprecated(element): - text = [] - for x in element.childNodes: - if hasattr(x, 'data'): - text.append(x.data.replace('\n', ' ').strip()) - else: - # This caters for tp:dbus-ref elements, but little else. - if x.childNodes and hasattr(x.childNodes[0], 'data'): - text.append(x.childNodes[0].data.replace('\n', ' ').strip()) - return ' '.join(text) - -def get_descendant_text(element_or_elements): - if not element_or_elements: - return '' - if isinstance(element_or_elements, list): - return ''.join(map(get_descendant_text, element_or_elements)) - parts = [] - for x in element_or_elements.childNodes: - if x.nodeType == x.TEXT_NODE: - parts.append(x.nodeValue) - elif x.nodeType == x.ELEMENT_NODE: - parts.append(get_descendant_text(x)) - else: - pass - return ''.join(parts) - - -class _SignatureIter: - """Iterator over a D-Bus signature. Copied from dbus-python 0.71 so we - can run genginterface in a limited environment with only Python - (like Scratchbox). - """ - def __init__(self, string): - self.remaining = string - - def next(self): - return self.__next__() - - def __next__(self): - if self.remaining == '': - raise StopIteration - - signature = self.remaining - block_depth = 0 - block_type = None - end = len(signature) - - for marker in range(0, end): - cur_sig = signature[marker] - - if cur_sig == 'a': - pass - elif cur_sig == '{' or cur_sig == '(': - if block_type == None: - block_type = cur_sig - - if block_type == cur_sig: - block_depth = block_depth + 1 - - elif cur_sig == '}': - if block_type == '{': - block_depth = block_depth - 1 - - if block_depth == 0: - end = marker - break - - elif cur_sig == ')': - if block_type == '(': - block_depth = block_depth - 1 - - if block_depth == 0: - end = marker - break - - else: - if block_depth == 0: - end = marker - break - - end = end + 1 - self.remaining = signature[end:] - return Signature(signature[0:end]) - - -class Signature(str): - """A string, iteration over which is by D-Bus single complete types - rather than characters. - """ - def __iter__(self): - return _SignatureIter(self) - - -def xml_escape(s): - s = s.replace('&', '&').replace("'", ''').replace('"', '"') - return s.replace('<', '<').replace('>', '>') - -def get_emits_changed(node): - try: - return [ - annotation.getAttribute('value') - for annotation in node.getElementsByTagName('annotation') - if annotation.getAttribute('name') == 'org.freedesktop.DBus.Property.EmitsChangedSignal' - ][0] - except IndexError: - return None diff --git a/tools/ls-interfaces.xsl b/tools/ls-interfaces.xsl deleted file mode 100644 index efb76b9..0000000 --- a/tools/ls-interfaces.xsl +++ /dev/null @@ -1,35 +0,0 @@ -<!-- -Extract a space-separated list of interface classnames from the Telepathy spec. -The master copy of this stylesheet is in the Telepathy spec repository - -please make any changes there. - -Copyright (C) 2006, 2007 Collabora Limited - -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.1 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 -Library 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 ---> - -<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> - - <xsl:output method="text" indent="no" encoding="ascii"/> - - <xsl:template match="text()"/> - - <xsl:template match="node"> - <xsl:value-of select="concat(' ', translate(@name, '/', ''), ' ')"/> - </xsl:template> - -</xsl:stylesheet> - -<!-- vim:set sw=2 sts=2 et noai noci: --> diff --git a/tools/make-all-async.xsl b/tools/make-all-async.xsl deleted file mode 100644 index 271bec5..0000000 --- a/tools/make-all-async.xsl +++ /dev/null @@ -1,43 +0,0 @@ -<!-- Alter a D-Bus introspection XML file to add the DBus.GLib.Async annotation -to all methods. -The master copy of this stylesheet is in the telepathy-glib repository - -please make any changes there. - -Copyright (C) 2006, 2007 Collabora Limited - -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.1 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 -Library 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 ---> -<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> - - <xsl:output method="xml" indent="yes" encoding="ascii"/> - - <xsl:template match="method"> - <xsl:copy> - <xsl:apply-templates select="@*|node()"/> - <xsl:if test="not(annotation[name='org.freedesktop.DBus.GLib.Async'])"> - <annotation name="org.freedesktop.DBus.GLib.Async" value=""/> - </xsl:if> - </xsl:copy> - </xsl:template> - - <xsl:template match="@*|node()"> - <xsl:copy> - <xsl:apply-templates select="@*|node()"/> - </xsl:copy> - </xsl:template> - -</xsl:stylesheet> - -<!-- vim:set sw=2 sts=2 et: --> diff --git a/tools/spec-to-introspect.xsl b/tools/spec-to-introspect.xsl deleted file mode 100644 index 3def766..0000000 --- a/tools/spec-to-introspect.xsl +++ /dev/null @@ -1,51 +0,0 @@ -<!-- Remove Telepathy extensions from a D-Bus interface, trying to leave only -DTD-compliant introspection XML. The output still needs to be subjected to the -following sed filter: -sed -e 's@xmlns:tp="http://telepathy\.freedesktop\.org/wiki/DbusSpec.extensions-v0"@@g' - -The master copy of this stylesheet is in the Telepathy spec repository - -please make any changes there. - -Copyright (C) 2006, 2007 Collabora Limited - -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.1 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 -Library 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 ---> - -<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" - xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0" - exclude-result-prefixes="tp"> - - <xsl:template match="*"> - <xsl:copy> - <xsl:for-each select="@*"> - <xsl:if test="not(starts-with(name(), 'tp:'))"> - <xsl:copy/> - </xsl:if> - </xsl:for-each> - <xsl:apply-templates/> - </xsl:copy> - </xsl:template> - - <xsl:template match="tp:*"/> - <xsl:template match="text()"/> - - <xsl:output method="xml" indent="yes" encoding="UTF-8" - omit-xml-declaration="no" - doctype-system="http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd" - doctype-public="-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" /> - -</xsl:stylesheet> - -<!-- vim:set sw=2 sts=2 et: --> |