diff options
Diffstat (limited to 'cpp/include')
-rw-r--r-- | cpp/include/Ice/.gitignore | 1 | ||||
-rw-r--r-- | cpp/include/Ice/BasicStream.h | 99 | ||||
-rw-r--r-- | cpp/include/Ice/Exception.h | 10 | ||||
-rw-r--r-- | cpp/include/Ice/Format.h | 39 | ||||
-rw-r--r-- | cpp/include/Ice/Object.h | 23 | ||||
-rw-r--r-- | cpp/include/Ice/SlicedData.h | 84 | ||||
-rw-r--r-- | cpp/include/Ice/SlicedDataF.h | 30 | ||||
-rw-r--r-- | cpp/include/Ice/Stream.h | 141 | ||||
-rw-r--r-- | cpp/include/Ice/UserExceptionFactory.h | 2 | ||||
-rw-r--r-- | cpp/include/Slice/CPlusPlusUtil.h | 1 | ||||
-rw-r--r-- | cpp/include/Slice/Parser.h | 13 |
11 files changed, 352 insertions, 91 deletions
diff --git a/cpp/include/Ice/.gitignore b/cpp/include/Ice/.gitignore index afeb219a27a..1566a24c88f 100644 --- a/cpp/include/Ice/.gitignore +++ b/cpp/include/Ice/.gitignore @@ -36,3 +36,4 @@ ServantLocator.h SliceChecksumDict.h StatsF.h Stats.h +Version.h diff --git a/cpp/include/Ice/BasicStream.h b/cpp/include/Ice/BasicStream.h index e243d78199e..ca1e2264999 100644 --- a/cpp/include/Ice/BasicStream.h +++ b/cpp/include/Ice/BasicStream.h @@ -16,6 +16,8 @@ #include <Ice/ObjectFactoryF.h> #include <Ice/Buffer.h> #include <Ice/Protocol.h> +#include <Ice/SlicedDataF.h> +#include <Ice/UserExceptionFactory.h> namespace Ice { @@ -76,12 +78,26 @@ public: { IceInternal::Ex::throwMemoryLimitException(__FILE__, __LINE__, sz, _messageSizeMax); } - + b.resize(sz); } + void format(Ice::FormatType); + + void startWriteObject(const Ice::SlicedDataPtr&); + void endWriteObject(); + + void startReadObject(); + Ice::SlicedDataPtr endReadObject(bool); + + void startWriteException(const Ice::SlicedDataPtr&); + void endWriteException(); + + void startReadException(); + Ice::SlicedDataPtr endReadException(bool); + void startWriteEncaps(); - + void startWriteEncaps(const Ice::EncodingVersion& encoding) { checkSupportedEncoding(encoding); @@ -207,7 +223,7 @@ public: { throwEncapsulationException(__FILE__, __LINE__); } - + // // Ice version < 3.3 had a bug where user exceptions with // class members could be encoded with a trailing byte @@ -275,10 +291,10 @@ public: Ice::Int getReadEncapsSize(); Ice::EncodingVersion skipEncaps(); - void startWriteSlice(); + void startWriteSlice(const std::string&, bool); void endWriteSlice(); - void startReadSlice(); + std::string startReadSlice(); // Returns type ID of next slice void endReadSlice(); void skipSlice(); @@ -339,10 +355,7 @@ public: } } - void readAndCheckSeqSize(int, Ice::Int&); - - void writeTypeId(const std::string&); - void readTypeId(std::string&); + void readAndCheckSeqSize(int, Ice::Int&); void writeBlob(const std::vector<Ice::Byte>&); void readBlob(std::vector<Ice::Byte>&, Ice::Int); @@ -553,14 +566,21 @@ public: void read(PatchFunc, void*); void write(const Ice::UserException&); - void throwException(); + void throwException(const UserExceptionFactoryPtr& = 0); void writePendingObjects(); void readPendingObjects(); void sliceObjects(bool); - struct PatchEntry + struct IndirectPatchEntry + { + Ice::Int index; + PatchFunc patchFunc; + void* patchAddr; + }; + + struct PatchEntry { PatchFunc patchFunc; void* patchAddr; @@ -576,6 +596,12 @@ public: typedef std::vector<Ice::ObjectPtr> ObjectList; + typedef std::vector<IndirectPatchEntry> IndirectPatchList; + typedef std::vector<Ice::Int> IndexList; + typedef std::map<Ice::Int, Ice::Int> IndirectionMap; + + typedef std::vector<IndexList> IndexListList; + private: // @@ -602,7 +628,7 @@ private: { public: - ReadEncaps() : patchMap(0), unmarshaledMap(0), typeIdMap(0), typeIdIndex(0), previous(0) + ReadEncaps() : patchMap(0), unmarshaledMap(0), typeIdMap(0), typeIdIndex(0), indirectPatchList(0), previous(0) { // Inlined for performance reasons. } @@ -612,6 +638,7 @@ private: delete patchMap; delete unmarshaledMap; delete typeIdMap; + delete indirectPatchList; } void reset() { @@ -619,11 +646,13 @@ private: delete patchMap; delete unmarshaledMap; delete typeIdMap; + delete indirectPatchList; patchMap = 0; unmarshaledMap = 0; typeIdMap = 0; typeIdIndex = 0; + indirectPatchList = 0; previous = 0; } void swap(ReadEncaps&); @@ -636,6 +665,7 @@ private: IndexToPtrMap* unmarshaledMap; TypeIdReadMap* typeIdMap; Ice::Int typeIdIndex; + IndirectPatchList* indirectPatchList; ReadEncaps* previous; }; @@ -644,7 +674,8 @@ private: { public: - WriteEncaps() : writeIndex(0), toBeMarshaledMap(0),marshaledMap(0),typeIdMap(0), typeIdIndex(0), previous(0) + WriteEncaps() : writeIndex(0), toBeMarshaledMap(0), marshaledMap(0), typeIdMap(0), typeIdIndex(0), + indirectionTable(0), indirectionMap(0), previous(0) { // Inlined for performance reasons. } @@ -654,6 +685,8 @@ private: delete toBeMarshaledMap; delete marshaledMap; delete typeIdMap; + delete indirectionTable; + delete indirectionMap; } void reset() { @@ -661,12 +694,16 @@ private: delete toBeMarshaledMap; delete marshaledMap; delete typeIdMap; + delete indirectionTable; + delete indirectionMap; writeIndex = 0; toBeMarshaledMap = 0; marshaledMap = 0; typeIdMap = 0; typeIdIndex = 0; + indirectionTable = 0; + indirectionMap = 0; previous = 0; } void swap(WriteEncaps&); @@ -679,6 +716,8 @@ private: PtrToIndexMap* marshaledMap; TypeIdWriteMap* typeIdMap; Ice::Int typeIdIndex; + IndexList* indirectionTable; + IndirectionMap* indirectionMap; WriteEncaps* previous; }; @@ -694,14 +733,39 @@ private: ReadEncaps* _currentReadEncaps; WriteEncaps* _currentWriteEncaps; + void initReadEncaps(); + void initWriteEncaps(); + ReadEncaps _preAllocatedReadEncaps; WriteEncaps _preAllocatedWriteEncaps; Container::size_type _readSlice; Container::size_type _writeSlice; + Container::size_type _writeFlags; + + enum SliceType { NoSlice, ObjectSlice, ExceptionSlice }; + SliceType _sliceType; + bool _firstSlice; // This is true if we are in the initial slice (writing) + + bool _needSliceHeader; // This is true if the slice header needs to be read (reading) + Ice::Byte _sliceFlags; // The flags for the current slice (reading) + std::string _typeId; // The type ID of the current slice (reading) + + Ice::SliceInfoSeq _slices; // Preserved slices. + IndexListList _indirectionTables; // Indirection tables for the preserved slices. + + void readSliceHeader(); + void writeSliceHeader(Ice::Byte, const std::string&); + void readTypeId(bool, std::string&); + bool registerTypeId(const std::string&, Ice::Int&); + Ice::Int registerObject(const Ice::ObjectPtr&); void writeInstance(const Ice::ObjectPtr&, Ice::Int); + void readInstance(); void patchPointers(Ice::Int, IndexToPtrMap::const_iterator, PatchMap::iterator); + void addPatchEntry(Ice::Int, PatchFunc, void*); + void writeSlicedData(const Ice::SlicedDataPtr&); + Ice::SlicedDataPtr prepareSlicedData(); int _traceSlicing; const char* _slicingCat; @@ -718,6 +782,15 @@ private: int _minSeqSize; ObjectList* _objectList; + + Ice::FormatType _format; + + static const Ice::Byte FLAG_HAS_TYPE_ID_STRING; + static const Ice::Byte FLAG_HAS_TYPE_ID_INDEX; + static const Ice::Byte FLAG_HAS_OPTIONAL_MEMBERS; + static const Ice::Byte FLAG_HAS_INDIRECTION_TABLE; + static const Ice::Byte FLAG_HAS_SLICE_SIZE; + static const Ice::Byte FLAG_IS_LAST_SLICE; }; } // End namespace IceInternal diff --git a/cpp/include/Ice/Exception.h b/cpp/include/Ice/Exception.h index fff6c741922..d8ffd574f1c 100644 --- a/cpp/include/Ice/Exception.h +++ b/cpp/include/Ice/Exception.h @@ -12,6 +12,7 @@ #include <IceUtil/Exception.h> #include <Ice/Config.h> +#include <Ice/Format.h> #include <Ice/Handle.h> namespace IceInternal @@ -37,7 +38,7 @@ typedef IceUtil::Exception Exception; class ICE_API LocalException : public IceUtil::Exception { -public: +public: LocalException(const char*, int); virtual ~LocalException() throw(); @@ -46,19 +47,19 @@ public: virtual void ice_throw() const = 0; }; - class ICE_API UserException : public IceUtil::Exception { -public: +public: virtual std::string ice_name() const = 0; virtual Exception* ice_clone() const = 0; virtual void ice_throw() const = 0; virtual void __write(::IceInternal::BasicStream*) const = 0; - virtual void __read(::IceInternal::BasicStream*, bool) = 0; + virtual void __read(::IceInternal::BasicStream*) = 0; virtual bool __usesClasses() const; + virtual void __usesClasses(bool); }; typedef ::IceInternal::Handle<UserException> UserExceptionPtr; @@ -76,7 +77,6 @@ public: typedef ::IceInternal::Handle<SystemException> SystemExceptionPtr; - #if defined(__SUNPRO_CC) // // COMPILERFIX: With Sun CC the presence of the overloaded operator diff --git a/cpp/include/Ice/Format.h b/cpp/include/Ice/Format.h new file mode 100644 index 00000000000..0e4ceb77405 --- /dev/null +++ b/cpp/include/Ice/Format.h @@ -0,0 +1,39 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2011 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +#ifndef ICE_FORMAT_H +#define ICE_FORMAT_H + +#include <Ice/Config.h> + +namespace Ice +{ + +// +// This enumeration describes the possible formats for classes and exceptions. +// +ICE_API enum FormatType +{ + // + // Indicates that no preference was specified. + // + DefaultFormat, + // + // A minimal format that eliminates the possibility for slicing unrecognized types. + // + CompactFormat, + // + // Allow slicing and preserve slices for unknown types. + // + SlicedFormat +}; + +} + +#endif diff --git a/cpp/include/Ice/Object.h b/cpp/include/Ice/Object.h index a36e006fd1a..831842c6ad8 100644 --- a/cpp/include/Ice/Object.h +++ b/cpp/include/Ice/Object.h @@ -18,6 +18,7 @@ #include <Ice/IncomingAsyncF.h> #include <Ice/Current.h> #include <Ice/StreamF.h> +#include <Ice/Format.h> namespace IceInternal { @@ -98,16 +99,20 @@ public: virtual DispatchStatus __dispatch(IceInternal::Incoming&, const Current&); virtual DispatchStatus __collocDispatch(IceInternal::Direct&); - virtual void __write(IceInternal::BasicStream*) const; - virtual void __read(IceInternal::BasicStream*, bool); + virtual void __write(IceInternal::BasicStream*) const {} + virtual void __writeImpl(IceInternal::BasicStream*) const {} + virtual void __read(IceInternal::BasicStream*) {} + virtual void __readImpl(IceInternal::BasicStream*) {} - virtual void __write(const OutputStreamPtr&) const; - virtual void __read(const InputStreamPtr&, bool); + virtual void __write(const OutputStreamPtr&) const {} + virtual void __read(const InputStreamPtr&) {} + // // Virtual methods to support garbage collection of Slice class instances. These // methods are overriden by Slice classes which can have cycles. + // virtual void __addObject(IceInternal::GCCountMap&) {} - virtual bool __usesClasses() { return false; } + virtual bool __usesGC() { return false; } void __decRefUnsafe() { --_ref; @@ -125,8 +130,11 @@ class ICE_API Blobject : virtual public Object { public: + // // Returns true if ok, false if user exception. + // virtual bool ice_invoke(const std::vector<Byte>&, std::vector<Byte>&, const Current&) = 0; + virtual DispatchStatus __dispatch(IceInternal::Incoming&, const Current&); }; @@ -134,8 +142,11 @@ class ICE_API BlobjectArray : virtual public Object { public: + // // Returns true if ok, false if user exception. + // virtual bool ice_invoke(const std::pair<const Byte*, const Byte*>&, std::vector<Byte>&, const Current&) = 0; + virtual DispatchStatus __dispatch(IceInternal::Incoming&, const Current&); }; @@ -144,6 +155,7 @@ class ICE_API BlobjectAsync : virtual public Object public: virtual void ice_invoke_async(const AMD_Object_ice_invokePtr&, const std::vector<Byte>&, const Current&) = 0; + virtual DispatchStatus __dispatch(IceInternal::Incoming&, const Current&); }; @@ -153,6 +165,7 @@ public: virtual void ice_invoke_async(const AMD_Object_ice_invokePtr&, const std::pair<const Byte*, const Byte*>&, const Current&) = 0; + virtual DispatchStatus __dispatch(IceInternal::Incoming&, const Current&); }; diff --git a/cpp/include/Ice/SlicedData.h b/cpp/include/Ice/SlicedData.h new file mode 100644 index 00000000000..da6f6ea952f --- /dev/null +++ b/cpp/include/Ice/SlicedData.h @@ -0,0 +1,84 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2010 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +#ifndef ICE_SLICED_DATA_H +#define ICE_SLICED_DATA_H + +#include <Ice/SlicedDataF.h> +#include <Ice/ObjectF.h> +#include <Ice/GCShared.h> + +namespace Ice +{ + +// +// SliceInfo encapsulates the details of a slice for an unknown class or exception type. +// +struct ICE_API SliceInfo : public ::IceUtil::Shared +{ + // + // The Slice type ID for this slice. + // + ::std::string typeId; + + // + // The encoded bytes for this slice, including the leading size integer. + // + ::std::vector<Byte> bytes; + + // + // The Ice objects referenced by this slice. + // + ::std::vector<ObjectPtr> objects; +}; + +// +// SlicedData holds the slices of unknown types. +// +class ICE_API SlicedData : public ::IceInternal::GCShared +{ +public: + + SlicedData(const SliceInfoSeq&); + + const SliceInfoSeq slices; + + // + // Returns true if any of the preserved slices contain object references. + // + bool hasObjects() const + { + return _hasObjects; + } + + void clearObjects(); + + // + // The internal methods below are necessary to support garbage collection + // of Ice objects. + // + + virtual void __gcReachable(IceInternal::GCCountMap&) const; + virtual void __gcClear(); + + void __decRefUnsafe() + { + --_ref; + } + + void __addObject(IceInternal::GCCountMap&); + +private: + + bool _hasObjects; +}; + +} + +#endif diff --git a/cpp/include/Ice/SlicedDataF.h b/cpp/include/Ice/SlicedDataF.h new file mode 100644 index 00000000000..30c4ca4365c --- /dev/null +++ b/cpp/include/Ice/SlicedDataF.h @@ -0,0 +1,30 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2011 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +#ifndef ICE_SLICED_DATA_F_H +#define ICE_SLICED_DATA_F_H + +#include <IceUtil/Shared.h> +#include <Ice/Handle.h> + +namespace Ice +{ + +struct SliceInfo; +ICE_API IceUtil::Shared* upCast(SliceInfo*); +typedef IceInternal::Handle<SliceInfo> SliceInfoPtr; +typedef ::std::vector<SliceInfoPtr> SliceInfoSeq; + +class SlicedData; +ICE_API IceUtil::Shared* upCast(SlicedData*); +typedef IceInternal::Handle<SlicedData> SlicedDataPtr; + +} + +#endif diff --git a/cpp/include/Ice/Stream.h b/cpp/include/Ice/Stream.h index 4d3c4e4430e..adfcabf7991 100644 --- a/cpp/include/Ice/Stream.h +++ b/cpp/include/Ice/Stream.h @@ -15,19 +15,12 @@ #include <Ice/Object.h> #include <Ice/Exception.h> #include <Ice/Proxy.h> +#include <Ice/SlicedDataF.h> #include <IceUtil/Shared.h> namespace Ice { - -// -// COMPILERFIX: VC++ 6 compiler bug doesn't allow using templates for -// the Stream API. -// -// see: http://support.microsoft.com/kb/240866 -// http://support.microsoft.com/kb/241569 -// -#if !defined(_MSC_VER) || (_MSC_VER >= 1300) + enum StreamTraitType { StreamTraitTypeBuiltin, @@ -70,7 +63,7 @@ struct StreamTrait< ::std::vector<T> > // StreamTrait specialization for std::vector<bool>. Sequences of bool // are handled specifically because C++ optimizations for vector<bool> // prevent us from reading vector of bools the same way as other -// sequences (see StreamReader<StreamTraitTypeSequenceBool>::read +// sequences (see StreamReader<StreamTraitTypeSequenceBool>::read // implementation below) // // COMPILERFIX: BCC2010 doesn't allow use of full specialization over @@ -78,7 +71,7 @@ struct StreamTrait< ::std::vector<T> > // #ifndef __BCPLUSPLUS__ template<> -struct StreamTrait< ::std::vector<bool> > +struct StreamTrait< ::std::vector<bool> > { static const StreamTraitType type = StreamTraitTypeSequenceBool; static const int minWireSize = 1; @@ -218,8 +211,6 @@ struct StreamReader } }; -#endif - class ICE_API ReadObjectCallback : public ::IceUtil::Shared { public: @@ -253,6 +244,40 @@ private: ::IceInternal::Handle<T>& _v; }; +class ICE_API UserExceptionReader : public UserException +{ +public: + + UserExceptionReader(const CommunicatorPtr&); + ~UserExceptionReader() throw(); + + virtual void read(const InputStreamPtr&) const = 0; + virtual bool usesClasses() const = 0; + virtual void usesClasses(bool) = 0; + + virtual ::std::string ice_name() const = 0; + virtual Exception* ice_clone() const = 0; + virtual void ice_throw() const = 0; + + virtual void __write(IceInternal::BasicStream*) const; + virtual void __read(IceInternal::BasicStream*); + + virtual bool __usesClasses() const; + virtual void __usesClasses(bool); + +protected: + + const CommunicatorPtr _communicator; +}; + +class ICE_API UserExceptionReaderFactory : public IceUtil::Shared +{ +public: + + virtual void createAndThrow(const std::string&) const = 0; +}; +typedef ::IceUtil::Handle<UserExceptionReaderFactory> UserExceptionReaderFactoryPtr; + class ICE_API InputStream : public ::IceUtil::Shared { public: @@ -292,7 +317,7 @@ public: ICE_DEPRECATED_API virtual ::std::vector<Double> readDoubleSeq() = 0; ICE_DEPRECATED_API virtual ::std::vector< ::std::string> readStringSeq(bool = true) = 0; ICE_DEPRECATED_API virtual ::std::vector< ::std::wstring> readWstringSeq() = 0; - + ICE_DEPRECATED_API virtual bool* readBoolSeq(::std::pair<const bool*, const bool*>&) = 0; ICE_DEPRECATED_API virtual void readByteSeq(::std::pair<const Byte*, const Byte*>&) = 0; ICE_DEPRECATED_API virtual Short* readShortSeq(::std::pair<const Short*, const Short*>&) = 0; @@ -306,10 +331,17 @@ public: virtual ObjectPrx readProxy() = 0; virtual void readObject(const ReadObjectCallbackPtr&) = 0; - virtual ::std::string readTypeId() = 0; + virtual void throwException() = 0; + virtual void throwException(const UserExceptionReaderFactoryPtr&) = 0; - virtual void startSlice() = 0; + virtual void startObject() = 0; + virtual SlicedDataPtr endObject(bool) = 0; + + virtual void startException() = 0; + virtual SlicedDataPtr endException(bool) = 0; + + virtual std::string startSlice() = 0; virtual void endSlice() = 0; virtual void skipSlice() = 0; @@ -320,7 +352,7 @@ public: virtual void readPendingObjects() = 0; virtual void rewind() = 0; - + virtual void read(bool&) = 0; virtual void read(Byte&) = 0; virtual void read(Short&) = 0; @@ -331,7 +363,7 @@ public: virtual void read(::std::string&, bool = true) = 0; virtual void read(::std::vector< ::std::string>&, bool) = 0; // Overload required for additional bool argument. virtual void read(::std::wstring&) = 0; - + virtual void read(::std::pair<const bool*, const bool*>&, ::IceUtil::ScopedArray<bool>&) = 0; virtual void read(::std::pair<const Byte*, const Byte*>&) = 0; virtual void read(::std::pair<const Short*, const Short*>&, ::IceUtil::ScopedArray<Short>&) = 0; @@ -339,7 +371,7 @@ public: virtual void read(::std::pair<const Long*, const Long*>&, ::IceUtil::ScopedArray<Long>&) = 0; virtual void read(::std::pair<const Float*, const Float*>&, ::IceUtil::ScopedArray<Float>&) = 0; virtual void read(::std::pair<const Double*, const Double*>&, ::IceUtil::ScopedArray<Double>&) = 0; - + template<typename T> inline void read(::IceInternal::ProxyHandle<T>& v) { @@ -362,21 +394,14 @@ public: readObject(cb); } -// -// COMPILERFIX: VC++ 6 compiler bugs doesn't allow using templates for -// the Stream API. -// -// see: http://support.microsoft.com/kb/240866 -// http://support.microsoft.com/kb/241569 -// -#if !defined(_MSC_VER) || (_MSC_VER >= 1300) template<typename T> inline void read(T& v) { StreamReader< StreamTrait<T>::type>::read(this, v); } -#endif + virtual void closure(void*) = 0; + virtual void* closure() const = 0; }; class ICE_API OutputStream : public ::IceUtil::Shared @@ -393,9 +418,9 @@ public: ICE_DEPRECATED_API virtual void writeFloat(Float) = 0; ICE_DEPRECATED_API virtual void writeDouble(Double) = 0; ICE_DEPRECATED_API virtual void writeString(const ::std::string&, bool = true) = 0; - ICE_DEPRECATED_API virtual void writeWstring(const ::std::wstring&)= 0; - - ICE_DEPRECATED_API virtual void writeBoolSeq(const ::std::vector<bool>&) = 0; + ICE_DEPRECATED_API virtual void writeWstring(const ::std::wstring&)= 0; + + ICE_DEPRECATED_API virtual void writeBoolSeq(const ::std::vector<bool>&) = 0; ICE_DEPRECATED_API virtual void writeByteSeq(const ::std::vector<Byte>&) = 0; ICE_DEPRECATED_API virtual void writeShortSeq(const ::std::vector<Short>&) = 0; ICE_DEPRECATED_API virtual void writeIntSeq(const ::std::vector<Int>&) = 0; @@ -407,7 +432,7 @@ public: ICE_DEPRECATED_API virtual void writeBoolSeq(const bool*, const bool*) = 0; ICE_DEPRECATED_API virtual void writeByteSeq(const Byte*, const Byte*) = 0; - ICE_DEPRECATED_API virtual void writeShortSeq(const Short*, const Short*) = 0; + ICE_DEPRECATED_API virtual void writeShortSeq(const Short*, const Short*) = 0; ICE_DEPRECATED_API virtual void writeIntSeq(const Int*, const Int*) = 0; ICE_DEPRECATED_API virtual void writeLongSeq(const Long*, const Long*) = 0; ICE_DEPRECATED_API virtual void writeFloatSeq(const Float*, const Float*) = 0; @@ -416,10 +441,17 @@ public: virtual void writeSize(Int) = 0; virtual void writeProxy(const ObjectPrx&) = 0; virtual void writeObject(const ObjectPtr&) = 0; - virtual void writeTypeId(const ::std::string&) = 0; virtual void writeException(const UserException&) = 0; - virtual void startSlice() = 0; + virtual void format(FormatType) = 0; + + virtual void startObject(const SlicedDataPtr&) = 0; + virtual void endObject() = 0; + + virtual void startException(const SlicedDataPtr&) = 0; + virtual void endException() = 0; + + virtual void startSlice(const ::std::string&, bool) = 0; virtual void endSlice() = 0; virtual void startEncapsulation(const Ice::EncodingVersion&) = 0; @@ -431,7 +463,7 @@ public: virtual void finished(::std::vector<Byte>&) = 0; virtual void reset(bool) = 0; - + virtual void write(bool) = 0; virtual void write(Byte) = 0; virtual void write(Short) = 0; @@ -450,8 +482,8 @@ public: virtual void write(const Int*, const Int*) = 0; virtual void write(const Long*, const Long*) = 0; virtual void write(const Float*, const Float*) = 0; - virtual void write(const Double*, const Double*) = 0; - + virtual void write(const Double*, const Double*) = 0; + template<typename T> inline void write(const ::IceInternal::ProxyHandle<T>& v) { @@ -464,34 +496,13 @@ public: writeObject(v); } - -// -// COMPILERFIX: VC++ 6 compiler bugs doesn't allow using templates for -// the Stream API. -// -// see: http://support.microsoft.com/kb/240866 -// http://support.microsoft.com/kb/241569 -// -#if !defined(_MSC_VER) || (_MSC_VER >= 1300) template<typename T> inline void write(const T& v) { StreamWriter<StreamTrait<T>::type>::write(this, v); - } -#endif - -protected: - + } }; -// -// COMPILERFIX: VC++ 6 compiler bugs doesn't allow using templates for -// the Stream API. -// -// see: http://support.microsoft.com/kb/240866 -// http://support.microsoft.com/kb/241569 -// -#if !defined(_MSC_VER) || (_MSC_VER >= 1300) template<> // StreamWriter specialization for structs struct StreamWriter<StreamTraitTypeStruct> { @@ -562,7 +573,6 @@ struct StreamReader<StreamTraitTypeByteEnum> } }; - template<> // StreamWriter specialization for short enums struct StreamWriter<StreamTraitTypeShortEnum> { @@ -732,21 +742,19 @@ struct StreamWriter<StreamTraitTypeUserException> } }; -#endif - class ICE_API ObjectReader : public Object { public: - virtual void read(const InputStreamPtr&, bool) = 0; + virtual void read(const InputStreamPtr&) = 0; private: virtual void __write(::IceInternal::BasicStream*) const; - virtual void __read(::IceInternal::BasicStream*, bool = true); + virtual void __read(::IceInternal::BasicStream*); virtual void __write(const OutputStreamPtr&) const; - virtual void __read(const InputStreamPtr&, bool); + virtual void __read(const InputStreamPtr&); }; typedef ::IceInternal::Handle<ObjectReader> ObjectReaderPtr; @@ -766,7 +774,6 @@ private: }; typedef ::IceInternal::Handle<ObjectWriter> ObjectWriterPtr; - class ICE_API UserExceptionWriter : public UserException { public: @@ -782,7 +789,7 @@ public: virtual void ice_throw() const = 0; virtual void __write(IceInternal::BasicStream*) const; - virtual void __read(IceInternal::BasicStream*, bool); + virtual void __read(IceInternal::BasicStream*); virtual bool __usesClasses() const; diff --git a/cpp/include/Ice/UserExceptionFactory.h b/cpp/include/Ice/UserExceptionFactory.h index 42c709167f0..fd0e97f1cae 100644 --- a/cpp/include/Ice/UserExceptionFactory.h +++ b/cpp/include/Ice/UserExceptionFactory.h @@ -21,7 +21,7 @@ class ICE_API UserExceptionFactory : public IceUtil::Shared { public: - virtual void createAndThrow() = 0; + virtual void createAndThrow(const ::std::string&) = 0; virtual ~UserExceptionFactory() {} }; diff --git a/cpp/include/Slice/CPlusPlusUtil.h b/cpp/include/Slice/CPlusPlusUtil.h index c751dba88f0..641ad1f6098 100644 --- a/cpp/include/Slice/CPlusPlusUtil.h +++ b/cpp/include/Slice/CPlusPlusUtil.h @@ -39,6 +39,7 @@ SLICE_API std::string returnTypeToString(const TypePtr&, const StringList& = Str SLICE_API std::string inputTypeToString(const TypePtr&, const StringList& = StringList(), int = 0); SLICE_API std::string outputTypeToString(const TypePtr&, const StringList& = StringList(), int = 0); SLICE_API std::string operationModeToString(Operation::Mode); +SLICE_API std::string formatTypeToString(FormatType); SLICE_API std::string fixKwd(const std::string&); diff --git a/cpp/include/Slice/Parser.h b/cpp/include/Slice/Parser.h index 16e5f8bae91..ab0a2ebc929 100644 --- a/cpp/include/Slice/Parser.h +++ b/cpp/include/Slice/Parser.h @@ -69,6 +69,16 @@ SLICE_API enum NodeType Real }; +// +// Format preference for classes and exceptions. +// +SLICE_API enum FormatType +{ + DefaultFormat, // No preference was specified. + CompactFormat, // Minimal format. + SlicedFormat // Full format. +}; + class GrammarBase; class SyntaxTreeBase; class Type; @@ -354,6 +364,8 @@ public: void setMetaData(const std::list<std::string>&); void addMetaData(const std::string&); // TODO: remove this method once "cs:" and "vb:" are hard errors. + static FormatType parseFormatMetaData(const std::list<std::string>&); + enum ContainedType { ContainedTypeSequence, @@ -580,6 +592,7 @@ public: bool returnsClasses() const; bool returnsData() const; int attributes() const; + FormatType format() const; virtual std::string kindOf() const; virtual void visit(ParserVisitor*, bool); |