Commit 1aeffdb7 authored by Simon McVittie's avatar Simon McVittie

Update Python tools from telepathy-glib (avoid deprecations, etc.)

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=26609Reviewed-by: Guillaume Desmottes's avatarGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
parent e43c17ba
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
from sys import argv, stdout, stderr from sys import argv, stdout, stderr
import xml.dom.minidom import xml.dom.minidom
from libtpcodegen import file_set_contents from libtpcodegen import file_set_contents, u
from libglibcodegen import NS_TP, get_docstring, \ from libglibcodegen import NS_TP, get_docstring, \
get_descendant_text, get_by_path get_descendant_text, get_by_path
...@@ -12,7 +12,7 @@ class Generator(object): ...@@ -12,7 +12,7 @@ class Generator(object):
self.prefix = prefix + '_' self.prefix = prefix + '_'
self.spec = get_by_path(dom, "spec")[0] self.spec = get_by_path(dom, "spec")[0]
self.output_base = output_base self.output_base = output_base
self.__header = [] self.__header = []
self.__docs = [] self.__docs = []
...@@ -21,14 +21,14 @@ class Generator(object): ...@@ -21,14 +21,14 @@ class Generator(object):
self.do_body() self.do_body()
self.do_footer() self.do_footer()
file_set_contents(self.output_base + '.h', ''.join(self.__header)) file_set_contents(self.output_base + '.h', u('').join(self.__header).encode('utf-8'))
file_set_contents(self.output_base + '-gtk-doc.h', ''.join(self.__docs)) file_set_contents(self.output_base + '-gtk-doc.h', u('').join(self.__docs).encode('utf-8'))
def write(self, code): def write(self, code):
self.__header.append(code.encode('utf-8')) self.__header.append(code)
def d(self, code): def d(self, code):
self.__docs.append(code.encode('utf-8')) self.__docs.append(code)
# Header # Header
def do_header(self): def do_header(self):
......
...@@ -27,9 +27,9 @@ import os.path ...@@ -27,9 +27,9 @@ import os.path
import xml.dom.minidom import xml.dom.minidom
from getopt import gnu_getopt from getopt import gnu_getopt
from libtpcodegen import file_set_contents from libtpcodegen import file_set_contents, key_by_name, u
from libglibcodegen import Signature, type_to_gtype, cmp_by_name, \ from libglibcodegen import (Signature, type_to_gtype,
get_docstring, xml_escape, get_deprecated get_docstring, xml_escape, get_deprecated, copy_into_gvalue)
NS_TP = "http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0" NS_TP = "http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0"
...@@ -74,18 +74,12 @@ class Generator(object): ...@@ -74,18 +74,12 @@ class Generator(object):
self.guard = opts.get('--guard', None) self.guard = opts.get('--guard', None)
def h(self, s): def h(self, s):
if isinstance(s, unicode):
s = s.encode('utf-8')
self.__header.append(s) self.__header.append(s)
def b(self, s): def b(self, s):
if isinstance(s, unicode):
s = s.encode('utf-8')
self.__body.append(s) self.__body.append(s)
def d(self, s): def d(self, s):
if isinstance(s, unicode):
s = s.encode('utf-8')
self.__docs.append(s) self.__docs.append(s)
def get_iface_quark(self): def get_iface_quark(self):
...@@ -192,6 +186,7 @@ class Generator(object): ...@@ -192,6 +186,7 @@ class Generator(object):
self.b(' TpProxySignalConnection *sc)') self.b(' TpProxySignalConnection *sc)')
self.b('{') self.b('{')
self.b(' G_GNUC_BEGIN_IGNORE_DEPRECATIONS')
self.b(' GValueArray *args = g_value_array_new (%d);' % len(args)) self.b(' GValueArray *args = g_value_array_new (%d);' % len(args))
self.b(' GValue blank = { 0 };') self.b(' GValue blank = { 0 };')
self.b(' guint i;') self.b(' guint i;')
...@@ -200,6 +195,7 @@ class Generator(object): ...@@ -200,6 +195,7 @@ class Generator(object):
self.b('') self.b('')
self.b(' for (i = 0; i < %d; i++)' % len(args)) self.b(' for (i = 0; i < %d; i++)' % len(args))
self.b(' g_value_array_append (args, &blank);') self.b(' g_value_array_append (args, &blank);')
self.b(' G_GNUC_END_IGNORE_DEPRECATIONS')
self.b('') self.b('')
for i, arg in enumerate(args): for i, arg in enumerate(args):
...@@ -209,36 +205,8 @@ class Generator(object): ...@@ -209,36 +205,8 @@ class Generator(object):
self.b(' g_value_unset (args->values + %d);' % i) self.b(' g_value_unset (args->values + %d);' % i)
self.b(' g_value_init (args->values + %d, %s);' % (i, gtype)) self.b(' g_value_init (args->values + %d, %s);' % (i, gtype))
if gtype == 'G_TYPE_STRING': self.b(' ' + copy_into_gvalue('args->values + %d' % i,
self.b(' g_value_set_string (args->values + %d, %s);' gtype, marshaller, name))
% (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('')
self.b(' tp_proxy_signal_connection_v0_take_results (sc, args);') self.b(' tp_proxy_signal_connection_v0_take_results (sc, args);')
...@@ -288,12 +256,14 @@ class Generator(object): ...@@ -288,12 +256,14 @@ class Generator(object):
self.b(' weak_object);') self.b(' weak_object);')
self.b('') self.b('')
self.b(' G_GNUC_BEGIN_IGNORE_DEPRECATIONS')
if len(args) > 0: if len(args) > 0:
self.b(' g_value_array_free (args);') self.b(' g_value_array_free (args);')
else: else:
self.b(' if (args != NULL)') self.b(' if (args != NULL)')
self.b(' g_value_array_free (args);') self.b(' g_value_array_free (args);')
self.b('') self.b('')
self.b(' G_GNUC_END_IGNORE_DEPRECATIONS')
self.b(' g_object_unref (tpproxy);') self.b(' g_object_unref (tpproxy);')
self.b('}') self.b('}')
...@@ -559,11 +529,13 @@ class Generator(object): ...@@ -559,11 +529,13 @@ class Generator(object):
self.b(' return;') self.b(' return;')
self.b(' }') self.b(' }')
self.b('') self.b('')
self.b(' G_GNUC_BEGIN_IGNORE_DEPRECATIONS')
self.b(' args = g_value_array_new (%d);' % len(out_args)) self.b(' args = g_value_array_new (%d);' % len(out_args))
self.b(' g_value_init (&blank, G_TYPE_INT);') self.b(' g_value_init (&blank, G_TYPE_INT);')
self.b('') self.b('')
self.b(' for (i = 0; i < %d; i++)' % len(out_args)) self.b(' for (i = 0; i < %d; i++)' % len(out_args))
self.b(' g_value_array_append (args, &blank);') self.b(' g_value_array_append (args, &blank);')
self.b(' G_GNUC_END_IGNORE_DEPRECATIONS')
for i, arg in enumerate(out_args): for i, arg in enumerate(out_args):
name, info, tp_type, elt = arg name, info, tp_type, elt = arg
...@@ -573,36 +545,8 @@ class Generator(object): ...@@ -573,36 +545,8 @@ class Generator(object):
self.b(' g_value_unset (args->values + %d);' % i) self.b(' g_value_unset (args->values + %d);' % i)
self.b(' g_value_init (args->values + %d, %s);' % (i, gtype)) self.b(' g_value_init (args->values + %d, %s);' % (i, gtype))
if gtype == 'G_TYPE_STRING': self.b(' ' + copy_into_gvalue('args->values + %d' % i,
self.b(' g_value_take_string (args->values + %d, %s);' gtype, marshaller, name))
% (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, ' self.b(' tp_proxy_pending_call_v0_take_results (user_data, '
'NULL, args);') 'NULL, args);')
...@@ -671,11 +615,13 @@ class Generator(object): ...@@ -671,11 +615,13 @@ class Generator(object):
self.b(' error, user_data, weak_object);') self.b(' error, user_data, weak_object);')
self.b('') self.b('')
self.b(' G_GNUC_BEGIN_IGNORE_DEPRECATIONS')
if len(out_args) > 0: if len(out_args) > 0:
self.b(' g_value_array_free (args);') self.b(' g_value_array_free (args);')
else: else:
self.b(' if (args != NULL)') self.b(' if (args != NULL)')
self.b(' g_value_array_free (args);') self.b(' g_value_array_free (args);')
self.b(' G_GNUC_END_IGNORE_DEPRECATIONS')
self.b('}') self.b('}')
self.b('') self.b('')
...@@ -948,11 +894,13 @@ class Generator(object): ...@@ -948,11 +894,13 @@ class Generator(object):
self.b('') self.b('')
self.b(' G_GNUC_BEGIN_IGNORE_DEPRECATIONS')
if len(out_args) > 0: if len(out_args) > 0:
self.b(' g_value_array_free (args);') self.b(' g_value_array_free (args);')
else: else:
self.b(' if (args != NULL)') self.b(' if (args != NULL)')
self.b(' g_value_array_free (args);') self.b(' g_value_array_free (args);')
self.b(' G_GNUC_END_IGNORE_DEPRECATIONS')
self.b('}') self.b('}')
self.b('') self.b('')
...@@ -1191,7 +1139,7 @@ class Generator(object): ...@@ -1191,7 +1139,7 @@ class Generator(object):
self.b('') self.b('')
nodes = self.dom.getElementsByTagName('node') nodes = self.dom.getElementsByTagName('node')
nodes.sort(cmp_by_name) nodes.sort(key=key_by_name)
for node in nodes: for node in nodes:
self.do_interface(node) self.do_interface(node)
...@@ -1244,9 +1192,9 @@ class Generator(object): ...@@ -1244,9 +1192,9 @@ class Generator(object):
self.h('#endif /* defined (%s) */' % self.guard) self.h('#endif /* defined (%s) */' % self.guard)
self.h('') self.h('')
file_set_contents(self.basename + '.h', '\n'.join(self.__header)) file_set_contents(self.basename + '.h', u('\n').join(self.__header).encode('utf-8'))
file_set_contents(self.basename + '-body.h', '\n'.join(self.__body)) file_set_contents(self.basename + '-body.h', u('\n').join(self.__body).encode('utf-8'))
file_set_contents(self.basename + '-gtk-doc.h', '\n'.join(self.__docs)) file_set_contents(self.basename + '-gtk-doc.h', u('\n').join(self.__docs).encode('utf-8'))
def types_to_gtypes(types): def types_to_gtypes(types):
return [type_to_gtype(t)[1] for t in types] return [type_to_gtype(t)[1] for t in types]
......
...@@ -31,23 +31,23 @@ class Generator(object): ...@@ -31,23 +31,23 @@ class Generator(object):
for signal in signals: for signal in signals:
self.do_signal(signal) self.do_signal(signal)
print 'void' print('void')
print '%s_register_dbus_glib_marshallers (void)' % self.prefix print('%s_register_dbus_glib_marshallers (void)' % self.prefix)
print '{' print('{')
all = self.marshallers.keys() all = list(self.marshallers.keys())
all.sort() all.sort()
for marshaller in all: for marshaller in all:
rhs = self.marshallers[marshaller] rhs = self.marshallers[marshaller]
print ' dbus_g_object_register_marshaller (' print(' dbus_g_object_register_marshaller (')
print ' g_cclosure_marshal_generic,' print(' g_cclosure_marshal_generic,')
print ' G_TYPE_NONE, /* return */' print(' G_TYPE_NONE, /* return */')
for type in rhs: for type in rhs:
print ' G_TYPE_%s,' % type.replace('VOID', 'NONE') print(' G_TYPE_%s,' % type.replace('VOID', 'NONE'))
print ' G_TYPE_INVALID);' print(' G_TYPE_INVALID);')
print '}' print('}')
def types_to_gtypes(types): def types_to_gtypes(types):
......
...@@ -12,13 +12,13 @@ class Generator(object): ...@@ -12,13 +12,13 @@ class Generator(object):
def __call__(self): def __call__(self):
print '{' print('{')
print ' GEnumClass *klass;' print(' GEnumClass *klass;')
print ' GEnumValue *value_by_name;' print(' GEnumValue *value_by_name;')
print ' GEnumValue *value_by_nick;' print(' GEnumValue *value_by_nick;')
print '' print('')
print ' g_type_init ();' print(' g_type_init ();')
print ' klass = g_type_class_ref (TP_TYPE_ERROR);' print(' klass = g_type_class_ref (TP_TYPE_ERROR);')
for error in self.errors.getElementsByTagNameNS(NS_TP, 'error'): for error in self.errors.getElementsByTagNameNS(NS_TP, 'error'):
ns = error.parentNode.getAttribute('namespace') ns = error.parentNode.getAttribute('namespace')
...@@ -28,30 +28,30 @@ class Generator(object): ...@@ -28,30 +28,30 @@ class Generator(object):
s = ('TP_ERROR_STR_' + s = ('TP_ERROR_STR_' +
error.getAttribute('name').replace(' ', '_').replace('.', '_').upper()) error.getAttribute('name').replace(' ', '_').replace('.', '_').upper())
print '' print('')
print ' /* %s.%s */' % (ns, nick) print(' /* %s.%s */' % (ns, nick))
print (' value_by_name = g_enum_get_value_by_name (klass, "%s");' print(' value_by_name = g_enum_get_value_by_name (klass, "%s");'
% enum) % enum)
print (' value_by_nick = g_enum_get_value_by_nick (klass, "%s");' print(' value_by_nick = g_enum_get_value_by_nick (klass, "%s");'
% nick) % nick)
print (' g_assert (value_by_name != NULL);') print(' g_assert (value_by_name != NULL);')
print (' g_assert (value_by_nick != NULL);') print(' g_assert (value_by_nick != NULL);')
print (' g_assert_cmpint (value_by_name->value, ==, %s);' print(' g_assert_cmpint (value_by_name->value, ==, %s);'
% enum) % enum)
print (' g_assert_cmpint (value_by_nick->value, ==, %s);' print(' g_assert_cmpint (value_by_nick->value, ==, %s);'
% enum) % enum)
print (' g_assert_cmpstr (value_by_name->value_name, ==, "%s");' print(' g_assert_cmpstr (value_by_name->value_name, ==, "%s");'
% enum) % enum)
print (' g_assert_cmpstr (value_by_nick->value_name, ==, "%s");' print(' g_assert_cmpstr (value_by_nick->value_name, ==, "%s");'
% enum) % enum)
print (' g_assert_cmpstr (value_by_name->value_nick, ==, "%s");' print(' g_assert_cmpstr (value_by_name->value_nick, ==, "%s");'
% nick) % nick)
print (' g_assert_cmpstr (value_by_nick->value_nick, ==, "%s");' print(' g_assert_cmpstr (value_by_nick->value_nick, ==, "%s");'
% nick) % nick)
print (' g_assert_cmpstr (%s, ==, TP_ERROR_PREFIX ".%s");' print(' g_assert_cmpstr (%s, ==, TP_ERROR_PREFIX ".%s");'
% (s, nick)) % (s, nick))
print '}' print('}')
if __name__ == '__main__': if __name__ == '__main__':
argv = sys.argv[1:] argv = sys.argv[1:]
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
import sys import sys
import xml.dom.minidom import xml.dom.minidom
from libtpcodegen import file_set_contents from libtpcodegen import file_set_contents, u
from libglibcodegen import NS_TP, get_docstring, xml_escape from libglibcodegen import NS_TP, get_docstring, xml_escape
class Generator(object): class Generator(object):
...@@ -17,18 +17,12 @@ class Generator(object): ...@@ -17,18 +17,12 @@ class Generator(object):
self.__docs = [] self.__docs = []
def h(self, s): def h(self, s):
if isinstance(s, unicode):
s = s.encode('utf-8')
self.__header.append(s) self.__header.append(s)
def b(self, s): def b(self, s):
if isinstance(s, unicode):
s = s.encode('utf-8')
self.__body.append(s) self.__body.append(s)
def d(self, s): def d(self, s):
if isinstance(s, unicode):
s = s.encode('utf-8')
self.__docs.append(s) self.__docs.append(s)
def __call__(self): def __call__(self):
...@@ -72,9 +66,9 @@ class Generator(object): ...@@ -72,9 +66,9 @@ class Generator(object):
self.h('') self.h('')
self.b('') self.b('')
file_set_contents(self.basename + '.h', '\n'.join(self.__header)) file_set_contents(self.basename + '.h', u('\n').join(self.__header).encode('utf-8'))
file_set_contents(self.basename + '.c', '\n'.join(self.__body)) file_set_contents(self.basename + '.c', u('\n').join(self.__body).encode('utf-8'))
file_set_contents(self.basename + '-gtk-doc.h', '\n'.join(self.__docs)) file_set_contents(self.basename + '-gtk-doc.h', u('\n').join(self.__docs).encode('utf-8'))
if __name__ == '__main__': if __name__ == '__main__':
argv = sys.argv[1:] argv = sys.argv[1:]
......
...@@ -26,8 +26,8 @@ import sys ...@@ -26,8 +26,8 @@ import sys
import os.path import os.path
import xml.dom.minidom import xml.dom.minidom
from libtpcodegen import file_set_contents from libtpcodegen import file_set_contents, key_by_name, u
from libglibcodegen import Signature, type_to_gtype, cmp_by_name, \ from libglibcodegen import Signature, type_to_gtype, \
NS_TP, dbus_gutils_wincaps_to_uscore NS_TP, dbus_gutils_wincaps_to_uscore
...@@ -85,18 +85,12 @@ class Generator(object): ...@@ -85,18 +85,12 @@ class Generator(object):
self.allow_havoc = allow_havoc self.allow_havoc = allow_havoc
def h(self, s): def h(self, s):
if isinstance(s, unicode):
s = s.encode('utf-8')
self.__header.append(s) self.__header.append(s)
def b(self, s): def b(self, s):
if isinstance(s, unicode):
s = s.encode('utf-8')
self.__body.append(s) self.__body.append(s)
def d(self, s): def d(self, s):
if isinstance(s, unicode):
s = s.encode('utf-8')
self.__docs.append(s) self.__docs.append(s)
def do_node(self, node): def do_node(self, node):
...@@ -733,7 +727,7 @@ class Generator(object): ...@@ -733,7 +727,7 @@ class Generator(object):
def __call__(self): def __call__(self):
nodes = self.dom.getElementsByTagName('node') nodes = self.dom.getElementsByTagName('node')
nodes.sort(cmp_by_name) nodes.sort(key=key_by_name)
self.h('#include <glib-object.h>') self.h('#include <glib-object.h>')
self.h('#include <dbus/dbus-glib.h>') self.h('#include <dbus/dbus-glib.h>')
...@@ -761,12 +755,12 @@ class Generator(object): ...@@ -761,12 +755,12 @@ class Generator(object):
self.h('') self.h('')
self.b('') self.b('')
file_set_contents(self.basename + '.h', '\n'.join(self.__header)) file_set_contents(self.basename + '.h', u('\n').join(self.__header).encode('utf-8'))
file_set_contents(self.basename + '.c', '\n'.join(self.__body)) file_set_contents(self.basename + '.c', u('\n').join(self.__body).encode('utf-8'))
file_set_contents(self.basename + '-gtk-doc.h', '\n'.join(self.__docs)) file_set_contents(self.basename + '-gtk-doc.h', u('\n').join(self.__docs).encode('utf-8'))
def cmdline_error(): def cmdline_error():
print """\ print("""\
usage: usage:
gen-ginterface [OPTIONS] xmlfile Prefix_ gen-ginterface [OPTIONS] xmlfile Prefix_
options: options:
...@@ -786,7 +780,7 @@ options: ...@@ -786,7 +780,7 @@ options:
void symbol (DBusGMethodInvocation *context) void symbol (DBusGMethodInvocation *context)
and return some sort of "not implemented" error via and return some sort of "not implemented" error via
dbus_g_method_return_error (context, ...) dbus_g_method_return_error (context, ...)
""" """)
sys.exit(1) sys.exit(1)
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
import sys import sys
import xml.dom.minidom import xml.dom.minidom
from libtpcodegen import file_set_contents from libtpcodegen import file_set_contents, u
from libglibcodegen import escape_as_identifier, \ from libglibcodegen import escape_as_identifier, \
get_docstring, \ get_docstring, \
NS_TP, \ NS_TP, \
...@@ -68,13 +68,13 @@ class GTypesGenerator(object): ...@@ -68,13 +68,13 @@ class GTypesGenerator(object):
self.need_other_arrays = {} self.need_other_arrays = {}
def h(self, code): def h(self, code):
self.header.append(code.encode("utf-8")) self.header.append(code)
def c(self, code): def c(self, code):
self.body.append(code.encode("utf-8")) self.body.append(code)
def d(self, code): def d(self, code):
self.docs.append(code.encode('utf-8')) self.docs.append(code)
def do_mapping_header(self, mapping): def do_mapping_header(self, mapping):
members = mapping.getElementsByTagNameNS(NS_TP, 'member') members = mapping.getElementsByTagNameNS(NS_TP, 'member')
...@@ -292,9 +292,9 @@ class GTypesGenerator(object): ...@@ -292,9 +292,9 @@ class GTypesGenerator(object):
self.c(' return t;\n') self.c(' return t;\n')
self.c('}\n\n') self.c('}\n\n')
file_set_contents(self.output + '.h', ''.join(self.header)) file_set_contents(self.output + '.h', u('').join(self.header).encode('utf-8'))
file_set_contents(self.output + '-body.h', ''.join(self.body)) file_set_contents(self.output + '-body.h', u('').join(self.body).encode('utf-8'))
file_set_contents(self.output + '-gtk-doc.h', ''.join(self.docs)) file_set_contents(self.output + '-gtk-doc.h', u('').join(self.docs).encode('utf-8'))
if __name__ == '__main__': if __name__ == '__main__':
argv = sys.argv[1:] argv = sys.argv[1:]
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
from sys import argv, stdout, stderr from sys import argv, stdout, stderr
import xml.dom.minidom import xml.dom.minidom
from libtpcodegen import file_set_contents from libtpcodegen import file_set_contents, u
from libglibcodegen import NS_TP, get_docstring, \ from libglibcodegen import NS_TP, get_docstring, \
get_descendant_text, get_by_path get_descendant_text, get_by_path
...@@ -24,22 +24,22 @@ class Generator(object): ...@@ -24,22 +24,22 @@ class Generator(object):
self.spec = get_by_path(dom, "spec")[0] self.spec = get_by_path(dom, "spec")[0]
def h(self, code): def h(self, code):
self.decls.append(code.encode('utf-8')) self.decls.append(code)
def c(self, code): def c(self, code):
self.impls.append(code.encode('utf-8')) self.impls.append(code)
def d(self, code): def d(self, code):
self.docs.append(code.encode('utf-8')) self.docs.append(code)
def __call__(self): def __call__(self):