diff mbox

[ovs-dev,0/3] Improve C++ support for OVSDB IDL.

Message ID 20170807180133.19988-1-joe@ovn.org
State Not Applicable
Headers show

Commit Message

Joe Stringer Aug. 7, 2017, 6:01 p.m. UTC
In the OVSDB IDL, we use C++ keywords such as "new", "mutable", "class"
for variable and field names. This series adds an underscore after each
usage of these names, to improve the ability to use the IDL from C++ code.
This series focuses primarily on code that exists in the tree; To
address such problems for generated field names that come from an OVSDB
schema, a subsequent patch will still be required. For instance, the
ovs-vswitchd schema has a column named "protected". This ends up as a
field name in the generated lib/vswitch-idl.[ch] code, which causes
similar problems to those addressed by this series.

This series was tested this far using the following diff, but since not
all of the compile errors are addressed yet - specifically those
mentioned above - I'm not submitting the below with this series:


Joe Stringer (3):
  ovsdb-idl: Avoid class declaration.
  ovsdb-idl: Avoid new expression.
  ovsdb-idl: Avoid mutable type specifier.

 lib/db-ctl-base.c        |   4 +-
 lib/ovsdb-data.h         |   4 +-
 lib/ovsdb-idl-provider.h |   6 +-
 lib/ovsdb-idl.c          | 216 +++++++++++++++++++++++------------------------
 ovsdb/ovsdb-idlc.in      |   2 +-
 5 files changed, 116 insertions(+), 116 deletions(-)
diff mbox

Patch

diff --git a/include/openvswitch/automake.mk b/include/openvswitch/automake.mk
index 6bace61593ff..2bcf9c9ebedb 100644
--- a/include/openvswitch/automake.mk
+++ b/include/openvswitch/automake.mk
@@ -29,7 +29,8 @@  openvswitchinclude_HEADERS = \
        include/openvswitch/uuid.h \
        include/openvswitch/version.h \
        include/openvswitch/vconn.h \
-       include/openvswitch/vlog.h
+       include/openvswitch/vlog.h \
+       lib/vswitch-idl.h

 if HAVE_CXX
 # OVS does not use C++ itself, but it provides public header files
@@ -42,7 +43,7 @@  nodist_include_openvswitch_libcxxtest_la_SOURCES = include/openvswitch/cxxtest.c
 include/openvswitch/cxxtest.cc: include/openvswitch/automake.mk
        $(AM_V_GEN)for header in $(openvswitchinclude_HEADERS); do      \
          echo $$header;                                                \
-       done | sed 's,^include/\(.*\)$$,#include <\1>,' > $@
+       done | sed -e 's,^include/\(.*\)$$,#include <\1>,' -e 's,^lib/\(.*\)$$,#include <\1>,'  > $@
 endif

 # OVS does not use C++ itself, but it provides public header files
diff --git a/ovsdb/ovsdb-idlc.in b/ovsdb/ovsdb-idlc.in
index 9c674e7f5e80..d5562add4410 100755
--- a/ovsdb/ovsdb-idlc.in
+++ b/ovsdb/ovsdb-idlc.in
@@ -136,7 +136,11 @@  def printCIDLHeader(schemaFile):
 #include "ovsdb-data.h"
 #include "ovsdb-idl-provider.h"
 #include "smap.h"
-#include "uuid.h"''' % {'prefix': prefix.upper()})
+#include "uuid.h"
+
+#ifdef  __cplusplus
+extern "C" {
+#endif''' % {'prefix': prefix.upper()})

     for tableName, table in sorted(schema.tables.items()):
         structName = "%s%s" % (prefix, tableName.lower())
@@ -1050,6 +1054,10 @@  const char *
 {
     return "%s";
 }
+
+#ifdef  __cplusplus
+}
+#endif
 """ % (prefix, schema.version))