[Libreoffice-commits] core.git: cli_ure/source

Stephan Bergmann sbergman at redhat.com
Mon Mar 30 03:55:55 PDT 2015


 cli_ure/source/uno_bridge/cli_base.h     |    2 +-
 cli_ure/source/uno_bridge/cli_bridge.cxx |    5 ++---
 cli_ure/source/uno_bridge/cli_data.cxx   |   26 +++++++++++++-------------
 cli_ure/source/uno_bridge/cli_proxy.cxx  |    4 ++--
 4 files changed, 18 insertions(+), 19 deletions(-)

New commits:
commit 50b02731ca8494592a8d9a844530baca0e870e3c
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Mon Mar 30 12:55:22 2015 +0200

    Replace scary reinterpret_casts with OUString::unacquired
    
    ...and actually fix some of them
    
    Change-Id: I3493ceb65f305466d167304bd77058adb042067c

diff --git a/cli_ure/source/uno_bridge/cli_base.h b/cli_ure/source/uno_bridge/cli_base.h
index 47aa720..8c29e66 100644
--- a/cli_ure/source/uno_bridge/cli_base.h
+++ b/cli_ure/source/uno_bridge/cli_base.h
@@ -160,7 +160,7 @@ inline TypeDescr::TypeDescr( typelib_TypeDescriptionReference * td_ref )
     {
         throw BridgeRuntimeError(
             "cannot get comprehensive type description for " +
-            *reinterpret_cast< OUString const * >( &td_ref->pTypeName ) );
+            OUString::unacquired(&td_ref->pTypeName) );
     }
 }
 
diff --git a/cli_ure/source/uno_bridge/cli_bridge.cxx b/cli_ure/source/uno_bridge/cli_bridge.cxx
index 279c4bb..241581d 100644
--- a/cli_ure/source/uno_bridge/cli_bridge.cxx
+++ b/cli_ure/source/uno_bridge/cli_bridge.cxx
@@ -296,10 +296,9 @@ SAL_DLLPUBLIC_EXPORT void SAL_CALL uno_ext_getMapping(
     }
 
 
-    OUString const & from_env_typename = *reinterpret_cast< OUString const * >(
+    OUString const & from_env_typename = OUString::unacquired(
         &pFrom->pTypeName );
-    OUString const & to_env_typename = *reinterpret_cast< OUString const * >(
-        &pTo->pTypeName );
+    OUString const & to_env_typename = OUString::unacquired( &pTo->pTypeName );
 
     uno_Mapping * mapping = 0;
 
diff --git a/cli_ure/source/uno_bridge/cli_data.cxx b/cli_ure/source/uno_bridge/cli_data.cxx
index 68cd3aa..5a8a4ac 100644
--- a/cli_ure/source/uno_bridge/cli_data.cxx
+++ b/cli_ure/source/uno_bridge/cli_data.cxx
@@ -1069,7 +1069,7 @@ void Bridge::map_to_uno(void * uno_data, System::Object^ cli_data,
                             }
                             else
                             {
-                                throw BridgeRuntimeError("[map_to_uno(): Member: " + *reinterpret_cast< OUString const * >(comp_td->ppMemberNames[nPos]));
+                                throw BridgeRuntimeError("[map_to_uno(): Member: " + OUString::unacquired(&comp_td->ppMemberNames[nPos]));
                             }
                         }
                         else
