Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New approach for slicing classes and exceptions #1719

Closed
wants to merge 26 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG-3.8.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ These are the changes since the Ice 3.7.10 release in [CHANGELOG-3.7.md](./CHANG

## Slice Language Changes

- Removed support for the `["preserve-slice"]` metadata. Slice classes encoded in the Sliced-format are now always
full-preserved.

- Exceptions are now always encoded in the Sliced-format and no longer support preservation of unknown type slices.

- Removed local Slice. `local` is no longer a Slice keyword.

- Slice classes can no longer define operations or implement interfaces, and `implements` is no longer a Slice keyword.
Expand Down
2 changes: 1 addition & 1 deletion config/Make.rules.Darwin
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ endif
shared_cppflags = $(if $(filter-out program,$($1_target)),-fPIC) -fvisibility=hidden

cppflags = -Wall -Wextra -Wshadow -Wshadow-all -Wredundant-decls -Wno-shadow-field \
-Wdeprecated -Wstrict-prototypes -Werror -Wconversion -Wdocumentation -pthread \
-Wdeprecated -Wstrict-prototypes -Wconversion -Wdocumentation -pthread \
$(if $(filter yes,$(OPTIMIZE)),-O2 -DNDEBUG,-g)

ifeq ($(MAXWARN),yes)
Expand Down
3 changes: 0 additions & 3 deletions cpp/include/Ice/Exception.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include <Ice/Format.h>
#include <Ice/ObjectF.h>
#include <Ice/ValueF.h>
#include <Ice/SlicedDataF.h>

namespace Ice
{
Expand Down Expand Up @@ -64,8 +63,6 @@ class ICE_API UserException : public IceUtil::Exception
*/
std::unique_ptr<UserException> ice_clone() const;

virtual Ice::SlicedDataPtr ice_getSlicedData() const;

/**
* Obtains the Slice type ID of this exception.
* @return The fully-scoped type ID.
Expand Down
20 changes: 7 additions & 13 deletions cpp/include/Ice/InputStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -312,14 +312,12 @@ class ICE_API InputStream : public IceInternal::Buffer
/**
* Marks the end of a class instance.
*
* @param preserve Pass true and the stream will preserve the unknown slices of the instance, or false
* to discard the unknown slices.
* @return An object that encapsulates the unknown slice data.
*/
SlicedDataPtr endValue(bool preserve)
SlicedDataPtr endValue()
{
assert(_currentEncaps && _currentEncaps->decoder);
return _currentEncaps->decoder->endInstance(preserve);
return _currentEncaps->decoder->endInstance();
}

/**
Expand All @@ -333,15 +331,11 @@ class ICE_API InputStream : public IceInternal::Buffer

/**
* Marks the end of a user exception.
*
* @param preserve Pass true and the stream will preserve the unknown slices of the exception, or false
* to discard the unknown slices.
* @return An object that encapsulates the unknown slice data.
*/
SlicedDataPtr endException(bool preserve)
void endException()
{
assert(_currentEncaps && _currentEncaps->decoder);
return _currentEncaps->decoder->endInstance(preserve);
_currentEncaps->decoder->endInstance();
}

/**
Expand Down Expand Up @@ -1097,7 +1091,7 @@ class ICE_API InputStream : public IceInternal::Buffer
virtual void throwException(UserExceptionFactory) = 0;

virtual void startInstance(SliceType) = 0;
virtual SlicedDataPtr endInstance(bool) = 0;
virtual SlicedDataPtr endInstance() = 0;
virtual std::string_view startSlice() = 0;
virtual void endSlice() = 0;
virtual void skipSlice() = 0;
Expand Down Expand Up @@ -1172,7 +1166,7 @@ class ICE_API InputStream : public IceInternal::Buffer
virtual void throwException(UserExceptionFactory);

virtual void startInstance(SliceType);
virtual SlicedDataPtr endInstance(bool);
virtual SlicedDataPtr endInstance();
virtual std::string_view startSlice();
virtual void endSlice();
virtual void skipSlice();
Expand Down Expand Up @@ -1207,7 +1201,7 @@ class ICE_API InputStream : public IceInternal::Buffer
virtual void throwException(UserExceptionFactory);

virtual void startInstance(SliceType);
virtual SlicedDataPtr endInstance(bool);
virtual SlicedDataPtr endInstance();
virtual std::string_view startSlice();
virtual void endSlice();
virtual void skipSlice();
Expand Down
6 changes: 2 additions & 4 deletions cpp/include/Ice/OutputStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,11 @@ class ICE_API OutputStream : public IceInternal::Buffer

/**
* Marks the start of an exception instance.
* @param data Contains the marshaled form of unknown slices from this instance. If not nil,
* these slices will be marshaled with the instance.
*/
void startException(const SlicedDataPtr& data)
void startException()
{
assert(_currentEncaps && _currentEncaps->encoder);
_currentEncaps->encoder->startInstance(ExceptionSlice, data);
_currentEncaps->encoder->startInstance(ExceptionSlice, nullptr);
}

/**
Expand Down
13 changes: 0 additions & 13 deletions cpp/include/Ice/SlicedData.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,6 @@ class ICE_API UnknownSlicedValue : public Value
*/
UnknownSlicedValue(const std::string& unknownTypeId);

/**
* Obtains the sliced data associated with this instance.
* @return The sliced data if the value has a preserved-slice base class and has been sliced during
* unmarshaling of the value, or nil otherwise.
*/
virtual SlicedDataPtr ice_getSlicedData() const override;

/**
* Determine the Slice type ID associated with this instance.
* @return The type ID supplied to the constructor.
Expand All @@ -103,11 +96,6 @@ class ICE_API UnknownSlicedValue : public Value
return std::static_pointer_cast<UnknownSlicedValue>(_iceCloneImpl());
}

/// \cond STREAM
virtual void _iceWrite(::Ice::OutputStream*) const override;
virtual void _iceRead(::Ice::InputStream*) override;
/// \endcond

protected:

/// \cond INTERNAL
Expand All @@ -117,7 +105,6 @@ class ICE_API UnknownSlicedValue : public Value
private:

const std::string _unknownTypeId;
SlicedDataPtr _slicedData;
};

}
Expand Down
6 changes: 5 additions & 1 deletion cpp/include/Ice/Value.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class ICE_API Value
* @return The sliced data if the value has a preserved-slice base class and has been sliced during
* unmarshaling of the value, nil otherwise.
*/
virtual SlicedDataPtr ice_getSlicedData() const;
SlicedDataPtr ice_getSlicedData() const;

/// \cond STREAM
virtual void _iceWrite(Ice::OutputStream*) const;
Expand All @@ -93,6 +93,10 @@ class ICE_API Value
virtual void _iceWriteImpl(Ice::OutputStream*) const {}
virtual void _iceReadImpl(Ice::InputStream*) {}
/// \endcond

private:

::std::shared_ptr<Ice::SlicedData> _slicedData;
};

/// \cond INTERNAL
Expand Down
10 changes: 2 additions & 8 deletions cpp/src/Ice/Exception.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,16 +97,10 @@ Ice::UserException::ice_clone() const
return unique_ptr<UserException>(static_cast<UserException*>(ice_cloneImpl()));
}

