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 #include <malloc.h>
31 #include <com/sun/star/uno/genfunc.hxx>
32 #include <uno/data.h>
33 
34 #include "bridges/cpp_uno/shared/bridge.hxx"
35 #include "bridges/cpp_uno/shared/types.hxx"
36 #include "bridges/cpp_uno/shared/unointerfaceproxy.hxx"
37 #include "bridges/cpp_uno/shared/vtables.hxx"
38 
39 #include "share.hxx"
40 
41 using namespace rtl;
42 using namespace com::sun::star::uno;
43 
44 namespace
45 {
46 //==================================================================================================
47 // The call instruction within the asm section of callVirtualMethod may throw
48 // exceptions.  So that the compiler handles this correctly, it is important
49 // that (a) callVirtualMethod might call dummy_can_throw_anything (although this
50 // never happens at runtime), which in turn can throw exceptions, and (b)
51 // callVirtualMethod is not inlined at its call site (so that any exceptions are
52 // caught which are thrown from the instruction calling callVirtualMethod):
53 
54 void callVirtualMethod( void * pAdjustedThisPtr,
55                         sal_Int32 nVtableIndex,
56                         void * pRegisterReturn,
57                         typelib_TypeClass eReturnType,
58                         sal_Int32 * pStackLongs,
59                         sal_Int32 nStackLongs ) __attribute__((noinline));
60 
61 void callVirtualMethod( void * pAdjustedThisPtr,
62                         sal_Int32 /* nVtableIndex */,
63                         void * pRegisterReturn,
64                         typelib_TypeClass eReturnType,
65 #if OSL_DEBUG_LEVEL > 0
66                         sal_Int32 * pStackLongs,
67                         sal_Int32 nStackLongs)
68 #else
69                         sal_Int32 * /*pStackLongs*/,
70                         sal_Int32 /*nStackLongs*/)
71 #endif
72 {
73 	// parameter list is mixed list of * and values
74 	// reference parameters are pointers
75 
76 	OSL_ENSURE( pStackLongs && pAdjustedThisPtr, "### null ptr!" );
77 	OSL_ENSURE( (sizeof(void *) == 4) &&
78 				 (sizeof(sal_Int32) == 4), "### unexpected size of int!" );
79 	OSL_ENSURE( nStackLongs && pStackLongs, "### no stack in callVirtualMethod !" );
80 
81     // never called
82     if (! pAdjustedThisPtr) CPPU_CURRENT_NAMESPACE::dummy_can_throw_anything("xxx"); // address something
83 
84 	volatile long o0 = 0, o1 = 0; // for register returns
85 	volatile double f0d = 0;
86 	volatile float f0f = 0;
87 	volatile long long saveReg[7];
88 
89 	__asm__ (
90 		// save registers
91 		"std %%l0, [%4]\n\t"
92 		"mov %4, %%l0\n\t"
93 		"mov %%l0, %%l1\n\t"
94 		"add %%l0, 8, %%l0\n\t"
95 		"std %%l2, [%%l0]\n\t"
96 		"add %%l0, 8, %%l0\n\t"
97 		"std %%l4, [%%l0]\n\t"
98 		"add %%l0, 8, %%l0\n\t"
99 		"std %%o0, [%%l0]\n\t"
100 		"add %%l0, 8, %%l0\n\t"
101 		"std %%o2, [%%l0]\n\t"
102 		"add %%l0, 8, %%l0\n\t"
103 		"std %%o4, [%%l0]\n\t"
104 		"add %%l0, 8, %%l0\n\t"
105 		"std %%l6, [%%l0]\n\t"
106 		"mov %%l1, %%l7\n\t"
107 
108 		// increase our own stackframe if necessary
109 		"mov %%sp, %%l3\n\t"		// save stack ptr for readjustment
110 
111 		"subcc %%i5, 7, %%l0\n\t"
112 		"ble .LmoveOn\n\t"
113 		"nop\n\t"
114 
115 		"sll %%l0, 2, %%l0\n\t"
116 		"add %%l0, 96, %%l0\n\t"
117 		"mov %%sp, %%l1\n\t"		// old stack ptr
118 		"sub %%sp, %%l0, %%l0\n\t"	// future stack ptr
119 		"andcc %%l0, 7, %%g0\n\t"	// align stack to 8
120 		"be .LisAligned\n\t"
121 		"nop\n\t"
122 		"sub %%l0, 4, %%l0\n"
123 	".LisAligned:\n\t"
124 		"mov %%l0, %%o5\n\t"			// save newly computed stack ptr
125 		"add %%g0, 16, %%o4\n"
126 
127 		// now copy longs down to save register window
128 		// and local variables
129 	".LcopyDown:\n\t"
130 		"ld [%%l1], %%l2\n\t"
131 		"st %%l2,[%%l0]\n\t"
132 		"add %%l0, 4, %%l0\n\t"
133 		"add %%l1, 4, %%l1\n\t"
134 		"subcc %%o4, 1, %%o4\n\t"
135 		"bne .LcopyDown\n\t"
136 
137 		"mov %%o5, %%sp\n\t"		// move new stack ptr (hopefully) atomically
138 		// while register window is valid in both spaces
139 		// (scheduling might hit in copyDown loop)
140 
141 		"sub %%i5, 7, %%l0\n\t"		// copy parameters past the sixth to stack
142 		"add %%i4, 28, %%l1\n\t"
143 		"add %%sp, 92, %%l2\n"
144 	".LcopyLong:\n\t"
145 		"ld [%%l1], %%o0\n\t"
146 		"st %%o0, [%%l2]\n\t"
147 		"add %%l1, 4, %%l1\n\t"
148 		"add %%l2, 4, %%l2\n\t"
149 		"subcc %%l0, 1, %%l0\n\t"
150 		"bne .LcopyLong\n\t"
151 		"nop\n"
152 
153 	".LmoveOn:\n\t"
154 		"mov %%i5, %%l0\n\t"		// prepare out registers
155 		"mov %%i4, %%l1\n\t"
156 
157 		"ld [%%l1], %%o0\n\t"		// prepare complex return ptr
158 		"st %%o0, [%%sp+64]\n\t"
159 		"sub %%l0, 1, %%l0\n\t"
160 		"add %%l1, 4, %%l1\n\t"
161 
162 		"ld [%%l1], %%o0\n\t"
163 		"subcc %%l0, 1, %%l0\n\t"
164 		"be .LdoCall\n\t"
165 		"nop\n\t"
166 
167 		"add %%l1, 4, %%l1\n\t"
168 		"ld [%%l1], %%o1\n\t"
169 		"subcc %%l0, 1, %%l0\n\t"
170 		"be .LdoCall\n\t"
171 		"nop\n\t"
172 
173 		"add %%l1, 4, %%l1\n\t"
174 		"ld [%%l1], %%o2\n\t"
175 		"subcc %%l0, 1, %%l0\n\t"
176 		"be .LdoCall\n\t"
177 		"nop\n\t"
178 
179 		"add %%l1, 4, %%l1\n\t"
180 		"ld [%%l1], %%o3\n\t"
181 		"subcc %%l0, 1, %%l0\n\t"
182 		"be .LdoCall\n\t"
183 		"nop\n\t"
184 
185 		"add %%l1, 4, %%l1\n\t"
186 		"ld [%%l1], %%o4\n\t"
187 		"subcc %%l0, 1, %%l0\n\t"
188 		"be .LdoCall\n\t"
189 		"nop\n\t"
190 
191 		"add %%l1, 4, %%l1\n\t"
192 		"ld [%%l1], %%o5\n"
193 
194 	".LdoCall:\n\t"
195 		"ld [%%i0], %%l0\n\t"		// get vtable ptr
196 
197 "sll %%i1, 2, %%l6\n\t"
198 //        "add %%l6, 8, %%l6\n\t"
199 		"add %%l6, %%l0, %%l0\n\t"
200 // 		// vtable has 8byte wide entries,
201 // 		// upper half contains 2 half words, of which the first
202 // 		// is the this ptr patch !
203 // 		// first entry is (or __tf)
204 
205 // 		"ldsh [%%l0], %%l6\n\t"		// load this ptr patch
206 // 		"add %%l6, %%o0, %%o0\n\t"	// patch this ptr
207 
208 // 		"add %%l0, 4, %%l0\n\t"		// get virtual function ptr
209 		"ld [%%l0], %%l0\n\t"
210 
211 		"ld [%%i4], %%l2\n\t"
212 		"subcc %%l2, %%g0, %%l2\n\t"
213 		"bne .LcomplexCall\n\t"
214 		"nop\n\t"
215 		"call %%l0\n\t"
216 		"nop\n\t"
217 		"ba .LcallReturned\n\t"
218 		"nop\n"
219 	".LcomplexCall:\n\t"
220 		"call %%l0\n\t"
221 		"nop\n\t"
222 		"unimp\n"
223 
224 	".LcallReturned:\n\t"
225 		"mov %%l3, %%sp\n\t"		// readjust stack so that our locals are where they belong
226 		"st %%o0, %0\n\t"			// save possible return registers into our locals
227 		"st %%o1, %1\n\t"
228 		"std %%f0, %2\n\t"
229 		"st %%f0, %3\n\t"
230 
231 		// restore registers
232 		"ldd [%%l7], %%l0\n\t"
233 		"add %%l7, 8, %%l7\n\t"
234 		"ldd [%%l7], %%l2\n\t"
235 		"add %%l7, 8, %%l7\n\t"
236 		"ldd [%%l7], %%l4\n\t"
237 		"add %%l7, 8, %%l7\n\t"
238 		"ldd [%%l7], %%o0\n\t"
239 		"add %%l7, 8, %%l7\n\t"
240 		"ldd [%%l7], %%o2\n\t"
241 		"add %%l7, 8, %%l7\n\t"
242 		"ldd [%%l7], %%o4\n\t"
243 		"add %%l7, 8, %%l7\n\t"
244 		"ldd [%%l7], %%l6\n\t"
245 		: :
246 		"m"(o0),
247 		"m"(o1),
248 		"m"(f0d),
249 		"m"(f0f),
250 		"r"(&saveReg[0])
251 		);
252 	switch( eReturnType )
253 	{
254 		case typelib_TypeClass_HYPER:
255 		case typelib_TypeClass_UNSIGNED_HYPER:
256 			((long*)pRegisterReturn)[1] = o1;
257 		case typelib_TypeClass_LONG:
258 		case typelib_TypeClass_UNSIGNED_LONG:
259 		case typelib_TypeClass_ENUM:
260 			((long*)pRegisterReturn)[0] = o0;
261 			break;
262 		case typelib_TypeClass_CHAR:
263 		case typelib_TypeClass_SHORT:
264 		case typelib_TypeClass_UNSIGNED_SHORT:
265 			*(unsigned short*)pRegisterReturn = (unsigned short)o0;
266 			break;
267 		case typelib_TypeClass_BOOLEAN:
268 		case typelib_TypeClass_BYTE:
269 			*(unsigned char*)pRegisterReturn = (unsigned char)o0;
270 			break;
271 		case typelib_TypeClass_FLOAT:
272 			*(float*)pRegisterReturn = f0f;
273 			break;
274 		case typelib_TypeClass_DOUBLE:
275 			*(double*)pRegisterReturn = f0d;
276 			break;
277 		default:
278 			break;
279 	}
280 }
281 
282 //=================================================================================================
283 static void cpp_call(
284 	bridges::cpp_uno::shared::UnoInterfaceProxy * pThis,
285 	bridges::cpp_uno::shared::VtableSlot aVtableSlot,
286 	typelib_TypeDescriptionReference * pReturnTypeRef,
287 	sal_Int32 nParams, typelib_MethodParameter * pParams,
288 	void * pUnoReturn, void * pUnoArgs[], uno_Any ** ppUnoExc )
289 {
290   	// max space for: complex ret ptr, this, values|ptr ...
291   	char * pCppStack	=
292   		(char *)alloca( (nParams+2) * sizeof(sal_Int64) );
293   	char * pCppStackStart	= pCppStack;
294 
295 	// return
296 	typelib_TypeDescription * pReturnTypeDescr = 0;
297 	TYPELIB_DANGER_GET( &pReturnTypeDescr, pReturnTypeRef );
298 	OSL_ENSURE( pReturnTypeDescr, "### expected return type description!" );
299 
300 	void * pCppReturn = 0; // if != 0 && != pUnoReturn, needs reconversion
301 
302 	if (pReturnTypeDescr)
303 	{
304 		if (bridges::cpp_uno::shared::isSimpleType( pReturnTypeDescr ))
305 		{
306 			pCppReturn = pUnoReturn; // direct way for simple types
307 			*(void**)pCppStack = NULL;
308 		}
309 		else
310 		{
311 			// complex return via ptr
312 			pCppReturn = *(void **)pCppStack = (bridges::cpp_uno::shared::relatesToInterfaceType(pReturnTypeDescr )
313 												? alloca( pReturnTypeDescr->nSize )
314 												: pUnoReturn); // direct way
315 		}
316 		pCppStack += sizeof(void*);
317 	}
318 	// push this
319 	void * pAdjustedThisPtr = reinterpret_cast< void ** >(pThis->getCppI())
320   	       + aVtableSlot.offset;
321   	       *(void**)pCppStack = pAdjustedThisPtr;
322 	pCppStack += sizeof( void* );
323 
324 	// stack space
325 	OSL_ENSURE( sizeof(void *) == sizeof(sal_Int32), "### unexpected size!" );
326 	// args
327 	void ** pCppArgs  = (void **)alloca( 3 * sizeof(void *) * nParams );
328 	// indizes of values this have to be converted (interface conversion cpp<=>uno)
329 	sal_Int32 * pTempIndizes = (sal_Int32 *)(pCppArgs + nParams);
330 	// type descriptions for reconversions
331 	typelib_TypeDescription ** ppTempParamTypeDescr = (typelib_TypeDescription **)(pCppArgs + (2 * nParams));
332 
333 	sal_Int32 nTempIndizes   = 0;
334 
335 	for ( sal_Int32 nPos = 0; nPos < nParams; ++nPos )
336 	{
337 		const typelib_MethodParameter & rParam = pParams[nPos];
338 		typelib_TypeDescription * pParamTypeDescr = 0;
339 		TYPELIB_DANGER_GET( &pParamTypeDescr, rParam.pTypeRef );
340 		if (!rParam.bOut && bridges::cpp_uno::shared::isSimpleType( pParamTypeDescr ))
341 		{
342 			pCppArgs[ nPos ] = CPPU_CURRENT_NAMESPACE::adjustPointer(pCppStack, pParamTypeDescr );
343 
344 			switch (pParamTypeDescr->eTypeClass)
345 			{
346 			case typelib_TypeClass_HYPER:
347 			case typelib_TypeClass_UNSIGNED_HYPER:
348 			case typelib_TypeClass_DOUBLE:
349                         OSL_ASSERT( sizeof (double) == sizeof (sal_Int64) );
350                           *reinterpret_cast< sal_Int32 * >(pCppStack) =
351                           *reinterpret_cast< sal_Int32 const * >(pUnoArgs[ nPos ]);
352                           pCppStack += sizeof (sal_Int32);
353                           *reinterpret_cast< sal_Int32 * >(pCppStack) =
354                           *(reinterpret_cast< sal_Int32 const * >(pUnoArgs[ nPos ] ) + 1);
355                           break;
356             		default:
357                           uno_copyAndConvertData(
358                              pCppArgs[nPos], pUnoArgs[nPos], pParamTypeDescr,
359                             pThis->getBridge()->getUno2Cpp() );
360                           break;
361                         }
362 			// no longer needed
363 			TYPELIB_DANGER_RELEASE( pParamTypeDescr );
364 		}
365 		else // ptr to complex value | ref
366 		{
367 			if (! rParam.bIn) // is pure out
368 			{
369 				// cpp out is constructed mem, uno out is not!
370 				uno_constructData(
371 					*(void **)pCppStack = pCppArgs[nPos] = alloca( pParamTypeDescr->nSize ),
372 					pParamTypeDescr );
373 				pTempIndizes[nTempIndizes] = nPos; // default constructed for cpp call
374 				// will be released at reconversion
375 				ppTempParamTypeDescr[nTempIndizes++] = pParamTypeDescr;
376 			}
377 			// is in/inout
378 			else if (bridges::cpp_uno::shared::relatesToInterfaceType(
379   	                        pParamTypeDescr ))
380 			{
381 				uno_copyAndConvertData(
382 					*(void **)pCppStack = pCppArgs[nPos] = alloca( pParamTypeDescr->nSize ),
383                                 	pUnoArgs[nPos], pParamTypeDescr,
384 					pThis->getBridge()->getUno2Cpp() );
385 
386 				pTempIndizes[nTempIndizes] = nPos; // has to be reconverted
387 				// will be released at reconversion
388 				ppTempParamTypeDescr[nTempIndizes++] = pParamTypeDescr;
389 			}
390 			else // direct way
391 			{
392 				*(void **)pCppStack = pCppArgs[nPos] = pUnoArgs[nPos];
393 				// no longer needed
394 				TYPELIB_DANGER_RELEASE( pParamTypeDescr );
395 			}
396 		}
397 		pCppStack += sizeof(sal_Int32); // standard parameter length
398 	}
399 
400 	try
401 	{
402 		int nStackLongs = (pCppStack - pCppStackStart)/sizeof(sal_Int32);
403 		OSL_ENSURE( !( (pCppStack - pCppStackStart ) & 3), "UNALIGNED STACK !!! (Please DO panic" );
404 
405 		if( nStackLongs & 1 )
406 			// stack has to be 8 byte aligned
407 			nStackLongs++;
408 		callVirtualMethod(
409 			pAdjustedThisPtr,
410 			aVtableSlot.index,
411 			pCppReturn,
412 			pReturnTypeDescr->eTypeClass,
413 			(sal_Int32 *)pCppStackStart,
414 			 nStackLongs);
415 		// NO exception occured...
416 		*ppUnoExc = 0;
417 
418 		// reconvert temporary params
419 		for ( ; nTempIndizes--; )
420 		{
421 			sal_Int32 nIndex = pTempIndizes[nTempIndizes];
422 			typelib_TypeDescription * pParamTypeDescr = ppTempParamTypeDescr[nTempIndizes];
423 
424 			if (pParams[nIndex].bIn)
425 			{
426 				if (pParams[nIndex].bOut) // inout
427 				{
428 					uno_destructData( pUnoArgs[nIndex], pParamTypeDescr, 0 ); // destroy uno value
429 					uno_copyAndConvertData( pUnoArgs[nIndex], pCppArgs[nIndex], pParamTypeDescr,
430 											pThis->getBridge()->getCpp2Uno() );
431 				}
432 			}
433 			else // pure out
434 			{
435 				uno_copyAndConvertData( pUnoArgs[nIndex], pCppArgs[nIndex], pParamTypeDescr,
436 										pThis->getBridge()->getCpp2Uno() );
437 			}
438 			// destroy temp cpp param => cpp: every param was constructed
439 			uno_destructData( pCppArgs[nIndex], pParamTypeDescr, cpp_release );
440 
441 			TYPELIB_DANGER_RELEASE( pParamTypeDescr );
442 		}
443 		// return value
444 		if (pCppReturn && pUnoReturn != pCppReturn)
445 		{
446 			uno_copyAndConvertData( pUnoReturn, pCppReturn, pReturnTypeDescr,
447 									pThis->getBridge()->getCpp2Uno() );
448 			uno_destructData( pCppReturn, pReturnTypeDescr, cpp_release );
449 		}
450 	}
451  	catch( ... )
452  	{
453  		// get exception
454 		   fillUnoException( CPPU_CURRENT_NAMESPACE::__cxa_get_globals()->caughtExceptions,
455 								*ppUnoExc, pThis->getBridge()->getCpp2Uno() );
456 
457 		// temporary params
458 		for ( ; nTempIndizes--; )
459 		{
460 			sal_Int32 nIndex = pTempIndizes[nTempIndizes];
461 			// destroy temp cpp param => cpp: every param was constructed
462 			uno_destructData( pCppArgs[nIndex], ppTempParamTypeDescr[nTempIndizes], cpp_release );
463 			TYPELIB_DANGER_RELEASE( ppTempParamTypeDescr[nTempIndizes] );
464 		}
465 		// return type
466 		if (pReturnTypeDescr)
467 			TYPELIB_DANGER_RELEASE( pReturnTypeDescr );
468 	}
469 }
470 
471 }
472 
473 namespace bridges { namespace cpp_uno { namespace shared {
474 
475 void unoInterfaceProxyDispatch(
476 	uno_Interface * pUnoI, const typelib_TypeDescription * pMemberDescr,
477     void * pReturn, void * pArgs[], uno_Any ** ppException )
478 {
479 #if defined BRIDGES_DEBUG
480     OString cstr( OUStringToOString( pMemberDescr->pTypeName, RTL_TEXTENCODING_ASCII_US ) );
481     fprintf( stderr, "received dispatch( %s )\n", cstr.getStr() );
482 #endif
483 
484 	// is my surrogate
485 	bridges::cpp_uno::shared::UnoInterfaceProxy * pThis
486        = static_cast< bridges::cpp_uno::shared::UnoInterfaceProxy * >(pUnoI);
487 //	typelib_InterfaceTypeDescription * pTypeDescr = pThis->pTypeDescr;
488 
489 	switch (pMemberDescr->eTypeClass)
490 	{
491 	case typelib_TypeClass_INTERFACE_ATTRIBUTE:
492 	{
493 	 VtableSlot aVtableSlot(
494   	           getVtableSlot(
495   	               reinterpret_cast<
496   	                   typelib_InterfaceAttributeTypeDescription const * >(
497   	                       pMemberDescr)));
498 		if (pReturn)
499 		{
500 			// dependent dispatch
501 			cpp_call(
502 				pThis, aVtableSlot,
503 				((typelib_InterfaceAttributeTypeDescription *)pMemberDescr)->pAttributeTypeRef,
504 				0, 0, // no params
505 				pReturn, pArgs, ppException );
506 		}
507 		else
508 		{
509 			// is SET
510 			typelib_MethodParameter aParam;
511 			aParam.pTypeRef =
512 				((typelib_InterfaceAttributeTypeDescription *)pMemberDescr)->pAttributeTypeRef;
513 			aParam.bIn		= sal_True;
514 			aParam.bOut		= sal_False;
515 
516 			typelib_TypeDescriptionReference * pReturnTypeRef = 0;
517 			OUString aVoidName( RTL_CONSTASCII_USTRINGPARAM("void") );
518 			typelib_typedescriptionreference_new(
519 				&pReturnTypeRef, typelib_TypeClass_VOID, aVoidName.pData );
520 
521 			// dependent dispatch
522 			aVtableSlot.index += 1; // get, then set method
523 			cpp_call(
524 				pThis, aVtableSlot,
525 				pReturnTypeRef,
526 				1, &aParam,
527 				pReturn, pArgs, ppException );
528 
529 			typelib_typedescriptionreference_release( pReturnTypeRef );
530 		}
531 
532 		break;
533 	}
534 	case typelib_TypeClass_INTERFACE_METHOD:
535 	{
536 		VtableSlot aVtableSlot(
537 		getVtableSlot(
538 		 reinterpret_cast<
539 		  typelib_InterfaceMethodTypeDescription const * >(
540 		  pMemberDescr)));
541 		switch (aVtableSlot.index)
542 		{
543 			// standard calls
544 		case 1: // acquire uno interface
545 			(*pUnoI->acquire)( pUnoI );
546 			*ppException = 0;
547 			break;
548 		case 2: // release uno interface
549 			(*pUnoI->release)( pUnoI );
550 			*ppException = 0;
551 			break;
552 		case 0: // queryInterface() opt
553 		{
554 			typelib_TypeDescription * pTD = 0;
555 			TYPELIB_DANGER_GET( &pTD, reinterpret_cast< Type * >( pArgs[0] )->getTypeLibType() );
556 			if (pTD)
557 			{
558                 uno_Interface * pInterface = 0;
559  		(*pThis->pBridge->getUnoEnv()->getRegisteredInterface)(
560  		  pThis->pBridge->getUnoEnv(),
561 				   (void **)&pInterface, pThis->oid.pData, (typelib_InterfaceTypeDescription *)pTD );
562 
563                 if (pInterface)
564                 {
565                     ::uno_any_construct(
566                         reinterpret_cast< uno_Any * >( pReturn ),
567                         &pInterface, pTD, 0 );
568                     (*pInterface->release)( pInterface );
569                     TYPELIB_DANGER_RELEASE( pTD );
570                     *ppException = 0;
571                     break;
572                 }
573                 TYPELIB_DANGER_RELEASE( pTD );
574             }
575 		} // else perform queryInterface()
576 		default:
577 			// dependent dispatch
578 			cpp_call(
579 				pThis, aVtableSlot,
580 				((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->pReturnTypeRef,
581 				((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->nParams,
582 				((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->pParams,
583 				pReturn, pArgs, ppException );
584 		}
585 		break;
586 	}
587 	default:
588 	{
589 		::com::sun::star::uno::RuntimeException aExc(
590 			OUString( RTL_CONSTASCII_USTRINGPARAM("illegal member type description!") ),
591 			::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >() );
592 
593 		Type const & rExcType = ::getCppuType( &aExc );
594 		// binary identical null reference
595 		::uno_type_any_construct( *ppException, &aExc, rExcType.getTypeLibType(), 0 );
596 	}
597 	}
598 }
599 
600 } } }
601