diff options
author | Mark Spruiell <mes@zeroc.com> | 2016-02-09 15:19:03 -0800 |
---|---|---|
committer | Mark Spruiell <mes@zeroc.com> | 2016-02-09 15:19:03 -0800 |
commit | 2fa55f190efe5a0409be24c5107ddac79b2a3a6b (patch) | |
tree | d931db935809d9614b970e68b1574bb55fa9918d /cpp | |
parent | Updated Objective-C mapping to use new stream classes (diff) | |
download | ice-2fa55f190efe5a0409be24c5107ddac79b2a3a6b.tar.bz2 ice-2fa55f190efe5a0409be24c5107ddac79b2a3a6b.tar.xz ice-2fa55f190efe5a0409be24c5107ddac79b2a3a6b.zip |
minor fixes to stream classes; restoring test/Ice/stream
Diffstat (limited to 'cpp')
-rwxr-xr-x | cpp/allTests.py | 1 | ||||
-rw-r--r-- | cpp/include/Ice/InputStream.h | 19 | ||||
-rw-r--r-- | cpp/include/Ice/OutputStream.h | 16 | ||||
-rw-r--r-- | cpp/src/Ice/InputStream.cpp | 12 | ||||
-rw-r--r-- | cpp/src/Ice/OutputStream.cpp | 2 | ||||
-rw-r--r-- | cpp/test/Ice/Makefile | 3 | ||||
-rw-r--r-- | cpp/test/Ice/Makefile.mak | 4 | ||||
-rw-r--r-- | cpp/test/Ice/stream/Client.cpp | 1020 | ||||
-rw-r--r-- | cpp/test/Ice/stream/Makefile | 2 | ||||
-rw-r--r-- | cpp/test/Ice/stream/Makefile.mak | 2 | ||||
-rw-r--r-- | cpp/test/Ice/stream/Test.ice | 3 |
11 files changed, 607 insertions, 477 deletions
diff --git a/cpp/allTests.py b/cpp/allTests.py index fe564e936c6..43a7aafbb7d 100755 --- a/cpp/allTests.py +++ b/cpp/allTests.py @@ -57,6 +57,7 @@ tests = [ ("Ice/gc", ["once", "noc++11"]), ("Ice/dispatcher", ["once"]), ("Ice/checksum", ["core"]), + ("Ice/stream", ["core"]), ("Ice/hold", ["core", "bt"]), ("Ice/custom", ["core", "nossl", "nows", "noc++11"]), ("Ice/retry", ["core"]), diff --git a/cpp/include/Ice/InputStream.h b/cpp/include/Ice/InputStream.h index 070d43e57a8..43a346cf9ed 100644 --- a/cpp/include/Ice/InputStream.h +++ b/cpp/include/Ice/InputStream.h @@ -213,7 +213,7 @@ public: if(_currentEncaps->encoding != Encoding_1_0) { - skipOpts(); + skipOptionals(); if(i != b.begin() + _currentEncaps->start + _currentEncaps->sz) { throwEncapsulationException(__FILE__, __LINE__); @@ -360,7 +360,7 @@ public: template<typename T> void read(Int tag, IceUtil::Optional<T>& v) { - if(readOpt(tag, StreamOptionalHelper<T, + if(readOptional(tag, StreamOptionalHelper<T, StreamableTraits<T>::helper, StreamableTraits<T>::fixedLength>::optionalFormat)) { @@ -376,12 +376,12 @@ public: } // Read type and tag for optionals - bool readOpt(Int tag, OptionalFormat expectedFormat) + bool readOptional(Int tag, OptionalFormat expectedFormat) { assert(_currentEncaps); if(_currentEncaps->decoder) { - return _currentEncaps->decoder->readOpt(tag, expectedFormat); + return _currentEncaps->decoder->readOptional(tag, expectedFormat); } else { @@ -605,9 +605,8 @@ public: void throwException(const Ice::UserExceptionFactoryPtr& = 0); // Read/write/skip optionals - bool readOptImpl(Int, OptionalFormat); - void skipOpt(OptionalFormat); - void skipOpts(); + void skipOptional(OptionalFormat); + void skipOptionals(); // Skip bytes from the stream void skip(size_type size) @@ -643,6 +642,8 @@ public: void initialize(IceInternal::Instance*, const EncodingVersion&); + bool readOptImpl(Int, OptionalFormat); + private: void initialize(const EncodingVersion&); @@ -703,7 +704,7 @@ private: virtual void endSlice() = 0; virtual void skipSlice() = 0; - virtual bool readOpt(Int, OptionalFormat) + virtual bool readOptional(Int, OptionalFormat) { return false; } @@ -804,7 +805,7 @@ private: virtual void endSlice(); virtual void skipSlice(); - virtual bool readOpt(Int, OptionalFormat); + virtual bool readOptional(Int, OptionalFormat); private: diff --git a/cpp/include/Ice/OutputStream.h b/cpp/include/Ice/OutputStream.h index 0f0138e78f2..c9c28155a5c 100644 --- a/cpp/include/Ice/OutputStream.h +++ b/cpp/include/Ice/OutputStream.h @@ -258,7 +258,7 @@ public: return; // Optional not set } - if(writeOpt(tag, StreamOptionalHelper<T, + if(writeOptional(tag, StreamOptionalHelper<T, StreamableTraits<T>::helper, StreamableTraits<T>::fixedLength>::optionalFormat)) { @@ -292,12 +292,12 @@ public: } // Write type and tag for optionals - bool writeOpt(Int tag, OptionalFormat format) + bool writeOptional(Int tag, OptionalFormat format) { assert(_currentEncaps); if(_currentEncaps->encoder) { - return _currentEncaps->encoder->writeOpt(tag, format); + return _currentEncaps->encoder->writeOptional(tag, format); } else { @@ -462,9 +462,6 @@ public: // Exception void writeException(const UserException&); - // Optionals - bool writeOptImpl(Int, OptionalFormat); - size_type pos() { return b.size(); @@ -482,6 +479,9 @@ public: void finished(std::vector<Byte>&); virtual std::pair<const Byte*, const Byte*> finished(); + // Optionals + bool writeOptImpl(Int, OptionalFormat); + private: // @@ -527,7 +527,7 @@ private: virtual void startSlice(const std::string&, int, bool) = 0; virtual void endSlice() = 0; - virtual bool writeOpt(Int, OptionalFormat) + virtual bool writeOptional(Int, OptionalFormat) { return false; } @@ -611,7 +611,7 @@ private: virtual void startSlice(const std::string&, int, bool); virtual void endSlice(); - virtual bool writeOpt(Int, OptionalFormat); + virtual bool writeOptional(Int, OptionalFormat); private: diff --git a/cpp/src/Ice/InputStream.cpp b/cpp/src/Ice/InputStream.cpp index 5c73c51d6f1..c21da7740f3 100644 --- a/cpp/src/Ice/InputStream.cpp +++ b/cpp/src/Ice/InputStream.cpp @@ -1212,7 +1212,7 @@ Ice::InputStream::readOptImpl(Int readTag, OptionalFormat expectedFormat) } else if(tag < readTag) { - skipOpt(format); // Skip optional data members + skipOptional(format); // Skip optional data members } else { @@ -1229,7 +1229,7 @@ Ice::InputStream::readOptImpl(Int readTag, OptionalFormat expectedFormat) } void -Ice::InputStream::skipOpt(OptionalFormat type) +Ice::InputStream::skipOptional(OptionalFormat type) { switch(type) { @@ -1283,7 +1283,7 @@ Ice::InputStream::skipOpt(OptionalFormat type) } void -Ice::InputStream::skipOpts() +Ice::InputStream::skipOptionals() { // // Skip remaining un-read optional members. @@ -1307,7 +1307,7 @@ Ice::InputStream::skipOpts() { skipSize(); } - skipOpt(format); + skipOptional(format); } } @@ -2181,7 +2181,7 @@ Ice::InputStream::EncapsDecoder11::endSlice() { if(_current->sliceFlags & FLAG_HAS_OPTIONAL_MEMBERS) { - _stream->skipOpts(); + _stream->skipOptionals(); } // @@ -2298,7 +2298,7 @@ Ice::InputStream::EncapsDecoder11::skipSlice() } bool -Ice::InputStream::EncapsDecoder11::readOpt(Ice::Int readTag, Ice::OptionalFormat expectedFormat) +Ice::InputStream::EncapsDecoder11::readOptional(Ice::Int readTag, Ice::OptionalFormat expectedFormat) { if(!_current) { diff --git a/cpp/src/Ice/OutputStream.cpp b/cpp/src/Ice/OutputStream.cpp index 318f411cc4a..605855d5460 100644 --- a/cpp/src/Ice/OutputStream.cpp +++ b/cpp/src/Ice/OutputStream.cpp @@ -1265,7 +1265,7 @@ Ice::OutputStream::EncapsEncoder11::endSlice() } bool -Ice::OutputStream::EncapsEncoder11::writeOpt(Ice::Int tag, Ice::OptionalFormat format) +Ice::OutputStream::EncapsEncoder11::writeOptional(Ice::Int tag, Ice::OptionalFormat format) { if(!_current) { diff --git a/cpp/test/Ice/Makefile b/cpp/test/Ice/Makefile index cec8e0380eb..8d2acb1d716 100644 --- a/cpp/test/Ice/Makefile +++ b/cpp/test/Ice/Makefile @@ -48,7 +48,8 @@ SUBDIRS = proxy \ logger \ networkProxy \ services \ - impl + impl \ + stream ifneq ($(CPP11_MAPPING),yes) SUBDIRS := $(SUBDIRS) \ diff --git a/cpp/test/Ice/Makefile.mak b/cpp/test/Ice/Makefile.mak index 06c947a2805..cd9431635c7 100644 --- a/cpp/test/Ice/Makefile.mak +++ b/cpp/test/Ice/Makefile.mak @@ -49,7 +49,8 @@ SUBDIRS = proxy \ logger \ networkProxy \ services \ - impl + impl \ + stream !else SUBDIRS = proxy \ operations \ @@ -72,6 +73,7 @@ SUBDIRS = proxy \ udp \ admin \ plugin \ + stream \ metrics \ optional \ enums \ diff --git a/cpp/test/Ice/stream/Client.cpp b/cpp/test/Ice/stream/Client.cpp index f09293e7092..a0302b47d46 100644 --- a/cpp/test/Ice/stream/Client.cpp +++ b/cpp/test/Ice/stream/Client.cpp @@ -14,30 +14,45 @@ DEFINE_TEST("client") using namespace std; +using namespace Test; +using namespace Test::Sub; +using namespace Test2::Sub2; -class TestObjectWriter : public Ice::ObjectWriter +#ifdef ICE_CPP11_MAPPING +class TestObjectWriter : public Ice::ValueHelper<TestObjectWriter, Ice::Value> +#else +class TestObjectWriter : public Ice::Object +#endif { public: - TestObjectWriter(const Test::MyClassPtr& p) + TestObjectWriter(const MyClassPtr& p) { obj = p; called = false; } - virtual void - write(const Ice::OutputStreamPtr& out) const + virtual void __write(Ice::OutputStream* out) const { obj->__write(out); const_cast<TestObjectWriter*>(this)->called = true; } - Test::MyClassPtr obj; + virtual void __read(Ice::InputStream*) + { + assert(false); + } + + MyClassPtr obj; bool called; }; -typedef IceUtil::Handle<TestObjectWriter> TestObjectWriterPtr; +ICE_DEFINE_PTR(TestObjectWriterPtr, TestObjectWriter); -class TestObjectReader : public Ice::ObjectReader +#ifdef ICE_CPP11_MAPPING +class TestObjectReader : public Ice::ValueHelper<TestObjectReader, Ice::Value> +#else +class TestObjectReader : public Ice::Object +#endif { public: @@ -46,19 +61,24 @@ public: called = false; } - virtual void - read(const Ice::InputStreamPtr& in) + virtual void __write(Ice::OutputStream*) const + { + assert(false); + } + + virtual void __read(Ice::InputStream* in) { - obj = new Test::MyClass; + obj = ICE_MAKE_SHARED(MyClass); obj->__read(in); called = true; } - Test::MyClassPtr obj; + MyClassPtr obj; bool called; }; -typedef IceUtil::Handle<TestObjectReader> TestObjectReaderPtr; +ICE_DEFINE_PTR(TestObjectReaderPtr, TestObjectReader); +#ifndef ICE_CPP11_MAPPING class TestValueFactory : public Ice::ValueFactory { public: @@ -70,7 +90,7 @@ public: create(const string&) #endif { - assert(type == Test::MyClass::ice_staticId()); + assert(type == MyClass::ice_staticId()); return new TestObjectReader; } @@ -79,51 +99,80 @@ public: { } }; +#endif + +#ifdef ICE_CPP11_MAPPING +void +patchObject(void* addr, const Ice::ValuePtr& v) +{ + Ice::ValuePtr* p = static_cast<Ice::ValuePtr*>(addr); + assert(p); + *p = v; +} +#else +void +patchObject(void* addr, const Ice::ObjectPtr& v) +{ + Ice::ObjectPtr* p = static_cast<Ice::ObjectPtr*>(addr); + assert(p); + *p = v; +} +#endif -class TestReadObjectCallback : public Ice::ReadObjectCallback +#ifdef ICE_CPP11_MAPPING +class MyClassFactoryWrapper { public: - virtual void - invoke(const Ice::ObjectPtr& p) + MyClassFactoryWrapper() { - obj = p; + clear(); } - Ice::ObjectPtr obj; -}; -typedef IceUtil::Handle<TestReadObjectCallback> TestReadObjectCallbackPtr; + Ice::ValuePtr create(const string& type) + { + return _factory(type); + } + + void setFactory(function<Ice::ValuePtr (const string&)> f) + { + _factory = f; + } + void clear() + { + _factory = [](const string&) { return ICE_MAKE_SHARED(MyClass); }; + } + + function<Ice::ValuePtr (const string&)> _factory; +}; +#else class MyClassFactoryWrapper : public Ice::ValueFactory { public: - MyClassFactoryWrapper() : _factory(Test::MyClass::ice_factory()) + MyClassFactoryWrapper() { + clear(); } - virtual Ice::ObjectPtr - create(const string& type) + virtual Ice::ObjectPtr create(const string& type) { return _factory->create(type); } - virtual void - destroy() + virtual void destroy() { } - void - setFactory(const Ice::ValueFactoryPtr& factory) + void setFactory(const Ice::ValueFactoryPtr& factory) { - if(!factory) - { - _factory = Test::MyClass::ice_factory(); - } - else - { - _factory = factory; - } + _factory = factory; + } + + void clear() + { + _factory = MyClass::ice_factory(); } private: @@ -131,7 +180,9 @@ private: Ice::ValueFactoryPtr _factory; }; typedef IceUtil::Handle<MyClassFactoryWrapper> MyClassFactoryWrapperPtr; +#endif +#ifndef ICE_CPP11_MAPPING class MyInterfaceFactory : public Ice::ValueFactory { public: @@ -139,7 +190,7 @@ public: virtual Ice::ObjectPtr create(const string&) { - return new Test::MyInterface; + return new MyInterface; } virtual void @@ -147,60 +198,59 @@ public: { } }; +#endif int run(int, char**, const Ice::CommunicatorPtr& communicator) { +#ifdef ICE_CPP11_MAPPING + MyClassFactoryWrapper factoryWrapper; + function<Ice::ValuePtr (const string&)> f = + std::bind(&MyClassFactoryWrapper::create, &factoryWrapper, std::placeholders::_1); + communicator->getValueFactoryManager()->add(f, MyClass::ice_staticId()); +#else MyClassFactoryWrapperPtr factoryWrapper = new MyClassFactoryWrapper; - communicator->addValueFactory(factoryWrapper, Test::MyClass::ice_staticId()); - communicator->addValueFactory(new MyInterfaceFactory, Test::MyInterface::ice_staticId()); + communicator->getValueFactoryManager()->add(factoryWrapper, MyClass::ice_staticId()); + communicator->getValueFactoryManager()->add(new MyInterfaceFactory, MyInterface::ice_staticId()); +#endif - Ice::InputStreamPtr in; - Ice::OutputStreamPtr out; vector<Ice::Byte> data; // - // Test the stream api. + // Test the stream API. // cout << "testing primitive types... " << flush; { vector<Ice::Byte> byte; - in = Ice::createInputStream(communicator, byte); + Ice::InputStream in(communicator, byte); } { - out = Ice::createOutputStream(communicator); - out->startEncapsulation(); - out->write(true); - out->endEncapsulation(); - out->finished(data); - pair<const Ice::Byte*, const Ice::Byte*> d = out->finished(); + Ice::OutputStream out(communicator); + out.startEncapsulation(); + out.write(true); + out.endEncapsulation(); + out.finished(data); + pair<const Ice::Byte*, const Ice::Byte*> d = out.finished(); test(d.second - d.first == static_cast<int>(data.size())); test(vector<Ice::Byte>(d.first, d.second) == data); - out = 0; - in = Ice::createInputStream(communicator, data); - in->startEncapsulation(); + Ice::InputStream in(communicator, data); + in.startEncapsulation(); bool v; - in->read(v); - test(v); - in->endEncapsulation(); - - in = Ice::wrapInputStream(communicator, data); - in->startEncapsulation(); - in->read(v); + in.read(v); test(v); - in->endEncapsulation(); + in.endEncapsulation(); } { vector<Ice::Byte> byte; - in = Ice::createInputStream(communicator, byte); + Ice::InputStream in(communicator, byte); try { bool v; - in->read(v); + in.read(v); test(false); } catch(const Ice::UnmarshalOutOfBoundsException&) @@ -209,82 +259,82 @@ run(int, char**, const Ice::CommunicatorPtr& communicator) } { - out = Ice::createOutputStream(communicator); - out->write(true); - out->finished(data); - in = Ice::createInputStream(communicator, data); + Ice::OutputStream out(communicator); + out.write(true); + out.finished(data); + Ice::InputStream in(communicator, data); bool v; - in->read(v); + in.read(v); test(v); } { - out = Ice::createOutputStream(communicator); - out->write((Ice::Byte)1); - out->finished(data); - in = Ice::createInputStream(communicator, data); + Ice::OutputStream out(communicator); + out.write((Ice::Byte)1); + out.finished(data); + Ice::InputStream in(communicator, data); Ice::Byte v; - in->read(v); + in.read(v); test(v == 1); } { - out = Ice::createOutputStream(communicator); - out->write((Ice::Short)2); - out->finished(data); - in = Ice::createInputStream(communicator, data); + Ice::OutputStream out(communicator); + out.write((Ice::Short)2); + out.finished(data); + Ice::InputStream in(communicator, data); Ice::Short v; - in->read(v); + in.read(v); test(v == 2); } { - out = Ice::createOutputStream(communicator); - out->write((Ice::Int)3); - out->finished(data); - in = Ice::createInputStream(communicator, data); + Ice::OutputStream out(communicator); + out.write((Ice::Int)3); + out.finished(data); + Ice::InputStream in(communicator, data); Ice::Int v; - in->read(v); + in.read(v); test(v == 3); } { - out = Ice::createOutputStream(communicator); - out->write((Ice::Long)4); - out->finished(data); - in = Ice::createInputStream(communicator, data); + Ice::OutputStream out(communicator); + out.write((Ice::Long)4); + out.finished(data); + Ice::InputStream in(communicator, data); Ice::Long v; - in->read(v); + in.read(v); test(v == 4); } { - out = Ice::createOutputStream(communicator); - out->write((Ice::Float)5.0); - out->finished(data); - in = Ice::createInputStream(communicator, data); + Ice::OutputStream out(communicator); + out.write((Ice::Float)5.0); + out.finished(data); + Ice::InputStream in(communicator, data); Ice::Float v; - in->read(v); + in.read(v); test(v == 5.0); } { - out = Ice::createOutputStream(communicator); - out->write((Ice::Double)6.0); - out->finished(data); - in = Ice::createInputStream(communicator, data); + Ice::OutputStream out(communicator); + out.write((Ice::Double)6.0); + out.finished(data); + Ice::InputStream in(communicator, data); Ice::Double v; - in->read(v); + in.read(v); test(v == 6.0); } { - out = Ice::createOutputStream(communicator); - out->write("hello world"); - out->finished(data); - in = Ice::createInputStream(communicator, data); + Ice::OutputStream out(communicator); + out.write("hello world"); + out.finished(data); + Ice::InputStream in(communicator, data); string v; - in->read(v); + in.read(v); test(v == "hello world"); } @@ -293,18 +343,18 @@ run(int, char**, const Ice::CommunicatorPtr& communicator) cout << "testing constructed types... " << flush; { - out = Ice::createOutputStream(communicator); - out->write(Test::enum3); - out->finished(data); - in = Ice::createInputStream(communicator, data); - Test::MyEnum e; - in->read(e); - test(e == Test::enum3); + Ice::OutputStream out(communicator); + out.write(ICE_ENUM(MyEnum, enum3)); + out.finished(data); + Ice::InputStream in(communicator, data); + MyEnum e; + in.read(e); + test(e == ICE_ENUM(MyEnum, enum3)); } { - out = Ice::createOutputStream(communicator); - Test::SmallStruct s; + Ice::OutputStream out(communicator); + SmallStruct s; s.bo = true; s.by = 1; s.sh = 2; @@ -313,45 +363,52 @@ run(int, char**, const Ice::CommunicatorPtr& communicator) s.f = 5.0; s.d = 6.0; s.str = "7"; - s.e = Test::enum2; - s.p = Test::MyClassPrx::uncheckedCast(communicator->stringToProxy("test:default")); - out->write(s); - out->finished(data); - in = Ice::createInputStream(communicator, data); - Test::SmallStruct s2; - in->read(s2); + s.e = ICE_ENUM(MyEnum, enum2); + s.p = ICE_UNCHECKED_CAST(MyInterfacePrx, communicator->stringToProxy("test:default")); + out.write(s); + out.finished(data); + Ice::InputStream in(communicator, data); + SmallStruct s2; + in.read(s2); +#ifndef ICE_CPP11_MAPPING + // + // No comparison operator generated in C++11. + // test(s2 == s); +#endif } +#ifndef ICE_CPP11_MAPPING { - out = Ice::createOutputStream(communicator); - Test::ClassStructPtr s = new Test::ClassStruct(); + Ice::OutputStream out(communicator); + ClassStructPtr s = new ClassStruct(); s->i = 10; - out->write(s); - out->finished(data); - in = Ice::createInputStream(communicator, data); - Test::ClassStructPtr s2 = new Test::ClassStruct(); - in->read(s2); + out.write(s); + out.finished(data); + Ice::InputStream in(communicator, data); + ClassStructPtr s2 = new ClassStruct(); + in.read(s2); test(s2->i == s->i); } +#endif { - out = Ice::createOutputStream(communicator); - Test::OptionalClassPtr o = new Test::OptionalClass(); + Ice::OutputStream out(communicator); + OptionalClassPtr o = ICE_MAKE_SHARED(OptionalClass); o->bo = false; o->by = 5; o->sh = 4; o->i = 3; - out->write(o); - out->writePendingObjects(); - out->finished(data); - in = Ice::createInputStream(communicator, data); - Test::OptionalClassPtr o2; - in->read(o2); - in->readPendingObjects(); + out.write(o); + out.writePendingObjects(); + out.finished(data); + Ice::InputStream in(communicator, data); + OptionalClassPtr o2; + in.read(o2); + in.readPendingObjects(); test(o2->bo == o->bo); test(o2->by == o->by); - if(in->getEncoding() == Ice::Encoding_1_0) + if(in.getEncoding() == Ice::Encoding_1_0) { test(!o2->sh); test(!o2->i); @@ -364,19 +421,19 @@ run(int, char**, const Ice::CommunicatorPtr& communicator) } { - out = Ice::createOutputStream(communicator, Ice::Encoding_1_0); - Test::OptionalClassPtr o = new Test::OptionalClass(); + Ice::OutputStream out(communicator, Ice::Encoding_1_0); + OptionalClassPtr o = ICE_MAKE_SHARED(OptionalClass); o->bo = false; o->by = 5; o->sh = 4; o->i = 3; - out->write(o); - out->writePendingObjects(); - out->finished(data); - in = Ice::createInputStream(communicator, data, Ice::Encoding_1_0); - Test::OptionalClassPtr o2; - in->read(o2); - in->readPendingObjects(); + out.write(o); + out.writePendingObjects(); + out.finished(data); + Ice::InputStream in(communicator, Ice::Encoding_1_0, data); + OptionalClassPtr o2; + in.read(o2); + in.readPendingObjects(); test(o2->bo == o->bo); test(o2->by == o->by); test(!o2->sh); @@ -390,27 +447,27 @@ run(int, char**, const Ice::CommunicatorPtr& communicator) arr.push_back(true); arr.push_back(false); - out = Ice::createOutputStream(communicator); - out->write(arr); - out->finished(data); + Ice::OutputStream out(communicator); + out.write(arr); + out.finished(data); - in = Ice::createInputStream(communicator, data); + Ice::InputStream in(communicator, data); Ice::BoolSeq arr2; - in->read(arr2); + in.read(arr2); test(arr2 == arr); - Test::BoolSS arrS; + BoolSS arrS; arrS.push_back(arr); arrS.push_back(Ice::BoolSeq()); arrS.push_back(arr); - out = Ice::createOutputStream(communicator); - out->write(arrS); - out->finished(data); + Ice::OutputStream out2(communicator); + out2.write(arrS); + out2.finished(data); - in = Ice::createInputStream(communicator, data); - Test::BoolSS arr2S; - in->read(arr2S); + Ice::InputStream in2(communicator, data); + BoolSS arr2S; + in2.read(arr2S); test(arr2S == arrS); } @@ -421,26 +478,26 @@ run(int, char**, const Ice::CommunicatorPtr& communicator) arr.push_back(0x12); arr.push_back(0x22); - out = Ice::createOutputStream(communicator); - out->write(arr); - out->finished(data); - in = Ice::createInputStream(communicator, data); + Ice::OutputStream out(communicator); + out.write(arr); + out.finished(data); + Ice::InputStream in(communicator, data); Ice::ByteSeq arr2; - in->read(arr2); + in.read(arr2); test(arr2 == arr); - Test::ByteSS arrS; + ByteSS arrS; arrS.push_back(arr); arrS.push_back(Ice::ByteSeq()); arrS.push_back(arr); - out = Ice::createOutputStream(communicator); - out->write(arrS); - out->finished(data); + Ice::OutputStream out2(communicator); + out2.write(arrS); + out2.finished(data); - in = Ice::createInputStream(communicator, data); - Test::ByteSS arr2S; - in->read(arr2S); + Ice::InputStream in2(communicator, data); + ByteSS arr2S; + in2.read(arr2S); test(arr2S == arrS); } @@ -450,26 +507,26 @@ run(int, char**, const Ice::CommunicatorPtr& communicator) arr.push_back(0x11); arr.push_back(0x12); arr.push_back(0x22); - out = Ice::createOutputStream(communicator); - out->write(arr); - out->finished(data); - in = Ice::createInputStream(communicator, data); + Ice::OutputStream out(communicator); + out.write(arr); + out.finished(data); + Ice::InputStream in(communicator, data); Ice::ShortSeq arr2; - in->read(arr2); + in.read(arr2); test(arr2 == arr); - Test::ShortSS arrS; + ShortSS arrS; arrS.push_back(arr); arrS.push_back(Ice::ShortSeq()); arrS.push_back(arr); - out = Ice::createOutputStream(communicator); - out->write(arrS); - out->finished(data); + Ice::OutputStream out2(communicator); + out2.write(arrS); + out2.finished(data); - in = Ice::createInputStream(communicator, data); - Test::ShortSS arr2S; - in->read(arr2S); + Ice::InputStream in2(communicator, data); + ShortSS arr2S; + in2.read(arr2S); test(arr2S == arrS); } @@ -479,26 +536,26 @@ run(int, char**, const Ice::CommunicatorPtr& communicator) arr.push_back(0x11); arr.push_back(0x12); arr.push_back(0x22); - out = Ice::createOutputStream(communicator); - out->write(arr); - out->finished(data); - in = Ice::createInputStream(communicator, data); + Ice::OutputStream out(communicator); + out.write(arr); + out.finished(data); + Ice::InputStream in(communicator, data); Ice::IntSeq arr2; - in->read(arr2); + in.read(arr2); test(arr2 == arr); - Test::IntSS arrS; + IntSS arrS; arrS.push_back(arr); arrS.push_back(Ice::IntSeq()); arrS.push_back(arr); - out = Ice::createOutputStream(communicator); - out->write(arrS); - out->finished(data); + Ice::OutputStream out2(communicator); + out2.write(arrS); + out2.finished(data); - in = Ice::createInputStream(communicator, data); - Test::IntSS arr2S; - in->read(arr2S); + Ice::InputStream in2(communicator, data); + IntSS arr2S; + in2.read(arr2S); test(arr2S == arrS); } @@ -508,26 +565,26 @@ run(int, char**, const Ice::CommunicatorPtr& communicator) arr.push_back(0x11); arr.push_back(0x12); arr.push_back(0x22); - out = Ice::createOutputStream(communicator); - out->write(arr); - out->finished(data); - in = Ice::createInputStream(communicator, data); + Ice::OutputStream out(communicator); + out.write(arr); + out.finished(data); + Ice::InputStream in(communicator, data); Ice::LongSeq arr2; - in->read(arr2); + in.read(arr2); test(arr2 == arr); - Test::LongSS arrS; + LongSS arrS; arrS.push_back(arr); arrS.push_back(Ice::LongSeq()); arrS.push_back(arr); - out = Ice::createOutputStream(communicator); - out->write(arrS); - out->finished(data); + Ice::OutputStream out2(communicator); + out2.write(arrS); + out2.finished(data); - in = Ice::createInputStream(communicator, data); - Test::LongSS arr2S; - in->read(arr2S); + Ice::InputStream in2(communicator, data); + LongSS arr2S; + in2.read(arr2S); test(arr2S == arrS); } @@ -537,26 +594,26 @@ run(int, char**, const Ice::CommunicatorPtr& communicator) arr.push_back(2); arr.push_back(3); arr.push_back(4); - out = Ice::createOutputStream(communicator); - out->write(arr); - out->finished(data); - in = Ice::createInputStream(communicator, data); + Ice::OutputStream out(communicator); + out.write(arr); + out.finished(data); + Ice::InputStream in(communicator, data); Ice::FloatSeq arr2; - in->read(arr2); + in.read(arr2); test(arr2 == arr); - Test::FloatSS arrS; + FloatSS arrS; arrS.push_back(arr); arrS.push_back(Ice::FloatSeq()); arrS.push_back(arr); - out = Ice::createOutputStream(communicator); - out->write(arrS); - out->finished(data); + Ice::OutputStream out2(communicator); + out2.write(arrS); + out2.finished(data); - in = Ice::createInputStream(communicator, data); - Test::FloatSS arr2S; - in->read(arr2S); + Ice::InputStream in2(communicator, data); + FloatSS arr2S; + in2.read(arr2S); test(arr2S == arrS); } @@ -566,26 +623,26 @@ run(int, char**, const Ice::CommunicatorPtr& communicator) arr.push_back(2); arr.push_back(3); arr.push_back(4); - out = Ice::createOutputStream(communicator); - out->write(arr); - out->finished(data); - in = Ice::createInputStream(communicator, data); + Ice::OutputStream out(communicator); + out.write(arr); + out.finished(data); + Ice::InputStream in(communicator, data); Ice::DoubleSeq arr2; - in->read(arr2); + in.read(arr2); test(arr2 == arr); - Test::DoubleSS arrS; + DoubleSS arrS; arrS.push_back(arr); arrS.push_back(Ice::DoubleSeq()); arrS.push_back(arr); - out = Ice::createOutputStream(communicator); - out->write(arrS); - out->finished(data); + Ice::OutputStream out2(communicator); + out2.write(arrS); + out2.finished(data); - in = Ice::createInputStream(communicator, data); - Test::DoubleSS arr2S; - in->read(arr2S); + Ice::InputStream in2(communicator, data); + DoubleSS arr2S; + in2.read(arr2S); test(arr2S == arrS); } @@ -595,64 +652,64 @@ run(int, char**, const Ice::CommunicatorPtr& communicator) arr.push_back("string2"); arr.push_back("string3"); arr.push_back("string4"); - out = Ice::createOutputStream(communicator); - out->write(arr); - out->finished(data); - in = Ice::createInputStream(communicator, data); + Ice::OutputStream out(communicator); + out.write(arr); + out.finished(data); + Ice::InputStream in(communicator, data); Ice::StringSeq arr2; - in->read(arr2); + in.read(arr2); test(arr2 == arr); - Test::StringSS arrS; + StringSS arrS; arrS.push_back(arr); arrS.push_back(Ice::StringSeq()); arrS.push_back(arr); - out = Ice::createOutputStream(communicator); - out->write(arrS); - out->finished(data); + Ice::OutputStream out2(communicator); + out2.write(arrS); + out2.finished(data); - in = Ice::createInputStream(communicator, data); - Test::StringSS arr2S; - in->read(arr2S); + Ice::InputStream in2(communicator, data); + StringSS arr2S; + in2.read(arr2S); test(arr2S == arrS); } { - Test::MyEnumS arr; - arr.push_back(Test::enum3); - arr.push_back(Test::enum2); - arr.push_back(Test::enum1); - arr.push_back(Test::enum2); - - out = Ice::createOutputStream(communicator); - out->write(arr); - out->finished(data); - in = Ice::createInputStream(communicator, data); - Test::MyEnumS arr2; - in->read(arr2); + MyEnumS arr; + arr.push_back(ICE_ENUM(MyEnum, enum3)); + arr.push_back(ICE_ENUM(MyEnum, enum2)); + arr.push_back(ICE_ENUM(MyEnum, enum1)); + arr.push_back(ICE_ENUM(MyEnum, enum2)); + + Ice::OutputStream out(communicator); + out.write(arr); + out.finished(data); + Ice::InputStream in(communicator, data); + MyEnumS arr2; + in.read(arr2); test(arr2 == arr); - Test::MyEnumSS arrS; + MyEnumSS arrS; arrS.push_back(arr); - arrS.push_back(Test::MyEnumS()); + arrS.push_back(MyEnumS()); arrS.push_back(arr); - out = Ice::createOutputStream(communicator); - out->write(arrS); - out->finished(data); + Ice::OutputStream out2(communicator); + out2.write(arrS); + out2.finished(data); - in = Ice::createInputStream(communicator, data); - Test::MyEnumSS arr2S; - in->read(arr2S); + Ice::InputStream in2(communicator, data); + MyEnumSS arr2S; + in2.read(arr2S); test(arr2S == arrS); } { - Test::SmallStructS arr; + SmallStructS arr; for(int i = 0; i < 4; ++i) { - Test::SmallStruct s; + SmallStruct s; s.bo = true; s.by = 1; s.sh = 2; @@ -661,47 +718,57 @@ run(int, char**, const Ice::CommunicatorPtr& communicator) s.f = 5.0; s.d = 6.0; s.str = "7"; - s.e = Test::enum2; - s.p = Test::MyClassPrx::uncheckedCast(communicator->stringToProxy("test:default")); + s.e = ICE_ENUM(MyEnum, enum2); + s.p = ICE_UNCHECKED_CAST(MyInterfacePrx, communicator->stringToProxy("test:default")); arr.push_back(s); } - out = Ice::createOutputStream(communicator); - out->write(arr); - out->writePendingObjects(); - out->finished(data); - in = Ice::createInputStream(communicator, data); - Test::SmallStructS arr2; - in->read(arr2); - in->readPendingObjects(); + Ice::OutputStream out(communicator); + out.write(arr); + out.writePendingObjects(); + out.finished(data); + Ice::InputStream in(communicator, data); + SmallStructS arr2; + in.read(arr2); + in.readPendingObjects(); test(arr2.size() == arr.size()); - for(Test::SmallStructS::size_type j = 0; j < arr2.size(); ++j) +#ifndef ICE_CPP11_MAPPING + // + // No comparison operator generated in C++11. + // + for(SmallStructS::size_type j = 0; j < arr2.size(); ++j) { test(arr[j] == arr2[j]); } +#endif - Test::SmallStructSS arrS; + SmallStructSS arrS; arrS.push_back(arr); - arrS.push_back(Test::SmallStructS()); + arrS.push_back(SmallStructS()); arrS.push_back(arr); - out = Ice::createOutputStream(communicator); - out->write(arrS); - out->finished(data); - - in = Ice::createInputStream(communicator, data); - Test::SmallStructSS arr2S; - in->read(arr2S); + Ice::OutputStream out2(communicator); + out2.write(arrS); + out2.finished(data); + + Ice::InputStream in2(communicator, data); + SmallStructSS arr2S; + in2.read(arr2S); +#ifndef ICE_CPP11_MAPPING + // + // No comparison operator generated in C++11. + // test(arr2S == arrS); +#endif } { - Test::MyClassS arr; + MyClassS arr; for(int i = 0; i < 4; ++i) { - Test::MyClassPtr c = new Test::MyClass; + MyClassPtr c = ICE_MAKE_SHARED(MyClass); c->c = c; c->o = c; - c->s.e = Test::enum2; + c->s.e = ICE_ENUM(MyEnum, enum2); c->seq1.push_back(true); c->seq1.push_back(false); @@ -743,29 +810,34 @@ run(int, char**, const Ice::CommunicatorPtr& communicator) c->seq8.push_back("string3"); c->seq8.push_back("string4"); - c->seq9.push_back(Test::enum3); - c->seq9.push_back(Test::enum2); - c->seq9.push_back(Test::enum1); + c->seq9.push_back(ICE_ENUM(MyEnum, enum3)); + c->seq9.push_back(ICE_ENUM(MyEnum, enum2)); + c->seq9.push_back(ICE_ENUM(MyEnum, enum1)); c->d["hi"] = c; +#ifndef ICE_CPP11_MAPPING + // + // No GC support in C++11. + // c->ice_collectable(true); +#endif arr.push_back(c); } - out = Ice::createOutputStream(communicator); - out->write(arr); - out->writePendingObjects(); - out->finished(data); - in = Ice::createInputStream(communicator, data); - Test::MyClassS arr2; - in->read(arr2); - in->readPendingObjects(); + Ice::OutputStream out(communicator); + out.write(arr); + out.writePendingObjects(); + out.finished(data); + Ice::InputStream in(communicator, data); + MyClassS arr2; + in.read(arr2); + in.readPendingObjects(); test(arr2.size() == arr.size()); - for(Test::MyClassS::size_type j = 0; j < arr2.size(); ++j) + for(MyClassS::size_type j = 0; j < arr2.size(); ++j) { test(arr2[j]); test(arr2[j]->c == arr2[j]); test(arr2[j]->o == arr2[j]); - test(arr2[j]->s.e == Test::enum2); + test(arr2[j]->s.e == ICE_ENUM(MyEnum, enum2)); test(arr2[j]->seq1 == arr[j]->seq1); test(arr2[j]->seq2 == arr[j]->seq2); test(arr2[j]->seq3 == arr[j]->seq3); @@ -778,78 +850,105 @@ run(int, char**, const Ice::CommunicatorPtr& communicator) test(arr2[j]->d["hi"] == arr2[j]); } - Test::MyClassSS arrS; + MyClassSS arrS; arrS.push_back(arr); - arrS.push_back(Test::MyClassS()); + arrS.push_back(MyClassS()); arrS.push_back(arr); - out = Ice::createOutputStream(communicator); - out->write(arrS); - out->finished(data); + Ice::OutputStream out2(communicator); + out2.write(arrS); + out2.finished(data); - in = Ice::createInputStream(communicator, data); - Test::MyClassSS arr2S; - in->read(arr2S); + Ice::InputStream in2(communicator, data); + MyClassSS arr2S; + in2.read(arr2S); test(arr2S.size() == arrS.size()); test(arr2S[0].size() == arrS[0].size()); test(arr2S[1].size() == arrS[1].size()); test(arr2S[2].size() == arrS[2].size()); } +#ifndef ICE_CPP11_MAPPING + // + // No support for interfaces-as-values in C++11. + // { - Test::MyInterfacePtr i = new Test::MyInterface(); - out = Ice::createOutputStream(communicator); - out->write(i); - out->writePendingObjects(); - out->finished(data); - in = Ice::createInputStream(communicator, data); + MyInterfacePtr i = new MyInterface(); + Ice::OutputStream out(communicator); + out.write(i); + out.writePendingObjects(); + out.finished(data); + Ice::InputStream in(communicator, data); i = 0; - in->read(i); - in->readPendingObjects(); + in.read(i); + in.readPendingObjects(); test(i); } +#endif { - out = Ice::createOutputStream(communicator); - Test::MyClassPtr obj = new Test::MyClass; - obj->s.e = Test::enum2; - TestObjectWriterPtr writer = new TestObjectWriter(obj); - out->writeObject(writer); - out->writePendingObjects(); - out->finished(data); + Ice::OutputStream out(communicator); + MyClassPtr obj = ICE_MAKE_SHARED(MyClass); + obj->s.e = ICE_ENUM(MyEnum, enum2); + TestObjectWriterPtr writer = ICE_MAKE_SHARED(TestObjectWriter, obj); +#ifdef ICE_CPP11_MAPPING + Ice::ValuePtr w = ICE_DYNAMIC_CAST(Ice::Value, writer); + out.write(w); +#else + out.write(Ice::ObjectPtr(writer)); +#endif + out.writePendingObjects(); + out.finished(data); test(writer->called); } { - out = Ice::createOutputStream(communicator); - Test::MyClassPtr obj = new Test::MyClass; - obj->s.e = Test::enum2; - TestObjectWriterPtr writer = new TestObjectWriter(obj); - out->writeObject(writer); - out->writePendingObjects(); - out->finished(data); + Ice::OutputStream out(communicator); + MyClassPtr obj = ICE_MAKE_SHARED(MyClass); + obj->s.e = ICE_ENUM(MyEnum, enum2); + TestObjectWriterPtr writer = ICE_MAKE_SHARED(TestObjectWriter, obj); +#ifdef ICE_CPP11_MAPPING + Ice::ValuePtr w = ICE_DYNAMIC_CAST(Ice::Value, writer); + out.write(w); +#else + out.write(Ice::ObjectPtr(writer)); +#endif + out.writePendingObjects(); + out.finished(data); test(writer->called); +#ifdef ICE_CPP11_MAPPING + factoryWrapper.setFactory([](const string&) { return ICE_MAKE_SHARED(TestObjectReader); }); +#else factoryWrapper->setFactory(new TestValueFactory); - in = Ice::createInputStream(communicator, data); - TestReadObjectCallbackPtr cb = new TestReadObjectCallback; - in->readObject(cb); - in->readPendingObjects(); - test(cb->obj); - TestObjectReaderPtr reader = TestObjectReaderPtr::dynamicCast(cb->obj); +#endif + Ice::InputStream in(communicator, data); +#ifdef ICE_CPP11_MAPPING + Ice::ValuePtr p; +#else + Ice::ObjectPtr p; +#endif + in.read(&patchObject, &p); + in.readPendingObjects(); + test(p); + TestObjectReaderPtr reader = ICE_DYNAMIC_CAST(TestObjectReader, p); test(reader); test(reader->called); test(reader->obj); - test(reader->obj->s.e == Test::enum2); - factoryWrapper->setFactory(0); + test(reader->obj->s.e == ICE_ENUM(MyEnum, enum2)); +#ifdef ICE_CPP11_MAPPING + factoryWrapper.clear(); +#else + factoryWrapper->clear(); +#endif } { - out = Ice::createOutputStream(communicator); - Test::MyException ex; - Test::MyClassPtr c = new Test::MyClass; + Ice::OutputStream out(communicator); + MyException ex; + MyClassPtr c = ICE_MAKE_SHARED(MyClass); c->c = c; c->o = c; - c->s.e = Test::enum2; + c->s.e = ICE_ENUM(MyEnum, enum2); c->seq1.push_back(true); c->seq1.push_back(false); @@ -891,23 +990,28 @@ run(int, char**, const Ice::CommunicatorPtr& communicator) c->seq8.push_back("string3"); c->seq8.push_back("string4"); - c->seq9.push_back(Test::enum3); - c->seq9.push_back(Test::enum2); - c->seq9.push_back(Test::enum1); + c->seq9.push_back(ICE_ENUM(MyEnum, enum3)); + c->seq9.push_back(ICE_ENUM(MyEnum, enum2)); + c->seq9.push_back(ICE_ENUM(MyEnum, enum1)); ex.c = c; +#ifndef ICE_CPP11_MAPPING + // + // No GC support in C++11. + // ex.c->ice_collectable(true); +#endif - out->write(ex); - out->finished(data); + out.write(ex); + out.finished(data); - in = Ice::createInputStream(communicator, data); + Ice::InputStream in(communicator, data); try { - in->throwException(); + in.throwException(); test(false); } - catch(const Test::MyException& ex1) + catch(const MyException& ex1) { test(ex1.c->s.e == c->s.e); test(ex1.c->seq1 == c->seq1); @@ -923,89 +1027,89 @@ run(int, char**, const Ice::CommunicatorPtr& communicator) } { - Test::ByteBoolD dict; + ByteBoolD dict; dict[0x04] = true; dict[0x01] = false; - out = Ice::createOutputStream(communicator); - out->write(dict); - out->finished(data); - in = Ice::createInputStream(communicator, data); - Test::ByteBoolD dict2; - in->read(dict2); + Ice::OutputStream out(communicator); + out.write(dict); + out.finished(data); + Ice::InputStream in(communicator, data); + ByteBoolD dict2; + in.read(dict2); test(dict2 == dict); } { - Test::ShortIntD dict; + ShortIntD dict; dict[1] = 9; dict[4] = 8; - out = Ice::createOutputStream(communicator); - out->write(dict); - out->finished(data); - in = Ice::createInputStream(communicator, data); - Test::ShortIntD dict2; - in->read(dict2); + Ice::OutputStream out(communicator); + out.write(dict); + out.finished(data); + Ice::InputStream in(communicator, data); + ShortIntD dict2; + in.read(dict2); test(dict2 == dict); } { - Test::LongFloatD dict; + LongFloatD dict; dict[123809828] = 0.51f; dict[123809829] = 0.56f; - out = Ice::createOutputStream(communicator); - out->write(dict); - out->finished(data); - in = Ice::createInputStream(communicator, data); - Test::LongFloatD dict2; - in->read(dict2); + Ice::OutputStream out(communicator); + out.write(dict); + out.finished(data); + Ice::InputStream in(communicator, data); + LongFloatD dict2; + in.read(dict2); test(dict2 == dict); } { - Test::StringStringD dict; + StringStringD dict; dict["key1"] = "value1"; dict["key2"] = "value2"; - out = Ice::createOutputStream(communicator); - out->write(dict); - out->finished(data); - in = Ice::createInputStream(communicator, data); - Test::StringStringD dict2; - in->read(dict2); + Ice::OutputStream out(communicator); + out.write(dict); + out.finished(data); + Ice::InputStream in(communicator, data); + StringStringD dict2; + in.read(dict2); test(dict2 == dict); } { - Test::StringMyClassD dict; - dict["key1"] = new Test::MyClass; - dict["key1"]->s.e = Test::enum2; - dict["key2"] = new Test::MyClass; - dict["key2"]->s.e = Test::enum3; - out = Ice::createOutputStream(communicator); - out->write(dict); - out->writePendingObjects(); - out->finished(data); - in = Ice::createInputStream(communicator, data); - Test::StringMyClassD dict2; - in->read(dict2); - in->readPendingObjects(); + StringMyClassD dict; + dict["key1"] = ICE_MAKE_SHARED(MyClass); + dict["key1"]->s.e = ICE_ENUM(MyEnum, enum2); + dict["key2"] = ICE_MAKE_SHARED(MyClass); + dict["key2"]->s.e = ICE_ENUM(MyEnum, enum3); + Ice::OutputStream out(communicator); + out.write(dict); + out.writePendingObjects(); + out.finished(data); + Ice::InputStream in(communicator, data); + StringMyClassD dict2; + in.read(dict2); + in.readPendingObjects(); test(dict2.size() == dict.size()); - test(dict2["key1"] && (dict2["key1"]->s.e == Test::enum2)); - test(dict2["key2"] && (dict2["key2"]->s.e == Test::enum3)); + test(dict2["key1"] && (dict2["key1"]->s.e == ICE_ENUM(MyEnum, enum2))); + test(dict2["key2"] && (dict2["key2"]->s.e == ICE_ENUM(MyEnum, enum3))); } { - out = Ice::createOutputStream(communicator); - out->write(Test::Sub::nestedEnum3); - out->finished(data); - in = Ice::createInputStream(communicator, data); - Test::Sub::NestedEnum e; - in->read(e); - test(e == Test::Sub::nestedEnum3); + Ice::OutputStream out(communicator); + out.write(ICE_ENUM(Sub::NestedEnum, nestedEnum3)); + out.finished(data); + Ice::InputStream in(communicator, data); + NestedEnum e; + in.read(e); + test(e == ICE_ENUM(Sub::NestedEnum, nestedEnum3)); } { - out = Ice::createOutputStream(communicator); - Test::Sub::NestedStruct s; + Ice::OutputStream out(communicator); + NestedStruct s; s.bo = true; s.by = 1; s.sh = 2; @@ -1014,60 +1118,70 @@ run(int, char**, const Ice::CommunicatorPtr& communicator) s.f = 5.0; s.d = 6.0; s.str = "7"; - s.e = Test::Sub::nestedEnum2; - out->write(s); - out->finished(data); - in = Ice::createInputStream(communicator, data); - Test::Sub::NestedStruct s2; - in->read(s2); + s.e = ICE_ENUM(Sub::NestedEnum, nestedEnum2); + out.write(s); + out.finished(data); + Ice::InputStream in(communicator, data); + NestedStruct s2; + in.read(s2); +#ifndef ICE_CPP11_MAPPING + // + // No comparison operator generated in C++11. + // test(s2 == s); +#endif } +#ifndef ICE_CPP11_MAPPING + // + // No support for struct-as-class in C++11. + // { - out = Ice::createOutputStream(communicator); - Test::Sub::NestedClassStructPtr s = new Test::Sub::NestedClassStruct(); + Ice::OutputStream out(communicator); + NestedClassStructPtr s = new NestedClassStruct(); s->i = 10; - out->write(s); - out->finished(data); - in = Ice::createInputStream(communicator, data); - Test::Sub::NestedClassStructPtr s2 = new Test::Sub::NestedClassStruct(); - in->read(s2); + out.write(s); + out.finished(data); + Ice::InputStream in(communicator, data); + NestedClassStructPtr s2 = new NestedClassStruct(); + in.read(s2); test(s2->i == s->i); } +#endif { - out = Ice::createOutputStream(communicator); - Test::Sub::NestedException ex; + Ice::OutputStream out(communicator); + NestedException ex; ex.str = "str"; - out->write(ex); - out->finished(data); + out.write(ex); + out.finished(data); - in = Ice::createInputStream(communicator, data); + Ice::InputStream in(communicator, data); try { - in->throwException(); + in.throwException(); test(false); } - catch(const Test::Sub::NestedException& ex1) + catch(const NestedException& ex1) { test(ex1.str == ex.str); } } { - out = Ice::createOutputStream(communicator); - out->write(Test2::Sub2::nestedEnum4); - out->finished(data); - in = Ice::createInputStream(communicator, data); - Test2::Sub2::NestedEnum2 e; - in->read(e); - test(e == Test2::Sub2::nestedEnum4); + Ice::OutputStream out(communicator); + out.write(ICE_ENUM(NestedEnum2, nestedEnum4)); + out.finished(data); + Ice::InputStream in(communicator, data); + NestedEnum2 e; + in.read(e); + test(e == ICE_ENUM(NestedEnum2, nestedEnum4)); } { - out = Ice::createOutputStream(communicator); - Test2::Sub2::NestedStruct2 s; + Ice::OutputStream out(communicator); + NestedStruct2 s; s.bo = true; s.by = 1; s.sh = 2; @@ -1076,42 +1190,52 @@ run(int, char**, const Ice::CommunicatorPtr& communicator) s.f = 5.0; s.d = 6.0; s.str = "7"; - s.e = Test2::Sub2::nestedEnum5; - out->write(s); - out->finished(data); - in = Ice::createInputStream(communicator, data); - Test2::Sub2::NestedStruct2 s2; - in->read(s2); + s.e = ICE_ENUM(NestedEnum2, nestedEnum5); + out.write(s); + out.finished(data); + Ice::InputStream in(communicator, data); + NestedStruct2 s2; + in.read(s2); +#ifndef ICE_CPP11_MAPPING + // + // No comparison operator generated in C++11. + // test(s2 == s); +#endif } +#ifndef ICE_CPP11_MAPPING + // + // No support for struct-as-class in C++11. + // { - out = Ice::createOutputStream(communicator); - Test2::Sub2::NestedClassStruct2Ptr s = new Test2::Sub2::NestedClassStruct2(); + Ice::OutputStream out(communicator); + NestedClassStruct2Ptr s = new NestedClassStruct2(); s->i = 10; - out->write(s); - out->finished(data); - in = Ice::createInputStream(communicator, data); - Test2::Sub2::NestedClassStruct2Ptr s2 = new Test2::Sub2::NestedClassStruct2(); - in->read(s2); + out.write(s); + out.finished(data); + Ice::InputStream in(communicator, data); + NestedClassStruct2Ptr s2 = new NestedClassStruct2(); + in.read(s2); test(s2->i == s->i); } +#endif { - out = Ice::createOutputStream(communicator); - Test2::Sub2::NestedException2 ex; + Ice::OutputStream out(communicator); + NestedException2 ex; ex.str = "str"; - out->write(ex); - out->finished(data); + out.write(ex); + out.finished(data); - in = Ice::createInputStream(communicator, data); + Ice::InputStream in(communicator, data); try { - in->throwException(); + in.throwException(); test(false); } - catch(const Test2::Sub2::NestedException2& ex1) + catch(const NestedException2& ex1) { test(ex1.str == ex.str); } diff --git a/cpp/test/Ice/stream/Makefile b/cpp/test/Ice/stream/Makefile index eea484e4c0a..e5c0e3e21d8 100644 --- a/cpp/test/Ice/stream/Makefile +++ b/cpp/test/Ice/stream/Makefile @@ -23,7 +23,7 @@ OBJS = $(COBJS) include $(top_srcdir)/config/Make.rules CPPFLAGS := -I. -I../../include $(CPPFLAGS) -SLICE2CPPFLAGS := --stream $(SLICE2CPPFLAGS) -I$(slicedir) +SLICE2CPPFLAGS := $(SLICE2CPPFLAGS) -I$(slicedir) $(CLIENT): $(COBJS) rm -f $@ diff --git a/cpp/test/Ice/stream/Makefile.mak b/cpp/test/Ice/stream/Makefile.mak index e48a05aeeca..2606d3398e3 100644 --- a/cpp/test/Ice/stream/Makefile.mak +++ b/cpp/test/Ice/stream/Makefile.mak @@ -30,7 +30,7 @@ OBJS = $(SLICE_OBJS) \ !include $(top_srcdir)/config/Make.rules.mak -SLICE2CPPFLAGS = --stream $(SLICE2CPPFLAGS) +SLICE2CPPFLAGS = $(SLICE2CPPFLAGS) CPPFLAGS = -I. -I../../include $(CPPFLAGS) -DWIN32_LEAN_AND_MEAN !if "$(GENERATE_PDB)" == "yes" diff --git a/cpp/test/Ice/stream/Test.ice b/cpp/test/Ice/stream/Test.ice index ec65a8c1e6c..845f8eb2b15 100644 --- a/cpp/test/Ice/stream/Test.ice +++ b/cpp/test/Ice/stream/Test.ice @@ -21,6 +21,7 @@ enum MyEnum enum3 }; +interface MyInterface; class MyClass; ["cpp:comparable"] struct SmallStruct @@ -34,7 +35,7 @@ class MyClass; double d; string str; MyEnum e; - MyClass* p; + MyInterface* p; }; ["cpp:class"] struct ClassStruct |