From patchwork Mon Aug 7 18:01:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Stringer X-Patchwork-Id: 798806 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 3xR5346V3Wz9s1h for ; Tue, 8 Aug 2017 04:02:24 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 80390B37; Mon, 7 Aug 2017 18:02:19 +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 6BD10901 for ; Mon, 7 Aug 2017 18:02:17 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 151B3400 for ; Mon, 7 Aug 2017 18:01:49 +0000 (UTC) Received: from mfilter15-d.gandi.net (mfilter15-d.gandi.net [217.70.178.143]) by relay5-d.mail.gandi.net (Postfix) with ESMTP id D3BC241C08D for ; Mon, 7 Aug 2017 20:01:47 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at mfilter15-d.gandi.net Received: from relay5-d.mail.gandi.net ([IPv6:::ffff:217.70.183.197]) by mfilter15-d.gandi.net (mfilter15-d.gandi.net [::ffff:10.0.15.180]) (amavisd-new, port 10024) with ESMTP id 8p-CLqLpyGr6 for ; Mon, 7 Aug 2017 20:01:46 +0200 (CEST) X-Originating-IP: 208.91.1.34 Received: from carno.eng.vmware.com (unknown [208.91.1.34]) (Authenticated sender: joe@ovn.org) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id 0475141C07F for ; Mon, 7 Aug 2017 20:01:45 +0200 (CEST) From: Joe Stringer To: dev@openvswitch.org Date: Mon, 7 Aug 2017 11:01:30 -0700 Message-Id: <20170807180133.19988-1-joe@ovn.org> X-Mailer: git-send-email 2.13.3 X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH 0/3] 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 (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 --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))