@@ -1167,7 +1167,7 @@ void Bridge::map_to_uno(void * uno_data, System::Object^ cli_data,
                 OUString str = "[map_to_uno():";
                 if (cliType)
                 {
-                    str += mapCliString(cliType->FullName) + "." + *reinterpret_cast< OUString const * >(comp_td->ppMemberNames[nPos]) + " ";
+                    str += mapCliString(cliType->FullName) + "." + OUString::unacquired(&comp_td->ppMemberNames[nPos]) + " ";
                 }
                 str += e.m_message;
                 throw BridgeRuntimeError(str);
@@ -1178,7 +1178,7 @@ void Bridge::map_to_uno(void * uno_data, System::Object^ cli_data,
                 OUString str = "[map_to_uno():";
                 if (cliType)
                 {
-                    str += mapCliString(cliType->FullName) + "." + *reinterpret_cast< OUString const * >(comp_td->ppMemberNames[nPos]);
+                    str += mapCliString(cliType->FullName) + "." + OUString::unacquired(&comp_td->ppMemberNames[nPos]);
                 }
                 str += "] Value has not the required type.";
                 throw BridgeRuntimeError(str);
@@ -1345,20 +1345,20 @@ void Bridge::map_to_uno(void * uno_data, System::Object^ cli_data,
                     }
                     default:
                     {
-                        throw BridgeRuntimeError("[map_to_uno():" + *reinterpret_cast< OUString const * >( &type->pTypeName ) +
-                            "] unsupported sequence element type: " + *reinterpret_cast< OUString const * >( &element_type->pTypeName ));
+                        throw BridgeRuntimeError("[map_to_uno():" + OUString::unacquired( &type->pTypeName ) +
+                            "] unsupported sequence element type: " + OUString::unacquired( &element_type->pTypeName ));
                     }
                     }
                 }
                 catch (BridgeRuntimeError& e)
                 {
-                    throw BridgeRuntimeError("[map_to_uno():" + *reinterpret_cast< OUString const * >( &type->pTypeName ) + "] conversion failed\n " + e.m_message);
+                    throw BridgeRuntimeError("[map_to_uno():" + OUString::unacquired( &type->pTypeName ) + "] conversion failed\n " + e.m_message);
                 }
                 catch (System::InvalidCastException^ )
                 {
                     // Ok, checked
-                    throw BridgeRuntimeError("[map_to_uno():" + *reinterpret_cast< OUString const * >( &type->pTypeName) +
-                        "] could not convert sequence element type: " + *reinterpret_cast< OUString const * >( &element_type->pTypeName ));
+                    throw BridgeRuntimeError("[map_to_uno():" + OUString::unacquired( &type->pTypeName) +
+                        "] could not convert sequence element type: " + OUString::unacquired( &element_type->pTypeName ));
                 }
                 catch (...)
                 {
@@ -1401,7 +1401,7 @@ void Bridge::map_to_uno(void * uno_data, System::Object^ cli_data,
         default:
         {
             //ToDo check
-            throw BridgeRuntimeError("[map_to_uno():" + *reinterpret_cast< OUString const * >( &type->pTypeName ) + "] unsupported type!");
+            throw BridgeRuntimeError("[map_to_uno():" + OUString::unacquired( &type->pTypeName ) + "] unsupported type!");
         }
         }
     }
@@ -1409,7 +1409,7 @@ void Bridge::map_to_uno(void * uno_data, System::Object^ cli_data,
     catch (System::InvalidCastException^ )
     {
         //ToDo check
-        throw BridgeRuntimeError("[map_to_uno():" + *reinterpret_cast< OUString const * >( &type->pTypeName ) + "] could not convert type!");
+        throw BridgeRuntimeError("[map_to_uno():" + OUString::unacquired( &type->pTypeName ) + "] could not convert type!");
     }
     catch (System::NullReferenceException ^ e)
     {
@@ -1892,8 +1892,8 @@ void Bridge::map_to_cli(
         }
         default:
         {
-            throw BridgeRuntimeError("[map_to_cli():" + *reinterpret_cast< OUString const * >( &type->pTypeName ) +
-                "] unsupported element type: " + *reinterpret_cast< OUString const * >( &element_type->pTypeName ));
+            throw BridgeRuntimeError("[map_to_cli():" + OUString::unacquired( &type->pTypeName ) +
+                "] unsupported element type: " + OUString::unacquired( &element_type->pTypeName ));
         }
         }
         break;
@@ -1914,7 +1914,7 @@ void Bridge::map_to_cli(
     default:
     {
         //ToDo check this exception. The String is probably crippled
-        throw BridgeRuntimeError("[map_to_cli():" + *reinterpret_cast< OUString const * >( &type->pTypeName ) + "] unsupported type!");
+        throw BridgeRuntimeError("[map_to_cli():" + OUString::unacquired( &type->pTypeName ) + "] unsupported type!");
     }
     } //switch
 } // method
diff --git a/cli_ure/source/uno_bridge/cli_proxy.cxx b/cli_ure/source/uno_bridge/cli_proxy.cxx
index 90add1d..85489b3 100644
--- a/cli_ure/source/uno_bridge/cli_proxy.cxx
+++ b/cli_ure/source/uno_bridge/cli_proxy.cxx
@@ -79,7 +79,7 @@ UnoInterfaceInfo::UnoInterfaceInfo(Bridge const * bridge, uno_Interface* unoI,
         sal_Bool bComplete = ::typelib_typedescription_complete( & _pt);
         if( ! bComplete)
         {
-            throw BridgeRuntimeError("cannot make type complete: " + *reinterpret_cast< OUString const * >(& m_typeDesc->aBase.pTypeName));
+            throw BridgeRuntimeError("cannot make type complete: " + OUString::unacquired(& m_typeDesc->aBase.pTypeName));
         }
     }
 }
@@ -542,7 +542,7 @@ srrm::IMessage^ UnoInterfaceProxy::Invoke(srrm::IMessage^ callmsg)
         // ToDo check if the message of the exception is not crippled
         // the thing that should not be... no method info found!
         throw BridgeRuntimeError("[cli_uno bridge]calling undeclared function on interface " +
-            *reinterpret_cast< OUString const * >(& ((typelib_TypeDescription *)info->m_typeDesc)->pTypeName) +
+            OUString::unacquired(& ((typelib_TypeDescription *)info->m_typeDesc)->pTypeName) +
             ": " + usMethodName);
     }
     catch (BridgeRuntimeError & err)


More information about the Libreoffice-commits mailing list