sbus_codegen revision fcd8093c58638dc7c4f9cddfc97f273b94ce2ead
120N/A# Stef Walter <stefw@redhat.com> 120N/A# Copyright (C) 2014 Red Hat 120N/A# This program is free software; you can redistribute it and/or modify 120N/A# it under the terms of the GNU General Public License as published by 120N/A# the Free Software Foundation; either version 3 of the License, or 120N/A# (at your option) any later version. 120N/A# This program is distributed in the hope that it will be useful, 120N/A# but WITHOUT ANY WARRANTY; without even the implied warranty of 120N/A# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 120N/A# GNU General Public License for more details. 120N/A# You should have received a copy of the GNU General Public License 120N/A# Some parser code from GLib 120N/A# Copyright (C) 2008-2011 Red Hat, Inc. 120N/A# This library is free software; you can redistribute it and/or 1455N/A# modify it under the terms of the GNU Lesser General Public 618N/A# License as published by the Free Software Foundation; either 120N/A# version 2 of the License, or (at your option) any later version. 844N/A# This library is distributed in the hope that it will be useful, 1455N/A# but WITHOUT ANY WARRANTY; without even the implied warranty of 120N/A# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 1258N/A# Lesser General Public License for more details. 2899N/A# You should have received a copy of the GNU Lesser General 2899N/A# Public License along with this library; if not, write to the 3817N/A# Free Software Foundation, Inc., 59 Temple Place, Suite 330, 3817N/A# Boston, MA 02111-1307, USA. 120N/A# Portions by: David Zeuthen <davidz@redhat.com> 4730N/A# DBus interfaces are defined here: 4730N/A# The introspection data format has become the standard way to represent a 4730N/A# A word about annotations. These are extra flags or values that can be 4730N/A# assigned to anything. So far, the codegen supports this annotation: 4730N/A# - An annotation specified in the specification that tells us what C symbol 1455N/A# to generate for a given interface or method. By default the codegen will 120N/A# build up a symbol name from the DBus name. 4337N/A# ----------------------------------------------------------------------------- # Lets us print problems like a compiler would # ----------------------------------------------------------------------------- out(" NULL, /* no in_args */") out(" NULL, /* no out_args */") out(" NULL, /* no args */") out("const struct sbus_property_meta %s__properties[] = {", iface.c_name()) out(" SBUS_PROPERTY_READABLE | SBUS_PROPERTY_WRITABLE,") out(" SBUS_PROPERTY_READABLE,") out(" SBUS_PROPERTY_WRITABLE,") out(" NULL, /* no methods */") out(" NULL, /* no signals */") out(" NULL, /* no propetries */") out("/* The following definitions are auto-generated from %s */", basename) # The sbus_interface structure out(" struct sbus_vtable vtable; /* derive from sbus_vtable */") # TODO: Property getters and setters will go here out("/* The following declarations are auto-generated from %s */", basename) out("/* ------------------------------------------------------------------------") out(" * DBus Vtable handler structures") out(" * These structures are filled in by implementors of the different") out(" * dbus interfaces to handle method calls.") out(" * Handler functions of type sbus_msg_handler_fn accept raw messages,") out(" * other handlers will be typed appropriately. If a handler that is") out(" * set to NULL is invoked it will result in a") out("/* ------------------------------------------------------------------------") out(" * DBus Interface Metadata") out(" * These structure definitions are filled in with the information about") out(" * the interfaces, methods, properties and so on.") out(" * The actual definitions are found in the accompanying C file next") out(" * to this header.") # ----------------------------------------------------------------------------- from standard XML Introspect data.") help="'header' or 'source' (default: header)", help="Set output file name (default: stdout)", help="name of a header to #include", print >> sys.stderr, "sbus_codegen: no input file specified" print >> sys.stderr, "sbus_codegen: specify --mode=header or --mode=source" # Write output at end to be nice to 'make'