2
0
mirror of https://github.com/openvswitch/ovs synced 2025-10-21 14:49:41 +00:00

ovsdb-idlc: Add "cDecls" and "hDecls" IDL schema extensions.

An IDL schema is an OVSDB schema with some extra stuff in it: an idlPrefix
and an idlHeader at the top level to indicate what ovsdb-idlc needs to
generate the interface definitions.  This commit adds support for two more
optional IDL schema extensions that allow extra code to be written to the
.c and .h file that ovsdb-idlc generates.

Signed-off-by: Ben Pfaff <blp@ovn.org>
This commit is contained in:
Ben Pfaff
2016-09-07 15:23:44 -07:00
parent 8b70d82461
commit 0ea866bbc0
3 changed files with 22 additions and 5 deletions

View File

@@ -125,24 +125,31 @@ class DbSchema(object):
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):