[omniORB] Re: 2.8.0pre2 char arrays in idl
Sai-Lai Lo
S.Lo@uk.research.att.com
20 Sep 1999 11:45:02 +0100
Sigh! This is caused by a bug in MS VC++ 5.0. It does not pick up the const
char* conversion operator of a internal class StringBuf when the class
instance is passed to an iostream. We have to do an explict casting. I have
done that to all the StringBuf usage in omniidl2, except the new bit of
code added to speed up array marshalling. Please apply the patch below to
fix the bug. By the way, I cannot reproduce the bug with VC++ 5.0sp3. I've
only seen this with the unpatched VC++ 5.0.
Sai-Lai
>>>>> Peter Bauer writes:
> Hello,
>> From the following idl
> // typedef char Karl[8]; results in same error
> struct Karl {
> char name[8];
> };
> interface Hugo {
> void hallo(in Karl otto);
> void hallo1(in Karl otto);
> void hallo2(in Karl otto);
> };
> omniidl2 creates the following code:
> // This file is generated by omniidl2- omniORB_2_8. Do not edit.
> ...
> void
> Karl::operator>>= (NetBufferedStream &_n) const
> {
> _n.put_char_array((const _CORBA_Char*) 00501EE0, 8);
> ^
> }
> (if only one method hallo is in the interface, no hex digits
> occur in the generated code, which then will compile w/o error...)
> omniIDL2 was build on NT 4.0 using VC++ 5.0. Tried with VC++ 6.0
> too, but same result. If compiled on alpha osf 4.0 with
> dec cxx 6.0, generated code is ok.
> Gruss PB
------------ Cut here ----------------
*** omniORB_280pre2/src/tool/omniidl2/omniORB2_be/o2be_operation.cc Fri Aug 20 12:39:11 1999
--- new/src/tool/omniidl2/omniORB2_be/o2be_operation.cc Mon Sep 20 11:34:15 1999
***************
*** 28,33 ****
--- 28,42 ----
/*
$Log: o2be_operation.cc,v $
+ Revision 1.34.2.1 1999/09/20 10:31:42 sll
+ MS VC++ 5.0 does not pick up the const char* conversion operator of a
+ StringBuf automagically when passed to an iostream. Have to do an explicit
+ casting.
+
+ Revision 1.34 1999/09/15 10:30:01 djr
+ produce_invoke() did not pass ctxt argument if operation had no
+ other arguments.
+
Revision 1.33 1999/08/20 11:39:10 djr
Removed debug output (left in by mistake!).
***************
*** 267,288 ****
void
o2be_operation::produce_invoke(std::fstream &s)
{
! s << uqname() << "(";
UTL_ScopeActiveIterator i(this,UTL_Scope::IK_decls);
while( !i.is_done() ) {
! o2be_argument *a = o2be_argument::narrow_from_decl(i.item());
! s << a->uqname();
i.next();
- s << ((!i.is_done()) ? ", " : (context()?",":""));
}
! if (context()) {
! s << "ctxt";
! }
!
! s << ")";
}
--- 276,295 ----
void
o2be_operation::produce_invoke(std::fstream &s)
{
! s << uqname() << '(';
UTL_ScopeActiveIterator i(this,UTL_Scope::IK_decls);
+ int first = 1;
while( !i.is_done() ) {
! o2be_argument* a = o2be_argument::narrow_from_decl(i.item());
! s << (first ? "":", ") << a->uqname();
! first = 0;
i.next();
}
! if( context() ) s << (first ? "ctxt" : ", ctxt");
! s << ')';
}
***************
*** 2509,2556 ****
case tChar:
case tOctet:
IND(s); s << netstream << ".get_char_array((_CORBA_Char*) "
! << ptr_to_first_elm << ", " << total_length << ");\n";
break;
case tShort:
IND(s); s << "CdrStreamHelper_unmarshalArrayShort("
! << netstream << ", " << ptr_to_first_elm << ", "
<< total_length << ");\n";
break;
case tUShort:
IND(s); s << "CdrStreamHelper_unmarshalArrayUShort("
! << netstream << ", " << ptr_to_first_elm << ", "
<< total_length << ");\n";
break;
case tLong:
IND(s); s << "CdrStreamHelper_unmarshalArrayLong("
! << netstream << ", " << ptr_to_first_elm << ", "
<< total_length << ");\n";
break;
case tULong:
IND(s); s << "CdrStreamHelper_unmarshalArrayULong("
! << netstream << ", " << ptr_to_first_elm << ", "
<< total_length << ");\n";
break;
case tEnum:
IND(s); s << "CdrStreamHelper_unmarshalArrayULong("
<< netstream << ", (_CORBA_ULong*) "
! << ptr_to_first_elm << ", " << total_length << ");\n";
break;
case tFloat:
IND(s); s << "CdrStreamHelper_unmarshalArrayFloat("
! << netstream << ", " << ptr_to_first_elm << ", "
<< total_length << ");\n";
break;
case tDouble:
IND(s); s << "CdrStreamHelper_unmarshalArrayDouble("
! << netstream << ", " << ptr_to_first_elm << ", "
<< total_length << ");\n";
break;
--- 2516,2571 ----
case tChar:
case tOctet:
IND(s); s << netstream << ".get_char_array((_CORBA_Char*) "
! << (const char*)ptr_to_first_elm
! << ", " << total_length << ");\n";
break;
case tShort:
IND(s); s << "CdrStreamHelper_unmarshalArrayShort("
! << netstream << ", "
! << (const char*)ptr_to_first_elm << ", "
<< total_length << ");\n";
break;
case tUShort:
IND(s); s << "CdrStreamHelper_unmarshalArrayUShort("
! << netstream << ", "
! << (const char*)ptr_to_first_elm << ", "
<< total_length << ");\n";
break;
case tLong:
IND(s); s << "CdrStreamHelper_unmarshalArrayLong("
! << netstream << ", "
! << (const char*)ptr_to_first_elm << ", "
<< total_length << ");\n";
break;
case tULong:
IND(s); s << "CdrStreamHelper_unmarshalArrayULong("
! << netstream << ", "
! << (const char*)ptr_to_first_elm << ", "
<< total_length << ");\n";
break;
case tEnum:
IND(s); s << "CdrStreamHelper_unmarshalArrayULong("
<< netstream << ", (_CORBA_ULong*) "
! << (const char*)ptr_to_first_elm
! << ", " << total_length << ");\n";
break;
case tFloat:
IND(s); s << "CdrStreamHelper_unmarshalArrayFloat("
! << netstream << ", "
! << (const char*)ptr_to_first_elm << ", "
<< total_length << ");\n";
break;
case tDouble:
IND(s); s << "CdrStreamHelper_unmarshalArrayDouble("
! << netstream << ", "
! << (const char*)ptr_to_first_elm << ", "
<< total_length << ");\n";
break;
***************
*** 2942,2954 ****
case tChar:
case tOctet:
IND(s); s << netstream << ".put_char_array((const _CORBA_Char*) "
! << ptr_to_first_elm << ", " << total_length << ");\n";
break;
case tShort:
case tUShort:
IND(s); s << netstream << ".put_char_array((const _CORBA_Char*) "
! << ptr_to_first_elm << ", " << (total_length * 2)
<< ", omni::ALIGN_2);\n";
break;
--- 2957,2971 ----
case tChar:
case tOctet:
IND(s); s << netstream << ".put_char_array((const _CORBA_Char*) "
! << (const char*)ptr_to_first_elm
! << ", " << total_length << ");\n";
break;
case tShort:
case tUShort:
IND(s); s << netstream << ".put_char_array((const _CORBA_Char*) "
! << (const char*)ptr_to_first_elm
! << ", " << (total_length * 2)
<< ", omni::ALIGN_2);\n";
break;
***************
*** 2957,2969 ****
case tEnum:
case tFloat:
IND(s); s << netstream << ".put_char_array((const _CORBA_Char*) "
! << ptr_to_first_elm << ", " << (total_length * 4)
<< ", omni::ALIGN_4);\n";
break;
case tDouble:
IND(s); s << netstream << ".put_char_array((const _CORBA_Char*) "
! << ptr_to_first_elm << ", " << (total_length * 8)
<< ", omni::ALIGN_8);\n";
break;
--- 2974,2988 ----
case tEnum:
case tFloat:
IND(s); s << netstream << ".put_char_array((const _CORBA_Char*) "
! << (const char*)ptr_to_first_elm
! << ", " << (total_length * 4)
<< ", omni::ALIGN_4);\n";
break;
case tDouble:
IND(s); s << netstream << ".put_char_array((const _CORBA_Char*) "
! << (const char*)ptr_to_first_elm
! << ", " << (total_length * 8)
<< ", omni::ALIGN_8);\n";
break;
--
Sai-Lai Lo S.Lo@uk.research.att.com
AT&T Laboratories Cambridge WWW: http://www.uk.research.att.com
24a Trumpington Street Tel: +44 1223 343000
Cambridge CB2 1QA Fax: +44 1223 313542
ENGLAND