diff options
author | sharath <sharath@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2001-06-27 19:09:42 +0000 |
---|---|---|
committer | sharath <sharath@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2001-06-27 19:09:42 +0000 |
commit | ed5c5077dc45bf454c70abfe9cac351ff3745216 (patch) | |
tree | efec9ce1561a53fc7148f4cc6a9d8e4b667bced2 | |
parent | 803c7301199f51198ca85a406c6cbdc2ba71ebf2 (diff) | |
download | ATCD-ed5c5077dc45bf454c70abfe9cac351ff3745216.tar.gz |
ChangeLogTag: Wed Jun 27 14:07:43 2001 Sharath R. Cholleti <sharath@cs.wustl.edu>
-rw-r--r-- | ChangeLog | 11 | ||||
-rw-r--r-- | ChangeLogs/ChangeLog-02a | 11 | ||||
-rw-r--r-- | ChangeLogs/ChangeLog-03a | 11 | ||||
-rw-r--r-- | ace/CDR_Stream.cpp | 127 | ||||
-rw-r--r-- | ace/CDR_Stream.h | 2 |
5 files changed, 124 insertions, 38 deletions
diff --git a/ChangeLog b/ChangeLog index 84a8713562e..d85b2ceef02 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Wed Jun 27 14:07:43 2001 Sharath R. Cholleti <sharath@cs.wustl.edu> + + * ace/CDR_Stream.{cpp,h}: + + Changed write_wstring() and read_wstring() to partially comply + with GIOP 1.2. + Wed Jun 27 07:13:13 2001 Balachandran Natarajan <bala@cs.wustl.edu> * ace/OS_TLI.inl: Fixed a compile error in Win32 builds. @@ -279,7 +286,7 @@ Tue Jun 19 16:08:34 2001 Sharath R. Cholleti <sharath@cs.wustl.edu> Fixed the skip_wchar() according to the changes in WChar implementation of GIOP 1.2. Thanks to Peter Phillips <pphillip@opentext.com> for reporting the problem - the fix. This fixes BIGID 945. + the fix. This fixes BUGID 945. Tue Jun 19 08:13:52 2001 Chanaka Liyanaarachchi <chanaka@ociweb.com> @@ -1156,7 +1163,7 @@ Fri May 25 05:42:39 2001 Douglas C. Schmidt <schmidt@tango.doc.wustl.edu> and return 0 in this case. Thanks to Airat A. Sadreev <airat@hq.tatenergo.ru> for reporting this. -Thu May 24 22:06:45 2001 Sharath R. Cholleti <sharth@cs.wustl.edu> +Thu May 24 22:06:45 2001 Sharath R. Cholleti <sharath@cs.wustl.edu> * tests/CDR_Test.cpp: Changed the initialization of WChar variable, to remove the warning "integer conversion resulted in a change of sign" diff --git a/ChangeLogs/ChangeLog-02a b/ChangeLogs/ChangeLog-02a index 84a8713562e..d85b2ceef02 100644 --- a/ChangeLogs/ChangeLog-02a +++ b/ChangeLogs/ChangeLog-02a @@ -1,3 +1,10 @@ +Wed Jun 27 14:07:43 2001 Sharath R. Cholleti <sharath@cs.wustl.edu> + + * ace/CDR_Stream.{cpp,h}: + + Changed write_wstring() and read_wstring() to partially comply + with GIOP 1.2. + Wed Jun 27 07:13:13 2001 Balachandran Natarajan <bala@cs.wustl.edu> * ace/OS_TLI.inl: Fixed a compile error in Win32 builds. @@ -279,7 +286,7 @@ Tue Jun 19 16:08:34 2001 Sharath R. Cholleti <sharath@cs.wustl.edu> Fixed the skip_wchar() according to the changes in WChar implementation of GIOP 1.2. Thanks to Peter Phillips <pphillip@opentext.com> for reporting the problem - the fix. This fixes BIGID 945. + the fix. This fixes BUGID 945. Tue Jun 19 08:13:52 2001 Chanaka Liyanaarachchi <chanaka@ociweb.com> @@ -1156,7 +1163,7 @@ Fri May 25 05:42:39 2001 Douglas C. Schmidt <schmidt@tango.doc.wustl.edu> and return 0 in this case. Thanks to Airat A. Sadreev <airat@hq.tatenergo.ru> for reporting this. -Thu May 24 22:06:45 2001 Sharath R. Cholleti <sharth@cs.wustl.edu> +Thu May 24 22:06:45 2001 Sharath R. Cholleti <sharath@cs.wustl.edu> * tests/CDR_Test.cpp: Changed the initialization of WChar variable, to remove the warning "integer conversion resulted in a change of sign" diff --git a/ChangeLogs/ChangeLog-03a b/ChangeLogs/ChangeLog-03a index 84a8713562e..d85b2ceef02 100644 --- a/ChangeLogs/ChangeLog-03a +++ b/ChangeLogs/ChangeLog-03a @@ -1,3 +1,10 @@ +Wed Jun 27 14:07:43 2001 Sharath R. Cholleti <sharath@cs.wustl.edu> + + * ace/CDR_Stream.{cpp,h}: + + Changed write_wstring() and read_wstring() to partially comply + with GIOP 1.2. + Wed Jun 27 07:13:13 2001 Balachandran Natarajan <bala@cs.wustl.edu> * ace/OS_TLI.inl: Fixed a compile error in Win32 builds. @@ -279,7 +286,7 @@ Tue Jun 19 16:08:34 2001 Sharath R. Cholleti <sharath@cs.wustl.edu> Fixed the skip_wchar() according to the changes in WChar implementation of GIOP 1.2. Thanks to Peter Phillips <pphillip@opentext.com> for reporting the problem - the fix. This fixes BIGID 945. + the fix. This fixes BUGID 945. Tue Jun 19 08:13:52 2001 Chanaka Liyanaarachchi <chanaka@ociweb.com> @@ -1156,7 +1163,7 @@ Fri May 25 05:42:39 2001 Douglas C. Schmidt <schmidt@tango.doc.wustl.edu> and return 0 in this case. Thanks to Airat A. Sadreev <airat@hq.tatenergo.ru> for reporting this. -Thu May 24 22:06:45 2001 Sharath R. Cholleti <sharth@cs.wustl.edu> +Thu May 24 22:06:45 2001 Sharath R. Cholleti <sharath@cs.wustl.edu> * tests/CDR_Test.cpp: Changed the initialization of WChar variable, to remove the warning "integer conversion resulted in a change of sign" diff --git a/ace/CDR_Stream.cpp b/ace/CDR_Stream.cpp index ad10c8a515e..6c945607c63 100644 --- a/ace/CDR_Stream.cpp +++ b/ace/CDR_Stream.cpp @@ -165,6 +165,24 @@ ACE_OutputCDR::grow_and_adjust (size_t size, } ACE_CDR::Boolean +ACE_OutputCDR::write_wchar (ACE_CDR::WChar x) +{ + if (ACE_static_cast (ACE_CDR::Short, major_version_) == 1 + && ACE_static_cast (ACE_CDR::Short, minor_version_) == 2) + { + ACE_CDR::Octet len = ACE_static_cast (ACE_CDR::Octet, sizeof(x)); + if (this->write_1 (&len)) + return this->write_octet_array (ACE_reinterpret_cast + (const ACE_CDR::Octet*, &x), + ACE_static_cast (ACE_CDR::ULong, len)); + } + else + if (this->wchar_translator_ == 0) + return this->write_2 (ACE_reinterpret_cast (const ACE_CDR::UShort*, &x)); + return this->wchar_translator_->write_wchar (*this, x); +} + +ACE_CDR::Boolean ACE_OutputCDR::write_string (ACE_CDR::ULong len, const char *x) { @@ -197,24 +215,6 @@ ACE_OutputCDR::write_string (ACE_CDR::ULong len, } ACE_CDR::Boolean -ACE_OutputCDR::write_wchar (ACE_CDR::WChar x) -{ - if (ACE_static_cast (ACE_CDR::Short, major_version_) == 1 - && ACE_static_cast (ACE_CDR::Short, minor_version_) == 2) - { - ACE_CDR::Octet len = ACE_static_cast (ACE_CDR::Octet, sizeof(x)); - if (this->write_1 (&len)) - return this->write_octet_array (ACE_reinterpret_cast - (const ACE_CDR::Octet*, &x), - ACE_static_cast (ACE_CDR::ULong, len)); - } - else - if (this->wchar_translator_ == 0) - return this->write_2 (ACE_reinterpret_cast (const ACE_CDR::UShort*, &x)); - return this->wchar_translator_->write_wchar (*this, x); -} - -ACE_CDR::Boolean ACE_OutputCDR::write_string (const ACE_CString &x) { // @@ Leave this method in here, not the `.i' file so that we don't @@ -229,23 +229,41 @@ ACE_OutputCDR::write_wstring (ACE_CDR::ULong len, // @@ This is a slight violation of "Optimize for the common case", // i.e. normally the translator will be 0, but OTOH the code is // smaller and should be better for the cache ;-) ;-) + // What do we do for GIOP 1.2??? if (this->wchar_translator_ != 0) return this->wchar_translator_->write_wstring (*this, len, x); - if (x != 0) + if (ACE_static_cast (ACE_CDR::Short, this->major_version_) == 1 + && ACE_static_cast (ACE_CDR::Short, this->minor_version_) == 2) { - if (this->write_ulong (len + 1)) + if (x != 0) { - return this->write_wchar_array (x, len + 1); + //In GIOP 1.2 the length field contains the number of bytes + //the wstring occupies rather than number of wchars + //Taking sizeof might not be a good way! This is a temporary fix. + if (this->write_ulong (sizeof(ACE_CDR::WChar)*len)) + { + return this->write_wchar_array (x, len); + } } - } - else - { - if (this->write_ulong (1)) + else { - return this->write_wchar (0); + //In GIOP 1.2 zero length wstrings are legal + return this->write_ulong (0); } } + + else + if (x != 0) + { + if (this->write_ulong (len + 1)) + return this->write_wchar_array (x, len + 1); + } + else + { + if (this->write_ulong (1)) + return this->write_wchar (0); + } return 0; } @@ -834,16 +852,43 @@ ACE_InputCDR::read_wstring (ACE_CDR::WChar*& x) ACE_CDR::ULong len; this->read_ulong (len); + // A check for the length being too great is done later in the // call to read_char_array but we want to have it done before // the memory is allocated. if (len > 0 && len <= this->length()) { - ACE_NEW_RETURN (x, - ACE_CDR::WChar[len], - 0); - if (this->read_wchar_array (x, len)) - return 1; + + if (ACE_static_cast (ACE_CDR::Short, this->major_version_) == 1 + && ACE_static_cast (ACE_CDR::Short, this->minor_version_) == 2) + { + len = len / sizeof (ACE_CDR::WChar); + + //allocating one extra for the null character needed by applications + ACE_NEW_RETURN (x, + ACE_CDR::WChar [len + 1], + 0); + + if (this->read_wchar_array (x, len)) + { + + //Null character used by applications to find the end of + //the wstring + //Is this okay with the GIOP 1.2 spec?? + x[len] = '\x00'; + + return 1; + } + } + else + { + ACE_NEW_RETURN (x, + ACE_CDR::WChar [len], + 0); + + if (this->read_wchar_array (x, len)) + return 1; + } delete [] x; } @@ -1088,6 +1133,26 @@ ACE_InputCDR::skip_string (void) } ACE_CDR::Boolean +ACE_InputCDR::skip_wstring (void) +{ + ACE_CDR::Boolean continue_skipping = 1; + ACE_CDR::ULong len; + + continue_skipping = read_ulong (len); + + if (continue_skipping != 0 && len != 0) + { + if (ACE_static_cast (ACE_CDR::Short, this->major_version_) == 1 + && ACE_static_cast (ACE_CDR::Short, this->minor_version_) == 2) + continue_skipping = this->skip_bytes ((size_t)len); + else + while (continue_skipping != 0 && len--) + continue_skipping = this->skip_wchar (); + } + return continue_skipping; +} + +ACE_CDR::Boolean ACE_InputCDR::skip_bytes (size_t len) { if (this->rd_ptr () + len <= this->end ()) diff --git a/ace/CDR_Stream.h b/ace/CDR_Stream.h index 5c8388d3e82..c6f4a89c8cb 100644 --- a/ace/CDR_Stream.h +++ b/ace/CDR_Stream.h @@ -618,7 +618,7 @@ public: /** * The buffer <x> must be large enough to contain <length> * elements. - * Return -1 on failure and 0 on success. + * Return 0 on failure and 1 on success. */ //@{ @name Read basic IDL types arrays ACE_CDR::Boolean read_boolean_array (ACE_CDR::Boolean* x, |