From 193e54dd621c05b940615111ff5adbbff3b83112 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Wed, 9 Dec 2015 17:43:56 +0000 Subject: Add options for not declaring conversion functions (for such cases when they are provided externally) --- slicer/slicer/parser.cpp | 22 ++++++++++++++-------- slicer/test/Jamfile.jam | 2 ++ slicer/test/conversions.h | 17 +++++++++++++++++ slicer/test/preprocessor.cpp | 3 ++- slicer/test/types.ice | 5 +++-- 5 files changed, 38 insertions(+), 11 deletions(-) create mode 100644 slicer/test/conversions.h diff --git a/slicer/slicer/parser.cpp b/slicer/slicer/parser.cpp index ab0bc88..5ea26b7 100644 --- a/slicer/slicer/parser.cpp +++ b/slicer/slicer/parser.cpp @@ -34,14 +34,20 @@ namespace Slicer { auto c = Slice::ContainedPtr::dynamicCast(dm->container()); auto conversions = getAllConversions(dm); for (const auto & conversion : conversions) { - fprintbf(cpp, "%s %s(const %s &);\n", - conversion.ExchangeType, - conversion.ConvertToExchangeFunc, - Slice::typeToString(type)); - fprintbf(cpp, "%s %s(const %s &);\n\n", - Slice::typeToString(type), - conversion.ConvertToModelFunc, - conversion.ExchangeType); + if (!AdHoc::containerContains(conversion.Options, "nodeclare")) { + if (!AdHoc::containerContains(conversion.Options, "nodeclareto")) { + fprintbf(cpp, "%s %s(const %s &);\n", + conversion.ExchangeType, + conversion.ConvertToExchangeFunc, + Slice::typeToString(type)); + } + if (!AdHoc::containerContains(conversion.Options, "nodeclarefrom")) { + fprintbf(cpp, "%s %s(const %s &);\n\n", + Slice::typeToString(type), + conversion.ConvertToModelFunc, + conversion.ExchangeType); + } + } } if (!conversions.empty()) { fprintbf(cpp, "template<>\nvoid\n"); diff --git a/slicer/test/Jamfile.jam b/slicer/test/Jamfile.jam index 7776c5d..e679a76 100644 --- a/slicer/test/Jamfile.jam +++ b/slicer/test/Jamfile.jam @@ -13,6 +13,7 @@ lib adhocutil : : : : /usr/include/adhocutil ; lib types : types.ice : + . pthread Ice IceUtil @@ -20,6 +21,7 @@ lib types : included//included included//included : : + . pthread Ice IceUtil diff --git a/slicer/test/conversions.h b/slicer/test/conversions.h new file mode 100644 index 0000000..d462fb4 --- /dev/null +++ b/slicer/test/conversions.h @@ -0,0 +1,17 @@ +#ifndef SLICER_TEST_CONVERSIONS_H +#define SLICER_TEST_CONVERSIONS_H + +#include + +namespace TestModule { + class DateTime; +} +namespace Slicer { + ::TestModule::DateTime + stringToDateTime(const std::string & in); + std::string + dateTimeToString(const ::TestModule::DateTime & in); +} + +#endif + diff --git a/slicer/test/preprocessor.cpp b/slicer/test/preprocessor.cpp index a55cdb2..435723f 100644 --- a/slicer/test/preprocessor.cpp +++ b/slicer/test/preprocessor.cpp @@ -61,8 +61,9 @@ BOOST_AUTO_TEST_CASE( slicer_test_ice ) const fs::path obj = fs::change_extension(tmp / base, ".o"); const std::string compile = stringbf( - "g++ -Os -fPIC -c -std=c++0x -fvisibility=hidden -I tmp -I /usr/include/adhocutil -I /usr/include/Ice -I /usr/include/IceUtil -I %s -I %s -I %s %s -o %s", + "g++ -Os -fPIC -c -std=c++0x -fvisibility=hidden -I tmp -I /usr/include/adhocutil -I /usr/include/Ice -I /usr/include/IceUtil -I %s -I %s -I %s -I %s %s -o %s", root / bjamout, + root, included / bjamout, root / "..", cpp, obj); diff --git a/slicer/test/types.ice b/slicer/test/types.ice index 3766342..562099b 100644 --- a/slicer/test/types.ice +++ b/slicer/test/types.ice @@ -1,4 +1,5 @@ [["cpp:include:boost/date_time/posix_time/posix_time_types.hpp"]] +[["cpp:include:conversions.h"]] #include @@ -22,7 +23,7 @@ module TestModule { }; class DateTimeContainer { [ "slicer:conversion:boost.posix_time.ptime:ptimeToDateTime:dateTimeToPTime", - "slicer:conversion:std.string:stringToDateTime:dateTimeToString" ] + "slicer:conversion:std.string:stringToDateTime:dateTimeToString:nodeclare" ] DateTime dt; IsoDate date; }; @@ -126,7 +127,7 @@ module TestModule2 { class CrossModule extends TestModule::ClassType { int anything; [ "slicer:conversion:boost.posix_time.ptime:ptimeToDateTime:dateTimeToPTime", - "slicer:conversion:std.string:stringToDateTime:dateTimeToString" ] + "slicer:conversion:std.string:stringToDateTime:dateTimeToString:nodeclare" ] TestModule::DateTime dt; TestModule::Base base; }; -- cgit v1.2.3