Skip to content

Commit

Permalink
IDLv4 Explicitly-named Integer Types
Browse files Browse the repository at this point in the history
Ported from DOCGroup#840 to ACE6/TAO2.
Also regenerated with Bison 3.7.6 at the same time like in
d581918 in
DOCGroup#1594
  • Loading branch information
iguessthislldo committed Jul 9, 2021
1 parent 2063860 commit 2cbdf73
Show file tree
Hide file tree
Showing 62 changed files with 5,621 additions and 4,638 deletions.
15 changes: 9 additions & 6 deletions ACE/ace/Basic_Types.h
Original file line number Diff line number Diff line change
Expand Up @@ -666,18 +666,21 @@ ACE_END_VERSIONED_NAMESPACE_DECL
# endif /* ACE_SIZEOF_LONG_DOUBLE */

// Max and min sizes for the ACE integer types.
#define ACE_CHAR_MAX 0x7F
#define ACE_CHAR_MIN -(ACE_CHAR_MAX)-1
#define ACE_OCTET_MAX 0xFF
#define ACE_INT8_MAX 0x7F
#define ACE_INT8_MIN -(ACE_INT8_MAX) - 1
#define ACE_UINT8_MAX 0xFF
#define ACE_CHAR_MAX (ACE_INT8_MAX)
#define ACE_CHAR_MIN (ACE_INT8_MIN)
#define ACE_OCTET_MAX (ACE_UINT8_MAX)
#define ACE_INT16_MAX 0x7FFF
#define ACE_INT16_MIN -(ACE_INT16_MAX)-1
#define ACE_INT16_MIN -(ACE_INT16_MAX) - 1
#define ACE_UINT16_MAX 0xFFFF
#define ACE_WCHAR_MAX ACE_UINT16_MAX
#define ACE_INT32_MAX 0x7FFFFFFF
#define ACE_INT32_MIN -(ACE_INT32_MAX)-1
#define ACE_INT32_MIN -(ACE_INT32_MAX) - 1
#define ACE_UINT32_MAX 0xFFFFFFFF
#define ACE_INT64_MAX ACE_INT64_LITERAL(0x7FFFFFFFFFFFFFFF)
#define ACE_INT64_MIN -(ACE_INT64_MAX)-1
#define ACE_INT64_MIN -(ACE_INT64_MAX) - 1
#define ACE_UINT64_MAX ACE_UINT64_LITERAL (0xFFFFFFFFFFFFFFFF)

// These use ANSI/IEEE format.
Expand Down
10 changes: 9 additions & 1 deletion ACE/ace/CDR_Base.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ class ACE_Export ACE_CDR
*/
//@{
typedef bool Boolean;
typedef unsigned char Octet;
typedef ACE_Byte Octet;
typedef char Char;
typedef ACE_WCHAR_T WChar;
typedef ACE_INT16 Short;
Expand All @@ -207,6 +207,14 @@ class ACE_Export ACE_CDR
typedef ACE_UINT32 ULong;
typedef ACE_INT64 LongLong;
typedef ACE_UINT64 ULongLong;
typedef ACE_INT8 Int8;
typedef ACE_UINT8 UInt8;
typedef Short Int16;
typedef UShort UInt16;
typedef Long Int32;
typedef ULong UInt32;
typedef LongLong Int64;
typedef ULongLong UInt64;

# if ACE_SIZEOF_FLOAT == 4
typedef float Float;
Expand Down
36 changes: 36 additions & 0 deletions ACE/ace/CDR_Stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,18 @@ class ACE_Export ACE_OutputCDR
ACE_CDR::WChar val_;
};

struct ACE_Export from_int8
{
explicit from_int8 (ACE_CDR::Int8 val);
ACE_CDR::Int8 val_;
};

struct ACE_Export from_uint8
{
explicit from_uint8 (ACE_CDR::UInt8 val);
ACE_CDR::UInt8 val_;
};

struct ACE_Export from_string
{
from_string (ACE_CDR::Char* s,
Expand Down Expand Up @@ -260,6 +272,8 @@ class ACE_Export ACE_OutputCDR
ACE_CDR::Boolean write_double (const ACE_CDR::Double &x);
ACE_CDR::Boolean write_longdouble (const ACE_CDR::LongDouble &x);
ACE_CDR::Boolean write_fixed (const ACE_CDR::Fixed &x);
ACE_CDR::Boolean write_int8 (ACE_CDR::Int8 x);
ACE_CDR::Boolean write_uint8 (ACE_CDR::UInt8 x);

/// For string we offer methods that accept a precomputed length.
ACE_CDR::Boolean write_string (const ACE_CDR::Char *x);
Expand Down Expand Up @@ -306,6 +320,8 @@ class ACE_Export ACE_OutputCDR
ACE_CDR::ULong length);
ACE_CDR::Boolean write_longdouble_array (const ACE_CDR::LongDouble* x,
ACE_CDR::ULong length);
ACE_CDR::Boolean write_int8_array (const ACE_CDR::Int8 *x, ACE_CDR::ULong length);
ACE_CDR::Boolean write_uint8_array (const ACE_CDR::UInt8 *x, ACE_CDR::ULong length);

/// Write an octet array contained inside a MB, this can be optimized
/// to minimize copies.
Expand Down Expand Up @@ -790,6 +806,18 @@ class ACE_Export ACE_InputCDR
ACE_CDR::Octet &ref_;
};

