Skip to content

Commit

Permalink
Remove Ice::Byte (#1875)
Browse files Browse the repository at this point in the history
Replace usage of Ice::Byte by std::uint8_t
  • Loading branch information
externl authored Feb 28, 2024
1 parent 1762a96 commit 19a6b5e
Show file tree
Hide file tree
Showing 137 changed files with 1,083 additions and 1,097 deletions.
16 changes: 8 additions & 8 deletions cpp/include/Ice/Buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ class ICE_API Buffer : private IceUtil::noncopyable
public:

Buffer() : i(b.begin()) { }
Buffer(const Ice::Byte* beg, const Ice::Byte* end) : b(beg, end), i(b.begin()) { }
Buffer(const std::vector<Ice::Byte>& v) : b(v), i(b.begin()) { }
Buffer(const std::uint8_t* beg, const std::uint8_t* end) : b(beg, end), i(b.begin()) { }
Buffer(const std::vector<std::uint8_t>& v) : b(v), i(b.begin()) { }
Buffer(Buffer& o, bool adopt) : b(o.b, adopt), i(b.begin()) { }

void swapBuffer(Buffer&);
Expand All @@ -29,12 +29,12 @@ class ICE_API Buffer : private IceUtil::noncopyable
// Standard vector-like operations.
//

typedef Ice::Byte value_type;
typedef Ice::Byte* iterator;
typedef const Ice::Byte* const_iterator;
typedef Ice::Byte& reference;
typedef const Ice::Byte& const_reference;
typedef Ice::Byte* pointer;
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;

Container();
Expand Down
12 changes: 0 additions & 12 deletions cpp/include/Ice/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,6 @@ namespace Ice
{
}

namespace IceInternal
{
}

namespace Ice
{

/** The mapping for the Slice byte type. */
typedef unsigned char Byte;

}

namespace IceInternal
{

Expand Down
14 changes: 7 additions & 7 deletions cpp/include/Ice/IconvStringConverter.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ class IconvStringConverter : public IceUtil::BasicStringConverter<charT>

IconvStringConverter(const std::string&);

virtual Ice::Byte* toUTF8(const charT*, const charT*, Ice::UTF8Buffer&) const;
virtual std::uint8_t* toUTF8(const charT*, const charT*, Ice::UTF8Buffer&) const;

virtual void fromUTF8(const Ice::Byte*, const Ice::Byte*, std::basic_string<charT>&) const;
virtual void fromUTF8(const std::uint8_t*, const std::uint8_t*, std::basic_string<charT>&) const;

private:

Expand Down Expand Up @@ -175,7 +175,7 @@ IconvStringConverter<charT>::getDescriptors() const
return descriptorHolder.descriptor;
}

template<typename charT> Ice::Byte*
template<typename charT> std::uint8_t*
IconvStringConverter<charT>::toUTF8(const charT* sourceStart,
const charT* sourceEnd,
Ice::UTF8Buffer& buf) const
Expand Down Expand Up @@ -208,7 +208,7 @@ IconvStringConverter<charT>::toUTF8(const charT* sourceStart,
{
size_t howMany = std::max(inbytesleft, size_t(4));
outbuf = reinterpret_cast<char*>(buf.getMoreBytes(howMany,
reinterpret_cast<Ice::Byte*>(outbuf)));
reinterpret_cast<std::uint8_t*>(outbuf)));
count = iconv(cd, &inbuf, &inbytesleft, &outbuf, &howMany);
} while(count == size_t(-1) && errno == E2BIG);

Expand All @@ -217,11 +217,11 @@ IconvStringConverter<charT>::toUTF8(const charT* sourceStart,
throw Ice::IllegalConversionException(__FILE__, __LINE__,
errno == 0 ? "Unknown error" : IceUtilInternal::errorToString(errno));
}
return reinterpret_cast<Ice::Byte*>(outbuf);
return reinterpret_cast<std::uint8_t*>(outbuf);
}

