1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_bridges.hxx" 26 27 #include <exception> 28 #include <typeinfo> 29 #include <stdio.h> 30 #include <stdlib.h> 31 #include <string.h> 32 33 #include "rtl/alloc.h" 34 #include "rtl/ustrbuf.hxx" 35 36 #include <com/sun/star/uno/genfunc.hxx> 37 #include "com/sun/star/uno/RuntimeException.hpp" 38 #include <uno/data.h> 39 40 #include <bridges/cpp_uno/shared/bridge.hxx> 41 #include <bridges/cpp_uno/shared/types.hxx> 42 #include "bridges/cpp_uno/shared/unointerfaceproxy.hxx" 43 #include "bridges/cpp_uno/shared/vtables.hxx" 44 45 #include "abi.hxx" 46 #include "share.hxx" 47 48 using namespace ::rtl; 49 using namespace ::com::sun::star::uno; 50 51 //================================================================================================== 52 static void callVirtualMethod(void * pThis, sal_uInt32 nVtableIndex, 53 void * pRegisterReturn, typelib_TypeDescriptionReference * pReturnTypeRef, bool bSimpleReturn, 54 sal_uInt64 *pStack, sal_uInt32 nStack, 55 sal_uInt64 *pGPR, sal_uInt32 nGPR, 56 double *pFPR, sal_uInt32 nFPR) __attribute__((noinline)); 57 58 static void callVirtualMethod(void * pThis, sal_uInt32 nVtableIndex, 59 void * pRegisterReturn, typelib_TypeDescriptionReference * pReturnTypeRef, bool bSimpleReturn, 60 sal_uInt64 *pStack, sal_uInt32 nStack, 61 sal_uInt64 *pGPR, sal_uInt32 nGPR, 62 double *pFPR, sal_uInt32 nFPR) 63 { 64 #if OSL_DEBUG_LEVEL > 1 65 // Let's figure out what is really going on here 66 { 67 fprintf( stderr, "= callVirtualMethod() =\nGPR's (%d): ", nGPR ); 68 for ( unsigned int i = 0; i < nGPR; ++i ) 69 fprintf( stderr, "0x%lx, ", pGPR[i] ); 70 fprintf( stderr, "\nFPR's (%d): ", nFPR ); 71 for ( unsigned int i = 0; i < nFPR; ++i ) 72 fprintf( stderr, "%f, ", pFPR[i] ); 73 fprintf( stderr, "\nStack (%d): ", nStack ); 74 for ( unsigned int i = 0; i < nStack; ++i ) 75 fprintf( stderr, "0x%lx, ", pStack[i] ); 76 fprintf( stderr, "\n" ); 77 } 78 #endif 79 80 // The call instruction within the asm section of callVirtualMethod may throw 81 // exceptions. So that the compiler handles this correctly, it is important 82 // that (a) callVirtualMethod might call dummy_can_throw_anything (although this 83 // never happens at runtime), which in turn can throw exceptions, and (b) 84 // callVirtualMethod is not inlined at its call site (so that any exceptions are 85 // caught which are thrown from the instruction calling callVirtualMethod): 86 if ( !pThis ) 87 CPPU_CURRENT_NAMESPACE::dummy_can_throw_anything( "xxx" ); // address something 88 89 // Should not happen, but... 90 if ( nFPR > x86_64::MAX_SSE_REGS ) 91 nFPR = x86_64::MAX_SSE_REGS; 92 if ( nGPR > x86_64::MAX_GPR_REGS ) 93 nGPR = x86_64::MAX_GPR_REGS; 94 95 // Get pointer to method 96 sal_uInt64 pMethod = *((sal_uInt64 *)pThis); 97 pMethod += 8 * nVtableIndex; 98 pMethod = *((sal_uInt64 *)pMethod); 99 100 // Load parameters to stack, if necessary 101 sal_uInt64* pCallStack = NULL; 102 if ( nStack ) 103 { 104 // 16-bytes aligned 105 sal_uInt32 nStackBytes = ( ( nStack + 1 ) >> 1 ) * 16; 106 pCallStack = (sal_uInt64*) __builtin_alloca( nStackBytes ); 107 memcpy( pCallStack, pStack, nStackBytes ); 108 } 109 110 // Return values 111 sal_uInt64 rax; 112 sal_uInt64 rdx; 113 double xmm0; 114 double xmm1; 115 116 asm volatile ( 117 // Fill the xmm registers 118 "movq %2, %%rax\n\t" 119 120 "movsd (%%rax), %%xmm0\n\t" 121 "movsd 8(%%rax), %%xmm1\n\t" 122 "movsd 16(%%rax), %%xmm2\n\t" 123 "movsd 24(%%rax), %%xmm3\n\t" 124 "movsd 32(%%rax), %%xmm4\n\t" 125 "movsd 40(%%rax), %%xmm5\n\t" 126 "movsd 48(%%rax), %%xmm6\n\t" 127 "movsd 56(%%rax), %%xmm7\n\t" 128 129 // Fill the general purpose registers 130 "movq %1, %%rax\n\t" 131 132 "movq (%%rax), %%rdi\n\t" 133 "movq 8(%%rax), %%rsi\n\t" 134 "movq 16(%%rax), %%rdx\n\t" 135 "movq 24(%%rax), %%rcx\n\t" 136 "movq 32(%%rax), %%r8\n\t" 137 "movq 40(%%rax), %%r9\n\t" 138 139 // Perform the call 140 "movq %0, %%r11\n\t" 141 "movq %3, %%rax\n\t" 142 "call *%%r11\n\t" 143 144 // Fill the return values 145 "movq %%rax, %4\n\t" 146 "movq %%rdx, %5\n\t" 147 "movsd %%xmm0, %6\n\t" 148 "movsd %%xmm1, %7\n\t" 149 : 150 : "m" ( pMethod ), "m" ( pGPR ), "m" ( pFPR ), "m" ( nFPR ), 151 "m" ( rax ), "m" ( rdx ), "m" ( xmm0 ), "m" ( xmm1 ), 152 "m" (pCallStack) // dummy input to prevent the compiler from optimizing the alloca out 153 : "rax", "rdi", "rsi", "rdx", "rcx", "r8", "r9", "r11", 154 "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7" 155 ); 156 157 switch (pReturnTypeRef->eTypeClass) 158 { 159 case typelib_TypeClass_HYPER: 160 case typelib_TypeClass_UNSIGNED_HYPER: 161 *reinterpret_cast<sal_uInt64 *>( pRegisterReturn ) = rax; 162 break; 163 case typelib_TypeClass_LONG: 164 case typelib_TypeClass_UNSIGNED_LONG: 165 case typelib_TypeClass_ENUM: 166 *reinterpret_cast<sal_uInt32 *>( pRegisterReturn ) = *reinterpret_cast<sal_uInt32*>( &rax ); 167 break; 168 case typelib_TypeClass_CHAR: 169 case typelib_TypeClass_SHORT: 170 case typelib_TypeClass_UNSIGNED_SHORT: 171 *reinterpret_cast<sal_uInt16 *>( pRegisterReturn ) = *reinterpret_cast<sal_uInt16*>( &rax ); 172 break; 173 case typelib_TypeClass_BOOLEAN: 174 case typelib_TypeClass_BYTE: 175 *reinterpret_cast<sal_uInt8 *>( pRegisterReturn ) = *reinterpret_cast<sal_uInt8*>( &rax ); 176 break; 177 case typelib_TypeClass_FLOAT: 178 case typelib_TypeClass_DOUBLE: 179 *reinterpret_cast<double *>( pRegisterReturn ) = xmm0; 180 break; 181 default: 182 { 183 sal_Int32 const nRetSize = pReturnTypeRef->pType->nSize; 184 if (bSimpleReturn && nRetSize <= 16 && nRetSize > 0) 185 { 186 sal_uInt64 longs[2]; 187 longs[0] = rax; 188 longs[1] = rdx; 189 190 double doubles[2]; 191 doubles[0] = xmm0; 192 doubles[1] = xmm1; 193 x86_64::fill_struct( pReturnTypeRef, &longs[0], &doubles[0], pRegisterReturn); 194 } 195 break; 196 } 197 } 198 } 199 200 //================================================================================================== 201 202 // Macros for easier insertion of values to registers or stack 203 // pSV - pointer to the source 204 // nr - order of the value [will be increased if stored to register] 205 // pFPR, pGPR - pointer to the registers 206 // pDS - pointer to the stack [will be increased if stored here] 207 208 // The value in %xmm register is already prepared to be retrieved as a float, 209 // thus we treat float and double the same 210 #define INSERT_FLOAT_DOUBLE( pSV, nr, pFPR, pDS ) \ 211 if ( nr < x86_64::MAX_SSE_REGS ) \ 212 pFPR[nr++] = *reinterpret_cast<double *>( pSV ); \ 213 else \ 214 *pDS++ = *reinterpret_cast<sal_uInt64 *>( pSV ); // verbatim! 215 216 #define INSERT_INT64( pSV, nr, pGPR, pDS ) \ 217 if ( nr < x86_64::MAX_GPR_REGS ) \ 218 pGPR[nr++] = *reinterpret_cast<sal_uInt64 *>( pSV ); \ 219 else \ 220 *pDS++ = *reinterpret_cast<sal_uInt64 *>( pSV ); 221 222 #define INSERT_INT32( pSV, nr, pGPR, pDS ) \ 223 if ( nr < x86_64::MAX_GPR_REGS ) \ 224 pGPR[nr++] = *reinterpret_cast<sal_uInt32 *>( pSV ); \ 225 else \ 226 *pDS++ = *reinterpret_cast<sal_uInt32 *>( pSV ); 227 228 #define INSERT_INT16( pSV, nr, pGPR, pDS ) \ 229 if ( nr < x86_64::MAX_GPR_REGS ) \ 230 pGPR[nr++] = *reinterpret_cast<sal_uInt16 *>( pSV ); \ 231 else \ 232 *pDS++ = *reinterpret_cast<sal_uInt16 *>( pSV ); 233 234 #define INSERT_INT8( pSV, nr, pGPR, pDS ) \ 235 if ( nr < x86_64::MAX_GPR_REGS ) \ 236 pGPR[nr++] = *reinterpret_cast<sal_uInt8 *>( pSV ); \ 237 else \ 238 *pDS++ = *reinterpret_cast<sal_uInt8 *>( pSV ); 239 240 //================================================================================================== 241 242 namespace { 243 244 void appendCString(OUStringBuffer & buffer, char const * text) { 245 if (text != 0) { 246 buffer.append( 247 OStringToOUString(OString(text), RTL_TEXTENCODING_ISO_8859_1)); 248 // use 8859-1 to avoid conversion failure 249 } 250 } 251 252 } 253 254 static void cpp_call( 255 bridges::cpp_uno::shared::UnoInterfaceProxy * pThis, 256 bridges::cpp_uno::shared::VtableSlot aVtableSlot, 257 typelib_TypeDescriptionReference * pReturnTypeRef, 258 sal_Int32 nParams, typelib_MethodParameter * pParams, 259 void * pUnoReturn, void * pUnoArgs[], uno_Any ** ppUnoExc ) 260 { 261 // Maxium space for [complex ret ptr], values | ptr ... 262 // (but will be used less - some of the values will be in pGPR and pFPR) 263 sal_uInt64 *pStack = (sal_uInt64 *)__builtin_alloca( (nParams + 3) * sizeof(sal_uInt64) ); 264 sal_uInt64 *pStackStart = pStack; 265 266 sal_uInt64 pGPR[x86_64::MAX_GPR_REGS]; 267 sal_uInt32 nGPR = 0; 268 269 double pFPR[x86_64::MAX_SSE_REGS]; 270 sal_uInt32 nFPR = 0; 271 272 // Return 273 typelib_TypeDescription * pReturnTypeDescr = 0; 274 TYPELIB_DANGER_GET( &pReturnTypeDescr, pReturnTypeRef ); 275 OSL_ENSURE( pReturnTypeDescr, "### expected return type description!" ); 276 277 void * pCppReturn = 0; // if != 0 && != pUnoReturn, needs reconversion (see below) 278 279 bool bSimpleReturn = true; 280 if ( pReturnTypeDescr ) 281 { 282 if ( x86_64::return_in_hidden_param( pReturnTypeRef ) ) 283 bSimpleReturn = false; 284 285 if ( bSimpleReturn ) 286 pCppReturn = pUnoReturn; // direct way for simple types 287 else 288 { 289 // complex return via ptr 290 pCppReturn = bridges::cpp_uno::shared::relatesToInterfaceType( pReturnTypeDescr )? 291 __builtin_alloca( pReturnTypeDescr->nSize ) : pUnoReturn; 292 INSERT_INT64( &pCppReturn, nGPR, pGPR, pStack ); 293 } 294 } 295 296 // Push "this" pointer 297 void * pAdjustedThisPtr = reinterpret_cast< void ** >( pThis->getCppI() ) + aVtableSlot.offset; 298 INSERT_INT64( &pAdjustedThisPtr, nGPR, pGPR, pStack ); 299 300 // Args 301 void ** pCppArgs = (void **)alloca( 3 * sizeof(void *) * nParams ); 302 // Indizes of values this have to be converted (interface conversion cpp<=>uno) 303 sal_Int32 * pTempIndizes = (sal_Int32 *)(pCppArgs + nParams); 304 // Type descriptions for reconversions 305 typelib_TypeDescription ** ppTempParamTypeDescr = (typelib_TypeDescription **)(pCppArgs + (2 * nParams)); 306 307 sal_Int32 nTempIndizes = 0; 308 309 for ( sal_Int32 nPos = 0; nPos < nParams; ++nPos ) 310 { 311 const typelib_MethodParameter & rParam = pParams[nPos]; 312 typelib_TypeDescription * pParamTypeDescr = 0; 313 TYPELIB_DANGER_GET( &pParamTypeDescr, rParam.pTypeRef ); 314 315 if (!rParam.bOut && bridges::cpp_uno::shared::isSimpleType( pParamTypeDescr )) 316 { 317 uno_copyAndConvertData( pCppArgs[nPos] = alloca( 8 ), pUnoArgs[nPos], pParamTypeDescr, 318 pThis->getBridge()->getUno2Cpp() ); 319 320 switch (pParamTypeDescr->eTypeClass) 321 { 322 case typelib_TypeClass_HYPER: 323 case typelib_TypeClass_UNSIGNED_HYPER: 324 INSERT_INT64( pCppArgs[nPos], nGPR, pGPR, pStack ); 325 break; 326 case typelib_TypeClass_LONG: 327 case typelib_TypeClass_UNSIGNED_LONG: 328 case typelib_TypeClass_ENUM: 329 INSERT_INT32( pCppArgs[nPos], nGPR, pGPR, pStack ); 330 break; 331 case typelib_TypeClass_SHORT: 332 case typelib_TypeClass_CHAR: 333 case typelib_TypeClass_UNSIGNED_SHORT: 334 INSERT_INT16( pCppArgs[nPos], nGPR, pGPR, pStack ); 335 break; 336 case typelib_TypeClass_BOOLEAN: 337 case typelib_TypeClass_BYTE: 338 INSERT_INT8( pCppArgs[nPos], nGPR, pGPR, pStack ); 339 break; 340 case typelib_TypeClass_FLOAT: 341 case typelib_TypeClass_DOUBLE: 342 INSERT_FLOAT_DOUBLE( pCppArgs[nPos], nFPR, pFPR, pStack ); 343 break; 344 default: 345 break; 346 } 347 348 // no longer needed 349 TYPELIB_DANGER_RELEASE( pParamTypeDescr ); 350 } 351 else // ptr to complex value | ref 352 { 353 if (! rParam.bIn) // is pure out 354 { 355 // cpp out is constructed mem, uno out is not! 356 uno_constructData( 357 pCppArgs[nPos] = alloca( pParamTypeDescr->nSize ), 358 pParamTypeDescr ); 359 pTempIndizes[nTempIndizes] = nPos; // default constructed for cpp call 360 // will be released at reconversion 361 ppTempParamTypeDescr[nTempIndizes++] = pParamTypeDescr; 362 } 363 // is in/inout 364 else if (bridges::cpp_uno::shared::relatesToInterfaceType( pParamTypeDescr )) 365 { 366 uno_copyAndConvertData( 367 pCppArgs[nPos] = alloca( pParamTypeDescr->nSize ), 368 pUnoArgs[nPos], pParamTypeDescr, pThis->getBridge()->getUno2Cpp() ); 369 370 pTempIndizes[nTempIndizes] = nPos; // has to be reconverted 371 // will be released at reconversion 372 ppTempParamTypeDescr[nTempIndizes++] = pParamTypeDescr; 373 } 374 else // direct way 375 { 376 pCppArgs[nPos] = pUnoArgs[nPos]; 377 // no longer needed 378 TYPELIB_DANGER_RELEASE( pParamTypeDescr ); 379 } 380 INSERT_INT64( &(pCppArgs[nPos]), nGPR, pGPR, pStack ); 381 } 382 } 383 384 try 385 { 386 try { 387 callVirtualMethod( 388 pAdjustedThisPtr, aVtableSlot.index, 389 pCppReturn, pReturnTypeRef, bSimpleReturn, 390 pStackStart, ( pStack - pStackStart ), 391 pGPR, nGPR, 392 pFPR, nFPR ); 393 } catch (Exception &) { 394 throw; 395 } catch (std::exception & e) { 396 OUStringBuffer buf; 397 buf.appendAscii(RTL_CONSTASCII_STRINGPARAM("C++ code threw ")); 398 appendCString(buf, typeid(e).name()); 399 buf.appendAscii(RTL_CONSTASCII_STRINGPARAM(": ")); 400 appendCString(buf, e.what()); 401 throw RuntimeException( 402 buf.makeStringAndClear(), Reference< XInterface >()); 403 } catch (...) { 404 throw RuntimeException( 405 OUString( 406 RTL_CONSTASCII_USTRINGPARAM( 407 "C++ code threw unknown exception")), 408 Reference< XInterface >()); 409 } 410 411 // NO exception occured... 412 *ppUnoExc = 0; 413 414 // reconvert temporary params 415 for ( ; nTempIndizes--; ) 416 { 417 sal_Int32 nIndex = pTempIndizes[nTempIndizes]; 418 typelib_TypeDescription * pParamTypeDescr = ppTempParamTypeDescr[nTempIndizes]; 419 420 if (pParams[nIndex].bIn) 421 { 422 if (pParams[nIndex].bOut) // inout 423 { 424 uno_destructData( pUnoArgs[nIndex], pParamTypeDescr, 0 ); // destroy uno value 425 uno_copyAndConvertData( pUnoArgs[nIndex], pCppArgs[nIndex], pParamTypeDescr, 426 pThis->getBridge()->getCpp2Uno() ); 427 } 428 } 429 else // pure out 430 { 431 uno_copyAndConvertData( pUnoArgs[nIndex], pCppArgs[nIndex], pParamTypeDescr, 432 pThis->getBridge()->getCpp2Uno() ); 433 } 434 // destroy temp cpp param => cpp: every param was constructed 435 uno_destructData( pCppArgs[nIndex], pParamTypeDescr, cpp_release ); 436 437 TYPELIB_DANGER_RELEASE( pParamTypeDescr ); 438 } 439 // return value 440 if (pCppReturn && pUnoReturn != pCppReturn) 441 { 442 uno_copyAndConvertData( pUnoReturn, pCppReturn, pReturnTypeDescr, 443 pThis->getBridge()->getCpp2Uno() ); 444 uno_destructData( pCppReturn, pReturnTypeDescr, cpp_release ); 445 } 446 } 447 catch (...) 448 { 449 // fill uno exception 450 fillUnoException( CPPU_CURRENT_NAMESPACE::__cxa_get_globals()->caughtExceptions, *ppUnoExc, pThis->getBridge()->getCpp2Uno() ); 451 452 // temporary params 453 for ( ; nTempIndizes--; ) 454 { 455 sal_Int32 nIndex = pTempIndizes[nTempIndizes]; 456 // destroy temp cpp param => cpp: every param was constructed 457 uno_destructData( pCppArgs[nIndex], ppTempParamTypeDescr[nTempIndizes], cpp_release ); 458 TYPELIB_DANGER_RELEASE( ppTempParamTypeDescr[nTempIndizes] ); 459 } 460 // return type 461 if (pReturnTypeDescr) 462 TYPELIB_DANGER_RELEASE( pReturnTypeDescr ); 463 } 464 } 465 466 //================================================================================================== 467 468 namespace bridges { namespace cpp_uno { namespace shared { 469 470 void unoInterfaceProxyDispatch( 471 uno_Interface * pUnoI, const typelib_TypeDescription * pMemberDescr, 472 void * pReturn, void * pArgs[], uno_Any ** ppException ) 473 { 474 // is my surrogate 475 bridges::cpp_uno::shared::UnoInterfaceProxy * pThis 476 = static_cast< bridges::cpp_uno::shared::UnoInterfaceProxy * >(pUnoI); 477 #if OSL_DEBUG_LEVEL > 0 478 typelib_InterfaceTypeDescription * pTypeDescr = pThis->pTypeDescr; 479 #endif 480 481 switch (pMemberDescr->eTypeClass) 482 { 483 case typelib_TypeClass_INTERFACE_ATTRIBUTE: 484 { 485 #if OSL_DEBUG_LEVEL > 0 486 // determine vtable call index 487 sal_Int32 nMemberPos = ((typelib_InterfaceMemberTypeDescription *)pMemberDescr)->nPosition; 488 OSL_ENSURE( nMemberPos < pTypeDescr->nAllMembers, "### member pos out of range!" ); 489 #endif 490 VtableSlot aVtableSlot( 491 getVtableSlot( 492 reinterpret_cast< 493 typelib_InterfaceAttributeTypeDescription const * >( 494 pMemberDescr))); 495 496 if (pReturn) 497 { 498 // dependent dispatch 499 cpp_call( 500 pThis, aVtableSlot, 501 ((typelib_InterfaceAttributeTypeDescription *)pMemberDescr)->pAttributeTypeRef, 502 0, 0, // no params 503 pReturn, pArgs, ppException ); 504 } 505 else 506 { 507 // is SET 508 typelib_MethodParameter aParam; 509 aParam.pTypeRef = 510 ((typelib_InterfaceAttributeTypeDescription *)pMemberDescr)->pAttributeTypeRef; 511 aParam.bIn = sal_True; 512 aParam.bOut = sal_False; 513 514 typelib_TypeDescriptionReference * pReturnTypeRef = 0; 515 OUString aVoidName( RTL_CONSTASCII_USTRINGPARAM("void") ); 516 typelib_typedescriptionreference_new( 517 &pReturnTypeRef, typelib_TypeClass_VOID, aVoidName.pData ); 518 519 // dependent dispatch 520 aVtableSlot.index += 1; // get, then set method 521 cpp_call( 522 pThis, aVtableSlot, // get, then set method 523 pReturnTypeRef, 524 1, &aParam, 525 pReturn, pArgs, ppException ); 526 527 typelib_typedescriptionreference_release( pReturnTypeRef ); 528 } 529 530 break; 531 } 532 case typelib_TypeClass_INTERFACE_METHOD: 533 { 534 #if OSL_DEBUG_LEVEL > 0 535 // determine vtable call index 536 sal_Int32 nMemberPos = ((typelib_InterfaceMemberTypeDescription *)pMemberDescr)->nPosition; 537 OSL_ENSURE( nMemberPos < pTypeDescr->nAllMembers, "### member pos out of range!" ); 538 #endif 539 VtableSlot aVtableSlot( 540 getVtableSlot( 541 reinterpret_cast< 542 typelib_InterfaceMethodTypeDescription const * >( 543 pMemberDescr))); 544 545 switch (aVtableSlot.index) 546 { 547 // standard calls 548 case 1: // acquire uno interface 549 (*pUnoI->acquire)( pUnoI ); 550 *ppException = 0; 551 break; 552 case 2: // release uno interface 553 (*pUnoI->release)( pUnoI ); 554 *ppException = 0; 555 break; 556 case 0: // queryInterface() opt 557 { 558 typelib_TypeDescription * pTD = 0; 559 TYPELIB_DANGER_GET( &pTD, reinterpret_cast< Type * >( pArgs[0] )->getTypeLibType() ); 560 if (pTD) 561 { 562 uno_Interface * pInterface = 0; 563 (*pThis->getBridge()->getUnoEnv()->getRegisteredInterface)( 564 pThis->getBridge()->getUnoEnv(), 565 (void **)&pInterface, pThis->oid.pData, (typelib_InterfaceTypeDescription *)pTD ); 566 567 if (pInterface) 568 { 569 ::uno_any_construct( 570 reinterpret_cast< uno_Any * >( pReturn ), 571 &pInterface, pTD, 0 ); 572 (*pInterface->release)( pInterface ); 573 TYPELIB_DANGER_RELEASE( pTD ); 574 *ppException = 0; 575 break; 576 } 577 TYPELIB_DANGER_RELEASE( pTD ); 578 } 579 } // else perform queryInterface() 580 default: 581 // dependent dispatch 582 cpp_call( 583 pThis, aVtableSlot, 584 ((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->pReturnTypeRef, 585 ((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->nParams, 586 ((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->pParams, 587 pReturn, pArgs, ppException ); 588 } 589 break; 590 } 591 default: 592 { 593 ::com::sun::star::uno::RuntimeException aExc( 594 OUString( RTL_CONSTASCII_USTRINGPARAM("illegal member type description!") ), 595 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >() ); 596 597 Type const & rExcType = ::getCppuType( &aExc ); 598 // binary identical null reference 599 ::uno_type_any_construct( *ppException, &aExc, rExcType.getTypeLibType(), 0 ); 600 } 601 } 602 } 603 604 } } } 605