From 3ce83f75bdd500a9054481bfdd2a32ce9d9e44b7 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Tue, 3 Apr 2018 18:22:09 +0100 Subject: Ice 3.7 Implements Slicer for Ice 3.7. This is largely: * Pointers are now all std::shared_ptr * libSlice isn't installed, so we build part of it into libslicer-compiler * Library name change to use Ice++11 There are a few other things, but mostly just minor language/function name compatibility changes. The compiling of libSlice is a bit of a hack, currently comprising a git submodule of Ice itself, and a few dirty defines on the command line, but appears to be functionally satisfactory if a little unpleasant. --- .gitmodules | 4 ++ Jamroot.jam | 3 +- ice | 1 + slicer/db/Jamfile.jam | 6 +-- slicer/db/sqlBinder.h | 2 +- slicer/db/sqlSource.cpp | 4 +- slicer/db/sqlSource.h | 2 +- slicer/db/testConversions.cpp | 2 +- slicer/db/testInsert.cpp | 37 +++++++++++------- slicer/db/testSelect.cpp | 16 ++++---- slicer/db/testUpdate.cpp | 16 ++++---- slicer/ice/Jamfile.jam | 6 +-- slicer/ice/serializer.cpp | 7 ++-- slicer/ice/testSpecifics.cpp | 2 +- slicer/json/Jamfile.jam | 2 - slicer/slicer/Jamfile.jam | 6 +-- slicer/slicer/modelParts.cpp | 4 +- slicer/slicer/modelParts.h | 24 ++++-------- slicer/slicer/modelPartsTypes.cpp | 4 +- slicer/slicer/modelPartsTypes.h | 12 +++--- slicer/slicer/modelPartsTypes.impl.h | 76 ++++++++++++++++++------------------ slicer/slicer/serializer.h | 10 ++--- slicer/slicer/slicer.cpp | 2 +- slicer/slicer/slicer.h | 5 +-- slicer/test/Jamfile.jam | 2 - slicer/test/classes.ice | 6 +-- slicer/test/classtype.ice | 14 +++++++ slicer/test/compilation.cpp | 28 +++++++------ slicer/test/included/Jamfile.jam | 9 ++--- slicer/test/preprocessor.cpp | 3 +- slicer/test/serializers.cpp | 55 ++++++++++++++------------ slicer/test/structs.ice | 3 +- slicer/tool/Jamfile.jam | 28 ++++++++++--- slicer/tool/parser.cpp | 2 +- slicer/xml/Jamfile.jam | 6 +-- 35 files changed, 219 insertions(+), 190 deletions(-) create mode 100644 .gitmodules create mode 160000 ice create mode 100644 slicer/test/classtype.ice diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..e0e648c --- /dev/null +++ b/.gitmodules @@ -0,0 +1,4 @@ +[submodule "ice"] + path = ice + url = https://github.com/zeroc-ice/ice + branch = 3.7 diff --git a/Jamroot.jam b/Jamroot.jam index a40d70e..d51b988 100644 --- a/Jamroot.jam +++ b/Jamroot.jam @@ -7,7 +7,8 @@ variant coverage : debug ; project : requirements - "-std=c++17 -fvisibility=hidden -fvisibility-inlines-hidden" + -DICE_CPP11_MAPPING + "-std=c++17 -fvisibility=hidden -fvisibility-inlines-hidden" "-Wl,-z,defs,--warn-once,--gc-sections" release:"-flto=2" release:"-flto=2" diff --git a/ice b/ice new file mode 160000 index 0000000..ab836be --- /dev/null +++ b/ice @@ -0,0 +1 @@ +Subproject commit ab836be545d3d1d4b320e79383dbb988426e335c diff --git a/slicer/db/Jamfile.jam b/slicer/db/Jamfile.jam index b8e45cc..cf5cca8 100644 --- a/slicer/db/Jamfile.jam +++ b/slicer/db/Jamfile.jam @@ -8,8 +8,7 @@ lib boost_system ; lib boost_filesystem ; lib boost_utf : : boost_unit_test_framework ; lib pthread ; -lib Ice ; -lib IceUtil ; +lib Ice++11 ; lib slicer-db : [ glob *.cpp : test*.cpp ] @@ -17,8 +16,7 @@ lib slicer-db : : .. pthread - Ice - IceUtil + Ice++11 dbppcore ../..//glibmm adhocutil diff --git a/slicer/db/sqlBinder.h b/slicer/db/sqlBinder.h index b4d7ac4..f7a0be6 100644 --- a/slicer/db/sqlBinder.h +++ b/slicer/db/sqlBinder.h @@ -28,7 +28,7 @@ namespace Slicer { DB::Command & command; const unsigned int idx; }; - typedef IceUtil::Handle SqlBinderPtr; + typedef std::shared_ptr SqlBinderPtr; } #endif diff --git a/slicer/db/sqlSource.cpp b/slicer/db/sqlSource.cpp index d277140..eeea99c 100644 --- a/slicer/db/sqlSource.cpp +++ b/slicer/db/sqlSource.cpp @@ -58,7 +58,9 @@ namespace Slicer { void SqlSource::set(Ice::Long & b) const { - column >> b; + int64_t cb; + column >> cb; + b = boost::numeric_cast(cb); } void diff --git a/slicer/db/sqlSource.h b/slicer/db/sqlSource.h index bf728dc..99ffabb 100644 --- a/slicer/db/sqlSource.h +++ b/slicer/db/sqlSource.h @@ -28,7 +28,7 @@ namespace Slicer { private: const DB::Column & column; }; - typedef IceUtil::Handle SqlSourcePtr; + typedef std::shared_ptr SqlSourcePtr; } #endif diff --git a/slicer/db/testConversions.cpp b/slicer/db/testConversions.cpp index 893c6ae..d19f309 100644 --- a/slicer/db/testConversions.cpp +++ b/slicer/db/testConversions.cpp @@ -10,7 +10,7 @@ namespace Slicer { ::TestDatabase::TimespanPtr timedurationToTimespan(const boost::posix_time::time_duration & td) { - return new ::TestDatabase::Timespan(SHORT(td.hours() / 24), SHORT(td.hours() % 24), SHORT(td.minutes()), SHORT(td.seconds())); + return std::make_shared<::TestDatabase::Timespan>(SHORT(td.hours() / 24), SHORT(td.hours() % 24), SHORT(td.minutes()), SHORT(td.seconds())); } DLL_PUBLIC diff --git a/slicer/db/testInsert.cpp b/slicer/db/testInsert.cpp index fec0ed7..1c9542f 100644 --- a/slicer/db/testInsert.cpp +++ b/slicer/db/testInsert.cpp @@ -10,12 +10,21 @@ #include #include +using namespace std::literals; + // LCOV_EXCL_START BOOST_TEST_DONT_PRINT_LOG_VALUE(TestModule::DateTime); BOOST_TEST_DONT_PRINT_LOG_VALUE(TestModule::IsoDate); BOOST_TEST_DONT_PRINT_LOG_VALUE(TestDatabase::Timespan); // LCOV_EXCL_STOP +namespace std { + template + ostream & operator<<(ostream & s, const IceUtil::Optional &) { + return s; + } +} + class StandardMockDatabase : public PQ::Mock { public: StandardMockDatabase() : PQ::Mock("user=postgres dbname=postgres", "pqmock", { @@ -32,7 +41,7 @@ typedef boost::shared_ptr SelectPtr; BOOST_AUTO_TEST_CASE( insert_builtins ) { auto db = DBPtr(DB::MockDatabase::openConnectionTo("pqmock")); - TestModule::BuiltInsPtr bi = new TestModule::BuiltIns(true, 4, 16, 64, 128, 1.2, 3.4, "text"); + TestModule::BuiltInsPtr bi = std::make_shared(true, 4, 16, 64, 128, 1.2, 3.4, "text"); Slicer::SerializeAny(bi, db.get(), "builtins"); auto sel = SelectPtr(db->newSelectCommand("SELECT * FROM builtins")); auto bi2 = Slicer::DeserializeAny(*sel); @@ -50,8 +59,8 @@ BOOST_AUTO_TEST_CASE( insert_seq_builtins ) { auto db = DBPtr(DB::MockDatabase::openConnectionTo("pqmock")); TestModule::BuiltInSeq bis = { - TestModule::BuiltInsPtr(new TestModule::BuiltIns(true, 5, 17, 65, 129, 2.3, 4.5, "more text")), - TestModule::BuiltInsPtr(new TestModule::BuiltIns(true, 6, 18, 66, 130, 3.4, 5.6, "even more text")) + std::make_shared(true, 5, 17, 65, 129, 2.3, 4.5, "more text"), + std::make_shared(true, 6, 18, 66, 130, 3.4, 5.6, "even more text") }; Slicer::SerializeAny(bis, db.get(), "builtins"); auto sel = SelectPtr(db->newSelectCommand("SELECT * FROM builtins ORDER BY mint")); @@ -71,8 +80,8 @@ BOOST_AUTO_TEST_CASE( autoinsert_seq_builtins ) { auto db = DBPtr(DB::MockDatabase::openConnectionTo("pqmock")); TestModule::BuiltInSeq bis = { - TestModule::BuiltInsPtr(new TestModule::BuiltIns(true, 5, 17, 0, 129, 2.3, 4.5, "more text")), - TestModule::BuiltInsPtr(new TestModule::BuiltIns(true, 6, 18, 0, 130, 3.4, 5.6, "even more text")) + std::make_shared(true, 5, 17, 0, 129, 2.3, 4.5, "more text"), + std::make_shared(true, 6, 18, 0, 130, 3.4, 5.6, "even more text") }; Slicer::SerializeAny(bis, db.get(), "builtins"); auto sel = SelectPtr(db->newSelectCommand("SELECT * FROM builtins WHERE mint IN (1, 2) ORDER BY mint")); @@ -95,8 +104,8 @@ BOOST_AUTO_TEST_CASE( fetchinsert_seq_builtins ) { auto db = DBPtr(DB::MockDatabase::openConnectionTo("pqmock")); TestModule::BuiltInSeq bis = { - TestModule::BuiltInsPtr(new TestModule::BuiltIns(true, 5, 17, 0, 129, 2.3, 4.5, "more text")), - TestModule::BuiltInsPtr(new TestModule::BuiltIns(true, 6, 18, 0, 130, 3.4, 5.6, "even more text")) + std::make_shared(true, 5, 17, 0, 129, 2.3, 4.5, "more text"), + std::make_shared(true, 6, 18, 0, 130, 3.4, 5.6, "even more text") }; Slicer::SerializeAny(bis, db.get(), "builtins"); auto sel = SelectPtr(db->newSelectCommand("SELECT * FROM builtins WHERE mint IN (3, 4) ORDER BY mint")); @@ -119,8 +128,8 @@ BOOST_AUTO_TEST_CASE( fetchinsert_seq_builtinsWithNulls ) { auto db = DBPtr(DB::MockDatabase::openConnectionTo("pqmock")); TestDatabase::BuiltInSeq bis = { - TestDatabase::BuiltInsPtr(new TestDatabase::BuiltIns(true, IceUtil::Optional(), 17, 0, 129, 2.3, 4.5, "more text")), - TestDatabase::BuiltInsPtr(new TestDatabase::BuiltIns(true, 6, 18, 0, 130, 3.4, IceUtil::Optional(), "even more text")) + std::make_shared(true, IceUtil::None, 17, 0, 129, 2.3, 4.5, "more text"s), + std::make_shared(true, 6, 18, 0, 130, 3.4, IceUtil::None, "even more text"s) }; Slicer::SerializeAny(bis, db.get(), "builtins"); auto sel = SelectPtr(db->newSelectCommand("SELECT * FROM builtins WHERE mint IN (5, 6) ORDER BY mint")); @@ -142,11 +151,11 @@ BOOST_AUTO_TEST_CASE( fetchinsert_seq_builtinsWithNulls ) BOOST_AUTO_TEST_CASE( insert_converted ) { auto db = DBPtr(DB::MockDatabase::openConnectionTo("pqmock")); - TestDatabase::SpecificTypesPtr st = new TestDatabase::SpecificTypes { - {2015, 10, 16, 19, 12, 34}, - {2015, 10, 16}, - new TestDatabase::Timespan(1, 2, 3, 4) - }; + TestDatabase::SpecificTypesPtr st = std::make_shared( + TestModule::DateTime {2015, 10, 16, 19, 12, 34}, + TestModule::IsoDate {2015, 10, 16}, + std::make_shared(1, 2, 3, 4) + ); Slicer::SerializeAny(st, db.get(), "converted"); auto sel = SelectPtr(db->newSelectCommand("SELECT * FROM converted")); auto st2 = Slicer::DeserializeAny(*sel); diff --git a/slicer/db/testSelect.cpp b/slicer/db/testSelect.cpp index e50047a..e1c2068 100644 --- a/slicer/db/testSelect.cpp +++ b/slicer/db/testSelect.cpp @@ -10,6 +10,8 @@ #include #include +using namespace std::literals; + class StandardMockDatabase : public PQ::Mock { public: StandardMockDatabase() : PQ::Mock("user=postgres dbname=postgres", "pqmock", { @@ -93,9 +95,9 @@ BOOST_AUTO_TEST_CASE( select_inherit_single ) "SELECT id a, '::TestModule::D' || CAST(id AS TEXT) tc, 200 b, 300 c, 400 d \ FROM test \ WHERE id = 2")); - auto bi = Slicer::DeserializeAny(*sel, "tc"); + auto bi = Slicer::DeserializeAny(*sel, "tc"s); BOOST_REQUIRE(bi); - auto d2 = TestModule::D2Ptr::dynamicCast(bi); + auto d2 = std::dynamic_pointer_cast(bi); BOOST_REQUIRE(d2); BOOST_REQUIRE_EQUAL(2, d2->a); BOOST_REQUIRE_EQUAL(300, d2->c); @@ -124,11 +126,11 @@ BOOST_AUTO_TEST_CASE( select_inherit_sequence ) FROM test \ WHERE id < 4 \ ORDER BY id DESC")); - auto bi = Slicer::DeserializeAny(*sel, "tc"); + auto bi = Slicer::DeserializeAny(*sel, "tc"s); BOOST_REQUIRE_EQUAL(3, bi.size()); - auto d3 = TestModule::D3Ptr::dynamicCast(bi[0]); - auto d2 = TestModule::D2Ptr::dynamicCast(bi[1]); - auto d1 = TestModule::D1Ptr::dynamicCast(bi[2]); + auto d3 = std::dynamic_pointer_cast(bi[0]); + auto d2 = std::dynamic_pointer_cast(bi[1]); + auto d1 = std::dynamic_pointer_cast(bi[2]); BOOST_REQUIRE(d3); BOOST_REQUIRE(d2); BOOST_REQUIRE(d1); @@ -264,7 +266,7 @@ BOOST_AUTO_TEST_CASE( select_null ) sel = SelectPtr(db->newSelectCommand("SELECT MAX(id) optSimple FROM test WHERE id IS NOT NULL")); oi = Slicer::DeserializeAny(*sel); BOOST_REQUIRE(oi->optSimple); - BOOST_REQUIRE_EQUAL(oi->optSimple.get(), 4); + BOOST_REQUIRE_EQUAL(*oi->optSimple, 4); sel = SelectPtr(db->newSelectCommand("SELECT MAX(id) FROM test WHERE false")); auto v = Slicer::DeserializeAny>(*sel); diff --git a/slicer/db/testUpdate.cpp b/slicer/db/testUpdate.cpp index 29115e3..f97a3f5 100644 --- a/slicer/db/testUpdate.cpp +++ b/slicer/db/testUpdate.cpp @@ -12,6 +12,8 @@ #include #include +using namespace std::literals; + class StandardMockDatabase : public PQ::Mock { public: StandardMockDatabase() : PQ::Mock("user=postgres dbname=postgres", "pqmock", { @@ -28,19 +30,19 @@ typedef boost::shared_ptr SelectPtr; BOOST_AUTO_TEST_CASE( update_builtinsNotFound ) { auto db = DBPtr(DB::MockDatabase::openConnectionTo("pqmock")); - TestModule::BuiltInsPtr ubi = new TestModule::BuiltIns(false, 5, 17, 64, 129, -1.2, -1.4, "string"); + TestModule::BuiltInsPtr ubi = std::make_shared(false, 5, 17, 64, 129, -1.2, -1.4, "string"); BOOST_REQUIRE_THROW(Slicer::SerializeAny(ubi, db.get(), "builtins"), Slicer::NoRowsFound); } BOOST_AUTO_TEST_CASE( update_builtins ) { auto db = DBPtr(DB::MockDatabase::openConnectionTo("pqmock")); - TestModule::BuiltInsPtr bi1 = new TestModule::BuiltIns(true, 4, 16, 64, 128, 1.2, 3.4, "text1"); - TestModule::BuiltInsPtr bi2 = new TestModule::BuiltIns(true, 3, 15, 63, 127, 5.2, 5.4, "text2"); + TestModule::BuiltInsPtr bi1 = std::make_shared(true, 4, 16, 64, 128, 1.2, 3.4, "text1"); + TestModule::BuiltInsPtr bi2 = std::make_shared(true, 3, 15, 63, 127, 5.2, 5.4, "text2"); Slicer::SerializeAny(bi1, db.get(), "builtins"); Slicer::SerializeAny(bi2, db.get(), "builtins"); - TestModule::BuiltInsPtr ubi = new TestModule::BuiltIns(false, 5, 17, 64, 128, -1.2, -1.4, "string"); + TestModule::BuiltInsPtr ubi = std::make_shared(false, 5, 17, 64, 128, -1.2, -1.4, "string"); Slicer::SerializeAny(ubi, db.get(), "builtins"); auto sel = SelectPtr(db->newSelectCommand("SELECT * FROM builtins ORDER BY mint DESC")); @@ -68,8 +70,8 @@ BOOST_AUTO_TEST_CASE( update_builtins_seq ) { auto db = DBPtr(DB::MockDatabase::openConnectionTo("pqmock")); TestModule::BuiltInSeq ubis { - TestModule::BuiltInsPtr(new TestModule::BuiltIns(false, 5, 17, 64, 128, -1.2, -1.4, "string")), - TestModule::BuiltInsPtr(new TestModule::BuiltIns(false, 5, 21, 63, 127, -4.2, -5.4, "string updated")) + TestModule::BuiltInsPtr(std::make_shared(false, 5, 17, 64, 128, -1.2, -1.4, "string")), + TestModule::BuiltInsPtr(std::make_shared(false, 5, 21, 63, 127, -4.2, -5.4, "string updated")) }; Slicer::SerializeAny(ubis, db.get(), "builtins"); @@ -102,7 +104,7 @@ BOOST_AUTO_TEST_CASE( update_withNulls ) BOOST_REQUIRE_EQUAL(2, bis.size()); BOOST_REQUIRE_EQUAL("string updated", *bis[0]->mstring); BOOST_REQUIRE_EQUAL("string", *bis[1]->mstring); - bis[0]->mstring = "not null"; + bis[0]->mstring = "not null"s; bis[1]->mstring = IceUtil::Optional(); bis[0]->mfloat = IceUtil::Optional(); bis[1]->mbyte = IceUtil::Optional(); diff --git a/slicer/ice/Jamfile.jam b/slicer/ice/Jamfile.jam index 75a7844..d775a4a 100644 --- a/slicer/ice/Jamfile.jam +++ b/slicer/ice/Jamfile.jam @@ -2,11 +2,10 @@ import testing ; import package ; lib pthread ; -lib Ice ; +lib Ice++11 ; lib boost_system ; lib boost_filesystem ; lib boost_utf : : boost_unit_test_framework ; -lib IceUtil ; lib adhocutil : : : : /usr/include/adhocutil ; lib slicer-ice : @@ -16,8 +15,7 @@ lib slicer-ice : boost_system boost_filesystem pthread - Ice - IceUtil + Ice++11 adhocutil ../slicer//slicer ../slicer//slicer diff --git a/slicer/ice/serializer.cpp b/slicer/ice/serializer.cpp index 981223f..a2e6f4a 100644 --- a/slicer/ice/serializer.cpp +++ b/slicer/ice/serializer.cpp @@ -1,6 +1,5 @@ #include "serializer.h" #include "Ice/Initialize.h" -#include "Ice/Stream.h" #include "Ice/Communicator.h" NAMEDFACTORY("application/ice", Slicer::IceStreamSerializer, Slicer::StreamSerializerFactory); @@ -26,9 +25,9 @@ namespace Slicer { void IceBlobSerializer::Serialize(ModelPartForRootPtr mp) { - auto s = Ice::createOutputStream(ic); + Ice::OutputStream s(ic); mp->Write(s); - s->finished(blob); + s.finished(blob); } IceStreamSerializer::IceStreamSerializer(std::ostream & os) : @@ -52,7 +51,7 @@ namespace Slicer { void IceBlobDeserializer::Deserialize(ModelPartForRootPtr mp) { - auto s = Ice::createInputStream(ic, blob); + Ice::InputStream s(ic, blob); mp->Read(s); } diff --git a/slicer/ice/testSpecifics.cpp b/slicer/ice/testSpecifics.cpp index 52a44b4..1689ed0 100644 --- a/slicer/ice/testSpecifics.cpp +++ b/slicer/ice/testSpecifics.cpp @@ -88,7 +88,7 @@ BOOST_AUTO_TEST_CASE( optionalBuiltins ) BOOST_AUTO_TEST_CASE( classes ) { - TestModule::BuiltInsPtr x = new TestModule::BuiltIns(); + TestModule::BuiltInsPtr x = std::make_shared(); x->mbool = true; x->mbyte = 14; x->mshort = 31434; diff --git a/slicer/json/Jamfile.jam b/slicer/json/Jamfile.jam index ef3c9e0..07186c8 100644 --- a/slicer/json/Jamfile.jam +++ b/slicer/json/Jamfile.jam @@ -8,7 +8,6 @@ lib jsonpp : : : : lib boost_system ; lib boost_filesystem ; lib boost_utf : : boost_unit_test_framework ; -lib IceUtil ; lib adhocutil : : : : /usr/include/adhocutil ; lib slicer-json : @@ -17,7 +16,6 @@ lib slicer-json : .. boost_system boost_filesystem - IceUtil jsonpp ../..//glibmm adhocutil diff --git a/slicer/slicer/Jamfile.jam b/slicer/slicer/Jamfile.jam index dec3934..e62a22a 100644 --- a/slicer/slicer/Jamfile.jam +++ b/slicer/slicer/Jamfile.jam @@ -1,8 +1,7 @@ import package ; lib pthread ; -lib Ice ; -lib IceUtil ; +lib Ice++11 ; lib boost_system ; lib boost_filesystem ; lib adhocutil : : : : /usr/include/adhocutil ; @@ -12,8 +11,7 @@ lib slicer : [ glob *.ice ] : pthread - Ice - IceUtil + Ice++11 boost_system adhocutil .. diff --git a/slicer/slicer/modelParts.cpp b/slicer/slicer/modelParts.cpp index 68b2597..83d7833 100644 --- a/slicer/slicer/modelParts.cpp +++ b/slicer/slicer/modelParts.cpp @@ -16,7 +16,7 @@ namespace Slicer { ModelPartPtr ModelPart::GetSubclassModelPart(const std::string &) { - return this; + return shared_from_this(); } TypeId @@ -71,7 +71,7 @@ namespace Slicer { ModelPartPtr ModelPart::GetContainedModelPart() { - return this; + return shared_from_this(); } HookCommon::HookCommon(const std::string & n) : diff --git a/slicer/slicer/modelParts.h b/slicer/slicer/modelParts.h index 36d8d48..08c1e0d 100644 --- a/slicer/slicer/modelParts.h +++ b/slicer/slicer/modelParts.h @@ -1,11 +1,9 @@ #ifndef SLICER_MODELPARTS_H #define SLICER_MODELPARTS_H -#include -#include #include -#include -#include +#include +#include #include #include #include @@ -13,14 +11,6 @@ #include namespace Slicer { - // This allows IceUtil::Handle to play nicely with boost::things - template - T * - get_pointer(const IceUtil::Handle & p) - { - return p.get(); - } - template class TValueTarget { public: @@ -75,8 +65,8 @@ namespace Slicer { class ModelPartForRootBase; class HookCommon; - typedef IceUtil::Handle ModelPartPtr; - typedef IceUtil::Handle ModelPartForRootPtr; + typedef std::shared_ptr ModelPartPtr; + typedef std::shared_ptr ModelPartForRootPtr; typedef std::unique_ptr HookCommonPtr; typedef IceUtil::Optional TypeId; @@ -128,7 +118,7 @@ namespace Slicer { const std::string name; }; - class DLL_PUBLIC ModelPart : virtual public IceUtil::Shared { + class DLL_PUBLIC ModelPart : public std::enable_shared_from_this { public: virtual ~ModelPart() = default; @@ -176,8 +166,8 @@ namespace Slicer { virtual void OnEachChild(const ChildHandler & ch) override; virtual ModelPartType GetType() const override; virtual bool IsOptional() const override; - virtual void Write(::Ice::OutputStreamPtr &) const = 0; - virtual void Read(::Ice::InputStreamPtr &) = 0; + virtual void Write(::Ice::OutputStream &) const = 0; + virtual void Read(::Ice::InputStream &) = 0; virtual ModelPartPtr GetContainedModelPart() override; ModelPartPtr mp; diff --git a/slicer/slicer/modelPartsTypes.cpp b/slicer/slicer/modelPartsTypes.cpp index 3adff5a..3b2961c 100644 --- a/slicer/slicer/modelPartsTypes.cpp +++ b/slicer/slicer/modelPartsTypes.cpp @@ -263,8 +263,8 @@ namespace Slicer { bool ModelPartForStreamBase::HasValue() const { return true; } // Stream Roots ModelPartForStreamRootBase::ModelPartForStreamRootBase(ModelPartPtr mp) : ModelPartForRootBase(mp) { } - void ModelPartForStreamRootBase::Write(Ice::OutputStreamPtr&) const { throw InvalidStreamOperation(__FUNCTION__); } - void ModelPartForStreamRootBase::Read(Ice::InputStreamPtr&) { throw InvalidStreamOperation(__FUNCTION__); } + void ModelPartForStreamRootBase::Write(Ice::OutputStream&) const { throw InvalidStreamOperation(__FUNCTION__); } + void ModelPartForStreamRootBase::Read(Ice::InputStream&) { throw InvalidStreamOperation(__FUNCTION__); } bool ModelPartForStreamRootBase::HasValue() const { return mp->HasValue(); } void ModelPartForStreamRootBase::OnEachChild(const ChildHandler & ch) { ch(GetRootName(), mp, NULL); } } diff --git a/slicer/slicer/modelPartsTypes.h b/slicer/slicer/modelPartsTypes.h index d50224d..a9b8501 100644 --- a/slicer/slicer/modelPartsTypes.h +++ b/slicer/slicer/modelPartsTypes.h @@ -25,8 +25,8 @@ namespace Slicer { const std::string & GetRootName() const override; virtual bool HasValue() const override; - void Write(::Ice::OutputStreamPtr &) const override; - void Read(::Ice::InputStreamPtr &) override; + void Write(::Ice::OutputStream &) const override; + void Read(::Ice::InputStream &) override; static const std::string rootName; @@ -206,9 +206,9 @@ namespace Slicer { }; template - class DLL_PUBLIC ModelPartForClass : public ModelPartForComplex, protected ModelPartModel > { + class DLL_PUBLIC ModelPartForClass : public ModelPartForComplex, protected ModelPartModel > { public: - typedef IceInternal::Handle element_type; + typedef std::shared_ptr element_type; ModelPartForClass(element_type * h); @@ -388,8 +388,8 @@ namespace Slicer { public: ModelPartForStreamRootBase(ModelPartPtr mp); - virtual void Write(Ice::OutputStreamPtr&) const override; - virtual void Read(Ice::InputStreamPtr&) override; + virtual void Write(Ice::OutputStream&) const override; + virtual void Read(Ice::InputStream&) override; virtual bool HasValue() const override; virtual void OnEachChild(const ChildHandler & ch) override; virtual const std::string & GetRootName() const override = 0; diff --git a/slicer/slicer/modelPartsTypes.impl.h b/slicer/slicer/modelPartsTypes.impl.h index 017d243..03af7c1 100644 --- a/slicer/slicer/modelPartsTypes.impl.h +++ b/slicer/slicer/modelPartsTypes.impl.h @@ -3,9 +3,7 @@ #include "modelPartsTypes.h" #include "common.h" -#include #include -#include #include #include #include @@ -13,13 +11,13 @@ #include #define CUSTOMMODELPARTFOR(Type, BaseModelPart, ModelPartType) \ - template<> ModelPartPtr ModelPart::CreateFor() { return new ModelPartType(nullptr); } \ - template<> ModelPartPtr ModelPart::CreateFor(Type & s) { return new ModelPartType(&s); } \ + template<> ModelPartPtr ModelPart::CreateFor() { return std::make_shared(nullptr); } \ + template<> ModelPartPtr ModelPart::CreateFor(Type & s) { return std::make_shared(&s); } \ template<> ModelPartPtr ModelPart::CreateFor(const Type & s) { return CreateFor(const_cast(s)); } \ - template<> ModelPartPtr ModelPart::CreateFor(IceUtil::Optional & s) { return new ModelPartForOptional(&s); } \ + template<> ModelPartPtr ModelPart::CreateFor(IceUtil::Optional & s) { return std::make_shared>(&s); } \ template<> ModelPartPtr ModelPart::CreateFor(const IceUtil::Optional & s) { return CreateFor(const_cast &>(s)); } \ - template<> ModelPartForRootPtr ModelPart::CreateRootFor(Type & s) { return new ModelPartForRoot(&s); } \ - template<> ModelPartForRootPtr ModelPart::CreateRootFor(IceUtil::Optional & s) { return new ModelPartForRoot >(&s); } \ + template<> ModelPartForRootPtr ModelPart::CreateRootFor(Type & s) { return std::make_shared>(&s); } \ + template<> ModelPartForRootPtr ModelPart::CreateRootFor(IceUtil::Optional & s) { return std::make_shared>>(&s); } \ template<> ModelPartForRootPtr ModelPart::CreateRootFor(const Type & s) { return CreateRootFor(const_cast(s)); } \ template<> ModelPartForRootPtr ModelPart::CreateRootFor(const IceUtil::Optional & s) { return CreateRootFor(const_cast &>(s)); } \ template class BaseModelPart; \ @@ -31,7 +29,7 @@ #define MODELPARTFORSTREAM(StreamImpl) \ namespace Slicer { \ template<> ModelPartForRootPtr ModelPart::CreateRootFor(const StreamImpl & stream) { \ - return new ModelPartForStreamRoot(const_cast(&stream)); \ + return std::make_shared>(const_cast(&stream)); \ } \ } @@ -58,16 +56,16 @@ namespace Slicer { template void - typeWrite(::Ice::OutputStreamPtr & s, const ::IceUtil::Optional & m) + typeWrite(::Ice::OutputStream & s, const ::IceUtil::Optional & m) { if constexpr (!Slicer::isLocal::value) { typedef Ice::StreamableTraits traits; typedef Ice::StreamOptionalHelper SOH; - s->startEncapsulation(); - if (m && s->writeOptional(0, SOH::optionalFormat)) { - SOH::write(s.get(), *m); + s.startEncapsulation(); + if (m && s.writeOptional(0, SOH::optionalFormat)) { + SOH::write(&s, *m); } - s->endEncapsulation(); + s.endEncapsulation(); } else { throw LocalTypeException(); @@ -76,10 +74,10 @@ namespace Slicer { template void - typeWrite(::Ice::OutputStreamPtr & s, const T & m) + typeWrite(::Ice::OutputStream & s, const T & m) { if constexpr (!Slicer::isLocal::value) { - s->write(m); + s.write(m); } else { throw LocalTypeException(); @@ -88,20 +86,20 @@ namespace Slicer { template void - typeRead(::Ice::InputStreamPtr & s, ::IceUtil::Optional & m) + typeRead(::Ice::InputStream & s, ::IceUtil::Optional & m) { if constexpr (!Slicer::isLocal::value) { typedef Ice::StreamableTraits traits; typedef Ice::StreamOptionalHelper SOH; - s->startEncapsulation(); - if (s->readOptional(0, SOH::optionalFormat)) { - m.__setIsSet(); - SOH::read(s.get(), *m); + s.startEncapsulation(); + if (s.readOptional(0, SOH::optionalFormat)) { + m = T(); + SOH::read(&s, *m); } else { m = IceUtil::None; } - s->endEncapsulation(); + s.endEncapsulation(); } else { throw LocalTypeException(); @@ -110,10 +108,10 @@ namespace Slicer { template void - typeRead(::Ice::InputStreamPtr & s, T & m) + typeRead(::Ice::InputStream & s, T & m) { if constexpr (!Slicer::isLocal::value) { - s->read(m); + s.read(m); } else { throw LocalTypeException(); @@ -121,13 +119,13 @@ namespace Slicer { } template - void ModelPartForRoot::Write(::Ice::OutputStreamPtr & s) const + void ModelPartForRoot::Write(::Ice::OutputStream & s) const { typeWrite(s, *ModelObject); } template - void ModelPartForRoot::Read(::Ice::InputStreamPtr & s) + void ModelPartForRoot::Read(::Ice::InputStream & s) { typeRead(s, *ModelObject); } @@ -171,7 +169,7 @@ namespace Slicer { bool ModelPartForConverted, M, MV>::HasValue() const { BOOST_ASSERT(this->Model); - return *this->Model; + return (bool)*this->Model; } // Function traits helpers @@ -195,7 +193,7 @@ namespace Slicer { template const T & operator()(const IceUtil::Optional & x) const { return *x; } static bool valueExists(const T &) { return true; } - static bool valueExists(const IceUtil::Optional & y) { return y; } + static bool valueExists(const IceUtil::Optional & y) { return y.has_value(); } }; template struct Coerce> { @@ -278,7 +276,7 @@ namespace Slicer { ModelPartModel >(h) { if (this->Model && *this->Model) { - modelPart = new T(&**this->Model); + modelPart = std::make_shared(&**this->Model); } } @@ -286,7 +284,7 @@ namespace Slicer { bool ModelPartForOptional::hasModel() const { BOOST_ASSERT(this->Model); - return *this->Model; + return (bool)*this->Model; } template @@ -295,7 +293,7 @@ namespace Slicer { BOOST_ASSERT(this->Model); if (!*this->Model) { *this->Model = typename T::element_type(); - modelPart = new T(&**this->Model); + modelPart = std::make_shared(&**this->Model); modelPart->Create(); } } @@ -394,7 +392,7 @@ namespace Slicer { template ModelPartPtr ModelPartForComplex::Hook::Get(T * t) const { - return new MP(t ? const_cast::type *>(&(t->*member)) : NULL); + return std::make_shared(t ? const_cast::type *>(&(t->*member)) : NULL); } template @@ -423,7 +421,7 @@ namespace Slicer { void ModelPartForClass::Create() { BOOST_ASSERT(this->Model); - *this->Model = new T(); + *this->Model = std::make_shared(); } template @@ -443,7 +441,7 @@ namespace Slicer { bool ModelPartForClass::HasValue() const { BOOST_ASSERT(this->Model); - return *this->Model; + return (bool)*this->Model; } template @@ -455,7 +453,7 @@ namespace Slicer { template ModelPartPtr ModelPartForClass::CreateModelPart(void * p) { - return new ModelPartForClass(static_cast(p)); + return std::make_shared>(static_cast(p)); } template @@ -638,7 +636,7 @@ namespace Slicer { { BOOST_ASSERT(this->Model); for (auto & pair : *this->Model) { - ch(pairName, new ModelPartForStruct(&pair), NULL); + ch(pairName, std::make_shared>(&pair), NULL); } } @@ -646,7 +644,7 @@ namespace Slicer { ChildRef ModelPartForDictionary::GetAnonChildRef(const HookFilter &) { BOOST_ASSERT(this->Model); - return ChildRef(new ModelPartForDictionaryElementInserter(this->Model)); + return ChildRef(std::make_shared>(this->Model)); } template @@ -656,7 +654,7 @@ namespace Slicer { if (!optionalCaseEq(name, pairName, matchCase)) { throw IncorrectElementName(name); } - return ChildRef(new ModelPartForDictionaryElementInserter(this->Model)); + return ChildRef(std::make_shared>(this->Model)); } template @@ -668,7 +666,7 @@ namespace Slicer { template ModelPartPtr ModelPartForDictionary::GetContainedModelPart() { - return new ModelPartForStruct(nullptr); + return std::make_shared>(nullptr); } // ModelPartForStream @@ -697,7 +695,7 @@ namespace Slicer { template ModelPartForStreamRoot::ModelPartForStreamRoot(Stream * s) : - ModelPartForStreamRootBase(new ModelPartForStream(s)) + ModelPartForStreamRootBase(std::make_shared>(s)) { } diff --git a/slicer/slicer/serializer.h b/slicer/slicer/serializer.h index fbe0bbf..5e76200 100644 --- a/slicer/slicer/serializer.h +++ b/slicer/slicer/serializer.h @@ -1,25 +1,23 @@ #ifndef SLICER_SERIALIZER_H #define SLICER_SERIALIZER_H -#include -#include #include #include #include #include namespace Slicer { - class DLL_PUBLIC Serializer : public IceUtil::Shared { + class DLL_PUBLIC Serializer { public: virtual void Serialize(ModelPartForRootPtr) = 0; }; - typedef IceUtil::Handle SerializerPtr; + typedef std::shared_ptr SerializerPtr; - class DLL_PUBLIC Deserializer : public IceUtil::Shared { + class DLL_PUBLIC Deserializer { public: virtual void Deserialize(ModelPartForRootPtr) = 0; }; - typedef IceUtil::Handle DeserializerPtr; + typedef std::shared_ptr DeserializerPtr; typedef AdHoc::Factory StreamSerializerFactory; typedef AdHoc::Factory StreamDeserializerFactory; diff --git a/slicer/slicer/slicer.cpp b/slicer/slicer/slicer.cpp index e132281..ba24faf 100644 --- a/slicer/slicer/slicer.cpp +++ b/slicer/slicer/slicer.cpp @@ -29,7 +29,7 @@ namespace Slicer { Slicer::ChildRef::operator bool() const { - return mpp; + return (bool)mpp; } const Metadata & diff --git a/slicer/slicer/slicer.h b/slicer/slicer/slicer.h index 4513ced..7d6f381 100644 --- a/slicer/slicer/slicer.h +++ b/slicer/slicer/slicer.h @@ -1,7 +1,6 @@ #ifndef SLICER_H #define SLICER_H -#include #include #include @@ -19,7 +18,7 @@ namespace Slicer { Object DeserializeAny(SerializerParams && ... sp) { - return DeserializeAnyWith(new Deserializer(sp ...)); + return DeserializeAnyWith(std::make_shared(sp ...)); } template @@ -33,7 +32,7 @@ namespace Slicer { void SerializeAny(const Object & object, SerializerParams && ... sp) { - SerializeAnyWith(object, new Serializer(sp ...)); + SerializeAnyWith(object, std::make_shared(sp ...)); } } diff --git a/slicer/test/Jamfile.jam b/slicer/test/Jamfile.jam index 9a801c4..44f9aa1 100644 --- a/slicer/test/Jamfile.jam +++ b/slicer/test/Jamfile.jam @@ -6,8 +6,6 @@ import toolset ; lib dl ; lib pthread ; -lib Ice ; -lib IceUtil ; lib boost_system ; lib boost_filesystem ; lib boost_date_time ; diff --git a/slicer/test/classes.ice b/slicer/test/classes.ice index c85f377..5a1642b 100644 --- a/slicer/test/classes.ice +++ b/slicer/test/classes.ice @@ -1,6 +1,7 @@ #ifndef SLICER_TEST_CLASSES #define SLICER_TEST_CLASSES +#include #include module TestModule { @@ -23,11 +24,6 @@ module TestModule { double mdouble; string mstring; }; - [ "slicer:custommodelpart:TestModule.AbValidator" ] - class ClassType { - int a; - int b; - }; class ClassClass { ClassType cls; StructType str; diff --git a/slicer/test/classtype.ice b/slicer/test/classtype.ice new file mode 100644 index 0000000..98ec34a --- /dev/null +++ b/slicer/test/classtype.ice @@ -0,0 +1,14 @@ +#ifndef SLICER_TEST_CLASSTYPE +#define SLICER_TEST_CLASSTYPE + +["slicer:include:conversions.h"] +module TestModule { + [ "slicer:custommodelpart:TestModule.AbValidator" ] + class ClassType { + int a; + int b; + }; +}; + +#endif + diff --git a/slicer/test/compilation.cpp b/slicer/test/compilation.cpp index ba87f06..85e13ce 100644 --- a/slicer/test/compilation.cpp +++ b/slicer/test/compilation.cpp @@ -15,19 +15,21 @@ BOOST_TEST_DONT_PRINT_LOG_VALUE(std::type_info); Slicer::ModelPartPtr mpp = Slicer::ModelPart::CreateFor(obj); \ BOOST_REQUIRE_EQUAL(Slicer::Expected, mpp->GetType()); \ \ - auto mppvalue = mpp.get(); \ - auto amppvalue = mpp.get(); \ - auto apmppvalue = mpp.get(); \ - BOOST_TEST_CHECKPOINT(typeid(*mppvalue).name()); \ - BOOST_REQUIRE_EQUAL(typeid(*mppvalue), typeid(*amppvalue)); \ - BOOST_REQUIRE_EQUAL(typeid(*mppvalue), typeid(*apmppvalue)); + BOOST_TEST_CONTEXT(#Var) { \ + auto mppvalue = mpp.get(); \ + auto amppvalue = mpp.get(); \ + auto apmppvalue = mpp.get(); \ + BOOST_TEST_CHECKPOINT(typeid(*mppvalue).name()); \ + BOOST_REQUIRE_EQUAL(typeid(*mppvalue), typeid(*amppvalue)); \ + BOOST_REQUIRE_EQUAL(typeid(*mppvalue), typeid(*apmppvalue)); \ + } #define StackTypeTest(Var, Explicit, Expected) \ TypeTest(Var, Var(), Explicit, Expected) BOOST_AUTO_TEST_CASE( compile_auto_modelpart_type_class ) { - TypeTest(TestModule::BuiltInsPtr, new TestModule::BuiltIns(), ModelPartForClass, mpt_Complex); + TypeTest(TestModule::BuiltInsPtr, std::make_shared(), ModelPartForClass, mpt_Complex); BOOST_REQUIRE_EQUAL(mpp.get(), mpp->GetContainedModelPart().get()); } @@ -143,7 +145,7 @@ BOOST_AUTO_TEST_CASE( compile_auto_modelpart_type_enum ) BOOST_AUTO_TEST_CASE( normalClassTypeId ) { - TestModule::BasePtr base = new TestModule::Base(1); + TestModule::BasePtr base = std::make_shared(1); BOOST_REQUIRE(base); auto a = Slicer::ModelPart::CreateFor(base); BOOST_REQUIRE(a); @@ -153,7 +155,7 @@ BOOST_AUTO_TEST_CASE( normalClassTypeId ) BOOST_AUTO_TEST_CASE( normalSubClassTypeId ) { - TestModule::BasePtr base = new TestModule::D1(1, 2); + TestModule::BasePtr base = std::make_shared(1, 2); BOOST_REQUIRE(base); auto a = Slicer::ModelPart::CreateFor(base); BOOST_REQUIRE(a); @@ -164,7 +166,7 @@ BOOST_AUTO_TEST_CASE( normalSubClassTypeId ) BOOST_AUTO_TEST_CASE( normalSubSubClassTypeId ) { - TestModule::BasePtr base = new TestModule::D3(1, 2, 3); + TestModule::BasePtr base = std::make_shared(1, 2, 3); BOOST_REQUIRE(base); auto a = Slicer::ModelPart::CreateFor(base); BOOST_REQUIRE(a); @@ -175,7 +177,7 @@ BOOST_AUTO_TEST_CASE( normalSubSubClassTypeId ) BOOST_AUTO_TEST_CASE( localClassTypeId ) { - Locals::LocalClassPtr base = new Locals::LocalClass(1, "One"); + Locals::LocalClassPtr base = std::make_shared(1, "One"); BOOST_REQUIRE(base); auto a = Slicer::ModelPart::CreateFor(base); BOOST_REQUIRE(a); @@ -185,7 +187,7 @@ BOOST_AUTO_TEST_CASE( localClassTypeId ) BOOST_AUTO_TEST_CASE( localSubClassTypeId ) { - Locals::LocalClassPtr base = new Locals::LocalSubClass(1, "One", 3.1); + Locals::LocalClassPtr base = std::make_shared(1, "One", 3.1); BOOST_REQUIRE(base); auto a = Slicer::ModelPart::CreateFor(base); BOOST_REQUIRE(a); @@ -196,7 +198,7 @@ BOOST_AUTO_TEST_CASE( localSubClassTypeId ) BOOST_AUTO_TEST_CASE( localSubSubClassTypeId ) { - Locals::LocalClassPtr base = new Locals::LocalSub2Class(1, "One", 3.1, 1); + Locals::LocalClassPtr base = std::make_shared(1, "One", 3.1, 1); BOOST_REQUIRE(base); auto a = Slicer::ModelPart::CreateFor(base); BOOST_REQUIRE(a); diff --git a/slicer/test/included/Jamfile.jam b/slicer/test/included/Jamfile.jam index bbf476d..a0fcac6 100644 --- a/slicer/test/included/Jamfile.jam +++ b/slicer/test/included/Jamfile.jam @@ -1,18 +1,15 @@ lib dl ; lib pthread ; -lib Ice ; -lib IceUtil ; +lib Ice++11 ; lib included : included.ice : pthread - Ice - IceUtil + Ice++11 : : pthread - Ice - IceUtil + Ice++11 . ; diff --git a/slicer/test/preprocessor.cpp b/slicer/test/preprocessor.cpp index fbf692a..ae93937 100644 --- a/slicer/test/preprocessor.cpp +++ b/slicer/test/preprocessor.cpp @@ -12,7 +12,8 @@ namespace fs = boost::filesystem; typedef std::map ComponentsCount; ComponentsCount COMPONENTS_IN_TEST_ICE = { - { "classes.ice", 4 }, + { "classtype.ice", 1 }, + { "classes.ice", 3 }, { "collections.ice", 6 }, { "enums.ice", 2 }, { "inheritance.ice", 12 }, diff --git a/slicer/test/serializers.cpp b/slicer/test/serializers.cpp index 8fee506..a94567e 100644 --- a/slicer/test/serializers.cpp +++ b/slicer/test/serializers.cpp @@ -25,6 +25,13 @@ namespace fs = boost::filesystem; // LCOV_EXCL_START BOOST_TEST_DONT_PRINT_LOG_VALUE ( TestModule::ClassMap::iterator ) +BOOST_TEST_DONT_PRINT_LOG_VALUE ( TestModule::SomeNumbers ) +namespace std { + template + ostream & operator<<(ostream & s, const IceUtil::Optional &) { + return s; + } +} // LCOV_EXCL_STOP class FileBased { @@ -144,30 +151,30 @@ void checkInherits_types(const TestModule::InheritanceContPtr & i) { BOOST_REQUIRE(i->b); - BOOST_REQUIRE(TestModule::D1Ptr::dynamicCast(i->b)); - BOOST_REQUIRE_EQUAL(TestModule::D1Ptr::dynamicCast(i->b)->a, 1); - BOOST_REQUIRE_EQUAL(TestModule::D1Ptr::dynamicCast(i->b)->b, 2); + BOOST_REQUIRE(std::dynamic_pointer_cast(i->b)); + BOOST_REQUIRE_EQUAL(std::dynamic_pointer_cast(i->b)->a, 1); + BOOST_REQUIRE_EQUAL(std::dynamic_pointer_cast(i->b)->b, 2); BOOST_REQUIRE_EQUAL(i->bs.size(), 3); BOOST_REQUIRE(i->bs[0]); - BOOST_REQUIRE(TestModule::D2Ptr::dynamicCast(i->bs[0])); - BOOST_REQUIRE_EQUAL(TestModule::D2Ptr::dynamicCast(i->bs[0])->a, 1); - BOOST_REQUIRE_EQUAL(TestModule::D2Ptr::dynamicCast(i->bs[0])->c, 100); + BOOST_REQUIRE(std::dynamic_pointer_cast(i->bs[0])); + BOOST_REQUIRE_EQUAL(std::dynamic_pointer_cast(i->bs[0])->a, 1); + BOOST_REQUIRE_EQUAL(std::dynamic_pointer_cast(i->bs[0])->c, 100); BOOST_REQUIRE(i->bs[1]); - BOOST_REQUIRE(TestModule::D3Ptr::dynamicCast(i->bs[1])); - BOOST_REQUIRE_EQUAL(TestModule::D3Ptr::dynamicCast(i->bs[1])->a, 2); - BOOST_REQUIRE_EQUAL(TestModule::D3Ptr::dynamicCast(i->bs[1])->c, 100); - BOOST_REQUIRE_EQUAL(TestModule::D3Ptr::dynamicCast(i->bs[1])->d, 200); + BOOST_REQUIRE(std::dynamic_pointer_cast(i->bs[1])); + BOOST_REQUIRE_EQUAL(std::dynamic_pointer_cast(i->bs[1])->a, 2); + BOOST_REQUIRE_EQUAL(std::dynamic_pointer_cast(i->bs[1])->c, 100); + BOOST_REQUIRE_EQUAL(std::dynamic_pointer_cast(i->bs[1])->d, 200); BOOST_REQUIRE(i->bs[2]); BOOST_REQUIRE_EQUAL(i->bs[2]->a, 3); - BOOST_REQUIRE(!TestModule::D1Ptr::dynamicCast(i->bs[2])); - BOOST_REQUIRE(!TestModule::D2Ptr::dynamicCast(i->bs[2])); - BOOST_REQUIRE(!TestModule::D3Ptr::dynamicCast(i->bs[2])); + BOOST_REQUIRE(!std::dynamic_pointer_cast(i->bs[2])); + BOOST_REQUIRE(!std::dynamic_pointer_cast(i->bs[2])); + BOOST_REQUIRE(!std::dynamic_pointer_cast(i->bs[2])); BOOST_REQUIRE_EQUAL(i->bm.size(), 3); - BOOST_REQUIRE(TestModule::D1Ptr::dynamicCast(i->bm.find(10)->second)); - BOOST_REQUIRE(TestModule::D3Ptr::dynamicCast(i->bm.find(12)->second)); - BOOST_REQUIRE(!TestModule::D1Ptr::dynamicCast(i->bm.find(14)->second)); - BOOST_REQUIRE(!TestModule::D2Ptr::dynamicCast(i->bm.find(14)->second)); - BOOST_REQUIRE(!TestModule::D3Ptr::dynamicCast(i->bm.find(14)->second)); + BOOST_REQUIRE(std::dynamic_pointer_cast(i->bm.find(10)->second)); + BOOST_REQUIRE(std::dynamic_pointer_cast(i->bm.find(12)->second)); + BOOST_REQUIRE(!std::dynamic_pointer_cast(i->bm.find(14)->second)); + BOOST_REQUIRE(!std::dynamic_pointer_cast(i->bm.find(14)->second)); + BOOST_REQUIRE(!std::dynamic_pointer_cast(i->bm.find(14)->second)); } void @@ -260,14 +267,14 @@ checkBare(const TestXml::BareContainers & bc) void checkSomeEnums(const TestModule::SomeEnumsPtr & se) { - BOOST_REQUIRE_EQUAL(se->one, TestModule::Ten); - BOOST_REQUIRE_EQUAL(se->two, TestModule::FiftyFive); + BOOST_REQUIRE_EQUAL(se->one, TestModule::SomeNumbers::Ten); + BOOST_REQUIRE_EQUAL(se->two, TestModule::SomeNumbers::FiftyFive); } void checkSomeNumbers(const TestModule::SomeNumbers & sn) { - BOOST_REQUIRE_EQUAL(sn, TestModule::FiftyFive); + BOOST_REQUIRE_EQUAL(sn, TestModule::SomeNumbers::FiftyFive); } void @@ -591,10 +598,10 @@ BOOST_AUTO_TEST_CASE( xml_streams ) BOOST_AUTO_TEST_CASE( invalid_enum ) { - Slicer::DeserializerPtr jdeserializer = new Slicer::JsonFileDeserializer(rootDir / "initial" / "invalidEnum.json"); + auto jdeserializer = std::make_shared(rootDir / "initial" / "invalidEnum.json"); BOOST_REQUIRE_THROW(Slicer::DeserializeAnyWith(jdeserializer), Slicer::InvalidEnumerationSymbol); - Slicer::DeserializerPtr xdeserializer = new Slicer::XmlFileDeserializer(rootDir / "initial" / "invalidEnum.xml"); + auto xdeserializer = std::make_shared(rootDir / "initial" / "invalidEnum.xml"); BOOST_REQUIRE_THROW(Slicer::DeserializeAnyWith(xdeserializer), Slicer::InvalidEnumerationSymbol); } @@ -625,7 +632,7 @@ BOOST_AUTO_TEST_CASE( missingConversion ) Slicer::DeserializeAny(in) ), Slicer::NoConversionFound); - TestModule2::MissingConvPtr obj = new TestModule2::MissingConv("2016-06-30 12:34:56"); + auto obj = std::make_shared("2016-06-30 12:34:56"); json::Value v; BOOST_REQUIRE_THROW( Slicer::SerializeAny(obj, v), diff --git a/slicer/test/structs.ice b/slicer/test/structs.ice index e06f93b..fcd17fe 100644 --- a/slicer/test/structs.ice +++ b/slicer/test/structs.ice @@ -1,6 +1,8 @@ #ifndef SLICER_TEST_STRUCTS #define SLICER_TEST_STRUCTS +#include + ["slicer:include:conversions.h"] module TestModule { struct DateTime { @@ -22,7 +24,6 @@ module TestModule { int a; int b; }; - class ClassType; struct StructStruct { ClassType cls; StructType str; diff --git a/slicer/tool/Jamfile.jam b/slicer/tool/Jamfile.jam index cc0ace7..de8b8f8 100644 --- a/slicer/tool/Jamfile.jam +++ b/slicer/tool/Jamfile.jam @@ -1,19 +1,37 @@ import package ; -lib Slice ; -lib Ice ; -lib IceUtil ; +lib Ice++11 ; lib po : : boost_program_options ; lib adhocutil : : : : /usr/include/adhocutil ; lib boost_system ; lib boost_filesystem ; +lib mcpp ; + +lib Slice : + ../../ice/cpp/src/Slice/Parser.cpp + ../../ice/cpp/src/Slice/Grammar.cpp + ../../ice/cpp/src/Slice/Preprocessor.cpp + ../../ice/cpp/src/Slice/CPlusPlusUtil.cpp + ../../ice/cpp/src/Slice/SliceUtil.cpp + ../../ice/cpp/src/Slice/FileTracker.cpp + ../../ice/cpp/src/Slice/Scanner.cpp + : + register= + -fPIC + -UICE_CPP11_MAPPING + -Wno-error=unused-parameter + ../../ice/cpp/src + static + : : + ../../ice/cpp/src + ; lib slicer-compiler : parser.cpp : Slice - Ice - IceUtil + Ice++11 + mcpp boost_system boost_filesystem adhocutil diff --git a/slicer/tool/parser.cpp b/slicer/tool/parser.cpp index ee7ef8c..c05e2e6 100644 --- a/slicer/tool/parser.cpp +++ b/slicer/tool/parser.cpp @@ -308,7 +308,7 @@ namespace Slicer { e->scoped()); fprintbf(cpp, "{\n\tModelPartForEnum< %s >::Enumerations e;\n", e->scoped()); - for (const auto & ee : e->getEnumerators()) { + for (const auto & ee : e->enumerators()) { fprintbf(cpp, "\te.insert( { %s, \"%s\" } );\n", ee->scoped(), ee->name()); } fprintbf(cpp, "\treturn e;\n}());\n\n"); diff --git a/slicer/xml/Jamfile.jam b/slicer/xml/Jamfile.jam index e9bcec4..b8a9e4c 100644 --- a/slicer/xml/Jamfile.jam +++ b/slicer/xml/Jamfile.jam @@ -2,11 +2,10 @@ import testing ; import package ; lib pthread ; -lib Ice ; +lib Ice++11 ; lib boost_system ; lib boost_filesystem ; lib boost_utf : : boost_unit_test_framework ; -lib IceUtil ; lib adhocutil : : : : /usr/include/adhocutil ; lib slicer-xml : @@ -17,8 +16,7 @@ lib slicer-xml : boost_system boost_filesystem pthread - Ice - IceUtil + Ice++11 ../..//libxmlpp adhocutil ../slicer//slicer -- cgit v1.2.3