sbus_codegen revision fcd8093c58638dc7c4f9cddfc97f273b94ce2ead
2N/A# Stef Walter <stefw@redhat.com> 2N/A# Copyright (C) 2014 Red Hat 2N/A# This program is free software; you can redistribute it and/or modify 2N/A# it under the terms of the GNU General Public License as published by 2N/A# the Free Software Foundation; either version 3 of the License, or 2N/A# (at your option) any later version. 2N/A# This program is distributed in the hope that it will be useful, 2N/A# but WITHOUT ANY WARRANTY; without even the implied warranty of 2N/A# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 2N/A# GNU General Public License for more details. 2N/A# You should have received a copy of the GNU General Public License 2N/A# Some parser code from GLib 2N/A# Copyright (C) 2008-2011 Red Hat, Inc. 2N/A# This library is free software; you can redistribute it and/or 2N/A# modify it under the terms of the GNU Lesser General Public 2N/A# License as published by the Free Software Foundation; either 2N/A# version 2 of the License, or (at your option) any later version. 2N/A# This library is distributed in the hope that it will be useful, 2N/A# but WITHOUT ANY WARRANTY; without even the implied warranty of 2N/A# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 2N/A# Lesser General Public License for more details. 2N/A# You should have received a copy of the GNU Lesser General 2N/A# Public License along with this library; if not, write to the 2N/A# Free Software Foundation, Inc., 59 Temple Place, Suite 330, 2N/A# Boston, MA 02111-1307, USA. 2N/A# Portions by: David Zeuthen <davidz@redhat.com> 2N/A# DBus interfaces are defined here: 2N/A# The introspection data format has become the standard way to represent a 2N/A# typical linux machine. 2N/A# A word about annotations. These are extra flags or values that can be 2N/A# assigned to anything. So far, the codegen supports this annotation: 2N/A# - An annotation specified in the specification that tells us what C symbol # to generate for a given interface or method. By default the codegen will # build up a symbol name from the DBus name. # ----------------------------------------------------------------------------- # 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'