Ice::SlicedDataPtr
Ice::UserException::ice_getSlicedData() const
{
return nullptr;
}

void
Ice::UserException::_write(::Ice::OutputStream* os) const
{
os->startException(0);
os->startException();
_writeImpl(os);
os->endException();
}
Expand All @@ -116,7 +110,7 @@ Ice::UserException::_read(::Ice::InputStream* is)
{
is->startException();
_readImpl(is);
is->endException(false);
is->endException();
}

bool
Expand Down
55 changes: 25 additions & 30 deletions cpp/src/Ice/InputStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1880,7 +1880,7 @@ Ice::InputStream::EncapsDecoder10::startInstance(SliceType)
}

SlicedDataPtr
Ice::InputStream::EncapsDecoder10::endInstance(bool)
Ice::InputStream::EncapsDecoder10::endInstance()
{
//
// Read the Ice::Value slice.
Expand Down Expand Up @@ -2182,15 +2182,11 @@ Ice::InputStream::EncapsDecoder11::startInstance(SliceType)
}

SlicedDataPtr
Ice::InputStream::EncapsDecoder11::endInstance(bool preserve)
Ice::InputStream::EncapsDecoder11::endInstance()
{
SlicedDataPtr slicedData;
if (preserve)
{
slicedData = readSlicedData();
}
_current->slices.clear();
SlicedDataPtr slicedData = readSlicedData();
_current->indirectionTables.clear();
_current->slices.clear();
_current = _current->previous;
return slicedData;
}
Expand Down Expand Up @@ -2337,36 +2333,37 @@ Ice::InputStream::EncapsDecoder11::skipSlice()
}

