[omniORB] Request w/patch

George Garvey tmwg-oorb at inxservices.com
Sat Oct 8 15:30:11 BST 2005


   We use gcc's warning against old C style casts.
   Please consider this patch, which changes the C casts in omniidl's
output to C++ casts. I'm sure I missed some, but omniORB compiles with
this patch.


diff -ur omniORB-4.0.6.org/src/lib/omniORB/omniidl_be/cxx/call.py omniORB-4.0.6/src/lib/omniORB/omniidl_be/cxx/call.py
--- omniORB-4.0.6.org/src/lib/omniORB/omniidl_be/cxx/call.py	2005-03-29 07:52:54.000000000 -0800
+++ omniORB-4.0.6/src/lib/omniORB/omniidl_be/cxx/call.py	2005-10-08 11:19:03.000000000 -0700
@@ -310,7 +310,7 @@
         # need to fetch the call descriptor. This suppresses a warning in gcc
         # about an unused variable.
         if result_string != "" or impl_args != []:
-            get_cd = self.__name + "* tcd = (" + self.__name + "*)cd;"
+            get_cd = self.__name + "* tcd = static_cast<" + self.__name + "*>(cd);"
         else:
             get_cd = ""
 
@@ -709,12 +709,12 @@
                 elif d_type.string():
                     marshal_block.out(arg_n + "_ = *" + arg_n + ";\n"+ \
                                       "*" + arg_n + " = " + \
-                                      "(char*) _CORBA_String_helper::empty_string;")
+                                      "static_cast<char*>(_CORBA_String_helper::empty_string);")
                 elif d_type.string():
                     # XXX the empty string constant may be wrong.
                     marshal_block.out(arg_n + "_ = *" + arg_n + ";\n" + \
                                       "*" + arg_n + " = " + \
-                                      "(CORBA::WChar*) _CORBA_WString_helper::empty_string;")
+                                      "static_cast<CORBA::WChar*>(_CORBA_WString_helper::empty_string);")
                 arg_n = "*" + arg_n
             skutil.unmarshall(marshal_block, None,
                               argtype, None, arg_n, "_n")
diff -ur omniORB-4.0.6.org/src/lib/omniORB/omniidl_be/cxx/dynskel/template.py omniORB-4.0.6/src/lib/omniORB/omniidl_be/cxx/dynskel/template.py
--- omniORB-4.0.6.org/src/lib/omniORB/omniidl_be/cxx/dynskel/template.py	2001-10-29 09:42:39.000000000 -0800
+++ omniORB-4.0.6/src/lib/omniORB/omniidl_be/cxx/dynskel/template.py	2005-10-08 14:07:15.000000000 -0700
@@ -181,7 +181,7 @@
 @private_prefix at _buildDesc@decl_cname@(tcDescriptor& _desc, const @dtype@(*_data)@tail_dims@)
 {
   _desc.p_array.getElementDesc = @private_prefix at _tcParser_getElementDesc@decl_cname@;
-  _desc.p_array.opq_array = (void*) _data;
+  _desc.p_array.opq_array = static_cast<void*>(_data);
 }
 #endif
 """
@@ -227,13 +227,13 @@
 static void
 @private_prefix at _tcParser_setElementCount@cname@(const tcSequenceDesc* _desc, CORBA::ULong _len)
 {
-  ((@sequence_template@*)_desc->opq_seq)->length(_len);
+  (static_cast<@sequence_template@*>(_desc->opq_seq))->length(_len);
 }
 
 static CORBA::ULong
 @private_prefix at _tcParser_getElementCount@cname@(const tcSequenceDesc* _desc)
 {
-  return ((@sequence_template@*)_desc->opq_seq)->length();
+  return (static_cast<@sequence_template@*>(_desc->opq_seq))->length();
 }
 
 static CORBA::Boolean
@@ -246,7 +246,7 @@
 static void
 @private_prefix at _buildDesc@cname@(tcDescriptor &_desc, const @sequence_template@& _data)
 {
-  _desc.p_sequence.opq_seq = (void*) &_data;
+  _desc.p_sequence.opq_seq = const_cast<void*>(static_cast<const void *>(&_data));
   _desc.p_sequence.setElementCount =
     @private_prefix at _tcParser_setElementCount@cname@;
   _desc.p_sequence.getElementCount =
@@ -272,7 +272,7 @@
 {
   _desc.p_struct.getMemberDesc = @private_prefix at _tcParser_getMemberDesc_@guard_name@;
   _desc.p_struct.getMemberCount = @private_prefix at _tcParser_getMemberCount_@guard_name@;
-  _desc.p_struct.opq_struct = (void *)&_data;
+  _desc.p_struct.opq_struct = const_cast<void *>(static_cast<const void *>(&_data));
 }
 """
 