struct ACE_Export to_int8
{
explicit to_int8 (ACE_CDR::Int8 &ref);
ACE_CDR::Int8 &ref_;
};

struct ACE_Export to_uint8
{
explicit to_uint8 (ACE_CDR::UInt8 &ref);
ACE_CDR::UInt8 &ref_;
};

struct ACE_Export to_string
{
/**
Expand Down Expand Up @@ -856,6 +884,8 @@ class ACE_Export ACE_InputCDR
ACE_CDR::Boolean read_double (ACE_CDR::Double &x);
ACE_CDR::Boolean read_longdouble (ACE_CDR::LongDouble &x);
ACE_CDR::Boolean read_fixed (ACE_CDR::Fixed &x);
ACE_CDR::Boolean read_int8 (ACE_CDR::Int8 &x);
ACE_CDR::Boolean read_uint8 (ACE_CDR::UInt8 &x);

ACE_CDR::Boolean read_string (ACE_CDR::Char *&x);
ACE_CDR::Boolean read_string (ACE_CString &x);
Expand Down Expand Up @@ -898,6 +928,8 @@ class ACE_Export ACE_InputCDR
ACE_CDR::ULong length);
ACE_CDR::Boolean read_longdouble_array (ACE_CDR::LongDouble* x,
ACE_CDR::ULong length);
ACE_CDR::Boolean read_int8_array (ACE_CDR::Int8 *x, ACE_CDR::ULong length);
ACE_CDR::Boolean read_uint8_array (ACE_CDR::UInt8 *x, ACE_CDR::ULong length);
//@}

/**
Expand Down Expand Up @@ -1412,6 +1444,8 @@ extern ACE_Export ACE_CDR::Boolean operator<< (ACE_OutputCDR &os,
extern ACE_Export ACE_CDR::Boolean operator<< (ACE_OutputCDR &os,
const std::wstring& x);
#endif
extern ACE_Export ACE_CDR::Boolean operator<< (ACE_OutputCDR &os, ACE_OutputCDR::from_uint8 x);
extern ACE_Export ACE_CDR::Boolean operator<< (ACE_OutputCDR &os, ACE_OutputCDR::from_int8 x);

// Not used by CORBA or TAO
extern ACE_Export ACE_CDR::Boolean operator>> (ACE_InputCDR &is,
Expand Down Expand Up @@ -1467,6 +1501,8 @@ extern ACE_Export ACE_CDR::Boolean operator<< (ACE_InputCDR &os,
extern ACE_Export ACE_CDR::Boolean operator>> (ACE_InputCDR &is,
std::wstring& x);
#endif
extern ACE_Export ACE_CDR::Boolean operator>> (ACE_InputCDR &os, ACE_InputCDR::to_uint8 x);
extern ACE_Export ACE_CDR::Boolean operator>> (ACE_InputCDR &os, ACE_InputCDR::to_int8 x);

ACE_END_VERSIONED_NAMESPACE_DECL

Expand Down
111 changes: 111 additions & 0 deletions ACE/ace/CDR_Stream.inl
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,30 @@ ACE_OutputCDR::from_std_wstring::from_std_wstring (const std::wstring &ws,
}
#endif

ACE_INLINE
ACE_InputCDR::to_int8::to_int8 (ACE_CDR::Int8 &ref)
: ref_ (ref)
{
}

ACE_INLINE
ACE_OutputCDR::from_int8::from_int8 (ACE_CDR::Int8 val)
: val_ (val)
{
}

ACE_INLINE
ACE_InputCDR::to_uint8::to_uint8 (ACE_CDR::UInt8 &ref)
: ref_ (ref)
{
}

ACE_INLINE
ACE_OutputCDR::from_uint8::from_uint8 (ACE_CDR::UInt8 val)
: val_ (val)
{
}

ACE_INLINE
ACE_InputCDR::Transfer_Contents::Transfer_Contents (ACE_InputCDR &rhs)
: rhs_ (rhs)
Expand Down Expand Up @@ -355,6 +379,18 @@ ACE_OutputCDR::write_wstring (const std::wstring &x)
}
#endif

ACE_INLINE ACE_CDR::Boolean
ACE_OutputCDR::write_int8 (ACE_CDR::Int8 x)
{
return this->write_1 (reinterpret_cast<ACE_CDR::Octet *> (&x));
}

ACE_INLINE ACE_CDR::Boolean
ACE_OutputCDR::write_uint8 (ACE_CDR::UInt8 x)
{
return this->write_1 (reinterpret_cast<ACE_CDR::Octet *> (&x));
}

ACE_INLINE ACE_CDR::Boolean
ACE_OutputCDR::write_char_array (const ACE_CDR::Char *x,
ACE_CDR::ULong length)
Expand Down Expand Up @@ -491,6 +527,18 @@ ACE_OutputCDR::write_longdouble_array (const ACE_CDR::LongDouble* x,
length);
}

ACE_INLINE ACE_CDR::Boolean
ACE_OutputCDR::write_int8_array (const ACE_CDR::Int8 *x, ACE_CDR::ULong length)
{
return write_array (x, ACE_CDR::OCTET_SIZE, ACE_CDR::OCTET_ALIGN, length);
}

ACE_INLINE ACE_CDR::Boolean
ACE_OutputCDR::write_uint8_array (const ACE_CDR::UInt8 *x, ACE_CDR::ULong length)
{
return write_array (x, ACE_CDR::OCTET_SIZE, ACE_CDR::OCTET_ALIGN, length);
}

ACE_INLINE bool
ACE_OutputCDR::good_bit (void) const
{
Expand Down Expand Up @@ -791,6 +839,18 @@ ACE_InputCDR::read_fixed (ACE_CDR::Fixed &x)
return false;
}

ACE_INLINE ACE_CDR::Boolean
ACE_InputCDR::read_int8 (ACE_CDR::Int8 &x)
{
return read_1 (reinterpret_cast<ACE_CDR::Octet *>(&x));
}

ACE_INLINE ACE_CDR::Boolean
ACE_InputCDR::read_uint8 (ACE_CDR::UInt8 &x)
{
return read_1 (reinterpret_cast<ACE_CDR::Octet *>(&x));
}

ACE_INLINE size_t
ACE_InputCDR::length (void) const
{
Expand Down Expand Up @@ -1021,6 +1081,30 @@ ACE_InputCDR::read_longdouble_array (ACE_CDR::LongDouble* x,
length);
}

ACE_INLINE ACE_CDR::Boolean
ACE_InputCDR::read_int8_array (ACE_CDR::Int8 *x, ACE_CDR::ULong length)
{
if (length * ACE_CDR::OCTET_SIZE > this->length ())
{
this->good_bit_ = false;
return false;
}

return read_array (x, ACE_CDR::OCTET_SIZE, ACE_CDR::OCTET_ALIGN, length);
}

ACE_INLINE ACE_CDR::Boolean
ACE_InputCDR::read_uint8_array (ACE_CDR::UInt8 *x, ACE_CDR::ULong length)
{
if (length * ACE_CDR::OCTET_SIZE > this->length ())
{
this->good_bit_ = false;
return false;
}

return read_array (x, ACE_CDR::OCTET_SIZE, ACE_CDR::OCTET_ALIGN, length);
}

ACE_INLINE ACE_CDR::Boolean
ACE_InputCDR::skip_octet (void)
{
Expand Down Expand Up @@ -1373,6 +1457,20 @@ operator<< (ACE_OutputCDR &os, ACE_OutputCDR::from_wstring x)
(ACE_CDR::Boolean) (os.good_bit () && (!x.bound_ || len <= x.bound_));
}

ACE_INLINE ACE_CDR::Boolean
operator<< (ACE_OutputCDR &os, ACE_OutputCDR::from_uint8 x)
{
os.write_uint8 (x.val_);
return (ACE_CDR::Boolean) os.good_bit ();
}

ACE_INLINE ACE_CDR::Boolean
operator<< (ACE_OutputCDR &os, ACE_OutputCDR::from_int8 x)
{
os.write_int8 (x.val_);
return (ACE_CDR::Boolean) os.good_bit ();
}

// ****************************************************************

ACE_INLINE ACE_CDR::Boolean
Expand Down Expand Up @@ -1537,6 +1635,19 @@ operator>> (ACE_InputCDR &is, ACE_InputCDR::to_std_wstring x)
|| static_cast<ACE_CDR::ULong> (x.val_.size ()) <= x.bound_));
}
#endif

ACE_INLINE ACE_CDR::Boolean
operator>> (ACE_InputCDR &is, ACE_InputCDR::to_uint8 x)
{
return is.read_uint8 (x.ref_) && is.good_bit ();
}

ACE_INLINE ACE_CDR::Boolean
operator>> (ACE_InputCDR &is, ACE_InputCDR::to_int8 x)
{
return is.read_int8 (x.ref_) && is.good_bit ();
}

// ***************************************************************************
// We must define these methods here because they use the "read_*" inlined
// methods of the ACE_InputCDR class
Expand Down
Loading

0 comments on commit 2cbdf73

Please sign in to comment.