From patchwork Wed Aug 9 22:27:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Stringer X-Patchwork-Id: 800008 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xSQrY6ycQz9t2M for ; Thu, 10 Aug 2017 08:27:56 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 4498AB93; Wed, 9 Aug 2017 22:27:51 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 8958F97 for ; Wed, 9 Aug 2017 22:27:49 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [217.70.183.194]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 59351183 for ; Wed, 9 Aug 2017 22:27:49 +0000 (UTC) X-Originating-IP: 208.91.1.34 Received: from carno.eng.vmware.com (unknown [208.91.1.34]) (Authenticated sender: joe@ovn.org) by relay2-d.mail.gandi.net (Postfix) with ESMTPSA id A7D07C5A53 for ; Thu, 10 Aug 2017 00:27:47 +0200 (CEST) From: Joe Stringer To: dev@openvswitch.org Date: Wed, 9 Aug 2017 15:27:38 -0700 Message-Id: <20170809222742.3970-1-joe@ovn.org> X-Mailer: git-send-email 2.13.3 Subject: [ovs-dev] [PATCHv2 0/4] Improve C++ support for OVSDB IDL. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org 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 (4): ovsdb-idl: Avoid class declaration. ovsdb-idl: Avoid mutable type specifier. ovsdb-idl: Avoid new expression. ovsdb-idl: Rename 'old' to 'old_datum'. lib/db-ctl-base.c | 4 +- lib/ovsdb-data.h | 8 +- lib/ovsdb-idl-provider.h | 42 +++---- lib/ovsdb-idl.c | 307 ++++++++++++++++++++++++----------------------- ovsdb/ovsdb-idlc.in | 2 +- 5 files changed, 185 insertions(+), 178 deletions(-) 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))