# HG changeset patch # User Goffi # Date 1312837459 -7200 # Node ID 502489e176859eec301670db261c98ac75dd0ed4 # Parent 193fd5995430008e74e969245eb231f3dad4556f D-Bus constructor: add Constructors specific flags (--flags argument) dbus-xml constructor now as annotation flag to add Qt annotation usefull for the Qt frontend (bellaciao) diff -r 193fd5995430 -r 502489e17685 src/bridge/bridge_constructor/bridge_contructor.py --- a/src/bridge/bridge_constructor/bridge_contructor.py Thu Jul 28 03:02:31 2011 +0200 +++ b/src/bridge/bridge_constructor/bridge_contructor.py Mon Aug 08 23:04:19 2011 +0200 @@ -482,7 +482,14 @@ Constructor.__init__(self, bridge_template, options) self.template="dbus_xml_template.xml" - self.core_dest="org.goffi.sat.xml" + self.core_dest="org.goffi.sat.xml" + self.default_annotation = { 'a{ss}': 'StringDict', + 'a(sa{ss}as)': 'QList', + 'a{i(ss)}': 'HistoryT', + 'a(sss)': 'QList', + 'a{sa{s(sia{ss})}}': 'PresenceStatusT', + 'a{sa{ss}}': 'ActionResultExtDataT', + } def generateCoreSide(self): try: @@ -510,8 +517,15 @@ arg_elt = doc.createElement('arg') arg_elt.setAttribute('name', args_doc[idx][0] if args_doc.has_key(idx) else "arg_%i" % idx) arg_elt.setAttribute('type', arg) - arg_elt.setAttribute('direction', 'in' if function["type"]=='method' else 'out') + _direction = 'in' if function["type"]=='method' else 'out' + arg_elt.setAttribute('direction', _direction) new_elt.appendChild(arg_elt) + if "annotation" in self.options.flags: + if arg in self.default_annotation: + annot_elt = doc.createElement("annotation") + annot_elt.setAttribute('name', "com.trolltech.QtDBus.QtTypeName.In%d" % idx) + annot_elt.setAttribute('value', self.default_annotation[arg]) + new_elt.appendChild(annot_elt) idx+=1 if function['sig_out']: @@ -519,6 +533,12 @@ arg_elt.setAttribute('type', function['sig_out']) arg_elt.setAttribute('direction', 'out') new_elt.appendChild(arg_elt) + if "annotation" in self.options.flags: + if function['sig_out'] in self.default_annotation: + annot_elt = doc.createElement("annotation") + annot_elt.setAttribute('name', "com.trolltech.QtDBus.QtTypeName.Out0") + annot_elt.setAttribute('value', self.default_annotation[function['sig_out']]) + new_elt.appendChild(annot_elt) interface_elt.appendChild(new_elt) @@ -564,9 +584,12 @@ help=("Add debug information printing")) parser.add_option("--no_unicode", action="store_false", dest="unicode", default=True, help=("Remove unicode type protection from string results")) + parser.add_option("--flags", action="store", type="string", + help=("Constructors' specific flags, comma separated")) (self.options, args) = parser.parse_args() + self.options.flags = self.options.flags.split(',') if self.options.flags else [] return args def go(self): diff -r 193fd5995430 -r 502489e17685 src/bridge/bridge_constructor/bridge_template.ini --- a/src/bridge/bridge_constructor/bridge_template.ini Thu Jul 28 03:02:31 2011 +0200 +++ b/src/bridge/bridge_constructor/bridge_template.ini Mon Aug 08 23:04:19 2011 +0200 @@ -400,7 +400,7 @@ doc_param_0=from_jid: source JID doc_param_1=to_jid: dest JID doc_param_2=size: size of the history (0 for the whole history) -doc_return=Dict where key is timestamp (seconds this the Epoch), and value is a tuple (from_jid, to_jid) +doc_return=Dict where key is timestamp (seconds this the Epoch), and value is a tuple (from_jid, message) [addContact] type=method