@@ -103,7 +103,7 @@ struct ofbundle {
struct bond *bond; /* Nonnull iff more than one port. */
bool use_priority_tags; /* Use 802.1p tag for frames in VLAN 0? */
- bool protected; /* Protected port mode */
+ bool protected_; /* Protected port mode */
/* Status. */
bool floodable; /* True if no port has OFPUTIL_PC_NO_FLOOD set. */
@@ -456,7 +456,7 @@ type_run(const char *type)
bundle->vlan, bundle->trunks, bundle->cvlans,
bundle->use_priority_tags,
bundle->bond, bundle->lacp,
- bundle->floodable, bundle->protected);
+ bundle->floodable, bundle->protected_);
}
HMAP_FOR_EACH (ofport, up.hmap_node, &ofproto->up.ports) {
@@ -3049,7 +3049,7 @@ bundle_set(struct ofproto *ofproto_, void *aux,
bundle->bond = NULL;
bundle->floodable = true;
- bundle->protected = false;
+ bundle->protected_ = false;
mbridge_register_bundle(ofproto->mbridge, bundle);
}
@@ -3207,8 +3207,8 @@ bundle_set(struct ofproto *ofproto_, void *aux,
}
/* Set proteced port mode */
- if (s->protected != bundle->protected) {
- bundle->protected = s->protected;
+ if (s->protected_ != bundle->protected_) {
+ bundle->protected_ = s->protected_;
need_flush = true;
}
@@ -414,7 +414,7 @@ struct ofproto_bundle_settings {
struct lacp_settings *lacp; /* Nonnull to enable LACP. */
struct lacp_slave_settings *lacp_slaves; /* Array of n_slaves elements. */
- bool protected; /* Protected port mode */
+ bool protected_; /* Protected port mode */
};
int ofproto_bundle_register(struct ofproto *, void *aux,
@@ -50,11 +50,13 @@ modified is re-serialized as JSON on standard output.
.
.IP "\fBc\-idl\-header\fI idl\fR"
Reads \fIidl\fR and prints on standard output a C header file that
-defines a structure for each table defined by the schema.
+defines a structure for each table defined by the schema. If a column
+name in \fIidl\fR is a C++ keyword, it will be appended with an underscore.
.
.IP "\fBc\-idl\-source\fI idl\fR"
Reads \fIidl\fR and prints on standard output a C source file that
-implements C bindings for the database defined by the schema.
+implements C bindings for the database defined by the schema. If a column
+name in \fIidl\fR is a C++ keyword, it will be appended with an underscore.
.
.SS "Options"
.so lib/common.man
@@ -122,8 +122,20 @@ def cMembers(prefix, tableName, columnName, column, const, refTable=True):
def sorted_columns(table):
return sorted(table.columns.items())
+# If a column name in the schema is a C++ keyword, append an underscore
+# to the column name.
+def replace_cplusplus_keyword(schema):
+ keywords = {'class', 'default', 'delete', 'mutable', 'new', 'private',
+ 'protected', 'public'}
+
+ for tableName, table in schema.tables.items():
+ for columnName in table.columns:
+ if columnName in keywords:
+ table.columns[columnName + '_'] = table.columns.pop(columnName)
+
def printCIDLHeader(schemaFile):
schema = parseSchema(schemaFile)
+ replace_cplusplus_keyword(schema)
prefix = schema.idlPrefix
print('''\
/* Generated automatically -- do not modify! -*- buffer-read-only: t -*- */
@@ -328,6 +340,7 @@ def printEnum(type, members):
def printCIDLSource(schemaFile):
schema = parseSchema(schemaFile)
+ replace_cplusplus_keyword(schema)
prefix = schema.idlPrefix
print('''\
/* Generated automatically -- do not modify! -*- buffer-read-only: t -*- */
@@ -1273,7 +1286,7 @@ void
for x in column.type.cInitType("%s_col_%s" % (tableName, columnName), prereqs))
print("""\
[%(P)s%(T)s_COL_%(C)s] = {
- .name = "%(c)s",
+ .name = "%(column_name_in_schema)s",
.type = {
%(type)s
},
@@ -1286,7 +1299,8 @@ void
'C': columnName.upper(),
's': structName,
'mutable': mutable,
- 'type': type_init})
+ 'type': type_init,
+ 'column_name_in_schema': column.name})
print("};")
# Table classes.
@@ -1046,7 +1046,7 @@ port_configure(struct port *port)
}
/* Protected port mode */
- s.protected = cfg->protected;
+ s.protected_ = cfg->protected_;
/* Register. */
ofproto_bundle_register(port->bridge->ofproto, port, &s);
In C++, 'protected' is a keyword. This patch renames 'protected' to 'protected_' in a couple files so that C++ compiler will not get confused. Signed-off-by: Yi-Hung Wei <yihung.wei@gmail.com> --- ofproto/ofproto-dpif.c | 10 +++++----- ofproto/ofproto.h | 2 +- ovsdb/ovsdb-idlc.1 | 6 ++++-- ovsdb/ovsdb-idlc.in | 18 ++++++++++++++++-- vswitchd/bridge.c | 2 +- 5 files changed, 27 insertions(+), 11 deletions(-)