generated by the C bindings. It should include the bracketing
\fB""\fR or \fB<>\fR.
.
+.IP "\fB""\fBcDecls\fR"" member of <database-schema>"
+.IQ "\fB""\fBhDecls\fR"" member of <database-schema>"
+These optional members may specify arbitrary code to include in the
+generated \fB.c\fR or \fB.h\fR file, respectively, in each case just
+after the \fB#include\fR directives in those files.
+.
.SS "Commands"
.IP "\fBannotate\fI schema annotations\fR"
Reads \fIschema\fR, which should be a file in JSON format (ordinarily
#ifdef __cplusplus
extern "C" {
#endif
-''' % {'prefix': prefix.upper()})
+%(hDecls)s''' % {'prefix': prefix.upper(),
+ 'hDecls': schema.hDecls})
for tableName, table in sorted(schema.tables.items()):
structName = "%s%s" % (prefix, tableName.lower())
/* Generated automatically -- do not modify! -*- buffer-read-only: t -*- */
#include <config.h>
-#include %s
+#include %(header)s
#include <limits.h>
#include "ovs-thread.h"
#include "ovsdb-data.h"
#include "ovsdb-error.h"
#include "util.h"
-''' % schema.idlHeader)
+%(cDecls)s
+
+''' % {'header': schema.idlHeader,
+ 'cDecls': schema.cDecls})
# Cast functions.
for tableName, table in sorted(schema.tables.items()):
class IdlSchema(DbSchema):
- def __init__(self, name, version, tables, idlPrefix, idlHeader):
+ def __init__(self, name, version, tables, idlPrefix, idlHeader,
+ cDecls, hDecls):
DbSchema.__init__(self, name, version, tables)
self.idlPrefix = idlPrefix
self.idlHeader = idlHeader
+ self.cDecls = cDecls
+ self.hDecls = hDecls
@staticmethod
def from_json(json):
parser = ovs.db.parser.Parser(json, "IDL schema")
idlPrefix = parser.get("idlPrefix", six.string_types)
idlHeader = parser.get("idlHeader", six.string_types)
+ cDecls = parser.get_optional("cDecls", six.string_types, "")
+ hDecls = parser.get_optional("hDecls", six.string_types, "")
subjson = dict(json)
del subjson["idlPrefix"]
del subjson["idlHeader"]
+ subjson.pop("cDecls", None)
+ subjson.pop("hDecls", None)
schema = DbSchema.from_json(subjson)
return IdlSchema(schema.name, schema.version, schema.tables,
- idlPrefix, idlHeader)
+ idlPrefix, idlHeader, cDecls, hDecls)
def column_set_from_json(json, columns):