//
// Preserve this slice.
// Preserve this slice if unmarshalling a value in Slice format. Exception slices are not preserved.
//
SliceInfoPtr info = make_shared<SliceInfo>();
info->typeId = _current->typeId;
info->compactId = _current->compactId;
info->hasOptionalMembers = _current->sliceFlags & FLAG_HAS_OPTIONAL_MEMBERS;
info->isLastSlice = _current->sliceFlags & FLAG_IS_LAST_SLICE;
if (info->hasOptionalMembers)
{
//
// Don't include the optional member end marker. It will be re-written by
// endSlice when the sliced data is re-written.
//
vector<uint8_t>(start, _stream->i - 1).swap(info->bytes);
}
else
if (_current->sliceType == ValueSlice)
{
vector<uint8_t>(start, _stream->i).swap(info->bytes);
SliceInfoPtr info = make_shared<SliceInfo>();
info->typeId = _current->typeId;
info->compactId = _current->compactId;
info->hasOptionalMembers = _current->sliceFlags & FLAG_HAS_OPTIONAL_MEMBERS;
info->isLastSlice = _current->sliceFlags & FLAG_IS_LAST_SLICE;
if (info->hasOptionalMembers)
{
//
// Don't include the optional member end marker. It will be re-written by
// endSlice when the sliced data is re-written.
//
vector<uint8_t>(start, _stream->i - 1).swap(info->bytes);
}
else
{
vector<uint8_t>(start, _stream->i).swap(info->bytes);
}
_current->slices.push_back(info);
}

_current->indirectionTables.push_back(IndexList());

//
// Read the indirect object table. We read the instances or their
// IDs if the instance is a reference to an already un-marhsaled
// IDs if the instance is a reference to an already un-marshaled
// object.
//
// The SliceInfo object sequence is initialized only if
// readSlicedData is called.
//
if (_current->sliceFlags & FLAG_HAS_INDIRECTION_TABLE)
{
IndexList& table = _current->indirectionTables.back();
Expand All @@ -2376,8 +2373,6 @@ Ice::InputStream::EncapsDecoder11::skipSlice()
*p = readInstance(_stream->readSize(), 0, 0);
}
}

_current->slices.push_back(info);
}

bool
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/Ice/OutgoingAsync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -958,7 +958,7 @@ LambdaInvoke::handleException(std::exception_ptr) noexcept
bool
LambdaInvoke::handleResponse(bool)
{
return _response != nullptr;
return (_response) != nullptr;
}

void
Expand Down
2 changes: 2 additions & 0 deletions cpp/src/Ice/OutputStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -850,6 +850,8 @@ void
Ice::OutputStream::writeException(const UserException& e)
{
initEncaps();
// Exceptions are always encoded with the sliced format.
_currentEncaps->format = FormatType::SlicedFormat;
_currentEncaps->encoder->write(e);
}

Expand Down
2 changes: 2 additions & 0 deletions cpp/src/Ice/RequestHandlerCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,4 +329,6 @@ RequestHandlerCache::handleException(
assert(false);
return 0;
}
assert(false);
return 0;
}
20 changes: 0 additions & 20 deletions cpp/src/Ice/SlicedData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,6 @@ Ice::UnknownSlicedValue::UnknownSlicedValue(const string& unknownTypeId) : _unkn
{
}

SlicedDataPtr
Ice::UnknownSlicedValue::ice_getSlicedData() const
{
return _slicedData;
}

string
Ice::UnknownSlicedValue::ice_id() const
{
Expand All @@ -53,17 +47,3 @@ Ice::UnknownSlicedValue::_iceCloneImpl() const
{
return make_shared<UnknownSlicedValue>(static_cast<const UnknownSlicedValue&>(*this));
}

void
Ice::UnknownSlicedValue::_iceWrite(Ice::OutputStream* ostr) const
{
ostr->startValue(_slicedData);
ostr->endValue();
}

void
Ice::UnknownSlicedValue::_iceRead(Ice::InputStream* istr)
{
istr->startValue();
_slicedData = istr->endValue(true);
}
6 changes: 3 additions & 3 deletions cpp/src/Ice/Value.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Ice::Value::ice_postUnmarshal()
void
Ice::Value::_iceWrite(Ice::OutputStream* os) const
{
os->startValue(0);
os->startValue(_slicedData);
_iceWriteImpl(os);
os->endValue();
}
Expand All @@ -35,7 +35,7 @@ Ice::Value::_iceRead(Ice::InputStream* is)
{
is->startValue();
_iceReadImpl(is);
is->endValue(false);
_slicedData = is->endValue();
}

string
Expand All @@ -54,7 +54,7 @@ Ice::Value::ice_staticId()
SlicedDataPtr
Ice::Value::ice_getSlicedData() const
{
return nullptr;
return _slicedData;
}

std::shared_ptr<Ice::Value>
Expand Down
Loading