@@ -290,7 +290,7 @@
 @private_prefix at _tcParser_setObjectPtr_@guard_name@(const tcObjrefDesc *_desc, CORBA::Object_ptr _ptr)
 {
   @fqname at _ptr _p = @fqname@::_narrow(_ptr);
-  @fqname at _ptr* pp = (@fqname at _ptr*)_desc->opq_objref;
+  @fqname at _ptr* pp = static_cast<@fqname at _ptr*>(_desc->opq_objref);
   if (_desc->opq_release && !CORBA::is_nil(*pp)) CORBA::release(*pp);
   *pp = _p;
   CORBA::release(_ptr);
@@ -299,19 +299,19 @@
 static CORBA::Object_ptr
 @private_prefix at _tcParser_getObjectPtr_@guard_name@(const tcObjrefDesc *_desc)
 {
-  return (CORBA::Object_ptr) *((@fqname at _ptr*)_desc->opq_objref);
+  return static_cast<CORBA::Object_ptr>(*((@fqname at _ptr*)_desc->opq_objref));
 }
 
 void @private_prefix at _buildDesc_c@guard_name@(tcDescriptor& _desc, const @objref_member@& _d)
 {
-  _desc.p_objref.opq_objref = (void*) &_d._data;
+  _desc.p_objref.opq_objref = static_cast<void*>(&_d._data);
   _desc.p_objref.opq_release = _d._rel;
   _desc.p_objref.setObjectPtr = @private_prefix at _tcParser_setObjectPtr_@guard_name@;
   _desc.p_objref.getObjectPtr = @private_prefix at _tcParser_getObjectPtr_@guard_name@;
 }
 
 void @private_prefix at _delete_@guard_name@(void* _data) {
-  CORBA::release((@fqname at _ptr) _data);
+  CORBA::release(static_cast<@fqname at _ptr>(_data));
 }
 
 void operator<<=(CORBA::Any& _a, @fqname at _ptr _s) {
@@ -328,14 +328,14 @@
 }
 
 CORBA::Boolean operator>>=(const CORBA::Any& _a, @fqname at _ptr& _s) {
-  @fqname at _ptr sp = (@fqname at _ptr) _a.PR_getCachedData();
+  @fqname at _ptr sp = static_cast<@fqname at _ptr>(_a.PR_getCachedData());
   if (sp == 0) {
     tcDescriptor tcd;
     @fqname at _var tmp;
     @private_prefix at _buildDesc_c@guard_name@(tcd, tmp);
     if( _a.PR_unpackTo(@tc_name@, &tcd) ) {
       if (!omniORB::omniORB_27_CompatibleAnyExtraction) {
-        ((CORBA::Any*)&_a)->PR_setCachedData((void*)(@fqname at _ptr)tmp, at private_prefix@_delete_ at guard_name@);
+        (const_cast<CORBA::Any*>(&_a))->PR_setCachedData(static_cast<void*>(static_cast<@fqname at _ptr>(tmp)), at private_prefix@_delete_ at guard_name@);
       }
       _s = tmp._retn();
       return 1;
@@ -361,7 +361,7 @@
 #   @private_prefix at _delete_@guard_name@
 typedef_array_decl_delete = """\
 void @private_prefix at _delete_@guard_name@(void* _data) {
-  @fqname at _slice* _0RL_t = (@fqname at _slice*) _data;
+  @fqname at _slice* _0RL_t = static_cast<@fqname at _slice*>(_data);
   @fqname at _free(_0RL_t);
 }
 """
@@ -381,7 +381,7 @@
   }
 }
 CORBA::Boolean operator>>=(const CORBA::Any& _a, @fqname at _forany& _s) {
-  @fqname at _slice* @private_prefix at _s = (@fqname at _slice*) _a.PR_getCachedData();
+  @fqname at _slice* @private_prefix at _s = static_cast<@fqname at _slice*>(_a.PR_getCachedData());
   if( !@private_prefix at _s ) {
     @private_prefix at _s = @fqname at _alloc();
     tcDescriptor @private_prefix at _tcdesc;
@@ -391,7 +391,7 @@
       _s = 0;
       return 0;
     }
-    ((CORBA::Any*)&_a)->PR_setCachedData(@private_prefix at _s, @private_prefix at _delete_@guard_name@);
+    (static_cast<CORBA::Any*>(&_a))->PR_setCachedData(@private_prefix at _s, @private_prefix at _delete_@guard_name@);
   } else {
     CORBA::TypeCode_var @private_prefix at _tc = _a.type();
     if( !@private_prefix at _tc->equivalent(@tcname@) ) {
@@ -419,28 +419,28 @@
 
 void @private_prefix at _seq_delete_@guard_name@(void* _data)
 {
-  delete (@fqname@*)_data;
+  delete static_cast<@fqname@*>(_data);
 }
 
 CORBA::Boolean operator >>= (const CORBA::Any& _a, @fqname@*& _s_out)
 {
-  return _a >>= (const @fqname@*&) _s_out;
+  return _a >>= const_cast<const @fqname@*&>(_s_out);
 }
 
 CORBA::Boolean operator >>= (const CORBA::Any& _a, const @fqname@*& _s_out)
 {
   _s_out = 0;
-  @fqname@* stmp = (@fqname@*) _a.PR_getCachedData();
+  @fqname@* stmp = static_cast<@fqname@*>(_a.PR_getCachedData());
   if( stmp == 0 ) {
     tcDescriptor tcdesc;
     stmp = new @fqname@;
     @private_prefix at _buildDesc@decl_cname@(tcdesc, *stmp);
     if( _a.PR_unpackTo(@tcname@, &tcdesc)) {
-      ((CORBA::Any*)&_a)->PR_setCachedData((void*)stmp, @private_prefix at _seq_delete_@guard_name@);
+      (const_cast<CORBA::Any*>(&_a))->PR_setCachedData((void*)stmp, @private_prefix at _seq_delete_@guard_name@);
       _s_out = stmp;
       return 1;
     } else {
-      delete (@fqname@ *)stmp;
+      delete stmp;
       return 0;
     }
   } else {
@@ -462,7 +462,7 @@
 enum = """\
 void @private_prefix at _buildDesc_c@guard_name@(tcDescriptor& _desc, const @fqname@& _data)
 {
-  _desc.p_enum.data = (void*)&_data;
+  _desc.p_enum.data = const_cast<void*>(static_cast<const void*>(&_data));
   _desc.p_enum.size = sizeof(_data);
 }
 
@@ -487,7 +487,7 @@
 #   @private_prefix at _delete_@guard_name@
 struct = """\
 void @private_prefix at _delete_@guard_name@(void* _data) {
-  @fqname@* @private_prefix at _t = (@fqname@*) _data;
+  @fqname@* @private_prefix at _t = static_cast<@fqname@*>(_data);
   delete @private_prefix at _t;
 }
 
@@ -507,7 +507,7 @@
 }
 
 CORBA::Boolean operator>>=(const CORBA::Any& _a, @fqname@*& _sp) {
-  return _a >>= (const @fqname@*&) _sp;
+  return _a >>= const_cast<const @fqname@*&>(_sp);
 }
 
 CORBA::Boolean operator>>=(const CORBA::Any& _a, const @fqname@*& _sp) {
@@ -517,10 +517,10 @@
     _sp = new @fqname@;
     @private_prefix at _buildDesc_c@guard_name@(@private_prefix at _tcdesc, *_sp);
     if (_a.PR_unpackTo(@private_prefix at _tc_@guard_name@, &@private_prefix at _tcdesc)) {
-      ((CORBA::Any *)&_a)->PR_setCachedData((void*)_sp, @private_prefix at _delete_@guard_name@);
+      (const_cast<CORBA::Any *>(&_a))->PR_setCachedData((void*)_sp, @private_prefix at _delete_@guard_name@);
       return 1;
     } else {
-      delete (@fqname@ *)_sp; _sp = 0;
+      delete _sp; _sp = 0;
       return 0;
     }
   } else {
@@ -539,19 +539,19 @@
 class @private_prefix at _tcParser_unionhelper_@guard_name@ {
 public:
   static void getDiscriminator(const tcUnionDesc* _desc, tcDescriptor& _newdesc, CORBA::PR_unionDiscriminator& _discrim) {
-    @fqname@* _u = (@fqname@*)_desc->opq_union;
+    @fqname@* _u = static_cast<@fqname@*>(_desc->opq_union);
     @private_prefix at _buildDesc@discrim_cname@(_newdesc, _u->_pd__d);
-    _discrim = (CORBA::PR_unionDiscriminator)_u->_pd__d;
+    _discrim = static_cast<CORBA::PR_unionDiscriminator>(_u->_pd__d);
   }
 
   static void setDiscriminator(const tcUnionDesc* _desc, CORBA::PR_unionDiscriminator _discrim, int _is_default) {
-    @fqname@* _u = (@fqname@*)_desc->opq_union;
-    _u->_pd__d = (@discrim_type@)_discrim;
+    @fqname@* _u = static_cast<@fqname@*>(_desc->opq_union);
+    _u->_pd__d = static_cast<@discrim_type@>(_discrim);
     _u->_pd__default = _is_default;
   }
 
   static CORBA::Boolean getValueDesc(const tcUnionDesc* _desc, tcDescriptor& _newdesc) {
-    @fqname@* _u = (@fqname@*)_desc->opq_union;
+    @fqname@* _u = static_cast<@fqname@*>(_desc->opq_union);
     @switch@
     return 1;
   }
@@ -571,12 +571,12 @@
   _desc.p_union.getDiscriminator = @private_prefix at _tcParser_unionhelper_@guard_name@::getDiscriminator;
   _desc.p_union.setDiscriminator = @private_prefix at _tcParser_unionhelper_@guard_name@::setDiscriminator;
   _desc.p_union.getValueDesc = @private_prefix at _tcParser_unionhelper_@guard_name@::getValueDesc;
-  _desc.p_union.opq_union = (void*)&_data;
+  _desc.p_union.opq_union = static_cast<void*>(&_data);
 }
 
 void @private_prefix at _delete_@guard_name@(void* _data)
 {
-  @fqname@* @private_prefix at _t = (@fqname@*) _data;
+  @fqname@* @private_prefix at _t = static_cast<@fqname@*>(_data);
   delete @private_prefix at _t;
 }
 
@@ -596,20 +596,20 @@
 }
 
 CORBA::Boolean operator>>=(const CORBA::Any& _a, @fqname@*& _sp) {
-  return _a >>= (const @fqname@*&) _sp;
+  return _a >>= const_cast<const @fqname@*&>(_sp);
 }
 
 CORBA::Boolean operator>>=(const CORBA::Any& _a, const @fqname@*& _sp) {
-  _sp = (@fqname@ *) _a.PR_getCachedData();
+  _sp = static_cast<@fqname@ *>(_a.PR_getCachedData());
   if (_sp == 0) {
     tcDescriptor @private_prefix at _tcdesc;
     _sp = new @fqname@;
     @private_prefix at _buildDesc_c@guard_name@(@private_prefix at _tcdesc, *_sp);
     if( _a.PR_unpackTo(@private_prefix at _tc_@guard_name@, &@private_prefix at _tcdesc) ) {
-      ((CORBA::Any*)&_a)->PR_setCachedData((void*)_sp, @private_prefix at _delete_@guard_name@);
+      (const_cast<CORBA::Any*>(&_a))->PR_setCachedData((void*)_sp, @private_prefix at _delete_@guard_name@);
       return 1;
     } else {
-      delete ( @fqname@*)_sp;
+      delete _sp;
       _sp = 0;
       return 0;
     }
@@ -628,7 +628,7 @@
 #   @private_prefix at _delete_@guard_name   
 exception = """\
 void @private_prefix at _delete_@guard_name@(void* _data) {
-  @fqname@* @private_prefix at _t = (@fqname@*) _data;
+  @fqname@* @private_prefix at _t = static_cast<@fqname@*>(_data);
   delete @private_prefix at _t;
 }
 
@@ -642,37 +642,37 @@
   tcDescriptor @private_prefix at _tcdesc;
   @private_prefix at _buildDesc_c@guard_name@(@private_prefix at _tcdesc, *_sp);
   _a.PR_packFrom(@private_prefix at _tc_@guard_name@, &@private_prefix at _tcdesc);
-  delete (@fqname@ *)_sp;
+  delete _sp;
 }
 
 CORBA::Boolean operator>>=(const CORBA::Any& _a,const @fqname@*& _sp) {
-  _sp = (@fqname@ *) _a.PR_getCachedData();
+  _sp = static_cast<@fqname@ *>(_a.PR_getCachedData());
   if (_sp == 0) {
     tcDescriptor @private_prefix at _tcdesc;
     _sp = new @fqname@;
     @private_prefix at _buildDesc_c@guard_name@(@private_prefix at _tcdesc, *_sp);
     if (_a.PR_unpackTo(@private_prefix at _tc_@guard_name@, &@private_prefix at _tcdesc)) {
-      ((CORBA::Any *)&_a)->PR_setCachedData((void*)_sp, @private_prefix at _delete_@guard_name@);
+      (const_cast<CORBA::Any *>(&_a))->PR_setCachedData((void*)_sp, @private_prefix at _delete_@guard_name@);
       return 1;
     } else {
-      delete (@fqname@ *)_sp;_sp = 0;
+      delete _sp;_sp = 0;
       return 0;
     }
   } else {
     CORBA::TypeCode_var @private_prefix at _tctmp = _a.type();
     if (@private_prefix at _tctmp->equivalent(@private_prefix at _tc_@guard_name@)) return 1;
-    delete (@fqname@ *)_sp;_sp = 0;
+    delete _sp;_sp = 0;
     return 0;
   }
 }
 
 static void @private_prefix at _insertToAny__c@guard_name@(CORBA::Any& _a,const CORBA::Exception& _e) {
-  const @fqname@ & _ex = (const @fqname@ &) _e;
+  const @fqname@ & _ex = static_cast<const @fqname@ &>(_e);
   operator<<=(_a,_ex);
 }
 
 static void @private_prefix at _insertToAnyNCP__c@guard_name@ (CORBA::Any& _a,const CORBA::Exception* _e) {
-  const @fqname@ * _ex = (const @fqname@ *) _e;
+  const @fqname@ * _ex = static_cast<const @fqname@ *>(_e);
   operator<<=(_a,_ex);
 }
 
diff -ur omniORB-4.0.6.org/src/lib/omniORB/omniidl_be/cxx/header/template.py omniORB-4.0.6/src/lib/omniORB/omniidl_be/cxx/header/template.py
--- omniORB-4.0.6.org/src/lib/omniORB/omniidl_be/cxx/header/template.py	2004-10-17 19:44:37.000000000 -0700
+++ omniORB-4.0.6/src/lib/omniORB/omniidl_be/cxx/header/template.py	2005-10-08 12:03:25.000000000 -0700
@@ -341,7 +341,7 @@
   virtual ~@POA_name@();
 
   inline ::@scopedID at _ptr _this() {
-    return (::@scopedID at _ptr) _do_this(::@scopedID@::_PD_repoId);
+    return static_cast< ::@scopedID at _ptr >(_do_this(::@scopedID@::_PD_repoId));
   }
 };
 """
@@ -396,7 +396,7 @@
   static inline _ptr_type _unmarshalObjRef(cdrStream& s) {
     omniObjRef* o = omniObjRef::_unMarshal(_PD_repoId,s);
     if (o)
-      return (_ptr_type) o->_ptrToObjRef(_PD_repoId);
+      return static_cast<_ptr_type>(o->_ptrToObjRef(_PD_repoId));
     else
       return _nil();
   }
@@ -479,7 +479,7 @@
   _sk_ at name@(const omniOrbBoaKey&);
   virtual ~_sk_ at name@();
   inline @name@::_ptr_type _this() {
-    return (@name@::_ptr_type) omniOrbBoaServant::_this(@name@::_PD_repoId);
+    return static_cast<@name@::_ptr_type>(omniOrbBoaServant::_this(@name@::_PD_repoId));
   }
 
 };
@@ -681,7 +681,7 @@
 
 sequence_var_array_subscript = """\
 inline @element at _slice* operator [] (_CORBA_ULong _s) {
-  return (@element at _slice*) ((_pd_seq->NP_data())[_s]);
+  return static_cast<@element at _slice*>(((_pd_seq->NP_data())[_s]));
 }
 """
 
@@ -746,7 +746,7 @@
 
 sequence_out_array_subscript = """\
 inline @element at _slice* operator [] (_CORBA_ULong _i) {
-  return (@element at _slice*) ((_data->NP_data())[_i]);
+  return static_cast<@element at _slice*>(((_data->NP_data())[_i]));
 }
 """
 
@@ -1284,7 +1284,7 @@
 
 enum_operators = """\
 inline void operator >>=(@name@ _e, cdrStream& s) {
-  ::operator>>=((CORBA::ULong)_e, s);
+  ::operator>>=(static_cast<CORBA::ULong>(_e), s);
 }
 
 inline void operator <<= (@name@& _e, cdrStream& s) {
@@ -1292,7 +1292,7 @@
   ::operator<<=(@private_prefix at _e,s);
   switch (@private_prefix at _e) {
     @cases@
-    _e = (@name@) @private_prefix at _e;
+    _e = static_cast<@name@>(@private_prefix at _e);
     break;
   default:
     OMNIORB_THROW(MARSHAL,_OMNI_NS(MARSHAL_InvalidEnumValue),
diff -ur omniORB-4.0.6.org/src/lib/omniORB/omniidl_be/cxx/impl/template.py omniORB-4.0.6/src/lib/omniORB/omniidl_be/cxx/impl/template.py
--- omniORB-4.0.6.org/src/lib/omniORB/omniidl_be/cxx/impl/template.py	2005-01-04 06:44:23.000000000 -0800
+++ omniORB-4.0.6/src/lib/omniORB/omniidl_be/cxx/impl/template.py	2005-10-08 12:35:19.000000000 -0700
@@ -95,7 +95,7 @@
   // IDL interface: @fqname@
   CORBA::Object_var ref = @inst_name at ->_this();
   CORBA::String_var sior(orb->object_to_string(ref));
-  std::cout << "IDL object @fqname@ IOR = '" << (char*)sior << "'" << std::endl;
+  std::cout << "IDL object @fqname@ IOR = '" << static_cast<char*>(sior) << "'" << std::endl;
 }
 """
 
diff -ur omniORB-4.0.6.org/src/lib/omniORB/omniidl_be/cxx/skel/template.py omniORB-4.0.6/src/lib/omniORB/omniidl_be/cxx/skel/template.py
--- omniORB-4.0.6.org/src/lib/omniORB/omniidl_be/cxx/skel/template.py	2005-03-29 07:52:53.000000000 -0800
+++ omniORB-4.0.6/src/lib/omniORB/omniidl_be/cxx/skel/template.py	2005-10-08 12:33:45.000000000 -0700
@@ -253,7 +253,7 @@
 @name@::_narrow(CORBA::Object_ptr obj)
 {
   if( !obj || obj->_NP_is_nil() || obj->_NP_is_pseudo() ) return _nil();
-  _ptr_type e = (_ptr_type) obj->_PR_getobj()->_realNarrow(_PD_repoId);
+  _ptr_type e = static_cast<_ptr_type>(obj->_PR_getobj()->_realNarrow(_PD_repoId));
   return e ? e : _nil();
 }
 
@@ -262,7 +262,7 @@
 @name@::_unchecked_narrow(CORBA::Object_ptr obj)
 {
   if( !obj || obj->_NP_is_nil() || obj->_NP_is_pseudo() ) return _nil();
-  _ptr_type e = (_ptr_type) obj->_PR_getobj()->_uncheckedNarrow(_PD_repoId);
+  _ptr_type e = static_cast<_ptr_type>(obj->_PR_getobj()->_uncheckedNarrow(_PD_repoId));
   return e ? e : _nil();
 }
 
@@ -308,16 +308,16 @@
 @fq_objref_name@::_ptrToObjRef(const char* id)
 {
   if( id == ::@name@::_PD_repoId )
-    return (::@name at _ptr) this;
+    return static_cast< ::@name at _ptr >(this);
   @_ptrToObjRef_ptr@
   if( id == ::CORBA::Object::_PD_repoId )
-    return (::CORBA::Object_ptr) this;
+    return static_cast< ::CORBA::Object_ptr >(this);
 
   if( omni::strMatch(id, ::@name@::_PD_repoId) )
-    return (::@name at _ptr) this;
+    return static_cast< ::@name at _ptr >(this);
   @_ptrToObjRef_str@
   if( omni::strMatch(id, ::CORBA::Object::_PD_repoId) )
-    return (::CORBA::Object_ptr) this;
+    return static_cast< ::CORBA::Object_ptr >(this);
 
   return 0;
 }
@@ -325,12 +325,12 @@
 
 interface_objref_repoID_ptr = """\
 if( id == ::@inherits_fqname@::_PD_repoId )
-  return (::@inherits_fqname at _ptr) this;
+  return static_cast< ::@inherits_fqname at _ptr >(this);
 """
 
 interface_objref_repoID_str = """\
 if( omni::strMatch(id, ::@inherits_fqname@::_PD_repoId) )
-  return (::@inherits_fqname at _ptr) this;
+  return static_cast< ::@inherits_fqname at _ptr >(this);
 """
 
 interface_shortcut = """\
@@ -356,7 +356,7 @@
 @local_call_descriptor@(omniCallDescriptor* cd, omniServant* svnt)
 {
   @get_call_descriptor@
-  @impl_fqname@* impl = (@impl_fqname@*) svnt->_ptrToInterface(@name@::_PD_repoId);
+  @impl_fqname@* impl = static_cast<@impl_fqname@*>(svnt->_ptrToInterface(@name@::_PD_repoId));
 @impl_call@
 }
 """
@@ -546,16 +546,16 @@
 @impl_fqname@::_ptrToInterface(const char* id)
 {
   if( id == ::@name@::_PD_repoId )
-    return (::@impl_fqname@*) this;
+    return static_cast< ::@impl_fqname@* >(this);
   @_ptrToInterface_ptr@
   if( id == ::CORBA::Object::_PD_repoId )
-    return (void*) 1;
+    return reinterpret_cast<void*>(1);
 
   if( omni::strMatch(id, ::@name@::_PD_repoId) )
-    return (::@impl_fqname@*) this;
+    return static_cast< ::@impl_fqname@* >(this);
   @_ptrToInterface_str@
   if( omni::strMatch(id, ::CORBA::Object::_PD_repoId) )
-    return (void*) 1;
+    return reinterpret_cast<void*>(1);
   return 0;
 }
 
@@ -583,12 +583,12 @@
 
 interface_impl_repoID_ptr = """\
 if( id == ::@inherited_name@::_PD_repoId )
-  return (::@impl_inherited_name@*) this;
+  return static_cast< ::@impl_inherited_name@* >(this);
 """
 
 interface_impl_repoID_str = """\
 if( omni::strMatch(id, ::@inherited_name@::_PD_repoId) )
-  return (::@impl_inherited_name@*) this;
+  return static_cast< ::@impl_inherited_name@* >(this);
 """
 
 interface_sk = """\
@@ -728,7 +728,7 @@
 
 @scoped_name@& @scoped_name@::operator=(const @scoped_name@& _s)
 {
-  ((CORBA::UserException*) this)->operator=(_s);
+  (static_cast<CORBA::UserException*>(this))->operator=(_s);
   @assign_op_body@
   return *this;
 }
@@ -741,11 +741,11 @@
 const char* @scoped_name@::_PD_typeId = "Exception/UserException/@scoped_name@";
 
 @scoped_name@* @scoped_name@::_downcast(CORBA::Exception* _e) {
-  return (@name@*) _NP_is_a(_e, _PD_typeId);
+  return static_cast<@name@*>(_NP_is_a(_e, _PD_typeId));
 }
 
 const @scoped_name@* @scoped_name@::_downcast(const CORBA::Exception* _e) {
-  return (const @name@*) _NP_is_a(_e, _PD_typeId);
+  return static_cast<const @name@*>(_NP_is_a(_e, _PD_typeId));
 }
 
 CORBA::Exception* @scoped_name@::_NP_duplicate() const {
diff -ur omniORB-4.0.6.org/src/lib/omniORB/omniidl_be/cxx/skutil.py omniORB-4.0.6/src/lib/omniORB/omniidl_be/cxx/skutil.py
--- omniORB-4.0.6.org/src/lib/omniORB/omniidl_be/cxx/skutil.py	2003-07-27 12:24:32.000000000 -0700
+++ omniORB-4.0.6/src/lib/omniORB/omniidl_be/cxx/skutil.py	2005-10-08 11:45:26.000000000 -0700
@@ -172,13 +172,16 @@
     if decl:
         assert isinstance(decl, idlast.Declarator)
         dims = decl.sizes() + type.dims()
-        slice_cast = ""
+        slice_cast_pre = ""
+        slice_cast_post = ""
     else:
         dims = type.dims()
         if len(dims) != 1:
-            slice_cast = "(" + type.base(environment) + "_slice" + "*)"
+            slice_cast_pre = "static_cast<" + type.base(environment) + "_slice" + "*>"
+            slice_cast_post = ")"
         else:
-            slice_cast = "(" + d_type.base(environment) + "*)"
+            slice_cast_pre = "static_cast<" + d_type.base(environment) + "*>"
+            slice_cast_post = ")"
 
     if dims != []:
         n_elements = reduce(lambda x,y:x*y, dims, 1)
@@ -199,21 +202,23 @@
             if alignment != "omni::ALIGN_1":
                 to.out("""\
 if (! @where at .marshal_byte_swap()) {
-  @where at .put_octet_array((CORBA::Octet*)(@slice_cast@@name@), at num@, at align@);
+  @where at .put_octet_array((CORBA::Octet*)(@slice_cast_pre@@name@@slice_cast_post@), at num@, at align@);
 }
 else """,
                        where = to_where,
                        name = argname,
-                       slice_cast = slice_cast,
+                       slice_cast = slice_cast_pre,
+                       slice_cast_post = slice_cast_post,
                        num = str(n_elements * elmsize),
                        align = alignment)
                 # Do not return here.
                 # let the code below to deal with the else block.
             else:
-                to.out("@where at .put_octet_array((CORBA::Octet*)(@slice_cast@@name@), at num@);",
+                to.out("@where at .put_octet_array((CORBA::Octet*)(@slice_cast_pre@@name@@slice_cast_post@), at num@);",
                        where = to_where,
                        name = argname,
-                       slice_cast = slice_cast,
+                       slice_cast_pre = slice_cast_pre,
+                       slice_cast_post = slice_cast_post,
                        num = str(n_elements))
                 return
 
@@ -246,9 +251,11 @@
         bounded = str(d_type.type().bound())
 
     if not d_type.is_basic_data_types() and not d_type.enum():
-        type_cast = "(const " + type_name + "&) "
+        type_cast_pre = "static_cast<const " + type_name + "&>("
+        type_cast_post = ")"
     else:
-        type_cast = ""
+        type_cast_pre = ""
+        type_cast_post = ""
 
     special_marshal_functions = {
       idltype.tk_boolean:
@@ -273,14 +280,15 @@
     if special_marshal_functions.has_key(kind):
         out_template = special_marshal_functions[kind]
     else:
-        out_template = "@type_cast@@element_name@ >>= @to_where@;"
+        out_template = "@type_cast_pre@@element_name@@type_cast_post@ >>= @to_where@;"
 
     to.out(out_template,
            to_where = to_where,
            element_name = element_name,
            bounded = bounded,
            type = type_name,
-           type_cast = type_cast)
+           type_cast_pre = type_cast_pre,
+			  type_cast_post = type_cast_post)
     loop.end()
 
     if dims != []:
@@ -307,13 +315,16 @@
     if decl:
         assert isinstance(decl, idlast.Declarator)
         dims = decl.sizes() + type.dims()
-        slice_cast = ""
+        slice_cast_pre = ""
+        slice_cast_post = ""
     else:
         dims = type.dims()
         if len(dims) != 1:
-            slice_cast = "(" + type.base(environment) + "_slice" + "*)"
+            slice_cast_pre = "static_cast<" + type.base(environment) + "_slice" + "*>"
+            slice_cast_post = ")"
         else:
-            slice_cast = "(" + d_type.base(environment) + "*)"
+            slice_cast_pre = "static_cast<" + d_type.base(environment) + "*>"
+            slice_cast_post = ""
 
     if dims != []:
 
@@ -332,11 +343,12 @@
           }
         if array_unmarshal_helpers.has_key(d_type.type().kind()):
             (helper,typecast) = array_unmarshal_helpers[d_type.type().kind()]
-            to.out("@where at .@helper@(@typecast@(@slice_cast@@name@), @num@);",
+            to.out("@where at .@helper@(@typecast@(@slice_cast_pre@@name@@slice_cast_post@), @num@);",
                    helper = helper,
                    where = from_where, typecast = typecast,
                    name = name,
-                   slice_cast = slice_cast,
+                   slice_cast_pre = slice_cast_pre,
+                   slice_cast_post = slice_cast_post,
                    num = str(n_elements))
             return
 
@@ -392,7 +404,7 @@
     if special_unmarshal_functions.has_key(kind):
         out_template = special_unmarshal_functions[kind]
     else:
-        out_template = "(@type@&)@element_name@ <<= @where@;"
+        out_template = "static_cast<@type@&>(@element_name@) <<= @where@;"
 
     to.out(out_template,
            type = type_name,



More information about the omniORB-list mailing list