sbus_codegen revision b07852825eeb63a78e1b3863e42b3f328430da18
1008N/A# Stef Walter <stefw@redhat.com> 2362N/A# Copyright (C) 2014 Red Hat 2362N/A# This program is free software; you can redistribute it and/or modify 1008N/A# it under the terms of the GNU General Public License as published by 1008N/A# the Free Software Foundation; either version 3 of the License, or 1008N/A# (at your option) any later version. 1008N/A# This program is distributed in the hope that it will be useful, 1008N/A# but WITHOUT ANY WARRANTY; without even the implied warranty of 1008N/A# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1008N/A# GNU General Public License for more details. 1008N/A# You should have received a copy of the GNU General Public License 1008N/A# Some parser code from GLib 1008N/A# Copyright (C) 2008-2011 Red Hat, Inc. 0N/A# This library is free software; you can redistribute it and/or 0N/A# modify it under the terms of the GNU Lesser General Public 1821N/A# License as published by the Free Software Foundation; either 1821N/A# version 2 of the License, or (at your option) any later version. 1821N/A# This library is distributed in the hope that it will be useful, 1821N/A# but WITHOUT ANY WARRANTY; without even the implied warranty of 1821N/A# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 1821N/A# Lesser General Public License for more details. 1821N/A# You should have received a copy of the GNU Lesser General 1821N/A# Public License along with this library; if not, write to the 2391N/A# Free Software Foundation, Inc., 59 Temple Place, Suite 330, 1821N/A# Boston, MA 02111-1307, USA. 2391N/A# Portions by: David Zeuthen <davidz@redhat.com> 2391N/A# DBus interfaces are defined here: 1821N/A# The introspection data format has become the standard way to represent a 1821N/A# A word about annotations. These are extra flags or values that can be 1821N/A# assigned to anything. So far, the codegen supports this annotation: 1821N/A# - An annotation specified in the specification that tells us what C symbol 1008N/A# to generate for a given interface or method. By default the codegen will 1008N/A# build up a symbol name from the DBus name. 2228N/A# ----------------------------------------------------------------------------- 2402N/A # Lets us print problems like a compiler would 1821N/A# The basic types that we support marshalling right now. These 1821N/A# are the ones we can pass as basic arguments to libdbus directly. 1821N/A# If the dbus and sssd types are identical we pass things directly. 2228N/A# otherwise some copying is necessary. 2228N/A 'y': ( "DBUS_TYPE_BYTE", "uint8_t", "uint8_t" ), 2228N/A 'b': ( "DBUS_TYPE_BOOLEAN", "dbus_bool_t", "bool" ), 2228N/A 'n': ( "DBUS_TYPE_INT16", "int16_t", "int16_t" ), 2228N/A 'q': ( "DBUS_TYPE_UINT16", "uint16_t", "uint16_t" ), 2228N/A 'i': ( "DBUS_TYPE_INT32", "int32_t", "int32_t" ), 2228N/A 'u': ( "DBUS_TYPE_UINT32", "uint32_t", "uint32_t" ), 2228N/A 'x': ( "DBUS_TYPE_INT64", "int64_t", "int64_t" ), 2228N/A 't': ( "DBUS_TYPE_UINT64", "uint64_t", "uint64_t" ), 2402N/A 'd': ( "DBUS_TYPE_DOUBLE", "double", "double" ), 2402N/A 's': ( "DBUS_TYPE_STRING", "const char *", "const char *" ), 2402N/A 'o': ( "DBUS_TYPE_OBJECT_PATH", "const char *", "const char *" ), 2228N/A # If types are not identical, we can't do array (yet) 2228N/A sig = "void (*%s)(struct sbus_request *, void *data, " % (name) 1008N/A# ----------------------------------------------------------------------------- 1821N/A # NOTE: Would like to use the following syntax for this function 1821N/A # but need to wait until python3 until it is supported: 1821N/A # def out(format, *args, new_line=True) 1821N/A return "int (*%s)(struct sbus_request *%s, void *%s%s)" % \ 1947N/A out("static int invoke_%s_method(struct sbus_request *dbus_req, void *function_ptr);", signature) 1947N/A out("static int invoke_%s_method(struct sbus_request *dbus_req, void *function_ptr)", signature) 1821N/A out(" if (!sbus_request_parse_or_finish(dbus_req,") 1821N/A out(" DBUS_TYPE_ARRAY, %s, &arg_%d, &len_%d,", 1008N/A out("int %s_finish(struct sbus_request *req%s)", 1821N/A out(" return sbus_request_return_and_finish(req,") 1821N/A out("DBUS_TYPE_ARRAY, %s, &arg_%s, len_%s,", 1821N/A out(" SBUS_PROPERTY_READABLE | SBUS_PROPERTY_WRITABLE,") 3740N/A out(" sbus_invoke_get_all, /* GetAll invoker */") 1821N/A # The sbus_interface structure 1821N/A out("int %s_finish(struct sbus_request *req%s);", 1821N/A out(" struct sbus_vtable vtable; /* derive from sbus_vtable */") 2500N/A out("/* ------------------------------------------------------------------------") 1934N/A out(" * Various constants of interface and method names mostly for use by clients") 1821N/A out("/* ------------------------------------------------------------------------") 1821N/A out(" * These structures are filled in by implementors of the different") 2017N/A out(" * dbus interfaces to handle method calls.") 2017N/A out(" * Handler functions of type sbus_msg_handler_fn accept raw messages,") 1821N/A out(" * other handlers are typed appropriately. If a handler that is") 1821N/A out(" * set to NULL is invoked it will result in a") 1821N/A out(" * Handlers have a matching xxx_finish() function (unless the method has") 1821N/A out(" * accepts raw messages). These finish functions the") 1821N/A out(" * sbus_request_return_and_finish() with the appropriate arguments to") 1008N/A out(" * construct a valid reply. Once a finish function has been called, the") 1008N/A out(" * @dbus_req it was called with is freed and no longer valid.") 1821N/A out("/* ------------------------------------------------------------------------") 2020N/A out(" * These structure definitions are filled in with the information about") 2020N/A out(" * the interfaces, methods, properties and so on.") 2020N/A out(" * The actual definitions are found in the accompanying C file next") 1821N/A# ----------------------------------------------------------------------------- 1008N/A from standard XML Introspect data.") 3866N/A # Write output at end to be nice to 'make'