diff --git a/cpp/include/Ice/AsyncResponseHandler.h b/cpp/include/Ice/AsyncResponseHandler.h index d392d72ea61..cb0f774afd5 100644 --- a/cpp/include/Ice/AsyncResponseHandler.h +++ b/cpp/include/Ice/AsyncResponseHandler.h @@ -44,7 +44,7 @@ namespace IceInternal // else we ignore this call. } - void sendResponse(bool ok, const std::pair& encaps) noexcept + void sendResponse(bool ok, const std::pair& encaps) noexcept { if (!_responseSent.test_and_set()) { diff --git a/cpp/include/Ice/Buffer.h b/cpp/include/Ice/Buffer.h index 255ae6928f3..59833a8664d 100644 --- a/cpp/include/Ice/Buffer.h +++ b/cpp/include/Ice/Buffer.h @@ -13,8 +13,8 @@ namespace IceInternal { public: Buffer() : i(b.begin()) {} - Buffer(const std::uint8_t* beg, const std::uint8_t* end) : b(beg, end), i(b.begin()) {} - Buffer(const std::vector& v) : b(v), i(b.begin()) {} + Buffer(const std::byte* beg, const std::byte* end) : b(beg, end), i(b.begin()) {} + Buffer(const std::vector& v) : b(v), i(b.begin()) {} Buffer(Buffer& o, bool adopt) : b(o.b, adopt), i(b.begin()) {} void swapBuffer(Buffer&); @@ -25,14 +25,13 @@ namespace IceInternal // // Standard vector-like operations. // - - typedef std::uint8_t value_type; - typedef std::uint8_t* iterator; - typedef const std::uint8_t* const_iterator; - typedef std::uint8_t& reference; - typedef const std::uint8_t& const_reference; - typedef std::uint8_t* pointer; - typedef size_t size_type; + using value_type = std::byte; + using iterator = std::byte*; + using const_iterator = const std::byte*; + using reference = std::byte&; + using const_reference = const std::byte&; + using pointer = std::byte*; + using size_type = size_t; Container(); Container(const_iterator, const_iterator); diff --git a/cpp/include/Ice/InputStream.h b/cpp/include/Ice/InputStream.h index 828da68433c..4bc995e3c66 100644 --- a/cpp/include/Ice/InputStream.h +++ b/cpp/include/Ice/InputStream.h @@ -67,7 +67,7 @@ namespace Ice * You can supply a communicator later by calling initialize(). * @param bytes The encoded data. */ - InputStream(const std::vector& bytes); + InputStream(const std::vector& bytes); /** * Constructs a stream using the latest encoding version but without a communicator. @@ -76,7 +76,7 @@ namespace Ice * You can supply a communicator later by calling initialize(). * @param bytes The encoded data. */ - InputStream(const std::pair& bytes); + InputStream(const std::pair& bytes); /// \cond INTERNAL InputStream(IceInternal::Buffer&, bool = false); @@ -93,16 +93,14 @@ namespace Ice * @param communicator The communicator to use for unmarshaling tasks. * @param bytes The encoded data. */ - InputStream(const CommunicatorPtr& communicator, const std::vector& bytes); + InputStream(const CommunicatorPtr& communicator, const std::vector& bytes); /** * Constructs a stream using the communicator's default encoding version. * @param communicator The communicator to use for unmarshaling tasks. * @param bytes The encoded data. */ - InputStream( - const CommunicatorPtr& communicator, - const std::pair& bytes); + InputStream(const CommunicatorPtr& communicator, const std::pair& bytes); /// \cond INTERNAL InputStream(const CommunicatorPtr& communicator, IceInternal::Buffer&, bool = false); @@ -125,7 +123,7 @@ namespace Ice * @param version The encoding version used to encode the data to be unmarshaled. * @param bytes The encoded data. */ - InputStream(const EncodingVersion& version, const std::vector& bytes); + InputStream(const EncodingVersion& version, const std::vector& bytes); /** * Constructs a stream using the given encoding version but without a communicator. @@ -135,7 +133,7 @@ namespace Ice * @param version The encoding version used to encode the data to be unmarshaled. * @param bytes The encoded data. */ - InputStream(const EncodingVersion& version, const std::pair& bytes); + InputStream(const EncodingVersion& version, const std::pair& bytes); /// \cond INTERNAL InputStream(const EncodingVersion&, IceInternal::Buffer&, bool = false); @@ -157,7 +155,7 @@ namespace Ice InputStream( const CommunicatorPtr& communicator, const EncodingVersion& version, - const std::vector& bytes); + const std::vector& bytes); /** * Constructs a stream using the given communicator and encoding version. @@ -168,7 +166,7 @@ namespace Ice InputStream( const CommunicatorPtr& communicator, const EncodingVersion& version, - const std::pair& bytes); + const std::pair& bytes); /// \cond INTERNAL InputStream(const CommunicatorPtr&, const EncodingVersion&, IceInternal::Buffer&, bool = false); @@ -473,7 +471,7 @@ namespace Ice * @param sz The number of bytes in the encapsulation. * @return encoding The encapsulation's encoding version. */ - EncodingVersion readEncapsulation(const std::uint8_t*& v, std::int32_t& sz) + EncodingVersion readEncapsulation(const std::byte*& v, std::int32_t& sz) { EncodingVersion encoding; v = i; @@ -601,7 +599,7 @@ namespace Ice { if (sz > 0) { - v = reinterpret_cast(i); + v = i; if (static_cast(b.end() - i) < sz) { throwUnmarshalOutOfBoundsException(__FILE__, __LINE__); @@ -610,7 +608,7 @@ namespace Ice } else { - v = reinterpret_cast(i); + v = i; } } @@ -747,7 +745,7 @@ namespace Ice { throwUnmarshalOutOfBoundsException(__FILE__, __LINE__); } - v = static_cast(*i++); + v = *i++; } /** @@ -760,21 +758,21 @@ namespace Ice { throwUnmarshalOutOfBoundsException(__FILE__, __LINE__); } - v = *i++; + v = static_cast(*i++); } /** * Reads a sequence of bytes from the stream. * @param v A vector to hold a copy of the bytes. */ - void read(std::vector& v); + void read(std::vector& v); /** * Reads a sequence of bytes from the stream. * @param v A pair of pointers into the internal marshaling buffer representing the start and end of the * sequence elements. */ - void read(std::pair& v); + void read(std::pair& v); /** * Reads a bool from the stream. @@ -786,7 +784,7 @@ namespace Ice { throwUnmarshalOutOfBoundsException(__FILE__, __LINE__); } - v = (0 != *i++); + v = (std::byte{0} != *i++); } /** diff --git a/cpp/include/Ice/Object.h b/cpp/include/Ice/Object.h index 05991b9a38d..19082e0b585 100644 --- a/cpp/include/Ice/Object.h +++ b/cpp/include/Ice/Object.h @@ -125,10 +125,8 @@ namespace Ice * @throws UserException A user exception can be raised directly and the * run time will marshal it. */ - virtual bool ice_invoke( - std::vector inEncaps, - std::vector& outEncaps, - const Current& current) = 0; + virtual bool + ice_invoke(std::vector inEncaps, std::vector& outEncaps, const Current& current) = 0; void dispatch(IncomingRequest&, std::function) final; }; @@ -154,8 +152,8 @@ namespace Ice * run time will marshal it. */ virtual bool ice_invoke( - std::pair inEncaps, - std::vector& outEncaps, + std::pair inEncaps, + std::vector& outEncaps, const Current& current) = 0; void dispatch(IncomingRequest&, std::function) final; @@ -183,8 +181,8 @@ namespace Ice * run time will marshal it. */ virtual void ice_invokeAsync( - std::vector inEncaps, - std::function&)> response, + std::vector inEncaps, + std::function&)> response, std::function error, const Current& current) = 0; @@ -213,8 +211,8 @@ namespace Ice * run time will marshal it. */ virtual void ice_invokeAsync( - std::pair inEncaps, - std::function&)> response, + std::pair inEncaps, + std::function&)> response, std::function error, const Current& current) = 0; diff --git a/cpp/include/Ice/OutgoingAsync.h b/cpp/include/Ice/OutgoingAsync.h index b07d3722363..1193812b8b5 100644 --- a/cpp/include/Ice/OutgoingAsync.h +++ b/cpp/include/Ice/OutgoingAsync.h @@ -210,7 +210,7 @@ namespace IceInternal } void endWriteParams() { _os.endEncapsulation(); } void writeEmptyParams() { _os.writeEmptyEncapsulation(_encoding); } - void writeParamEncaps(const ::std::uint8_t* encaps, std::int32_t size) + void writeParamEncaps(const ::std::byte* encaps, std::int32_t size) { if (size == 0) { diff --git a/cpp/include/Ice/OutgoingResponse.h b/cpp/include/Ice/OutgoingResponse.h index ea37c2d4d35..586a11c80c9 100644 --- a/cpp/include/Ice/OutgoingResponse.h +++ b/cpp/include/Ice/OutgoingResponse.h @@ -160,7 +160,7 @@ namespace Ice */ ICE_API OutgoingResponse makeOutgoingResponse( bool ok, - const std::pair& encapsulation, + const std::pair& encapsulation, const Current& current) noexcept; /** diff --git a/cpp/include/Ice/OutputStream.h b/cpp/include/Ice/OutputStream.h index fd061f928b6..f4d38900445 100644 --- a/cpp/include/Ice/OutputStream.h +++ b/cpp/include/Ice/OutputStream.h @@ -57,7 +57,7 @@ namespace Ice OutputStream( const CommunicatorPtr& communicator, const EncodingVersion& version, - const std::pair& bytes); + const std::pair& bytes); ~OutputStream() { @@ -247,7 +247,7 @@ namespace Ice * @param v The start of the buffer. * @param sz The number of bytes to copy. */ - void writeEncapsulation(const std::uint8_t* v, std::int32_t sz) + void writeEncapsulation(const std::byte* v, std::int32_t sz) { if (sz < 6) { @@ -325,12 +325,12 @@ namespace Ice assert(v >= 0); if (v > 254) { - *dest++ = std::uint8_t(255); + *dest++ = std::byte{255}; write(v, dest); } else { - *dest = static_cast(v); + *dest = static_cast(v); } } @@ -360,12 +360,6 @@ namespace Ice */ void writeBlob(const std::vector& v); - /** - * Copies the specified blob of bytes to the stream without modification. - * @param v The bytes to be copied. - */ - void writeBlob(const std::vector& v); - /** * Copies the specified blob of bytes to the stream without modification. * @param v The start of the buffer to be copied. @@ -537,13 +531,20 @@ namespace Ice * Writes a byte to the stream. * @param v The byte to write. */ - void write(std::byte v) { b.push_back(static_cast(v)); } + void write(std::byte v) { b.push_back(v); } /** * Writes a byte to the stream. * @param v The byte to write. */ - void write(std::uint8_t v) { b.push_back(v); } + void write(std::uint8_t v) { b.push_back(std::byte{v}); } + + /** + * Writes a byte sequence to the stream. + * @param start The beginning of the sequence. + * @param end The end of the sequence. + */ + void write(const std::byte* start, const std::byte* end); /** * Writes a byte sequence to the stream. @@ -556,7 +557,7 @@ namespace Ice * Writes a boolean to the stream. * @param v The boolean to write. */ - void write(bool v) { b.push_back(static_cast(v)); } + void write(bool v) { b.push_back(static_cast(v)); } /** * Writes a boolean sequence to the stream. @@ -814,14 +815,14 @@ namespace Ice * Indicates that marshaling is complete. This function must only be called once. * @param v Filled with a copy of the encoded data. */ - void finished(std::vector& v); + void finished(std::vector& v); /** * Indicates that marshaling is complete. This function must only be called once. * @return A pair of pointers into the internal marshaling buffer. These pointers are * valid for the lifetime of the stream. */ - std::pair finished(); + std::pair finished(); /// \cond INTERNAL OutputStream(IceInternal::Instance*, const EncodingVersion&); diff --git a/cpp/include/Ice/Proxy.h b/cpp/include/Ice/Proxy.h index d411c0539c5..60cc2fbad88 100644 --- a/cpp/include/Ice/Proxy.h +++ b/cpp/include/Ice/Proxy.h @@ -422,8 +422,8 @@ namespace Ice bool ice_invoke( std::string_view operation, Ice::OperationMode mode, - const std::vector& inParams, - std::vector& outParams, + const std::vector& inParams, + std::vector& outParams, const Ice::Context& context = Ice::noExplicitContext) const; /** @@ -434,10 +434,10 @@ namespace Ice * @param context The context map for the invocation. * @return The future object for the invocation. */ - std::future>> ice_invokeAsync( + std::future>> ice_invokeAsync( const std::string& operation, Ice::OperationMode mode, - const std::vector& inParams, + const std::vector& inParams, const Ice::Context& context = Ice::noExplicitContext) const; /** @@ -454,8 +454,8 @@ namespace Ice std::function ice_invokeAsync( std::string_view operation, Ice::OperationMode mode, - const std::vector& inParams, - std::function)> response, + const std::vector& inParams, + std::function)> response, std::function ex = nullptr, std::function sent = nullptr, const Ice::Context& context = Ice::noExplicitContext) const; @@ -475,8 +475,8 @@ namespace Ice bool ice_invoke( std::string_view operation, Ice::OperationMode mode, - const std::pair& inParams, - std::vector& outParams, + const std::pair& inParams, + std::vector& outParams, const Ice::Context& context = Ice::noExplicitContext) const; /** @@ -487,10 +487,10 @@ namespace Ice * @param context The context map for the invocation. * @return The future object for the invocation. */ - std::future>> ice_invokeAsync( + std::future>> ice_invokeAsync( const std::string& operation, Ice::OperationMode mode, - const std::pair& inParams, + const std::pair& inParams, const Ice::Context& context = Ice::noExplicitContext) const; /** @@ -507,8 +507,8 @@ namespace Ice std::function ice_invokeAsync( std::string_view operation, Ice::OperationMode mode, - const std::pair& inParams, - std::function)> response, + const std::pair& inParams, + std::function)> response, std::function ex = nullptr, std::function sent = nullptr, const Ice::Context& context = Ice::noExplicitContext) const; diff --git a/cpp/include/Ice/SlicedData.h b/cpp/include/Ice/SlicedData.h index f17f5ce4a56..2098b51f1f4 100644 --- a/cpp/include/Ice/SlicedData.h +++ b/cpp/include/Ice/SlicedData.h @@ -29,7 +29,7 @@ namespace Ice /** * The encoded bytes for this slice, including the leading size integer. */ - std::vector bytes; + std::vector bytes; /** * The class instances referenced by this slice. diff --git a/cpp/src/Glacier2/Blobject.cpp b/cpp/src/Glacier2/Blobject.cpp index c55a9291338..dc45cfb43ac 100644 --- a/cpp/src/Glacier2/Blobject.cpp +++ b/cpp/src/Glacier2/Blobject.cpp @@ -67,8 +67,8 @@ Glacier2::Blobject::updateObserver(const shared_ptr& inParams, - function&)> response, + const std::pair& inParams, + function&)> response, function exception, const Current& current) { @@ -253,7 +253,7 @@ Glacier2::Blobject::invoke( try { - function)> amiResponse = nullptr; + function)> amiResponse = nullptr; function amiSent = nullptr; if (proxy->ice_isTwoway()) diff --git a/cpp/src/Glacier2/Blobject.h b/cpp/src/Glacier2/Blobject.h index 8af20def54f..2e2dfcba8b7 100644 --- a/cpp/src/Glacier2/Blobject.h +++ b/cpp/src/Glacier2/Blobject.h @@ -25,8 +25,8 @@ namespace Glacier2 protected: void invoke( Ice::ObjectPrx&, - const std::pair&, - std::function&)>, + const std::pair&, + std::function&)>, std::function, const Ice::Current&); diff --git a/cpp/src/Glacier2/ClientBlobject.cpp b/cpp/src/Glacier2/ClientBlobject.cpp index 4e08d3b615a..a12c886d41f 100644 --- a/cpp/src/Glacier2/ClientBlobject.cpp +++ b/cpp/src/Glacier2/ClientBlobject.cpp @@ -29,8 +29,8 @@ Glacier2::ClientBlobject::ClientBlobject( void Glacier2::ClientBlobject::ice_invokeAsync( - pair inParams, - function&)> response, + pair inParams, + function&)> response, function error, const Current& current) { diff --git a/cpp/src/Glacier2/ClientBlobject.h b/cpp/src/Glacier2/ClientBlobject.h index 863856f7d1f..b9a5d2f6e69 100644 --- a/cpp/src/Glacier2/ClientBlobject.h +++ b/cpp/src/Glacier2/ClientBlobject.h @@ -23,8 +23,8 @@ namespace Glacier2 std::shared_ptr); void ice_invokeAsync( - std::pair inEncaps, - std::function&)> response, + std::pair inEncaps, + std::function&)> response, std::function error, const Ice::Current& current) override; diff --git a/cpp/src/Glacier2/RequestQueue.cpp b/cpp/src/Glacier2/RequestQueue.cpp index 52946fa5f24..5e2ee7d8084 100644 --- a/cpp/src/Glacier2/RequestQueue.cpp +++ b/cpp/src/Glacier2/RequestQueue.cpp @@ -12,11 +12,11 @@ using namespace Glacier2; Glacier2::Request::Request( ObjectPrx proxy, - const std::pair& inParams, + const std::pair& inParams, const Current& current, bool forwardContext, const Ice::Context& sslContext, - function)> response, + function)> response, function exception) : _proxy(std::move(proxy)), _inParams(inParams.first, inParams.second), @@ -35,11 +35,11 @@ Glacier2::Request::Request( void Glacier2::Request::invoke( - function)>&& response, + function)>&& response, function&& exception, std::function&& sent) { - pair inPair; + pair inPair; if (_inParams.size() == 0) { inPair.first = inPair.second = nullptr; @@ -138,7 +138,7 @@ Glacier2::Request::override(const shared_ptr& other) const } void -Glacier2::Request::response(bool ok, const pair& outParams) +Glacier2::Request::response(bool ok, const pair& outParams) { assert(_proxy->ice_isTwoway()); _response(ok, outParams); @@ -245,7 +245,7 @@ Glacier2::RequestQueue::flushRequests() } auto self = shared_from_this(); request->invoke( - [self, request](bool ok, const pair& outParams) + [self, request](bool ok, const pair& outParams) { self->response(ok, outParams, request); }, [self, request](exception_ptr e) { self->exception(e, request); }); } @@ -289,7 +289,7 @@ Glacier2::RequestQueue::flush() auto request = *p; request->invoke( - [self, request](bool ok, const pair& outParams) + [self, request](bool ok, const pair& outParams) { self->response(ok, outParams, request); }, [self, request, completedExceptionally](exception_ptr e) { @@ -324,7 +324,7 @@ Glacier2::RequestQueue::flush() void Glacier2::RequestQueue::response( bool ok, - const pair& outParams, + const pair& outParams, const shared_ptr& request) { assert(request); diff --git a/cpp/src/Glacier2/RequestQueue.h b/cpp/src/Glacier2/RequestQueue.h index dcc4a2deaec..034f8250264 100644 --- a/cpp/src/Glacier2/RequestQueue.h +++ b/cpp/src/Glacier2/RequestQueue.h @@ -23,15 +23,15 @@ namespace Glacier2 public: Request( Ice::ObjectPrx, - const std::pair&, + const std::pair&, const Ice::Current&, bool, const Ice::Context&, - std::function)>, + std::function)>, std::function); void invoke( - std::function)>&&, + std::function)>&&, std::function&&, std::function&& = nullptr); bool override(const std::shared_ptr&) const; @@ -39,7 +39,7 @@ namespace Glacier2 private: friend class RequestQueue; - void response(bool, const std::pair&); + void response(bool, const std::pair&); void exception(std::exception_ptr); void queued(); @@ -49,7 +49,7 @@ namespace Glacier2 const bool _forwardContext; const Ice::Context _sslContext; const std::string _override; - std::function&)> _response; + std::function&)> _response; std::function _exception; }; @@ -68,8 +68,7 @@ namespace Glacier2 private: void flush(); - void - response(bool, const std::pair&, const std::shared_ptr&); + void response(bool, const std::pair&, const std::shared_ptr&); void exception(std::exception_ptr, const std::shared_ptr&); void sent(bool, const std::shared_ptr&); diff --git a/cpp/src/Glacier2/ServerBlobject.cpp b/cpp/src/Glacier2/ServerBlobject.cpp index 64ca56b1df1..cee09c75ea0 100644 --- a/cpp/src/Glacier2/ServerBlobject.cpp +++ b/cpp/src/Glacier2/ServerBlobject.cpp @@ -15,8 +15,8 @@ Glacier2::ServerBlobject::ServerBlobject(shared_ptr instance, shared_p void Glacier2::ServerBlobject::ice_invokeAsync( - pair inParams, - function&)> response, + pair inParams, + function&)> response, function error, const Current& current) { diff --git a/cpp/src/Glacier2/ServerBlobject.h b/cpp/src/Glacier2/ServerBlobject.h index f7759fcd309..bbb511a0d65 100644 --- a/cpp/src/Glacier2/ServerBlobject.h +++ b/cpp/src/Glacier2/ServerBlobject.h @@ -15,8 +15,8 @@ namespace Glacier2 ServerBlobject(std::shared_ptr, std::shared_ptr); void ice_invokeAsync( - std::pair inEncaps, - std::function&)> response, + std::pair inEncaps, + std::function&)> response, std::function error, const Ice::Current& current) override; }; diff --git a/cpp/src/Ice/BatchRequestQueue.cpp b/cpp/src/Ice/BatchRequestQueue.cpp index 9d8847c62d6..10129c0b191 100644 --- a/cpp/src/Ice/BatchRequestQueue.cpp +++ b/cpp/src/Ice/BatchRequestQueue.cpp @@ -158,10 +158,10 @@ BatchRequestQueue::swap(OutputStream* os, bool& compress) _conditionVariable.wait(lock, [this] { return !_batchStreamInUse || _batchStreamCanFlush; }); - vector lastRequest; + vector lastRequest; if (_batchMarker < _batchStream.b.size()) { - vector(_batchStream.b.begin() + _batchMarker, _batchStream.b.end()).swap(lastRequest); + vector(_batchStream.b.begin() + _batchMarker, _batchStream.b.end()).swap(lastRequest); _batchStream.b.resize(_batchMarker); } @@ -178,7 +178,7 @@ BatchRequestQueue::swap(OutputStream* os, bool& compress) _batchMarker = _batchStream.b.size(); if (!lastRequest.empty()) { - _batchStream.writeBlob(reinterpret_cast(&lastRequest[0]), lastRequest.size()); + _batchStream.writeBlob(lastRequest.data(), lastRequest.size()); } return requestNum; } diff --git a/cpp/src/Ice/CollocatedRequestHandler.cpp b/cpp/src/Ice/CollocatedRequestHandler.cpp index 195d4fdf94d..a771dba11ed 100644 --- a/cpp/src/Ice/CollocatedRequestHandler.cpp +++ b/cpp/src/Ice/CollocatedRequestHandler.cpp @@ -54,7 +54,7 @@ namespace void fillInValue(OutputStream* os, int pos, int32_t value) { - const uint8_t* p = reinterpret_cast(&value); + const byte* p = reinterpret_cast(&value); if constexpr (endian::native == endian::big) { reverse_copy(p, p + sizeof(std::int32_t), os->b.begin() + pos); diff --git a/cpp/src/Ice/ConnectionI.cpp b/cpp/src/Ice/ConnectionI.cpp index 021cd781fc4..6bac71f44c4 100644 --- a/cpp/src/Ice/ConnectionI.cpp +++ b/cpp/src/Ice/ConnectionI.cpp @@ -222,7 +222,7 @@ ConnectionFlushBatchAsync::invoke(string_view operation, Ice::CompressBatch comp } } -Ice::ConnectionI::Observer::Observer() : _readStreamPos(0), _writeStreamPos(0) {} +Ice::ConnectionI::Observer::Observer() : _readStreamPos(nullptr), _writeStreamPos(nullptr) {} void Ice::ConnectionI::Observer::startRead(const Buffer& buf) @@ -713,7 +713,7 @@ Ice::ConnectionI::sendAsyncRequest(const OutgoingAsyncBasePtr& out, bool compres // // Fill in the request ID. // - const uint8_t* p = reinterpret_cast(&requestId); + const byte* p = reinterpret_cast(&requestId); if constexpr (endian::native == endian::big) { reverse_copy(p, p + sizeof(int32_t), os->b.begin() + headerSize); @@ -725,7 +725,7 @@ Ice::ConnectionI::sendAsyncRequest(const OutgoingAsyncBasePtr& out, bool compres } else if (batchRequestNum > 0) { - const uint8_t* p = reinterpret_cast(&batchRequestNum); + const byte* p = reinterpret_cast(&batchRequestNum); if constexpr (endian::native == endian::big) { reverse_copy(p, p + sizeof(int32_t), os->b.begin() + headerSize); @@ -1472,13 +1472,7 @@ Ice::ConnectionI::message(ThreadPoolCurrent& current) _readStream.readBlob(m, static_cast(sizeof(magic))); if (m[0] != magic[0] || m[1] != magic[1] || m[2] != magic[2] || m[3] != magic[3]) { - throw BadMagicException( - __FILE__, - __LINE__, - "", - Ice::ByteSeq( - reinterpret_cast(&m[0]), - reinterpret_cast(&m[0]) + sizeof(magic))); + throw BadMagicException(__FILE__, __LINE__, "", Ice::ByteSeq(&m[0], &m[0] + sizeof(magic))); } ProtocolVersion pv; _readStream.read(pv); @@ -2680,13 +2674,7 @@ Ice::ConnectionI::validate(SocketOperation operation) _readStream.read(m[3]); if (m[0] != magic[0] || m[1] != magic[1] || m[2] != magic[2] || m[3] != magic[3]) { - throw BadMagicException( - __FILE__, - __LINE__, - "", - Ice::ByteSeq( - reinterpret_cast(&m[0]), - reinterpret_cast(&m[0]) + sizeof(magic))); + throw BadMagicException(__FILE__, __LINE__, "", Ice::ByteSeq(&m[0], &m[0] + sizeof(magic))); } ProtocolVersion pv; _readStream.read(pv); @@ -2802,7 +2790,7 @@ Ice::ConnectionI::sendNextMessage(vector& callbacks) // // Message compressed. Request compressed response, if any. // - message->stream->b[9] = 2; + message->stream->b[9] = byte{2}; // // Do compression. @@ -2823,14 +2811,14 @@ Ice::ConnectionI::sendNextMessage(vector& callbacks) // // Message not compressed. Request compressed response, if any. // - message->stream->b[9] = 1; + message->stream->b[9] = byte{1}; } // // No compression, just fill in the message size. // int32_t sz = static_cast(message->stream->b.size()); - const uint8_t* p = reinterpret_cast(&sz); + const byte* p = reinterpret_cast(&sz); if constexpr (endian::native == endian::big) { reverse_copy(p, p + sizeof(int32_t), message->stream->b.begin() + 10); @@ -2917,7 +2905,7 @@ Ice::ConnectionI::sendMessage(OutgoingMessage& message) // // Message compressed. Request compressed response, if any. // - message.stream->b[9] = 2; + message.stream->b[9] = byte{2}; // // Do compression. @@ -2966,14 +2954,14 @@ Ice::ConnectionI::sendMessage(OutgoingMessage& message) // // Message not compressed. Request compressed response, if any. // - message.stream->b[9] = 1; + message.stream->b[9] = byte{1}; } // // No compression, just fill in the message size. // int32_t sz = static_cast(message.stream->b.size()); - const uint8_t* p = reinterpret_cast(&sz); + const byte* p = reinterpret_cast(&sz); if constexpr (endian::native == endian::big) { reverse_copy(p, p + sizeof(int32_t), message.stream->b.begin() + 10); @@ -3089,7 +3077,7 @@ getBZ2Error(int bzError) void Ice::ConnectionI::doCompress(OutputStream& uncompressed, OutputStream& compressed) { - const uint8_t* p; + const byte* p; // // Compress the message body, but not the header. @@ -3117,7 +3105,7 @@ Ice::ConnectionI::doCompress(OutputStream& uncompressed, OutputStream& compresse // will also be in the header of the compressed stream. // int32_t compressedSize = static_cast(compressed.b.size()); - p = reinterpret_cast(&compressedSize); + p = reinterpret_cast(&compressedSize); if constexpr (endian::native == endian::big) { reverse_copy(p, p + sizeof(int32_t), uncompressed.b.begin() + 10); @@ -3132,7 +3120,7 @@ Ice::ConnectionI::doCompress(OutputStream& uncompressed, OutputStream& compresse // of the compressed stream. // int32_t uncompressedSize = static_cast(uncompressed.b.size()); - p = reinterpret_cast(&uncompressedSize); + p = reinterpret_cast(&uncompressedSize); if constexpr (endian::native == endian::big) { reverse_copy(p, p + sizeof(int32_t), compressed.b.begin() + headerSize); diff --git a/cpp/src/Ice/ConnectionI.h b/cpp/src/Ice/ConnectionI.h index f2d34a67ba9..ad5ed8c490f 100644 --- a/cpp/src/Ice/ConnectionI.h +++ b/cpp/src/Ice/ConnectionI.h @@ -63,8 +63,8 @@ namespace Ice void attach(const Ice::Instrumentation::ConnectionObserverPtr&); private: - std::uint8_t* _readStreamPos; - std::uint8_t* _writeStreamPos; + std::byte* _readStreamPos; + std::byte* _writeStreamPos; }; public: diff --git a/cpp/src/Ice/HttpParser.cpp b/cpp/src/Ice/HttpParser.cpp index 81e64252b82..39e9d57dd61 100644 --- a/cpp/src/Ice/HttpParser.cpp +++ b/cpp/src/Ice/HttpParser.cpp @@ -11,6 +11,15 @@ using namespace std; using namespace Ice; using namespace IceInternal; +namespace +{ + // Convert a byte array to a string + string bytesToString(const byte* begin, const byte* end) + { + return string(reinterpret_cast(begin), reinterpret_cast(end)); + } +} + IceInternal::WebSocketException::WebSocketException(const string& r) : reason(r) {} IceInternal::HttpParser::HttpParser() @@ -22,10 +31,10 @@ IceInternal::HttpParser::HttpParser() { } -const uint8_t* -IceInternal::HttpParser::isCompleteMessage(const uint8_t* begin, const uint8_t* end) const +const byte* +IceInternal::HttpParser::isCompleteMessage(const byte* begin, const byte* end) const { - const uint8_t* p = begin; + const byte* p = begin; // // Skip any leading CR-LF characters. @@ -68,10 +77,10 @@ IceInternal::HttpParser::isCompleteMessage(const uint8_t* begin, const uint8_t* } bool -IceInternal::HttpParser::parse(const uint8_t* begin, const uint8_t* end) +IceInternal::HttpParser::parse(const byte* begin, const byte* end) { - const uint8_t* p = begin; - const uint8_t* start = 0; + const byte* p = begin; + const byte* start = 0; const string::value_type CR = '\r'; const string::value_type LF = '\n'; @@ -249,7 +258,7 @@ IceInternal::HttpParser::parse(const uint8_t* begin, const uint8_t* end) } HeaderFields::iterator q = _headers.find(_headerName); assert(q != _headers.end()); - q->second.second = q->second.second + " " + string(start, p); + q->second.second = q->second.second + " " + bytesToString(start, p); _state = c == CR ? StateHeaderFieldLF : StateHeaderFieldStart; } else @@ -288,14 +297,14 @@ IceInternal::HttpParser::parse(const uint8_t* begin, const uint8_t* end) { if (_headerName.empty()) { - _headerName = IceUtilInternal::toLower(string(start, p)); + _headerName = IceUtilInternal::toLower(bytesToString(start, p)); HeaderFields::iterator q = _headers.find(_headerName); // // Add a placeholder entry if necessary. // if (q == _headers.end()) { - _headers[_headerName] = make_pair(string(start, p), ""); + _headers[_headerName] = make_pair(bytesToString(start, p), ""); } } @@ -357,11 +366,11 @@ IceInternal::HttpParser::parse(const uint8_t* begin, const uint8_t* end) } else if (q->second.second.empty()) { - q->second.second = string(start, p); + q->second.second = bytesToString(start, p); } else { - q->second.second = q->second.second + ", " + string(start, p); + q->second.second = q->second.second + ", " + bytesToString(start, p); } } @@ -580,7 +589,7 @@ IceInternal::HttpParser::parse(const uint8_t* begin, const uint8_t* end) { if (p > start) { - _reason = string(start, p); + _reason = bytesToString(start, p); } _state = c == CR ? StateResponseLF : StateHeaderFieldStart; } diff --git a/cpp/src/Ice/HttpParser.h b/cpp/src/Ice/HttpParser.h index 18020cd3c89..6c07d16662f 100644 --- a/cpp/src/Ice/HttpParser.h +++ b/cpp/src/Ice/HttpParser.h @@ -38,9 +38,9 @@ namespace IceInternal TypeResponse }; - const std::uint8_t* isCompleteMessage(const std::uint8_t*, const std::uint8_t*) const; + const std::byte* isCompleteMessage(const std::byte*, const std::byte*) const; - bool parse(const std::uint8_t*, const std::uint8_t*); + bool parse(const std::byte*, const std::byte*); Type type() const; diff --git a/cpp/src/Ice/InputStream.cpp b/cpp/src/Ice/InputStream.cpp index f395721c6ce..53d5ea746e2 100644 --- a/cpp/src/Ice/InputStream.cpp +++ b/cpp/src/Ice/InputStream.cpp @@ -35,9 +35,9 @@ using namespace IceInternal; Ice::InputStream::InputStream() { initialize(currentEncoding); } -Ice::InputStream::InputStream(const vector& v) : Buffer(v) { initialize(currentEncoding); } +Ice::InputStream::InputStream(const vector& v) : Buffer(v) { initialize(currentEncoding); } -Ice::InputStream::InputStream(const pair& p) : Buffer(p.first, p.second) +Ice::InputStream::InputStream(const pair& p) : Buffer(p.first, p.second) { initialize(currentEncoding); } @@ -46,12 +46,12 @@ Ice::InputStream::InputStream(Buffer& buf, bool adopt) : Buffer(buf, adopt) { in Ice::InputStream::InputStream(const CommunicatorPtr& communicator) { initialize(communicator); } -Ice::InputStream::InputStream(const CommunicatorPtr& communicator, const vector& v) : Buffer(v) +Ice::InputStream::InputStream(const CommunicatorPtr& communicator, const vector& v) : Buffer(v) { initialize(communicator); } -Ice::InputStream::InputStream(const CommunicatorPtr& communicator, const pair& p) +Ice::InputStream::InputStream(const CommunicatorPtr& communicator, const pair& p) : Buffer(p.first, p.second) { initialize(communicator); @@ -64,12 +64,12 @@ Ice::InputStream::InputStream(const CommunicatorPtr& communicator, Buffer& buf, Ice::InputStream::InputStream(const EncodingVersion& encoding) { initialize(encoding); } -Ice::InputStream::InputStream(const EncodingVersion& encoding, const vector& v) : Buffer(v) +Ice::InputStream::InputStream(const EncodingVersion& encoding, const vector& v) : Buffer(v) { initialize(encoding); } -Ice::InputStream::InputStream(const EncodingVersion& encoding, const pair& p) +Ice::InputStream::InputStream(const EncodingVersion& encoding, const pair& p) : Buffer(p.first, p.second) { initialize(encoding); @@ -88,7 +88,7 @@ Ice::InputStream::InputStream(const CommunicatorPtr& communicator, const Encodin Ice::InputStream::InputStream( const CommunicatorPtr& communicator, const EncodingVersion& encoding, - const vector& v) + const vector& v) : Buffer(v) { initialize(communicator, encoding); @@ -97,7 +97,7 @@ Ice::InputStream::InputStream( Ice::InputStream::InputStream( const CommunicatorPtr& communicator, const EncodingVersion& encoding, - const pair& p) + const pair& p) : Buffer(p.first, p.second) { initialize(communicator, encoding); @@ -378,7 +378,7 @@ Ice::InputStream::readBlob(vector& v, int32_t sz) { throw UnmarshalOutOfBoundsException(__FILE__, __LINE__); } - vector(reinterpret_cast(i), reinterpret_cast(i) + sz).swap(v); + vector(i, i + sz).swap(v); i += sz; } else @@ -388,9 +388,9 @@ Ice::InputStream::readBlob(vector& v, int32_t sz) } void -Ice::InputStream::read(std::vector& v) +Ice::InputStream::read(std::vector& v) { - std::pair p; + std::pair p; read(p); if (p.first != p.second) { @@ -404,7 +404,7 @@ Ice::InputStream::read(std::vector& v) } void -Ice::InputStream::read(pair& v) +Ice::InputStream::read(pair& v) { int32_t sz = readAndCheckSeqSize(1); if (sz > 0) @@ -426,7 +426,7 @@ Ice::InputStream::read(vector& v) if (sz > 0) { v.resize(static_cast(sz)); - copy(i, i + sz, v.begin()); + copy(reinterpret_cast(i), reinterpret_cast(i) + sz, v.begin()); i += sz; } else @@ -489,17 +489,17 @@ Ice::InputStream::read(int16_t& v) { throw UnmarshalOutOfBoundsException(__FILE__, __LINE__); } - const uint8_t* src = &(*i); + const byte* src = &(*i); i += sizeof(int16_t); if constexpr (endian::native == endian::big) { - uint8_t* dest = reinterpret_cast(&v) + sizeof(int16_t) - 1; + byte* dest = reinterpret_cast(&v) + sizeof(int16_t) - 1; *dest-- = *src++; *dest = *src; } else { - uint8_t* dest = reinterpret_cast(&v); + byte* dest = reinterpret_cast(&v); *dest++ = *src++; *dest = *src; } @@ -516,8 +516,8 @@ Ice::InputStream::read(vector& v) v.resize(static_cast(sz)); if constexpr (endian::native == endian::big) { - const uint8_t* src = &(*begin); - uint8_t* dest = reinterpret_cast(&v[0]) + sizeof(int16_t) - 1; + const byte* src = &(*begin); + byte* dest = reinterpret_cast(&v[0]) + sizeof(int16_t) - 1; for (int j = 0; j < sz; ++j) { *dest-- = *src++; @@ -527,7 +527,7 @@ Ice::InputStream::read(vector& v) } else { - copy(begin, i, reinterpret_cast(&v[0])); + copy(begin, i, reinterpret_cast(&v[0])); } } else @@ -557,8 +557,8 @@ Ice::InputStream::read(pair& v) i += sz * static_cast(sizeof(int16_t)); if constexpr (endian::native == endian::big) { - const uint8_t* src = &(*begin); - uint8_t* dest = reinterpret_cast(&result[0]) + sizeof(int16_t) - 1; + const byte* src = &(*begin); + byte* dest = reinterpret_cast(&result[0]) + sizeof(int16_t) - 1; for (int j = 0; j < sz; ++j) { *dest-- = *src++; @@ -568,7 +568,7 @@ Ice::InputStream::read(pair& v) } else { - copy(begin, i, reinterpret_cast(&result[0])); + copy(begin, i, reinterpret_cast(&result[0])); } #endif } @@ -585,11 +585,11 @@ Ice::InputStream::read(int32_t& v) { throwUnmarshalOutOfBoundsException(__FILE__, __LINE__); } - const uint8_t* src = &(*i); + const byte* src = &(*i); i += sizeof(int32_t); if constexpr (endian::native == endian::big) { - uint8_t* dest = reinterpret_cast(&v) + sizeof(int32_t) - 1; + byte* dest = reinterpret_cast(&v) + sizeof(int32_t) - 1; *dest-- = *src++; *dest-- = *src++; *dest-- = *src++; @@ -597,7 +597,7 @@ Ice::InputStream::read(int32_t& v) } else { - uint8_t* dest = reinterpret_cast(&v); + byte* dest = reinterpret_cast(&v); *dest++ = *src++; *dest++ = *src++; *dest++ = *src++; @@ -616,8 +616,8 @@ Ice::InputStream::read(vector& v) v.resize(static_cast(sz)); if constexpr (endian::native == endian::big) { - const uint8_t* src = &(*begin); - uint8_t* dest = reinterpret_cast(&v[0]) + sizeof(int32_t) - 1; + const byte* src = &(*begin); + byte* dest = reinterpret_cast(&v[0]) + sizeof(int32_t) - 1; for (int j = 0; j < sz; ++j) { *dest-- = *src++; @@ -629,7 +629,7 @@ Ice::InputStream::read(vector& v) } else { - copy(begin, i, reinterpret_cast(&v[0])); + copy(begin, i, reinterpret_cast(&v[0])); } } else @@ -658,8 +658,8 @@ Ice::InputStream::read(pair& v) i += sz * static_cast(sizeof(int32_t)); if constexpr (endian::native == endian::big) { - const uint8_t* src = &(*begin); - uint8_t* dest = reinterpret_cast(&result[0]) + sizeof(int32_t) - 1; + const byte* src = &(*begin); + byte* dest = reinterpret_cast(&result[0]) + sizeof(int32_t) - 1; for (int j = 0; j < sz; ++j) { *dest-- = *src++; @@ -671,7 +671,7 @@ Ice::InputStream::read(pair& v) } else { - copy(begin, i, reinterpret_cast(&result[0])); + copy(begin, i, reinterpret_cast(&result[0])); } #endif } @@ -688,11 +688,11 @@ Ice::InputStream::read(int64_t& v) { throw UnmarshalOutOfBoundsException(__FILE__, __LINE__); } - const uint8_t* src = &(*i); + const byte* src = &(*i); i += sizeof(int64_t); if constexpr (endian::native == endian::big) { - uint8_t* dest = reinterpret_cast(&v) + sizeof(int64_t) - 1; + byte* dest = reinterpret_cast(&v) + sizeof(int64_t) - 1; *dest-- = *src++; *dest-- = *src++; *dest-- = *src++; @@ -704,7 +704,7 @@ Ice::InputStream::read(int64_t& v) } else { - uint8_t* dest = reinterpret_cast(&v); + byte* dest = reinterpret_cast(&v); *dest++ = *src++; *dest++ = *src++; *dest++ = *src++; @@ -727,8 +727,8 @@ Ice::InputStream::read(vector& v) v.resize(static_cast(sz)); if constexpr (endian::native == endian::big) { - const uint8_t* src = &(*begin); - uint8_t* dest = reinterpret_cast(&v[0]) + sizeof(int64_t) - 1; + const byte* src = &(*begin); + byte* dest = reinterpret_cast(&v[0]) + sizeof(int64_t) - 1; for (int j = 0; j < sz; ++j) { *dest-- = *src++; @@ -744,7 +744,7 @@ Ice::InputStream::read(vector& v) } else { - copy(begin, i, reinterpret_cast(&v[0])); + copy(begin, i, reinterpret_cast(&v[0])); } } else @@ -774,8 +774,8 @@ Ice::InputStream::read(pair& v) i += sz * static_cast(sizeof(int64_t)); if constexpr (endian::native == endian::big) { - const uint8_t* src = &(*begin); - uint8_t* dest = reinterpret_cast(&result[0]) + sizeof(int64_t) - 1; + const byte* src = &(*begin); + byte* dest = reinterpret_cast(&result[0]) + sizeof(int64_t) - 1; for (int j = 0; j < sz; ++j) { *dest-- = *src++; @@ -791,7 +791,7 @@ Ice::InputStream::read(pair& v) } else { - copy(begin, i, reinterpret_cast(&result[0])); + copy(begin, i, reinterpret_cast(&result[0])); } #endif } @@ -808,11 +808,11 @@ Ice::InputStream::read(float& v) { throw UnmarshalOutOfBoundsException(__FILE__, __LINE__); } - const uint8_t* src = &(*i); + const byte* src = &(*i); i += sizeof(float); if constexpr (endian::native == endian::big) { - uint8_t* dest = reinterpret_cast(&v) + sizeof(float) - 1; + byte* dest = reinterpret_cast(&v) + sizeof(float) - 1; *dest-- = *src++; *dest-- = *src++; *dest-- = *src++; @@ -820,7 +820,7 @@ Ice::InputStream::read(float& v) } else { - uint8_t* dest = reinterpret_cast(&v); + byte* dest = reinterpret_cast(&v); *dest++ = *src++; *dest++ = *src++; *dest++ = *src++; @@ -839,8 +839,8 @@ Ice::InputStream::read(vector& v) v.resize(static_cast(sz)); if constexpr (endian::native == endian::big) { - const uint8_t* src = &(*begin); - uint8_t* dest = reinterpret_cast(&v[0]) + sizeof(float) - 1; + const byte* src = &(*begin); + byte* dest = reinterpret_cast(&v[0]) + sizeof(float) - 1; for (int j = 0; j < sz; ++j) { *dest-- = *src++; @@ -852,7 +852,7 @@ Ice::InputStream::read(vector& v) } else { - copy(begin, i, reinterpret_cast(&v[0])); + copy(begin, i, reinterpret_cast(&v[0])); } } else @@ -882,8 +882,8 @@ Ice::InputStream::read(pair& v) i += sz * static_cast(sizeof(float)); if constexpr (endian::native == endian::big) { - const uint8_t* src = &(*begin); - uint8_t* dest = reinterpret_cast(&result[0]) + sizeof(float) - 1; + const byte* src = &(*begin); + byte* dest = reinterpret_cast(&result[0]) + sizeof(float) - 1; for (int j = 0; j < sz; ++j) { *dest-- = *src++; @@ -895,7 +895,7 @@ Ice::InputStream::read(pair& v) } else { - copy(begin, i, reinterpret_cast(&result[0])); + copy(begin, i, reinterpret_cast(&result[0])); } #endif } @@ -912,11 +912,11 @@ Ice::InputStream::read(double& v) { throw UnmarshalOutOfBoundsException(__FILE__, __LINE__); } - const uint8_t* src = &(*i); + const byte* src = &(*i); i += sizeof(double); if constexpr (endian::native == endian::big) { - uint8_t* dest = reinterpret_cast(&v) + sizeof(double) - 1; + byte* dest = reinterpret_cast(&v) + sizeof(double) - 1; *dest-- = *src++; *dest-- = *src++; *dest-- = *src++; @@ -928,7 +928,7 @@ Ice::InputStream::read(double& v) } else { - uint8_t* dest = reinterpret_cast(&v); + byte* dest = reinterpret_cast(&v); *dest++ = *src++; *dest++ = *src++; *dest++ = *src++; @@ -951,8 +951,8 @@ Ice::InputStream::read(vector& v) v.resize(static_cast(sz)); if constexpr (endian::native == endian::big) { - const uint8_t* src = &(*begin); - uint8_t* dest = reinterpret_cast(&v[0]) + sizeof(double) - 1; + const byte* src = &(*begin); + byte* dest = reinterpret_cast(&v[0]) + sizeof(double) - 1; for (int j = 0; j < sz; ++j) { *dest-- = *src++; @@ -968,7 +968,7 @@ Ice::InputStream::read(vector& v) } else { - copy(begin, i, reinterpret_cast(&v[0])); + copy(begin, i, reinterpret_cast(&v[0])); } } else @@ -997,8 +997,8 @@ Ice::InputStream::read(pair& v) i += sz * static_cast(sizeof(double)); if constexpr (endian::native == endian::big) { - const uint8_t* src = &(*begin); - uint8_t* dest = reinterpret_cast(&result[0]) + sizeof(double) - 1; + const byte* src = &(*begin); + byte* dest = reinterpret_cast(&result[0]) + sizeof(double) - 1; for (int j = 0; j < sz; ++j) { *dest-- = *src++; @@ -1014,7 +1014,7 @@ Ice::InputStream::read(pair& v) } else { - copy(begin, i, reinterpret_cast(&result[0])); + copy(begin, i, reinterpret_cast(&result[0])); } #endif } @@ -1118,7 +1118,10 @@ Ice::InputStream::readConverted(string& v, int sz) const StringConverterPtr& stringConverter = _instance->getStringConverter(); if (stringConverter) { - stringConverter->fromUTF8(i, i + sz, v); + stringConverter->fromUTF8( + reinterpret_cast(i), + reinterpret_cast(i) + sz, + v); converted = true; } } @@ -1127,7 +1130,10 @@ Ice::InputStream::readConverted(string& v, int sz) StringConverterPtr stringConverter = getProcessStringConverter(); if (stringConverter) { - stringConverter->fromUTF8(i, i + sz, v); + stringConverter->fromUTF8( + reinterpret_cast(i), + reinterpret_cast(i) + sz, + v); converted = true; } } @@ -1174,12 +1180,18 @@ Ice::InputStream::read(wstring& v) if (_instance) { const WstringConverterPtr& wstringConverter = _instance->getWstringConverter(); - wstringConverter->fromUTF8(i, i + sz, v); + wstringConverter->fromUTF8( + reinterpret_cast(i), + reinterpret_cast(i) + sz, + v); } else { WstringConverterPtr wstringConverter = getProcessWstringConverter(); - wstringConverter->fromUTF8(i, i + sz, v); + wstringConverter->fromUTF8( + reinterpret_cast(i), + reinterpret_cast(i) + sz, + v); } i += sz; @@ -2350,11 +2362,11 @@ Ice::InputStream::EncapsDecoder11::skipSlice() // Don't include the optional member end marker. It will be re-written by // endSlice when the sliced data is re-written. // - vector(start, _stream->i - 1).swap(info->bytes); + vector(start, _stream->i - 1).swap(info->bytes); } else { - vector(start, _stream->i).swap(info->bytes); + vector(start, _stream->i).swap(info->bytes); } _current->slices.push_back(info); } diff --git a/cpp/src/Ice/NetworkProxy.cpp b/cpp/src/Ice/NetworkProxy.cpp index 9131206f2fe..6c797b4800c 100644 --- a/cpp/src/Ice/NetworkProxy.cpp +++ b/cpp/src/Ice/NetworkProxy.cpp @@ -75,29 +75,29 @@ SOCKSNetworkProxy::beginWrite(const Address& addr, Buffer& buf) // buf.b.resize(9); buf.i = buf.b.begin(); - uint8_t* dest = &buf.b[0]; - *dest++ = 0x04; // SOCKS version 4. - *dest++ = 0x01; // Command, establish a TCP/IP stream connection + byte* dest = &buf.b[0]; + *dest++ = byte{0x04}; // SOCKS version 4. + *dest++ = byte{0x01}; // Command, establish a TCP/IP stream connection - const uint8_t* src; + const byte* src; // // Port (already in big-endian order) // - src = reinterpret_cast(&addr.saIn.sin_port); + src = reinterpret_cast(&addr.saIn.sin_port); *dest++ = *src++; *dest++ = *src; // // IPv4 address (already in big-endian order) // - src = reinterpret_cast(&addr.saIn.sin_addr.s_addr); + src = reinterpret_cast(&addr.saIn.sin_addr.s_addr); *dest++ = *src++; *dest++ = *src++; *dest++ = *src++; *dest++ = *src; - *dest = 0x00; // User ID. + *dest = byte{0x00}; // User ID. } SocketOperation @@ -134,10 +134,10 @@ SOCKSNetworkProxy::finish(Buffer& readBuffer, Buffer&) throw Ice::UnmarshalOutOfBoundsException(__FILE__, __LINE__); } - const uint8_t* src = &(*readBuffer.i); - const uint8_t b1 = *src++; - const uint8_t b2 = *src++; - if (b1 != 0x00 || b2 != 0x5a) + const byte* src = &(*readBuffer.i); + const byte b1 = *src++; + const byte b2 = *src++; + if (b1 != byte{0x00} || b2 != byte{0x5a}) { throw Ice::ConnectFailedException(__FILE__, __LINE__); } @@ -221,7 +221,7 @@ HTTPNetworkProxy::endRead(Buffer& buf) // Check if we received the full HTTP response, if not, continue // reading otherwise we're done. // - const uint8_t* end = HttpParser().isCompleteMessage(buf.b.begin(), buf.i); + const byte* end = HttpParser().isCompleteMessage(buf.b.begin(), buf.i); if (!end && buf.i == buf.b.end()) { // diff --git a/cpp/src/Ice/Object.cpp b/cpp/src/Ice/Object.cpp index 27108f153c4..74c4756ba28 100644 --- a/cpp/src/Ice/Object.cpp +++ b/cpp/src/Ice/Object.cpp @@ -195,11 +195,11 @@ void Ice::Blobject::dispatch(IncomingRequest& request, std::function sendResponse) { const Current& current = request.current(); - const uint8_t* inEncaps; + const byte* inEncaps; int32_t sz; request.inputStream().readEncapsulation(inEncaps, sz); - vector outEncaps; - bool ok = ice_invoke(vector(inEncaps, inEncaps + sz), outEncaps, current); + vector outEncaps; + bool ok = ice_invoke(vector(inEncaps, inEncaps + sz), outEncaps, current); if (outEncaps.empty()) { @@ -215,11 +215,11 @@ void Ice::BlobjectArray::dispatch(IncomingRequest& request, std::function sendResponse) { const Current& current = request.current(); - pair inEncaps; + pair inEncaps; int32_t sz; request.inputStream().readEncapsulation(inEncaps.first, sz); inEncaps.second = inEncaps.first + sz; - vector outEncaps; + vector outEncaps; bool ok = ice_invoke(inEncaps, outEncaps, current); if (outEncaps.empty()) @@ -235,15 +235,15 @@ Ice::BlobjectArray::dispatch(IncomingRequest& request, std::function sendResponse) { - const uint8_t* inEncaps; + const byte* inEncaps; int32_t sz; request.inputStream().readEncapsulation(inEncaps, sz); auto responseHandler = make_shared(std::move(sendResponse), request.current()); try { ice_invokeAsync( - vector{inEncaps, inEncaps + sz}, - [responseHandler](bool ok, const vector& outEncaps) + vector{inEncaps, inEncaps + sz}, + [responseHandler](bool ok, const vector& outEncaps) { if (outEncaps.empty()) { @@ -266,7 +266,7 @@ Ice::BlobjectAsync::dispatch(IncomingRequest& request, std::function sendResponse) { - pair inEncaps; + pair inEncaps; int32_t sz; request.inputStream().readEncapsulation(inEncaps.first, sz); inEncaps.second = inEncaps.first + sz; @@ -275,7 +275,7 @@ Ice::BlobjectArrayAsync::dispatch(IncomingRequest& request, std::function& outEncaps) + [responseHandler](bool ok, const pair& outEncaps) { responseHandler->sendResponse(ok, outEncaps); }, [responseHandler](std::exception_ptr ex) { responseHandler->sendException(ex); }, responseHandler->current()); diff --git a/cpp/src/Ice/OutgoingResponse.cpp b/cpp/src/Ice/OutgoingResponse.cpp index 6ff610eb007..5f020d3d23e 100644 --- a/cpp/src/Ice/OutgoingResponse.cpp +++ b/cpp/src/Ice/OutgoingResponse.cpp @@ -270,10 +270,7 @@ Ice::makeEmptyOutgoingResponse(const Current& current) noexcept } OutgoingResponse -Ice::makeOutgoingResponse( - bool ok, - const pair& encapsulation, - const Current& current) noexcept +Ice::makeOutgoingResponse(bool ok, const pair& encapsulation, const Current& current) noexcept { OutputStream ostr(current.adapter->getCommunicator(), Ice::currentProtocolEncoding); if (current.requestId != 0) diff --git a/cpp/src/Ice/OutputStream.cpp b/cpp/src/Ice/OutputStream.cpp index 192a8e75249..e7788b7da53 100644 --- a/cpp/src/Ice/OutputStream.cpp +++ b/cpp/src/Ice/OutputStream.cpp @@ -39,7 +39,7 @@ namespace // // Return unused bytes // - _stream.resize(static_cast(firstUnused - _stream.b.begin())); + _stream.resize(static_cast(firstUnused - reinterpret_cast(_stream.b.begin()))); } // @@ -53,7 +53,7 @@ namespace // _stream.resize(pos + howMany); - return &_stream.b[pos]; + return reinterpret_cast(&_stream.b[pos]); } private: @@ -85,7 +85,7 @@ Ice::OutputStream::OutputStream(const CommunicatorPtr& communicator, const Encod Ice::OutputStream::OutputStream( const CommunicatorPtr& communicator, const EncodingVersion& encoding, - const pair& buf) + const pair& buf) : Buffer(buf.first, buf.second), _closure(0), _currentEncaps(0) @@ -241,13 +241,15 @@ Ice::OutputStream::writeBlob(const vector& v) } void -Ice::OutputStream::writeBlob(const vector& v) +Ice::OutputStream::write(const byte* begin, const byte* end) { - if (!v.empty()) + int32_t sz = static_cast(end - begin); + writeSize(sz); + if (sz > 0) { Container::size_type pos = b.size(); - resize(pos + v.size()); - memcpy(&b[pos], &v[0], v.size()); + resize(pos + static_cast(sz)); + memcpy(&b[pos], begin, static_cast(sz)); } } @@ -273,7 +275,7 @@ Ice::OutputStream::write(const vector& v) { Container::size_type pos = b.size(); resize(pos + static_cast(sz)); - copy(v.begin(), v.end(), b.begin() + pos); + copy(v.begin(), v.end(), reinterpret_cast(b.begin()) + pos); } } @@ -286,7 +288,7 @@ namespace { for (size_t idx = 0; idx < static_cast(sz); ++idx) { - b[pos + idx] = static_cast(*(begin + idx)); + b[pos + idx] = static_cast(*(begin + idx)); } } }; @@ -319,16 +321,16 @@ Ice::OutputStream::write(int16_t v) { Container::size_type pos = b.size(); resize(pos + sizeof(int16_t)); - uint8_t* dest = &b[pos]; + byte* dest = &b[pos]; if constexpr (endian::native == endian::big) { - const uint8_t* src = reinterpret_cast(&v) + sizeof(int16_t) - 1; + const byte* src = reinterpret_cast(&v) + sizeof(int16_t) - 1; *dest++ = *src--; *dest = *src; } else { - const uint8_t* src = reinterpret_cast(&v); + const byte* src = reinterpret_cast(&v); *dest++ = *src++; *dest = *src; } @@ -345,8 +347,8 @@ Ice::OutputStream::write(const int16_t* begin, const int16_t* end) resize(pos + static_cast(sz) * sizeof(int16_t)); if constexpr (endian::native == endian::big) { - const uint8_t* src = reinterpret_cast(begin) + sizeof(int16_t) - 1; - uint8_t* dest = &(*(b.begin() + pos)); + const byte* src = reinterpret_cast(begin) + sizeof(int16_t) - 1; + byte* dest = &(*(b.begin() + pos)); for (int j = 0; j < sz; ++j) { *dest++ = *src--; @@ -356,7 +358,7 @@ Ice::OutputStream::write(const int16_t* begin, const int16_t* end) } else { - memcpy(&b[pos], reinterpret_cast(begin), static_cast(sz) * sizeof(int16_t)); + memcpy(&b[pos], reinterpret_cast(begin), static_cast(sz) * sizeof(int16_t)); } } } @@ -366,7 +368,7 @@ Ice::OutputStream::write(int32_t v, Container::iterator dest) { if constexpr (endian::native == endian::big) { - const std::uint8_t* src = reinterpret_cast(&v) + sizeof(std::int32_t) - 1; + const std::byte* src = reinterpret_cast(&v) + sizeof(std::int32_t) - 1; *dest++ = *src--; *dest++ = *src--; *dest++ = *src--; @@ -374,7 +376,7 @@ Ice::OutputStream::write(int32_t v, Container::iterator dest) } else { - const std::uint8_t* src = reinterpret_cast(&v); + const std::byte* src = reinterpret_cast(&v); *dest++ = *src++; *dest++ = *src++; *dest++ = *src++; @@ -393,8 +395,8 @@ Ice::OutputStream::write(const int32_t* begin, const int32_t* end) resize(pos + static_cast(sz) * sizeof(int32_t)); if constexpr (endian::native == endian::big) { - const uint8_t* src = reinterpret_cast(begin) + sizeof(int32_t) - 1; - uint8_t* dest = &(*(b.begin() + pos)); + const byte* src = reinterpret_cast(begin) + sizeof(int32_t) - 1; + byte* dest = &(*(b.begin() + pos)); for (int j = 0; j < sz; ++j) { *dest++ = *src--; @@ -406,7 +408,7 @@ Ice::OutputStream::write(const int32_t* begin, const int32_t* end) } else { - memcpy(&b[pos], reinterpret_cast(begin), static_cast(sz) * sizeof(int32_t)); + memcpy(&b[pos], reinterpret_cast(begin), static_cast(sz) * sizeof(int32_t)); } } } @@ -416,10 +418,10 @@ Ice::OutputStream::write(int64_t v) { Container::size_type pos = b.size(); resize(pos + sizeof(int64_t)); - uint8_t* dest = &b[pos]; + byte* dest = &b[pos]; if constexpr (endian::native == endian::big) { - const uint8_t* src = reinterpret_cast(&v) + sizeof(std::int64_t) - 1; + const byte* src = reinterpret_cast(&v) + sizeof(std::int64_t) - 1; *dest++ = *src--; *dest++ = *src--; *dest++ = *src--; @@ -431,7 +433,7 @@ Ice::OutputStream::write(int64_t v) } else { - const uint8_t* src = reinterpret_cast(&v); + const byte* src = reinterpret_cast(&v); *dest++ = *src++; *dest++ = *src++; *dest++ = *src++; @@ -454,8 +456,8 @@ Ice::OutputStream::write(const int64_t* begin, const int64_t* end) resize(pos + static_cast(sz) * sizeof(int64_t)); if constexpr (endian::native == endian::big) { - const uint8_t* src = reinterpret_cast(begin) + sizeof(int64_t) - 1; - uint8_t* dest = &(*(b.begin() + pos)); + const byte* src = reinterpret_cast(begin) + sizeof(int64_t) - 1; + byte* dest = &(*(b.begin() + pos)); for (int j = 0; j < sz; ++j) { *dest++ = *src--; @@ -471,7 +473,7 @@ Ice::OutputStream::write(const int64_t* begin, const int64_t* end) } else { - memcpy(&b[pos], reinterpret_cast(begin), static_cast(sz) * sizeof(int64_t)); + memcpy(&b[pos], reinterpret_cast(begin), static_cast(sz) * sizeof(int64_t)); } } } @@ -481,10 +483,10 @@ Ice::OutputStream::write(float v) { Container::size_type pos = b.size(); resize(pos + sizeof(float)); - uint8_t* dest = &b[pos]; + byte* dest = &b[pos]; if constexpr (endian::native == endian::big) { - const uint8_t* src = reinterpret_cast(&v) + sizeof(float) - 1; + const byte* src = reinterpret_cast(&v) + sizeof(float) - 1; *dest++ = *src--; *dest++ = *src--; *dest++ = *src--; @@ -492,7 +494,7 @@ Ice::OutputStream::write(float v) } else { - const uint8_t* src = reinterpret_cast(&v); + const byte* src = reinterpret_cast(&v); *dest++ = *src++; *dest++ = *src++; *dest++ = *src++; @@ -511,8 +513,8 @@ Ice::OutputStream::write(const float* begin, const float* end) resize(pos + static_cast(sz) * sizeof(float)); if constexpr (endian::native == endian::big) { - const uint8_t* src = reinterpret_cast(begin) + sizeof(float) - 1; - uint8_t* dest = &(*(b.begin() + pos)); + const byte* src = reinterpret_cast(begin) + sizeof(float) - 1; + byte* dest = &(*(b.begin() + pos)); for (int j = 0; j < sz; ++j) { *dest++ = *src--; @@ -524,7 +526,7 @@ Ice::OutputStream::write(const float* begin, const float* end) } else { - memcpy(&b[pos], reinterpret_cast(begin), static_cast(sz) * sizeof(float)); + memcpy(&b[pos], reinterpret_cast(begin), static_cast(sz) * sizeof(float)); } } } @@ -534,10 +536,10 @@ Ice::OutputStream::write(double v) { Container::size_type pos = b.size(); resize(pos + sizeof(double)); - uint8_t* dest = &b[pos]; + byte* dest = &b[pos]; if constexpr (endian::native == endian::big) { - const uint8_t* src = reinterpret_cast(&v) + sizeof(double) - 1; + const byte* src = reinterpret_cast(&v) + sizeof(double) - 1; *dest++ = *src--; *dest++ = *src--; *dest++ = *src--; @@ -549,7 +551,7 @@ Ice::OutputStream::write(double v) } else { - const uint8_t* src = reinterpret_cast(&v); + const byte* src = reinterpret_cast(&v); *dest++ = *src++; *dest++ = *src++; *dest++ = *src++; @@ -572,8 +574,8 @@ Ice::OutputStream::write(const double* begin, const double* end) resize(pos + static_cast(sz) * sizeof(double)); if constexpr (endian::native == endian::big) { - const uint8_t* src = reinterpret_cast(begin) + sizeof(double) - 1; - uint8_t* dest = &(*(b.begin() + pos)); + const byte* src = reinterpret_cast(begin) + sizeof(double) - 1; + byte* dest = &(*(b.begin() + pos)); for (int j = 0; j < sz; ++j) { *dest++ = *src--; @@ -589,7 +591,7 @@ Ice::OutputStream::write(const double* begin, const double* end) } else { - memcpy(&b[pos], reinterpret_cast(begin), static_cast(sz) * sizeof(double)); + memcpy(&b[pos], reinterpret_cast(begin), static_cast(sz) * sizeof(double)); } } } @@ -624,14 +626,14 @@ Ice::OutputStream::writeConverted(const char* vdata, size_t vsize) size_t firstIndex = b.size(); StreamUTF8BufferI buffer(*this); - uint8_t* lastByte = nullptr; + byte* lastByte = nullptr; bool converted = false; if (_instance) { const StringConverterPtr& stringConverter = _instance->getStringConverter(); if (stringConverter) { - lastByte = stringConverter->toUTF8(vdata, vdata + vsize, buffer); + lastByte = reinterpret_cast(stringConverter->toUTF8(vdata, vdata + vsize, buffer)); converted = true; } } @@ -640,7 +642,7 @@ Ice::OutputStream::writeConverted(const char* vdata, size_t vsize) StringConverterPtr stringConverter = getProcessStringConverter(); if (stringConverter) { - lastByte = stringConverter->toUTF8(vdata, vdata + vsize, buffer); + lastByte = reinterpret_cast(stringConverter->toUTF8(vdata, vdata + vsize, buffer)); converted = true; } } @@ -736,16 +738,18 @@ Ice::OutputStream::write(wstring_view v) size_t firstIndex = b.size(); StreamUTF8BufferI buffer(*this); - uint8_t* lastByte = nullptr; + byte* lastByte = nullptr; // Note: wstringConverter is never null; when set to null, get returns the default unicode wstring converter if (_instance) { - lastByte = _instance->getWstringConverter()->toUTF8(v.data(), v.data() + v.size(), buffer); + lastByte = reinterpret_cast( + _instance->getWstringConverter()->toUTF8(v.data(), v.data() + v.size(), buffer)); } else { - lastByte = getProcessWstringConverter()->toUTF8(v.data(), v.data() + v.size(), buffer); + lastByte = + reinterpret_cast(getProcessWstringConverter()->toUTF8(v.data(), v.data() + v.size(), buffer)); } if (lastByte != b.end()) @@ -879,21 +883,21 @@ Ice::OutputStream::writeOptImpl(int32_t tag, OptionalFormat type) } void -Ice::OutputStream::finished(vector& bytes) +Ice::OutputStream::finished(vector& bytes) { - vector(b.begin(), b.end()).swap(bytes); + vector(b.begin(), b.end()).swap(bytes); } -pair +pair Ice::OutputStream::finished() { if (b.empty()) { - return pair(reinterpret_cast(0), reinterpret_cast(0)); + return pair(nullptr, nullptr); } else { - return pair(&b[0], &b[0] + b.size()); + return pair(&b[0], &b[0] + b.size()); } } @@ -1047,7 +1051,7 @@ Ice::OutputStream::EncapsEncoder10::endSlice() // Write the slice length. // int32_t sz = static_cast(_stream->b.size() - _writeSlice + sizeof(int32_t)); - uint8_t* dest = &(*(_stream->b.begin() + _writeSlice - sizeof(int32_t))); + byte* dest = &(*(_stream->b.begin() + _writeSlice - sizeof(int32_t))); _stream->write(sz, dest); } @@ -1282,7 +1286,7 @@ Ice::OutputStream::EncapsEncoder11::endSlice() if (_current->sliceFlags & FLAG_HAS_SLICE_SIZE) { int32_t sz = static_cast(_stream->b.size() - _current->writeSlice + sizeof(int32_t)); - uint8_t* dest = &(*(_stream->b.begin() + _current->writeSlice - sizeof(int32_t))); + byte* dest = &(*(_stream->b.begin() + _current->writeSlice - sizeof(int32_t))); _stream->write(sz, dest); } @@ -1310,8 +1314,8 @@ Ice::OutputStream::EncapsEncoder11::endSlice() // // Finally, update the slice flags. // - uint8_t* dest = &(*(_stream->b.begin() + _current->sliceFlagsPos)); - *dest = _current->sliceFlags; + byte* dest = &(*(_stream->b.begin() + _current->sliceFlagsPos)); + *dest = byte{_current->sliceFlags}; } bool diff --git a/cpp/src/Ice/ProxyAsync.cpp b/cpp/src/Ice/ProxyAsync.cpp index 80793dc24e5..3ab8e4057e7 100644 --- a/cpp/src/Ice/ProxyAsync.cpp +++ b/cpp/src/Ice/ProxyAsync.cpp @@ -19,7 +19,7 @@ using namespace IceInternal; namespace IceInternal { - inline std::pair makePair(const Ice::ByteSeq& seq) + inline std::pair makePair(const Ice::ByteSeq& seq) { if (seq.empty()) { @@ -121,12 +121,12 @@ namespace IceInternal void invoke( string_view operation, Ice::OperationMode mode, - const std::pair& inParams, + const std::pair& inParams, const Ice::Context& context) { _read = [](bool ok, Ice::InputStream* stream) { - const uint8_t* encaps; + const byte* encaps; std::int32_t sz; stream->readEncapsulation(encaps, sz); return R{ok, {encaps, encaps + sz}}; @@ -476,18 +476,18 @@ bool Ice::ObjectPrx::ice_invoke( string_view operation, Ice::OperationMode mode, - const vector& inParams, - vector& outParams, + const vector& inParams, + vector& outParams, const Ice::Context& context) const { return ice_invoke(operation, mode, makePair(inParams), outParams, context); } -std::future>> +std::future>> Ice::ObjectPrx::ice_invokeAsync( const string& operation, Ice::OperationMode mode, - const vector& inParams, + const vector& inParams, const Ice::Context& context) const { return ice_invokeAsync(operation, mode, makePair(inParams), context); @@ -497,17 +497,17 @@ std::function Ice::ObjectPrx::ice_invokeAsync( string_view operation, Ice::OperationMode mode, - const vector& inParams, - std::function)> response, + const vector& inParams, + std::function)> response, std::function ex, std::function sent, const Ice::Context& context) const { - using Outgoing = InvokeLambdaOutgoing>>; - std::function>&&)> r; + using Outgoing = InvokeLambdaOutgoing>>; + std::function>&&)> r; if (response) { - r = [response = std::move(response)](std::tuple>&& result) + r = [response = std::move(response)](std::tuple>&& result) { auto [success, outParams] = std::move(result); response(success, std::move(outParams)); @@ -522,11 +522,11 @@ bool Ice::ObjectPrx::ice_invoke( string_view operation, Ice::OperationMode mode, - const std::pair& inParams, - vector& outParams, + const std::pair& inParams, + vector& outParams, const Ice::Context& context) const { - using Outgoing = InvokePromiseOutgoing>>; + using Outgoing = InvokePromiseOutgoing>>; auto outAsync = std::make_shared(*this, true); outAsync->invoke(operation, mode, inParams, context); auto result = outAsync->getFuture().get(); @@ -535,14 +535,14 @@ Ice::ObjectPrx::ice_invoke( return success; } -std::future>> +std::future>> Ice::ObjectPrx::ice_invokeAsync( const string& operation, Ice::OperationMode mode, - const std::pair& inParams, + const std::pair& inParams, const Ice::Context& context) const { - using Outgoing = ::IceInternal::InvokePromiseOutgoing<::std::tuple>>; + using Outgoing = ::IceInternal::InvokePromiseOutgoing<::std::tuple>>; auto outAsync = ::std::make_shared(*this, false); outAsync->invoke(operation, mode, inParams, context); return outAsync->getFuture(); @@ -552,13 +552,13 @@ std::function Ice::ObjectPrx::ice_invokeAsync( string_view operation, Ice::OperationMode mode, - const std::pair& inParams, - std::function)> response, + const std::pair& inParams, + std::function)> response, std::function ex, std::function sent, const Ice::Context& context) const { - using Result = ::std::tuple>; + using Result = ::std::tuple>; using Outgoing = ::IceInternal::InvokeLambdaOutgoing; ::std::function r; diff --git a/cpp/src/Ice/WSTransceiver.cpp b/cpp/src/Ice/WSTransceiver.cpp index a0003a01daf..d1a3f983e60 100644 --- a/cpp/src/Ice/WSTransceiver.cpp +++ b/cpp/src/Ice/WSTransceiver.cpp @@ -59,14 +59,14 @@ namespace // // Rename to avoid conflict with OS 10.10 htonll // - void ice_htonll(int64_t v, uint8_t* dest) + void ice_htonll(int64_t v, byte* dest) { // // Transfer a 64-bit integer in network (big-endian) order. // if constexpr (endian::native == endian::big) { - const uint8_t* src = reinterpret_cast(&v); + const byte* src = reinterpret_cast(&v); *dest++ = *src++; *dest++ = *src++; *dest++ = *src++; @@ -78,7 +78,7 @@ namespace } else { - const uint8_t* src = reinterpret_cast(&v) + sizeof(int64_t) - 1; + const byte* src = reinterpret_cast(&v) + sizeof(int64_t) - 1; *dest++ = *src--; *dest++ = *src--; *dest++ = *src--; @@ -93,7 +93,7 @@ namespace // // Rename to avoid conflict with OS 10.10 nlltoh // - int64_t ice_nlltoh(const uint8_t* src) + int64_t ice_nlltoh(const byte* src) { int64_t v; @@ -102,7 +102,7 @@ namespace // if constexpr (endian::native == endian::big) { - uint8_t* dest = reinterpret_cast(&v); + byte* dest = reinterpret_cast(&v); *dest++ = *src++; *dest++ = *src++; *dest++ = *src++; @@ -114,7 +114,7 @@ namespace } else { - uint8_t* dest = reinterpret_cast(&v) + sizeof(int64_t) - 1; + byte* dest = reinterpret_cast(&v) + sizeof(int64_t) - 1; *dest-- = *src++; *dest-- = *src++; *dest-- = *src++; @@ -241,7 +241,7 @@ IceInternal::WSTransceiver::initialize(Buffer& readBuffer, Buffer& writeBuffer) // // Check if we have enough data for a complete message. // - const uint8_t* p = _parser->isCompleteMessage(&_readBuffer.b[0], _readBuffer.i); + const byte* p = _parser->isCompleteMessage(&_readBuffer.b[0], _readBuffer.i); if (!p) { if (_readBuffer.i < _readBuffer.b.end()) @@ -1117,8 +1117,8 @@ IceInternal::WSTransceiver::preRead(Buffer& buf) // last frame. Least-significant four bits hold the // opcode. // - unsigned char ch = static_cast(*_readI++); - _readOpCode = ch & 0xf; + byte ch = *_readI++; + _readOpCode = static_cast(ch & byte{0xf}); // // Remember if last frame if we're going to read a data or @@ -1131,7 +1131,7 @@ IceInternal::WSTransceiver::preRead(Buffer& buf) { throw ProtocolException(__FILE__, __LINE__, "invalid data frame, no FIN on previous frame"); } - _readLastFrame = (ch & FLAG_FINAL) == FLAG_FINAL; + _readLastFrame = (ch & byte{FLAG_FINAL}) == byte{FLAG_FINAL}; } else if (_readOpCode == OP_CONT) { @@ -1139,16 +1139,16 @@ IceInternal::WSTransceiver::preRead(Buffer& buf) { throw ProtocolException(__FILE__, __LINE__, "invalid continuation frame, previous frame FIN set"); } - _readLastFrame = (ch & FLAG_FINAL) == FLAG_FINAL; + _readLastFrame = (ch & byte{FLAG_FINAL}) == byte{FLAG_FINAL}; } - ch = static_cast(*_readI++); + ch = *_readI++; // // Check the MASK bit. Messages sent by a client must be masked; // messages sent by a server must not be masked. // - const bool masked = (ch & FLAG_MASKED) == FLAG_MASKED; + const bool masked = (ch & byte{FLAG_MASKED}) == byte{FLAG_MASKED}; if (masked != _incoming) { throw ProtocolException(__FILE__, __LINE__, "invalid masking"); @@ -1161,7 +1161,7 @@ IceInternal::WSTransceiver::preRead(Buffer& buf) // 126: The subsequent two bytes contain the payload length // 127: The subsequent eight bytes contain the payload length // - _readPayloadLength = (ch & 0x7f); + _readPayloadLength = static_cast((ch & byte{0x7f})); if (_readPayloadLength < 126) { _readHeaderLength = 0; @@ -1673,21 +1673,21 @@ IceInternal::WSTransceiver::prepareWriteHeader(uint8_t opCode, IceInternal::Buff // // Set the opcode - this is the one and only data frame. // - *_writeBuffer.i++ = static_cast(opCode | FLAG_FINAL); + *_writeBuffer.i++ = static_cast(opCode | FLAG_FINAL); // // Set the payload length. // if (payloadLength <= 125) { - *_writeBuffer.i++ = static_cast(payloadLength); + *_writeBuffer.i++ = static_cast(payloadLength); } else if (payloadLength > 125 && payloadLength <= USHRT_MAX) { // // Use an extra 16 bits to encode the payload length. // - *_writeBuffer.i++ = static_cast(126); + *_writeBuffer.i++ = byte{126}; *reinterpret_cast(_writeBuffer.i) = htons(static_cast(payloadLength)); _writeBuffer.i += 2; } @@ -1696,7 +1696,7 @@ IceInternal::WSTransceiver::prepareWriteHeader(uint8_t opCode, IceInternal::Buff // // Use an extra 64 bits to encode the payload length. // - *_writeBuffer.i++ = static_cast(127); + *_writeBuffer.i++ = byte{127}; ice_htonll(static_cast(payloadLength), _writeBuffer.i); _writeBuffer.i += 8; } @@ -1707,7 +1707,7 @@ IceInternal::WSTransceiver::prepareWriteHeader(uint8_t opCode, IceInternal::Buff // Add a random 32-bit mask to every outgoing frame, copy the payload data, // and apply the mask. // - _writeBuffer.b[1] |= FLAG_MASKED; + _writeBuffer.b[1] |= byte{FLAG_MASKED}; IceUtilInternal::generateRandom(reinterpret_cast(_writeMask), sizeof(_writeMask)); memcpy(_writeBuffer.i, _writeMask, sizeof(_writeMask)); _writeBuffer.i += sizeof(_writeMask); diff --git a/cpp/src/Ice/WSTransceiver.h b/cpp/src/Ice/WSTransceiver.h index 48835a32e0c..d3c6f234c77 100644 --- a/cpp/src/Ice/WSTransceiver.h +++ b/cpp/src/Ice/WSTransceiver.h @@ -109,7 +109,7 @@ namespace IceInternal size_t _readPayloadLength; Buffer::Container::iterator _readStart; Buffer::Container::iterator _readFrameStart; - unsigned char _readMask[4]; + std::byte _readMask[4]; enum WriteState { @@ -121,7 +121,7 @@ namespace IceInternal WriteState _writeState; Buffer _writeBuffer; const Buffer::Container::size_type _writeBufferSize; - unsigned char _writeMask[4]; + std::byte _writeMask[4]; size_t _writePayloadLength; bool _readPending; diff --git a/cpp/src/IceBridge/IceBridge.cpp b/cpp/src/IceBridge/IceBridge.cpp index a4a9ff75c69..2e0fc2fb152 100644 --- a/cpp/src/IceBridge/IceBridge.cpp +++ b/cpp/src/IceBridge/IceBridge.cpp @@ -25,8 +25,8 @@ namespace // ice_invokeAsync completes, so we have to make a copy of the in parameters // QueuedDispatch( - pair p, - function&)>&& r, + pair p, + function&)>&& r, function&& e, const Current& c) : inParams(p.first, p.second), @@ -41,8 +41,8 @@ namespace // Make sure we don't copy this struct by accident QueuedDispatch(const QueuedDispatch&) = delete; - const vector inParams; - function&)> response; + const vector inParams; + function&)> response; function error; const Current current; }; @@ -95,16 +95,16 @@ namespace void closed(const shared_ptr&); void dispatch( - pair, - function&)>, + pair, + function&)>, function, const Current&); private: void send( const shared_ptr&, - pair, - function&)>, + pair, + function&)>, function, const Current& current); @@ -134,8 +134,8 @@ namespace BridgeI(shared_ptr adapter, ObjectPrx target); void ice_invokeAsync( - pair inEncaps, - function&)> response, + pair inEncaps, + function&)> response, function error, const Current& current) final; @@ -304,8 +304,8 @@ BridgeConnection::closed(const shared_ptr& con) void BridgeConnection::dispatch( - pair inParams, - function&)> response, + pair inParams, + function&)> response, function error, const Current& current) { @@ -341,8 +341,8 @@ BridgeConnection::dispatch( void BridgeConnection::send( const shared_ptr& dest, - pair inParams, - function&)> response, + pair inParams, + function&)> response, function error, const Current& current) { @@ -397,8 +397,8 @@ BridgeI::BridgeI(shared_ptr adapter, ObjectPrx target) void BridgeI::ice_invokeAsync( - pair inParams, - function&)> response, + pair inParams, + function&)> response, function error, const Current& current) { diff --git a/cpp/src/IceDB/IceDB.h b/cpp/src/IceDB/IceDB.h index d0eec2f0a50..8fab7d9fcb2 100644 --- a/cpp/src/IceDB/IceDB.h +++ b/cpp/src/IceDB/IceDB.h @@ -424,9 +424,9 @@ namespace IceDB { static void read(T& t, const MDB_val& val, const IceContext& ctx) { - std::pair p( - static_cast(val.mv_data), - static_cast(val.mv_data) + val.mv_size); + std::pair p( + static_cast(val.mv_data), + static_cast(val.mv_data) + val.mv_size); Ice::InputStream in(ctx.communicator, ctx.encoding, p); in.read(t); } @@ -442,9 +442,9 @@ namespace IceDB static bool write(const T& t, MDB_val& val, const IceContext& ctx) { const size_t limit = val.mv_size; - std::pair p( - reinterpret_cast(val.mv_data), - reinterpret_cast(val.mv_data) + limit); + std::pair p( + reinterpret_cast(val.mv_data), + reinterpret_cast(val.mv_data) + limit); Ice::OutputStream stream(ctx.communicator, ctx.encoding, p); stream.write(t); val.mv_size = stream.b.size(); diff --git a/cpp/src/IceGrid/AdminCallbackRouter.cpp b/cpp/src/IceGrid/AdminCallbackRouter.cpp index 0714659074b..9f5bb00562b 100644 --- a/cpp/src/IceGrid/AdminCallbackRouter.cpp +++ b/cpp/src/IceGrid/AdminCallbackRouter.cpp @@ -35,8 +35,8 @@ AdminCallbackRouter::removeMapping(const string& category) void AdminCallbackRouter::ice_invokeAsync( - pair inParams, - function&)> response, + pair inParams, + function&)> response, function exception, const Ice::Current& current) { diff --git a/cpp/src/IceGrid/AdminCallbackRouter.h b/cpp/src/IceGrid/AdminCallbackRouter.h index 467c3f08e95..987831d92d2 100644 --- a/cpp/src/IceGrid/AdminCallbackRouter.h +++ b/cpp/src/IceGrid/AdminCallbackRouter.h @@ -23,8 +23,8 @@ namespace IceGrid void removeMapping(const std::string&); void ice_invokeAsync( - std::pair, - std::function&)>, + std::pair, + std::function&)>, std::function, const Ice::Current& current) override; diff --git a/cpp/src/IceGrid/AdminRouter.cpp b/cpp/src/IceGrid/AdminRouter.cpp index e56285466af..2046b47d04a 100644 --- a/cpp/src/IceGrid/AdminRouter.cpp +++ b/cpp/src/IceGrid/AdminRouter.cpp @@ -12,8 +12,8 @@ IceGrid::AdminRouter::AdminRouter(const shared_ptr& traceLevels) : void IceGrid::AdminRouter::invokeOnTarget( const Ice::ObjectPrxPtr& target, - const pair& inParams, - function&)>&& response, + const pair& inParams, + function&)>&& response, function&& exception, const Ice::Current& current) { diff --git a/cpp/src/IceGrid/AdminRouter.h b/cpp/src/IceGrid/AdminRouter.h index 9f69e182e94..47a3bcacc31 100644 --- a/cpp/src/IceGrid/AdminRouter.h +++ b/cpp/src/IceGrid/AdminRouter.h @@ -20,8 +20,8 @@ namespace IceGrid void invokeOnTarget( const Ice::ObjectPrxPtr&, - const std::pair&, - std::function&)>&&, + const std::pair&, + std::function&)>&&, std::function&&, const Ice::Current&); diff --git a/cpp/src/IceGrid/AdminSessionI.cpp b/cpp/src/IceGrid/AdminSessionI.cpp index fe8e1677141..9d2c3720a5d 100644 --- a/cpp/src/IceGrid/AdminSessionI.cpp +++ b/cpp/src/IceGrid/AdminSessionI.cpp @@ -24,8 +24,8 @@ namespace SubscriberForwarderI(const Ice::ObjectPrxPtr& proxy) : _proxy(proxy) {} void ice_invokeAsync( - pair inParams, - function&)> response, + pair inParams, + function&)> response, function exception, const Ice::Current& current) override { diff --git a/cpp/src/IceGrid/NodeAdminRouter.cpp b/cpp/src/IceGrid/NodeAdminRouter.cpp index 106a4944379..b3617573aba 100644 --- a/cpp/src/IceGrid/NodeAdminRouter.cpp +++ b/cpp/src/IceGrid/NodeAdminRouter.cpp @@ -19,8 +19,8 @@ NodeServerAdminRouter::NodeServerAdminRouter(const shared_ptr& node) void NodeServerAdminRouter::ice_invokeAsync( - pair inParams, - function&)> response, + pair inParams, + function&)> response, function exception, const Ice::Current& current) { diff --git a/cpp/src/IceGrid/NodeAdminRouter.h b/cpp/src/IceGrid/NodeAdminRouter.h index 0c88022c48d..4d61a5d050b 100644 --- a/cpp/src/IceGrid/NodeAdminRouter.h +++ b/cpp/src/IceGrid/NodeAdminRouter.h @@ -19,8 +19,8 @@ namespace IceGrid NodeServerAdminRouter(const std::shared_ptr&); void ice_invokeAsync( - std::pair, - std::function&)>, + std::pair, + std::function&)>, std::function, const Ice::Current& current) override; diff --git a/cpp/src/IceGrid/RegistryAdminRouter.cpp b/cpp/src/IceGrid/RegistryAdminRouter.cpp index 9f2fc13462e..7d0988b24b3 100644 --- a/cpp/src/IceGrid/RegistryAdminRouter.cpp +++ b/cpp/src/IceGrid/RegistryAdminRouter.cpp @@ -18,8 +18,8 @@ namespace public: SynchronizationCallbackI( const shared_ptr& adminRouter, - const pair& inParams, - function&)> response, + const pair& inParams, + function&)> response, function exception, const Current& current) : _adminRouter(adminRouter), @@ -49,9 +49,9 @@ namespace private: const shared_ptr _adminRouter; - function&)> _response; + function&)> _response; function _exception; - const vector _inParams; + const vector _inParams; const Current _current; }; } @@ -64,8 +64,8 @@ RegistryServerAdminRouter::RegistryServerAdminRouter(const shared_ptr& void RegistryServerAdminRouter::ice_invokeAsync( - pair inParams, - function&)> response, + pair inParams, + function&)> response, function exception, const Ice::Current& current) { @@ -118,8 +118,8 @@ RegistryNodeAdminRouter::RegistryNodeAdminRouter(const string& collocNodeName, c void RegistryNodeAdminRouter::ice_invokeAsync( - pair inParams, - function&)> response, + pair inParams, + function&)> response, function exception, const Ice::Current& current) { @@ -169,8 +169,8 @@ RegistryReplicaAdminRouter::RegistryReplicaAdminRouter(const string& name, const void RegistryReplicaAdminRouter::ice_invokeAsync( - pair inParams, - function&)> response, + pair inParams, + function&)> response, function exception, const Ice::Current& current) { diff --git a/cpp/src/IceGrid/RegistryAdminRouter.h b/cpp/src/IceGrid/RegistryAdminRouter.h index 3e4ff839da7..2f07b147fd4 100644 --- a/cpp/src/IceGrid/RegistryAdminRouter.h +++ b/cpp/src/IceGrid/RegistryAdminRouter.h @@ -17,8 +17,8 @@ namespace IceGrid RegistryServerAdminRouter(const std::shared_ptr&); void ice_invokeAsync( - std::pair, - std::function&)>, + std::pair, + std::function&)>, std::function, const Ice::Current& current) override; @@ -32,8 +32,8 @@ namespace IceGrid RegistryNodeAdminRouter(const std::string&, const std::shared_ptr&); void ice_invokeAsync( - std::pair, - std::function&)>, + std::pair, + std::function&)>, std::function, const Ice::Current& current) override; @@ -48,8 +48,8 @@ namespace IceGrid RegistryReplicaAdminRouter(const std::string&, const std::shared_ptr&); void ice_invokeAsync( - std::pair, - std::function&)>, + std::pair, + std::function&)>, std::function, const Ice::Current& current) override; diff --git a/cpp/src/IceLocatorDiscovery/PluginI.cpp b/cpp/src/IceLocatorDiscovery/PluginI.cpp index 0dda6954332..d884372085d 100644 --- a/cpp/src/IceLocatorDiscovery/PluginI.cpp +++ b/cpp/src/IceLocatorDiscovery/PluginI.cpp @@ -25,9 +25,9 @@ namespace LocatorI* locator, const string& operation, Ice::OperationMode mode, - const pair& inParams, + const pair& inParams, const Ice::Context& ctx, - function)> responseCallback, + function)> responseCallback, function exceptionCallback) : _locator(locator), _operation(operation), @@ -40,7 +40,7 @@ namespace } void invoke(const Ice::LocatorPrx&); - void response(bool, const pair&); + void response(bool, const pair&); void exception(std::exception_ptr); protected: @@ -49,7 +49,7 @@ namespace const Ice::OperationMode _mode; const Ice::Context _context; const Ice::ByteSeq _inParams; - function)> _responseCallback; + function)> _responseCallback; function _exceptionCallback; exception_ptr _exception; @@ -66,8 +66,8 @@ namespace void setLookupReply(const LookupReplyPrx&); void ice_invokeAsync( - pair, - function&)>, + pair, + function&)>, function, const Ice::Current&) final; @@ -310,9 +310,9 @@ Request::invoke(const Ice::LocatorPrx& l) _operation, _mode, _inParams, - [self](bool ok, vector outParams) + [self](bool ok, vector outParams) { - pair outPair; + pair outPair; if (outParams.empty()) { outPair.first = outPair.second = 0; @@ -341,7 +341,7 @@ Request::invoke(const Ice::LocatorPrx& l) } void -Request::response(bool ok, const pair& outParams) +Request::response(bool ok, const pair& outParams) { _responseCallback(ok, outParams); } @@ -444,8 +444,8 @@ LocatorI::setLookupReply(const LookupReplyPrx& lookupReply) void LocatorI::ice_invokeAsync( - pair inParams, - function&)> responseCB, + pair inParams, + function&)> responseCB, function exceptionCB, const Ice::Current& current) { diff --git a/cpp/src/IcePatch2/FileServerI.cpp b/cpp/src/IcePatch2/FileServerI.cpp index 27143ec0557..ff018b38b73 100644 --- a/cpp/src/IcePatch2/FileServerI.cpp +++ b/cpp/src/IcePatch2/FileServerI.cpp @@ -61,21 +61,21 @@ IcePatch2::FileServerI::getLargeFileCompressedAsync( string pa, int64_t pos, int32_t num, - function& returnValue)> response, + function& returnValue)> response, function exception, const Current&) const { try { - vector buffer; + vector buffer; getFileCompressedInternal(std::move(pa), pos, num, buffer, true); if (buffer.empty()) { - response(make_pair(0, 0)); + response(make_pair(0, 0)); } else { - response(make_pair(&buffer[0], &buffer[0] + buffer.size())); + response(make_pair(&buffer[0], &buffer[0] + buffer.size())); } } catch (const std::exception&) @@ -89,7 +89,7 @@ IcePatch2::FileServerI::getFileCompressedInternal( std::string pa, int64_t pos, int32_t num, - vector& buffer, + vector& buffer, bool largeFile) const { if (IceUtilInternal::isAbsolutePath(pa)) diff --git a/cpp/src/IcePatch2/FileServerI.h b/cpp/src/IcePatch2/FileServerI.h index 6adbf6f1c46..9ec77e2f851 100644 --- a/cpp/src/IcePatch2/FileServerI.h +++ b/cpp/src/IcePatch2/FileServerI.h @@ -27,7 +27,7 @@ namespace IcePatch2 std::string, std::int32_t, std::int32_t, - std::function& returnValue)>, + std::function& returnValue)>, std::function, const Ice::Current&) const; @@ -35,12 +35,12 @@ namespace IcePatch2 std::string, std::int64_t, std::int32_t, - std::function& returnValue)>, + std::function& returnValue)>, std::function, const Ice::Current&) const final; private: - void getFileCompressedInternal(std::string, std::int64_t, std::int32_t, std::vector&, bool) const; + void getFileCompressedInternal(std::string, std::int64_t, std::int32_t, std::vector&, bool) const; const std::string _dataDir; const IcePatch2Internal::FileTree0 _tree0; diff --git a/cpp/src/IcePatch2Lib/ClientUtil.cpp b/cpp/src/IcePatch2Lib/ClientUtil.cpp index 1e7f9006511..660e7671c8e 100644 --- a/cpp/src/IcePatch2Lib/ClientUtil.cpp +++ b/cpp/src/IcePatch2Lib/ClientUtil.cpp @@ -675,8 +675,7 @@ namespace path, pos, chunkSize, - [cb](std::pair result) - { cb->complete(ByteSeq(result.first, result.second)); }, + [cb](std::pair result) { cb->complete(ByteSeq(result.first, result.second)); }, [cb](exception_ptr exception) { cb->exception(exception); }); } diff --git a/cpp/src/IcePatch2Lib/Util.cpp b/cpp/src/IcePatch2Lib/Util.cpp index 89b99571320..a1fd0dc4422 100644 --- a/cpp/src/IcePatch2Lib/Util.cpp +++ b/cpp/src/IcePatch2Lib/Util.cpp @@ -147,8 +147,8 @@ IcePatch2Internal::bytesToString(const ByteSeq& bytes) for (unsigned int i = 0; i < bytes.size(); ++i) { - s[i * 2] = toHex[(bytes[i] >> 4) & 0xf]; - s[i * 2 + 1] = toHex[bytes[i] & 0xf]; + s[i * 2] = toHex[static_cast(bytes[i] >> 4) & 0xf]; + s[i * 2 + 1] = toHex[static_cast(bytes[i]) & 0xf]; } return s; @@ -193,7 +193,7 @@ IcePatch2Internal::stringToBytes(const string& str) } } - bytes.push_back(static_cast(byte)); + bytes.push_back(static_cast(byte)); } return bytes; @@ -593,7 +593,7 @@ IcePatch2Internal::compressBytesToFile(const string& pa, const ByteSeq& bytes, i BZ2_bzWrite( &bzError, bzFile, - const_cast(&bytes[static_cast(pos)]), + const_cast(&bytes[static_cast(pos)]), static_cast(bytes.size()) - pos); if (bzError != BZ_OK) { @@ -817,16 +817,16 @@ namespace info.executable = false; ByteSeq bytes(relPath.size()); - copy(relPath.begin(), relPath.end(), bytes.begin()); + std::transform(relPath.begin(), relPath.end(), bytes.begin(), [](char c) { return std::byte(c); }); ByteSeq bytesSHA(20); if (!bytes.empty()) { - IceInternal::sha1(reinterpret_cast(&bytes[0]), bytes.size(), bytesSHA); + IceInternal::sha1(&bytes[0], bytes.size(), bytesSHA); } else { - fill(bytesSHA.begin(), bytesSHA.end(), uint8_t(0)); + fill(bytesSHA.begin(), bytesSHA.end(), byte{0}); } info.checksum.swap(bytesSHA); @@ -888,7 +888,7 @@ namespace if (relPath.size() == 0 && buf.st_size == 0) { bytesSHA.resize(20); - fill(bytesSHA.begin(), bytesSHA.end(), uint8_t(0)); + fill(bytesSHA.begin(), bytesSHA.end(), byte{0}); } else { @@ -963,7 +963,7 @@ namespace BZ2_bzWrite( &bzError, bzFile, - const_cast(&bytes[0]), + reinterpret_cast(&bytes[0]), static_cast(bytes.size())); if (bzError != BZ_OK) { @@ -1231,19 +1231,16 @@ IcePatch2Internal::getFileTree0(const LargeFileInfoSeq& infoSeq, FileTree0& tree for (LargeFileInfoSeq::const_iterator p = tree1.files.begin(); p != tree1.files.end(); ++p, c1 += 21) { copy(p->checksum.begin(), p->checksum.end(), c1); - *(c1 + 20) = p->executable; + *(c1 + 20) = byte{p->executable}; } if (!allChecksums1.empty()) { - IceInternal::sha1( - reinterpret_cast(&allChecksums1[0]), - allChecksums1.size(), - tree1.checksum); + IceInternal::sha1(&allChecksums1[0], allChecksums1.size(), tree1.checksum); } else { - fill(tree1.checksum.begin(), tree1.checksum.end(), uint8_t(0)); + fill(tree1.checksum.begin(), tree1.checksum.end(), byte{0}); } copy(tree1.checksum.begin(), tree1.checksum.end(), c0); @@ -1251,10 +1248,10 @@ IcePatch2Internal::getFileTree0(const LargeFileInfoSeq& infoSeq, FileTree0& tree if (!allChecksums0.empty()) { - IceInternal::sha1(reinterpret_cast(&allChecksums0[0]), allChecksums0.size(), tree0.checksum); + IceInternal::sha1(&allChecksums0[0], allChecksums0.size(), tree0.checksum); } else { - fill(tree0.checksum.begin(), tree0.checksum.end(), uint8_t(0)); + fill(tree0.checksum.begin(), tree0.checksum.end(), byte{0}); } } diff --git a/cpp/src/IceSSL/SChannelTransceiverI.cpp b/cpp/src/IceSSL/SChannelTransceiverI.cpp index f9359ecb2af..88dfda61cb2 100644 --- a/cpp/src/IceSSL/SChannelTransceiverI.cpp +++ b/cpp/src/IceSSL/SChannelTransceiverI.cpp @@ -612,7 +612,7 @@ SChannel::TransceiverI::decryptMessage(IceInternal::Buffer& buffer) // If we have filled the buffer or if nothing left to read from // the read buffer, we're done. // - uint8_t* i = buffer.i + length; + byte* i = buffer.i + length; if (i == buffer.b.end() || _readBuffer.i == _readBuffer.b.begin()) { break; diff --git a/cpp/src/IceSSL/SecureTransportTransceiverI.cpp b/cpp/src/IceSSL/SecureTransportTransceiverI.cpp index df43f578017..d28e8b6f01b 100644 --- a/cpp/src/IceSSL/SecureTransportTransceiverI.cpp +++ b/cpp/src/IceSSL/SecureTransportTransceiverI.cpp @@ -49,7 +49,7 @@ namespace { const TransceiverI* transceiver = static_cast(connection); assert(transceiver); - return transceiver->writeRaw(reinterpret_cast(data), length); + return transceiver->writeRaw(reinterpret_cast(data), length); } // @@ -59,7 +59,7 @@ namespace { const TransceiverI* transceiver = static_cast(connection); assert(transceiver); - return transceiver->readRaw(reinterpret_cast(data), length); + return transceiver->readRaw(reinterpret_cast(data), length); } TrustError errorToTrustError(CFErrorRef err) @@ -656,15 +656,13 @@ IceSSL::SecureTransport::TransceiverI::TransceiverI( IceSSL::SecureTransport::TransceiverI::~TransceiverI() {} OSStatus -IceSSL::SecureTransport::TransceiverI::writeRaw(const char* data, size_t* length) const +IceSSL::SecureTransport::TransceiverI::writeRaw(const byte* data, size_t* length) const { _tflags &= ~SSLWantWrite; try { - IceInternal::Buffer buf( - reinterpret_cast(data), - reinterpret_cast(data) + *length); + IceInternal::Buffer buf(data, data + *length); IceInternal::SocketOperation op = _delegate->write(buf); if (op == IceInternal::SocketOperationWrite) { @@ -691,13 +689,13 @@ IceSSL::SecureTransport::TransceiverI::writeRaw(const char* data, size_t* length } OSStatus -IceSSL::SecureTransport::TransceiverI::readRaw(char* data, size_t* length) const +IceSSL::SecureTransport::TransceiverI::readRaw(byte* data, size_t* length) const { _tflags &= ~SSLWantRead; try { - IceInternal::Buffer buf(reinterpret_cast(data), reinterpret_cast(data) + *length); + IceInternal::Buffer buf(data, data + *length); IceInternal::SocketOperation op = _delegate->read(buf); if (op == IceInternal::SocketOperationRead) { diff --git a/cpp/src/IceSSL/SecureTransportTransceiverI.h b/cpp/src/IceSSL/SecureTransportTransceiverI.h index 0bd3d284211..27a23bd53e7 100644 --- a/cpp/src/IceSSL/SecureTransportTransceiverI.h +++ b/cpp/src/IceSSL/SecureTransportTransceiverI.h @@ -44,8 +44,8 @@ namespace IceSSL void checkSendSize(const IceInternal::Buffer&) final; void setBufferSize(int rcvSize, int sndSize) final; - OSStatus writeRaw(const char*, size_t*) const; - OSStatus readRaw(char*, size_t*) const; + OSStatus writeRaw(const std::byte*, size_t*) const; + OSStatus readRaw(std::byte*, size_t*) const; private: const InstancePtr _instance; diff --git a/cpp/src/IceStorm/IceStormDB.cpp b/cpp/src/IceStorm/IceStormDB.cpp index 47ec6048b41..6a637367c2e 100644 --- a/cpp/src/IceStorm/IceStormDB.cpp +++ b/cpp/src/IceStorm/IceStormDB.cpp @@ -172,10 +172,9 @@ run(const shared_ptr& communicator, const Ice::StringSeq& arg fs.seekg(0, ios::beg); - vector buf; + vector buf; buf.reserve(static_cast(fileSize)); - buf.insert(buf.begin(), istream_iterator(fs), istream_iterator()); - + fs.read(reinterpret_cast(buf.data()), fileSize); fs.close(); string type; diff --git a/cpp/src/IceStorm/Subscriber.cpp b/cpp/src/IceStorm/Subscriber.cpp index 4b848087925..b53e03fd807 100644 --- a/cpp/src/IceStorm/Subscriber.cpp +++ b/cpp/src/IceStorm/Subscriber.cpp @@ -34,8 +34,7 @@ namespace void setSubscriber(shared_ptr subscriber) { _subscriber = std::move(subscriber); } - bool ice_invoke(pair inParams, vector&, const Ice::Current& current) - override + bool ice_invoke(pair inParams, vector&, const Ice::Current& current) override { // Use cached reads. CachedReadHelper unlock(_instance->node(), __FILE__, __LINE__); @@ -286,7 +285,7 @@ SubscriberTwoway::flush() e.op, e.mode, e.data, - [self](bool, vector) { self->completed(); }, + [self](bool, vector) { self->completed(); }, [self](exception_ptr ex) { self->error(true, ex); }, nullptr, e.context); diff --git a/cpp/src/IceStorm/TopicI.cpp b/cpp/src/IceStorm/TopicI.cpp index 975415f63a7..5e4e3d1238d 100644 --- a/cpp/src/IceStorm/TopicI.cpp +++ b/cpp/src/IceStorm/TopicI.cpp @@ -38,8 +38,7 @@ namespace { } - bool - ice_invoke(pair inParams, Ice::ByteSeq&, const Ice::Current& current) override + bool ice_invoke(pair inParams, Ice::ByteSeq&, const Ice::Current& current) override { // The publish call does a cached read. EventData event = {current.operation, current.mode, Ice::ByteSeq(), current.ctx}; diff --git a/cpp/src/IceStorm/TransientTopicI.cpp b/cpp/src/IceStorm/TransientTopicI.cpp index 3465eefe528..847a265bb7f 100644 --- a/cpp/src/IceStorm/TransientTopicI.cpp +++ b/cpp/src/IceStorm/TransientTopicI.cpp @@ -27,8 +27,7 @@ namespace public: TransientPublisherI(shared_ptr impl) : _impl(std::move(impl)) {} - bool - ice_invoke(pair inParams, Ice::ByteSeq&, const Ice::Current& current) override + bool ice_invoke(pair inParams, Ice::ByteSeq&, const Ice::Current& current) override { // Use cached reads. EventData event = {current.operation, current.mode, Ice::ByteSeq(), current.ctx}; diff --git a/cpp/src/icegriddb/IceGridDB.cpp b/cpp/src/icegriddb/IceGridDB.cpp index b5f5d14f6fa..5e61521f8d3 100644 --- a/cpp/src/icegriddb/IceGridDB.cpp +++ b/cpp/src/icegriddb/IceGridDB.cpp @@ -243,10 +243,9 @@ run(const Ice::StringSeq& args) fs.seekg(0, ios::beg); - vector buf; + vector buf; buf.reserve(static_cast(fileSize)); - buf.insert(buf.begin(), istream_iterator(fs), istream_iterator()); - + fs.read(reinterpret_cast(buf.data()), fileSize); fs.close(); if (!serverVersion.empty()) diff --git a/cpp/src/slice2cpp/CPlusPlusUtil.cpp b/cpp/src/slice2cpp/CPlusPlusUtil.cpp index 1ce9731888c..9f84d74e26a 100644 --- a/cpp/src/slice2cpp/CPlusPlusUtil.cpp +++ b/cpp/src/slice2cpp/CPlusPlusUtil.cpp @@ -49,12 +49,20 @@ namespace if (seqType == "%array") { BuiltinPtr builtin = dynamic_pointer_cast(seq->type()); - string s = typeToString( - seq->type(), - false, - scope, - seq->typeMetaData(), - typeCtx | (inWstringModule(seq) ? TypeContext::UseWstring : TypeContext::None)); + string s; + if (builtin && builtin->kind() == Builtin::KindByte) + { + s = "std::byte"; + } + else + { + s = typeToString( + seq->type(), + false, + scope, + seq->typeMetaData(), + typeCtx | (inWstringModule(seq) ? TypeContext::UseWstring : TypeContext::None)); + } return "::std::pair"; } else diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp index 59ba192584d..6e33136f4ee 100644 --- a/cpp/src/slice2cpp/Gen.cpp +++ b/cpp/src/slice2cpp/Gen.cpp @@ -1355,7 +1355,6 @@ Slice::Gen::ForwardDeclVisitor::visitSequence(const SequencePtr& p) string scope = fixKwd(p->scope()); TypePtr type = p->type(); TypeContext typeCtx = _useWstring; - string s = typeToString(type, false, scope, p->typeMetaData(), typeCtx); StringList metaData = p->getMetaData(); string seqType = findMetaData(metaData, _useWstring); @@ -1368,7 +1367,16 @@ Slice::Gen::ForwardDeclVisitor::visitSequence(const SequencePtr& p) } else { - H << nl << "using " << name << " = ::std::vector<" << s << ">;"; + auto builtin = dynamic_pointer_cast(type); + if (builtin && builtin->kind() == Builtin::KindByte) + { + H << nl << "using " << name << " = ::std::vector;"; + } + else + { + string s = typeToString(type, false, scope, p->typeMetaData(), typeCtx); + H << nl << "using " << name << " = ::std::vector<" << s << ">;"; + } } } diff --git a/cpp/test/Glacier2/override/CallbackI.cpp b/cpp/test/Glacier2/override/CallbackI.cpp index 1f55ac0dd99..590a1ac7021 100644 --- a/cpp/test/Glacier2/override/CallbackI.cpp +++ b/cpp/test/Glacier2/override/CallbackI.cpp @@ -131,7 +131,7 @@ CallbackI::initiateCallbackWithPayloadAsync( ctx["_ovrd"] = p->second; } - Ice::ByteSeq seq(1000 * 1024, 0); + Ice::ByteSeq seq(1000 * 1024, byte{0}); if (proxy->ice_isTwoway()) { proxy->callbackWithPayloadAsync(seq, std::move(response), std::move(error), nullptr, ctx); diff --git a/cpp/test/Glacier2/router/CallbackI.cpp b/cpp/test/Glacier2/router/CallbackI.cpp index c36c835d96b..3901a865ece 100644 --- a/cpp/test/Glacier2/router/CallbackI.cpp +++ b/cpp/test/Glacier2/router/CallbackI.cpp @@ -204,7 +204,7 @@ CallbackI::initiateCallbackWithPayloadAsync( function error, const Current& current) { - Ice::ByteSeq seq(1000 * 1024, 0); + Ice::ByteSeq seq(1000 * 1024, byte{0}); proxy->callbackWithPayloadAsync(seq, std::move(response), std::move(error), nullptr, current.ctx); } diff --git a/cpp/test/Ice/ami/AllTests.cpp b/cpp/test/Ice/ami/AllTests.cpp index 3249a2ab291..935120493ae 100644 --- a/cpp/test/Ice/ami/AllTests.cpp +++ b/cpp/test/Ice/ami/AllTests.cpp @@ -1101,7 +1101,7 @@ allTests(TestHelper* helper, bool collocated) seq.resize(1024 * 10); for (ByteSeq::iterator q = seq.begin(); q != seq.end(); ++q) { - *q = static_cast(IceUtilInternal::random(255)); + *q = static_cast(IceUtilInternal::random(255)); } // diff --git a/cpp/test/Ice/background/AllTests.cpp b/cpp/test/Ice/background/AllTests.cpp index 658dc40c70f..049701c7e71 100644 --- a/cpp/test/Ice/background/AllTests.cpp +++ b/cpp/test/Ice/background/AllTests.cpp @@ -1113,7 +1113,7 @@ readWriteTests( seq.resize(10024); // Make sure the request doesn't compress too well. for (Ice::ByteSeq::iterator p = seq.begin(); p != seq.end(); ++p) { - *p = static_cast(IceUtilInternal::random(255)); + *p = static_cast(IceUtilInternal::random(255)); } // Fill up the receive and send buffers diff --git a/cpp/test/Ice/custom/AllTests.cpp b/cpp/test/Ice/custom/AllTests.cpp index ddb00d3e1bd..bac47094f52 100644 --- a/cpp/test/Ice/custom/AllTests.cpp +++ b/cpp/test/Ice/custom/AllTests.cpp @@ -95,18 +95,18 @@ allTests(TestHelper* helper) { ByteList in; - uint8_t inArray[5]; - inArray[0] = '1'; + byte inArray[5]; + inArray[0] = byte{'1'}; in.push_back(inArray[0]); - inArray[1] = '2'; + inArray[1] = byte{'2'}; in.push_back(inArray[1]); - inArray[2] = '3'; + inArray[2] = byte{'3'}; in.push_back(inArray[2]); - inArray[3] = '4'; + inArray[3] = byte{'4'}; in.push_back(inArray[3]); - inArray[4] = '5'; + inArray[4] = byte{'5'}; in.push_back(inArray[4]); - pair inPair(inArray, inArray + 5); + pair inPair(inArray, inArray + 5); ByteList out; ByteList ret = t->opByteArray(inPair, out); @@ -165,29 +165,29 @@ allTests(TestHelper* helper) } { - deque in(5); - in[0] = '1'; - in[1] = '2'; - in[2] = '3'; - in[3] = '4'; - in[4] = '5'; + deque in(5); + in[0] = byte{'1'}; + in[1] = byte{'2'}; + in[2] = byte{'3'}; + in[3] = byte{'4'}; + in[4] = byte{'5'}; - deque out; - deque ret = t->opByteSeq(in, out); + deque out; + deque ret = t->opByteSeq(in, out); test(out == in); test(ret == in); } { - list in; - in.push_back('1'); - in.push_back('2'); - in.push_back('3'); - in.push_back('4'); - in.push_back('5'); + list in; + in.push_back(byte{'1'}); + in.push_back(byte{'2'}); + in.push_back(byte{'3'}); + in.push_back(byte{'4'}); + in.push_back(byte{'5'}); - list out; - list ret = t->opByteList(in, out); + list out; + list ret = t->opByteList(in, out); test(out == in); test(ret == in); } @@ -197,7 +197,7 @@ allTests(TestHelper* helper) int i = 0; for (MyByteSeq::iterator p = in.begin(); p != in.end(); ++p) { - *p = static_cast('1' + i++); + *p = static_cast('1' + i++); } MyByteSeq out; @@ -503,7 +503,7 @@ allTests(TestHelper* helper) test(retBS == inBS); BufferStruct bs; - bs.byteBuf.setAndInit(new uint8_t[10], 10); + bs.byteBuf.setAndInit(new byte[10], 10); bs.boolBuf.setAndInit(new bool[10], 10); bs.shortBuf.setAndInit(new int16_t[10], 10); bs.intBuf.setAndInit(new int32_t[10], 10); @@ -567,18 +567,18 @@ allTests(TestHelper* helper) { ByteList in; - uint8_t inArray[5]; - inArray[0] = '1'; + byte inArray[5]; + inArray[0] = byte{'1'}; in.push_back(inArray[0]); - inArray[1] = '2'; + inArray[1] = byte{'2'}; in.push_back(inArray[1]); - inArray[2] = '3'; + inArray[2] = byte{'3'}; in.push_back(inArray[2]); - inArray[3] = '4'; + inArray[3] = byte{'4'}; in.push_back(inArray[3]); - inArray[4] = '5'; + inArray[4] = byte{'5'}; in.push_back(inArray[4]); - pair inPair(inArray, inArray + 5); + pair inPair(inArray, inArray + 5); auto r = t->opByteArrayAsync(inPair).get(); test(std::get<1>(r) == in); @@ -632,12 +632,12 @@ allTests(TestHelper* helper) } { - deque in(5); - in[0] = '1'; - in[1] = '2'; - in[2] = '3'; - in[3] = '4'; - in[4] = '5'; + deque in(5); + in[0] = byte{'1'}; + in[1] = byte{'2'}; + in[2] = byte{'3'}; + in[3] = byte{'4'}; + in[4] = byte{'5'}; auto r = t->opByteSeqAsync(in).get(); test(std::get<1>(r) == in); @@ -645,12 +645,12 @@ allTests(TestHelper* helper) } { - list in; - in.push_back('1'); - in.push_back('2'); - in.push_back('3'); - in.push_back('4'); - in.push_back('5'); + list in; + in.push_back(byte{'1'}); + in.push_back(byte{'2'}); + in.push_back(byte{'3'}); + in.push_back(byte{'4'}); + in.push_back(byte{'5'}); auto r = t->opByteListAsync(in).get(); test(std::get<1>(r) == in); @@ -662,7 +662,7 @@ allTests(TestHelper* helper) int i = 0; for (MyByteSeq::iterator p = in.begin(); p != in.end(); ++p) { - *p = static_cast('1' + i++); + *p = static_cast('1' + i++); } auto r = t->opMyByteSeqAsync(in).get(); @@ -894,10 +894,10 @@ allTests(TestHelper* helper) { ByteSeq in; - in.push_back('1'); - in.push_back('2'); - in.push_back('3'); - in.push_back('4'); + in.push_back(byte{'1'}); + in.push_back(byte{'2'}); + in.push_back(byte{'3'}); + in.push_back(byte{'4'}); auto r = t->opOutArrayByteSeqAsync(in).get(); test(r.size() == in.size()); @@ -967,22 +967,22 @@ allTests(TestHelper* helper) } { - uint8_t in[5]; - in[0] = '1'; - in[1] = '2'; - in[2] = '3'; - in[3] = '4'; - in[4] = '5'; - pair inPair(in, in + 5); + byte in[5]; + in[0] = byte{'1'}; + in[1] = byte{'2'}; + in[2] = byte{'3'}; + in[3] = byte{'4'}; + in[4] = byte{'5'}; + pair inPair(in, in + 5); promise done; t->opByteArrayAsync( inPair, - [&](pair ret, pair out) + [&](pair ret, pair out) { - test(arrayRangeEquals(out, inPair)); - test(arrayRangeEquals(ret, inPair)); + test(arrayRangeEquals(out, inPair)); + test(arrayRangeEquals(ret, inPair)); done.set_value(true); }, [&](std::exception_ptr) { done.set_value(false); }); @@ -1067,18 +1067,18 @@ allTests(TestHelper* helper) } { - deque in(5); - in[0] = '1'; - in[1] = '2'; - in[2] = '3'; - in[3] = '4'; - in[4] = '5'; + deque in(5); + in[0] = byte{'1'}; + in[1] = byte{'2'}; + in[2] = byte{'3'}; + in[3] = byte{'4'}; + in[4] = byte{'5'}; promise done; t->opByteSeqAsync( in, - [&](deque ret, deque out) + [&](deque ret, deque out) { test(ret == out); test(ret == in); @@ -1090,18 +1090,18 @@ allTests(TestHelper* helper) } { - list in; - in.push_back('1'); - in.push_back('2'); - in.push_back('3'); - in.push_back('4'); - in.push_back('5'); + list in; + in.push_back(byte{'1'}); + in.push_back(byte{'2'}); + in.push_back(byte{'3'}); + in.push_back(byte{'4'}); + in.push_back(byte{'5'}); promise done; t->opByteListAsync( in, - [&](list ret, list out) + [&](list ret, list out) { test(ret == out); test(ret == in); @@ -1117,7 +1117,7 @@ allTests(TestHelper* helper) int i = 0; for (MyByteSeq::iterator p = in.begin(); p != in.end(); ++p) { - *p = static_cast('1' + i++); + *p = static_cast('1' + i++); } promise done; @@ -1483,18 +1483,18 @@ allTests(TestHelper* helper) { ByteSeq in; - in.push_back('1'); - in.push_back('2'); - in.push_back('3'); - in.push_back('4'); + in.push_back(byte{'1'}); + in.push_back(byte{'2'}); + in.push_back(byte{'3'}); + in.push_back(byte{'4'}); promise done; t->opOutArrayByteSeqAsync( in, - [&](pair out) + [&](pair out) { - test(arrayRangeEquals(make_pair(&in[0], &in[0] + in.size()), out)); + test(arrayRangeEquals(make_pair(&in[0], &in[0] + in.size()), out)); done.set_value(true); }, [&](std::exception_ptr) { done.set_value(false); }); diff --git a/cpp/test/Ice/custom/CustomBuffer.h b/cpp/test/Ice/custom/CustomBuffer.h index 9eea50f7019..f2015f3adce 100644 --- a/cpp/test/Ice/custom/CustomBuffer.h +++ b/cpp/test/Ice/custom/CustomBuffer.h @@ -6,6 +6,7 @@ #define CUSTOM_BUFFER_H #include +#include #if defined(_MSC_VER) # pragma warning(disable : 4800) diff --git a/cpp/test/Ice/custom/MyByteSeq.cpp b/cpp/test/Ice/custom/MyByteSeq.cpp index 7aa57918f60..1a98cc48c7f 100644 --- a/cpp/test/Ice/custom/MyByteSeq.cpp +++ b/cpp/test/Ice/custom/MyByteSeq.cpp @@ -2,7 +2,7 @@ // Copyright (c) ZeroC, Inc. All rights reserved. // -#include +#include "MyByteSeq.h" MyByteSeq::MyByteSeq() : _size(0), _data(0) {} @@ -10,7 +10,7 @@ MyByteSeq::MyByteSeq(size_t size) : _size(size), _data(0) { if (_size != 0) { - _data = new uint8_t[_size]; + _data = new std::byte[_size]; } } @@ -19,7 +19,7 @@ MyByteSeq::MyByteSeq(const MyByteSeq& seq) _size = seq._size; if (_size != 0) { - _data = new uint8_t[_size]; + _data = new std::byte[_size]; memcpy(_data, seq._data, _size); } else @@ -40,7 +40,7 @@ void MyByteSeq::swap(MyByteSeq& seq) { size_t tmpSize = seq._size; - uint8_t* tmpData = seq._data; + std::byte* tmpData = seq._data; seq._size = _size; seq._data = _data; _size = tmpSize; @@ -68,7 +68,7 @@ MyByteSeq::operator=(const MyByteSeq& rhs) _size = rhs._size; if (_size != 0) { - _data = new uint8_t[_size]; + _data = new std::byte[_size]; memcpy(_data, rhs._data, _size); } } diff --git a/cpp/test/Ice/custom/MyByteSeq.h b/cpp/test/Ice/custom/MyByteSeq.h index c316a862342..ec1b428770e 100644 --- a/cpp/test/Ice/custom/MyByteSeq.h +++ b/cpp/test/Ice/custom/MyByteSeq.h @@ -10,10 +10,10 @@ class MyByteSeq { public: - typedef std::uint8_t* iterator; - typedef std::uint8_t* const_iterator; + typedef std::byte* iterator; + typedef std::byte* const_iterator; - typedef std::uint8_t value_type; + typedef std::byte value_type; MyByteSeq(); MyByteSeq(size_t); @@ -29,7 +29,7 @@ class MyByteSeq private: size_t _size; - std::uint8_t* _data; + std::byte* _data; }; #endif diff --git a/cpp/test/Ice/custom/Test.ice b/cpp/test/Ice/custom/Test.ice index 664852e34eb..0395db72bba 100644 --- a/cpp/test/Ice/custom/Test.ice +++ b/cpp/test/Ice/custom/Test.ice @@ -21,7 +21,7 @@ sequence BoolListSeq; ["cpp:type:std::list<::std::deque>"] sequence<["cpp:type:std::deque"] BoolSeq> BoolDequeList; sequence ByteSeq; -["cpp:type:std::list<::std::uint8_t>"] sequence ByteList; +["cpp:type:std::list<::std::byte>"] sequence ByteList; ["cpp:type:std::list<::Test::ByteList>"] sequence ByteListList; sequence ByteListSeq; @@ -109,7 +109,7 @@ class DictClass ["cpp:type:Test::CustomBuffer"] sequence LongBuffer; ["cpp:type:Test::CustomBuffer"] sequence FloatBuffer; ["cpp:type:Test::CustomBuffer"] sequence DoubleBuffer; -["cpp:type:Test::CustomBuffer<::std::uint8_t>"] sequence ByteBuffer; +["cpp:type:Test::CustomBuffer<::std::byte>"] sequence ByteBuffer; struct BufferStruct { ByteBuffer byteBuf; @@ -140,9 +140,9 @@ interface TestIntf ["cpp:array"] BoolDequeList opBoolDequeListArray(["cpp:array"] BoolDequeList inSeq, out ["cpp:array"] BoolDequeList outSeq); - ["cpp:type:std::deque<::std::uint8_t>"] ByteSeq - opByteSeq(["cpp:type:std::deque<::std::uint8_t>"] ByteSeq inSeq, - out ["cpp:type:std::deque<::std::uint8_t>"] ByteSeq outSeq); + ["cpp:type:std::deque<::std::byte>"] ByteSeq + opByteSeq(["cpp:type:std::deque<::std::byte>"] ByteSeq inSeq, + out ["cpp:type:std::deque<::std::byte>"] ByteSeq outSeq); ByteList opByteList(ByteList inSeq, out ByteList outSeq); diff --git a/cpp/test/Ice/custom/TestAMD.ice b/cpp/test/Ice/custom/TestAMD.ice index 6143a7362fc..1ed1a015cc4 100644 --- a/cpp/test/Ice/custom/TestAMD.ice +++ b/cpp/test/Ice/custom/TestAMD.ice @@ -18,7 +18,7 @@ sequence BoolListSeq; ["cpp:type:std::list<::Test::BoolSeq>"] sequence BoolSeqList; sequence ByteSeq; -["cpp:type:std::list"] sequence ByteList; +["cpp:type:std::list"] sequence ByteList; ["cpp:type:std::list<::Test::ByteList>"] sequence ByteListList; sequence ByteListSeq; @@ -106,7 +106,7 @@ class DictClass ["cpp:type:Test::CustomBuffer"] sequence LongBuffer; ["cpp:type:Test::CustomBuffer"] sequence FloatBuffer; ["cpp:type:Test::CustomBuffer"] sequence DoubleBuffer; -["cpp:type:Test::CustomBuffer"] sequence ByteBuffer; +["cpp:type:Test::CustomBuffer"] sequence ByteBuffer; struct BufferStruct { ByteBuffer byteBuf; @@ -133,9 +133,9 @@ struct BufferStruct BoolList opBoolList(BoolList inSeq, out BoolList outSeq); - ["cpp:type:std::deque"] ByteSeq - opByteSeq(["cpp:type:std::deque"] ByteSeq inSeq, - out ["cpp:type:std::deque"] ByteSeq outSeq); + ["cpp:type:std::deque"] ByteSeq + opByteSeq(["cpp:type:std::deque"] ByteSeq inSeq, + out ["cpp:type:std::deque"] ByteSeq outSeq); ByteList opByteList(ByteList inSeq, out ByteList outSeq); diff --git a/cpp/test/Ice/custom/TestAMDI.cpp b/cpp/test/Ice/custom/TestAMDI.cpp index 6f282e94292..52bd08d6ba3 100644 --- a/cpp/test/Ice/custom/TestAMDI.cpp +++ b/cpp/test/Ice/custom/TestAMDI.cpp @@ -33,8 +33,8 @@ TestIntfI::opBoolArrayAsync( void TestIntfI::opByteArrayAsync( - pair in, - function&, const pair&)> response, + pair in, + function&, const pair&)> response, function, const Current&) { @@ -74,8 +74,8 @@ TestIntfI::opBoolListAsync( void TestIntfI::opByteSeqAsync( - deque in, - function&, const deque&)> response, + deque in, + function&, const deque&)> response, function, const Current&) { @@ -245,7 +245,7 @@ TestIntfI::opCListAsync( void TestIntfI::opOutArrayByteSeqAsync( ByteSeq in, - function&)> response, + function&)> response, function, const Current&) { diff --git a/cpp/test/Ice/custom/TestAMDI.h b/cpp/test/Ice/custom/TestAMDI.h index 08e1a6fafc2..d46f053a6f9 100644 --- a/cpp/test/Ice/custom/TestAMDI.h +++ b/cpp/test/Ice/custom/TestAMDI.h @@ -23,10 +23,10 @@ class TestIntfI : public virtual Test::TestIntf const Ice::Current&) override; void opByteArrayAsync( - std::pair, + std::pair, std::function&, - const std::pair&)>, + const std::pair&, + const std::pair&)>, std::function, const Ice::Current&) override; @@ -49,8 +49,8 @@ class TestIntfI : public virtual Test::TestIntf const Ice::Current&) override; void opByteSeqAsync( - std::deque, - std::function&, const std::deque&)>, + std::deque, + std::function&, const std::deque&)>, std::function, const Ice::Current&) override; @@ -152,7 +152,7 @@ class TestIntfI : public virtual Test::TestIntf void opOutArrayByteSeqAsync( Test::ByteSeq, - std::function&)>, + std::function&)>, std::function, const Ice::Current&) override; diff --git a/cpp/test/Ice/custom/TestI.cpp b/cpp/test/Ice/custom/TestI.cpp index 1e0f0ee958f..585f44082bc 100644 --- a/cpp/test/Ice/custom/TestI.cpp +++ b/cpp/test/Ice/custom/TestI.cpp @@ -24,7 +24,7 @@ TestIntfI::opBoolArray(pair inSeq, BoolSeq& outSeq, co } ByteList -TestIntfI::opByteArray(pair inSeq, ByteList& outSeq, const Current&) +TestIntfI::opByteArray(pair inSeq, ByteList& outSeq, const Current&) { ByteList(inSeq.first, inSeq.second).swap(outSeq); return outSeq; @@ -71,15 +71,15 @@ TestIntfI::opBoolDequeListArray( return outSeq; } -deque -TestIntfI::opByteSeq(deque inSeq, deque& outSeq, const Current&) +deque +TestIntfI::opByteSeq(deque inSeq, deque& outSeq, const Current&) { outSeq = inSeq; return inSeq; } -list -TestIntfI::opByteList(list inSeq, list& outSeq, const Current&) +list +TestIntfI::opByteList(list inSeq, list& outSeq, const Current&) { outSeq = inSeq; return inSeq; diff --git a/cpp/test/Ice/custom/TestI.h b/cpp/test/Ice/custom/TestI.h index 17e2876226c..d21a6403431 100644 --- a/cpp/test/Ice/custom/TestI.h +++ b/cpp/test/Ice/custom/TestI.h @@ -15,7 +15,7 @@ class TestIntfI final : public Test::TestIntf Test::BoolSeq opBoolArray(std::pair, Test::BoolSeq&, const Ice::Current&) final; Test::ByteList - opByteArray(std::pair, Test::ByteList&, const Ice::Current&) final; + opByteArray(std::pair, Test::ByteList&, const Ice::Current&) final; Test::VariableList opVariableArray( std::pair, @@ -33,9 +33,9 @@ class TestIntfI final : public Test::TestIntf Test::BoolDequeList&, const Ice::Current&) final; - std::deque opByteSeq(std::deque, std::deque&, const Ice::Current&) final; + std::deque opByteSeq(std::deque, std::deque&, const Ice::Current&) final; - std::list opByteList(std::list, std::list&, const Ice::Current&) final; + std::list opByteList(std::list, std::list&, const Ice::Current&) final; MyByteSeq opMyByteSeq(MyByteSeq, MyByteSeq&, const Ice::Current&) final; diff --git a/cpp/test/Ice/echo/BlobjectI.cpp b/cpp/test/Ice/echo/BlobjectI.cpp index c2c38925bc0..72b910aa927 100644 --- a/cpp/test/Ice/echo/BlobjectI.cpp +++ b/cpp/test/Ice/echo/BlobjectI.cpp @@ -34,8 +34,8 @@ BlobjectI::flushBatch() void BlobjectI::ice_invokeAsync( - std::vector inEncaps, - std::function&)> response, + std::vector inEncaps, + std::function&)> response, std::function ex, const Ice::Current& current) { @@ -61,9 +61,9 @@ BlobjectI::ice_invokeAsync( if (_batchProxy) { - vector out; + vector out; obj->ice_invoke(current.operation, current.mode, inEncaps, out, current.ctx); - response(true, vector()); + response(true, vector()); } else { @@ -71,9 +71,9 @@ BlobjectI::ice_invokeAsync( current.operation, current.mode, inEncaps, - [](bool, const std::vector&) { assert(0); }, + [](bool, const std::vector&) { assert(0); }, ex, - [&](bool) { response(true, vector()); }, + [&](bool) { response(true, vector()); }, current.ctx); } } diff --git a/cpp/test/Ice/echo/BlobjectI.h b/cpp/test/Ice/echo/BlobjectI.h index da0bd821605..de46a5d6491 100644 --- a/cpp/test/Ice/echo/BlobjectI.h +++ b/cpp/test/Ice/echo/BlobjectI.h @@ -17,8 +17,8 @@ class BlobjectI final : public Ice::BlobjectAsync void setConnection(const Ice::ConnectionPtr&); void ice_invokeAsync( - std::vector, - std::function&)>, + std::vector, + std::function&)>, std::function, const Ice::Current&) final; diff --git a/cpp/test/Ice/executor/AllTests.cpp b/cpp/test/Ice/executor/AllTests.cpp index 4ae3a49cafa..9627c974a68 100644 --- a/cpp/test/Ice/executor/AllTests.cpp +++ b/cpp/test/Ice/executor/AllTests.cpp @@ -151,7 +151,7 @@ allTests(TestHelper* helper) seq.resize(1024); // Make sure the request doesn't compress too well. for (ByteSeq::iterator q = seq.begin(); q != seq.end(); ++q) { - *q = static_cast(IceUtilInternal::random(255)); + *q = static_cast(IceUtilInternal::random(255)); } vector>> completed; diff --git a/cpp/test/Ice/invoke/AllTests.cpp b/cpp/test/Ice/invoke/AllTests.cpp index 510e20f9260..a0df4beb83a 100644 --- a/cpp/test/Ice/invoke/AllTests.cpp +++ b/cpp/test/Ice/invoke/AllTests.cpp @@ -59,7 +59,7 @@ allTests(Test::TestHelper* helper) } // ice_invoke with array mapping - pair inPair(&inEncaps[0], &inEncaps[0] + inEncaps.size()); + pair inPair(&inEncaps[0], &inEncaps[0] + inEncaps.size()); if (cl->ice_invoke("opString", OperationMode::Normal, inPair, outEncaps)) { InputStream in(communicator, out.getEncoding(), outEncaps); @@ -117,7 +117,7 @@ allTests(Test::TestHelper* helper) "opOneway", OperationMode::Normal, inEncaps, - [](bool, const vector) { test(false); }, + [](bool, const vector) { test(false); }, [](exception_ptr) { test(false); }, [](bool) { test(false); }); batchOneway->ice_flushBatchRequests(); @@ -185,7 +185,7 @@ allTests(Test::TestHelper* helper) "opString", OperationMode::Normal, inEncaps, - [&](bool ok, vector outParams) + [&](bool ok, vector outParams) { outEncaps = std::move(outParams); completed.set_value(ok); @@ -242,9 +242,9 @@ allTests(Test::TestHelper* helper) "opString", OperationMode::Normal, inPair, - [&](bool ok, pair outParams) + [&](bool ok, pair outParams) { - vector(outParams.first, outParams.second).swap(outEncaps); + vector(outParams.first, outParams.second).swap(outEncaps); completed.set_value(ok); }, [&](exception_ptr ex) { completed.set_exception(ex); }, @@ -297,7 +297,7 @@ allTests(Test::TestHelper* helper) "opException", OperationMode::Normal, inEncaps, - [&](bool ok, vector outParams) + [&](bool ok, vector outParams) { outEncaps = std::move(outParams); completed.set_value(ok); diff --git a/cpp/test/Ice/invoke/BlobjectI.cpp b/cpp/test/Ice/invoke/BlobjectI.cpp index aca68d747b2..f5cf2128138 100644 --- a/cpp/test/Ice/invoke/BlobjectI.cpp +++ b/cpp/test/Ice/invoke/BlobjectI.cpp @@ -12,7 +12,7 @@ using namespace Test; using namespace Ice; bool -invokeInternal(InputStream& in, vector& outEncaps, const Current& current) +invokeInternal(InputStream& in, vector& outEncaps, const Current& current) { CommunicatorPtr communicator = current.adapter->getCommunicator(); OutputStream out(communicator); @@ -81,17 +81,14 @@ invokeInternal(InputStream& in, vector& outEncaps, const Current& curre } bool -BlobjectI::ice_invoke(vector inEncaps, vector& outEncaps, const Current& current) +BlobjectI::ice_invoke(vector inEncaps, vector& outEncaps, const Current& current) { InputStream in(current.adapter->getCommunicator(), current.encoding, inEncaps); return invokeInternal(in, outEncaps, current); } bool -BlobjectArrayI::ice_invoke( - pair inEncaps, - vector& outEncaps, - const Current& current) +BlobjectArrayI::ice_invoke(pair inEncaps, vector& outEncaps, const Current& current) { InputStream in(current.adapter->getCommunicator(), current.encoding, inEncaps); return invokeInternal(in, outEncaps, current); @@ -99,30 +96,28 @@ BlobjectArrayI::ice_invoke( void BlobjectAsyncI::ice_invokeAsync( - vector inEncaps, - function&)> response, + vector inEncaps, + function&)> response, function, const Current& current) { InputStream in(current.adapter->getCommunicator(), inEncaps); - vector outEncaps; + vector outEncaps; bool ok = invokeInternal(in, outEncaps, current); response(ok, outEncaps); } void BlobjectArrayAsyncI::ice_invokeAsync( - pair inEncaps, - function&)> response, + pair inEncaps, + function&)> response, function, const Current& current) { InputStream in(current.adapter->getCommunicator(), inEncaps); - vector outEncaps; + vector outEncaps; bool ok = invokeInternal(in, outEncaps, current); - pair outPair( - static_cast(nullptr), - static_cast(nullptr)); + pair outPair(static_cast(nullptr), static_cast(nullptr)); if (outEncaps.size() != 0) { outPair.first = &outEncaps[0]; diff --git a/cpp/test/Ice/invoke/BlobjectI.h b/cpp/test/Ice/invoke/BlobjectI.h index 88e32f94919..afa1286bb2c 100644 --- a/cpp/test/Ice/invoke/BlobjectI.h +++ b/cpp/test/Ice/invoke/BlobjectI.h @@ -10,24 +10,21 @@ class BlobjectI final : public Ice::Blobject { public: - bool ice_invoke(std::vector, std::vector&, const Ice::Current&) final; + bool ice_invoke(std::vector, std::vector&, const Ice::Current&) final; }; class BlobjectArrayI final : public Ice::BlobjectArray { public: - bool ice_invoke( - std::pair, - std::vector&, - const Ice::Current&) final; + bool ice_invoke(std::pair, std::vector&, const Ice::Current&) final; }; class BlobjectAsyncI final : public Ice::BlobjectAsync { public: void ice_invokeAsync( - std::vector, - std::function&)>, + std::vector, + std::function&)>, std::function, const Ice::Current&) final; }; @@ -36,8 +33,8 @@ class BlobjectArrayAsyncI final : public Ice::BlobjectArrayAsync { public: void ice_invokeAsync( - std::pair, - std::function&)>, + std::pair, + std::function&)>, std::function, const Ice::Current&) final; }; diff --git a/cpp/test/Ice/objects/TestI.cpp b/cpp/test/Ice/objects/TestI.cpp index 324702c831d..381eca55ada 100644 --- a/cpp/test/Ice/objects/TestI.cpp +++ b/cpp/test/Ice/objects/TestI.cpp @@ -305,7 +305,7 @@ InitialI::opM(MPtr v1, MPtr& v2, const Current&) } bool -UnexpectedObjectExceptionTestI::ice_invoke(vector, vector& outParams, const Current& current) +UnexpectedObjectExceptionTestI::ice_invoke(vector, vector& outParams, const Current& current) { CommunicatorPtr communicator = current.adapter->getCommunicator(); OutputStream out(communicator); diff --git a/cpp/test/Ice/objects/TestI.h b/cpp/test/Ice/objects/TestI.h index 854c9b7a842..b2fb8b468d6 100644 --- a/cpp/test/Ice/objects/TestI.h +++ b/cpp/test/Ice/objects/TestI.h @@ -117,7 +117,7 @@ class InitialI final : public Test::Initial class UnexpectedObjectExceptionTestI : public Ice::Blobject { public: - bool ice_invoke(std::vector, std::vector&, const Ice::Current&) final; + bool ice_invoke(std::vector, std::vector&, const Ice::Current&) final; }; using UnexpectedObjectExceptionTestIPtr = std::shared_ptr; diff --git a/cpp/test/Ice/operations/Twoways.cpp b/cpp/test/Ice/operations/Twoways.cpp index e2581ab0dc8..85bf1cd5f7f 100644 --- a/cpp/test/Ice/operations/Twoways.cpp +++ b/cpp/test/Ice/operations/Twoways.cpp @@ -327,34 +327,34 @@ twoways(const Ice::CommunicatorPtr& communicator, Test::TestHelper*, const Test: Test::ByteS bsi1; Test::ByteS bsi2; - bsi1.push_back(uint8_t(0x01)); - bsi1.push_back(uint8_t(0x11)); - bsi1.push_back(uint8_t(0x12)); - bsi1.push_back(uint8_t(0x22)); + bsi1.push_back(byte{0x01}); + bsi1.push_back(byte{0x11}); + bsi1.push_back(byte{0x12}); + bsi1.push_back(byte{0x22}); - bsi2.push_back(uint8_t(0xf1)); - bsi2.push_back(uint8_t(0xf2)); - bsi2.push_back(uint8_t(0xf3)); - bsi2.push_back(uint8_t(0xf4)); + bsi2.push_back(byte{0xf1}); + bsi2.push_back(byte{0xf2}); + bsi2.push_back(byte{0xf3}); + bsi2.push_back(byte{0xf4}); Test::ByteS bso; Test::ByteS rso; rso = p->opByteS(bsi1, bsi2, bso); test(bso.size() == 4); - test(bso[0] == uint8_t(0x22)); - test(bso[1] == uint8_t(0x12)); - test(bso[2] == uint8_t(0x11)); - test(bso[3] == uint8_t(0x01)); + test(bso[0] == byte{0x22}); + test(bso[1] == byte{0x12}); + test(bso[2] == byte{0x11}); + test(bso[3] == byte{0x01}); test(rso.size() == 8); - test(rso[0] == uint8_t(0x01)); - test(rso[1] == uint8_t(0x11)); - test(rso[2] == uint8_t(0x12)); - test(rso[3] == uint8_t(0x22)); - test(rso[4] == uint8_t(0xf1)); - test(rso[5] == uint8_t(0xf2)); - test(rso[6] == uint8_t(0xf3)); - test(rso[7] == uint8_t(0xf4)); + test(rso[0] == byte{0x01}); + test(rso[1] == byte{0x11}); + test(rso[2] == byte{0x12}); + test(rso[3] == byte{0x22}); + test(rso[4] == byte{0xf1}); + test(rso[5] == byte{0xf2}); + test(rso[6] == byte{0xf3}); + test(rso[7] == byte{0xf4}); } { @@ -490,14 +490,14 @@ twoways(const Ice::CommunicatorPtr& communicator, Test::TestHelper*, const Test: Test::ByteSS bsi2; bsi2.resize(2); - bsi1[0].push_back(uint8_t(0x01)); - bsi1[0].push_back(uint8_t(0x11)); - bsi1[0].push_back(uint8_t(0x12)); - bsi1[1].push_back(uint8_t(0xff)); + bsi1[0].push_back(byte{0x01}); + bsi1[0].push_back(byte{0x11}); + bsi1[0].push_back(byte{0x12}); + bsi1[1].push_back(byte{0xff}); - bsi2[0].push_back(uint8_t(0x0e)); - bsi2[1].push_back(uint8_t(0xf2)); - bsi2[1].push_back(uint8_t(0xf1)); + bsi2[0].push_back(byte{0x0e}); + bsi2[1].push_back(byte{0xf2}); + bsi2[1].push_back(byte{0xf1}); Test::ByteSS bso; Test::ByteSS rso; @@ -505,23 +505,23 @@ twoways(const Ice::CommunicatorPtr& communicator, Test::TestHelper*, const Test: rso = p->opByteSS(bsi1, bsi2, bso); test(bso.size() == 2); test(bso[0].size() == 1); - test(bso[0][0] == uint8_t(0xff)); + test(bso[0][0] == byte{0xff}); test(bso[1].size() == 3); - test(bso[1][0] == uint8_t(0x01)); - test(bso[1][1] == uint8_t(0x11)); - test(bso[1][2] == uint8_t(0x12)); + test(bso[1][0] == byte{0x01}); + test(bso[1][1] == byte{0x11}); + test(bso[1][2] == byte{0x12}); test(rso.size() == 4); test(rso[0].size() == 3); - test(rso[0][0] == uint8_t(0x01)); - test(rso[0][1] == uint8_t(0x11)); - test(rso[0][2] == uint8_t(0x12)); + test(rso[0][0] == byte{0x01}); + test(rso[0][1] == byte{0x11}); + test(rso[0][2] == byte{0x12}); test(rso[1].size() == 1); - test(rso[1][0] == uint8_t(0xff)); + test(rso[1][0] == byte{0xff}); test(rso[2].size() == 1); - test(rso[2][0] == uint8_t(0x0e)); + test(rso[2][0] == byte{0x0e}); test(rso[3].size() == 2); - test(rso[3][0] == uint8_t(0xf2)); - test(rso[3][1] == uint8_t(0xf1)); + test(rso[3][0] == byte{0xf2}); + test(rso[3][1] == byte{0xf1}); } { @@ -1247,15 +1247,15 @@ twoways(const Ice::CommunicatorPtr& communicator, Test::TestHelper*, const Test: Test::ByteS si2; Test::ByteS si3; - si1.push_back(uint8_t(0x01)); - si1.push_back(uint8_t(0x11)); - si2.push_back(uint8_t(0x12)); - si3.push_back(uint8_t(0xf2)); - si3.push_back(uint8_t(0xf3)); + si1.push_back(byte{0x01}); + si1.push_back(byte{0x11}); + si2.push_back(byte{0x12}); + si3.push_back(byte{0xf2}); + si3.push_back(byte{0xf3}); - sdi1[uint8_t(0x01)] = si1; - sdi1[uint8_t(0x22)] = si2; - sdi2[uint8_t(0xf1)] = si3; + sdi1[uint8_t{0x01}] = si1; + sdi1[uint8_t{0x22}] = si2; + sdi2[uint8_t{0xf1}] = si3; try { @@ -1264,14 +1264,14 @@ twoways(const Ice::CommunicatorPtr& communicator, Test::TestHelper*, const Test: test(_do == sdi2); test(ro.size() == 3); - test(ro[uint8_t(0x01)].size() == 2); - test(ro[uint8_t(0x01)][0] == uint8_t(0x01)); - test(ro[uint8_t(0x01)][1] == uint8_t(0x11)); - test(ro[uint8_t(0x22)].size() == 1); - test(ro[uint8_t(0x22)][0] == uint8_t(0x12)); - test(ro[uint8_t(0xf1)].size() == 2); - test(ro[uint8_t(0xf1)][0] == uint8_t(0xf2)); - test(ro[uint8_t(0xf1)][1] == uint8_t(0xf3)); + test(ro[uint8_t{0x01}].size() == 2); + test(ro[uint8_t{0x01}][0] == byte{0x01}); + test(ro[uint8_t{0x01}][1] == byte{0x11}); + test(ro[uint8_t{0x22}].size() == 1); + test(ro[uint8_t{0x22}][0] == byte{0x12}); + test(ro[uint8_t{0xf1}].size() == 2); + test(ro[uint8_t{0xf1}][0] == byte{0xf2}); + test(ro[uint8_t{0xf1}][1] == byte{0xf3}); } catch (const Ice::OperationNotExistException&) { diff --git a/cpp/test/Ice/operations/TwowaysAMI.cpp b/cpp/test/Ice/operations/TwowaysAMI.cpp index adb33c046d7..d887a017bff 100644 --- a/cpp/test/Ice/operations/TwowaysAMI.cpp +++ b/cpp/test/Ice/operations/TwowaysAMI.cpp @@ -181,19 +181,19 @@ namespace void opByteS(const ByteS& rso, const ByteS& bso) { test(bso.size() == 4); - test(bso[0] == uint8_t(0x22)); - test(bso[1] == uint8_t(0x12)); - test(bso[2] == uint8_t(0x11)); - test(bso[3] == uint8_t(0x01)); + test(bso[0] == byte{0x22}); + test(bso[1] == byte{0x12}); + test(bso[2] == byte{0x11}); + test(bso[3] == byte{0x01}); test(rso.size() == 8); - test(rso[0] == uint8_t(0x01)); - test(rso[1] == uint8_t(0x11)); - test(rso[2] == uint8_t(0x12)); - test(rso[3] == uint8_t(0x22)); - test(rso[4] == uint8_t(0xf1)); - test(rso[5] == uint8_t(0xf2)); - test(rso[6] == uint8_t(0xf3)); - test(rso[7] == uint8_t(0xf4)); + test(rso[0] == byte{0x01}); + test(rso[1] == byte{0x11}); + test(rso[2] == byte{0x12}); + test(rso[3] == byte{0x22}); + test(rso[4] == byte{0xf1}); + test(rso[5] == byte{0xf2}); + test(rso[6] == byte{0xf3}); + test(rso[7] == byte{0xf4}); called(); } @@ -272,23 +272,23 @@ namespace { test(bso.size() == 2); test(bso[0].size() == 1); - test(bso[0][0] == uint8_t(0xff)); + test(bso[0][0] == byte{0xff}); test(bso[1].size() == 3); - test(bso[1][0] == uint8_t(0x01)); - test(bso[1][1] == uint8_t(0x11)); - test(bso[1][2] == uint8_t(0x12)); + test(bso[1][0] == byte{0x01}); + test(bso[1][1] == byte{0x11}); + test(bso[1][2] == byte{0x12}); test(rso.size() == 4); test(rso[0].size() == 3); - test(rso[0][0] == uint8_t(0x01)); - test(rso[0][1] == uint8_t(0x11)); - test(rso[0][2] == uint8_t(0x12)); + test(rso[0][0] == byte{0x01}); + test(rso[0][1] == byte{0x11}); + test(rso[0][2] == byte{0x12}); test(rso[1].size() == 1); - test(rso[1][0] == uint8_t(0xff)); + test(rso[1][0] == byte{0xff}); test(rso[2].size() == 1); - test(rso[2][0] == uint8_t(0x0e)); + test(rso[2][0] == byte{0x0e}); test(rso[3].size() == 2); - test(rso[3][0] == uint8_t(0xf2)); - test(rso[3][1] == uint8_t(0xf1)); + test(rso[3][0] == byte{0xf2}); + test(rso[3][1] == byte{0xf1}); called(); } @@ -742,22 +742,22 @@ namespace void opByteByteSD(const ByteByteSD& ro, const ByteByteSD& _do) { test(_do.size() == 1); - test(_do.find(uint8_t(0xf1)) != _do.end()); - test(_do.find(uint8_t(0xf1))->second.size() == 2); - test(_do.find(uint8_t(0xf1))->second[0] == 0xf2); - test(_do.find(uint8_t(0xf1))->second[1] == 0xf3); + test(_do.find(uint8_t{0xf1}) != _do.end()); + test(_do.find(uint8_t{0xf1})->second.size() == 2); + test(_do.find(uint8_t{0xf1})->second[0] == byte{0xf2}); + test(_do.find(uint8_t{0xf1})->second[1] == byte{0xf3}); test(ro.size() == 3); - test(ro.find(uint8_t(0x01)) != ro.end()); - test(ro.find(uint8_t(0x01))->second.size() == 2); - test(ro.find(uint8_t(0x01))->second[0] == uint8_t(0x01)); - test(ro.find(uint8_t(0x01))->second[1] == uint8_t(0x11)); - test(ro.find(uint8_t(0x22)) != ro.end()); - test(ro.find(uint8_t(0x22))->second.size() == 1); - test(ro.find(uint8_t(0x22))->second[0] == uint8_t(0x12)); - test(ro.find(uint8_t(0xf1)) != ro.end()); - test(ro.find(uint8_t(0xf1))->second.size() == 2); - test(ro.find(uint8_t(0xf1))->second[0] == uint8_t(0xf2)); - test(ro.find(uint8_t(0xf1))->second[1] == uint8_t(0xf3)); + test(ro.find(uint8_t{0x01}) != ro.end()); + test(ro.find(uint8_t{0x01})->second.size() == 2); + test(ro.find(uint8_t{0x01})->second[0] == byte{0x01}); + test(ro.find(uint8_t{0x01})->second[1] == byte{0x11}); + test(ro.find(uint8_t{0x22}) != ro.end()); + test(ro.find(uint8_t{0x22})->second.size() == 1); + test(ro.find(uint8_t{0x22})->second[0] == byte{0x12}); + test(ro.find(uint8_t{0xf1}) != ro.end()); + test(ro.find(uint8_t{0xf1})->second.size() == 2); + test(ro.find(uint8_t{0xf1})->second[0] == byte{0xf2}); + test(ro.find(uint8_t{0xf1})->second[1] == byte{0xf3}); called(); } @@ -1123,15 +1123,15 @@ twowaysAMI(const CommunicatorPtr& communicator, const MyClassPrx& p) ByteS bsi1; ByteS bsi2; - bsi1.push_back(uint8_t(0x01)); - bsi1.push_back(uint8_t(0x11)); - bsi1.push_back(uint8_t(0x12)); - bsi1.push_back(uint8_t(0x22)); + bsi1.push_back(byte{0x01}); + bsi1.push_back(byte{0x11}); + bsi1.push_back(byte{0x12}); + bsi1.push_back(byte{0x22}); - bsi2.push_back(uint8_t(0xf1)); - bsi2.push_back(uint8_t(0xf2)); - bsi2.push_back(uint8_t(0xf3)); - bsi2.push_back(uint8_t(0xf4)); + bsi2.push_back(byte{0xf1}); + bsi2.push_back(byte{0xf2}); + bsi2.push_back(byte{0xf3}); + bsi2.push_back(byte{0xf4}); CallbackPtr cb = make_shared(); p->opByteSAsync( @@ -1236,14 +1236,14 @@ twowaysAMI(const CommunicatorPtr& communicator, const MyClassPrx& p) ByteSS bsi2; bsi2.resize(2); - bsi1[0].push_back(uint8_t(0x01)); - bsi1[0].push_back(uint8_t(0x11)); - bsi1[0].push_back(uint8_t(0x12)); - bsi1[1].push_back(uint8_t(0xff)); + bsi1[0].push_back(byte{0x01}); + bsi1[0].push_back(byte{0x11}); + bsi1[0].push_back(byte{0x12}); + bsi1[1].push_back(byte{0xff}); - bsi2[0].push_back(uint8_t(0x0e)); - bsi2[1].push_back(uint8_t(0xf2)); - bsi2[1].push_back(uint8_t(0xf1)); + bsi2[0].push_back(byte{0x0e}); + bsi2[1].push_back(byte{0xf2}); + bsi2[1].push_back(byte{0xf1}); CallbackPtr cb = make_shared(); p->opByteSSAsync( @@ -1680,15 +1680,15 @@ twowaysAMI(const CommunicatorPtr& communicator, const MyClassPrx& p) ByteS si2; ByteS si3; - si1.push_back(uint8_t(0x01)); - si1.push_back(uint8_t(0x11)); - si2.push_back(uint8_t(0x12)); - si3.push_back(uint8_t(0xf2)); - si3.push_back(uint8_t(0xf3)); + si1.push_back(byte{0x01}); + si1.push_back(byte{0x11}); + si2.push_back(byte{0x12}); + si3.push_back(byte{0xf2}); + si3.push_back(byte{0xf3}); - sdi1[uint8_t(0x01)] = si1; - sdi1[uint8_t(0x22)] = si2; - sdi2[uint8_t(0xf1)] = si3; + sdi1[uint8_t{0x01}] = si1; + sdi1[uint8_t{0x22}] = si2; + sdi2[uint8_t{0xf1}] = si3; CallbackPtr cb = make_shared(); p->opByteByteSDAsync( @@ -2396,15 +2396,15 @@ twowaysAMI(const CommunicatorPtr& communicator, const MyClassPrx& p) ByteS bsi1; ByteS bsi2; - bsi1.push_back(uint8_t(0x01)); - bsi1.push_back(uint8_t(0x11)); - bsi1.push_back(uint8_t(0x12)); - bsi1.push_back(uint8_t(0x22)); + bsi1.push_back(byte{0x01}); + bsi1.push_back(byte{0x11}); + bsi1.push_back(byte{0x12}); + bsi1.push_back(byte{0x22}); - bsi2.push_back(uint8_t(0xf1)); - bsi2.push_back(uint8_t(0xf2)); - bsi2.push_back(uint8_t(0xf3)); - bsi2.push_back(uint8_t(0xf4)); + bsi2.push_back(byte{0xf1}); + bsi2.push_back(byte{0xf2}); + bsi2.push_back(byte{0xf3}); + bsi2.push_back(byte{0xf4}); CallbackPtr cb = make_shared(); auto f = p->opByteSAsync(bsi1, bsi2); @@ -2551,14 +2551,14 @@ twowaysAMI(const CommunicatorPtr& communicator, const MyClassPrx& p) ByteSS bsi2; bsi2.resize(2); - bsi1[0].push_back(uint8_t(0x01)); - bsi1[0].push_back(uint8_t(0x11)); - bsi1[0].push_back(uint8_t(0x12)); - bsi1[1].push_back(uint8_t(0xff)); + bsi1[0].push_back(byte{0x01}); + bsi1[0].push_back(byte{0x11}); + bsi1[0].push_back(byte{0x12}); + bsi1[1].push_back(byte{0xff}); - bsi2[0].push_back(uint8_t(0x0e)); - bsi2[1].push_back(uint8_t(0xf2)); - bsi2[1].push_back(uint8_t(0xf1)); + bsi2[0].push_back(byte{0x0e}); + bsi2[1].push_back(byte{0xf2}); + bsi2[1].push_back(byte{0xf1}); CallbackPtr cb = make_shared(); auto f = p->opByteSSAsync(bsi1, bsi2); @@ -3085,15 +3085,15 @@ twowaysAMI(const CommunicatorPtr& communicator, const MyClassPrx& p) ByteS si2; ByteS si3; - si1.push_back(uint8_t(0x01)); - si1.push_back(uint8_t(0x11)); - si2.push_back(uint8_t(0x12)); - si3.push_back(uint8_t(0xf2)); - si3.push_back(uint8_t(0xf3)); + si1.push_back(byte{0x01}); + si1.push_back(byte{0x11}); + si2.push_back(byte{0x12}); + si3.push_back(byte{0xf2}); + si3.push_back(byte{0xf3}); - sdi1[uint8_t(0x01)] = si1; - sdi1[uint8_t(0x22)] = si2; - sdi2[uint8_t(0xf1)] = si3; + sdi1[uint8_t{0x01}] = si1; + sdi1[uint8_t{0x22}] = si2; + sdi2[uint8_t{0xf1}] = si3; CallbackPtr cb = make_shared(); auto f = p->opByteByteSDAsync(sdi1, sdi2); diff --git a/cpp/test/Ice/optional/AllTests.cpp b/cpp/test/Ice/optional/AllTests.cpp index cd78345c48c..a4b2454c11d 100644 --- a/cpp/test/Ice/optional/AllTests.cpp +++ b/cpp/test/Ice/optional/AllTests.cpp @@ -313,7 +313,7 @@ allTests(Test::TestHelper* helper, bool) mo1->j = MyInterfacePrx(communicator, "test"); mo1->k = mo1; mo1->bs = ByteSeq(); - (*mo1->bs).push_back(5); + (*mo1->bs).push_back(byte{5}); mo1->ss = StringSeq(); mo1->ss->push_back("test"); mo1->ss->push_back("test2"); @@ -1344,13 +1344,13 @@ allTests(Test::TestHelper* helper, bool) cout << "testing optional parameters and custom sequences... " << flush; { - optional> p1; + optional> p1; optional p3; optional p2 = initial->opByteSeq(p1, p3); test(!p2 && !p3); - vector bs(100); - fill(bs.begin(), bs.end(), 56); + vector bs(100); + fill(bs.begin(), bs.end(), byte{56}); p1 = toArrayRange(bs); p2 = initial->opByteSeq(p1, p3); test(p2 && p3); diff --git a/cpp/test/Ice/optional/TestAMDI.cpp b/cpp/test/Ice/optional/TestAMDI.cpp index 3ede6c4e2f2..92a60f8bc35 100644 --- a/cpp/test/Ice/optional/TestAMDI.cpp +++ b/cpp/test/Ice/optional/TestAMDI.cpp @@ -226,10 +226,9 @@ InitialI::opMyInterfaceProxyAsync( void InitialI::opByteSeqAsync( - optional> p1, - function>&, - const optional>&)> response, + optional> p1, + function>&, const optional>&)> + response, function, const Ice::Current&) { diff --git a/cpp/test/Ice/optional/TestAMDI.h b/cpp/test/Ice/optional/TestAMDI.h index 89d74e68bf1..e9847ac1933 100644 --- a/cpp/test/Ice/optional/TestAMDI.h +++ b/cpp/test/Ice/optional/TestAMDI.h @@ -131,10 +131,10 @@ class InitialI final : public Test::Initial const Ice::Current&) final; void opByteSeqAsync( - std::optional>, + std::optional>, std::function>&, - const std::optional>&)>, + const std::optional>&, + const std::optional>&)>, std::function, const Ice::Current&) final; diff --git a/cpp/test/Ice/optional/TestI.cpp b/cpp/test/Ice/optional/TestI.cpp index 33d43910d2a..c11800aaad5 100644 --- a/cpp/test/Ice/optional/TestI.cpp +++ b/cpp/test/Ice/optional/TestI.cpp @@ -171,7 +171,7 @@ InitialI::opMyInterfaceProxy(optional p1, optional -InitialI::opByteSeq(optional> p1, optional& p3, const Current&) +InitialI::opByteSeq(optional> p1, optional& p3, const Current&) { if (p1) { diff --git a/cpp/test/Ice/optional/TestI.h b/cpp/test/Ice/optional/TestI.h index fe1af2854e3..dc37378adee 100644 --- a/cpp/test/Ice/optional/TestI.h +++ b/cpp/test/Ice/optional/TestI.h @@ -75,7 +75,7 @@ class InitialI : public Test::Initial const ::Ice::Current&); virtual std::optional<::Test::ByteSeq> opByteSeq( - std::optional<::std::pair>, + std::optional<::std::pair>, std::optional<::Test::ByteSeq>&, const ::Ice::Current&); diff --git a/cpp/test/Ice/proxy/AllTests.cpp b/cpp/test/Ice/proxy/AllTests.cpp index 71f744142b4..fc55b137454 100644 --- a/cpp/test/Ice/proxy/AllTests.cpp +++ b/cpp/test/Ice/proxy/AllTests.cpp @@ -1035,11 +1035,11 @@ allTests(TestHelper* helper) Ice::OutputStream out(communicator); out.startEncapsulation(); out.endEncapsulation(); - vector inEncaps; + vector inEncaps; out.finished(inEncaps); - inEncaps[4] = version.major; - inEncaps[5] = version.minor; - vector outEncaps; + inEncaps[4] = byte{version.major}; + inEncaps[5] = byte{version.minor}; + vector outEncaps; cl->ice_invoke("ice_ping", Ice::OperationMode::Normal, inEncaps, outEncaps); test(false); } @@ -1056,11 +1056,11 @@ allTests(TestHelper* helper) Ice::OutputStream out(communicator); out.startEncapsulation(); out.endEncapsulation(); - vector inEncaps; + vector inEncaps; out.finished(inEncaps); - inEncaps[4] = version.major; - inEncaps[5] = version.minor; - vector outEncaps; + inEncaps[4] = byte{version.major}; + inEncaps[5] = byte{version.minor}; + vector outEncaps; cl->ice_invoke("ice_ping", Ice::OperationMode::Normal, inEncaps, outEncaps); test(false); } diff --git a/cpp/test/Ice/stream/Client.cpp b/cpp/test/Ice/stream/Client.cpp index 35e7a2b4c3a..e9eafd2b1af 100644 --- a/cpp/test/Ice/stream/Client.cpp +++ b/cpp/test/Ice/stream/Client.cpp @@ -109,7 +109,7 @@ allTests(Test::TestHelper* helper) std::bind(&MyClassFactoryWrapper::create, &factoryWrapper, std::placeholders::_1); communicator->getValueFactoryManager()->add(f, MyClass::ice_staticId()); - vector data; + vector data; // // Test the stream API. @@ -117,7 +117,7 @@ allTests(Test::TestHelper* helper) cout << "testing primitive types... " << flush; { - vector byte; + vector byte; Ice::InputStream in(communicator, byte); } @@ -127,9 +127,9 @@ allTests(Test::TestHelper* helper) out.write(true); out.endEncapsulation(); out.finished(data); - pair d = out.finished(); + pair d = out.finished(); test(d.second - d.first == static_cast(data.size())); - test(vector(d.first, d.second) == data); + test(vector(d.first, d.second) == data); Ice::InputStream in(communicator, data); in.startEncapsulation(); @@ -140,7 +140,7 @@ allTests(Test::TestHelper* helper) } { - vector byte; + vector byte; Ice::InputStream in(communicator, byte); try { @@ -352,10 +352,10 @@ allTests(Test::TestHelper* helper) { Ice::ByteSeq arr; - arr.push_back(0x01); - arr.push_back(0x11); - arr.push_back(0x12); - arr.push_back(0x22); + arr.push_back(byte{0x01}); + arr.push_back(byte{0x11}); + arr.push_back(byte{0x12}); + arr.push_back(byte{0x22}); Ice::OutputStream out(communicator); out.write(arr); @@ -646,10 +646,10 @@ allTests(Test::TestHelper* helper) c->seq1.push_back(true); c->seq1.push_back(false); - c->seq2.push_back(1); - c->seq2.push_back(2); - c->seq2.push_back(3); - c->seq2.push_back(4); + c->seq2.push_back(byte{1}); + c->seq2.push_back(byte{2}); + c->seq2.push_back(byte{3}); + c->seq2.push_back(byte{4}); c->seq3.push_back(1); c->seq3.push_back(2); @@ -826,10 +826,10 @@ allTests(Test::TestHelper* helper) c->seq1.push_back(true); c->seq1.push_back(false); - c->seq2.push_back(1); - c->seq2.push_back(2); - c->seq2.push_back(3); - c->seq2.push_back(4); + c->seq2.push_back(byte{1}); + c->seq2.push_back(byte{2}); + c->seq2.push_back(byte{3}); + c->seq2.push_back(byte{4}); c->seq3.push_back(1); c->seq3.push_back(2); @@ -1072,30 +1072,30 @@ allTests(Test::TestHelper* helper) // Test marshaling to user-supplied buffer. // { - uint8_t buf[128]; - pair p(&buf[0], &buf[0] + sizeof(buf)); + byte buf[128]; + pair p(&buf[0], &buf[0] + sizeof(buf)); Ice::OutputStream out(communicator, Ice::currentEncoding, p); - vector v; + vector v; v.resize(127); out.write(v); test(out.pos() == 128); // 127 bytes + leading size (1 byte) test(out.b.begin() == buf); // Verify the stream hasn't reallocated. } { - uint8_t buf[128]; - pair p(&buf[0], &buf[0] + sizeof(buf)); + byte buf[128]; + pair p(&buf[0], &buf[0] + sizeof(buf)); Ice::OutputStream out(communicator, Ice::currentEncoding, p); - vector v; + vector v; v.resize(127); ::memset(&v[0], 0xFF, v.size()); out.write(v); - out.write(uint8_t(0xFF)); // This extra byte should make the stream reallocate. + out.write(byte(0xFF)); // This extra byte should make the stream reallocate. test(out.pos() == 129); // 127 bytes + leading size (1 byte) + 1 byte test(out.b.begin() != buf); // Verify the stream was reallocated. out.finished(data); Ice::InputStream in(communicator, data); - vector v2; + vector v2; in.read(v2); test(v2.size() == 127); test(v == v2); // Make sure the original buffer was preserved. diff --git a/matlab/src/Endpoint.cpp b/matlab/src/Endpoint.cpp index 336ef15f294..5362c13e830 100644 --- a/matlab/src/Endpoint.cpp +++ b/matlab/src/Endpoint.cpp @@ -89,13 +89,7 @@ namespace { mxSetFieldByNumber(r, 0, Field::RawEncoding, createEncodingVersion(opaqueInfo->rawEncoding)); byte* p = &opaqueInfo->rawBytes[0]; - mxSetFieldByNumber( - r, - 0, - Field::RawBytes, - createByteArray( - reinterpret_cast(p), - reinterpret_cast(p) + opaqueInfo->rawBytes.size())); + mxSetFieldByNumber(r, 0, Field::RawBytes, createByteArray(p, p + opaqueInfo->rawBytes.size())); } auto udpInfo = dynamic_pointer_cast(info); diff --git a/matlab/src/ObjectPrx.cpp b/matlab/src/ObjectPrx.cpp index 5f61a2f03db..b8193c37312 100644 --- a/matlab/src/ObjectPrx.cpp +++ b/matlab/src/ObjectPrx.cpp @@ -24,8 +24,8 @@ namespace const std::shared_ptr&, const Ice::EncodingVersion&, bool, - std::pair); - void getResults(bool&, pair&); + std::pair); + void getResults(bool&, pair&); protected: virtual State stateImpl() const; @@ -34,7 +34,7 @@ namespace const bool _twoway; State _state; bool _ok; // True for success, false for user exception. - vector _data; + vector _data; }; InvocationFuture::InvocationFuture(bool twoway, bool batch) @@ -66,7 +66,7 @@ namespace const std::shared_ptr& /*communicator*/, const Ice::EncodingVersion& /*encoding*/, bool b, - pair p) + pair p) { lock_guard lock(_mutex); _ok = b; @@ -74,13 +74,13 @@ namespace _token = nullptr; if (p.second > p.first) { - vector data(p.first, p.second); // Makes a copy. - _data.swap(data); // Avoids another copy. + vector data(p.first, p.second); // Makes a copy. + _data.swap(data); // Avoids another copy. } _cond.notify_all(); } - void InvocationFuture::getResults(bool& ok, pair& p) + void InvocationFuture::getResults(bool& ok, pair& p) { lock_guard lock(_mutex); assert(_twoway); @@ -174,8 +174,8 @@ extern "C" { assert(!mxIsEmpty(buf)); - pair p; - p.first = reinterpret_cast(mxGetData(buf)) + start; + pair p; + p.first = reinterpret_cast(mxGetData(buf)) + start; p.second = p.first + size; try @@ -212,7 +212,7 @@ extern "C" Ice::OutputStream out(comm, enc); out.write(prx); - pair p = out.finished(); + pair p = out.finished(); assert(p.second > p.first); return createResultValue(createByteArray(p.first, p.second)); @@ -226,14 +226,14 @@ extern "C" mxArray* Ice_ObjectPrx_ice_invoke(void* self, const char* op, int m, mxArray* inParams, unsigned int size, mxArray* context) { - pair params(0, 0); + pair params(0, 0); if (!mxIsEmpty(inParams)) { - params.first = reinterpret_cast(mxGetData(inParams)); + params.first = reinterpret_cast(mxGetData(inParams)); params.second = params.first + size; } auto mode = static_cast(m); - vector v; + vector v; try { @@ -256,14 +256,14 @@ extern "C" mxArray* Ice_ObjectPrx_ice_invokeNC(void* self, const char* op, int m, mxArray* inParams, unsigned int size) { - pair params(0, 0); + pair params(0, 0); if (!mxIsEmpty(inParams)) { - params.first = reinterpret_cast(mxGetData(inParams)); + params.first = reinterpret_cast(mxGetData(inParams)); params.second = params.first + size; } auto mode = static_cast(m); - vector v; + vector v; try { @@ -292,10 +292,10 @@ extern "C" void** future) { const auto proxy = restoreProxy(self); - pair params(0, 0); + pair params(0, 0); if (!mxIsEmpty(inParams)) { - params.first = reinterpret_cast(mxGetData(inParams)); + params.first = reinterpret_cast(mxGetData(inParams)); params.second = params.first + size; } auto mode = static_cast(m); @@ -313,7 +313,7 @@ extern "C" op, mode, params, - [proxy, f](bool ok, pair outParams) + [proxy, f](bool ok, pair outParams) { f->finished(proxy->ice_getCommunicator(), proxy->ice_getEncodingVersion(), ok, outParams); }, [f](exception_ptr e) { f->exception(e); }, [f](bool /*sentSynchronously*/) { f->sent(); }, @@ -337,10 +337,10 @@ extern "C" void** future) { const auto proxy = restoreProxy(self); - pair params(0, 0); + pair params(0, 0); if (!mxIsEmpty(inParams)) { - params.first = reinterpret_cast(mxGetData(inParams)); + params.first = reinterpret_cast(mxGetData(inParams)); params.second = params.first + size; } auto mode = static_cast(m); @@ -356,7 +356,7 @@ extern "C" op, mode, params, - [proxy, f](bool ok, pair outParams) + [proxy, f](bool ok, pair outParams) { f->finished(proxy->ice_getCommunicator(), proxy->ice_getEncodingVersion(), ok, outParams); }, [f](exception_ptr e) { f->exception(e); }, [f](bool /*sentSynchronously*/) { f->sent(); }); @@ -1082,7 +1082,7 @@ extern "C" } bool ok; - pair p; + pair p; f->getResults(ok, p); mxArray* params = 0; if (p.second > p.first) diff --git a/matlab/src/Util.cpp b/matlab/src/Util.cpp index d75221f43f5..0ee65bc2c5f 100644 --- a/matlab/src/Util.cpp +++ b/matlab/src/Util.cpp @@ -583,7 +583,7 @@ IceMatlab::getStringList(mxArray* m, vector& v) } mxArray* -IceMatlab::createByteArray(const uint8_t* begin, const uint8_t* end) +IceMatlab::createByteArray(const byte* begin, const byte* end) { mxArray* r = mxCreateUninitNumericMatrix(1, end - begin, mxUINT8_CLASS, mxREAL); memcpy(reinterpret_cast(mxGetData(r)), begin, end - begin); @@ -591,13 +591,13 @@ IceMatlab::createByteArray(const uint8_t* begin, const uint8_t* end) } mxArray* -IceMatlab::createByteList(const vector& bytes) +IceMatlab::createByteList(const vector& bytes) { auto r = mxCreateCellMatrix(1, static_cast(bytes.size())); mwIndex i = 0; for (auto byte : bytes) { - mxSetCell(r, i++, createByte(byte)); + mxSetCell(r, i++, createByte(static_cast(byte))); } return r; } diff --git a/matlab/src/Util.h b/matlab/src/Util.h index fbfbf710900..4cc68a4c291 100644 --- a/matlab/src/Util.h +++ b/matlab/src/Util.h @@ -40,8 +40,8 @@ namespace IceMatlab mxArray* createOptionalValue(bool, mxArray*); mxArray* createStringList(const std::vector&); void getStringList(mxArray*, std::vector&); - mxArray* createByteArray(const std::uint8_t*, const std::uint8_t*); - mxArray* createByteList(const std::vector&); + mxArray* createByteArray(const std::byte*, const std::byte*); + mxArray* createByteList(const std::vector&); mxArray* createCertificateList(const std::vector&); std::string idToClass(const std::string&); diff --git a/php/src/Operation.cpp b/php/src/Operation.cpp index 995e1d627af..22bed3af4ac 100644 --- a/php/src/Operation.cpp +++ b/php/src/Operation.cpp @@ -106,9 +106,9 @@ namespace IcePHP protected: OperationIPtr _op; - bool prepareRequest(int, zval*, Ice::OutputStream*, pair&); - void unmarshalResults(int, zval*, zval*, const pair&); - void unmarshalException(zval*, const pair&); + bool prepareRequest(int, zval*, Ice::OutputStream*, pair&); + void unmarshalResults(int, zval*, zval*, const pair&); + void unmarshalException(zval*, const pair&); bool validateException(const ExceptionInfoPtr&) const; void checkTwowayOnly(const Ice::ObjectPrx&) const; }; @@ -355,7 +355,7 @@ IcePHP::TypedInvocation::prepareRequest( int argc, zval* args, Ice::OutputStream* os, - pair& params) + pair& params) { // Verify that the expected number of arguments are supplied. The context argument is optional. if (argc != _op->numParams && argc != _op->numParams + 1) @@ -445,11 +445,7 @@ IcePHP::TypedInvocation::prepareRequest( } void -IcePHP::TypedInvocation::unmarshalResults( - int argc, - zval* args, - zval* ret, - const pair& bytes) +IcePHP::TypedInvocation::unmarshalResults(int argc, zval* args, zval* ret, const pair& bytes) { Ice::InputStream is(_communicator->getCommunicator(), bytes); @@ -533,7 +529,7 @@ IcePHP::TypedInvocation::unmarshalResults( } void -IcePHP::TypedInvocation::unmarshalException(zval* zex, const pair& bytes) +IcePHP::TypedInvocation::unmarshalException(zval* zex, const pair& bytes) { Ice::InputStream is(_communicator->getCommunicator(), bytes); @@ -627,7 +623,7 @@ IcePHP::SyncTypedInvocation::invoke(INTERNAL_FUNCTION_PARAMETERS) } Ice::OutputStream os(_prx->ice_getCommunicator()); - pair params; + pair params; if (!prepareRequest(ZEND_NUM_ARGS(), args, &os, params)) { return; @@ -649,7 +645,7 @@ IcePHP::SyncTypedInvocation::invoke(INTERNAL_FUNCTION_PARAMETERS) checkTwowayOnly(_prx); // Invoke the operation. - vector result; + vector result; bool status; { if (hasCtx) @@ -668,7 +664,7 @@ IcePHP::SyncTypedInvocation::invoke(INTERNAL_FUNCTION_PARAMETERS) if (!status) { // Unmarshal a user exception. - pair rb(0, 0); + pair rb(0, 0); if (!result.empty()) { rb.first = &result[0]; @@ -686,7 +682,7 @@ IcePHP::SyncTypedInvocation::invoke(INTERNAL_FUNCTION_PARAMETERS) else if (!_op->outParams.empty() || _op->returnType) { // Unmarshal the results. - pair rb(0, 0); + pair rb(0, 0); if (!result.empty()) { rb.first = &result[0]; diff --git a/php/src/Types.cpp b/php/src/Types.cpp index 892071d1bf0..423faf52a33 100644 --- a/php/src/Types.cpp +++ b/php/src/Types.cpp @@ -302,7 +302,7 @@ IcePHP::StreamUtil::setSlicedDataMember(zval* obj, const Ice::SlicedDataPtr& sli AutoDestroy bytesDestroyer(&bytes); for (const auto& q : p->bytes) { - add_next_index_long(&bytes, q & 0xff); + add_next_index_long(&bytes, std::to_integer(q & byte{0xff})); } addPropertyZval(&slice, "bytes", &bytes); @@ -396,12 +396,12 @@ IcePHP::StreamUtil::getSlicedDataMember(zval* obj, ObjectMap* objectMap) # pragma clang diagnostic push # pragma clang diagnostic ignored "-Wshadow" #endif - vector::size_type i = 0; + vector::size_type i = 0; ZEND_HASH_FOREACH_VAL(barr, e) { long l = static_cast(Z_LVAL_P(e)); assert(l >= 0 && l <= 255); - info->bytes[i++] = static_cast(l); + info->bytes[i++] = static_cast(l); } ZEND_HASH_FOREACH_END(); #if defined(__clang__) @@ -1615,7 +1615,7 @@ IcePHP::SequenceInfo::marshalPrimitiveSequence(const PrimitiveInfoPtr& pi, zval* } long l = static_cast(Z_LVAL_P(val)); assert(l >= 0 && l <= 255); - seq[i++] = static_cast(l); + seq[i++] = static_cast(l); } ZEND_HASH_FOREACH_END(); diff --git a/python/modules/IcePy/Operation.cpp b/python/modules/IcePy/Operation.cpp index bd82057b517..5e123575486 100644 --- a/python/modules/IcePy/Operation.cpp +++ b/python/modules/IcePy/Operation.cpp @@ -112,9 +112,9 @@ namespace IcePy PyObject*, MappingType, Ice::OutputStream*, - pair&); - PyObject* unmarshalResults(const OperationPtr&, const pair&); - PyObject* unmarshalException(const OperationPtr&, const pair&); + pair&); + PyObject* unmarshalResults(const OperationPtr&, const pair&); + PyObject* unmarshalException(const OperationPtr&, const pair&); bool validateException(const OperationPtr&, PyObject*) const; void checkTwowayOnly(const OperationPtr&, const Ice::ObjectPrx&) const; @@ -142,13 +142,13 @@ namespace IcePy PyObject* invoke(PyObject*, PyObject* = 0) final; - void response(bool, const pair&); + void response(bool, const pair&); void exception(const Ice::Exception&); void sent(bool); protected: virtual function handleInvoke(PyObject*, PyObject*) = 0; - virtual void handleResponse(PyObject*, bool, const pair&) = 0; + virtual void handleResponse(PyObject*, bool, const pair&) = 0; PyObject* _pyProxy; string _operation; @@ -158,7 +158,7 @@ namespace IcePy bool _done; PyObject* _future; bool _ok; - vector _results; + vector _results; PyObject* _exception; }; using AsyncInvocationPtr = shared_ptr; @@ -170,7 +170,7 @@ namespace IcePy protected: function handleInvoke(PyObject*, PyObject*) final; - void handleResponse(PyObject*, bool, const pair&) final; + void handleResponse(PyObject*, bool, const pair&) final; private: OperationPtr _op; @@ -192,7 +192,7 @@ namespace IcePy protected: function handleInvoke(PyObject*, PyObject*) final; - void handleResponse(PyObject*, bool, const pair&) final; + void handleResponse(PyObject*, bool, const pair&) final; string _op; }; @@ -201,7 +201,7 @@ namespace IcePy class Upcall : public enable_shared_from_this { public: - virtual void dispatch(PyObject*, const pair&, const Ice::Current&) = 0; + virtual void dispatch(PyObject*, const pair&, const Ice::Current&) = 0; virtual void response(PyObject*) = 0; virtual void exception(PyException&) = 0; @@ -217,18 +217,18 @@ namespace IcePy public: TypedUpcall( const OperationPtr&, - function&)>, + function&)>, function, const Ice::CommunicatorPtr&); - void dispatch(PyObject*, const pair&, const Ice::Current&) final; + void dispatch(PyObject*, const pair&, const Ice::Current&) final; void response(PyObject*) final; void exception(PyException&) final; private: OperationPtr _op; - function&)> _response; + function&)> _response; function _error; Ice::CommunicatorPtr _communicator; @@ -243,15 +243,15 @@ namespace IcePy { public: BlobjectUpcall( - function&)>, + function&)>, function); - void dispatch(PyObject*, const pair&, const Ice::Current&) final; + void dispatch(PyObject*, const pair&, const Ice::Current&) final; void response(PyObject*) final; void exception(PyException&) final; private: - function&)> _response; + function&)> _response; function _error; }; @@ -263,8 +263,8 @@ namespace IcePy TypedServantWrapper(PyObject*); void ice_invokeAsync( - pair inEncaps, - function&)> response, + pair inEncaps, + function&)> response, function error, const Ice::Current& current) final; @@ -281,8 +281,8 @@ namespace IcePy BlobjectServantWrapper(PyObject*); void ice_invokeAsync( - pair inEncaps, - function&)> response, + pair inEncaps, + function&)> response, function error, const Ice::Current& current) final; }; @@ -1363,10 +1363,10 @@ IcePy::Invocation::prepareRequest( PyObject* args, MappingType mapping, Ice::OutputStream* os, - pair& params) + pair& params) { assert(PyTuple_Check(args)); - params.first = params.second = static_cast(0); + params.first = params.second = static_cast(0); // // Validate the number of arguments. @@ -1479,7 +1479,7 @@ IcePy::Invocation::prepareRequest( } PyObject* -IcePy::Invocation::unmarshalResults(const OperationPtr& op, const pair& bytes) +IcePy::Invocation::unmarshalResults(const OperationPtr& op, const pair& bytes) { Py_ssize_t numResults = static_cast(op->outParams.size()); if (op->returnType) @@ -1558,7 +1558,7 @@ IcePy::Invocation::unmarshalResults(const OperationPtr& op, const pair& bytes) +IcePy::Invocation::unmarshalException(const OperationPtr& op, const pair& bytes) { Ice::InputStream is(_communicator, bytes); @@ -1665,7 +1665,7 @@ IcePy::SyncTypedInvocation::invoke(PyObject* args, PyObject* /* kwds */) // Marshal the input parameters to a byte sequence. // Ice::OutputStream os(_communicator); - pair params; + pair params; if (!prepareRequest(_op, pyparams, SyncMapping, &os, params)) { return 0; @@ -1678,7 +1678,7 @@ IcePy::SyncTypedInvocation::invoke(PyObject* args, PyObject* /* kwds */) // // Invoke the operation. // - vector result; + vector result; bool status; Ice::Context ctx; if (pyctx != Py_None) @@ -1710,7 +1710,7 @@ IcePy::SyncTypedInvocation::invoke(PyObject* args, PyObject* /* kwds */) // if (_prx->ice_isTwoway()) { - pair rb{0, 0}; + pair rb{0, 0}; if (!result.empty()) { rb.first = &result[0]; @@ -1898,7 +1898,7 @@ IcePy::AsyncInvocation::invoke(PyObject* args, PyObject* kwds) // // Delegate to the subclass. // - pair p(&_results[0], &_results[0] + _results.size()); + pair p(&_results[0], &_results[0] + _results.size()); handleResponse(future.get(), _ok, p); if (PyErr_Occurred()) { @@ -1921,7 +1921,7 @@ IcePy::AsyncInvocation::invoke(PyObject* args, PyObject* kwds) } void -IcePy::AsyncInvocation::response(bool ok, const pair& results) +IcePy::AsyncInvocation::response(bool ok, const pair& results) { AdoptThread adoptThread; // Ensure the current thread is able to call into Python. @@ -1931,7 +1931,7 @@ IcePy::AsyncInvocation::response(bool ok, const pair v(results.first, results.second); + vector v(results.first, results.second); _results.swap(v); _done = true; return; @@ -2063,7 +2063,7 @@ IcePy::AsyncTypedInvocation::handleInvoke(PyObject* args, PyObject* /* kwds */) // Marshal the input parameters to a byte sequence. Ice::OutputStream os(_communicator); - pair params; + pair params; if (!prepareRequest(_op, pyparams, AsyncMapping, &os, params)) { return 0; @@ -2092,7 +2092,7 @@ IcePy::AsyncTypedInvocation::handleInvoke(PyObject* args, PyObject* /* kwds */) _op->name, _op->sendMode, params, - [self](bool ok, const pair& results) { self->response(ok, results); }, + [self](bool ok, const pair& results) { self->response(ok, results); }, [self](exception_ptr exptr) { try @@ -2109,10 +2109,7 @@ IcePy::AsyncTypedInvocation::handleInvoke(PyObject* args, PyObject* /* kwds */) } void -IcePy::AsyncTypedInvocation::handleResponse( - PyObject* future, - bool ok, - const pair& results) +IcePy::AsyncTypedInvocation::handleResponse(PyObject* future, bool ok, const pair& results) { try { @@ -2202,16 +2199,16 @@ IcePy::SyncBlobjectInvocation::invoke(PyObject* args, PyObject* /* kwds */) assert(!PyErr_Occurred()); Py_ssize_t sz = PyBytes_GET_SIZE(inParams); - pair in(static_cast(0), static_cast(0)); + pair in(static_cast(0), static_cast(0)); if (sz > 0) { - in.first = reinterpret_cast(PyBytes_AS_STRING(inParams)); + in.first = reinterpret_cast(PyBytes_AS_STRING(inParams)); in.second = in.first + sz; } try { - vector out; + vector out; bool ok; Ice::Context context; @@ -2302,10 +2299,10 @@ IcePy::AsyncBlobjectInvocation::handleInvoke(PyObject* args, PyObject* /* kwds * assert(!PyErr_Occurred()); Py_ssize_t sz = PyBytes_GET_SIZE(inParams); - pair params{0, 0}; + pair params{0, 0}; if (sz > 0) { - params.first = reinterpret_cast(PyBytes_AS_STRING(inParams)); + params.first = reinterpret_cast(PyBytes_AS_STRING(inParams)); params.second = params.first + sz; } @@ -2323,7 +2320,7 @@ IcePy::AsyncBlobjectInvocation::handleInvoke(PyObject* args, PyObject* /* kwds * operation, sendMode, params, - [self](bool ok, const pair& results) { self->response(ok, results); }, + [self](bool ok, const pair& results) { self->response(ok, results); }, [self](exception_ptr exptr) { try @@ -2340,10 +2337,7 @@ IcePy::AsyncBlobjectInvocation::handleInvoke(PyObject* args, PyObject* /* kwds * } void -IcePy::AsyncBlobjectInvocation::handleResponse( - PyObject* future, - bool ok, - const pair& results) +IcePy::AsyncBlobjectInvocation::handleResponse(PyObject* future, bool ok, const pair& results) { // Prepare the args as a tuple of the bool and out param buffer. PyObjectHandle args = PyTuple_New(2); @@ -2453,7 +2447,7 @@ Upcall::dispatchImpl(PyObject* servant, const string& dispatchName, PyObject* ar // IcePy::TypedUpcall::TypedUpcall( const OperationPtr& op, - function&)> response, + function&)> response, function error, const Ice::CommunicatorPtr& communicator) : _op(op), @@ -2466,7 +2460,7 @@ IcePy::TypedUpcall::TypedUpcall( void IcePy::TypedUpcall::dispatch( PyObject* servant, - const pair& inBytes, + const pair& inBytes, const Ice::Current& current) { _encoding = current.encoding; @@ -2652,7 +2646,7 @@ IcePy::TypedUpcall::exception(PyException& ex) // BlobjectUpcall // IcePy::BlobjectUpcall::BlobjectUpcall( - function&)> response, + function&)> response, function error) : _response(std::move(response)), _error(std::move(error)) @@ -2662,7 +2656,7 @@ IcePy::BlobjectUpcall::BlobjectUpcall( void IcePy::BlobjectUpcall::dispatch( PyObject* servant, - const pair& inBytes, + const pair& inBytes, const Ice::Current& current) { Ice::CommunicatorPtr communicator = current.adapter->getCommunicator(); @@ -2725,10 +2719,10 @@ IcePy::BlobjectUpcall::response(PyObject* result) } Py_ssize_t sz = PyBytes_GET_SIZE(arg); - pair r{0, 0}; + pair r{0, 0}; if (sz > 0) { - r.first = reinterpret_cast(PyBytes_AS_STRING(arg)); + r.first = reinterpret_cast(PyBytes_AS_STRING(arg)); r.second = r.first + sz; } @@ -3053,8 +3047,8 @@ IcePy::TypedServantWrapper::TypedServantWrapper(PyObject* servant) void IcePy::TypedServantWrapper::ice_invokeAsync( - pair inParams, - function&)> response, + pair inParams, + function&)> response, function error, const Ice::Current& current) { @@ -3130,8 +3124,8 @@ IcePy::BlobjectServantWrapper::BlobjectServantWrapper(PyObject* servant) : Serva void IcePy::BlobjectServantWrapper::ice_invokeAsync( - pair inParams, - function&)> response, + pair inParams, + function&)> response, function error, const Ice::Current& current) { diff --git a/python/modules/IcePy/Types.cpp b/python/modules/IcePy/Types.cpp index 8ffabb0b638..0dc6d18015a 100644 --- a/python/modules/IcePy/Types.cpp +++ b/python/modules/IcePy/Types.cpp @@ -525,7 +525,7 @@ IcePy::StreamUtil::getSlicedDataMember(PyObject* obj, ObjectMap* objectMap) Py_ssize_t strsz; assert(PyBytes_Check(bytes.get())); PyBytes_AsStringAndSize(bytes.get(), &str, &strsz); - vector vtmp(reinterpret_cast(str), reinterpret_cast(str + strsz)); + vector vtmp(reinterpret_cast(str), reinterpret_cast(str + strsz)); info->bytes.swap(vtmp); PyObjectHandle instances = getAttr(s.get(), "instances", false); @@ -1913,7 +1913,7 @@ IcePy::SequenceInfo::marshalPrimitiveSequence(const PrimitiveInfoPtr& pi, PyObje assert(PyBytes_Check(p)); char* str; PyBytes_AsStringAndSize(p, &str, &sz); - os->write(reinterpret_cast(str), reinterpret_cast(str + sz)); + os->write(reinterpret_cast(str), reinterpret_cast(str + sz)); } else { @@ -1938,7 +1938,7 @@ IcePy::SequenceInfo::marshalPrimitiveSequence(const PrimitiveInfoPtr& pi, PyObje static_cast(i)); throw AbortMarshaling(); } - seq[static_cast(i)] = static_cast(val); + seq[static_cast(i)] = static_cast(val); } os->write(seq); } diff --git a/python/modules/IcePy/Util.cpp b/python/modules/IcePy/Util.cpp index b1ae9808fe7..0e5c0550804 100644 --- a/python/modules/IcePy/Util.cpp +++ b/python/modules/IcePy/Util.cpp @@ -508,7 +508,7 @@ IcePy::byteSeqToList(const Ice::ByteSeq& seq) for (Ice::ByteSeq::const_iterator p = seq.begin(); p != seq.end(); ++p) { - PyObject* byte = PyLong_FromLong(*p); + PyObject* byte = PyLong_FromLong(std::to_integer(*p)); if (!byte) { Py_DECREF(l); diff --git a/ruby/src/IceRuby/Operation.cpp b/ruby/src/IceRuby/Operation.cpp index cd5a55601e4..442200f42c5 100644 --- a/ruby/src/IceRuby/Operation.cpp +++ b/ruby/src/IceRuby/Operation.cpp @@ -65,9 +65,9 @@ namespace IceRuby void convertParams(VALUE, ParamInfoList&, long, bool&); ParamInfoPtr convertParam(VALUE, long); - void prepareRequest(const Ice::ObjectPrx&, VALUE, Ice::OutputStream*, pair&); - VALUE unmarshalResults(const vector&, const Ice::CommunicatorPtr&); - VALUE unmarshalException(const vector&, const Ice::CommunicatorPtr&); + void prepareRequest(const Ice::ObjectPrx&, VALUE, Ice::OutputStream*, pair&); + VALUE unmarshalResults(const vector&, const Ice::CommunicatorPtr&); + VALUE unmarshalException(const vector&, const Ice::CommunicatorPtr&); bool validateException(VALUE) const; void checkTwowayOnly(const Ice::ObjectPrx&) const; }; @@ -275,7 +275,7 @@ IceRuby::OperationI::invoke(const Ice::ObjectPrx& proxy, VALUE args, VALUE hctx) // Marshal the input parameters to a byte sequence. // Ice::OutputStream os(communicator); - pair params; + pair params; prepareRequest(proxy, args, &os, params); if (!_deprecateMessage.empty()) @@ -388,9 +388,9 @@ IceRuby::OperationI::prepareRequest( const Ice::ObjectPrx& proxy, VALUE args, Ice::OutputStream* os, - pair& params) + pair& params) { - params.first = params.second = static_cast(0); + params.first = params.second = static_cast(0); // // Validate the number of arguments. @@ -468,7 +468,7 @@ IceRuby::OperationI::prepareRequest( } VALUE -IceRuby::OperationI::unmarshalResults(const vector& bytes, const Ice::CommunicatorPtr& communicator) +IceRuby::OperationI::unmarshalResults(const vector& bytes, const Ice::CommunicatorPtr& communicator) { int numResults = static_cast(_outParams.size()); if (_returnType) @@ -550,7 +550,7 @@ IceRuby::OperationI::unmarshalResults(const vector& bytes, const Ice::C } VALUE -IceRuby::OperationI::unmarshalException(const vector& bytes, const Ice::CommunicatorPtr& communicator) +IceRuby::OperationI::unmarshalException(const vector& bytes, const Ice::CommunicatorPtr& communicator) { Ice::InputStream is(communicator, bytes); diff --git a/ruby/src/IceRuby/Types.cpp b/ruby/src/IceRuby/Types.cpp index 3efa1f8c056..d437eeb9a2b 100644 --- a/ruby/src/IceRuby/Types.cpp +++ b/ruby/src/IceRuby/Types.cpp @@ -353,9 +353,7 @@ IceRuby::StreamUtil::getSlicedDataMember(VALUE obj, ValueMap* valueMap) const long len = RSTRING_LEN(bytes); if (str != 0 && len != 0) { - vector vtmp( - reinterpret_cast(str), - reinterpret_cast(str + len)); + vector vtmp(reinterpret_cast(str), reinterpret_cast(str + len)); info->bytes.swap(vtmp); } @@ -1413,7 +1411,7 @@ IceRuby::SequenceInfo::marshalPrimitiveSequence(const PrimitiveInfoPtr& pi, VALU } else { - os->write(reinterpret_cast(s), reinterpret_cast(s + len)); + os->write(reinterpret_cast(s), reinterpret_cast(s + len)); } } else @@ -1427,7 +1425,7 @@ IceRuby::SequenceInfo::marshalPrimitiveSequence(const PrimitiveInfoPtr& pi, VALU { throw RubyException(rb_eTypeError, "invalid value for element %ld of sequence", i); } - seq[static_cast(i)] = static_cast(val); + seq[static_cast(i)] = static_cast(val); } os->write(seq); } diff --git a/ruby/src/IceRuby/Util.cpp b/ruby/src/IceRuby/Util.cpp index 78b6ec7c82f..1df1f11ac9f 100644 --- a/ruby/src/IceRuby/Util.cpp +++ b/ruby/src/IceRuby/Util.cpp @@ -336,15 +336,15 @@ IceRuby::stringSeqToArray(const vector& seq) } VALUE -IceRuby::createNumSeq(const vector& v) +IceRuby::createNumSeq(const vector& v) { volatile VALUE result = createArray(v.size()); long i = 0; if (v.size() > 0) { - for (vector::const_iterator p = v.begin(); p != v.end(); ++p, ++i) + for (vector::const_iterator p = v.begin(); p != v.end(); ++p, ++i) { - RARRAY_ASET(result, i, INT2FIX(*p)); + RARRAY_ASET(result, i, INT2FIX(std::to_integer(*p))); } } return result; diff --git a/ruby/src/IceRuby/Util.h b/ruby/src/IceRuby/Util.h index 2d74238eca1..74aa02204fb 100644 --- a/ruby/src/IceRuby/Util.h +++ b/ruby/src/IceRuby/Util.h @@ -92,10 +92,10 @@ namespace IceRuby VALUE stringSeqToArray(const std::vector&); // - // Convert a vector of std::uint8_t into a Ruby array of numbers. + // Convert a vector of std::byte into a Ruby array of numbers. // May raise RubyException. // - VALUE createNumSeq(const std::vector&); + VALUE createNumSeq(const std::vector&); // // Convert a Ruby hash to Ice::Context. Returns true on success diff --git a/swift/src/IceImpl/BlobjectFacade.h b/swift/src/IceImpl/BlobjectFacade.h index 72287793f0c..a4a98a031f6 100644 --- a/swift/src/IceImpl/BlobjectFacade.h +++ b/swift/src/IceImpl/BlobjectFacade.h @@ -42,8 +42,8 @@ class BlobjectFacade : public Ice::BlobjectArrayAsync ~BlobjectFacade() { [_facade facadeRemoved]; } virtual void ice_invokeAsync( - std::pair inEncaps, - std::function&)> response, + std::pair inEncaps, + std::function&)> response, std::function error, const Ice::Current& current); diff --git a/swift/src/IceImpl/BlobjectFacade.mm b/swift/src/IceImpl/BlobjectFacade.mm index e14b9b17264..dbcdde61d19 100644 --- a/swift/src/IceImpl/BlobjectFacade.mm +++ b/swift/src/IceImpl/BlobjectFacade.mm @@ -10,13 +10,13 @@ void BlobjectFacade::ice_invokeAsync( - std::pair inEncaps, - std::function&)> response, + std::pair inEncaps, + std::function&)> response, std::function error, const Ice::Current& current) { ICEBlobjectResponse responseCallback = ^(bool ok, const void* outParams, long count) { - const std::uint8_t* start = static_cast(outParams); + const std::byte* start = static_cast(outParams); response(ok, std::make_pair(start, start + static_cast(count))); }; @@ -30,7 +30,7 @@ @autoreleasepool { [_facade facadeInvoke:adapter - inEncapsBytes:const_cast(inEncaps.first) + inEncapsBytes:const_cast(inEncaps.first) inEncapsCount:static_cast(inEncaps.second - inEncaps.first) con:con name:toNSString(current.id.name) diff --git a/swift/src/IceImpl/ObjectPrx.mm b/swift/src/IceImpl/ObjectPrx.mm index a2c48504562..6db2a1fe28d 100644 --- a/swift/src/IceImpl/ObjectPrx.mm +++ b/swift/src/IceImpl/ObjectPrx.mm @@ -565,8 +565,8 @@ + (id)ice_read:(NSData*)data bytesRead:(NSInteger*)bytesRead error:(NSError**)error { - std::pair p; - p.first = static_cast(data.bytes); + std::pair p; + p.first = static_cast(data.bytes); p.second = p.first + data.length; auto comm = [communicator communicator]; @@ -617,8 +617,8 @@ - (BOOL)invoke:(NSString* _Nonnull)op response:(void (^)(bool, void*, long))response error:(NSError**)error { - std::pair params(0, 0); - params.first = static_cast(inParams.bytes); + std::pair params(0, 0); + params.first = static_cast(inParams.bytes); params.second = params.first + inParams.length; try @@ -628,7 +628,7 @@ - (BOOL)invoke:(NSString* _Nonnull)op { fromNSDictionary(context, ctx); } - std::vector outParams; + std::vector outParams; // We use a std::promise and invokeAsync to avoid making an extra copy of the outParam buffer // and to avoid calling PromiseKit wait. PromiseKit issues a warning if wait() is called on the main thread. @@ -639,7 +639,7 @@ - (BOOL)invoke:(NSString* _Nonnull)op fromNSString(op), static_cast(mode), params, - [response, &p](bool ok, std::pair outParams) + [response, &p](bool ok, std::pair outParams) { // We need an autorelease pool as the unmarshaling (in the response) can // create autorelease objects, typically when unmarshaling proxies @@ -647,7 +647,7 @@ - (BOOL)invoke:(NSString* _Nonnull)op { response( ok, - const_cast(outParams.first), + const_cast(outParams.first), static_cast(outParams.second - outParams.first)); } p.set_value(); @@ -672,8 +672,8 @@ - (BOOL)onewayInvoke:(NSString*)op context:(NSDictionary*)context error:(NSError**)error { - std::pair params(0, 0); - params.first = static_cast(inParams.bytes); + std::pair params(0, 0); + params.first = static_cast(inParams.bytes); params.second = params.first + inParams.length; try @@ -684,7 +684,7 @@ - (BOOL)onewayInvoke:(NSString*)op fromNSDictionary(context, ctx); } - std::vector ignored; + std::vector ignored; _prx->ice_invoke( fromNSString(op), static_cast(mode), @@ -708,8 +708,8 @@ - (void)invokeAsync:(NSString* _Nonnull)op exception:(void (^)(NSError*))exception sent:(void (^_Nullable)(bool))sent { - std::pair params(0, 0); - params.first = static_cast(inParams.bytes); + std::pair params(0, 0); + params.first = static_cast(inParams.bytes); params.second = params.first + inParams.length; try @@ -724,7 +724,7 @@ - (void)invokeAsync:(NSString* _Nonnull)op fromNSString(op), static_cast(mode), params, - [response](bool ok, std::pair outParams) + [response](bool ok, std::pair outParams) { // We need an autorelease pool in case the unmarshaling creates auto // release objects, and in case the application attaches a handler to @@ -734,7 +734,7 @@ - (void)invokeAsync:(NSString* _Nonnull)op { response( ok, - const_cast(outParams.first), + const_cast(outParams.first), static_cast(outParams.second - outParams.first)); } },