summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorBen Pfaff <blp@ovn.org>2016-09-07 15:23:44 -0700
committerBen Pfaff <blp@ovn.org>2018-02-16 15:08:08 -0800
commit0ea866bbc0fb8cd10d2b86fa0ed6f1abd864a5b9 (patch)
treeb12efc4ec0ef4abca145616aea2371800b968d2e /python
parent8b70d82461ea104858ebd7d397ec004f6974240b (diff)
downloadopenvswitch-0ea866bbc0fb8cd10d2b86fa0ed6f1abd864a5b9.tar.gz
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>
Diffstat (limited to 'python')
-rw-r--r--python/ovs/db/schema.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/python/ovs/db/schema.py b/python/ovs/db/schema.py
index b68c19e00..5f1f6c41a 100644
--- a/python/ovs/db/schema.py
+++ b/python/ovs/db/schema.py
@@ -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):