1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_bridges.hxx"
30 
31 #include <stdio.h>
32 #include <stdlib.h>
33 #include <string.h>
34 #include <rtl/alloc.h>
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     if ( nStack )
102     {
103         // 16-bytes aligned
104         sal_uInt32 nStackBytes = ( ( nStack + 1 ) >> 1 ) * 16;
105         sal_uInt64 *pCallStack = (sal_uInt64 *) __builtin_alloca( nStackBytes );
106         memcpy( pCallStack, pStack, nStackBytes );
107     }
108 
109     // Return values
110     sal_uInt64 rax;
111     sal_uInt64 rdx;
112     double xmm0;
113     double xmm1;
114 
115     asm volatile (
116 
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         : "rax", "rdi", "rsi", "rdx", "rcx", "r8", "r9", "r11"
153     );
154 
155     switch (pReturnTypeRef->eTypeClass)
156     {
157     case typelib_TypeClass_HYPER:
158     case typelib_TypeClass_UNSIGNED_HYPER:
159         *reinterpret_cast<sal_uInt64 *>( pRegisterReturn ) = rax;
160         break;
161     case typelib_TypeClass_LONG:
162     case typelib_TypeClass_UNSIGNED_LONG:
163     case typelib_TypeClass_ENUM:
164         *reinterpret_cast<sal_uInt32 *>( pRegisterReturn ) = *reinterpret_cast<sal_uInt32*>( &rax );
165         break;
166     case typelib_TypeClass_CHAR:
167     case typelib_TypeClass_SHORT:
168     case typelib_TypeClass_UNSIGNED_SHORT:
169         *reinterpret_cast<sal_uInt16 *>( pRegisterReturn ) = *reinterpret_cast<sal_uInt16*>( &rax );
170         break;
171     case typelib_TypeClass_BOOLEAN:
172     case typelib_TypeClass_BYTE:
173         *reinterpret_cast<sal_uInt8 *>( pRegisterReturn ) = *reinterpret_cast<sal_uInt8*>( &rax );
174         break;
175     case typelib_TypeClass_FLOAT:
176     case typelib_TypeClass_DOUBLE:
177         *reinterpret_cast<double *>( pRegisterReturn ) = xmm0;
178         break;
179     default:
180         {
181             sal_Int32 const nRetSize = pReturnTypeRef->pType->nSize;
182             if (bSimpleReturn && nRetSize <= 16 && nRetSize > 0)
183             {
184                 sal_uInt64 longs[2];
185                 longs[0] = rax;
186                 longs[1] = rdx;
187 
188                 double doubles[2];
189                 doubles[0] = xmm0;
190                 doubles[1] = xmm1;
191                 x86_64::fill_struct( pReturnTypeRef, &longs[0], &doubles[0], pRegisterReturn);
192             }
193             break;
194         }
195     }
196 }
197 
198 //==================================================================================================
199 
200 // Macros for easier insertion of values to registers or stack
201 // pSV - pointer to the source
202 // nr - order of the value [will be increased if stored to register]
203 // pFPR, pGPR - pointer to the registers
204 // pDS - pointer to the stack [will be increased if stored here]
205 
206 // The value in %xmm register is already prepared to be retrieved as a float,
207 // thus we treat float and double the same
208 #define INSERT_FLOAT_DOUBLE( pSV, nr, pFPR, pDS ) \
209 	if ( nr < x86_64::MAX_SSE_REGS ) \
210 		pFPR[nr++] = *reinterpret_cast<double *>( pSV ); \
211 	else \
212 		*pDS++ = *reinterpret_cast<sal_uInt64 *>( pSV ); // verbatim!
213 
214 #define INSERT_INT64( pSV, nr, pGPR, pDS ) \
215 	if ( nr < x86_64::MAX_GPR_REGS ) \
216 		pGPR[nr++] = *reinterpret_cast<sal_uInt64 *>( pSV ); \
217 	else \
218 		*pDS++ = *reinterpret_cast<sal_uInt64 *>( pSV );
219 
220 #define INSERT_INT32( pSV, nr, pGPR, pDS ) \
221 	if ( nr < x86_64::MAX_GPR_REGS ) \
222 		pGPR[nr++] = *reinterpret_cast<sal_uInt32 *>( pSV ); \
223 	else \
224 		*pDS++ = *reinterpret_cast<sal_uInt32 *>( pSV );
225 
226 #define INSERT_INT16( pSV, nr, pGPR, pDS ) \
227 	if ( nr < x86_64::MAX_GPR_REGS ) \
228 		pGPR[nr++] = *reinterpret_cast<sal_uInt16 *>( pSV ); \
229 	else \
230 		*pDS++ = *reinterpret_cast<sal_uInt16 *>( pSV );
231 
232 #define INSERT_INT8( pSV, nr, pGPR, pDS ) \
233 	if ( nr < x86_64::MAX_GPR_REGS ) \
234 		pGPR[nr++] = *reinterpret_cast<sal_uInt8 *>( pSV ); \
235 	else \
236 		*pDS++ = *reinterpret_cast<sal_uInt8 *>( pSV );
237 
238 //==================================================================================================
239 
240 static void cpp_call(
241 	bridges::cpp_uno::shared::UnoInterfaceProxy * pThis,
242 	bridges::cpp_uno::shared::VtableSlot aVtableSlot,
243 	typelib_TypeDescriptionReference * pReturnTypeRef,
244 	sal_Int32 nParams, typelib_MethodParameter * pParams,
245 	void * pUnoReturn, void * pUnoArgs[], uno_Any ** ppUnoExc )
246 {
247 	// Maxium space for [complex ret ptr], values | ptr ...
248 	// (but will be used less - some of the values will be in pGPR and pFPR)
249   	sal_uInt64 *pStack = (sal_uInt64 *)__builtin_alloca( (nParams + 3) * sizeof(sal_uInt64) );
250   	sal_uInt64 *pStackStart = pStack;
251 
252 	sal_uInt64 pGPR[x86_64::MAX_GPR_REGS];
253 	sal_uInt32 nGPR = 0;
254 
255 	double pFPR[x86_64::MAX_SSE_REGS];
256 	sal_uInt32 nFPR = 0;
257 
258 	// Return
259 	typelib_TypeDescription * pReturnTypeDescr = 0;
260 	TYPELIB_DANGER_GET( &pReturnTypeDescr, pReturnTypeRef );
261 	OSL_ENSURE( pReturnTypeDescr, "### expected return type description!" );
262 
263 	void * pCppReturn = 0; // if != 0 && != pUnoReturn, needs reconversion (see below)
264 
265 	bool bSimpleReturn = true;
266 	if ( pReturnTypeDescr )
267 	{
268 		if ( x86_64::return_in_hidden_param( pReturnTypeRef ) )
269 			bSimpleReturn = false;
270 
271 		if ( bSimpleReturn )
272 			pCppReturn = pUnoReturn; // direct way for simple types
273 		else
274 		{
275 			// complex return via ptr
276 			pCppReturn = bridges::cpp_uno::shared::relatesToInterfaceType( pReturnTypeDescr )?
277 						 __builtin_alloca( pReturnTypeDescr->nSize ) : pUnoReturn;
278 			INSERT_INT64( &pCppReturn, nGPR, pGPR, pStack );
279 		}
280 	}
281 
282 	// Push "this" pointer
283 	void * pAdjustedThisPtr = reinterpret_cast< void ** >( pThis->getCppI() ) + aVtableSlot.offset;
284 	INSERT_INT64( &pAdjustedThisPtr, nGPR, pGPR, pStack );
285 
286 	// Args
287 	void ** pCppArgs = (void **)alloca( 3 * sizeof(void *) * nParams );
288 	// Indizes of values this have to be converted (interface conversion cpp<=>uno)
289 	sal_Int32 * pTempIndizes = (sal_Int32 *)(pCppArgs + nParams);
290 	// Type descriptions for reconversions
291 	typelib_TypeDescription ** ppTempParamTypeDescr = (typelib_TypeDescription **)(pCppArgs + (2 * nParams));
292 
293 	sal_Int32 nTempIndizes = 0;
294 
295 	for ( sal_Int32 nPos = 0; nPos < nParams; ++nPos )
296 	{
297 		const typelib_MethodParameter & rParam = pParams[nPos];
298 		typelib_TypeDescription * pParamTypeDescr = 0;
299 		TYPELIB_DANGER_GET( &pParamTypeDescr, rParam.pTypeRef );
300 
301 		if (!rParam.bOut && bridges::cpp_uno::shared::isSimpleType( pParamTypeDescr ))
302 		{
303 			uno_copyAndConvertData( pCppArgs[nPos] = alloca( 8 ), pUnoArgs[nPos], pParamTypeDescr,
304 									pThis->getBridge()->getUno2Cpp() );
305 
306 			switch (pParamTypeDescr->eTypeClass)
307 			{
308 			case typelib_TypeClass_HYPER:
309 			case typelib_TypeClass_UNSIGNED_HYPER:
310 				INSERT_INT64( pCppArgs[nPos], nGPR, pGPR, pStack );
311 				break;
312 			case typelib_TypeClass_LONG:
313 			case typelib_TypeClass_UNSIGNED_LONG:
314 			case typelib_TypeClass_ENUM:
315 				INSERT_INT32( pCppArgs[nPos], nGPR, pGPR, pStack );
316 				break;
317 			case typelib_TypeClass_SHORT:
318 			case typelib_TypeClass_CHAR:
319 			case typelib_TypeClass_UNSIGNED_SHORT:
320 				INSERT_INT16( pCppArgs[nPos], nGPR, pGPR, pStack );
321 				break;
322 			case typelib_TypeClass_BOOLEAN:
323 			case typelib_TypeClass_BYTE:
324 				INSERT_INT8( pCppArgs[nPos], nGPR, pGPR, pStack );
325 				break;
326 			case typelib_TypeClass_FLOAT:
327 			case typelib_TypeClass_DOUBLE:
328 				INSERT_FLOAT_DOUBLE( pCppArgs[nPos], nFPR, pFPR, pStack );
329 				break;
330 			default:
331 				break;
332 			}
333 
334 			// no longer needed
335 			TYPELIB_DANGER_RELEASE( pParamTypeDescr );
336 		}
337 		else // ptr to complex value | ref
338 		{
339 			if (! rParam.bIn) // is pure out
340 			{
341 				// cpp out is constructed mem, uno out is not!
342 				uno_constructData(
343 					pCppArgs[nPos] = alloca( pParamTypeDescr->nSize ),
344 					pParamTypeDescr );
345 				pTempIndizes[nTempIndizes] = nPos; // default constructed for cpp call
346 				// will be released at reconversion
347 				ppTempParamTypeDescr[nTempIndizes++] = pParamTypeDescr;
348 			}
349 			// is in/inout
350 			else if (bridges::cpp_uno::shared::relatesToInterfaceType( pParamTypeDescr ))
351 			{
352 				uno_copyAndConvertData(
353 					pCppArgs[nPos] = alloca( pParamTypeDescr->nSize ),
354 					pUnoArgs[nPos], pParamTypeDescr, pThis->getBridge()->getUno2Cpp() );
355 
356 				pTempIndizes[nTempIndizes] = nPos; // has to be reconverted
357 				// will be released at reconversion
358 				ppTempParamTypeDescr[nTempIndizes++] = pParamTypeDescr;
359 			}
360 			else // direct way
361 			{
362 				pCppArgs[nPos] = pUnoArgs[nPos];
363 				// no longer needed
364 				TYPELIB_DANGER_RELEASE( pParamTypeDescr );
365 			}
366 			INSERT_INT64( &(pCppArgs[nPos]), nGPR, pGPR, pStack );
367 		}
368 	}
369 
370 	try
371 	{
372 		callVirtualMethod(
373 			pAdjustedThisPtr, aVtableSlot.index,
374 			pCppReturn, pReturnTypeRef, bSimpleReturn,
375 			pStackStart, ( pStack - pStackStart ),
376 			pGPR, nGPR,
377 			pFPR, nFPR );
378 		// NO exception occured...
379 		*ppUnoExc = 0;
380 
381 		// reconvert temporary params
382 		for ( ; nTempIndizes--; )
383 		{
384 			sal_Int32 nIndex = pTempIndizes[nTempIndizes];
385 			typelib_TypeDescription * pParamTypeDescr = ppTempParamTypeDescr[nTempIndizes];
386 
387 			if (pParams[nIndex].bIn)
388 			{
389 				if (pParams[nIndex].bOut) // inout
390 				{
391 					uno_destructData( pUnoArgs[nIndex], pParamTypeDescr, 0 ); // destroy uno value
392 					uno_copyAndConvertData( pUnoArgs[nIndex], pCppArgs[nIndex], pParamTypeDescr,
393 											pThis->getBridge()->getCpp2Uno() );
394 				}
395 			}
396 			else // pure out
397 			{
398 				uno_copyAndConvertData( pUnoArgs[nIndex], pCppArgs[nIndex], pParamTypeDescr,
399 										pThis->getBridge()->getCpp2Uno() );
400 			}
401 			// destroy temp cpp param => cpp: every param was constructed
402 			uno_destructData( pCppArgs[nIndex], pParamTypeDescr, cpp_release );
403 
404 			TYPELIB_DANGER_RELEASE( pParamTypeDescr );
405 		}
406 		// return value
407 		if (pCppReturn && pUnoReturn != pCppReturn)
408 		{
409 			uno_copyAndConvertData( pUnoReturn, pCppReturn, pReturnTypeDescr,
410 									pThis->getBridge()->getCpp2Uno() );
411 			uno_destructData( pCppReturn, pReturnTypeDescr, cpp_release );
412 		}
413 	}
414  	catch (...)
415  	{
416   		// fill uno exception
417 		fillUnoException( CPPU_CURRENT_NAMESPACE::__cxa_get_globals()->caughtExceptions, *ppUnoExc, pThis->getBridge()->getCpp2Uno() );
418 
419 		// temporary params
420 		for ( ; nTempIndizes--; )
421 		{
422 			sal_Int32 nIndex = pTempIndizes[nTempIndizes];
423 			// destroy temp cpp param => cpp: every param was constructed
424 			uno_destructData( pCppArgs[nIndex], ppTempParamTypeDescr[nTempIndizes], cpp_release );
425 			TYPELIB_DANGER_RELEASE( ppTempParamTypeDescr[nTempIndizes] );
426 		}
427 		// return type
428 		if (pReturnTypeDescr)
429 			TYPELIB_DANGER_RELEASE( pReturnTypeDescr );
430 	}
431 }
432 
433 //==================================================================================================
434 
435 namespace bridges { namespace cpp_uno { namespace shared {
436 
437 void unoInterfaceProxyDispatch(
438 	uno_Interface * pUnoI, const typelib_TypeDescription * pMemberDescr,
439 	void * pReturn, void * pArgs[], uno_Any ** ppException )
440 {
441 	// is my surrogate
442 	bridges::cpp_uno::shared::UnoInterfaceProxy * pThis
443 		= static_cast< bridges::cpp_uno::shared::UnoInterfaceProxy * >(pUnoI);
444 #if OSL_DEBUG_LEVEL > 0
445 	typelib_InterfaceTypeDescription * pTypeDescr = pThis->pTypeDescr;
446 #endif
447 
448 	switch (pMemberDescr->eTypeClass)
449 	{
450 	case typelib_TypeClass_INTERFACE_ATTRIBUTE:
451 	{
452 #if OSL_DEBUG_LEVEL > 0
453 		// determine vtable call index
454 		sal_Int32 nMemberPos = ((typelib_InterfaceMemberTypeDescription *)pMemberDescr)->nPosition;
455 		OSL_ENSURE( nMemberPos < pTypeDescr->nAllMembers, "### member pos out of range!" );
456 #endif
457 		VtableSlot aVtableSlot(
458 				getVtableSlot(
459 					reinterpret_cast<
460 					typelib_InterfaceAttributeTypeDescription const * >(
461 						pMemberDescr)));
462 
463 		if (pReturn)
464 		{
465 			// dependent dispatch
466 			cpp_call(
467 				pThis, aVtableSlot,
468 				((typelib_InterfaceAttributeTypeDescription *)pMemberDescr)->pAttributeTypeRef,
469 				0, 0, // no params
470 				pReturn, pArgs, ppException );
471 		}
472 		else
473 		{
474 			// is SET
475 			typelib_MethodParameter aParam;
476 			aParam.pTypeRef =
477 				((typelib_InterfaceAttributeTypeDescription *)pMemberDescr)->pAttributeTypeRef;
478 			aParam.bIn		= sal_True;
479 			aParam.bOut		= sal_False;
480 
481 			typelib_TypeDescriptionReference * pReturnTypeRef = 0;
482 			OUString aVoidName( RTL_CONSTASCII_USTRINGPARAM("void") );
483 			typelib_typedescriptionreference_new(
484 				&pReturnTypeRef, typelib_TypeClass_VOID, aVoidName.pData );
485 
486 			// dependent dispatch
487 			aVtableSlot.index += 1; // get, then set method
488 			cpp_call(
489 				pThis, aVtableSlot, // get, then set method
490 				pReturnTypeRef,
491 				1, &aParam,
492 				pReturn, pArgs, ppException );
493 
494 			typelib_typedescriptionreference_release( pReturnTypeRef );
495 		}
496 
497 		break;
498 	}
499 	case typelib_TypeClass_INTERFACE_METHOD:
500 	{
501 #if OSL_DEBUG_LEVEL > 0
502 		// determine vtable call index
503 		sal_Int32 nMemberPos = ((typelib_InterfaceMemberTypeDescription *)pMemberDescr)->nPosition;
504 		OSL_ENSURE( nMemberPos < pTypeDescr->nAllMembers, "### member pos out of range!" );
505 #endif
506 		VtableSlot aVtableSlot(
507 				getVtableSlot(
508 					reinterpret_cast<
509 					typelib_InterfaceMethodTypeDescription const * >(
510 						pMemberDescr)));
511 
512 		switch (aVtableSlot.index)
513 		{
514 			// standard calls
515 		case 1: // acquire uno interface
516 			(*pUnoI->acquire)( pUnoI );
517 			*ppException = 0;
518 			break;
519 		case 2: // release uno interface
520 			(*pUnoI->release)( pUnoI );
521 			*ppException = 0;
522 			break;
523 		case 0: // queryInterface() opt
524 		{
525 			typelib_TypeDescription * pTD = 0;
526 			TYPELIB_DANGER_GET( &pTD, reinterpret_cast< Type * >( pArgs[0] )->getTypeLibType() );
527 			if (pTD)
528 			{
529                 uno_Interface * pInterface = 0;
530                 (*pThis->getBridge()->getUnoEnv()->getRegisteredInterface)(
531                     pThis->getBridge()->getUnoEnv(),
532                     (void **)&pInterface, pThis->oid.pData, (typelib_InterfaceTypeDescription *)pTD );
533 
534                 if (pInterface)
535                 {
536                     ::uno_any_construct(
537                         reinterpret_cast< uno_Any * >( pReturn ),
538                         &pInterface, pTD, 0 );
539                     (*pInterface->release)( pInterface );
540                     TYPELIB_DANGER_RELEASE( pTD );
541                     *ppException = 0;
542                     break;
543                 }
544                 TYPELIB_DANGER_RELEASE( pTD );
545             }
546 		} // else perform queryInterface()
547 		default:
548 			// dependent dispatch
549 			cpp_call(
550 				pThis, aVtableSlot,
551 				((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->pReturnTypeRef,
552 				((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->nParams,
553 				((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->pParams,
554 				pReturn, pArgs, ppException );
555 		}
556 		break;
557 	}
558 	default:
559 	{
560 		::com::sun::star::uno::RuntimeException aExc(
561 			OUString( RTL_CONSTASCII_USTRINGPARAM("illegal member type description!") ),
562 			::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >() );
563 
564 		Type const & rExcType = ::getCppuType( &aExc );
565 		// binary identical null reference
566 		::uno_type_any_construct( *ppException, &aExc, rExcType.getTypeLibType(), 0 );
567 	}
568 	}
569 }
570 
571 } } }
572