This is an automated email from the ASF dual-hosted git repository. leginee pushed a commit to branch win10-msvc-trunk in repository https://gitbox.apache.org/repos/asf/openoffice.git
commit ffe4980d48415aa953d95cda65387546f9f391e4 Author: Peter Kovacs <[email protected]> AuthorDate: Fri Aug 21 20:23:23 2026 +0200 cli_ure: the .NET bridge compiles and links cli_uno.dll builds, alongside cli_basetypes, cli_uretypes, cli_ure and the three policy assemblies. Two of the three pieces of the binding are done; native/ remains. Beyond the mechanical conversion already described in 13d3177df7, the compiler found these, none of which a table of syntax rules would have predicted: NAMESPACE ALIASES. This module reaches System:: through sc, sd, sr, sre, sri, srr, srrm, srrp and st. The first pass only knew the spelled-out namespaces, so 67 pointers stayed pointers. NATIVE POINTERS TO VALUE TYPES. *(System::Int32 *) uno_data reads raw UNO memory as a value type. System::Int32 is a value class, so that is a plain pointer and not a handle -- the blanket System::* -> ^ rule got 13 of these wrong and they had to go back. CliProxy IS NATIVE. It derives from uno_Interface and merely looks managed; the cli_uno:: prefix made the qualified pass claim it. __property. MC++ spelled a property as get_X/set_X method pair. C++/CLI has property syntax, and because UnoInterfaceProxy implements IRemotingTypeInfo the accessors have to be virtual. MARSHAL::COPY HAS NO UNSIGNED OR BOOLEAN OVERLOADS. The original cast ushort[] to short[] with static_cast, which C++/CLI will not do between managed array types -- but the CLR treats them as assignment-compatible, so the cast moves to the safe_cast of cli_data itself. bool[] goes the same way via byte[]. Copy's raw destination also needs an explicit IntPtr now. &args[n] ON A MANAGED ARRAY. args was a native array of handles, so &args[n] was an Object**. A cli::array element has no native address, so those calls go through a local and assign back. A REGEX THAT ATE A COMMENT. The pointer rule matched "System::Type" across a newline onto the "*" of the following "*/", turning it into "^/" and commenting out 250 lines. Everything in them was then invisible to the compiler, which is why the error count went UP as it was fixed. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01W7pjcp2sXU1HaUwXT7kc29 --- main/cli_ure/source/uno_bridge/cli_bridge.cxx | 11 +- main/cli_ure/source/uno_bridge/cli_bridge.h | 4 +- main/cli_ure/source/uno_bridge/cli_data.cxx | 260 ++++++++++----------- main/cli_ure/source/uno_bridge/cli_environment.cxx | 10 +- main/cli_ure/source/uno_bridge/cli_proxy.cxx | 152 ++++++------ main/cli_ure/source/uno_bridge/cli_proxy.h | 46 ++-- main/cli_ure/source/uno_bridge/cli_uno.cxx | 26 ++- 7 files changed, 262 insertions(+), 247 deletions(-) diff --git a/main/cli_ure/source/uno_bridge/cli_bridge.cxx b/main/cli_ure/source/uno_bridge/cli_bridge.cxx index 1d091121b1..2314e21555 100644 --- a/main/cli_ure/source/uno_bridge/cli_bridge.cxx +++ b/main/cli_ure/source/uno_bridge/cli_bridge.cxx @@ -95,7 +95,7 @@ void SAL_CALL Mapping_cli2uno( if (0 != cliI) { - System::Object ^ cliObj= sri::GCHandle::op_Explicit(cliI).Target; + System::Object ^ cliObj= sri::GCHandle::FromIntPtr(System::IntPtr(cliI)).Target; (*ppOut)= bridge->map_cli2uno(cliObj, (typelib_TypeDescription*) td); } } @@ -140,7 +140,12 @@ void SAL_CALL Mapping_uno2cli( if (0 != *ppDNetI) { - sri::GCHandle::op_Explicit(ppDNetI).Free(); + // op_Explicit was MC++'s spelling of the conversion operator; + // C++/CLI names it FromIntPtr. Kept faithful to the original, + // which converts the POINTER and not *ppDNetI -- see the guard + // just above. That looks wrong, but changing it is a + // behavioural fix and does not belong in a syntax port. + sri::GCHandle::FromIntPtr(System::IntPtr(ppDNetI)).Free(); } if (0 != pUnoI) @@ -149,7 +154,7 @@ void SAL_CALL Mapping_uno2cli( intptr_t ptr= NULL; if(cliI) { - ptr= sri::GCHandle::op_Explicit(sri::GCHandle::Alloc(cliI)) + ptr= sri::GCHandle::ToIntPtr(sri::GCHandle::Alloc(cliI)) #ifdef _WIN32 .ToInt32(); #else /* defined(_WIN64) */ .ToInt64(); diff --git a/main/cli_ure/source/uno_bridge/cli_bridge.h b/main/cli_ure/source/uno_bridge/cli_bridge.h index 1aa44bdd49..3f98b915a4 100644 --- a/main/cli_ure/source/uno_bridge/cli_bridge.h +++ b/main/cli_ure/source/uno_bridge/cli_bridge.h @@ -52,7 +52,7 @@ struct Mapping : public uno_Mapping //Managed cli environment for cli objects an UNO proxies (which are cli //objects. The uno_Environment is not used for cli objects. ref struct CliEnvHolder { -static Cli_environment ^ g_cli_env = NULL; +static Cli_environment ^ g_cli_env = nullptr; }; //================================================================================================== @@ -100,7 +100,7 @@ struct Bridge void call_cli( - System::Object ^ cliI, sr::MethodInfo* method, + System::Object ^ cliI, sr::MethodInfo ^ method, typelib_TypeDescriptionReference * return_type, typelib_MethodParameter * params, int nParams, void * uno_ret, void * uno_args [], uno_Any ** uno_exc ) const; diff --git a/main/cli_ure/source/uno_bridge/cli_data.cxx b/main/cli_ure/source/uno_bridge/cli_data.cxx index 1419835097..0bd15c4261 100644 --- a/main/cli_ure/source/uno_bridge/cli_data.cxx +++ b/main/cli_ure/source/uno_bridge/cli_data.cxx @@ -75,7 +75,7 @@ inline auto_ptr< rtl_mem > seq_allocate( sal_Int32 nElements, sal_Int32 nSize ) System::Object ^ Bridge::map_uno2cli(uno_Interface * pUnoI, typelib_InterfaceTypeDescription *pTD) const { - System::Object ^ retVal= NULL; + System::Object ^ retVal= nullptr; // get oid rtl_uString * pOid = 0; (*m_uno_env->getObjectIdentifier)( m_uno_env, &pOid, pUnoI ); @@ -153,7 +153,7 @@ inline System::Type ^ loadCliType(rtl_uString * unoName) System::Type ^ loadCliType(System::String ^ unoName) { - System::Type ^ retVal= NULL; + System::Type ^ retVal= nullptr; try { //If unoName denotes a polymorphic type, e.g com.sun.star.beans.Defaulted<System.Char> @@ -168,7 +168,7 @@ System::Type ^ loadCliType(System::String ^ unoName) bIsPolymorphic = true; } System::AppDomain ^ currentDomain = System::AppDomain::CurrentDomain; - sr::Assembly* assems[] = currentDomain->GetAssemblies(); + cli::array< sr::Assembly ^ > ^ assems = currentDomain->GetAssemblies(); for (int i = 0; i < assems->Length; i++) { retVal = assems[i]->GetType(loadName, false); @@ -176,7 +176,7 @@ System::Type ^ loadCliType(System::String ^ unoName) break; } - if (retVal == NULL) + if (retVal == nullptr) { System::String ^ msg = gcnew System::String("A type could not be loaded: "); msg = System::String::Concat(msg, loadName); @@ -204,7 +204,7 @@ System::Type ^ mapUnoType(typelib_TypeDescription const * pTD) System::Type ^ mapUnoType(typelib_TypeDescriptionReference const * pTD) { - System::Type ^ retVal = 0; + System::Type ^ retVal = nullptr; switch (pTD->eTypeClass) { case typelib_TypeClass_VOID: @@ -326,7 +326,7 @@ System::Type ^ mapUnoType(typelib_TypeDescriptionReference const * pTD) typelib_TypeDescriptionReference* mapCliType(System::Type ^ cliType) { typelib_TypeDescriptionReference* retVal= NULL; - if (cliType == NULL) + if (cliType == nullptr) { retVal = * typelib_static_type_getByTypeClass( typelib_TypeClass_VOID ); @@ -442,7 +442,7 @@ typelib_TypeDescriptionReference* mapCliType(System::Type ^ cliType) { OUString usTypeName; uno::PolymorphicType ^ poly = dynamic_cast<uno::PolymorphicType ^>(cliType); - if (poly != NULL) + if (poly != nullptr) usTypeName = mapCliTypeName( poly->PolymorphicName); else usTypeName = mapCliTypeName(cliTypeName); @@ -474,7 +474,7 @@ typelib_TypeDescriptionReference* mapCliType(System::Type ^ cliType) System::String ^ mapUnoTypeName(rtl_uString const * typeName) { OUString usUnoName( const_cast< rtl_uString * >( typeName ) ); - st::StringBuilder* buf= new st::StringBuilder(); + st::StringBuilder ^ buf= gcnew st::StringBuilder(); //determine if the type is a sequence and its dimensions int dims= 0; if (usUnoName[0] == '[') @@ -584,7 +584,7 @@ System::String ^ mapPolymorphicName(System::String ^ unoName, bool bCliToUno) int countParams = 0; while (cur <= endIndex) { - System::Char c = unoName->Chars[cur]; + System::Char c = unoName[cur]; if (c == ',' || c == '>') { //insert a comma if needed @@ -613,7 +613,7 @@ System::String ^ mapPolymorphicName(System::String ^ unoName, bool bCliToUno) int numNested = 0; for (;;cur++) { - System::Char curChar = unoName->Chars[cur]; + System::Char curChar = unoName[cur]; if (curChar == '<') { numNested ++; @@ -645,7 +645,7 @@ OUString mapCliTypeName(System::String ^ typeName) bool bRightBracket = false; while (cur >= 0) { - System::Char c = typeName->Chars[cur]; + System::Char c = typeName[cur]; if (c == ']') { bRightBracket = true; @@ -724,7 +724,8 @@ OUString mapCliTypeName(System::String ^ typeName) return mapCliString(buf->ToString()); } /** Maps uno types to dot net types. - * If uno_data is null then the type description is converted to System::Type ^/ + * If uno_data is null then the type description is converted to System::Type + */ inline System::String ^ mapUnoString( rtl_uString const * data) { OSL_ASSERT(data); @@ -734,7 +735,7 @@ inline System::String ^ mapUnoString( rtl_uString const * data) OUString mapCliString(System::String ^ data) { - if (data != NULL) + if (data != nullptr) { OSL_ASSERT(sizeof(wchar_t) == sizeof(sal_Unicode)); pin_ptr< wchar_t const > pdata= PtrToStringChars(data); @@ -760,67 +761,67 @@ void Bridge::map_to_uno(void * uno_data, System::Object ^ cli_data, break; case typelib_TypeClass_CHAR: { - System::Char aChar= *safe_cast< System::Char ^ >(cli_data); + System::Char aChar= safe_cast< System::Char >(cli_data); *(sal_Unicode*) uno_data= aChar; break; } case typelib_TypeClass_BOOLEAN: { - System::Boolean aBool= *safe_cast< System::Boolean ^ >(cli_data); + System::Boolean aBool= safe_cast< System::Boolean >(cli_data); *(sal_Bool*)uno_data= aBool == true ? sal_True : sal_False; break; } case typelib_TypeClass_BYTE: { - System::Byte aByte= *safe_cast< System::Byte ^ >(cli_data); + System::Byte aByte= safe_cast< System::Byte >(cli_data); *(sal_Int8*) uno_data= aByte; break; } case typelib_TypeClass_SHORT: { - System::Int16 aShort= *safe_cast< System::Int16 ^ >(cli_data); + System::Int16 aShort= safe_cast< System::Int16 >(cli_data); *(sal_Int16*) uno_data= aShort; break; } case typelib_TypeClass_UNSIGNED_SHORT: { - System::UInt16 aUShort= *safe_cast< System::UInt16 ^ >(cli_data); + System::UInt16 aUShort= safe_cast< System::UInt16 >(cli_data); *(sal_uInt16*) uno_data= aUShort; break; } case typelib_TypeClass_LONG: { - System::Int32 aLong= *safe_cast< System::Int32 ^ >(cli_data); + System::Int32 aLong= safe_cast< System::Int32 >(cli_data); *(sal_Int32*) uno_data= aLong; break; } case typelib_TypeClass_UNSIGNED_LONG: { - System::UInt32 aULong= *safe_cast< System::UInt32 ^ >(cli_data); + System::UInt32 aULong= safe_cast< System::UInt32 >(cli_data); *(sal_uInt32*) uno_data= aULong; break; } case typelib_TypeClass_HYPER: { - System::Int64 aHyper= *safe_cast< System::Int64 ^ >(cli_data); + System::Int64 aHyper= safe_cast< System::Int64 >(cli_data); *(sal_Int64*) uno_data= aHyper; break; } case typelib_TypeClass_UNSIGNED_HYPER: { - System::UInt64 aLong= *safe_cast< System::UInt64 ^ >(cli_data); + System::UInt64 aLong= safe_cast< System::UInt64 >(cli_data); *(sal_uInt64*) uno_data= aLong; break; } case typelib_TypeClass_FLOAT: { - System::Single aFloat= *safe_cast< System::Single ^ >(cli_data); + System::Single aFloat= safe_cast< System::Single >(cli_data); *(float*) uno_data= aFloat; break; } case typelib_TypeClass_DOUBLE: { - System::Double aDouble= *safe_cast< System::Double ^ >(cli_data); + System::Double aDouble= safe_cast< System::Double >(cli_data); *(double*) uno_data= aDouble; break; } @@ -865,7 +866,7 @@ void Bridge::map_to_uno(void * uno_data, System::Object ^ cli_data, uno_any_construct( pAny, 0, 0, 0 ); break; } - uno::Any aAny= *safe_cast< uno::Any >(cli_data); + uno::Any aAny= safe_cast< uno::Any >(cli_data); css::uno::Type value_td( mapCliType(aAny.Type), SAL_NO_ACQUIRE); if (assign) @@ -880,42 +881,42 @@ void Bridge::map_to_uno(void * uno_data, System::Object ^ cli_data, break; case typelib_TypeClass_CHAR: pAny->pData = &pAny->pReserved; - *(sal_Unicode*) &pAny->pReserved = *safe_cast< System::Char ^ >(aAny.Value); + *(sal_Unicode*) &pAny->pReserved = safe_cast< System::Char >(aAny.Value); break; case typelib_TypeClass_BOOLEAN: pAny->pData = &pAny->pReserved; - *(sal_Bool *) &pAny->pReserved = *safe_cast< System::Boolean ^ >(aAny.Value); + *(sal_Bool *) &pAny->pReserved = safe_cast< System::Boolean >(aAny.Value); break; case typelib_TypeClass_BYTE: pAny->pData = &pAny->pReserved; - *(sal_Int8*) &pAny->pReserved = *safe_cast< System::Byte ^ >(aAny.Value); + *(sal_Int8*) &pAny->pReserved = safe_cast< System::Byte >(aAny.Value); break; case typelib_TypeClass_SHORT: pAny->pData = &pAny->pReserved; - *(sal_Int16*) &pAny->pReserved = *safe_cast< System::Int16 ^ >(aAny.Value); + *(sal_Int16*) &pAny->pReserved = safe_cast< System::Int16 >(aAny.Value); break; case typelib_TypeClass_UNSIGNED_SHORT: pAny->pData = &pAny->pReserved; - *(sal_uInt16*) &pAny->pReserved = *safe_cast< System::UInt16 ^ >(aAny.Value); + *(sal_uInt16*) &pAny->pReserved = safe_cast< System::UInt16 >(aAny.Value); break; case typelib_TypeClass_LONG: pAny->pData = &pAny->pReserved; - *(sal_Int32*) &pAny->pReserved = *safe_cast< System::Int32 ^ >(aAny.Value); + *(sal_Int32*) &pAny->pReserved = safe_cast< System::Int32 >(aAny.Value); break; case typelib_TypeClass_UNSIGNED_LONG: pAny->pData = &pAny->pReserved; - *(sal_uInt32*) &pAny->pReserved = *safe_cast< System::UInt32 ^ >(aAny.Value); + *(sal_uInt32*) &pAny->pReserved = safe_cast< System::UInt32 >(aAny.Value); break; case typelib_TypeClass_HYPER: if (sizeof (sal_Int64) <= sizeof (void *)) { pAny->pData = &pAny->pReserved; - *(sal_Int64*) &pAny->pReserved = *safe_cast< System::Int64 ^ >(aAny.Value); + *(sal_Int64*) &pAny->pReserved = safe_cast< System::Int64 >(aAny.Value); } else { auto_ptr< rtl_mem > mem( rtl_mem::allocate( sizeof (sal_Int64) ) ); - *(sal_Int64 *) mem.get()= *safe_cast< System::Int64 ^ >(aAny.Value); + *(sal_Int64 *) mem.get()= safe_cast< System::Int64 >(aAny.Value); pAny->pData = mem.release(); } break; @@ -923,12 +924,12 @@ void Bridge::map_to_uno(void * uno_data, System::Object ^ cli_data, if (sizeof (sal_uInt64) <= sizeof (void *)) { pAny->pData = &pAny->pReserved; - *(sal_uInt64*) &pAny->pReserved = *safe_cast< System::UInt64 ^ >(aAny.Value); + *(sal_uInt64*) &pAny->pReserved = safe_cast< System::UInt64 >(aAny.Value); } else { auto_ptr< rtl_mem > mem( rtl_mem::allocate( sizeof (sal_uInt64) ) ); - *(sal_uInt64 *) mem.get()= *safe_cast< System::UInt64 ^ >(aAny.Value); + *(sal_uInt64 *) mem.get()= safe_cast< System::UInt64 >(aAny.Value); pAny->pData = mem.release(); } break; @@ -936,12 +937,12 @@ void Bridge::map_to_uno(void * uno_data, System::Object ^ cli_data, if (sizeof (float) <= sizeof (void *)) { pAny->pData = &pAny->pReserved; - *(float*) &pAny->pReserved = *safe_cast< System::Single ^ >(aAny.Value); + *(float*) &pAny->pReserved = safe_cast< System::Single >(aAny.Value); } else { auto_ptr< rtl_mem > mem( rtl_mem::allocate( sizeof (float) ) ); - *(float*) mem.get() = *safe_cast< System::Single ^ >(aAny.Value); + *(float*) mem.get() = safe_cast< System::Single >(aAny.Value); pAny->pData = mem.release(); } break; @@ -949,12 +950,12 @@ void Bridge::map_to_uno(void * uno_data, System::Object ^ cli_data, if (sizeof (double) <= sizeof (void *)) { pAny->pData = &pAny->pReserved; - *(double*) &pAny->pReserved= *safe_cast< System::Double ^ >(aAny.Value); + *(double*) &pAny->pReserved= safe_cast< System::Double >(aAny.Value); } else { auto_ptr< rtl_mem > mem( rtl_mem::allocate( sizeof (double) ) ); - *(double*) mem.get()= *safe_cast< System::Double ^ >(aAny.Value); + *(double*) mem.get()= safe_cast< System::Double >(aAny.Value); pAny->pData= mem.release(); } break; @@ -1062,7 +1063,7 @@ void Bridge::map_to_uno(void * uno_data, System::Object ^ cli_data, sal_Int32 nMembers = comp_td->nMembers; boolean bException= false; - System::Type ^ cliType = NULL; + System::Type ^ cliType = nullptr; if (cli_data) cliType = cli_data->GetType(); @@ -1084,14 +1085,14 @@ void Bridge::map_to_uno(void * uno_data, System::Object ^ cli_data, member_type= comp_td->ppTypeRefs[nPos]; #if OSL_DEBUG_LEVEL >= 2 System::String ^ __s; - sr::FieldInfo* arFields[]; + cli::array< sr::FieldInfo ^ > ^ arFields; __s = mapUnoString(comp_td->ppMemberNames[nPos]); arFields = cliType != NULL ? cliType->GetFields() : NULL; #endif - System::Object ^ val= NULL; + System::Object ^ val= nullptr; if (cli_data != NULL) { - sr::FieldInfo* aField= cliType->GetField( + sr::FieldInfo ^ aField= cliType->GetField( mapUnoString(comp_td->ppMemberNames[nPos])); // special case for Exception.Message property // The com.sun.star.uno.Exception.Message field is mapped to the @@ -1101,9 +1102,9 @@ void Bridge::map_to_uno(void * uno_data, System::Object ^ cli_data, rtl::OUString usMessageMember(RTL_CONSTASCII_USTRINGPARAM("Message")); if (usMessageMember.equals(comp_td->ppMemberNames[nPos])) { - sr::PropertyInfo* pi= cliType->GetProperty( + sr::PropertyInfo ^ pi= cliType->GetProperty( mapUnoString(comp_td->ppMemberNames[nPos])); - val= pi->GetValue(cli_data, NULL); + val= pi->GetValue(cli_data, nullptr); } else { @@ -1132,67 +1133,67 @@ void Bridge::map_to_uno(void * uno_data, System::Object ^ cli_data, if (bDefault) *(sal_Unicode*) p = 0; else - *(sal_Unicode*) p = *safe_cast< System::Char ^ >(val); + *(sal_Unicode*) p = safe_cast< System::Char >(val); break; case typelib_TypeClass_BOOLEAN: if (bDefault) *(sal_Bool*) p = sal_False; else - *(sal_Bool*) p = *safe_cast< System::Boolean ^ >(val); + *(sal_Bool*) p = safe_cast< System::Boolean >(val); break; case typelib_TypeClass_BYTE: if (bDefault) *(sal_Int8*) p = 0; else - *(sal_Int8*) p = *safe_cast< System::Byte ^ >(val); + *(sal_Int8*) p = safe_cast< System::Byte >(val); break; case typelib_TypeClass_SHORT: if (bDefault) *(sal_Int16*) p = 0; else - *(sal_Int16*) p = *safe_cast< System::Int16 ^ >(val); + *(sal_Int16*) p = safe_cast< System::Int16 >(val); break; case typelib_TypeClass_UNSIGNED_SHORT: if (bDefault) *(sal_uInt16*) p = 0; else - *(sal_uInt16*) p = *safe_cast< System::UInt16 ^ >(val); + *(sal_uInt16*) p = safe_cast< System::UInt16 >(val); break; case typelib_TypeClass_LONG: if (bDefault) *(sal_Int32*) p = 0; else - *(sal_Int32*) p = *safe_cast< System::Int32 ^ >(val); + *(sal_Int32*) p = safe_cast< System::Int32 >(val); break; case typelib_TypeClass_UNSIGNED_LONG: if (bDefault) *(sal_uInt32*) p = 0; else - *(sal_uInt32*) p = *safe_cast< System::UInt32 ^ >(val); + *(sal_uInt32*) p = safe_cast< System::UInt32 >(val); break; case typelib_TypeClass_HYPER: if (bDefault) *(sal_Int64*) p = 0; else - *(sal_Int64*) p = *safe_cast< System::Int64 ^ >(val); + *(sal_Int64*) p = safe_cast< System::Int64 >(val); break; case typelib_TypeClass_UNSIGNED_HYPER: if (bDefault) *(sal_uInt64*) p = 0; else - *(sal_uInt64*) p= *safe_cast< System::UInt64 ^ >(val); + *(sal_uInt64*) p= safe_cast< System::UInt64 >(val); break; case typelib_TypeClass_FLOAT: if (bDefault) *(float*) p = 0.; else - *(float*) p = *safe_cast< System::Single ^ >(val); + *(float*) p = safe_cast< System::Single >(val); break; case typelib_TypeClass_DOUBLE: if (bDefault) *(double*) p = 0.; else - *(double*) p = *safe_cast< System::Double ^ >(val); + *(double*) p = safe_cast< System::Double >(val); break; default: { // ToDo enum, should be converted here @@ -1264,7 +1265,7 @@ void Bridge::map_to_uno(void * uno_data, System::Object ^ cli_data, auto_ptr< rtl_mem > seq; - System::Array ^ ar = NULL; + System::Array ^ ar = nullptr; if (cli_data != NULL) { ar = safe_cast< System::Array ^ >(cli_data); @@ -1277,60 +1278,57 @@ void Bridge::map_to_uno(void * uno_data, System::Object ^ cli_data, case typelib_TypeClass_CHAR: seq = seq_allocate(nElements, sizeof (sal_Unicode)); sri::Marshal::Copy(safe_cast< cli::array< System::Char > ^ >(cli_data), 0, - & ((uno_Sequence*) seq.get())->elements, nElements); + System::IntPtr(& ((uno_Sequence*) seq.get())->elements), nElements); break; case typelib_TypeClass_BOOLEAN: seq = seq_allocate(nElements, sizeof (sal_Bool)); - sri::Marshal::Copy(safe_cast< cli::array< System::Boolean > ^ >(cli_data), 0, - & ((uno_Sequence*) seq.get())->elements, nElements); + sri::Marshal::Copy(safe_cast< cli::array< System::Byte > ^ >(cli_data), 0, + System::IntPtr(& ((uno_Sequence*) seq.get())->elements), nElements); break; case typelib_TypeClass_BYTE: seq = seq_allocate( nElements, sizeof (sal_Int8) ); sri::Marshal::Copy(safe_cast< cli::array< System::Byte > ^ >(cli_data), 0, - & ((uno_Sequence*) seq.get())->elements, nElements); + System::IntPtr(& ((uno_Sequence*) seq.get())->elements), nElements); break; case typelib_TypeClass_SHORT: seq = seq_allocate(nElements, sizeof (sal_Int16)); sri::Marshal::Copy(safe_cast< cli::array< System::Int16 > ^ >(cli_data), 0, - & ((uno_Sequence*) seq.get())->elements, nElements); + System::IntPtr(& ((uno_Sequence*) seq.get())->elements), nElements); break; case typelib_TypeClass_UNSIGNED_SHORT: seq = seq_allocate( nElements, sizeof (sal_uInt16) ); - sri::Marshal::Copy(static_cast<System::Int16[]>( - safe_cast< cli::array< System::UInt16 > ^ >(cli_data)), 0, - & ((uno_Sequence*) seq.get())->elements, nElements); + sri::Marshal::Copy(safe_cast< cli::array< System::Int16 > ^ >(cli_data), 0, + System::IntPtr(& ((uno_Sequence*) seq.get())->elements), nElements); break; case typelib_TypeClass_LONG: seq = seq_allocate(nElements, sizeof (sal_Int32)); sri::Marshal::Copy(safe_cast< cli::array< System::Int32 > ^ >(cli_data), 0, - & ((uno_Sequence*) seq.get())->elements, nElements); + System::IntPtr(& ((uno_Sequence*) seq.get())->elements), nElements); break; case typelib_TypeClass_UNSIGNED_LONG: seq = seq_allocate( nElements, sizeof (sal_uInt32) ); - sri::Marshal::Copy(static_cast<System::Int32[]>( - safe_cast< cli::array< System::UInt32 > ^ >(cli_data)), 0, - & ((uno_Sequence*) seq.get())->elements, nElements); + sri::Marshal::Copy(safe_cast< cli::array< System::Int32 > ^ >(cli_data), 0, + System::IntPtr(& ((uno_Sequence*) seq.get())->elements), nElements); break; case typelib_TypeClass_HYPER: seq = seq_allocate(nElements, sizeof (sal_Int64)); sri::Marshal::Copy(safe_cast< cli::array< System::Int64 > ^ >(cli_data), 0, - & ((uno_Sequence*) seq.get())->elements, nElements); + System::IntPtr(& ((uno_Sequence*) seq.get())->elements), nElements); break; case typelib_TypeClass_UNSIGNED_HYPER: seq = seq_allocate(nElements, sizeof (sal_uInt64)); - sri::Marshal::Copy(static_cast<System::Int64[]>( - safe_cast< cli::array< System::UInt64 > ^ >(cli_data)), 0, - & ((uno_Sequence*) seq.get())->elements, nElements); + sri::Marshal::Copy(safe_cast< cli::array< System::Int64 > ^ >(cli_data), 0, + System::IntPtr(& ((uno_Sequence*) seq.get())->elements), nElements); break; case typelib_TypeClass_FLOAT: seq = seq_allocate(nElements, sizeof (float)); sri::Marshal::Copy(safe_cast< cli::array< System::Single > ^ >(cli_data), 0, - & ((uno_Sequence*) seq.get())->elements, nElements); + System::IntPtr(& ((uno_Sequence*) seq.get())->elements), nElements); break; case typelib_TypeClass_DOUBLE: seq = seq_allocate(nElements, sizeof (double)); sri::Marshal::Copy(safe_cast< cli::array< System::Double > ^ >(cli_data), 0, - & ((uno_Sequence*) seq.get())->elements, nElements); + System::IntPtr(& ((uno_Sequence*) seq.get())->elements), nElements); break; case typelib_TypeClass_STRING: { @@ -1570,9 +1568,9 @@ void Bridge::map_to_cli( uno_Any const * pAny = (uno_Any const *)uno_data; if (typelib_TypeClass_VOID != pAny->pType->eTypeClass) { - System::Object ^ objCli= NULL; + System::Object ^ objCli= nullptr; map_to_cli( - &objCli, pAny->pData, pAny->pType, 0, + &objCli, pAny->pData, pAny->pType, nullptr, false); uno::Any anyVal(mapUnoType(pAny->pType), objCli); @@ -1586,15 +1584,15 @@ void Bridge::map_to_cli( } case typelib_TypeClass_ENUM: { - if (info != NULL) + if (info != nullptr) { OSL_ASSERT(info->IsByRef); info= info->GetElementType(); - *cli_data= System::Enum::ToObject(info, *(System::Int32 ^) uno_data); + *cli_data= System::Enum::ToObject(info, *(System::Int32 *) uno_data); } else *cli_data= System::Enum::ToObject( - mapUnoType(type), *(System::Int32 ^) uno_data); + mapUnoType(type), *(System::Int32 *) uno_data); break; } case typelib_TypeClass_STRUCT: @@ -1651,12 +1649,12 @@ void Bridge::map_to_cli( ((char*) uno_data + offset)); //We need to find a constructor for the exception that takes the message string //We assume that the first argument is the message string - sr::ConstructorInfo* arCtorInfo[] = cliType->GetConstructors(); - sr::ConstructorInfo* ctorInfo = NULL; + cli::array< sr::ConstructorInfo ^ > ^ arCtorInfo = cliType->GetConstructors(); + sr::ConstructorInfo ^ ctorInfo = nullptr; int numCtors = arCtorInfo->Length; //Constructor must at least have 2 params for the base //unoidl.com.sun.star.uno.Exception (String, Object); - sr::ParameterInfo * arParamInfo[]; + cli::array< sr::ParameterInfo ^ > ^ arParamInfo; for (int i = 0; i < numCtors; i++) { arParamInfo = arCtorInfo[i]->GetParameters(); @@ -1671,7 +1669,7 @@ void Bridge::map_to_cli( && arParamInfo[1]->Position == 1); //Prepare parameters for constructor int numArgs = arParamInfo->Length; - cli::array< System::Object ^ > ^ args = gcgcnew cli::array< System::Object ^ >( numArgs ); + cli::array< System::Object ^ > ^ args = gcnew cli::array< System::Object ^ >( numArgs ); //only initialize the first argument with the message args[0] = sMessage; cliObj = ctorInfo->Invoke(args); @@ -1688,7 +1686,7 @@ void Bridge::map_to_cli( // cliObj is used by the callee instead of a newly created struct map_to_cli( &cliObj, uno_data, - ((typelib_TypeDescription *)comp_td->pBaseTypeDescription)->pWeakRef, 0, + ((typelib_TypeDescription *)comp_td->pBaseTypeDescription)->pWeakRef, nullptr, true); } rtl::OUString usUnoException(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.uno.Exception")); @@ -1696,7 +1694,7 @@ void Bridge::map_to_cli( { typelib_TypeDescriptionReference * member_type = comp_td->ppTypeRefs[ nPos ]; System::String ^ sMemberName= mapUnoString(comp_td->ppMemberNames[nPos]); - sr::FieldInfo* aField= cliType->GetField(sMemberName); + sr::FieldInfo ^ aField= cliType->GetField(sMemberName); // special case for Exception.Message. The field has already been // set while constructing cli object if ( ! aField && usUnoException.equals(td.get()->pTypeName)) @@ -1707,43 +1705,43 @@ void Bridge::map_to_cli( switch (member_type->eTypeClass) { case typelib_TypeClass_CHAR: - aField->SetValue(cliObj, (::System::Object ^)(*(System::Char ^) p)); + aField->SetValue(cliObj, (::System::Object ^)(*(System::Char *) p)); break; case typelib_TypeClass_BOOLEAN: - aField->SetValue(cliObj, (::System::Object ^)(*(System::Boolean ^) p)); + aField->SetValue(cliObj, (::System::Object ^)(*(System::Boolean *) p)); break; case typelib_TypeClass_BYTE: - aField->SetValue(cliObj, (::System::Object ^)(*(System::Byte ^) p)); + aField->SetValue(cliObj, (::System::Object ^)(*(System::Byte *) p)); break; case typelib_TypeClass_SHORT: - aField->SetValue(cliObj, (::System::Object ^)(*(System::Int16 ^) p)); + aField->SetValue(cliObj, (::System::Object ^)(*(System::Int16 *) p)); break; case typelib_TypeClass_UNSIGNED_SHORT: - aField->SetValue(cliObj, (::System::Object ^)(*(System::UInt16 ^) p)); + aField->SetValue(cliObj, (::System::Object ^)(*(System::UInt16 *) p)); break; case typelib_TypeClass_LONG: - aField->SetValue(cliObj, (::System::Object ^)(*(System::Int32 ^) p)); + aField->SetValue(cliObj, (::System::Object ^)(*(System::Int32 *) p)); break; case typelib_TypeClass_UNSIGNED_LONG: - aField->SetValue(cliObj, (::System::Object ^)(*(System::UInt32 ^) p)); + aField->SetValue(cliObj, (::System::Object ^)(*(System::UInt32 *) p)); break; case typelib_TypeClass_HYPER: - aField->SetValue(cliObj, (::System::Object ^)(*(System::Int64 ^) p)); + aField->SetValue(cliObj, (::System::Object ^)(*(System::Int64 *) p)); break; case typelib_TypeClass_UNSIGNED_HYPER: - aField->SetValue(cliObj, (::System::Object ^)(*(System::UInt64 ^) p)); + aField->SetValue(cliObj, (::System::Object ^)(*(System::UInt64 *) p)); break; case typelib_TypeClass_FLOAT: - aField->SetValue(cliObj, (::System::Object ^)(*(System::Single ^) p)); + aField->SetValue(cliObj, (::System::Object ^)(*(System::Single *) p)); break; case typelib_TypeClass_DOUBLE: - aField->SetValue(cliObj, (::System::Object ^)(*(System::Double ^) p)); + aField->SetValue(cliObj, (::System::Object ^)(*(System::Double *) p)); break; default: { System::Object ^ cli_val; map_to_cli( - &cli_val, p, member_type, 0, + &cli_val, p, member_type, nullptr, false); aField->SetValue(cliObj, cli_val); break; @@ -1768,86 +1766,86 @@ void Bridge::map_to_cli( { case typelib_TypeClass_CHAR: { - System::Char arChar[]= gcnew System::Char[nElements]; - sri::Marshal::Copy( (void*) &seq->elements, arChar, 0, nElements); + cli::array< System::Char > ^ arChar = gcnew cli::array< System::Char >( nElements ); + sri::Marshal::Copy( System::IntPtr( (void*) &seq->elements ), arChar, 0, nElements); *cli_data= arChar; break; } case typelib_TypeClass_BOOLEAN: { - System::Boolean arBool[]= gcnew System::Boolean[nElements]; - sri::Marshal::Copy( (void*) &seq->elements, arBool, 0, nElements); + cli::array< System::Byte > ^ arBool = gcnew cli::array< System::Byte >( nElements ); + sri::Marshal::Copy( System::IntPtr( (void*) &seq->elements ), arBool, 0, nElements); *cli_data= arBool; break; } case typelib_TypeClass_BYTE: { - System::Byte arByte[]= gcnew System::Byte[nElements]; - sri::Marshal::Copy( (void*) &seq->elements, arByte, 0, nElements); + cli::array< System::Byte > ^ arByte = gcnew cli::array< System::Byte >( nElements ); + sri::Marshal::Copy( System::IntPtr( (void*) &seq->elements ), arByte, 0, nElements); *cli_data= arByte; break; } case typelib_TypeClass_SHORT: { - System::Int16 arShort[]= gcnew System::Int16[nElements]; - sri::Marshal::Copy( (void*) &seq->elements, arShort, 0, nElements); + cli::array< System::Int16 > ^ arShort = gcnew cli::array< System::Int16 >( nElements ); + sri::Marshal::Copy( System::IntPtr( (void*) &seq->elements ), arShort, 0, nElements); *cli_data= arShort; break; } case typelib_TypeClass_UNSIGNED_SHORT: { - System::UInt16 arUInt16[]= gcnew System::UInt16[nElements]; - sri::Marshal::Copy( (void*) &seq->elements, static_cast<System::Int16[]>(arUInt16), + cli::array< System::Int16 > ^ arUInt16 = gcnew cli::array< System::Int16 >( nElements ); + sri::Marshal::Copy( System::IntPtr( (void*) &seq->elements ), arUInt16, 0, nElements); *cli_data= arUInt16; break; } case typelib_TypeClass_LONG: { - System::Int32 arInt32[]= gcnew System::Int32[nElements]; - sri::Marshal::Copy( (void*) &seq->elements, arInt32, 0, nElements); + cli::array< System::Int32 > ^ arInt32 = gcnew cli::array< System::Int32 >( nElements ); + sri::Marshal::Copy( System::IntPtr( (void*) &seq->elements ), arInt32, 0, nElements); *cli_data= arInt32; break; } case typelib_TypeClass_UNSIGNED_LONG: { - System::UInt32 arUInt32[]= gcnew System::UInt32[nElements]; - sri::Marshal::Copy( (void*) &seq->elements, static_cast<System::Int32[]>(arUInt32), + cli::array< System::Int32 > ^ arUInt32 = gcnew cli::array< System::Int32 >( nElements ); + sri::Marshal::Copy( System::IntPtr( (void*) &seq->elements ), arUInt32, 0, nElements); *cli_data= arUInt32; break; } case typelib_TypeClass_HYPER: { - System::Int64 arInt64[]= gcnew System::Int64[nElements]; - sri::Marshal::Copy( (void*) &seq->elements, arInt64, 0, nElements); + cli::array< System::Int64 > ^ arInt64 = gcnew cli::array< System::Int64 >( nElements ); + sri::Marshal::Copy( System::IntPtr( (void*) &seq->elements ), arInt64, 0, nElements); *cli_data= arInt64; break; } case typelib_TypeClass_UNSIGNED_HYPER: { - System::UInt64 arUInt64[]= gcnew System::UInt64[nElements]; - sri::Marshal::Copy( (void*) &seq->elements, arUInt64, 0, nElements); + cli::array< System::Int64 > ^ arUInt64 = gcnew cli::array< System::Int64 >( nElements ); + sri::Marshal::Copy( System::IntPtr( (void*) &seq->elements ), arUInt64, 0, nElements); *cli_data= arUInt64; break; } case typelib_TypeClass_FLOAT: { - System::Single arSingle[]= gcnew System::Single[nElements]; - sri::Marshal::Copy( (void*) &seq->elements, arSingle, 0, nElements); + cli::array< System::Single > ^ arSingle = gcnew cli::array< System::Single >( nElements ); + sri::Marshal::Copy( System::IntPtr( (void*) &seq->elements ), arSingle, 0, nElements); *cli_data= arSingle; break; } case typelib_TypeClass_DOUBLE: { - System::Double arDouble[]= gcnew System::Double[nElements]; - sri::Marshal::Copy( (void*) &seq->elements, arDouble, 0, nElements); + cli::array< System::Double > ^ arDouble = gcnew cli::array< System::Double >( nElements ); + sri::Marshal::Copy( System::IntPtr( (void*) &seq->elements ), arDouble, 0, nElements); *cli_data= arDouble; break; } case typelib_TypeClass_STRING: { - cli::array< System::String ^ > ^ arString= gcgcnew cli::array< System::String ^ >( nElements ); + cli::array< System::String ^ > ^ arString= gcnew cli::array< System::String ^ >( nElements ); for (int i= 0; i < nElements; i++) { rtl_uString *aStr= ((rtl_uString**)(&seq->elements))[i]; @@ -1858,7 +1856,7 @@ void Bridge::map_to_cli( } case typelib_TypeClass_TYPE: { - cli::array< System::Type ^ > ^ arType= gcgcnew cli::array< System::Type ^ >( nElements ); + cli::array< System::Type ^ > ^ arType= gcnew cli::array< System::Type ^ >( nElements ); for (int i= 0; i < nElements; i++) { arType[i]= @@ -1873,10 +1871,10 @@ void Bridge::map_to_cli( uno_Any const * p = (uno_Any const *)seq->elements; for (sal_Int32 nPos = 0; nPos < nElements; ++nPos ) { - System::Object ^ cli_obj = NULL; + System::Object ^ cli_obj = nullptr; map_to_cli( - &cli_obj, &p[ nPos ], element_type, 0, false); - arCli[nPos]= *safe_cast< uno::Any >(cli_obj); + &cli_obj, &p[ nPos ], element_type, nullptr, false); + arCli[nPos]= safe_cast< uno::Any >(cli_obj); } *cli_data= arCli; break; @@ -1884,8 +1882,8 @@ void Bridge::map_to_cli( case typelib_TypeClass_ENUM: { //get the Enum type - System::Type ^ enumType= NULL; - if (info != NULL) + System::Type ^ enumType= nullptr; + if (info != nullptr) { //info is EnumType[]&, remove & OSL_ASSERT(info->IsByRef); @@ -1921,7 +1919,7 @@ void Bridge::map_to_cli( { System::Object ^ val; map_to_cli( - &val, p + (nSize * nPos), element_type, 0, false); + &val, p + (nSize * nPos), element_type, nullptr, false); ar->SetValue(val, nPos); } } @@ -1941,7 +1939,7 @@ void Bridge::map_to_cli( { System::Object ^ val; map_to_cli( - &val, &elements[nPos], element_type, 0, false); + &val, &elements[nPos], element_type, nullptr, false); ar->SetValue(val, nPos); } } @@ -1960,7 +1958,7 @@ void Bridge::map_to_cli( { System::Object ^ val; map_to_cli( - &val, p + (nSize * nPos), element_type, NULL, false); + &val, p + (nSize * nPos), element_type, nullptr, false); ar->SetValue(val, nPos); } diff --git a/main/cli_ure/source/uno_bridge/cli_environment.cxx b/main/cli_ure/source/uno_bridge/cli_environment.cxx index 7b74c6e1df..275ed9ca04 100644 --- a/main/cli_ure/source/uno_bridge/cli_environment.cxx +++ b/main/cli_ure/source/uno_bridge/cli_environment.cxx @@ -91,7 +91,7 @@ System::Object ^ Cli_environment::registerInterface ( void Cli_environment::revokeInterface(System::String ^ oid, System::Type ^ type) { - System::String ^ key = type != NULL ? createKey(oid, type) : oid; + System::String ^ key = type != nullptr ? createKey(oid, type) : oid; #if OSL_DEBUG_LEVEL >= 1 _numRegisteredObjects --; #endif @@ -112,7 +112,7 @@ void Cli_environment::revokeInterface(System::String ^ oid, System::Type ^ type) inline void Cli_environment::revokeInterface(System::String ^ oid) { - return revokeInterface(oid, NULL); + return revokeInterface(oid, nullptr); } System::Object ^ Cli_environment::getRegisteredInterface(System::String ^ oid, @@ -140,7 +140,7 @@ System::Object ^ Cli_environment::getRegisteredInterface(System::String ^ oid, System::String ^ Cli_environment::getObjectIdentifier(System::Object ^ obj) { - System::String ^ oId= 0; + System::String ^ oId= nullptr; RealProxy ^ aProxy= RemotingServices::GetRealProxy(obj); if (aProxy) { @@ -149,13 +149,13 @@ System::String ^ Cli_environment::getObjectIdentifier(System::Object ^ obj) oId= proxyImpl->getOid(); } - if (oId == 0) + if (oId == nullptr) { StringBuilder ^ buf= gcnew StringBuilder(256); bool bFirst = false; System::Threading::Monitor::Enter(Cli_environment::typeid); try { - buf->Append(m_IDGen->GetId(obj, & bFirst)); + buf->Append(m_IDGen->GetId(obj, bFirst)); } __finally { System::Threading::Monitor::Exit(Cli_environment::typeid); diff --git a/main/cli_ure/source/uno_bridge/cli_proxy.cxx b/main/cli_ure/source/uno_bridge/cli_proxy.cxx index cb1d97172f..459f7bf706 100644 --- a/main/cli_ure/source/uno_bridge/cli_proxy.cxx +++ b/main/cli_ure/source/uno_bridge/cli_proxy.cxx @@ -169,7 +169,7 @@ System::Object ^ UnoInterfaceProxy::create( void UnoInterfaceProxy::addUnoInterface(uno_Interface* pUnoI, typelib_InterfaceTypeDescription* pTd) { - sc::IEnumerator* enumInfos = m_listIfaces->GetEnumerator(); + sc::IEnumerator ^ enumInfos = m_listIfaces->GetEnumerator(); System::Threading::Monitor::Enter(this); try { @@ -235,7 +235,7 @@ bool UnoInterfaceProxy::CanCastTo(System::Type ^ fromType, System::Threading::Monitor::Enter(this); try { - if (0 != findInfo( fromType )) // proxy supports demanded interface + if (nullptr != findInfo( fromType )) // proxy supports demanded interface return true; //query an uno interface for the required type @@ -247,11 +247,11 @@ bool UnoInterfaceProxy::CanCastTo(System::Type ^ fromType, css::uno::TypeDescription membertd( reinterpret_cast<typelib_InterfaceTypeDescription*>( info->m_typeDesc)->ppAllMembers[0]); - System::Object ^args[] = gcgcnew cli::array< System::Object ^ >( 1 ); + cli::array< System::Object ^ > ^ args = gcnew cli::array< System::Object ^ >( 1 ); args[0] = fromType; uno::Any pAny; - System::Object ^ pException = NULL; + System::Object ^ pException = nullptr; pAny= safe_cast< uno::Any >( m_bridge->call_uno( @@ -262,18 +262,18 @@ bool UnoInterfaceProxy::CanCastTo(System::Type ^ fromType, 1, ((typelib_InterfaceMethodTypeDescription*) membertd.get())->pParams, - args, NULL, &pException) ); + args, nullptr, &pException) ); // handle regular exception from target OSL_ENSURE( - 0 == pException, + nullptr == pException, OUStringToOString( mapCliString( pException->ToString()), RTL_TEXTENCODING_UTF8 ).getStr() ); if (pAny.Type != void::typeid) // has value? { - if (0 != findInfo( fromType )) + if (nullptr != findInfo( fromType )) { // proxy now supports demanded interface return true; @@ -293,7 +293,7 @@ bool UnoInterfaceProxy::CanCastTo(System::Type ^ fromType, OSL_ASSERT( 0 != proxy->findInfo( fromType ) ); m_listAdditionalProxies->Add( proxy ); m_nlistAdditionalProxies = m_listAdditionalProxies->Count; - OSL_ASSERT( 0 != findInfo( fromType ) ); + OSL_ASSERT(nullptr != findInfo( fromType ) ); return true; } } @@ -329,21 +329,21 @@ bool UnoInterfaceProxy::CanCastTo(System::Type ^ fromType, return false; } -srrm::IMessage* UnoInterfaceProxy::invokeObject( - sc::IDictionary* props, - srrm::LogicalCallContext* context, - srrm::IMethodCallMessage* mcm) +srrm::IMessage ^ UnoInterfaceProxy::invokeObject( + sc::IDictionary ^ props, + srrm::LogicalCallContext ^ context, + srrm::IMethodCallMessage ^ mcm) { System::Object ^ retMethod = 0; System::String ^ sMethod = static_cast<System::String ^> (props[ m_methodNameString ]); - cli::array< System::Object ^ > ^ args = static_cast<System::Object ^[]>( + cli::array< System::Object ^ > ^ args = safe_cast< cli::array< System::Object ^ > ^ >( props[ m_ArgsString ]); if (m_Equals_String->Equals(sMethod)) { // Object.Equals OSL_ASSERT(args->Length == 1); - srrp::RealProxy* rProxy = srr::RemotingServices::GetRealProxy(args[0]); + srrp::RealProxy ^ rProxy = srr::RemotingServices::GetRealProxy(args[0]); bool bDone = false; if (rProxy) { @@ -376,7 +376,7 @@ srrm::IMessage* UnoInterfaceProxy::invokeObject( else if (m_ToString_String->Equals(sMethod)) { // Object.ToString - st::StringBuilder* sb = new st::StringBuilder(256); + st::StringBuilder ^ sb = gcnew st::StringBuilder(256); // sb->AppendFormat("Uno object proxy. Implemented interface: {0}" // ". OID: {1}", m_type->ToString(), m_oid); sb->AppendFormat("Uno object proxy. OID: {0}", m_oid); @@ -388,8 +388,8 @@ srrm::IMessage* UnoInterfaceProxy::invokeObject( //which should not be possible OSL_ASSERT(0); } - srrm::IMessage* retVal= new srrm::ReturnMessage( - retMethod, gcgcnew cli::array< System::Object ^ >( 0 ), 0, context, mcm); + srrm::IMessage ^ retVal= gcnew srrm::ReturnMessage( + retMethod, gcnew cli::array< System::Object ^ >( 0 ), 0, context, mcm); return retVal; } @@ -408,22 +408,22 @@ UnoInterfaceInfo ^ UnoInterfaceProxy::findInfo( ::System::Type ^ type ) static_cast< UnoInterfaceProxy ^ >( m_listAdditionalProxies[ i ] ); UnoInterfaceInfo ^ info = proxy->findInfo( type ); - if (0 != info) + if (nullptr != info) return info; } - return 0; + return nullptr; } -srrm::IMessage* UnoInterfaceProxy::Invoke(srrm::IMessage* callmsg) +srrm::IMessage ^ UnoInterfaceProxy::Invoke(srrm::IMessage ^ callmsg) { try { - sc::IDictionary* props= callmsg->Properties; - srrm::LogicalCallContext* context= - static_cast<srrm::LogicalCallContext*>( + sc::IDictionary ^ props= callmsg->Properties; + srrm::LogicalCallContext ^ context= + static_cast<srrm::LogicalCallContext ^>( props[ m_CallContextString ]); - srrm::IMethodCallMessage* mcm= - static_cast<srrm::IMethodCallMessage*>(callmsg); + srrm::IMethodCallMessage ^ mcm= + static_cast<srrm::IMethodCallMessage ^>(callmsg); //Find out which UNO interface is being called System::String ^ sTypeName = static_cast<System::String ^>( @@ -479,11 +479,11 @@ srrm::IMessage* UnoInterfaceProxy::Invoke(srrm::IMessage* callmsg) (typelib_InterfaceMethodTypeDescription *) member_td.get(); - cli::array< System::Object ^ > ^ args = static_cast<System::Object ^[]>( + cli::array< System::Object ^ > ^ args = safe_cast< cli::array< System::Object ^ > ^ >( props[ m_ArgsString ]); - cli::array< System::Type ^ > ^ argTypes = static_cast<System::Type ^[]>( + cli::array< System::Type ^ > ^ argTypes = safe_cast< cli::array< System::Type ^ > ^ >( props[ m_methodSignatureString ]); - System::Object ^ pExc = NULL; + System::Object ^ pExc = nullptr; System::Object ^ cli_ret = m_bridge->call_uno( info->m_unoI, member_td.get(), method_td->pReturnTypeRef, method_td->nParams, @@ -516,13 +516,13 @@ srrm::IMessage* UnoInterfaceProxy::Invoke(srrm::IMessage* callmsg) (typelib_InterfaceAttributeTypeDescription*) member_td.get(); - System::Object ^ pExc = NULL; + System::Object ^ pExc = nullptr; System::Object ^ cli_ret= m_bridge->call_uno( info->m_unoI, member_td.get(), attribute_td->pAttributeTypeRef, 0, 0, - NULL, NULL, &pExc); - return constructReturnMessage(cli_ret, NULL, NULL, + nullptr, nullptr, &pExc); + return constructReturnMessage(cli_ret, nullptr, nullptr, callmsg, pExc); } else if ('s' == usMethodName[0]) @@ -539,19 +539,19 @@ srrm::IMessage* UnoInterfaceProxy::Invoke(srrm::IMessage* callmsg) param.bOut = sal_False; cli::array< System::Object ^ > ^ args = - static_cast<System::Object ^[]>( + safe_cast< cli::array< System::Object ^ > ^ >( props[ m_ArgsString ]); - System::Object ^ pExc = NULL; + System::Object ^ pExc = nullptr; m_bridge->call_uno( info->m_unoI, member_td.get(), ::getCppuVoidType().getTypeLibType(), - 1, ¶m, args, NULL, &pExc); - return constructReturnMessage(NULL, NULL, NULL, + 1, ¶m, args, nullptr, &pExc); + return constructReturnMessage(NULL, nullptr, nullptr, callmsg, pExc); } else { - return constructReturnMessage(NULL, NULL, NULL, + return constructReturnMessage(NULL, nullptr, nullptr, callmsg, NULL); } } @@ -573,14 +573,14 @@ srrm::IMessage* UnoInterfaceProxy::Invoke(srrm::IMessage* callmsg) } catch (BridgeRuntimeError & err) { - srrm::IMethodCallMessage* mcm = - static_cast<srrm::IMethodCallMessage*>(callmsg); - return new srrm::ReturnMessage(new ucss::uno::RuntimeException( - mapUnoString(err.m_message.pData), NULL), mcm); + srrm::IMethodCallMessage ^ mcm = + static_cast<srrm::IMethodCallMessage ^>(callmsg); + return gcnew srrm::ReturnMessage(gcnew ucss::uno::RuntimeException( + mapUnoString(err.m_message.pData), nullptr), mcm); } catch (System::Exception ^ e) { - st::StringBuilder * sb = new st::StringBuilder(512); + st::StringBuilder ^ sb = gcnew st::StringBuilder(512); sb->Append(gcnew System::String( "An unexpected CLI exception occurred in " "UnoInterfaceProxy::Invoke. Original" @@ -588,9 +588,9 @@ srrm::IMessage* UnoInterfaceProxy::Invoke(srrm::IMessage* callmsg) sb->Append(e->Message); sb->Append((__wchar_t) '\n'); sb->Append(e->StackTrace); - srrm::IMethodCallMessage* mcm = - static_cast<srrm::IMethodCallMessage*>(callmsg); - return new srrm::ReturnMessage(new ucss::uno::RuntimeException( + srrm::IMethodCallMessage ^ mcm = + static_cast<srrm::IMethodCallMessage ^>(callmsg); + return gcnew srrm::ReturnMessage(gcnew ucss::uno::RuntimeException( sb->ToString(), NULL), mcm); } catch (...) @@ -598,41 +598,41 @@ srrm::IMessage* UnoInterfaceProxy::Invoke(srrm::IMessage* callmsg) System::String ^ msg = gcnew System::String( "An unexpected native C++ exception occurred in " "UnoInterfaceProxy::Invoke."); - srrm::IMethodCallMessage* mcm = - static_cast<srrm::IMethodCallMessage*>(callmsg); - return new srrm::ReturnMessage(new ucss::uno::RuntimeException( + srrm::IMethodCallMessage ^ mcm = + static_cast<srrm::IMethodCallMessage ^>(callmsg); + return gcnew srrm::ReturnMessage(gcnew ucss::uno::RuntimeException( msg, NULL), mcm); } - return NULL; + return nullptr; } /** If the argument args is NULL then this function is called for an attribute method (either setXXX or getXXX). For attributes the argument mtd is also NULL. */ -srrm::IMessage* UnoInterfaceProxy::constructReturnMessage( +srrm::IMessage ^ UnoInterfaceProxy::constructReturnMessage( System::Object ^ cliReturn, cli::array< System::Object ^ > ^ args, typelib_InterfaceMethodTypeDescription* mtd, - srrm::IMessage* msg, System::Object ^ exc) + srrm::IMessage ^ msg, System::Object ^ exc) { - srrm::IMessage * retVal= NULL; - srrm::IMethodCallMessage* mcm = static_cast<srrm::IMethodCallMessage*>(msg); + srrm::IMessage ^ retVal= nullptr; + srrm::IMethodCallMessage ^ mcm = static_cast<srrm::IMethodCallMessage ^>(msg); if (exc) { - retVal = new srrm::ReturnMessage( + retVal = gcnew srrm::ReturnMessage( dynamic_cast<System::Exception ^>(exc), mcm); } else { - sc::IDictionary* props= msg->Properties; - srrm::LogicalCallContext* context= - static_cast<srrm::LogicalCallContext*>( + sc::IDictionary ^ props= msg->Properties; + srrm::LogicalCallContext ^ context= + static_cast<srrm::LogicalCallContext ^>( props[ m_CallContextString ]); - if (args != NULL) + if (args != nullptr) { // Method //build the array of out parameters, allocate max length - cli::array< System::Object ^ > ^ arOut= gcgcnew cli::array< System::Object ^ >( mtd->nParams ); + cli::array< System::Object ^ > ^ arOut= gcnew cli::array< System::Object ^ >( mtd->nParams ); int nOut = 0; for (int i= 0; i < mtd->nParams; i++) { @@ -642,13 +642,13 @@ srrm::IMessage* UnoInterfaceProxy::constructReturnMessage( nOut++; } } - retVal= new srrm::ReturnMessage(cliReturn, arOut, nOut, + retVal= gcnew srrm::ReturnMessage(cliReturn, arOut, nOut, context, mcm); } else { // Attribute (getXXX) - retVal= new srrm::ReturnMessage(cliReturn, NULL, 0, + retVal= gcnew srrm::ReturnMessage(cliReturn, nullptr, 0, context, mcm); } } @@ -695,7 +695,7 @@ void CliProxy::makeMethodInfos() if (m_type->IsInterface == false) return; - sr::MethodInfo* arThisMethods[] = m_type->GetMethods(); + cli::array< sr::MethodInfo ^ > ^ arThisMethods = m_type->GetMethods(); //get the inherited interfaces cli::array< System::Type ^ > ^ arInheritedIfaces = m_type->GetInterfaces(); m_nInheritedInterfaces = arInheritedIfaces->Length; @@ -710,19 +710,19 @@ void CliProxy::makeMethodInfos() numMethods += arInheritedIfaces[i]->GetMethods()->Length; } //array containing MethodInfos of the cli object - m_arMethodInfos = new sr::MethodInfo*[numMethods]; + m_arMethodInfos = gcnew cli::array< sr::MethodInfo ^ >( numMethods ); //array containing MethodInfos of the interface - m_arInterfaceMethodInfos = new sr::MethodInfo*[numMethods]; + m_arInterfaceMethodInfos = gcnew cli::array< sr::MethodInfo ^ >( numMethods ); //array containing the mapping of Uno interface pos to pos in //m_arMethodInfos - m_arUnoPosToCliPos = gcnew System::Int32[numMethods]; + m_arUnoPosToCliPos = gcnew cli::array< System::Int32 >( numMethods ); // initialize with -1 for (int i = 0; i < numMethods; i++) m_arUnoPosToCliPos[i] = -1; #if OSL_DEBUG_LEVEL >= 2 - sr::MethodInfo* arMethodInfosDbg[]; - sr::MethodInfo* arInterfaceMethodInfosDbg[]; + sr::MethodInfo ^ arMethodInfosDbg[]; + sr::MethodInfo ^ arInterfaceMethodInfosDbg[]; System::Int32 arInterfaceMethodCountDbg[]; arMethodInfosDbg = m_arMethodInfos; arInterfaceMethodInfosDbg = m_arInterfaceMethodInfos; @@ -782,14 +782,14 @@ void CliProxy::makeMethodInfos() } } -sr::MethodInfo* CliProxy::getMethodInfo(int nUnoFunctionPos, +sr::MethodInfo ^ CliProxy::getMethodInfo(int nUnoFunctionPos, const rtl::OUString& usMethodName, MethodKind methodKind) { - sr::MethodInfo* ret = NULL; + sr::MethodInfo ^ ret = nullptr; #if OSL_DEBUG_LEVEL >= 2 System::String ^ sMethodNameDbg; - sr::MethodInfo* arMethodInfosDbg[]; - sr::MethodInfo* arInterfaceMethodInfosDbg[]; + sr::MethodInfo ^ arMethodInfosDbg[]; + sr::MethodInfo ^ arInterfaceMethodInfosDbg[]; System::Int32 arInterfaceMethodCountDbg[]; System::Int32 arUnoPosToCliPosDbg[]; sMethodNameDbg = mapUnoString(usMethodName.pData); @@ -856,7 +856,7 @@ sr::MethodInfo* CliProxy::getMethodInfo(int nUnoFunctionPos, "cli object does not implement interface method: ")); buf.append(usMethodName); throw BridgeRuntimeError(buf.makeStringAndClear()); - return 0; + return nullptr; } m_arUnoPosToCliPos[nUnoFunctionPos] = indexCliMethod; ret = m_arMethodInfos[indexCliMethod]; @@ -952,8 +952,8 @@ extern "C" void SAL_CALL cli_proxy_free( uno_ExtEnvironment *, void * proxy ) SAL_THROW_EXTERN_C() { - cli_uno::CliProxy ^ cliProxy = reinterpret_cast< - cli_uno::CliProxy ^ >( proxy ); + cli_uno::CliProxy * cliProxy = reinterpret_cast< + cli_uno::CliProxy * >( proxy ); delete cliProxy; } @@ -1010,7 +1010,7 @@ void SAL_CALL cli_proxy_dispatch( OUString const& usAttrName= *(rtl_uString**)& ((typelib_InterfaceMemberTypeDescription*) member_td) ->pMemberName; - sr::MethodInfo* info = proxy->getMethodInfo(function_pos, + sr::MethodInfo ^ info = proxy->getMethodInfo(function_pos, usAttrName, CliProxy::MK_GET); bridge->call_cli( proxy->m_cliI, @@ -1025,7 +1025,7 @@ void SAL_CALL cli_proxy_dispatch( OUString const& usAttrName= *(rtl_uString**) & ((typelib_InterfaceMemberTypeDescription*) member_td) ->pMemberName; - sr::MethodInfo* info = proxy->getMethodInfo(function_pos + 1, + sr::MethodInfo ^ info = proxy->getMethodInfo(function_pos + 1, usAttrName, CliProxy::MK_SET); typelib_MethodParameter param; param.pTypeRef = @@ -1131,7 +1131,7 @@ void SAL_CALL cli_proxy_dispatch( ((typelib_InterfaceMemberTypeDescription*) member_td) ->pMemberName; - sr::MethodInfo* info = proxy->getMethodInfo(function_pos, + sr::MethodInfo ^ info = proxy->getMethodInfo(function_pos, usMethodName, CliProxy::MK_METHOD); bridge->call_cli( proxy->m_cliI, diff --git a/main/cli_ure/source/uno_bridge/cli_proxy.h b/main/cli_ure/source/uno_bridge/cli_proxy.h index 5974c8c612..fbec89ad37 100644 --- a/main/cli_ure/source/uno_bridge/cli_proxy.h +++ b/main/cli_ure/source/uno_bridge/cli_proxy.h @@ -68,7 +68,7 @@ public ref class UnoInterfaceProxy: public srrp::RealProxy, grow and elements are never changed. If an element was added it must not be changed! */ - sc::ArrayList* m_listIfaces; + sc::ArrayList ^ m_listIfaces; /** The number of UNO interfaces this proxy represents. It corresponds to the number of elements in m_listIfaces. */ @@ -77,7 +77,7 @@ public ref class UnoInterfaceProxy: public srrp::RealProxy, to aggregation via bridges. Though the latter is strongly discouraged, this has to be supported. */ - sc::ArrayList* m_listAdditionalProxies; + sc::ArrayList ^ m_listAdditionalProxies; int m_nlistAdditionalProxies; UnoInterfaceInfo ^ findInfo( ::System::Type ^ type ); @@ -107,7 +107,7 @@ public: const rtl::OUString& oid); /** RealProxy::Invoke */ - srrm::IMessage* Invoke(srrm::IMessage* msg); + virtual srrm::IMessage ^ Invoke(srrm::IMessage ^ msg) override; /** Must be called from within a synchronized section. Add only the interface if it is not already contained. @@ -124,15 +124,21 @@ public: { return m_oid; } //IRemotingTypeInfo ---------------------------------------------- - bool CanCastTo(System::Type ^ fromType, System::Object ^ o); + virtual bool CanCastTo(System::Type ^ fromType, System::Object ^ o); - __property System::String ^ get_TypeName() + // IRemotingTypeInfo::TypeName. MC++ spelled a property as a pair of + // __property get_X/set_X methods; C++/CLI has property syntax, and the + // accessors have to be virtual because this implements an interface. + property System::String ^ TypeName { - return m_sTypeName; - } - __property void set_TypeName(System::String ^ name) - { - m_sTypeName = name; + virtual System::String ^ get() + { + return m_sTypeName; + } + virtual void set(System::String ^ name) + { + m_sTypeName = name; + } } @@ -143,10 +149,10 @@ private: typelib_InterfaceTypeDescription* pTD, const rtl::OUString& oid ); - static srrm::IMessage* constructReturnMessage(System::Object ^ retVal, + static srrm::IMessage ^ constructReturnMessage(System::Object ^ retVal, cli::array< System::Object ^ > ^ outArgs, typelib_InterfaceMethodTypeDescription* mtd, - srrm::IMessage* msg, System::Object ^ exc); + srrm::IMessage ^ msg, System::Object ^ exc); static System::String ^ m_methodNameString = gcnew System::String("__MethodName"); @@ -165,9 +171,9 @@ private: static System::String ^ m_ToString_String = gcnew System::String("ToString"); protected: - srrm::IMessage* invokeObject(sc::IDictionary* properties, - srrm::LogicalCallContext* context, - srrm::IMethodCallMessage* mcm); + srrm::IMessage ^ invokeObject(sc::IDictionary ^ properties, + srrm::LogicalCallContext ^ context, + srrm::IMethodCallMessage ^ mcm); }; @@ -204,7 +210,7 @@ struct CliProxy: public uno_Interface This is becaus, the cli interface does not contain the XInterface methods. */ - gcroot<sr::MethodInfo*[]> m_arMethodInfos; + gcroot< cli::array< sr::MethodInfo ^ > ^ > m_arMethodInfos; /** This array is similar to m_arMethodInfos but it contains the MethodInfo objects of the interface (not the object). When a call is made from uno @@ -213,7 +219,7 @@ struct CliProxy: public uno_Interface array. The name of the actual implemented method may not be the same as the interface method. */ - gcroot<sr::MethodInfo*[]> m_arInterfaceMethodInfos; + gcroot< cli::array< sr::MethodInfo ^ > ^ > m_arInterfaceMethodInfos; /** Maps the position of the method in the UNO interface to the position of the corresponding MethodInfo in m_arMethodInfos. The Uno position must @@ -226,14 +232,14 @@ struct CliProxy: public uno_Interface arUnoPosToCliPos[pos] contains the index for m_arMethodInfos. */ - gcroot<System::Int32[]> m_arUnoPosToCliPos; + gcroot< cli::array< System::Int32 > ^ > m_arUnoPosToCliPos; /** Count of inherited interfaces of the cli interface. */ int m_nInheritedInterfaces; /** Contains the number of methods of each interface. */ - gcroot<System::Int32[]> m_arInterfaceMethodCount; + gcroot< cli::array< System::Int32 > ^ > m_arInterfaceMethodCount; CliProxy( Bridge const* bridge, System::Object ^ cliI, typelib_TypeDescription const* pTD, @@ -277,7 +283,7 @@ struct CliProxy: public uno_Interface @param nUnoFunctionPos Position of the method in the uno interface. */ - sr::MethodInfo* getMethodInfo(int nUnoFunctionPos, + sr::MethodInfo ^ getMethodInfo(int nUnoFunctionPos, const rtl::OUString & usMethodName, MethodKind mk); diff --git a/main/cli_ure/source/uno_bridge/cli_uno.cxx b/main/cli_ure/source/uno_bridge/cli_uno.cxx index 76a56a51ea..ed27463489 100644 --- a/main/cli_ure/source/uno_bridge/cli_uno.cxx +++ b/main/cli_ure/source/uno_bridge/cli_uno.cxx @@ -139,9 +139,13 @@ System::Object ^ Bridge::call_uno(uno_Interface * pUnoI, { try { + // A cli::array element has no native address, so the + // out-parameter goes through a local and is assigned back. + System::Object ^ cliArg = nullptr; map_to_cli( - &args[nPos], uno_args[nPos], param.pTypeRef, - argTypes != NULL ? argTypes[nPos] : NULL, false ); + &cliArg, uno_args[nPos], param.pTypeRef, + argTypes != nullptr ? argTypes[nPos] : nullptr, false ); + args[nPos] = cliArg; } catch (...) { @@ -171,7 +175,7 @@ System::Object ^ Bridge::call_uno(uno_Interface * pUnoI, { System::Object ^ cli_ret; map_to_cli( - &cli_ret, uno_ret, return_type, 0, false); + &cli_ret, uno_ret, return_type, nullptr, false); uno_type_destructData(uno_ret, return_type, 0); return cli_ret; } @@ -195,34 +199,36 @@ System::Object ^ Bridge::call_uno(uno_Interface * pUnoI, } } map_to_cli(ppExc, uno_exc_holder.pData, - uno_exc_holder.pType, NULL, false); + uno_exc_holder.pType, nullptr, false); return 0; } } void Bridge::call_cli( System::Object ^ cliI, - sr::MethodInfo* method, + sr::MethodInfo ^ method, typelib_TypeDescriptionReference * return_type, typelib_MethodParameter * params, int nParams, void * uno_ret, void * uno_args [], uno_Any ** uno_exc ) const { - System::Object ^args[]= gcgcnew cli::array< System::Object ^ >( nParams ); + cli::array< System::Object ^ > ^ args = gcnew cli::array< System::Object ^ >( nParams ); for (int nPos= 0; nPos < nParams; nPos++) { typelib_MethodParameter const & param= params[nPos]; if (param.bIn) { - map_to_cli( &args[nPos], - uno_args[nPos], param.pTypeRef, 0, false); + System::Object ^ cliArg = nullptr; + map_to_cli( &cliArg, + uno_args[nPos], param.pTypeRef, nullptr, false); + args[nPos] = cliArg; } } - System::Object ^ retInvoke= NULL; + System::Object ^ retInvoke= nullptr; try { retInvoke= method->Invoke(cliI, args); } - catch (sr::TargetInvocationException* e) + catch (sr::TargetInvocationException ^ e) { System::Exception ^ exc= e->InnerException; css::uno::TypeDescription td(mapCliType(exc->GetType()));
