3 # glib-ginterface-gen.py: service-side interface generator
5 # Generate dbus-glib 0.x service GInterfaces from the Telepathy specification.
6 # The master copy of this program is in the telepathy-glib repository -
7 # please make any changes there.
9 # Copyright (C) 2006, 2007 Collabora Limited
11 # This library is free software; you can redistribute it and/or
12 # modify it under the terms of the GNU Lesser General Public
13 # License as published by the Free Software Foundation; either
14 # version 2.1 of the License, or (at your option) any later version.
16 # This library is distributed in the hope that it will be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 # Lesser General Public License for more details.
21 # You should have received a copy of the GNU Lesser General Public
22 # License along with this library; if not, write to the Free Software
23 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
27 import xml.dom.minidom
29 from libtpcodegen import file_set_contents
30 from libglibcodegen import Signature, type_to_gtype, cmp_by_name, \
31 NS_TP, dbus_gutils_wincaps_to_uscore
34 NS_TP = "http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0"
36 def get_emits_changed(node):
39 annotation.getAttribute('value')
40 for annotation in node.getElementsByTagName('annotation')
41 if annotation.getAttribute('name') == 'org.freedesktop.DBus.Property.EmitsChangedSignal'
46 class Generator(object):
48 def __init__(self, dom, prefix, basename, signal_marshal_prefix,
49 headers, end_headers, not_implemented_func,
56 assert prefix.endswith('_')
57 assert not signal_marshal_prefix.endswith('_')
59 # The main_prefix, sub_prefix thing is to get:
61 # FOO_SVC_ -> (FOO_, _SVC_)
63 # FOO_BAR/ -> (FOO_BAR_, _)
64 # FOO_BAR/SVC_ -> (FOO_BAR_, _SVC_)
67 main_prefix, sub_prefix = prefix.upper().split('/', 1)
68 prefix = prefix.replace('/', '_')
70 main_prefix, sub_prefix = prefix.upper().split('_', 1)
72 self.MAIN_PREFIX_ = main_prefix + '_'
73 self._SUB_PREFIX_ = '_' + sub_prefix
76 self.Prefix = prefix.replace('_', '')
77 self.prefix_ = prefix.lower()
78 self.PREFIX_ = prefix.upper()
80 self.basename = basename
81 self.signal_marshal_prefix = signal_marshal_prefix
82 self.headers = headers
83 self.end_headers = end_headers
84 self.not_implemented_func = not_implemented_func
85 self.allow_havoc = allow_havoc
88 if isinstance(s, unicode):
90 self.__header.append(s)
93 if isinstance(s, unicode):
98 if isinstance(s, unicode):
100 self.__docs.append(s)
102 def do_node(self, node):
103 node_name = node.getAttribute('name').replace('/', '')
104 node_name_mixed = self.node_name_mixed = node_name.replace('_', '')
105 node_name_lc = self.node_name_lc = node_name.lower()
106 node_name_uc = self.node_name_uc = node_name.upper()
108 interfaces = node.getElementsByTagName('interface')
109 assert len(interfaces) == 1, interfaces
110 interface = interfaces[0]
111 self.iface_name = interface.getAttribute('name')
113 tmp = interface.getAttribute('tp:implement-service')
117 tmp = interface.getAttribute('tp:causes-havoc')
118 if tmp and not self.allow_havoc:
119 raise AssertionError('%s is %s' % (self.iface_name, tmp))
121 iface_emits_changed = get_emits_changed(interface)
123 self.b('static const DBusGObjectInfo _%s%s_object_info;'
124 % (self.prefix_, node_name_lc))
127 methods = interface.getElementsByTagName('method')
128 signals = interface.getElementsByTagName('signal')
129 properties = interface.getElementsByTagName('property')
130 # Don't put properties in dbus-glib glue
133 self.b('struct _%s%sClass {' % (self.Prefix, node_name_mixed))
134 self.b(' GTypeInterface parent_class;')
135 for method in methods:
136 self.b(' %s %s;' % self.get_method_impl_names(method))
142 for signal in signals:
143 self.b(' %s,' % self.get_signal_const_entry(signal))
144 self.b(' N_%s_SIGNALS' % node_name_uc)
146 self.b('static guint %s_signals[N_%s_SIGNALS] = {0};'
147 % (node_name_lc, node_name_uc))
150 self.b('static void %s%s_base_init (gpointer klass);'
151 % (self.prefix_, node_name_lc))
155 self.b('%s%s_get_type (void)'
156 % (self.prefix_, node_name_lc))
158 self.b(' static GType type = 0;')
160 self.b(' if (G_UNLIKELY (type == 0))')
162 self.b(' static const GTypeInfo info = {')
163 self.b(' sizeof (%s%sClass),' % (self.Prefix, node_name_mixed))
164 self.b(' %s%s_base_init, /* base_init */'
165 % (self.prefix_, node_name_lc))
166 self.b(' NULL, /* base_finalize */')
167 self.b(' NULL, /* class_init */')
168 self.b(' NULL, /* class_finalize */')
169 self.b(' NULL, /* class_data */')
171 self.b(' 0, /* n_preallocs */')
172 self.b(' NULL /* instance_init */')
175 self.b(' type = g_type_register_static (G_TYPE_INTERFACE,')
176 self.b(' "%s%s", &info, 0);' % (self.Prefix, node_name_mixed))
179 self.b(' return type;')
184 self.d(' * %s%s:' % (self.Prefix, node_name_mixed))
186 self.d(' * Dummy typedef representing any implementation of this '
190 self.h('typedef struct _%s%s %s%s;'
191 % (self.Prefix, node_name_mixed, self.Prefix, node_name_mixed))
195 self.d(' * %s%sClass:' % (self.Prefix, node_name_mixed))
197 self.d(' * The class of %s%s.' % (self.Prefix, node_name_mixed))
201 self.d(' * In a full implementation of this interface (i.e. all')
202 self.d(' * methods implemented), the interface initialization')
203 self.d(' * function used in G_IMPLEMENT_INTERFACE() would')
204 self.d(' * typically look like this:')
206 self.d(' * <programlisting>')
207 self.d(' * static void')
208 self.d(' * implement_%s (gpointer klass,' % self.node_name_lc)
209 self.d(' * gpointer unused G_GNUC_UNUSED)')
211 self.d(' * #define IMPLEMENT(x) %s%s_implement_##x (\\'
212 % (self.prefix_, self.node_name_lc))
213 self.d(' * klass, my_object_##x)')
215 for method in methods:
216 class_member_name = method.getAttribute('tp:name-for-bindings')
217 class_member_name = class_member_name.lower()
218 self.d(' * IMPLEMENT (%s);' % class_member_name)
220 self.d(' * #undef IMPLEMENT')
222 self.d(' * </programlisting>')
224 self.d(' * This interface has no D-Bus methods, so an')
225 self.d(' * implementation can typically pass %NULL to')
226 self.d(' * G_IMPLEMENT_INTERFACE() as the interface')
227 self.d(' * initialization function.')
232 self.h('typedef struct _%s%sClass %s%sClass;'
233 % (self.Prefix, node_name_mixed, self.Prefix, node_name_mixed))
235 self.h('GType %s%s_get_type (void);'
236 % (self.prefix_, node_name_lc))
238 gtype = self.current_gtype = \
239 self.MAIN_PREFIX_ + 'TYPE' + self._SUB_PREFIX_ + node_name_uc
240 classname = self.Prefix + node_name_mixed
242 self.h('#define %s \\\n (%s%s_get_type ())'
243 % (gtype, self.prefix_, node_name_lc))
244 self.h('#define %s%s(obj) \\\n'
245 ' (G_TYPE_CHECK_INSTANCE_CAST((obj), %s, %s))'
246 % (self.PREFIX_, node_name_uc, gtype, classname))
247 self.h('#define %sIS%s%s(obj) \\\n'
248 ' (G_TYPE_CHECK_INSTANCE_TYPE((obj), %s))'
249 % (self.MAIN_PREFIX_, self._SUB_PREFIX_, node_name_uc, gtype))
250 self.h('#define %s%s_GET_CLASS(obj) \\\n'
251 ' (G_TYPE_INSTANCE_GET_INTERFACE((obj), %s, %sClass))'
252 % (self.PREFIX_, node_name_uc, gtype, classname))
258 for method in methods:
259 self.do_method(method)
261 for signal in signals:
262 base_init_code.extend(self.do_signal(signal))
264 self.b('static inline void')
265 self.b('%s%s_base_init_once (gpointer klass G_GNUC_UNUSED)'
266 % (self.prefix_, node_name_lc))
270 self.b(' static TpDBusPropertiesMixinPropInfo properties[%d] = {'
271 % (len(properties) + 1))
274 access = m.getAttribute('access')
275 assert access in ('read', 'write', 'readwrite')
278 flags = 'TP_DBUS_PROPERTIES_MIXIN_FLAG_READ'
279 elif access == 'write':
280 flags = 'TP_DBUS_PROPERTIES_MIXIN_FLAG_WRITE'
282 flags = ('TP_DBUS_PROPERTIES_MIXIN_FLAG_READ | '
283 'TP_DBUS_PROPERTIES_MIXIN_FLAG_WRITE')
285 prop_emits_changed = get_emits_changed(m)
287 if prop_emits_changed is None:
288 prop_emits_changed = iface_emits_changed
290 if prop_emits_changed == 'true':
291 flags += ' | TP_DBUS_PROPERTIES_MIXIN_FLAG_EMITS_CHANGED'
292 elif prop_emits_changed == 'invalidates':
293 flags += ' | TP_DBUS_PROPERTIES_MIXIN_FLAG_EMITS_INVALIDATED'
295 self.b(' { 0, %s, "%s", 0, NULL, NULL }, /* %s */'
296 % (flags, m.getAttribute('type'), m.getAttribute('name')))
298 self.b(' { 0, 0, NULL, 0, NULL, NULL }')
300 self.b(' static TpDBusPropertiesMixinIfaceInfo interface =')
301 self.b(' { 0, properties, NULL, NULL };')
305 self.b(' dbus_g_object_type_install_info (%s%s_get_type (),'
306 % (self.prefix_, node_name_lc))
307 self.b(' &_%s%s_object_info);'
308 % (self.prefix_, node_name_lc))
312 self.b(' interface.dbus_interface = g_quark_from_static_string '
313 '("%s");' % self.iface_name)
315 for i, m in enumerate(properties):
316 self.b(' properties[%d].name = g_quark_from_static_string ("%s");'
317 % (i, m.getAttribute('name')))
318 self.b(' properties[%d].type = %s;'
319 % (i, type_to_gtype(m.getAttribute('type'))[1]))
321 self.b(' tp_svc_interface_set_dbus_properties_info (%s, &interface);'
322 % self.current_gtype)
326 for s in base_init_code:
330 self.b('static void')
331 self.b('%s%s_base_init (gpointer klass)'
332 % (self.prefix_, node_name_lc))
334 self.b(' static gboolean initialized = FALSE;')
336 self.b(' if (!initialized)')
338 self.b(' initialized = TRUE;')
339 self.b(' %s%s_base_init_once (klass);'
340 % (self.prefix_, node_name_lc))
342 # insert anything we need to do per implementation here
347 self.b('static const DBusGMethodInfo _%s%s_methods[] = {'
348 % (self.prefix_, node_name_lc))
350 method_blob, offsets = self.get_method_glue(methods)
352 for method, offset in zip(methods, offsets):
353 self.do_method_glue(method, offset)
355 if len(methods) == 0:
356 # empty arrays are a gcc extension, so put in a dummy member
357 self.b(" { NULL, NULL, 0 }")
362 self.b('static const DBusGObjectInfo _%s%s_object_info = {'
363 % (self.prefix_, node_name_lc))
364 self.b(' 0,') # version
365 self.b(' _%s%s_methods,' % (self.prefix_, node_name_lc))
366 self.b(' %d,' % len(methods))
367 self.b('"' + method_blob.replace('\0', '\\0') + '",')
368 self.b('"' + self.get_signal_glue(signals).replace('\0', '\\0') + '",')
370 self.get_property_glue(glue_properties).replace('\0', '\\0') +
375 self.node_name_mixed = None
376 self.node_name_lc = None
377 self.node_name_uc = None
379 def get_method_glue(self, methods):
383 for method in methods:
384 offsets.append(len(''.join(info)))
386 info.append(self.iface_name + '\0')
387 info.append(method.getAttribute('name') + '\0')
389 info.append('A\0') # async
392 for arg in method.getElementsByTagName('arg'):
393 out = arg.getAttribute('direction') == 'out'
395 name = arg.getAttribute('name')
398 name = 'arg%u' % counter
401 info.append(name + '\0')
409 info.append('F\0') # not const
410 info.append('N\0') # not error or return
411 info.append(arg.getAttribute('type') + '\0')
415 return ''.join(info) + '\0', offsets
417 def do_method_glue(self, method, offset):
418 lc_name = method.getAttribute('tp:name-for-bindings')
419 if method.getAttribute('name') != lc_name.replace('_', ''):
420 raise AssertionError('Method %s tp:name-for-bindings (%s) does '
421 'not match' % (method.getAttribute('name'), lc_name))
422 lc_name = lc_name.lower()
424 marshaller = 'g_cclosure_marshal_generic'
425 wrapper = self.prefix_ + self.node_name_lc + '_' + lc_name
427 self.b(" { (GCallback) %s, %s, %d }," % (wrapper, marshaller, offset))
429 def get_signal_glue(self, signals):
432 for signal in signals:
433 info.append(self.iface_name)
434 info.append(signal.getAttribute('name'))
436 return '\0'.join(info) + '\0\0'
438 # the implementation can be the same
439 get_property_glue = get_signal_glue
441 def get_method_impl_names(self, method):
442 dbus_method_name = method.getAttribute('name')
444 class_member_name = method.getAttribute('tp:name-for-bindings')
445 if dbus_method_name != class_member_name.replace('_', ''):
446 raise AssertionError('Method %s tp:name-for-bindings (%s) does '
447 'not match' % (dbus_method_name, class_member_name))
448 class_member_name = class_member_name.lower()
450 stub_name = (self.prefix_ + self.node_name_lc + '_' +
452 return (stub_name + '_impl', class_member_name + '_cb')
454 def do_method(self, method):
455 assert self.node_name_mixed is not None
459 # Examples refer to Thing.DoStuff (su) -> ii
462 dbus_method_name = method.getAttribute('name')
464 class_member_name = method.getAttribute('tp:name-for-bindings')
465 if dbus_method_name != class_member_name.replace('_', ''):
466 raise AssertionError('Method %s tp:name-for-bindings (%s) does '
467 'not match' % (dbus_method_name, class_member_name))
468 class_member_name = class_member_name.lower()
470 # void tp_svc_thing_do_stuff (TpSvcThing *, const char *, guint,
471 # DBusGMethodInvocation *);
472 stub_name = (self.prefix_ + self.node_name_lc + '_' +
474 # typedef void (*tp_svc_thing_do_stuff_impl) (TpSvcThing *,
475 # const char *, guint, DBusGMethodInvocation);
476 impl_name = stub_name + '_impl'
477 # void tp_svc_thing_return_from_do_stuff (DBusGMethodInvocation *,
479 ret_name = (self.prefix_ + self.node_name_lc + '_return_from_' +
485 for i in method.getElementsByTagName('arg'):
486 name = i.getAttribute('name')
487 direction = i.getAttribute('direction') or 'in'
488 dtype = i.getAttribute('type')
490 assert direction in ('in', 'out')
493 name = direction + '_' + name
494 elif direction == 'in':
495 name = direction + str(len(in_args))
497 name = direction + str(len(out_args))
499 ctype, gtype, marshaller, pointer = type_to_gtype(dtype)
502 ctype = 'const ' + ctype
504 struct = (ctype, name)
506 if direction == 'in':
507 in_args.append(struct)
509 out_args.append(struct)
511 # Implementation type declaration (in header, docs separated)
513 self.d(' * %s:' % impl_name)
514 self.d(' * @self: The object implementing this interface')
515 for (ctype, name) in in_args:
516 self.d(' * @%s: %s (FIXME, generate documentation)'
518 self.d(' * @context: Used to return values or throw an error')
520 self.d(' * The signature of an implementation of the D-Bus method')
521 self.d(' * %s on interface %s.' % (dbus_method_name, self.iface_name))
524 self.h('typedef void (*%s) (%s%s *self,'
525 % (impl_name, self.Prefix, self.node_name_mixed))
526 for (ctype, name) in in_args:
527 self.h(' %s%s,' % (ctype, name))
528 self.h(' DBusGMethodInvocation *context);')
530 # Class member (in class definition)
531 in_class.append(' %s %s;' % (impl_name, class_member_name))
533 # Stub definition (in body only - it's static)
534 self.b('static void')
535 self.b('%s (%s%s *self,'
536 % (stub_name, self.Prefix, self.node_name_mixed))
537 for (ctype, name) in in_args:
538 self.b(' %s%s,' % (ctype, name))
539 self.b(' DBusGMethodInvocation *context)')
541 self.b(' %s impl = (%s%s_GET_CLASS (self)->%s_cb);'
542 % (impl_name, self.PREFIX_, self.node_name_uc, class_member_name))
544 self.b(' if (impl != NULL)')
545 tmp = ['self'] + [name for (ctype, name) in in_args] + ['context']
547 self.b(' (impl) (%s);' % ',\n '.join(tmp))
551 if self.not_implemented_func:
552 self.b(' %s (context);' % self.not_implemented_func)
554 self.b(' GError e = { DBUS_GERROR, ')
555 self.b(' DBUS_GERROR_UNKNOWN_METHOD,')
556 self.b(' "Method not implemented" };')
558 self.b(' dbus_g_method_return_error (context, &e);')
563 # Implementation registration (in both header and body)
564 self.h('void %s%s_implement_%s (%s%sClass *klass, %s impl);'
565 % (self.prefix_, self.node_name_lc, class_member_name,
566 self.Prefix, self.node_name_mixed, impl_name))
569 self.d(' * %s%s_implement_%s:'
570 % (self.prefix_, self.node_name_lc, class_member_name))
571 self.d(' * @klass: A class whose instances implement this interface')
572 self.d(' * @impl: A callback used to implement the %s D-Bus method'
575 self.d(' * Register an implementation for the %s method in the vtable'
577 self.d(' * of an implementation of this interface. To be called from')
578 self.d(' * the interface init function.')
582 self.b('%s%s_implement_%s (%s%sClass *klass, %s impl)'
583 % (self.prefix_, self.node_name_lc, class_member_name,
584 self.Prefix, self.node_name_mixed, impl_name))
586 self.b(' klass->%s_cb = impl;' % class_member_name)
590 # Return convenience function (static inline, in header)
592 self.d(' * %s:' % ret_name)
593 self.d(' * @context: The D-Bus method invocation context')
594 for (ctype, name) in out_args:
595 self.d(' * @%s: %s (FIXME, generate documentation)'
598 self.d(' * Return successfully by calling dbus_g_method_return().')
599 self.d(' * This inline function exists only to provide type-safety.')
603 tmp = (['DBusGMethodInvocation *context'] +
604 [ctype + name for (ctype, name) in out_args])
605 self.h('static inline')
606 self.h('/* this comment is to stop gtkdoc realising this is static */')
607 self.h(('void %s (' % ret_name) + (',\n '.join(tmp)) + ');')
608 self.h('static inline void')
609 self.h(('%s (' % ret_name) + (',\n '.join(tmp)) + ')')
611 tmp = ['context'] + [name for (ctype, name) in out_args]
612 self.h(' dbus_g_method_return (' + ',\n '.join(tmp) + ');')
618 def get_signal_const_entry(self, signal):
619 assert self.node_name_uc is not None
620 return ('SIGNAL_%s_%s'
621 % (self.node_name_uc, signal.getAttribute('name')))
623 def do_signal(self, signal):
624 assert self.node_name_mixed is not None
628 # for signal: Thing::StuffHappened (s, u)
630 # void tp_svc_thing_emit_stuff_happened (gpointer instance,
631 # const char *arg0, guint arg1);
633 dbus_name = signal.getAttribute('name')
635 ugly_name = signal.getAttribute('tp:name-for-bindings')
636 if dbus_name != ugly_name.replace('_', ''):
637 raise AssertionError('Signal %s tp:name-for-bindings (%s) does '
638 'not match' % (dbus_name, ugly_name))
640 stub_name = (self.prefix_ + self.node_name_lc + '_emit_' +
643 const_name = self.get_signal_const_entry(signal)
647 for i in signal.getElementsByTagName('arg'):
648 name = i.getAttribute('name')
649 dtype = i.getAttribute('type')
650 tp_type = i.getAttribute('tp:type')
655 name = 'arg' + str(len(args))
657 ctype, gtype, marshaller, pointer = type_to_gtype(dtype)
660 ctype = 'const ' + ctype
662 struct = (ctype, name, gtype)
665 tmp = (['gpointer instance'] +
666 [ctype + name for (ctype, name, gtype) in args])
668 self.h(('void %s (' % stub_name) + (',\n '.join(tmp)) + ');')
673 self.d(' * %s:' % stub_name)
674 self.d(' * @instance: The object implementing this interface')
675 for (ctype, name, gtype) in args:
676 self.d(' * @%s: %s (FIXME, generate documentation)'
679 self.d(' * Type-safe wrapper around g_signal_emit to emit the')
680 self.d(' * %s signal on interface %s.'
681 % (dbus_name, self.iface_name))
685 self.b(('%s (' % stub_name) + (',\n '.join(tmp)) + ')')
687 self.b(' g_assert (instance != NULL);')
688 self.b(' g_assert (G_TYPE_CHECK_INSTANCE_TYPE (instance, %s));'
689 % (self.current_gtype))
690 tmp = (['instance', '%s_signals[%s]' % (self.node_name_lc, const_name),
691 '0'] + [name for (ctype, name, gtype) in args])
692 self.b(' g_signal_emit (' + ',\n '.join(tmp) + ');')
696 signal_name = dbus_gutils_wincaps_to_uscore(dbus_name).replace('_',
700 self.d(' * %s%s::%s:'
701 % (self.Prefix, self.node_name_mixed, signal_name))
702 self.d(' * @self: an object')
703 for (ctype, name, gtype) in args:
704 self.d(' * @%s: %s (FIXME, generate documentation)'
707 self.d(' * The %s D-Bus signal is emitted whenever '
708 'this GObject signal is.' % dbus_name)
712 in_base_init.append(' %s_signals[%s] ='
713 % (self.node_name_lc, const_name))
714 in_base_init.append(' g_signal_new ("%s",' % signal_name)
715 in_base_init.append(' G_OBJECT_CLASS_TYPE (klass),')
716 in_base_init.append(' G_SIGNAL_RUN_LAST|G_SIGNAL_DETAILED,')
717 in_base_init.append(' 0,')
718 in_base_init.append(' NULL, NULL,')
719 in_base_init.append(' g_cclosure_marshal_generic,')
720 in_base_init.append(' G_TYPE_NONE,')
721 tmp = ['%d' % len(args)] + [gtype for (ctype, name, gtype) in args]
722 in_base_init.append(' %s);' % ',\n '.join(tmp))
723 in_base_init.append('')
727 def have_properties(self, nodes):
729 interface = node.getElementsByTagName('interface')[0]
730 if interface.getElementsByTagName('property'):
735 nodes = self.dom.getElementsByTagName('node')
736 nodes.sort(cmp_by_name)
738 self.h('#include <glib-object.h>')
739 self.h('#include <dbus/dbus-glib.h>')
741 for header in self.headers:
742 self.h('#include %s' % header)
746 self.h('G_BEGIN_DECLS')
749 self.b('#include "%s.h"' % self.basename)
756 self.h('G_END_DECLS')
759 for header in self.end_headers:
760 self.b('#include %s' % header)
764 file_set_contents(self.basename + '.h', '\n'.join(self.__header))
765 file_set_contents(self.basename + '.c', '\n'.join(self.__body))
766 file_set_contents(self.basename + '-gtk-doc.h', '\n'.join(self.__docs))
771 gen-ginterface [OPTIONS] xmlfile Prefix_
773 --include='<header.h>' (may be repeated)
774 --include='"header.h"' (ditto)
775 --include-end='"header.h"' (ditto)
776 Include extra headers in the generated .c file
777 --signal-marshal-prefix='prefix'
778 Use the given prefix on generated signal marshallers (default is
780 --filename='BASENAME'
781 Set the basename for the output files (default is prefix.lower()
783 --not-implemented-func='symbol'
784 Set action when methods not implemented in the interface vtable are
785 called. symbol must have signature
786 void symbol (DBusGMethodInvocation *context)
787 and return some sort of "not implemented" error via
788 dbus_g_method_return_error (context, ...)
793 if __name__ == '__main__':
794 from getopt import gnu_getopt
796 options, argv = gnu_getopt(sys.argv[1:], '',
797 ['filename=', 'signal-marshal-prefix=',
798 'include=', 'include-end=',
800 'not-implemented-func='])
807 basename = prefix.lower() + 'ginterfaces'
808 signal_marshal_prefix = prefix.lower().rstrip('_')
811 not_implemented_func = ''
814 for option, value in options:
815 if option == '--filename':
817 elif option == '--signal-marshal-prefix':
818 signal_marshal_prefix = value
819 elif option == '--include':
820 if value[0] not in '<"':
821 value = '"%s"' % value
822 headers.append(value)
823 elif option == '--include-end':
824 if value[0] not in '<"':
825 value = '"%s"' % value
826 end_headers.append(value)
827 elif option == '--not-implemented-func':
828 not_implemented_func = value
829 elif option == '--allow-unstable':
833 dom = xml.dom.minidom.parse(argv[0])
837 Generator(dom, prefix, basename, signal_marshal_prefix, headers,
838 end_headers, not_implemented_func, allow_havoc)()