summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorCosimo Alfarano <cosimo.alfarano@collabora.co.uk>2010-01-29 19:02:04 +0000
committerCosimo Alfarano <cosimo.alfarano@collabora.co.uk>2010-01-29 19:02:04 +0000
commit2e520db643e63c674ad955212f143ce1997189f2 (patch)
tree5f6aad7531b1f38b176d69393a02b7d1642b3c5b /tools
parentdeb5b0460352f8ae9031621360c64f33b5c1c70b (diff)
downloadtelepathy-logger-2e520db643e63c674ad955212f143ce1997189f2.tar.gz
Added file for TP DBus extension support
Diffstat (limited to 'tools')
-rw-r--r--tools/.gitignore3
-rw-r--r--tools/Makefile.am57
-rwxr-xr-x[-rw-r--r--]tools/c-constants-gen.py59
-rw-r--r--tools/check-coding-style.mk4
-rw-r--r--tools/check-whitespace.sh11
-rw-r--r--tools/glib-client-gen.py1157
-rw-r--r--tools/glib-client-marshaller-gen.py59
-rw-r--r--tools/glib-errors-enum-body-gen.py62
-rw-r--r--tools/glib-errors-enum-header-gen.py75
-rwxr-xr-x[-rw-r--r--]tools/glib-ginterface-gen.py172
-rwxr-xr-x[-rw-r--r--]tools/glib-gtypes-generator.py205
-rwxr-xr-x[-rw-r--r--]tools/glib-interfaces-gen.py60
-rwxr-xr-x[-rw-r--r--]tools/glib-signals-marshal-gen.py0
-rw-r--r--tools/gobject-foo.py81
-rw-r--r--tools/identity.xsl7
-rw-r--r--tools/lcov.am5
-rwxr-xr-x[-rw-r--r--]tools/libglibcodegen.py5
-rwxr-xr-x[-rw-r--r--]tools/libtpcodegen.py36
-rwxr-xr-xtools/log-strip.py35
-rw-r--r--tools/make-version-script.py205
-rw-r--r--tools/telepathy-glib-env.in9
-rw-r--r--tools/telepathy.am15
-rw-r--r--tools/with-session-bus.sh84
-rwxr-xr-xtools/xincludator.py39
24 files changed, 451 insertions, 1994 deletions
diff --git a/tools/.gitignore b/tools/.gitignore
deleted file mode 100644
index 2578e98..0000000
--- a/tools/.gitignore
+++ /dev/null
@@ -1,3 +0,0 @@
-_gen
-extensions.html
-telepathy-glib-env
diff --git a/tools/Makefile.am b/tools/Makefile.am
index 8662b44..71bede7 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -1,13 +1,3 @@
-include $(top_srcdir)/tools/shave.mk
-
-abs_top_builddir = @abs_top_builddir@
-
-noinst_SCRIPTS = telepathy-glib-env
-
-telepathy-glib-env: telepathy-glib-env.in Makefile
- sed -e 's![@]abs_top_builddir[@]!$(abs_top_builddir)!' $< > $@
- chmod +x $@
-
EXTRA_DIST = \
c-constants-gen.py \
check-coding-style.mk \
@@ -15,53 +5,34 @@ EXTRA_DIST = \
check-misc.sh \
check-whitespace.sh \
doc-generator.xsl \
- flymake.mk \
- glib-client-gen.py \
- glib-client-marshaller-gen.py \
- glib-errors-enum-body-gen.py \
- glib-errors-enum-header-gen.py \
glib-ginterface-gen.py \
glib-gtypes-generator.py \
glib-interfaces-gen.py \
glib-signals-marshal-gen.py \
- gobject-foo.py \
- identity.xsl \
lcov.am \
- libtpcodegen.py \
libglibcodegen.py \
- make-version-script.py \
+ libtpcodegen.py \
telepathy.am \
- telepathy-glib-env.in \
- with-session-bus.sh
+ xincludator.py
-CLEANFILES = libtpcodegen.pyc libtpcodegen.pyo libglibcodegen.pyc libglibcodegen.pyo $(noinst_SCRIPTS)
+CLEANFILES = *.pyc *.pyo
all: $(EXTRA_DIST)
libglibcodegen.py: libtpcodegen.py
- $(QUIET_GEN)touch $@
-c-constants-gen.py: libglibcodegen.py
- $(QUIET_GEN)touch $@
-glib-client-marshaller-gen.py: libglibcodegen.py
- $(QUIET_GEN)touch $@
-glib-errors-enum-body-gen.py: libglibcodegen.py
- $(QUIET_GEN)touch $@
-glib-errors-enum-header-gen.py: libglibcodegen.py
- $(QUIET_GEN)touch $@
-glib-ginterface-gen.py: libglibcodegen.py
- $(QUIET_GEN)touch $@
-glib-gtypes-generator.py: libglibcodegen.py
- $(QUIET_GEN)touch $@
-glib-interfaces-gen.py: libglibcodegen.py
- $(QUIET_GEN)touch $@
-glib-signals-marshal-gen.py: libglibcodegen.py
- $(QUIET_GEN)touch $@
+ test -e $<
+ $(AM_V_GEN)touch $@
+
+glib-ginterface-gen.py glib-gtypes-generator.py glib-interfaces-gen.py \
+glib-signals-marshal-gen.py c-constants-gen.py: %: libglibcodegen.py
+ test -e $<
+ $(AM_V_GEN)touch $@
-TELEPATHY_SPEC_SRCDIR = $(top_srcdir)/../telepathy-spec
-maintainer-update-from-telepathy-spec:
+TELEPATHY_GLIB_SRCDIR = $(top_srcdir)/../telepathy-glib
+maintainer-update-from-telepathy-glib:
set -e && cd $(srcdir) && \
for x in $(EXTRA_DIST); do \
- if test -f $(TELEPATHY_SPEC_SRCDIR)/tools/$$x; then \
- cp $(TELEPATHY_SPEC_SRCDIR)/tools/$$x $$x; \
+ if test -f $(TELEPATHY_GLIB_SRCDIR)/tools/$$x; then \
+ cp $(TELEPATHY_GLIB_SRCDIR)/tools/$$x $$x; \
fi; \
done
diff --git a/tools/c-constants-gen.py b/tools/c-constants-gen.py
index f338257..8969ffd 100644..100755
--- a/tools/c-constants-gen.py
+++ b/tools/c-constants-gen.py
@@ -3,7 +3,7 @@
from sys import argv, stdout, stderr
import xml.dom.minidom
-from libglibcodegen import NS_TP, camelcase_to_upper, get_docstring, \
+from libglibcodegen import NS_TP, get_docstring, \
get_descendant_text, get_by_path
class Generator(object):
@@ -16,21 +16,24 @@ class Generator(object):
self.do_body()
self.do_footer()
+ def write(self, code):
+ stdout.write(code.encode('utf-8'))
+
# Header
def do_header(self):
- stdout.write('/* Generated from ')
- stdout.write(get_descendant_text(get_by_path(self.spec, 'title')))
+ self.write('/* Generated from ')
+ self.write(get_descendant_text(get_by_path(self.spec, 'title')))
version = get_by_path(self.spec, "version")
if version:
- stdout.write(', version ' + get_descendant_text(version))
- stdout.write('\n\n')
+ self.write(', version ' + get_descendant_text(version))
+ self.write('\n\n')
for copyright in get_by_path(self.spec, 'copyright'):
- stdout.write(get_descendant_text(copyright))
- stdout.write('\n')
- stdout.write(get_descendant_text(get_by_path(self.spec, 'license')))
- stdout.write('\n')
- stdout.write(get_descendant_text(get_by_path(self.spec, 'docstring')))
- stdout.write("""
+ self.write(get_descendant_text(copyright))
+ self.write('\n')
+ self.write(get_descendant_text(get_by_path(self.spec, 'license')))
+ self.write('\n')
+ self.write(get_descendant_text(get_by_path(self.spec, 'docstring')))
+ self.write("""
*/
#ifdef __cplusplus
@@ -51,28 +54,28 @@ extern "C" {
value_prefix = flags.getAttribute('singular') or \
flags.getAttribute('value-prefix') or \
flags.getAttribute('name')
- stdout.write("""\
+ self.write("""\
/**
*
%s:
""" % (self.prefix + name).replace('_', ''))
for flag in get_by_path(flags, 'flag'):
self.do_gtkdoc(flag, value_prefix)
- stdout.write(' *\n')
+ self.write(' *\n')
docstrings = get_by_path(flags, 'docstring')
if docstrings:
- stdout.write("""\
+ self.write("""\
* <![CDATA[%s]]>
*
""" % get_descendant_text(docstrings).replace('\n', ' '))
- stdout.write("""\
+ self.write("""\
* Bitfield/set of flags generated from the Telepathy specification.
*/
typedef enum {
""")
for flag in get_by_path(flags, 'flag'):
self.do_val(flag, value_prefix)
- stdout.write("""\
+ self.write("""\
} %s;
""" % (self.prefix + name).replace('_', ''))
@@ -84,7 +87,7 @@ typedef enum {
enum.getAttribute('name')
name_plural = enum.getAttribute('plural') or \
enum.getAttribute('name') + 's'
- stdout.write("""\
+ self.write("""\
/**
*
%s:
@@ -92,21 +95,21 @@ typedef enum {
vals = get_by_path(enum, 'enumvalue')
for val in vals:
self.do_gtkdoc(val, value_prefix)
- stdout.write(' *\n')
+ self.write(' *\n')
docstrings = get_by_path(enum, 'docstring')
if docstrings:
- stdout.write("""\
+ self.write("""\
* <![CDATA[%s]]>
*
""" % get_descendant_text(docstrings).replace('\n', ' '))
- stdout.write("""\
+ self.write("""\
* Bitfield/set of flags generated from the Telepathy specification.
*/
typedef enum {
""")
for val in vals:
self.do_val(val, value_prefix)
- stdout.write("""\
+ self.write("""\
} %(mixed-name)s;
/**
@@ -127,20 +130,20 @@ typedef enum {
(suffix or name)).upper()
assert not (name and suffix) or name == suffix, \
'Flag/enumvalue name %s != suffix %s' % (name, suffix)
- stdout.write(' %s = %s,\n' % (use_name, val.getAttribute('value')))
+ self.write(' %s = %s,\n' % (use_name, val.getAttribute('value')))
def do_gtkdoc(self, node, value_prefix):
- stdout.write(' * @')
- stdout.write((self.prefix + value_prefix + '_' +
+ self.write(' * @')
+ self.write((self.prefix + value_prefix + '_' +
node.getAttribute('suffix')).upper())
- stdout.write(': <![CDATA[')
+ self.write(': <![CDATA[')
docstring = get_by_path(node, 'docstring')
- stdout.write(get_descendant_text(docstring).replace('\n', ' '))
- stdout.write(']]>\n')
+ self.write(get_descendant_text(docstring).replace('\n', ' '))
+ self.write(']]>\n')
# Footer
def do_footer(self):
- stdout.write("""
+ self.write("""
#ifdef __cplusplus
}
#endif
diff --git a/tools/check-coding-style.mk b/tools/check-coding-style.mk
index 3fc92fc..1c0a60f 100644
--- a/tools/check-coding-style.mk
+++ b/tools/check-coding-style.mk
@@ -3,12 +3,12 @@ check-coding-style:
if test -n "$(check_misc_sources)"; then \
tools_dir=$(top_srcdir)/tools \
sh $(top_srcdir)/tools/check-misc.sh \
- $(check_misc_sources) || fail=1; \
+ $(addprefix $(srcdir)/,$(check_misc_sources)) || fail=1; \
fi; \
if test -n "$(check_c_sources)"; then \
tools_dir=$(top_srcdir)/tools \
sh $(top_srcdir)/tools/check-c-style.sh \
- $(check_c_sources) || fail=1; \
+ $(addprefix $(srcdir)/,$(check_c_sources)) || fail=1; \
fi;\
if test yes = "$(ENABLE_CODING_STYLE_CHECKS)"; then \
exit "$$fail";\
diff --git a/tools/check-whitespace.sh b/tools/check-whitespace.sh
index 489322f..5348331 100644
--- a/tools/check-whitespace.sh
+++ b/tools/check-whitespace.sh
@@ -8,17 +8,10 @@ then
fail=1
fi
-if grep -n ' $' "$@"
+if grep -n ' ' "$@"
then
- echo "^^^ The above files contain unwanted trailing tabs"
+ echo "^^^ The above files contain tabs"
fail=1
fi
-# TODO: enable tab checking once all Empathy switched to TP coding style
-#if grep -n ' ' "$@"
-#then
-# echo "^^^ The above files contain tabs"
-# fail=1
-#fi
-
exit $fail
diff --git a/tools/glib-client-gen.py b/tools/glib-client-gen.py
deleted file mode 100644
index 701fcaf..0000000
--- a/tools/glib-client-gen.py
+++ /dev/null
@@ -1,1157 +0,0 @@
-#!/usr/bin/python
-
-# glib-client-gen.py: "I Can't Believe It's Not dbus-binding-tool"
-#
-# Generate GLib client wrappers from the Telepathy specification.
-# The master copy of this program is in the telepathy-glib repository -
-# please make any changes there.
-#
-# Copyright (C) 2006-2008 Collabora Ltd. <http://www.collabora.co.uk/>
-#
-# 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 getopt import gnu_getopt
-
-from libglibcodegen import Signature, type_to_gtype, cmp_by_name, \
- camelcase_to_lower, get_docstring, xml_escape
-
-
-NS_TP = "http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0"
-
-class Generator(object):
-
- def __init__(self, dom, prefix, basename, opts):
- self.dom = dom
- self.__header = []
- self.__body = []
-
- self.prefix_lc = prefix.lower()
- self.prefix_uc = prefix.upper()
- self.prefix_mc = prefix.replace('_', '')
- self.basename = basename
- self.group = opts.get('--group', None)
- self.iface_quark_prefix = opts.get('--iface-quark-prefix', None)
- self.tp_proxy_api = tuple(map(int,
- opts.get('--tp-proxy-api', '0').split('.')))
- self.proxy_cls = opts.get('--subclass', 'TpProxy') + ' *'
- self.proxy_arg = opts.get('--subclass', 'void') + ' *'
- self.proxy_assert = opts.get('--subclass-assert', 'TP_IS_PROXY')
- self.proxy_doc = ('A #%s or subclass'
- % opts.get('--subclass', 'TpProxy'))
- if self.proxy_arg == 'void *':
- self.proxy_arg = 'gpointer '
-
- def h(self, s):
- if isinstance(s, unicode):
- s = s.encode('utf-8')
- self.__header.append(s)
-
- def b(self, s):
- if isinstance(s, unicode):
- s = s.encode('utf-8')
- self.__body.append(s)
-
- def get_iface_quark(self):
- assert self.iface_dbus is not None
- assert self.iface_uc is not None
- if self.iface_quark_prefix is None:
- return 'g_quark_from_static_string (\"%s\")' % self.iface_dbus
- else:
- return '%s_%s' % (self.iface_quark_prefix, self.iface_uc)
-
- def do_signal(self, iface, signal):
- iface_lc = iface.lower()
-
- member = signal.getAttribute('name')
- member_lc = camelcase_to_lower(member)
- member_uc = member_lc.upper()
-
- arg_count = 0
- args = []
- out_args = []
-
- for arg in signal.getElementsByTagName('arg'):
- name = arg.getAttribute('name')
- type = arg.getAttribute('type')
- tp_type = arg.getAttribute('tp:type')
-
- if not name:
- name = 'arg%u' % arg_count
- arg_count += 1
- else:
- name = 'arg_%s' % name
-
- info = type_to_gtype(type)
- args.append((name, info, tp_type, arg))
-
- callback_name = ('%s_%s_signal_callback_%s'
- % (self.prefix_lc, iface_lc, member_lc))
- collect_name = ('_%s_%s_collect_args_of_%s'
- % (self.prefix_lc, iface_lc, member_lc))
- invoke_name = ('_%s_%s_invoke_callback_for_%s'
- % (self.prefix_lc, iface_lc, member_lc))
-
- # Example:
- #
- # typedef void (*tp_cli_connection_signal_callback_new_channel)
- # (TpConnection *proxy, const gchar *arg_object_path,
- # const gchar *arg_channel_type, guint arg_handle_type,
- # guint arg_handle, gboolean arg_suppress_handler,
- # gpointer user_data, GObject *weak_object);
-
- self.b('/**')
- self.b(' * %s:' % callback_name)
- self.b(' * @proxy: The proxy on which %s_%s_connect_to_%s ()'
- % (self.prefix_lc, iface_lc, member_lc))
- self.b(' * was called')
-
- for arg in args:
- name, info, tp_type, elt = arg
- ctype, gtype, marshaller, pointer = info
-
- self.b(' * @%s: %s' % (name,
- xml_escape(get_docstring(elt) or '(Undocumented)')))
-
- self.b(' * @user_data: User-supplied data')
- self.b(' * @weak_object: User-supplied weakly referenced object')
- self.b(' *')
- self.b(' * Represents the signature of a callback for the signal %s.'
- % member)
- self.b(' */')
- self.h('typedef void (*%s) (%sproxy,'
- % (callback_name, self.proxy_cls))
-
- for arg in args:
- name, info, tp_type, elt = arg
- ctype, gtype, marshaller, pointer = info
-
- const = pointer and 'const ' or ''
-
- self.h(' %s%s%s,' % (const, ctype, name))
-
- self.h(' gpointer user_data, GObject *weak_object);')
-
- if args:
- self.b('static void')
- self.b('%s (DBusGProxy *proxy G_GNUC_UNUSED,' % collect_name)
-
- for arg in args:
- name, info, tp_type, elt = arg
- ctype, gtype, marshaller, pointer = info
-
- const = pointer and 'const ' or ''
-
- self.b(' %s%s%s,' % (const, ctype, name))
-
- self.b(' TpProxySignalConnection *sc)')
- self.b('{')
- self.b(' GValueArray *args = g_value_array_new (%d);' % len(args))
- self.b(' GValue blank = { 0 };')
- self.b(' guint i;')
- self.b('')
- self.b(' g_value_init (&blank, G_TYPE_INT);')
- self.b('')
- self.b(' for (i = 0; i < %d; i++)' % len(args))
- self.b(' g_value_array_append (args, &blank);')
- self.b('')
-
- for i, arg in enumerate(args):
- name, info, tp_type, elt = arg
- ctype, gtype, marshaller, pointer = info
-
- self.b(' g_value_unset (args->values + %d);' % i)
- self.b(' g_value_init (args->values + %d, %s);' % (i, gtype))
-
- if gtype == 'G_TYPE_STRING':
- self.b(' g_value_set_string (args->values + %d, %s);'
- % (i, name))
- elif marshaller == 'BOXED':
- self.b(' g_value_set_boxed (args->values + %d, %s);'
- % (i, name))
- elif gtype == 'G_TYPE_UCHAR':
- self.b(' g_value_set_uchar (args->values + %d, %s);'
- % (i, name))
- elif gtype == 'G_TYPE_BOOLEAN':
- self.b(' g_value_set_boolean (args->values + %d, %s);'
- % (i, name))
- elif gtype == 'G_TYPE_INT':
- self.b(' g_value_set_int (args->values + %d, %s);'
- % (i, name))
- elif gtype == 'G_TYPE_UINT':
- self.b(' g_value_set_uint (args->values + %d, %s);'
- % (i, name))
- elif gtype == 'G_TYPE_INT64':
- self.b(' g_value_set_int (args->values + %d, %s);'
- % (i, name))
- elif gtype == 'G_TYPE_UINT64':
- self.b(' g_value_set_uint64 (args->values + %d, %s);'
- % (i, name))
- elif gtype == 'G_TYPE_DOUBLE':
- self.b(' g_value_set_double (args->values + %d, %s);'
- % (i, name))
- else:
- assert False, ("Don't know how to put %s in a GValue"
- % gtype)
- self.b('')
-
- self.b(' tp_proxy_signal_connection_v0_take_results (sc, args);')
- self.b('}')
-
- self.b('static void')
- self.b('%s (TpProxy *tpproxy,' % invoke_name)
- self.b(' GError *error G_GNUC_UNUSED,')
- self.b(' GValueArray *args,')
- self.b(' GCallback generic_callback,')
- self.b(' gpointer user_data,')
- self.b(' GObject *weak_object)')
- self.b('{')
- self.b(' %s callback =' % callback_name)
- self.b(' (%s) generic_callback;' % callback_name)
- self.b('')
- self.b(' if (callback != NULL)')
- self.b(' callback (g_object_ref (tpproxy),')
-
- # FIXME: factor out into a function
- for i, arg in enumerate(args):
- name, info, tp_type, elt = arg
- ctype, gtype, marshaller, pointer = info
-
- if marshaller == 'BOXED':
- self.b(' g_value_get_boxed (args->values + %d),' % i)
- elif gtype == 'G_TYPE_STRING':
- self.b(' g_value_get_string (args->values + %d),' % i)
- elif gtype == 'G_TYPE_UCHAR':
- self.b(' g_value_get_uchar (args->values + %d),' % i)
- elif gtype == 'G_TYPE_BOOLEAN':
- self.b(' g_value_get_boolean (args->values + %d),' % i)
- elif gtype == 'G_TYPE_UINT':
- self.b(' g_value_get_uint (args->values + %d),' % i)
- elif gtype == 'G_TYPE_INT':
- self.b(' g_value_get_int (args->values + %d),' % i)
- elif gtype == 'G_TYPE_UINT64':
- self.b(' g_value_get_uint64 (args->values + %d),' % i)
- elif gtype == 'G_TYPE_INT64':
- self.b(' g_value_get_int64 (args->values + %d),' % i)
- elif gtype == 'G_TYPE_DOUBLE':
- self.b(' g_value_get_double (args->values + %d),' % i)
- else:
- assert False, "Don't know how to get %s from a GValue" % gtype
-
- self.b(' user_data,')
- self.b(' weak_object);')
- self.b('')
-
- if len(args) > 0:
- self.b(' g_value_array_free (args);')
- else:
- self.b(' if (args != NULL)')
- self.b(' g_value_array_free (args);')
- self.b('')
-
- self.b(' g_object_unref (tpproxy);')
- self.b('}')
-
- # Example:
- #
- # TpProxySignalConnection *
- # tp_cli_connection_connect_to_new_channel
- # (TpConnection *proxy,
- # tp_cli_connection_signal_callback_new_channel callback,
- # gpointer user_data,
- # GDestroyNotify destroy);
- #
- # destroy is invoked when the signal becomes disconnected. This
- # is either because the signal has been disconnected explicitly
- # by the user, because the TpProxy has become invalid and
- # emitted the 'invalidated' signal, or because the weakly referenced
- # object has gone away.
-
- self.b('/**')
- self.b(' * %s_%s_connect_to_%s:'
- % (self.prefix_lc, iface_lc, member_lc))
- self.b(' * @proxy: %s' % self.proxy_doc)
- self.b(' * @callback: Callback to be called when the signal is')
- self.b(' * received')
- self.b(' * @user_data: User-supplied data for the callback')
- self.b(' * @destroy: Destructor for the user-supplied data, which')
- self.b(' * will be called when this signal is disconnected, or')
- self.b(' * before this function returns %NULL')
- self.b(' * @weak_object: A #GObject which will be weakly referenced; ')
- self.b(' * if it is destroyed, this callback will automatically be')
- self.b(' * disconnected')
- self.b(' * @error: If not %NULL, used to raise an error if %NULL is')
- self.b(' * returned')
- self.b(' *')
- self.b(' * Connect a handler to the signal %s.' % member)
- self.b(' *')
- self.b(' * %s' % xml_escape(get_docstring(signal) or '(Undocumented)'))
- self.b(' *')
- self.b(' * Returns: a #TpProxySignalConnection containing all of the')
- self.b(' * above, which can be used to disconnect the signal; or')
- self.b(' * %NULL if the proxy does not have the desired interface')
- self.b(' * or has become invalid.')
- self.b(' */')
- self.h('TpProxySignalConnection *%s_%s_connect_to_%s (%sproxy,'
- % (self.prefix_lc, iface_lc, member_lc, self.proxy_arg))
- self.h(' %s callback,' % callback_name)
- self.h(' gpointer user_data,')
- self.h(' GDestroyNotify destroy,')
- self.h(' GObject *weak_object,')
- self.h(' GError **error);')
-
- self.b('TpProxySignalConnection *')
- self.b('%s_%s_connect_to_%s (%sproxy,'
- % (self.prefix_lc, iface_lc, member_lc, self.proxy_arg))
- self.b(' %s callback,' % callback_name)
- self.b(' gpointer user_data,')
- self.b(' GDestroyNotify destroy,')
- self.b(' GObject *weak_object,')
- self.b(' GError **error)')
- self.b('{')
- self.b(' GType expected_types[%d] = {' % (len(args) + 1))
-
- for arg in args:
- name, info, tp_type, elt = arg
- ctype, gtype, marshaller, pointer = info
-
- self.b(' %s,' % gtype)
-
- self.b(' G_TYPE_INVALID };')
- self.b('')
- self.b(' g_return_val_if_fail (%s (proxy), NULL);'
- % self.proxy_assert)
- self.b(' g_return_val_if_fail (callback != NULL, NULL);')
- self.b('')
- self.b(' return tp_proxy_signal_connection_v0_new ((TpProxy *) proxy,')
- self.b(' %s, \"%s\",' % (self.get_iface_quark(), member))
- self.b(' expected_types,')
-
- if args:
- self.b(' G_CALLBACK (%s),' % collect_name)
- else:
- self.b(' NULL, /* no args => no collector function */')
-
- self.b(' %s,' % invoke_name)
- self.b(' G_CALLBACK (callback), user_data, destroy,')
- self.b(' weak_object, error);')
- self.b('}')
- self.b('')
-
- self.h('')
-
- def do_method(self, iface, method):
- iface_lc = iface.lower()
-
- member = method.getAttribute('name')
- member_lc = camelcase_to_lower(member)
- member_uc = member_lc.upper()
-
- in_count = 0
- ret_count = 0
- in_args = []
- out_args = []
-
- for arg in method.getElementsByTagName('arg'):
- name = arg.getAttribute('name')
- direction = arg.getAttribute('direction')
- type = arg.getAttribute('type')
- tp_type = arg.getAttribute('tp:type')
-
- if direction != 'out':
- if not name:
- name = 'in%u' % in_count
- in_count += 1
- else:
- name = 'in_%s' % name
- else:
- if not name:
- name = 'out%u' % ret_count
- ret_count += 1
- else:
- name = 'out_%s' % name
-
- info = type_to_gtype(type)
- if direction != 'out':
- in_args.append((name, info, tp_type, arg))
- else:
- out_args.append((name, info, tp_type, arg))
-
- # Async reply callback type
-
- # Example:
- # void (*tp_cli_properties_interface_callback_for_get_properties)
- # (TpProxy *proxy,
- # const GPtrArray *out0,
- # const GError *error,
- # gpointer user_data,
- # GObject *weak_object);
-
- self.b('/**')
- self.b(' * %s_%s_callback_for_%s:'
- % (self.prefix_lc, iface_lc, member_lc))
- self.b(' * @proxy: the proxy on which the call was made')
-
- for arg in out_args:
- name, info, tp_type, elt = arg
- ctype, gtype, marshaller, pointer = info
-
- self.b(' * @%s: Used to return an \'out\' argument if @error is '
- '%%NULL: %s'
- % (name, xml_escape(get_docstring(elt) or '(Undocumented)')))
-
- self.b(' * @error: %NULL on success, or an error on failure')
- self.b(' * @user_data: user-supplied data')
- self.b(' * @weak_object: user-supplied object')
- self.b(' *')
- self.b(' * Signature of the callback called when a %s method call'
- % member)
- self.b(' * succeeds or fails.')
- self.b(' */')
-
- callback_name = '%s_%s_callback_for_%s' % (self.prefix_lc, iface_lc,
- member_lc)
-
- self.h('typedef void (*%s) (%sproxy,'
- % (callback_name, self.proxy_cls))
-
- for arg in out_args:
- name, info, tp_type, elt = arg
- ctype, gtype, marshaller, pointer = info
- const = pointer and 'const ' or ''
-
- self.h(' %s%s%s,' % (const, ctype, name))
-
- self.h(' const GError *error, gpointer user_data,')
- self.h(' GObject *weak_object);')
- self.h('')
-
- # Async callback implementation
-
- invoke_callback = '_%s_%s_invoke_callback_%s' % (self.prefix_lc,
- iface_lc,
- member_lc)
-
- collect_callback = '_%s_%s_collect_callback_%s' % (self.prefix_lc,
- iface_lc,
- member_lc)
-
- # The callback called by dbus-glib; this ends the call and collects
- # the results into a GValueArray.
- self.b('static void')
- self.b('%s (DBusGProxy *proxy,' % collect_callback)
- self.b(' DBusGProxyCall *call,')
- self.b(' gpointer user_data)')
- self.b('{')
- self.b(' GError *error = NULL;')
-
- if len(out_args) > 0:
- self.b(' GValueArray *args;')
- self.b(' GValue blank = { 0 };')
- self.b(' guint i;')
-
- for arg in out_args:
- name, info, tp_type, elt = arg
- ctype, gtype, marshaller, pointer = info
-
- # "We handle variants specially; the caller is expected to
- # have already allocated storage for them". Thanks,
- # dbus-glib...
- if gtype == 'G_TYPE_VALUE':
- self.b(' GValue *%s = g_new0 (GValue, 1);' % name)
- else:
- self.b(' %s%s;' % (ctype, name))
-
- self.b('')
- self.b(' dbus_g_proxy_end_call (proxy, call, &error,')
-
- for arg in out_args:
- name, info, tp_type, elt = arg
- ctype, gtype, marshaller, pointer = info
-
- if gtype == 'G_TYPE_VALUE':
- self.b(' %s, %s,' % (gtype, name))
- else:
- self.b(' %s, &%s,' % (gtype, name))
-
- self.b(' G_TYPE_INVALID);')
-
- if len(out_args) == 0:
- self.b(' tp_proxy_pending_call_v0_take_results (user_data, error,'
- 'NULL);')
- else:
- self.b('')
- self.b(' if (error != NULL)')
- self.b(' {')
- self.b(' tp_proxy_pending_call_v0_take_results (user_data, error,')
- self.b(' NULL);')
-
- for arg in out_args:
- name, info, tp_type, elt = arg
- ctype, gtype, marshaller, pointer = info
- if gtype == 'G_TYPE_VALUE':
- self.b(' g_free (%s);' % name)
-
- self.b(' return;')
- self.b(' }')
- self.b('')
- self.b(' args = g_value_array_new (%d);' % len(out_args))
- self.b(' g_value_init (&blank, G_TYPE_INT);')
- self.b('')
- self.b(' for (i = 0; i < %d; i++)' % len(out_args))
- self.b(' g_value_array_append (args, &blank);')
-
- for i, arg in enumerate(out_args):
- name, info, tp_type, elt = arg
- ctype, gtype, marshaller, pointer = info
-
- self.b('')
- self.b(' g_value_unset (args->values + %d);' % i)
- self.b(' g_value_init (args->values + %d, %s);' % (i, gtype))
-
- if gtype == 'G_TYPE_STRING':
- self.b(' g_value_take_string (args->values + %d, %s);'
- % (i, name))
- elif marshaller == 'BOXED':
- self.b(' g_value_take_boxed (args->values + %d, %s);'
- % (i, name))
- elif gtype == 'G_TYPE_UCHAR':
- self.b(' g_value_set_uchar (args->values + %d, %s);'
- % (i, name))
- elif gtype == 'G_TYPE_BOOLEAN':
- self.b(' g_value_set_boolean (args->values + %d, %s);'
- % (i, name))
- elif gtype == 'G_TYPE_INT':
- self.b(' g_value_set_int (args->values + %d, %s);'
- % (i, name))
- elif gtype == 'G_TYPE_UINT':
- self.b(' g_value_set_uint (args->values + %d, %s);'
- % (i, name))
- elif gtype == 'G_TYPE_INT64':
- self.b(' g_value_set_int (args->values + %d, %s);'
- % (i, name))
- elif gtype == 'G_TYPE_UINT64':
- self.b(' g_value_set_uint (args->values + %d, %s);'
- % (i, name))
- elif gtype == 'G_TYPE_DOUBLE':
- self.b(' g_value_set_double (args->values + %d, %s);'
- % (i, name))
- else:
- assert False, ("Don't know how to put %s in a GValue"
- % gtype)
-
- self.b(' tp_proxy_pending_call_v0_take_results (user_data, '
- 'NULL, args);')
-
- self.b('}')
-
- self.b('static void')
- self.b('%s (TpProxy *self,' % invoke_callback)
- self.b(' GError *error,')
- self.b(' GValueArray *args,')
- self.b(' GCallback generic_callback,')
- self.b(' gpointer user_data,')
- self.b(' GObject *weak_object)')
- self.b('{')
- self.b(' %s callback = (%s) generic_callback;'
- % (callback_name, callback_name))
- self.b('')
- self.b(' if (error != NULL)')
- self.b(' {')
- self.b(' callback ((%s) self,' % self.proxy_cls)
-
- for arg in out_args:
- name, info, tp_type, elt = arg
- ctype, gtype, marshaller, pointer = info
-
- if marshaller == 'BOXED' or pointer:
- self.b(' NULL,')
- elif gtype == 'G_TYPE_DOUBLE':
- self.b(' 0.0,')
- else:
- self.b(' 0,')
-
- self.b(' error, user_data, weak_object);')
- self.b(' g_error_free (error);')
- self.b(' return;')
- self.b(' }')
-
- self.b(' callback ((%s) self,' % self.proxy_cls)
-
- # FIXME: factor out into a function
- for i, arg in enumerate(out_args):
- name, info, tp_type, elt = arg
- ctype, gtype, marshaller, pointer = info
-
- if marshaller == 'BOXED':
- self.b(' g_value_get_boxed (args->values + %d),' % i)
- elif gtype == 'G_TYPE_STRING':
- self.b(' g_value_get_string (args->values + %d),' % i)
- elif gtype == 'G_TYPE_UCHAR':
- self.b(' g_value_get_uchar (args->values + %d),' % i)
- elif gtype == 'G_TYPE_BOOLEAN':
- self.b(' g_value_get_boolean (args->values + %d),' % i)
- elif gtype == 'G_TYPE_UINT':
- self.b(' g_value_get_uint (args->values + %d),' % i)
- elif gtype == 'G_TYPE_INT':
- self.b(' g_value_get_int (args->values + %d),' % i)
- elif gtype == 'G_TYPE_UINT64':
- self.b(' g_value_get_uint64 (args->values + %d),' % i)
- elif gtype == 'G_TYPE_INT64':
- self.b(' g_value_get_int64 (args->values + %d),' % i)
- elif gtype == 'G_TYPE_DOUBLE':
- self.b(' g_value_get_double (args->values + %d),' % i)
- else:
- assert False, "Don't know how to get %s from a GValue" % gtype
-
- self.b(' error, user_data, weak_object);')
- self.b('')
-
- if len(out_args) > 0:
- self.b(' g_value_array_free (args);')
- else:
- self.b(' if (args != NULL)')
- self.b(' g_value_array_free (args);')
-
- self.b('}')
- self.b('')
-
- # Async stub
-
- # Example:
- # TpProxyPendingCall *
- # tp_cli_properties_interface_call_get_properties
- # (gpointer proxy,
- # gint timeout_ms,
- # const GArray *in_properties,
- # tp_cli_properties_interface_callback_for_get_properties callback,
- # gpointer user_data,
- # GDestroyNotify *destructor);
-
- self.h('TpProxyPendingCall *%s_%s_call_%s (%sproxy,'
- % (self.prefix_lc, iface_lc, member_lc, self.proxy_arg))
- self.h(' gint timeout_ms,')
-
- self.b('/**')
- self.b(' * %s_%s_call_%s:'
- % (self.prefix_lc, iface_lc, member_lc))
- self.b(' * @proxy: the #TpProxy')
- self.b(' * @timeout_ms: the timeout in milliseconds, or -1 to use the')
- self.b(' * default')
-
- for arg in in_args:
- name, info, tp_type, elt = arg
- ctype, gtype, marshaller, pointer = info
-
- self.b(' * @%s: Used to pass an \'in\' argument: %s'
- % (name, xml_escape(get_docstring(elt) or '(Undocumented)')))
-
- self.b(' * @callback: called when the method call succeeds or fails;')
- self.b(' * may be %NULL to make a "fire and forget" call with no ')
- self.b(' * reply tracking')
- self.b(' * @user_data: user-supplied data passed to the callback;')
- self.b(' * must be %NULL if @callback is %NULL')
- self.b(' * @destroy: called with the user_data as argument, after the')
- self.b(' * call has succeeded, failed or been cancelled;')
- self.b(' * must be %NULL if @callback is %NULL')
- self.b(' * @weak_object: If not %NULL, a #GObject which will be ')
- self.b(' * weakly referenced; if it is destroyed, this call ')
- self.b(' * will automatically be cancelled. Must be %NULL if ')
- self.b(' * @callback is %NULL')
- self.b(' *')
- self.b(' * Start a %s method call.' % member)
- self.b(' *')
- self.b(' * %s' % xml_escape(get_docstring(method) or '(Undocumented)'))
- self.b(' *')
- self.b(' * Returns: a #TpProxyPendingCall representing the call in')
- self.b(' * progress. It is borrowed from the object, and will become')
- self.b(' * invalid when the callback is called, the call is')
- self.b(' * cancelled or the #TpProxy becomes invalid.')
- self.b(' */')
- self.b('TpProxyPendingCall *\n%s_%s_call_%s (%sproxy,'
- % (self.prefix_lc, iface_lc, member_lc, self.proxy_arg))
- self.b(' gint timeout_ms,')
-
- for arg in in_args:
- name, info, tp_type, elt = arg
- ctype, gtype, marshaller, pointer = info
-
- const = pointer and 'const ' or ''
-
- self.h(' %s%s%s,' % (const, ctype, name))
- self.b(' %s%s%s,' % (const, ctype, name))
-
- self.h(' %s callback,' % callback_name)
- self.h(' gpointer user_data,')
- self.h(' GDestroyNotify destroy,')
- self.h(' GObject *weak_object);')
- self.h('')
-
- self.b(' %s callback,' % callback_name)
- self.b(' gpointer user_data,')
- self.b(' GDestroyNotify destroy,')
- self.b(' GObject *weak_object)')
- self.b('{')
- self.b(' GError *error = NULL;')
- self.b(' GQuark interface = %s;' % self.get_iface_quark())
- self.b(' DBusGProxy *iface;')
- self.b('')
- self.b(' g_return_val_if_fail (%s (proxy), NULL);'
- % self.proxy_assert)
- self.b(' g_return_val_if_fail (callback != NULL || '
- 'user_data == NULL, NULL);')
- self.b(' g_return_val_if_fail (callback != NULL || '
- 'destroy == NULL, NULL);')
- self.b(' g_return_val_if_fail (callback != NULL || '
- 'weak_object == NULL, NULL);')
- self.b('')
- self.b(' iface = tp_proxy_borrow_interface_by_id (')
- self.b(' (TpProxy *) proxy,')
- self.b(' interface, &error);')
- self.b('')
- self.b(' if (iface == NULL)')
- self.b(' {')
- self.b(' if (callback != NULL)')
- self.b(' callback (proxy,')
-
- for arg in out_args:
- name, info, tp_type, elt = arg
- ctype, gtype, marshaller, pointer = info
-
- if pointer:
- self.b(' NULL,')
- else:
- self.b(' 0,')
-
- self.b(' error, user_data, weak_object);')
- self.b('')
- self.b(' if (destroy != NULL)')
- self.b(' destroy (user_data);')
- self.b('')
- self.b(' g_error_free (error);')
- self.b(' return NULL;')
- self.b(' }')
- self.b('')
- self.b(' if (callback == NULL)')
- self.b(' {')
- self.b(' dbus_g_proxy_call_no_reply (iface, "%s",' % member)
-
- for arg in in_args:
- name, info, tp_type, elt = arg
- ctype, gtype, marshaller, pointer = info
-
- const = pointer and 'const ' or ''
-
- self.b(' %s, %s,' % (gtype, name))
-
- self.b(' G_TYPE_INVALID);')
- self.b(' return NULL;')
- self.b(' }')
- self.b(' else')
- self.b(' {')
- self.b(' TpProxyPendingCall *data;')
- self.b('')
- self.b(' data = tp_proxy_pending_call_v0_new ((TpProxy *) proxy,')
- self.b(' interface, "%s", iface,' % member)
- self.b(' %s,' % invoke_callback)
- self.b(' G_CALLBACK (callback), user_data, destroy,')
- self.b(' weak_object, FALSE);')
- self.b(' tp_proxy_pending_call_v0_take_pending_call (data,')
- self.b(' dbus_g_proxy_begin_call_with_timeout (iface,')
- self.b(' "%s",' % member)
- self.b(' %s,' % collect_callback)
- self.b(' data,')
- self.b(' tp_proxy_pending_call_v0_completed,')
- self.b(' timeout_ms,')
-
- for arg in in_args:
- name, info, tp_type, elt = arg
- ctype, gtype, marshaller, pointer = info
-
- const = pointer and 'const ' or ''
-
- self.b(' %s, %s,' % (gtype, name))
-
- self.b(' G_TYPE_INVALID));')
- self.b('')
- self.b(' return data;')
- self.b(' }')
- self.b('}')
- self.b('')
-
- # Reentrant blocking calls
- # Example:
- # gboolean tp_cli_properties_interface_run_get_properties
- # (gpointer proxy,
- # gint timeout_ms,
- # const GArray *in_properties,
- # GPtrArray **out0,
- # GError **error,
- # GMainLoop **loop);
-
- self.b('typedef struct {')
- self.b(' GMainLoop *loop;')
- self.b(' GError **error;')
-
- for arg in out_args:
- name, info, tp_type, elt = arg
- ctype, gtype, marshaller, pointer = info
-
- self.b(' %s*%s;' % (ctype, name))
-
- self.b(' unsigned success:1;')
- self.b(' unsigned completed:1;')
- self.b('} _%s_%s_run_state_%s;'
- % (self.prefix_lc, iface_lc, member_lc))
-
- reentrant_invoke = '_%s_%s_finish_running_%s' % (self.prefix_lc,
- iface_lc,
- member_lc)
-
- self.b('static void')
- self.b('%s (TpProxy *self G_GNUC_UNUSED,' % reentrant_invoke)
- self.b(' GError *error,')
- self.b(' GValueArray *args,')
- self.b(' GCallback unused G_GNUC_UNUSED,')
- self.b(' gpointer user_data G_GNUC_UNUSED,')
- self.b(' GObject *unused2 G_GNUC_UNUSED)')
- self.b('{')
- self.b(' _%s_%s_run_state_%s *state = user_data;'
- % (self.prefix_lc, iface_lc, member_lc))
- self.b('')
- self.b(' state->success = (error == NULL);')
- self.b(' state->completed = TRUE;')
- self.b(' g_main_loop_quit (state->loop);')
- self.b('')
- self.b(' if (error != NULL)')
- self.b(' {')
- self.b(' if (state->error != NULL)')
- self.b(' *state->error = error;')
- self.b(' else')
- self.b(' g_error_free (error);')
- self.b('')
- self.b(' return;')
- self.b(' }')
- self.b('')
-
- for i, arg in enumerate(out_args):
- name, info, tp_type, elt = arg
- ctype, gtype, marshaller, pointer = info
-
- self.b(' if (state->%s != NULL)' % name)
- if marshaller == 'BOXED':
- self.b(' *state->%s = g_value_dup_boxed ('
- 'args->values + %d);' % (name, i))
- elif marshaller == 'STRING':
- self.b(' *state->%s = g_value_dup_string '
- '(args->values + %d);' % (name, i))
- elif marshaller in ('UCHAR', 'BOOLEAN', 'INT', 'UINT',
- 'INT64', 'UINT64', 'DOUBLE'):
- self.b(' *state->%s = g_value_get_%s (args->values + %d);'
- % (name, marshaller.lower(), i))
- else:
- assert False, "Don't know how to copy %s" % gtype
-
- self.b('')
-
- if len(out_args) > 0:
- self.b(' g_value_array_free (args);')
- else:
- self.b(' if (args != NULL)')
- self.b(' g_value_array_free (args);')
-
- self.b('}')
- self.b('')
-
- self.h('gboolean %s_%s_run_%s (%sproxy,'
- % (self.prefix_lc, iface_lc, member_lc, self.proxy_arg))
- self.h(' gint timeout_ms,')
-
- self.b('/**')
- self.b(' * %s_%s_run_%s:' % (self.prefix_lc, iface_lc, member_lc))
- self.b(' * @proxy: %s' % self.proxy_doc)
- self.b(' * @timeout_ms: Timeout in milliseconds, or -1 for default')
-
- for arg in in_args:
- name, info, tp_type, elt = arg
- ctype, gtype, marshaller, pointer = info
-
- self.b(' * @%s: Used to pass an \'in\' argument: %s'
- % (name, xml_escape(get_docstring(elt) or '(Undocumented)')))
-
- for arg in out_args:
- name, info, tp_type, elt = arg
- ctype, gtype, marshaller, pointer = info
-
- self.b(' * @%s: Used to return an \'out\' argument if %%TRUE is '
- 'returned: %s'
- % (name, xml_escape(get_docstring(elt) or '(Undocumented)')))
-
- self.b(' * @error: If not %NULL, used to return errors if %FALSE ')
- self.b(' * is returned')
- self.b(' * @loop: If not %NULL, set before re-entering ')
- self.b(' * the main loop, to point to a #GMainLoop ')
- self.b(' * which can be used to cancel this call with ')
- self.b(' * g_main_loop_quit(), causing a return of ')
- self.b(' * %FALSE with @error set to %TP_DBUS_ERROR_CANCELLED')
- self.b(' *')
- self.b(' * Call the method %s and run the main loop' % member)
- self.b(' * until it returns. Before calling this method, you must')
- self.b(' * add a reference to any borrowed objects you need to keep,')
- self.b(' * and generally ensure that everything is in a consistent')
- self.b(' * state.')
- self.b(' *')
- self.b(' * %s' % xml_escape(get_docstring(method) or '(Undocumented)'))
- self.b(' *')
- self.b(' * Returns: TRUE on success, FALSE and sets @error on error')
- self.b(' */')
- self.b('gboolean\n%s_%s_run_%s (%sproxy,'
- % (self.prefix_lc, iface_lc, member_lc, self.proxy_arg))
- self.b(' gint timeout_ms,')
-
- for arg in in_args:
- name, info, tp_type, elt = arg
- ctype, gtype, marshaller, pointer = info
-
- const = pointer and 'const ' or ''
-
- self.h(' %s%s%s,' % (const, ctype, name))
- self.b(' %s%s%s,' % (const, ctype, name))
-
- for arg in out_args:
- name, info, tp_type, elt = arg
- ctype, gtype, marshaller, pointer = info
-
- self.h(' %s*%s,' % (ctype, name))
- self.b(' %s*%s,' % (ctype, name))
-
- self.h(' GError **error,')
- self.h(' GMainLoop **loop);')
- self.h('')
-
- self.b(' GError **error,')
- self.b(' GMainLoop **loop)')
- self.b('{')
- self.b(' DBusGProxy *iface;')
- self.b(' GQuark interface = %s;' % self.get_iface_quark())
- self.b(' TpProxyPendingCall *pc;')
- self.b(' _%s_%s_run_state_%s state = {'
- % (self.prefix_lc, iface_lc, member_lc))
- self.b(' NULL /* loop */, error,')
-
- for arg in out_args:
- name, info, tp_type, elt = arg
-
- self.b(' %s,' % name)
-
- self.b(' FALSE /* completed */, FALSE /* success */ };')
- self.b('')
- self.b(' g_return_val_if_fail (%s (proxy), FALSE);'
- % self.proxy_assert)
- self.b('')
- self.b(' iface = tp_proxy_borrow_interface_by_id')
- self.b(' ((TpProxy *) proxy, interface, error);')
- self.b('')
- self.b(' if (iface == NULL)')
- self.b(' return FALSE;')
- self.b('')
- self.b(' state.loop = g_main_loop_new (NULL, FALSE);')
- self.b('')
- self.b(' pc = tp_proxy_pending_call_v0_new ((TpProxy *) proxy,')
- self.b(' interface, "%s", iface,' % member)
- self.b(' %s,' % reentrant_invoke)
- self.b(' NULL, &state, NULL, NULL, TRUE);')
- self.b('')
- self.b(' if (loop != NULL)')
- self.b(' *loop = state.loop;')
- self.b('')
- self.b(' tp_proxy_pending_call_v0_take_pending_call (pc,')
- self.b(' dbus_g_proxy_begin_call_with_timeout (iface,')
- self.b(' "%s",' % member)
- self.b(' %s,' % collect_callback)
- self.b(' pc,')
- self.b(' tp_proxy_pending_call_v0_completed,')
- self.b(' timeout_ms,')
-
- for arg in in_args:
- name, info, tp_type, elt = arg
- ctype, gtype, marshaller, pointer = info
-
- const = pointer and 'const ' or ''
-
- self.b(' %s, %s,' % (gtype, name))
-
- self.b(' G_TYPE_INVALID));')
- self.b('')
- self.b(' if (!state.completed)')
- self.b(' g_main_loop_run (state.loop);')
- self.b('')
- self.b(' if (!state.completed)')
- self.b(' tp_proxy_pending_call_cancel (pc);')
- self.b('')
- self.b(' if (loop != NULL)')
- self.b(' *loop = NULL;')
- self.b('')
- self.b(' g_main_loop_unref (state.loop);')
- self.b('')
- self.b(' return state.success;')
- self.b('}')
- self.b('')
-
- # leave a gap for the end of the method
- self.b('')
- self.h('')
-
- def do_signal_add(self, signal):
- marshaller_items = []
- gtypes = []
-
- for i in signal.getElementsByTagName('arg'):
- name = i.getAttribute('name')
- type = i.getAttribute('type')
- info = type_to_gtype(type)
- # type, GType, STRING, is a pointer
- gtypes.append(info[1])
-
- self.b(' dbus_g_proxy_add_signal (proxy, "%s",'
- % signal.getAttribute('name'))
- for gtype in gtypes:
- self.b(' %s,' % gtype)
- self.b(' G_TYPE_INVALID);')
-
- def do_interface(self, node):
- ifaces = node.getElementsByTagName('interface')
- assert len(ifaces) == 1
- iface = ifaces[0]
- name = node.getAttribute('name').replace('/', '')
-
- self.iface = name
- self.iface_lc = name.lower()
- self.iface_uc = name.upper()
- self.iface_mc = name.replace('_', '')
- self.iface_dbus = iface.getAttribute('name')
-
- signals = node.getElementsByTagName('signal')
- methods = node.getElementsByTagName('method')
-
- if signals:
- self.b('static inline void')
- self.b('%s_add_signals_for_%s (DBusGProxy *proxy)'
- % (self.prefix_lc, name.lower()))
- self.b('{')
-
- if self.tp_proxy_api >= (0, 7, 6):
- self.b(' if (!tp_proxy_dbus_g_proxy_claim_for_signal_adding '
- '(proxy))')
- self.b(' return;')
-
- for signal in signals:
- self.do_signal_add(signal)
-
- self.b('}')
- self.b('')
- self.b('')
-
- for signal in signals:
- self.do_signal(name, signal)
-
- for method in methods:
- self.do_method(name, method)
-
- self.iface_dbus = None
-
- def __call__(self):
-
- self.h('G_BEGIN_DECLS')
- self.h('')
-
- self.b('/* We don\'t want gtkdoc scanning this file, it\'ll get')
- self.b(' * confused by seeing function definitions, so mark it as: */')
- self.b('/*<private_header>*/')
- self.b('')
-
- nodes = self.dom.getElementsByTagName('node')
- nodes.sort(cmp_by_name)
-
- for node in nodes:
- self.do_interface(node)
-
- if self.group is not None:
-
- self.b('/*')
- self.b(' * %s_%s_add_signals:' % (self.prefix_lc, self.group))
- self.b(' * @self: the #TpProxy')
- self.b(' * @quark: a quark whose string value is the interface')
- self.b(' * name whose signals should be added')
- self.b(' * @proxy: the D-Bus proxy to which to add the signals')
- self.b(' * @unused: not used for anything')
- self.b(' *')
- self.b(' * Tell dbus-glib that @proxy has the signatures of all')
- self.b(' * signals on the given interface, if it\'s one we')
- self.b(' * support.')
- self.b(' *')
- self.b(' * This function should be used as a signal handler for')
- self.b(' * #TpProxy::interface-added.')
- self.b(' */')
- self.b('static void')
- self.b('%s_%s_add_signals (TpProxy *self G_GNUC_UNUSED,'
- % (self.prefix_lc, self.group))
- self.b(' guint quark,')
- self.b(' DBusGProxy *proxy,')
- self.b(' gpointer unused G_GNUC_UNUSED)')
-
- self.b('{')
-
- for node in nodes:
- iface = node.getElementsByTagName('interface')[0]
- self.iface_dbus = iface.getAttribute('name')
- signals = node.getElementsByTagName('signal')
- if not signals:
- continue
- name = node.getAttribute('name').replace('/', '').lower()
- self.iface_uc = name.upper()
- self.b(' if (quark == %s)' % self.get_iface_quark())
- self.b(' %s_add_signals_for_%s (proxy);'
- % (self.prefix_lc, name))
-
- self.b('}')
- self.b('')
-
- self.h('G_END_DECLS')
- self.h('')
-
- open(self.basename + '.h', 'w').write('\n'.join(self.__header))
- open(self.basename + '-body.h', 'w').write('\n'.join(self.__body))
-
-
-def types_to_gtypes(types):
- return [type_to_gtype(t)[1] for t in types]
-
-
-if __name__ == '__main__':
- options, argv = gnu_getopt(sys.argv[1:], '',
- ['group=', 'subclass=', 'subclass-assert=',
- 'iface-quark-prefix=', 'tp-proxy-api='])
-
- opts = {}
-
- for option, value in options:
- opts[option] = value
-
- dom = xml.dom.minidom.parse(argv[0])
-
- Generator(dom, argv[1], argv[2], opts)()
diff --git a/tools/glib-client-marshaller-gen.py b/tools/glib-client-marshaller-gen.py
deleted file mode 100644
index 5444725..0000000
--- a/tools/glib-client-marshaller-gen.py
+++ /dev/null
@@ -1,59 +0,0 @@
-#!/usr/bin/python
-
-import sys
-import xml.dom.minidom
-from string import ascii_letters, digits
-
-
-from libglibcodegen import signal_to_marshal_name
-
-
-NS_TP = "http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0"
-
-class Generator(object):
-
- def __init__(self, dom, prefix):
- self.dom = dom
- self.marshallers = {}
- self.prefix = prefix
-
- def do_signal(self, signal):
- marshaller = signal_to_marshal_name(signal, self.prefix)
-
- assert '__' in marshaller
- rhs = marshaller.split('__', 1)[1].split('_')
-
- self.marshallers[marshaller] = rhs
-
- def __call__(self):
- signals = self.dom.getElementsByTagName('signal')
-
- for signal in signals:
- self.do_signal(signal)
-
- print 'void'
- print '%s_register_dbus_glib_marshallers (void)' % self.prefix
- print '{'
-
- all = self.marshallers.keys()
- all.sort()
- for marshaller in all:
- rhs = self.marshallers[marshaller]
-
- print ' dbus_g_object_register_marshaller (%s,' % marshaller
- print ' G_TYPE_NONE, /* return */'
- for type in rhs:
- print ' G_TYPE_%s,' % type.replace('VOID', 'NONE')
- print ' G_TYPE_INVALID);'
-
- print '}'
-
-
-def types_to_gtypes(types):
- return [type_to_gtype(t)[1] for t in types]
-
-if __name__ == '__main__':
- argv = sys.argv[1:]
- dom = xml.dom.minidom.parse(argv[0])
-
- Generator(dom, argv[1])()
diff --git a/tools/glib-errors-enum-body-gen.py b/tools/glib-errors-enum-body-gen.py
deleted file mode 100644
index 44863ee..0000000
--- a/tools/glib-errors-enum-body-gen.py
+++ /dev/null
@@ -1,62 +0,0 @@
-#!/usr/bin/python
-
-import sys
-import xml.dom.minidom
-
-from libglibcodegen import NS_TP, camelcase_to_upper, get_docstring, \
- get_descendant_text
-
-class Generator(object):
- def __init__(self, dom):
- self.dom = dom
- self.errors = self.dom.getElementsByTagNameNS(NS_TP, 'errors')[0]
-
- def do_header(self):
- print '/* Generated from the Telepathy spec\n'
- copyrights = self.errors.getElementsByTagNameNS(NS_TP, 'copyright')
- for copyright in copyrights:
- print get_descendant_text(copyright)
- license = self.errors.getElementsByTagNameNS(NS_TP, 'license')[0]
- print '\n' + get_descendant_text(license) + '\n*/'
-
- def do_enum_values(self):
- for error in self.errors.getElementsByTagNameNS(NS_TP, 'error'):
- print ''
- nick = error.getAttribute('name').replace(' ', '')
- name = camelcase_to_upper(nick.replace('.', ''))
- ns = error.parentNode.getAttribute('namespace')
- enum = 'TP_ERROR_' + name
- print ' /* ' + ns + '.' + name
- print ' ' + get_docstring(error)
- print ' */'
- print ' { %s, "%s", "%s" },' % (enum, enum, nick)
-
-
- def do_get_type(self):
- print """
-#include <_gen/telepathy-errors.h>
-
-GType
-tp_error_get_type (void)
-{
- static GType etype = 0;
- if (G_UNLIKELY (etype == 0))
- {
- static const GEnumValue values[] = {"""
- self.do_enum_values()
- print """\
- };
-
- etype = g_enum_register_static ("TpError", values);
- }
- return etype;
-}
-"""
-
- def __call__(self):
- self.do_header()
- self.do_get_type()
-
-if __name__ == '__main__':
- argv = sys.argv[1:]
- Generator(xml.dom.minidom.parse(argv[0]))()
diff --git a/tools/glib-errors-enum-header-gen.py b/tools/glib-errors-enum-header-gen.py
deleted file mode 100644
index 64939b4..0000000
--- a/tools/glib-errors-enum-header-gen.py
+++ /dev/null
@@ -1,75 +0,0 @@
-#!/usr/bin/python
-
-import sys
-import xml.dom.minidom
-
-from libglibcodegen import NS_TP, camelcase_to_upper, get_docstring, \
- get_descendant_text
-
-class Generator(object):
- def __init__(self, dom):
- self.dom = dom
- self.errors = self.dom.getElementsByTagNameNS(NS_TP, 'errors')[0]
-
- def do_header(self):
- print '/* Generated from the Telepathy spec\n'
- copyrights = self.errors.getElementsByTagNameNS(NS_TP, 'copyright')
- for copyright in copyrights:
- print get_descendant_text(copyright)
- license = self.errors.getElementsByTagNameNS(NS_TP, 'license')[0]
- print '\n' + get_descendant_text(license) + '\n*/'
-
- def do_gtkdoc(self):
- for error in self.errors.getElementsByTagNameNS(NS_TP, 'error'):
- ns = error.parentNode.getAttribute('namespace')
- nick = error.getAttribute('name').replace(' ', '')
- enum = 'TP_ERROR_' + camelcase_to_upper(nick.replace('.', ''))
- print ' * @' + enum + ': ' + ns + '.' + nick + ':'
- print ' * ' + get_docstring(error) + ' '
-
- def do_enumnames(self):
- for error in self.errors.getElementsByTagNameNS(NS_TP, 'error'):
- nick = error.getAttribute('name').replace(' ', '')
- enum = 'TP_ERROR_' + camelcase_to_upper(nick.replace('.', ''))
- print ' ' + enum + ','
-
- def do_get_type(self):
- print """
-#include <glib-object.h>
-
-G_BEGIN_DECLS
-
-GType tp_error_get_type (void);
-
-/**
- * TP_TYPE_ERROR:
- *
- * The GType of the Telepathy error enumeration.
- */
-#define TP_TYPE_ERROR (tp_error_get_type())
-"""
-
- def do_enum(self):
- print """\
-/**
- * TpError:"""
- self.do_gtkdoc()
- print """\
- *
- * Enumerated type representing the Telepathy D-Bus errors.
- */
-typedef enum {"""
- self.do_enumnames()
- print """\
-} TpError;
-
-G_END_DECLS"""
-
- def __call__(self):
- self.do_header()
- self.do_get_type()
- self.do_enum()
-
-if __name__ == '__main__':
- argv = sys.argv[1:]
- Generator(xml.dom.minidom.parse(argv[0]))()
diff --git a/tools/glib-ginterface-gen.py b/tools/glib-ginterface-gen.py
index 9eb7af5..95c827c 100644..100755
--- a/tools/glib-ginterface-gen.py
+++ b/tools/glib-ginterface-gen.py
@@ -27,7 +27,7 @@ import os.path
import xml.dom.minidom
from libglibcodegen import Signature, type_to_gtype, cmp_by_name, \
- camelcase_to_lower, NS_TP, dbus_gutils_wincaps_to_uscore, \
+ NS_TP, dbus_gutils_wincaps_to_uscore, \
signal_to_marshal_name, method_to_glue_marshal_name
@@ -66,6 +66,7 @@ class Generator(object):
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
@@ -170,7 +171,42 @@ class Generator(object):
self.h(' * %s%sClass:' % (self.Prefix, node_name_mixed))
self.h(' *')
self.h(' * The class of %s%s.' % (self.Prefix, node_name_mixed))
+
+ if methods:
+ self.h(' *')
+ self.h(' * In a full implementation of this interface (i.e. all')
+ self.h(' * methods implemented), the interface initialization')
+ self.h(' * function used in G_IMPLEMENT_INTERFACE() would')
+ self.h(' * typically look like this:')
+ self.h(' *')
+ self.h(' * <programlisting>')
+ self.h(' * static void')
+ self.h(' * implement_%s (gpointer klass,' % self.node_name_lc)
+ self.h(' * gpointer unused G_GNUC_UNUSED)')
+ self.h(' * {')
+ # "#" is special to gtkdoc under some circumstances; it appears
+ # that escaping "##" as "#<!---->#" or "&#35;&#35;" doesn't work,
+ # but adding an extra hash symbol does. Thanks, gtkdoc :-(
+ self.h(' * #define IMPLEMENT(x) %s%s_implement_###x (\\'
+ % (self.prefix_, self.node_name_lc))
+ self.h(' * 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.h(' * IMPLEMENT (%s);' % class_member_name)
+
+ self.h(' * #undef IMPLEMENT')
+ self.h(' * }')
+ self.h(' * </programlisting>')
+ else:
+ self.h(' * This interface has no D-Bus methods, so an')
+ self.h(' * implementation can typically pass %NULL to')
+ self.h(' * G_IMPLEMENT_INTERFACE() as the interface')
+ self.h(' * initialization function.')
+
self.h(' */')
+
self.h('typedef struct _%s%sClass %s%sClass;'
% (self.Prefix, node_name_mixed, self.Prefix, node_name_mixed))
self.h('')
@@ -207,48 +243,56 @@ class Generator(object):
self.b('%s%s_base_init_once (gpointer klass G_GNUC_UNUSED)'
% (self.prefix_, node_name_lc))
self.b('{')
- self.b(' static TpDBusPropertiesMixinPropInfo properties[%d] = {'
- % (len(properties) + 1))
- for m in properties:
- access = m.getAttribute('access')
- assert access in ('read', 'write', 'readwrite')
+ if properties:
+ self.b(' static TpDBusPropertiesMixinPropInfo properties[%d] = {'
+ % (len(properties) + 1))
- 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')
+ for m in properties:
+ access = m.getAttribute('access')
+ assert access in ('read', 'write', 'readwrite')
- self.b(' { 0, %s, "%s", 0, NULL, NULL }, /* %s */'
- % (flags, m.getAttribute('type'), m.getAttribute('name')))
+ 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')
- self.b(' { 0, 0, NULL, 0, NULL, NULL }')
- self.b(' };')
- self.b(' static TpDBusPropertiesMixinIfaceInfo interface =')
- self.b(' { 0, properties, NULL, NULL };')
- self.b('')
- self.b(' interface.dbus_interface = g_quark_from_static_string '
- '("%s");' % self.iface_name)
+ self.b(' { 0, %s, "%s", 0, NULL, NULL }, /* %s */'
+ % (flags, m.getAttribute('type'), m.getAttribute('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(' { 0, 0, NULL, 0, NULL, NULL }')
+ self.b(' };')
+ self.b(' static TpDBusPropertiesMixinIfaceInfo interface =')
+ self.b(' { 0, properties, NULL, NULL };')
+ self.b('')
- self.b(' tp_svc_interface_set_dbus_properties_info (%s, &interface);'
- % self.current_gtype)
- self.b('')
- for s in base_init_code:
- self.b(s)
self.b(' dbus_g_object_type_install_info (%s%s_get_type (),'
% (self.prefix_, node_name_lc))
self.b(' &_%s%s_object_info);'
% (self.prefix_, node_name_lc))
+ 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('')
+
+ for s in base_init_code:
+ self.b(s)
self.b('}')
self.b('static void')
@@ -276,6 +320,10 @@ class Generator(object):
for method, offset in zip(methods, offsets):
self.do_method_glue(method, offset)
+ if len(methods) == 0:
+ # empty arrays are a gcc extension, so put in a dummy member
+ self.b(" { NULL, NULL, 0 }")
+
self.b('};')
self.b('')
@@ -335,7 +383,11 @@ class Generator(object):
return ''.join(info) + '\0', offsets
def do_method_glue(self, method, offset):
- lc_name = camelcase_to_lower(method.getAttribute('name'))
+ lc_name = method.getAttribute('tp:name-for-bindings')
+ if method.getAttribute('name') != lc_name.replace('_', ''):
+ raise AssertionError('Method %s tp:name-for-bindings (%s) does '
+ 'not match' % (method.getAttribute('name'), lc_name))
+ lc_name = lc_name.lower()
marshaller = method_to_glue_marshal_name(method,
self.signal_marshal_prefix)
@@ -357,10 +409,16 @@ class Generator(object):
def get_method_impl_names(self, method):
dbus_method_name = method.getAttribute('name')
- class_member_name = camelcase_to_lower(dbus_method_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)
+ return (stub_name + '_impl', class_member_name + '_cb')
def do_method(self, method):
assert self.node_name_mixed is not None
@@ -372,7 +430,12 @@ class Generator(object):
# DoStuff
dbus_method_name = method.getAttribute('name')
# do_stuff
- class_member_name = camelcase_to_lower(dbus_method_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()
+
# void tp_svc_thing_do_stuff (TpSvcThing *, const char *, guint,
# DBusGMethodInvocation *);
stub_name = (self.prefix_ + self.node_name_lc + '_' +
@@ -443,7 +506,7 @@ class Generator(object):
self.b(' %s%s,' % (ctype, name))
self.b(' DBusGMethodInvocation *context)')
self.b('{')
- self.b(' %s impl = (%s%s_GET_CLASS (self)->%s);'
+ self.b(' %s impl = (%s%s_GET_CLASS (self)->%s_cb);'
% (impl_name, self.PREFIX_, self.node_name_uc, class_member_name))
self.b('')
self.b(' if (impl != NULL)')
@@ -487,7 +550,7 @@ class Generator(object):
% (self.prefix_, self.node_name_lc, class_member_name,
self.Prefix, self.node_name_mixed, impl_name))
self.b('{')
- self.b(' klass->%s = impl;' % class_member_name)
+ self.b(' klass->%s_cb = impl;' % class_member_name)
self.b('}')
self.b('')
@@ -533,8 +596,15 @@ class Generator(object):
# 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_' +
- camelcase_to_lower(dbus_name))
+ ugly_name.lower())
+
const_name = self.get_signal_const_entry(signal)
# Gather arguments
@@ -616,23 +686,33 @@ class Generator(object):
return in_base_init
+ 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(cmp_by_name)
+
self.h('#include <glib-object.h>')
self.h('#include <dbus/dbus-glib.h>')
- self.h('#include <telepathy-glib/dbus-properties-mixin.h>')
+
+ if self.have_properties(nodes):
+ self.h('#include <telepathy-glib/dbus-properties-mixin.h>')
+
self.h('')
self.h('G_BEGIN_DECLS')
self.h('')
- self.b('#include "%s.h"' % basename)
+ self.b('#include "%s.h"' % self.basename)
self.b('')
for header in self.headers:
self.b('#include %s' % header)
self.b('')
- nodes = self.dom.getElementsByTagName('node')
- nodes.sort(cmp_by_name)
-
for node in nodes:
self.do_node(node)
@@ -645,8 +725,8 @@ class Generator(object):
self.h('')
self.b('')
- open(basename + '.h', 'w').write('\n'.join(self.__header))
- open(basename + '.c', 'w').write('\n'.join(self.__body))
+ open(self.basename + '.h', 'w').write('\n'.join(self.__header))
+ open(self.basename + '.c', 'w').write('\n'.join(self.__body))
def cmdline_error():
diff --git a/tools/glib-gtypes-generator.py b/tools/glib-gtypes-generator.py
index fcb46e8..ebc2ad4 100644..100755
--- a/tools/glib-gtypes-generator.py
+++ b/tools/glib-gtypes-generator.py
@@ -51,9 +51,24 @@ class GTypesGenerator(object):
' * as the specification from which it was generated.\n'
' */\n\n')
+ # keys are e.g. 'sv', values are the key escaped
self.need_mappings = {}
+ # keys are the contents of the struct (e.g. 'sssu'), values are the
+ # key escaped
self.need_structs = {}
- self.need_arrays = {}
+ # keys are the contents of the struct (e.g. 'sssu'), values are the
+ # key escaped
+ self.need_struct_arrays = {}
+
+ # keys are the contents of the array (unlike need_struct_arrays!),
+ # values are the key escaped
+ self.need_other_arrays = {}
+
+ def h(self, code):
+ self.header.write(code.encode("utf-8"))
+
+ def c(self, code):
+ self.body.write(code.encode("utf-8"))
def do_mapping_header(self, mapping):
members = mapping.getElementsByTagNameNS(NS_TP, 'member')
@@ -70,45 +85,59 @@ class GTypesGenerator(object):
docstring = get_docstring(mapping) or '(Undocumented)'
- self.header.write('/**\n * %s:\n *\n' % name)
- self.header.write(' * %s\n' % xml_escape(docstring))
- self.header.write(' *\n')
- self.header.write(' * This macro expands to a call to a function\n')
- self.header.write(' * that returns the #GType of a #GHashTable\n')
- self.header.write(' * appropriate for representing a D-Bus\n')
- self.header.write(' * dictionary of signature\n')
- self.header.write(' * <literal>a{%s}</literal>.\n' % impl_sig)
- self.header.write(' *\n')
+ self.h('/**\n * %s:\n *\n' % name)
+ self.h(' * %s\n' % xml_escape(docstring))
+ self.h(' *\n')
+ self.h(' * This macro expands to a call to a function\n')
+ self.h(' * that returns the #GType of a #GHashTable\n')
+ self.h(' * appropriate for representing a D-Bus\n')
+ self.h(' * dictionary of signature\n')
+ self.h(' * <literal>a{%s}</literal>.\n' % impl_sig)
+ self.h(' *\n')
key, value = members
- self.header.write(' * Keys (D-Bus type <literal>%s</literal>,\n'
+ self.h(' * Keys (D-Bus type <literal>%s</literal>,\n'
% key.getAttribute('type'))
tp_type = key.getAttributeNS(NS_TP, 'type')
if tp_type:
- self.header.write(' * type <literal>%s</literal>,\n' % tp_type)
- self.header.write(' * named <literal>%s</literal>):\n'
+ self.h(' * type <literal>%s</literal>,\n' % tp_type)
+ self.h(' * named <literal>%s</literal>):\n'
% key.getAttribute('name'))
docstring = get_docstring(key) or '(Undocumented)'
- self.header.write(' * %s\n' % xml_escape(docstring))
- self.header.write(' *\n')
+ self.h(' * %s\n' % xml_escape(docstring))
+ self.h(' *\n')
- self.header.write(' * Values (D-Bus type <literal>%s</literal>,\n'
+ self.h(' * Values (D-Bus type <literal>%s</literal>,\n'
% value.getAttribute('type'))
tp_type = value.getAttributeNS(NS_TP, 'type')
if tp_type:
- self.header.write(' * type <literal>%s</literal>,\n' % tp_type)
- self.header.write(' * named <literal>%s</literal>):\n'
+ self.h(' * type <literal>%s</literal>,\n' % tp_type)
+ self.h(' * named <literal>%s</literal>):\n'
% value.getAttribute('name'))
docstring = get_docstring(value) or '(Undocumented)'
- self.header.write(' * %s\n' % xml_escape(docstring))
- self.header.write(' *\n')
+ self.h(' * %s\n' % xml_escape(docstring))
+ self.h(' *\n')
- self.header.write(' */\n')
+ self.h(' */\n')
- self.header.write('#define %s (%s ())\n\n' % (name, impl))
+ self.h('#define %s (%s ())\n\n' % (name, impl))
self.need_mappings[impl_sig] = esc_impl_sig
+ array_name = mapping.getAttribute('array-name')
+ if array_name:
+ gtype_name = self.PREFIX_ + 'ARRAY_TYPE_' + array_name.upper()
+ contents_sig = 'a{' + impl_sig + '}'
+ esc_contents_sig = escape_as_identifier(contents_sig)
+ impl = self.prefix_ + 'type_dbus_array_of_' + esc_contents_sig
+ self.h('/**\n * %s:\n\n' % gtype_name)
+ self.h(' * Expands to a call to a function\n')
+ self.h(' * that returns the #GType of a #GPtrArray\n')
+ self.h(' * of #%s.\n' % name)
+ self.h(' */\n')
+ self.h('#define %s (%s ())\n\n' % (gtype_name, impl))
+ self.need_other_arrays[contents_sig] = esc_contents_sig
+
def do_struct_header(self, struct):
members = struct.getElementsByTagNameNS(NS_TP, 'member')
impl_sig = ''.join([elt.getAttribute('type') for elt in members])
@@ -128,43 +157,43 @@ class GTypesGenerator(object):
docstring = '(Undocumented)'
else:
docstring = '(Undocumented)'
- self.header.write('/**\n * %s:\n\n' % name)
- self.header.write(' * %s\n' % xml_escape(docstring))
- self.header.write(' *\n')
- self.header.write(' * This macro expands to a call to a function\n')
- self.header.write(' * that returns the #GType of a #GValueArray\n')
- self.header.write(' * appropriate for representing a D-Bus struct\n')
- self.header.write(' * with signature <literal>(%s)</literal>.\n'
+ self.h('/**\n * %s:\n\n' % name)
+ self.h(' * %s\n' % xml_escape(docstring))
+ self.h(' *\n')
+ self.h(' * This macro expands to a call to a function\n')
+ self.h(' * that returns the #GType of a #GValueArray\n')
+ self.h(' * appropriate for representing a D-Bus struct\n')
+ self.h(' * with signature <literal>(%s)</literal>.\n'
% impl_sig)
- self.header.write(' *\n')
+ self.h(' *\n')
for i, member in enumerate(members):
- self.header.write(' * Member %d (D-Bus type '
+ self.h(' * Member %d (D-Bus type '
'<literal>%s</literal>,\n'
% (i, member.getAttribute('type')))
tp_type = member.getAttributeNS(NS_TP, 'type')
if tp_type:
- self.header.write(' * type <literal>%s</literal>,\n' % tp_type)
- self.header.write(' * named <literal>%s</literal>):\n'
+ self.h(' * type <literal>%s</literal>,\n' % tp_type)
+ self.h(' * named <literal>%s</literal>):\n'
% member.getAttribute('name'))
docstring = get_docstring(member) or '(Undocumented)'
- self.header.write(' * %s\n' % xml_escape(docstring))
- self.header.write(' *\n')
+ self.h(' * %s\n' % xml_escape(docstring))
+ self.h(' *\n')
- self.header.write(' */\n')
- self.header.write('#define %s (%s ())\n\n' % (name, impl))
+ self.h(' */\n')
+ self.h('#define %s (%s ())\n\n' % (name, impl))
array_name = struct.getAttribute('array-name')
if array_name != '':
array_name = (self.PREFIX_ + 'ARRAY_TYPE_' + array_name.upper())
impl = self.prefix_ + 'type_dbus_array_' + esc_impl_sig
- self.header.write('/**\n * %s:\n\n' % array_name)
- self.header.write(' * Expands to a call to a function\n')
- self.header.write(' * that returns the #GType of a #GPtrArray\n')
- self.header.write(' * of #%s.\n' % name)
- self.header.write(' */\n')
- self.header.write('#define %s (%s ())\n\n' % (array_name, impl))
- self.need_arrays[impl_sig] = esc_impl_sig
+ self.h('/**\n * %s:\n\n' % array_name)
+ self.h(' * Expands to a call to a function\n')
+ self.h(' * that returns the #GType of a #GPtrArray\n')
+ self.h(' * of #%s.\n' % name)
+ self.h(' */\n')
+ self.h('#define %s (%s ())\n\n' % (array_name, impl))
+ self.need_struct_arrays[impl_sig] = esc_impl_sig
self.need_structs[impl_sig] = esc_impl_sig
@@ -176,51 +205,83 @@ class GTypesGenerator(object):
self.do_mapping_header(mapping)
for sig in self.need_mappings:
- self.header.write('GType %stype_dbus_hash_%s (void);\n\n' %
+ self.h('GType %stype_dbus_hash_%s (void);\n\n' %
(self.prefix_, self.need_mappings[sig]))
- self.body.write('GType\n%stype_dbus_hash_%s (void)\n{\n' %
+ self.c('GType\n%stype_dbus_hash_%s (void)\n{\n' %
(self.prefix_, self.need_mappings[sig]))
- self.body.write(' static GType t = 0;\n\n')
- self.body.write(' if (G_UNLIKELY (t == 0))\n')
+ self.c(' static GType t = 0;\n\n')
+ self.c(' if (G_UNLIKELY (t == 0))\n')
# FIXME: translate sig into two GTypes
items = tuple(Signature(sig))
gtypes = types_to_gtypes(items)
- self.body.write(' t = dbus_g_type_get_map ("GHashTable", '
+ self.c(' t = dbus_g_type_get_map ("GHashTable", '
'%s, %s);\n' % (gtypes[0], gtypes[1]))
- self.body.write(' return t;\n')
- self.body.write('}\n\n')
+ self.c(' return t;\n')
+ self.c('}\n\n')
for struct in structs:
self.do_struct_header(struct)
for sig in self.need_structs:
- self.header.write('GType %stype_dbus_struct_%s (void);\n\n' %
+ self.h('GType %stype_dbus_struct_%s (void);\n\n' %
(self.prefix_, self.need_structs[sig]))
- self.body.write('GType\n%stype_dbus_struct_%s (void)\n{\n' %
+ self.c('GType\n%stype_dbus_struct_%s (void)\n{\n' %
(self.prefix_, self.need_structs[sig]))
- self.body.write(' static GType t = 0;\n\n')
- self.body.write(' if (G_UNLIKELY (t == 0))\n')
- self.body.write(' t = dbus_g_type_get_struct ("GValueArray",\n')
+ self.c(' static GType t = 0;\n\n')
+ self.c(' if (G_UNLIKELY (t == 0))\n')
+ self.c(' t = dbus_g_type_get_struct ("GValueArray",\n')
items = tuple(Signature(sig))
gtypes = types_to_gtypes(items)
for gtype in gtypes:
- self.body.write(' %s,\n' % gtype)
- self.body.write(' G_TYPE_INVALID);\n')
- self.body.write(' return t;\n')
- self.body.write('}\n\n')
-
- for sig in self.need_arrays:
- self.header.write('GType %stype_dbus_array_%s (void);\n\n' %
- (self.prefix_, self.need_structs[sig]))
- self.body.write('GType\n%stype_dbus_array_%s (void)\n{\n' %
- (self.prefix_, self.need_structs[sig]))
- self.body.write(' static GType t = 0;\n\n')
- self.body.write(' if (G_UNLIKELY (t == 0))\n')
- self.body.write(' t = dbus_g_type_get_collection ("GPtrArray", '
+ self.c(' %s,\n' % gtype)
+ self.c(' G_TYPE_INVALID);\n')
+ self.c(' return t;\n')
+ self.c('}\n\n')
+
+ for sig in self.need_struct_arrays:
+ self.h('GType %stype_dbus_array_%s (void);\n\n' %
+ (self.prefix_, self.need_struct_arrays[sig]))
+ self.c('GType\n%stype_dbus_array_%s (void)\n{\n' %
+ (self.prefix_, self.need_struct_arrays[sig]))
+ self.c(' static GType t = 0;\n\n')
+ self.c(' if (G_UNLIKELY (t == 0))\n')
+ self.c(' t = dbus_g_type_get_collection ("GPtrArray", '
'%stype_dbus_struct_%s ());\n' %
- (self.prefix_, self.need_structs[sig]))
- self.body.write(' return t;\n')
- self.body.write('}\n\n')
+ (self.prefix_, self.need_struct_arrays[sig]))
+ self.c(' return t;\n')
+ self.c('}\n\n')
+
+ for sig in self.need_other_arrays:
+ self.h('GType %stype_dbus_array_of_%s (void);\n\n' %
+ (self.prefix_, self.need_other_arrays[sig]))
+ self.c('GType\n%stype_dbus_array_of_%s (void)\n{\n' %
+ (self.prefix_, self.need_other_arrays[sig]))
+ self.c(' static GType t = 0;\n\n')
+ self.c(' if (G_UNLIKELY (t == 0))\n')
+
+ if sig[:2] == 'a{' and sig[-1:] == '}':
+ # array of mappings
+ self.c(' t = dbus_g_type_get_collection ('
+ '"GPtrArray", '
+ '%stype_dbus_hash_%s ());\n' %
+ (self.prefix_, escape_as_identifier(sig[2:-1])))
+ elif sig[:2] == 'a(' and sig[-1:] == ')':
+ # array of arrays of struct
+ self.c(' t = dbus_g_type_get_collection ('
+ '"GPtrArray", '
+ '%stype_dbus_array_%s ());\n' %
+ (self.prefix_, escape_as_identifier(sig[2:-1])))
+ elif sig[:1] == 'a':
+ # array of arrays of non-struct
+ self.c(' t = dbus_g_type_get_collection ('
+ '"GPtrArray", '
+ '%stype_dbus_array_of_%s ());\n' %
+ (self.prefix_, escape_as_identifier(sig[1:])))
+ else:
+ raise AssertionError("array of '%s' not supported" % sig)
+
+ self.c(' return t;\n')
+ self.c('}\n\n')
if __name__ == '__main__':
argv = sys.argv[1:]
diff --git a/tools/glib-interfaces-gen.py b/tools/glib-interfaces-gen.py
index 741626c..9543968 100644..100755
--- a/tools/glib-interfaces-gen.py
+++ b/tools/glib-interfaces-gen.py
@@ -3,7 +3,7 @@
from sys import argv, stdout, stderr
import xml.dom.minidom
-from libglibcodegen import NS_TP, camelcase_to_upper, get_docstring, \
+from libglibcodegen import NS_TP, get_docstring, \
get_descendant_text, get_by_path
class Generator(object):
@@ -13,26 +13,32 @@ class Generator(object):
self.decls = open(declfile, 'w')
self.spec = get_by_path(dom, "spec")[0]
+ def h(self, code):
+ self.decls.write(code.encode('utf-8'))
+
+ def c(self, code):
+ self.impls.write(code.encode('utf-8'))
+
def __call__(self):
- for file in self.decls, self.impls:
- self.do_header(file)
+ for f in self.h, self.c:
+ self.do_header(f)
self.do_body()
# Header
- def do_header(self, file):
- file.write('/* Generated from: ')
- file.write(get_descendant_text(get_by_path(self.spec, 'title')))
+ def do_header(self, f):
+ f('/* Generated from: ')
+ f(get_descendant_text(get_by_path(self.spec, 'title')))
version = get_by_path(self.spec, "version")
if version:
- file.write(' version ' + get_descendant_text(version))
- file.write('\n\n')
+ f(' version ' + get_descendant_text(version))
+ f('\n\n')
for copyright in get_by_path(self.spec, 'copyright'):
- stdout.write(get_descendant_text(copyright))
- stdout.write('\n')
- file.write('\n')
- file.write(get_descendant_text(get_by_path(self.spec, 'license')))
- file.write(get_descendant_text(get_by_path(self.spec, 'docstring')))
- file.write("""
+ f(get_descendant_text(copyright))
+ f('\n')
+ f('\n')
+ f(get_descendant_text(get_by_path(self.spec, 'license')))
+ f(get_descendant_text(get_by_path(self.spec, 'docstring')))
+ f("""
*/
""")
@@ -44,10 +50,10 @@ class Generator(object):
def do_iface(self, iface):
parent_name = get_by_path(iface, '../@name')
- self.decls.write("""\
+ self.h("""\
/**
* %(IFACE_DEFINE)s:
- *
+ *
* The interface name "%(name)s"
*/
#define %(IFACE_DEFINE)s \\
@@ -56,10 +62,10 @@ class Generator(object):
parent_name).upper().replace('/', ''),
'name' : iface.getAttribute('name')})
- self.decls.write("""
+ self.h("""
/**
* %(IFACE_QUARK_DEFINE)s:
- *
+ *
* Expands to a call to a function that returns a quark for the interface \
name "%(name)s"
*/
@@ -74,7 +80,7 @@ GQuark %(iface_quark_func)s (void);
parent_name).lower().replace('/', ''),
'name' : iface.getAttribute('name')})
- self.impls.write("""\
+ self.c("""\
GQuark
%(iface_quark_func)s (void)
{
@@ -92,6 +98,22 @@ GQuark
parent_name).lower().replace('/', ''),
'name' : iface.getAttribute('name')})
+ for prop in iface.getElementsByTagNameNS(None, 'property'):
+ self.decls.write("""
+/**
+ * %(IFACE_PREFIX)s_%(PROP_UC)s:
+ *
+ * The fully-qualified property name "%(name)s.%(prop)s"
+ */
+#define %(IFACE_PREFIX)s_%(PROP_UC)s \\
+"%(name)s.%(prop)s"
+""" % {'IFACE_PREFIX' : (self.prefix + 'PROP_' + \
+ parent_name).upper().replace('/', ''),
+ 'PROP_UC': prop.getAttributeNS(NS_TP, "name-for-bindings").upper(),
+ 'name' : iface.getAttribute('name'),
+ 'prop' : prop.getAttribute('name'),
+ })
+
if __name__ == '__main__':
argv = argv[1:]
Generator(argv[0], argv[1], argv[2], xml.dom.minidom.parse(argv[3]))()
diff --git a/tools/glib-signals-marshal-gen.py b/tools/glib-signals-marshal-gen.py
index 0d02c13..0d02c13 100644..100755
--- a/tools/glib-signals-marshal-gen.py
+++ b/tools/glib-signals-marshal-gen.py
diff --git a/tools/gobject-foo.py b/tools/gobject-foo.py
deleted file mode 100644
index 5921cab..0000000
--- a/tools/gobject-foo.py
+++ /dev/null
@@ -1,81 +0,0 @@
-#!/usr/bin/python
-
-# gobject-foo.py: generate standard GObject type macros etc.
-#
-# The master copy of this program is in the telepathy-glib repository -
-# please make any changes there.
-#
-# Copyright (C) 2007 Collabora Ltd. <http://www.collabora.co.uk/>
-#
-# 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
-
-def gobject_header(head, tail, as_interface=False):
- out = []
- o = out.append
-
- name = head + '_' + tail
- MixedCase = name.replace('_', '')
- lower_case = name.lower()
- UPPER_CASE = name.upper()
-
- gtype = head.upper() + '_TYPE_' + tail.upper()
-
- o("typedef struct _%s %s;" % (MixedCase, MixedCase))
- o("typedef struct _%sClass %sClass;" % (MixedCase, MixedCase))
- o("typedef struct _%sPrivate %sPrivate;" % (MixedCase, MixedCase))
- o("")
- o("GType %s_get_type (void);" % lower_case)
- o("")
-
- o("#define %s \\" % gtype)
- o(" (%s_get_type ())" % lower_case)
-
- o("#define %s(obj) \\" % UPPER_CASE)
- o(" (G_TYPE_CHECK_INSTANCE_CAST ((obj), %s, \\" % gtype)
- o(" %s))" % MixedCase)
-
- if not as_interface:
- o("#define %s_CLASS(klass) \\" % UPPER_CASE)
- o(" (G_TYPE_CHECK_CLASS_CAST ((klass), %s, \\" % gtype)
- o(" %sClass))" % MixedCase)
-
- o("#define %s_IS_%s(obj) \\" % (head.upper(), tail.upper()))
- o(" (G_TYPE_CHECK_INSTANCE_TYPE ((obj), %s))" % gtype)
-
- if not as_interface:
- o("#define %s_IS_%s_CLASS(klass) \\" % (head.upper(), tail.upper()))
- o(" (G_TYPE_CHECK_CLASS_TYPE ((klass), %s))" % gtype)
-
- o("#define %s_GET_CLASS(obj) \\" % UPPER_CASE)
- o(" (G_TYPE_INSTANCE_GET_CLASS ((obj), %s, \\" % gtype)
- o(" %sClass))" % MixedCase)
-
- return out
-
-if __name__ == '__main__':
- import sys
- from getopt import gnu_getopt
-
- options, argv = gnu_getopt(sys.argv[1:], '', ['interface'])
-
- as_interface = False
-
- for opt, val in options:
- if opt == '--interface':
- as_interface = True
-
- head, tail = argv
-
- print '\n'.join(gobject_header(head, tail, as_interface=as_interface))
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/lcov.am b/tools/lcov.am
index 97eed8f..7384f1b 100644
--- a/tools/lcov.am
+++ b/tools/lcov.am
@@ -8,7 +8,8 @@ lcov-report:
--remove @top_builddir@/lcov.info.tmp telepathy-glib-scan.c
rm @top_builddir@/lcov.info.tmp
$(mkdir_p) @top_builddir@/lcov.html
- genhtml --title telepathy-glib \
+ git_commit=`GIT_DIR=@top_srcdir@/.git git log -1 --pretty=format:%h 2>/dev/null`;\
+ genhtml --title "@PACKAGE_STRING@ $$git_commit" \
--output-directory @top_builddir@/lcov.html lcov.info
@echo
@echo 'lcov report can be found in:'
@@ -17,7 +18,7 @@ lcov-report:
lcov-check:
$(MAKE) lcov-reset
- $(MAKE) check
+ $(MAKE) check $(LCOV_CHECK_ARGS)
$(MAKE) lcov-report
## vim:set ft=automake:
diff --git a/tools/libglibcodegen.py b/tools/libglibcodegen.py
index 129c179..6a9d214 100644..100755
--- a/tools/libglibcodegen.py
+++ b/tools/libglibcodegen.py
@@ -23,14 +23,13 @@ please make any changes there.
from libtpcodegen import NS_TP, \
Signature, \
- camelcase_to_lower, \
- camelcase_to_upper, \
cmp_by_name, \
escape_as_identifier, \
get_by_path, \
get_descendant_text, \
get_docstring, \
- xml_escape
+ xml_escape, \
+ get_deprecated
def dbus_gutils_wincaps_to_uscore(s):
"""Bug-for-bug compatible Python port of _dbus_gutils_wincaps_to_uscore
diff --git a/tools/libtpcodegen.py b/tools/libtpcodegen.py
index 6391f1a..837ff2f 100644..100755
--- a/tools/libtpcodegen.py
+++ b/tools/libtpcodegen.py
@@ -29,32 +29,6 @@ NS_TP = "http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0"
_ASCII_ALNUM = ascii_letters + digits
-def camelcase_to_lower(s):
- out ="";
- out += s[0].lower()
- last_upper=False
- if s[0].isupper():
- last_upper=True
- for i in range(1,len(s)):
- if s[i].isupper():
- if last_upper:
- if (i+1) < len(s) and s[i+1].islower():
- out += "_" + s[i].lower()
- else:
- out += s[i].lower()
- else:
- out += "_" + s[i].lower()
- last_upper=True
- else:
- out += s[i]
- last_upper=False
- return out
-
-
-def camelcase_to_upper(s):
- return camelcase_to_lower(s).upper()
-
-
def cmp_by_name(node1, node2):
return cmp(node1.getAttributeNode("name").nodeValue,
node2.getAttributeNode("name").nodeValue)
@@ -146,6 +120,16 @@ def get_docstring(element):
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:
diff --git a/tools/log-strip.py b/tools/log-strip.py
new file mode 100755
index 0000000..3c8ca93
--- /dev/null
+++ b/tools/log-strip.py
@@ -0,0 +1,35 @@
+#!/usr/bin/python
+"""
+Strip varying data (PIDs, pointer values) from Gabble logs to make them
+easier to compare.
+"""
+
+from __future__ import with_statement
+
+import re
+import sys
+
+def sanitise(line):
+ return (
+ re.sub('^(\*\* )?\(telepathy-gabble:\d+\)', '',
+ re.sub('\x1b\[0m', '',
+ re.sub('^RECV \[\d+\]', 'RECV [???]',
+ re.sub('0x[0-9A-Fa-f]{5,8}', '0x???????',
+ re.sub("('?<[^ ]+ [^>]*id=)[\"'][^\"']+[\"']",
+ lambda m: m.group(1) + '"?????"', line))))))
+
+def process(file):
+ for line in file:
+ print sanitise(line),
+
+def main():
+ if len(sys.argv) > 1:
+ for fn in sys.argv[1:]:
+ with open(fn) as f:
+ process(f)
+ else:
+ process(sys.stdin)
+
+if __name__ == '__main__':
+ main()
+
diff --git a/tools/make-version-script.py b/tools/make-version-script.py
deleted file mode 100644
index 91306a0..0000000
--- a/tools/make-version-script.py
+++ /dev/null
@@ -1,205 +0,0 @@
-#!/usr/bin/python
-
-"""Construct a GNU ld or Debian dpkg version-script from a set of
-RFC822-style symbol lists.
-
-Usage:
- make-version-script.py [--symbols SYMBOLS] [--unreleased-version VER]
- [--dpkg "LIBRARY.so.0 LIBRARY0 #MINVER#"]
- [--dpkg-build-depends-package LIBRARY-dev]
- [FILES...]
-
-Each FILE starts with RFC822-style headers "Version:" (the name of the
-symbol version, e.g. FOO_1.2.3) and "Extends:" (either the previous
-version, or "-" if this is the first version). Next there is a blank
-line, then a list of C symbols one per line.
-
-Comments (lines starting with whitespace + "#") are allowed and ignored.
-
-If --symbols is given, SYMBOLS lists the symbols actually exported by
-the library (one per line). If --unreleased-version is given, any symbols
-in SYMBOLS but not in FILES are assigned to that version; otherwise, any
-such symbols cause an error.
-
-If --dpkg is given, produce a Debian dpkg-gensymbols file instead of a
-GNU ld version-script. The argument to --dpkg is the first line of the
-resulting symbols file, and --dpkg-build-depends-package can optionally
-be used to set the Build-Depends-Package field.
-
-This script originates in telepathy-glib <http://telepathy.freedesktop.org/> -
-please send us any changes that are needed.
-"""
-
-# Copyright (C) 2008 Collabora Ltd. <http://www.collabora.co.uk/>
-# Copyright (C) 2008 Nokia Corporation
-#
-# Copying and distribution of this file, with or without modification,
-# are permitted in any medium without royalty provided the copyright
-# notice and this notice are preserved.
-
-import sys
-from getopt import gnu_getopt
-from sets import Set as set
-
-
-def e(format, *args):
- sys.stderr.write((format + '\n') % args)
-
-
-def main(abifiles, symbols=None, unreleased_version=None,
- dpkg=False, dpkg_first_line=None, dpkg_build_depends_package=None):
-
- gnuld = not dpkg
- symbol_set = None
-
- if symbols is not None:
- symbol_set = open(symbols, 'r').readlines()
- symbol_set = map(str.strip, symbol_set)
- symbol_set = set(symbol_set)
-
- versioned_symbols = set()
-
- dpkg_symbols = []
- dpkg_versions = []
-
- if dpkg:
- assert dpkg_first_line is not None
- print dpkg_first_line
- if dpkg_build_depends_package is not None:
- print "* Build-Depends-Package: %s" % dpkg_build_depends_package
-
- for filename in abifiles:
- lines = open(filename, 'r').readlines()
-
- version = None
- extends = None
- release = None
-
- for i, line in enumerate(lines):
- line = line.strip()
-
- if line.startswith('#'):
- continue
- elif not line:
- # the transition betwen headers and symbols
- cut = i + 1
- break
- elif line.lower().startswith('version:'):
- line = line[8:].strip()
- version = line
- continue
- elif line.lower().startswith('extends:'):
- line = line[8:].strip()
- extends = line
- continue
- elif line.lower().startswith('release:'):
- release = line[8:].strip()
- continue
- else:
- e('Could not understand line in %s header: %s', filename, line)
- raise SystemExit(1)
-
- else:
- e('No symbols in %s', filename)
- raise SystemExit(1)
-
- if version is None:
- e('No Versions: header in %s', filename)
- raise SystemExit(1)
-
- if extends is None:
- e('No Extends: header in %s', filename)
- raise SystemExit(1)
-
- if release is None and dpkg:
- e('No Release: header in %s', filename)
- raise SystemExit(1)
-
- if dpkg:
- dpkg_versions.append('%s@%s %s' % (version, version, release))
-
- lines = lines[cut:]
-
- if gnuld:
- print "%s {" % version
- print " global:"
-
- for symbol in lines:
- symbol = symbol.strip()
-
- if symbol.startswith('#'):
- continue
-
- if gnuld:
- print " %s;" % symbol
- elif dpkg:
- dpkg_symbols.append('%s@%s %s' % (symbol, version, release))
-
- versioned_symbols.add(symbol)
-
- if gnuld:
- if extends == '-':
- print " local:"
- print " *;"
- print "};"
- else:
- print "} %s;" % extends
- print
-
- if dpkg:
- dpkg_symbols.sort()
- dpkg_versions.sort()
-
- for x in dpkg_versions:
- print " %s" % x
-
- for x in dpkg_symbols:
- print " %s" % x
-
- if symbol_set is not None:
- missing = versioned_symbols - symbol_set
-
- if missing:
- e('These symbols have disappeared:')
-
- for symbol in missing:
- e(' %s', symbol)
-
- raise SystemExit(1)
-
- unreleased = symbol_set - versioned_symbols
-
- if unreleased:
- if unreleased_version is None:
- e('Unversioned symbols are not allowed in releases:')
-
- for symbol in unreleased:
- e(' %s', symbol)
-
- raise SystemExit(1)
-
- if gnuld:
- print "%s {" % unreleased_version
- print " global:"
-
- for symbol in unreleased:
- print " %s;" % symbol
-
- print "} %s;" % version
-
-
-if __name__ == '__main__':
- options, argv = gnu_getopt (sys.argv[1:], '',
- ['symbols=', 'unreleased-version=',
- 'dpkg=', 'dpkg-build-depends-package='])
-
- opts = {'dpkg': False}
-
- for option, value in options:
- if option == '--dpkg':
- opts['dpkg'] = True
- opts['dpkg_first_line'] = value
- else:
- opts[option.lstrip('-').replace('-', '_')] = value
-
- main(argv, **opts)
diff --git a/tools/telepathy-glib-env.in b/tools/telepathy-glib-env.in
deleted file mode 100644
index ddc47bf..0000000
--- a/tools/telepathy-glib-env.in
+++ /dev/null
@@ -1,9 +0,0 @@
-#!/bin/sh
-abs_top_builddir="@abs_top_builddir@"
-export abs_top_builddir
-LD_LIBRARY_PATH="${abs_top_builddir}/telepathy-glib/.libs${LD_LIBRARY_PATH:+":${LD_LIBRARY_PATH}"}"
-export LD_LIBRARY_PATH
-G_DEBUG="fatal_criticals,fatal_warnings${G_DEBUG:+",${G_DEBUG}"}"
-export G_DEBUG
-
-exec "$@"
diff --git a/tools/telepathy.am b/tools/telepathy.am
index d061b89..93b73d2 100644
--- a/tools/telepathy.am
+++ b/tools/telepathy.am
@@ -3,10 +3,21 @@
dist-hook:
chmod u+w ${distdir}/ChangeLog
if test -d ${top_srcdir}/.git; then \
- git log --stat > ${distdir}/ChangeLog || \
- git log > ${distdir}/ChangeLog; \
+ git log --date=iso $(CHANGELOG_RANGE) > ${distdir}/ChangeLog; \
fi
+distcheck-hook:
+ @case @VERSION@ in \
+ *.*.*.*) ;; \
+ *) \
+ if grep -r UNRELEASED $(CHECK_FOR_UNRELEASED); \
+ then \
+ echo "^^^ This is meant to be a release, but some files say UNRELEASED" >&2; \
+ exit 2; \
+ fi \
+ ;; \
+ esac
+
maintainer-upload-release: _maintainer-upload-release
_maintainer-upload-release-check:
diff --git a/tools/with-session-bus.sh b/tools/with-session-bus.sh
deleted file mode 100644
index 519b9b1..0000000
--- a/tools/with-session-bus.sh
+++ /dev/null
@@ -1,84 +0,0 @@
-#!/bin/sh
-# with-session-bus.sh - run a program with a temporary D-Bus session daemon
-#
-# The canonical location of this program is the telepathy-glib tools/
-# directory, please synchronize any changes with that copy.
-#
-# Copyright (C) 2007-2008 Collabora Ltd. <http://www.collabora.co.uk/>
-#
-# Copying and distribution of this file, with or without modification,
-# are permitted in any medium without royalty provided the copyright
-# notice and this notice are preserved.
-
-set -e
-
-me=with-session-bus
-
-dbus_daemon_args="--print-address=5 --print-pid=6 --fork"
-
-usage ()
-{
- echo "usage: $me [options] -- program [program_options]" >&2
- echo "Requires write access to the current directory." >&2
- echo "" >&2
- echo "If \$WITH_SESSION_BUS_FORK_DBUS_MONITOR is set, fork dbus-monitor" >&2
- echo "with the arguments in \$WITH_SESSION_BUS_FORK_DBUS_MONITOR_OPT." >&2
- echo "The output of dbus-monitor is saved in $me-<pid>.dbus-monitor-logs" >&2
- exit 2
-}
-
-while test "z$1" != "z--"; do
- case "$1" in
- --session)
- dbus_daemon_args="$dbus_daemon_args --session"
- shift
- ;;
- --config-file=*)
- # FIXME: assumes config file doesn't contain any special characters
- dbus_daemon_args="$dbus_daemon_args $1"
- shift
- ;;
- *)
- usage
- ;;
- esac
-done
-shift
-if test "z$1" = "z"; then usage; fi
-
-exec 5> $me-$$.address
-exec 6> $me-$$.pid
-
-cleanup ()
-{
- pid=`head -n1 $me-$$.pid`
- if test -n "$pid" ; then
- echo "Killing temporary bus daemon: $pid" >&2
- kill -INT "$pid"
- fi
- rm -f $me-$$.address
- rm -f $me-$$.pid
-}
-
-trap cleanup INT HUP TERM
-dbus-daemon $dbus_daemon_args
-
-{ echo -n "Temporary bus daemon is "; cat $me-$$.address; } >&2
-{ echo -n "Temporary bus daemon PID is "; head -n1 $me-$$.pid; } >&2
-
-e=0
-DBUS_SESSION_BUS_ADDRESS="`cat $me-$$.address`"
-export DBUS_SESSION_BUS_ADDRESS
-
-if [ -n "$WITH_SESSION_BUS_FORK_DBUS_MONITOR" ] ; then
- echo -n "Forking dbus-monitor $WITH_SESSION_BUS_FORK_DBUS_MONITOR_OPT" >&2
- dbus-monitor $WITH_SESSION_BUS_FORK_DBUS_MONITOR_OPT \
- &> $me-$$.dbus-monitor-logs &
-fi
-
-"$@" || e=$?
-
-trap - INT HUP TERM
-cleanup
-
-exit $e
diff --git a/tools/xincludator.py b/tools/xincludator.py
new file mode 100755
index 0000000..63e106a
--- /dev/null
+++ b/tools/xincludator.py
@@ -0,0 +1,39 @@
+#!/usr/bin/python
+
+from sys import argv, stdout, stderr
+import codecs, locale
+import os
+import xml.dom.minidom
+
+stdout = codecs.getwriter('utf-8')(stdout)
+
+NS_XI = 'http://www.w3.org/2001/XInclude'
+
+def xincludate(dom, base, dropns = []):
+ remove_attrs = []
+ for i in xrange(dom.documentElement.attributes.length):
+ attr = dom.documentElement.attributes.item(i)
+ if attr.prefix == 'xmlns':
+ if attr.localName in dropns:
+ remove_attrs.append(attr)
+ else:
+ dropns.append(attr.localName)
+ for attr in remove_attrs:
+ dom.documentElement.removeAttributeNode(attr)
+ for include in dom.getElementsByTagNameNS(NS_XI, 'include'):
+ href = include.getAttribute('href')
+ # FIXME: assumes Unixy paths
+ filename = os.path.join(os.path.dirname(base), href)
+ subdom = xml.dom.minidom.parse(filename)
+ xincludate(subdom, filename, dropns)
+ if './' in href:
+ subdom.documentElement.setAttribute('xml:base', href)
+ include.parentNode.replaceChild(subdom.documentElement, include)
+
+if __name__ == '__main__':
+ argv = argv[1:]
+ dom = xml.dom.minidom.parse(argv[0])
+ xincludate(dom, argv[0])
+ xml = dom.toxml()
+ stdout.write(xml)
+ stdout.write('\n')