template<typename charT> void
IconvStringConverter<charT>::fromUTF8(const Ice::Byte* sourceStart, const Ice::Byte* sourceEnd,
IconvStringConverter<charT>::fromUTF8(const std::uint8_t* sourceStart, const std::uint8_t* sourceEnd,
std::basic_string<charT>& target) const
{
iconv_t cd = getDescriptors().first;
Expand All @@ -239,7 +239,7 @@ IconvStringConverter<charT>::fromUTF8(const Ice::Byte* sourceStart, const Ice::B
#ifdef ICE_CONST_ICONV_INBUF
const char* inbuf = reinterpret_cast<const char*>(sourceStart);
#else
char* inbuf = reinterpret_cast<char*>(const_cast<Ice::Byte*>(sourceStart));
char* inbuf = reinterpret_cast<char*>(const_cast<std::uint8_t*>(sourceStart));
#endif
assert(sourceEnd > sourceStart);
size_t inbytesleft = static_cast<size_t>(sourceEnd - sourceStart);
Expand Down
12 changes: 6 additions & 6 deletions cpp/include/Ice/Incoming.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,15 @@ class ICE_API IncomingBase
Ice::OutputStream* startWriteParams();
void endWriteParams();
void writeEmptyParams();
void writeParamEncaps(const Ice::Byte*, std::int32_t, bool);
void writeParamEncaps(const std::uint8_t*, std::int32_t, bool);
void setMarshaledResult(const Ice::MarshaledResult&);

void response(bool);
void exception(std::exception_ptr, bool);

protected:

IncomingBase(Instance*, ResponseHandler*, Ice::Connection*, const Ice::ObjectAdapterPtr&, bool, Ice::Byte, std::int32_t);
IncomingBase(Instance*, ResponseHandler*, Ice::Connection*, const Ice::ObjectAdapterPtr&, bool, std::uint8_t, std::int32_t);
IncomingBase(IncomingBase&);
IncomingBase(const IncomingBase&) = delete;

Expand All @@ -92,7 +92,7 @@ class ICE_API IncomingBase
::std::shared_ptr<void> _cookie;
DispatchObserver _observer;
bool _response;
Ice::Byte _compress;
std::uint8_t _compress;
Ice::FormatType _format;
Ice::OutputStream _os;

Expand All @@ -110,7 +110,7 @@ class ICE_API Incoming final : public IncomingBase
{
public:

Incoming(Instance*, ResponseHandler*, Ice::Connection*, const Ice::ObjectAdapterPtr&, bool, Ice::Byte, std::int32_t);
Incoming(Instance*, ResponseHandler*, Ice::Connection*, const Ice::ObjectAdapterPtr&, bool, std::uint8_t, std::int32_t);

const Ice::Current& getCurrent()
{
Expand Down Expand Up @@ -157,7 +157,7 @@ class ICE_API Incoming final : public IncomingBase
{
_current.encoding = _is->skipEmptyEncapsulation();
}
void readParamEncaps(const Ice::Byte*& v, std::int32_t& sz)
void readParamEncaps(const std::uint8_t*& v, std::int32_t& sz)
{
_current.encoding = _is->readEncapsulation(v, sz);
}
Expand All @@ -167,7 +167,7 @@ class ICE_API Incoming final : public IncomingBase
friend class IncomingAsync;

Ice::InputStream* _is;
Ice::Byte* _inParamPos;
std::uint8_t* _inParamPos;

IncomingAsyncPtr _inAsync;
};
Expand Down
40 changes: 20 additions & 20 deletions cpp/include/Ice/InputStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class ICE_API InputStream : public IceInternal::Buffer
* You can supply a communicator later by calling initialize().
* @param bytes The encoded data.
*/
InputStream(const std::vector<Byte>& bytes);
InputStream(const std::vector<std::uint8_t>& bytes);

/**
* Constructs a stream using the latest encoding version but without a communicator.
Expand All @@ -79,7 +79,7 @@ class ICE_API InputStream : public IceInternal::Buffer
* You can supply a communicator later by calling initialize().
* @param bytes The encoded data.
*/
InputStream(const std::pair<const Byte*, const Byte*>& bytes);
InputStream(const std::pair<const std::uint8_t*, const std::uint8_t*>& bytes);

/// \cond INTERNAL
InputStream(IceInternal::Buffer&, bool = false);
Expand All @@ -96,14 +96,14 @@ class ICE_API InputStream : public IceInternal::Buffer
* @param communicator The communicator to use for unmarshaling tasks.
* @param bytes The encoded data.
*/
InputStream(const CommunicatorPtr& communicator, const std::vector<Byte>& bytes);
InputStream(const CommunicatorPtr& communicator, const std::vector<std::uint8_t>& 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<const Byte*, const Byte*>& bytes);
InputStream(const CommunicatorPtr& communicator, const std::pair<const std::uint8_t*, const std::uint8_t*>& bytes);

/// \cond INTERNAL
InputStream(const CommunicatorPtr& communicator, IceInternal::Buffer&, bool = false);
Expand All @@ -126,7 +126,7 @@ class ICE_API InputStream : public IceInternal::Buffer
* @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<Byte>& bytes);
InputStream(const EncodingVersion& version, const std::vector<std::uint8_t>& bytes);

/**
* Constructs a stream using the given encoding version but without a communicator.
Expand All @@ -136,7 +136,7 @@ class ICE_API InputStream : public IceInternal::Buffer
* @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<const Byte*, const Byte*>& bytes);
InputStream(const EncodingVersion& version, const std::pair<const std::uint8_t*, const std::uint8_t*>& bytes);

/// \cond INTERNAL
InputStream(const EncodingVersion&, IceInternal::Buffer&, bool = false);
Expand All @@ -155,7 +155,7 @@ class ICE_API InputStream : public IceInternal::Buffer
* @param version The encoding version used to encode the data to be unmarshaled.
* @param bytes The encoded data.
*/
InputStream(const CommunicatorPtr& communicator, const EncodingVersion& version, const std::vector<Byte>& bytes);
InputStream(const CommunicatorPtr& communicator, const EncodingVersion& version, const std::vector<std::uint8_t>& bytes);

/**
* Constructs a stream using the given communicator and encoding version.
Expand All @@ -164,7 +164,7 @@ class ICE_API InputStream : public IceInternal::Buffer
* @param bytes The encoded data.
*/
InputStream(const CommunicatorPtr& communicator, const EncodingVersion& version,
const std::pair<const Byte*, const Byte*>& bytes);
const std::pair<const std::uint8_t*, const std::uint8_t*>& bytes);

/// \cond INTERNAL
InputStream(const CommunicatorPtr&, const EncodingVersion&, IceInternal::Buffer&, bool = false);
Expand Down Expand Up @@ -475,7 +475,7 @@ class ICE_API InputStream : public IceInternal::Buffer
* @param sz The number of bytes in the encapsulation.
* @return encoding The encapsulation's encoding version.
*/
EncodingVersion readEncapsulation(const Byte*& v, std::int32_t& sz)
EncodingVersion readEncapsulation(const std::uint8_t*& v, std::int32_t& sz)
{
EncodingVersion encoding;
v = i;
Expand Down Expand Up @@ -561,7 +561,7 @@ class ICE_API InputStream : public IceInternal::Buffer
*/
std::int32_t readSize() // Inlined for performance reasons.
{
Byte byte;
std::uint8_t byte;
read(byte);
unsigned char val = static_cast<unsigned char>(byte);
if(val == 255)
Expand Down Expand Up @@ -594,15 +594,15 @@ class ICE_API InputStream : public IceInternal::Buffer
* @param bytes The vector to hold a copy of the bytes from the marshaling buffer.
* @param sz The number of bytes to read.
*/
void readBlob(std::vector<Byte>& bytes, std::int32_t sz);
void readBlob(std::vector<std::uint8_t>& bytes, std::int32_t sz);

/**
* Reads a blob of bytes from the stream.
*
* @param v A pointer into the internal marshaling buffer representing the start of the blob.
* @param sz The number of bytes to read.
*/
void readBlob(const Byte*& v, Container::size_type sz)
void readBlob(const std::uint8_t*& v, Container::size_type sz)
{
if(sz > 0)
{
Expand Down Expand Up @@ -753,7 +753,7 @@ class ICE_API InputStream : public IceInternal::Buffer
* Reads a byte from the stream.
* @param v The extracted byte.
*/
void read(Byte& v)
void read(std::uint8_t& v)
{
if(i >= b.end())
{
Expand All @@ -766,14 +766,14 @@ class ICE_API InputStream : public IceInternal::Buffer
* Reads a sequence of bytes from the stream.
* @param v A vector to hold a copy of the bytes.
*/
void read(std::vector<Byte>& v);
void read(std::vector<std::uint8_t>& 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<const Byte*, const Byte*>& v);
void read(std::pair<const std::uint8_t*, const std::uint8_t*>& v);

/**
* Reads a bool from the stream.
Expand Down Expand Up @@ -830,16 +830,16 @@ class ICE_API InputStream : public IceInternal::Buffer
{
throwUnmarshalOutOfBoundsException(__FILE__, __LINE__);
}
const Byte* src = &(*i);
const std::uint8_t* src = &(*i);
i += sizeof(std::int32_t);
#ifdef ICE_BIG_ENDIAN
Byte* dest = reinterpret_cast<Byte*>(&v) + sizeof(std::int32_t) - 1;
std::uint8_t* dest = reinterpret_cast<std::uint8_t*>(&v) + sizeof(std::int32_t) - 1;
*dest-- = *src++;
*dest-- = *src++;
*dest-- = *src++;
*dest = *src;
#else
Byte* dest = reinterpret_cast<Byte*>(&v);
std::uint8_t* dest = reinterpret_cast<std::uint8_t*>(&v);
*dest++ = *src++;
*dest++ = *src++;
*dest++ = *src++;
Expand Down Expand Up @@ -1035,7 +1035,7 @@ class ICE_API InputStream : public IceInternal::Buffer
*/
void skipSize()
{
Byte bt;
std::uint8_t bt;
read(bt);
if(static_cast<unsigned char>(bt) == 255)
{
Expand Down Expand Up @@ -1276,7 +1276,7 @@ class ICE_API InputStream : public IceInternal::Buffer
IndexListList indirectionTables;

// Slice attributes
Byte sliceFlags;
std::uint8_t sliceFlags;
std::int32_t sliceSize;
std::string typeId;
int compactId;
Expand Down
12 changes: 6 additions & 6 deletions cpp/include/Ice/Object.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class ICE_API Blobject : public virtual Object
* @throws UserException A user exception can be raised directly and the
* run time will marshal it.
*/
virtual bool ice_invoke(std::vector<Byte> inEncaps, std::vector<Byte>& outEncaps, const Current& current) = 0;
virtual bool ice_invoke(std::vector<std::uint8_t> inEncaps, std::vector<std::uint8_t>& outEncaps, const Current& current) = 0;

/// \cond INTERNAL
virtual bool _iceDispatch(IceInternal::Incoming&, const Current&);
Expand Down Expand Up @@ -176,7 +176,7 @@ class ICE_API BlobjectArray : public virtual Object
* @throws UserException A user exception can be raised directly and the
* run time will marshal it.
*/
virtual bool ice_invoke(std::pair<const Byte*, const Byte*> inEncaps, std::vector<Byte>& outEncaps,
virtual bool ice_invoke(std::pair<const std::uint8_t*, const std::uint8_t*> inEncaps, std::vector<std::uint8_t>& outEncaps,
const Current& current) = 0;

/// \cond INTERNAL
Expand Down Expand Up @@ -206,8 +206,8 @@ class ICE_API BlobjectAsync : public virtual Object
* @throws UserException A user exception can be raised directly and the
* run time will marshal it.
*/
virtual void ice_invokeAsync(std::vector<Byte> inEncaps,
std::function<void(bool, const std::vector<Byte>&)> response,
virtual void ice_invokeAsync(std::vector<std::uint8_t> inEncaps,
std::function<void(bool, const std::vector<std::uint8_t>&)> response,
std::function<void(std::exception_ptr)> error,
const Current& current) = 0;

Expand Down Expand Up @@ -238,8 +238,8 @@ class ICE_API BlobjectArrayAsync : public virtual Object
* @throws UserException A user exception can be raised directly and the
* run time will marshal it.
*/
virtual void ice_invokeAsync(std::pair<const Byte*, const Byte*> inEncaps,
std::function<void(bool, const std::pair<const Byte*, const Byte*>&)> response,
virtual void ice_invokeAsync(std::pair<const std::uint8_t*, const std::uint8_t*> inEncaps,
std::function<void(bool, const std::pair<const std::uint8_t*, const std::uint8_t*>&)> response,
std::function<void(std::exception_ptr)> error,
const Current& current) = 0;
/// \cond INTERNAL
Expand Down
2 changes: 1 addition & 1 deletion cpp/include/Ice/OutgoingAsync.h
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ class ICE_API OutgoingAsync : public ProxyOutgoingAsyncBase
{
_os.writeEmptyEncapsulation(_encoding);
}
void writeParamEncaps(const ::Ice::Byte* encaps, std::int32_t size)
void writeParamEncaps(const ::std::uint8_t* encaps, std::int32_t size)
{
if(size == 0)
{
Expand Down
Loading

0 comments on commit 19a6b5e

Please sign in to comment.