sbus_codegen revision ac744223411099a862a747e7168a30255c003bf7
545805c4e49aafd8660829ddfd6ea32fea6a8f74jsl# Stef Walter <stefw@redhat.com>
545805c4e49aafd8660829ddfd6ea32fea6a8f74jsl# Copyright (C) 2014 Red Hat
545805c4e49aafd8660829ddfd6ea32fea6a8f74jsl# This program is free software; you can redistribute it and/or modify
545805c4e49aafd8660829ddfd6ea32fea6a8f74jsl# it under the terms of the GNU General Public License as published by
545805c4e49aafd8660829ddfd6ea32fea6a8f74jsl# the Free Software Foundation; either version 3 of the License, or
545805c4e49aafd8660829ddfd6ea32fea6a8f74jsl# (at your option) any later version.
545805c4e49aafd8660829ddfd6ea32fea6a8f74jsl# This program is distributed in the hope that it will be useful,
52fff662005b1866a3ff09bb6c902800c5cc6dedjerenkrantz# but WITHOUT ANY WARRANTY; without even the implied warranty of
545805c4e49aafd8660829ddfd6ea32fea6a8f74jsl# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
545805c4e49aafd8660829ddfd6ea32fea6a8f74jsl# GNU General Public License for more details.
4b5981e276e93df97c34e4da05ca5cf8bbd937dand# You should have received a copy of the GNU General Public License
545805c4e49aafd8660829ddfd6ea32fea6a8f74jsl# along with this program. If not, see <http://www.gnu.org/licenses/>.
545805c4e49aafd8660829ddfd6ea32fea6a8f74jsl# Some parser code from GLib
545805c4e49aafd8660829ddfd6ea32fea6a8f74jsl# Copyright (C) 2008-2011 Red Hat, Inc.
545805c4e49aafd8660829ddfd6ea32fea6a8f74jsl# This library is free software; you can redistribute it and/or
545805c4e49aafd8660829ddfd6ea32fea6a8f74jsl# modify it under the terms of the GNU Lesser General Public
545805c4e49aafd8660829ddfd6ea32fea6a8f74jsl# License as published by the Free Software Foundation; either
545805c4e49aafd8660829ddfd6ea32fea6a8f74jsl# version 2 of the License, or (at your option) any later version.
545805c4e49aafd8660829ddfd6ea32fea6a8f74jsl# This library is distributed in the hope that it will be useful,
545805c4e49aafd8660829ddfd6ea32fea6a8f74jsl# but WITHOUT ANY WARRANTY; without even the implied warranty of
545805c4e49aafd8660829ddfd6ea32fea6a8f74jsl# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
545805c4e49aafd8660829ddfd6ea32fea6a8f74jsl# Lesser General Public License for more details.
545805c4e49aafd8660829ddfd6ea32fea6a8f74jsl# You should have received a copy of the GNU Lesser General
545805c4e49aafd8660829ddfd6ea32fea6a8f74jsl# Public License along with this library; if not, write to the
545805c4e49aafd8660829ddfd6ea32fea6a8f74jsl# Free Software Foundation, Inc., 59 Temple Place, Suite 330,
545805c4e49aafd8660829ddfd6ea32fea6a8f74jsl# Boston, MA 02111-1307, USA.
545805c4e49aafd8660829ddfd6ea32fea6a8f74jsl# Portions by: David Zeuthen <davidz@redhat.com>
545805c4e49aafd8660829ddfd6ea32fea6a8f74jsl# DBus interfaces are defined here:
545805c4e49aafd8660829ddfd6ea32fea6a8f74jsl# http://dbus.freedesktop.org/doc/dbus-specification.html#introspection-format
545805c4e49aafd8660829ddfd6ea32fea6a8f74jsl# The introspection data format has become the standard way to represent a
545805c4e49aafd8660829ddfd6ea32fea6a8f74jsl# DBus interface. For many examples see /usr/share/dbus-1/interfaces/ on a
545805c4e49aafd8660829ddfd6ea32fea6a8f74jsl# typical linux machine.
0445a18339d45005993881420ca854143fe829bcnd# A word about annotations. These are extra flags or values that can be
545805c4e49aafd8660829ddfd6ea32fea6a8f74jsl# assigned to anything. So far, the codegen supports this annotation:
545805c4e49aafd8660829ddfd6ea32fea6a8f74jsl# - An annotation specified in the specification that tells us what C symbol
545805c4e49aafd8660829ddfd6ea32fea6a8f74jsl# to generate for a given interface or method. By default the codegen will
545805c4e49aafd8660829ddfd6ea32fea6a8f74jsl# build up a symbol name from the DBus name.
545805c4e49aafd8660829ddfd6ea32fea6a8f74jsl# -----------------------------------------------------------------------------
545805c4e49aafd8660829ddfd6ea32fea6a8f74jsl # Lets us print problems like a compiler would
545805c4e49aafd8660829ddfd6ea32fea6a8f74jsl return self.annotations.get("org.freedesktop.DBus.GLib.CSymbol", self.name)
545805c4e49aafd8660829ddfd6ea32fea6a8f74jsl# The basic types that we support marshalling right now. These
545805c4e49aafd8660829ddfd6ea32fea6a8f74jsl# are the ones we can pass as basic arguments to libdbus directly.
545805c4e49aafd8660829ddfd6ea32fea6a8f74jsl# If the dbus and sssd types are identical we pass things directly.
545805c4e49aafd8660829ddfd6ea32fea6a8f74jsl# otherwise some copying is necessary.
545805c4e49aafd8660829ddfd6ea32fea6a8f74jsl 's': ( "DBUS_TYPE_STRING", "const char *", "const char *" ),
545805c4e49aafd8660829ddfd6ea32fea6a8f74jsl 'o': ( "DBUS_TYPE_OBJECT_PATH", "const char *", "const char *" ),
c68d0ab2e06a7a736695b73205aa9a5261f659b3nd type = type[1:]
545805c4e49aafd8660829ddfd6ea32fea6a8f74jsl (self.dbus_constant, self.dbus_type, self.sssd_type) = BASIC_TYPES[type]
545805c4e49aafd8660829ddfd6ea32fea6a8f74jsl if not self.only_basic_args() and not self.use_raw_handler():
545805c4e49aafd8660829ddfd6ea32fea6a8f74jsl raise DBusXmlException("Method has complex arguments and requires " +
0445a18339d45005993881420ca854143fe829bcnd return self.annotations.get(anno, self.iface.annotations.get(anno)) == 'true'
0445a18339d45005993881420ca854143fe829bcnd raise DBusXmlException('Invalid access type %s'%self.access)
a78048ccbdb6256da15e6b0e7e95355e480c2301nd return type
4b22542f6f38567cae7873b176188a6622f67eb0fielding sig = "void (*%s)(struct sbus_request *, void *data, " % (name)
return sig
self.methods = []
self.signals = []
self.properties = []
if with_names:
if with_names:
return str
for meth in iface.methods:
return invokers
for sig in iface.signals:
if sig.args:
if sig.args:
for prop in properties:
elif prop.readable:
elif prop.writable:
if prop.readable:
if iface.methods:
if iface.signals:
if iface.properties:
if include_header:
if iface.methods:
if iface.signals:
if iface.properties:
for meth in iface.methods:
for prop in iface.properties:
for meth in iface.methods:
for sig in iface.signals:
for prop in iface.properties:
for meth in iface.methods:
self.state_stack = []
try:
if self.state == STATE_IGNORED:
elif self.cur_object and name == STATE_ANNOTATION:
elif self.state == STATE_TOP:
if name == STATE_NODE:
elif self.state == STATE_NODE:
if name == STATE_INTERFACE:
elif self.state == STATE_INTERFACE:
if name == STATE_METHOD:
elif name == STATE_SIGNAL:
elif name == STATE_PROPERTY:
elif self.state == STATE_METHOD:
elif self.state == STATE_SIGNAL:
elif self.state == STATE_PROPERTY:
elif self.state == STATE_ARG:
if options.output:
if options.output:
try: