merge the formfield patch from ooo-build
[ooovba.git] / bridges / source / cpp_uno / gcc3_linux_ia64 / uno2cpp.cxx
blobbee7f3a3397c89d1a07293d0ec06d11b44e1b64b
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: uno2cpp.cxx,v $
10 * $Revision: 1.3 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_bridges.hxx"
34 #include <malloc.h>
36 #include <com/sun/star/uno/genfunc.hxx>
37 #include <uno/data.h>
39 #include "bridges/cpp_uno/shared/bridge.hxx"
40 #include "bridges/cpp_uno/shared/types.hxx"
41 #include "bridges/cpp_uno/shared/unointerfaceproxy.hxx"
42 #include "bridges/cpp_uno/shared/vtables.hxx"
44 #include "share.hxx"
46 #include <stdio.h>
47 #include <string.h>
50 using namespace ::rtl;
51 using namespace ::com::sun::star::uno;
53 void MapReturn(const ia64::RegReturn &rRet, double dret, typelib_TypeDescription * pReturnTypeDescr, bool bSimpleReturn, sal_uInt64 *pRegisterReturn)
55 switch (pReturnTypeDescr->eTypeClass)
57 case typelib_TypeClass_HYPER:
58 case typelib_TypeClass_UNSIGNED_HYPER:
59 case typelib_TypeClass_LONG:
60 case typelib_TypeClass_UNSIGNED_LONG:
61 case typelib_TypeClass_ENUM:
62 *pRegisterReturn = rRet.r8;
63 break;
64 case typelib_TypeClass_CHAR:
65 case typelib_TypeClass_SHORT:
66 case typelib_TypeClass_UNSIGNED_SHORT:
67 *pRegisterReturn = (unsigned short)rRet.r8;
68 break;
69 case typelib_TypeClass_BOOLEAN:
70 case typelib_TypeClass_BYTE:
71 *pRegisterReturn = (unsigned char)rRet.r8;
72 break;
73 case typelib_TypeClass_FLOAT:
74 *reinterpret_cast<float *>( pRegisterReturn ) = dret;
75 break;
76 case typelib_TypeClass_DOUBLE:
77 *reinterpret_cast<double *>( pRegisterReturn ) = dret;
78 break;
79 case typelib_TypeClass_STRUCT:
80 case typelib_TypeClass_EXCEPTION:
82 sal_uInt32 nRetSize = pReturnTypeDescr->nSize;
83 if (bSimpleReturn && nRetSize <= 32 && nRetSize > 0)
84 memcpy(pRegisterReturn, (void*)&rRet, nRetSize);
85 break;
87 default:
88 break;
92 namespace ia64
94 bool is_complex_struct( typelib_TypeDescriptionReference *pTypeRef )
96 if (pTypeRef->eTypeClass == typelib_TypeClass_STRUCT || pTypeRef->eTypeClass == typelib_TypeClass_EXCEPTION)
98 typelib_TypeDescription * pTypeDescr = 0;
99 TYPELIB_DANGER_GET( &pTypeDescr, pTypeRef );
101 bool bRet = bridges::cpp_uno::shared::relatesToInterfaceType( pTypeDescr );
102 TYPELIB_DANGER_RELEASE( pTypeDescr );
104 return bRet;
106 return false;
109 bool return_via_r8_buffer( typelib_TypeDescriptionReference *pTypeRef )
111 if (pTypeRef->eTypeClass == typelib_TypeClass_STRUCT || pTypeRef->eTypeClass == typelib_TypeClass_EXCEPTION)
113 if (is_complex_struct( pTypeRef )) return false;
115 typelib_TypeDescription * pTypeDescr = 0;
116 TYPELIB_DANGER_GET( &pTypeDescr, pTypeRef );
118 /* If the struct is larger than 32 bytes, then there is a buffer at r8 to stick the return value into */
119 bool bRet = pTypeDescr->nSize > 32;
120 TYPELIB_DANGER_RELEASE( pTypeDescr );
121 return bRet;
123 return false;
126 bool return_in_hidden_param( typelib_TypeDescriptionReference *pTypeRef )
128 if (bridges::cpp_uno::shared::isSimpleType(pTypeRef))
129 return false;
130 else if (pTypeRef->eTypeClass == typelib_TypeClass_STRUCT || pTypeRef->eTypeClass == typelib_TypeClass_EXCEPTION)
131 return is_complex_struct( pTypeRef );
132 return true;
138 namespace
140 //==================================================================================================
141 static void callVirtualMethod(void * pThis, sal_uInt32 nVtableIndex,
142 void * pRegisterReturn, typelib_TypeDescription * pReturnTypeDescr, bool bSimpleReturn,
143 sal_uInt64 *pStack, sal_uInt32 nStack,
144 sal_uInt64 *pGPR, sal_uInt32 nGPR,
145 double *pFPR, sal_uInt32 nFPR)
147 // Stack, if used, must be 16-bytes aligned
148 if ( nStack )
149 nStack = ( nStack + 1 ) & ~1;
151 // Should not happen, but...
152 if ( nFPR > ia64::MAX_SSE_REGS )
153 nFPR = ia64::MAX_SSE_REGS;
154 if ( nGPR > ia64::MAX_GPR_REGS )
155 nGPR = ia64::MAX_GPR_REGS;
157 #ifdef CMC_DEBUG
158 // Let's figure out what is really going on here
160 fprintf( stderr, "= callVirtualMethod() =\nGPR's (%d): ", nGPR );
161 for ( unsigned int i = 0; i < nGPR; ++i )
162 fprintf( stderr, "0x%lx, ", pGPR[i] );
163 fprintf( stderr, "\nFPR's (%d): ", nFPR );
164 for ( unsigned int i = 0; i < nFPR; ++i )
165 fprintf( stderr, "0x%lx (%f), ", pFPR[i], pFPR[i] );
166 fprintf( stderr, "\nStack (%d): ", nStack );
167 for ( unsigned int i = 0; i < nStack; ++i )
168 fprintf( stderr, "0x%lx, ", pStack[i] );
169 fprintf( stderr, "\n" );
170 fprintf( stderr, "pRegisterReturn is %p\n", pRegisterReturn);
172 #endif
174 // Load parameters to stack, if necessary
175 sal_uInt64 *stack = (sal_uInt64 *) __builtin_alloca( nStack * 8 );
176 memcpy( stack, pStack, nStack * 8 );
178 // To get pointer to method
179 // a) get the address of the vtable
180 sal_uInt64 pMethod = *((sal_uInt64 *)pThis);
181 // b) get the address from the vtable entry at offset, each entry is 16bytes,
182 // 8 for function pointer, and 8 for global pointer
183 pMethod += 16 * nVtableIndex;
185 typedef void (* FunctionCall )( sal_uInt64, sal_uInt64, sal_uInt64, sal_uInt64, sal_uInt64, sal_uInt64, sal_uInt64, sal_uInt64 );
186 FunctionCall pFunc = (FunctionCall)pMethod;
188 switch (nFPR) //deliberate fall through
190 case 8:
191 asm volatile("ldfd f15=%0" : : "m"(pFPR[7]) : "f15");
192 case 7:
193 asm volatile("ldfd f14=%0" : : "m"(pFPR[6]) : "f14");
194 case 6:
195 asm volatile("ldfd f13=%0" : : "m"(pFPR[5]) : "f13");
196 case 5:
197 asm volatile("ldfd f12=%0" : : "m"(pFPR[4]) : "f12");
198 case 4:
199 asm volatile("ldfd f11=%0" : : "m"(pFPR[3]) : "f11");
200 case 3:
201 asm volatile("ldfd f10=%0" : : "m"(pFPR[2]) : "f10");
202 case 2:
203 asm volatile("ldfd f9=%0" : : "m"(pFPR[1]) : "f9");
204 case 1:
205 asm volatile("ldfd f8=%0" : : "m"(pFPR[0]) : "f8");
206 default:
207 break;
210 //stick the return area into r8 for big struct returning
211 asm volatile("ld8 r8=%0" : : "m"(pRegisterReturn) : "r8");
213 (*pFunc)(pGPR[0], pGPR[1], pGPR[2], pGPR[3], pGPR[4], pGPR[5], pGPR[6], pGPR[7]);
215 register double f8 asm("f8");
216 ia64::RegReturn ret;
218 register long r8 asm("r8"); ret.r8 = r8;
219 register long r9 asm("r9"); ret.r9 = r9;
220 register long r10 asm("r10"); ret.r10 = r10;
221 register long r11 asm("r11"); ret.r11 = r11;
224 MapReturn(ret, f8, pReturnTypeDescr, bSimpleReturn, (sal_uInt64*)pRegisterReturn);
227 // Macros for easier insertion of values to registers or stack
228 // pSV - pointer to the source
229 // nr - order of the value [will be increased if stored to register]
230 // pFPR, pGPR - pointer to the registers
231 // pDS - pointer to the stack [will be increased if stored here]
233 // The value in %xmm register is already prepared to be retrieved as a float,
234 // thus we treat float and double the same
235 #define INSERT_FLOAT( pSV, nfr, pFPR, ngr, pGPR, pDS, bOverflow ) \
236 if ( nfr < ia64::MAX_SSE_REGS && ngr < ia64::MAX_GPR_REGS ) \
237 pFPR[nfr++] = *reinterpret_cast<float *>( pSV ); \
238 if ( ngr < ia64::MAX_GPR_REGS ) \
239 pGPR[ngr++] = *reinterpret_cast<sal_uInt64 *>( pSV ); \
240 else \
241 bOverFlow = true; \
242 if (bOverFlow) \
243 *pDS++ = *reinterpret_cast<sal_uInt64 *>( pSV ); // verbatim!
245 #define INSERT_DOUBLE( pSV, nfr, pFPR, ngr, pGPR, pDS, bOverflow ) \
246 if ( nfr < ia64::MAX_SSE_REGS && ngr < ia64::MAX_GPR_REGS ) \
247 pFPR[nfr++] = *reinterpret_cast<double *>( pSV ); \
248 if ( ngr < ia64::MAX_GPR_REGS ) \
249 pGPR[ngr++] = *reinterpret_cast<sal_uInt64 *>( pSV ); \
250 else \
251 bOverFlow = true; \
252 if (bOverFlow) \
253 *pDS++ = *reinterpret_cast<sal_uInt64 *>( pSV ); // verbatim!
255 #define INSERT_INT64( pSV, nr, pGPR, pDS, bOverflow ) \
256 if ( nr < ia64::MAX_GPR_REGS ) \
257 pGPR[nr++] = *reinterpret_cast<sal_uInt64 *>( pSV ); \
258 else \
259 bOverFlow = true; \
260 if (bOverFlow) \
261 *pDS++ = *reinterpret_cast<sal_uInt64 *>( pSV );
263 #define INSERT_INT32( pSV, nr, pGPR, pDS, bOverflow ) \
264 if ( nr < ia64::MAX_GPR_REGS ) \
265 pGPR[nr++] = *reinterpret_cast<sal_uInt32 *>( pSV ); \
266 else \
267 bOverFlow = true; \
268 if (bOverFlow) \
269 *pDS++ = *reinterpret_cast<sal_uInt32 *>( pSV );
271 #define INSERT_INT16( pSV, nr, pGPR, pDS, bOverflow ) \
272 if ( nr < ia64::MAX_GPR_REGS ) \
273 pGPR[nr++] = *reinterpret_cast<sal_uInt16 *>( pSV ); \
274 else \
275 bOverFlow = true; \
276 if (bOverFlow) \
277 *pDS++ = *reinterpret_cast<sal_uInt16 *>( pSV );
279 #define INSERT_INT8( pSV, nr, pGPR, pDS, bOverflow ) \
280 if ( nr < ia64::MAX_GPR_REGS ) \
281 pGPR[nr++] = *reinterpret_cast<sal_uInt8 *>( pSV ); \
282 else \
283 bOverFlow = true; \
284 if (bOverFlow) \
285 *pDS++ = *reinterpret_cast<sal_uInt8 *>( pSV );
287 //==================================================================================================
288 static void cpp_call(
289 bridges::cpp_uno::shared::UnoInterfaceProxy * pThis,
290 bridges::cpp_uno::shared::VtableSlot aVtableSlot,
291 typelib_TypeDescriptionReference * pReturnTypeRef,
292 sal_Int32 nParams, typelib_MethodParameter * pParams,
293 void * pUnoReturn, void * pUnoArgs[], uno_Any ** ppUnoExc )
295 // max space for: [complex ret ptr], values|ptr ...
296 sal_uInt64 * pStack = (sal_uInt64 *)alloca( (nParams+3) * sizeof(sal_Int64) );
297 sal_uInt64 * pStackStart = pStack;
299 sal_uInt64 pGPR[ia64::MAX_GPR_REGS];
300 sal_uInt32 nGPR = 0;
302 double pFPR[ia64::MAX_SSE_REGS];
303 sal_uInt32 nFPR = 0;
305 // return
306 typelib_TypeDescription * pReturnTypeDescr = 0;
307 TYPELIB_DANGER_GET( &pReturnTypeDescr, pReturnTypeRef );
308 OSL_ENSURE( pReturnTypeDescr, "### expected return type description!" );
310 void * pCppReturn = 0; // if != 0 && != pUnoReturn, needs reconversion
312 bool bOverFlow = false;
314 bool bSimpleReturn = true;
315 if (pReturnTypeDescr)
317 #ifdef CMC_DEBUG
318 fprintf(stderr, "return type is %d\n", pReturnTypeDescr->eTypeClass);
319 #endif
320 if ( ia64::return_in_hidden_param(pReturnTypeRef) || ia64::return_via_r8_buffer(pReturnTypeRef) )
321 bSimpleReturn = false;
323 if ( bSimpleReturn )
325 pCppReturn = pUnoReturn; // direct way for simple types
326 #ifdef CMC_DEBUG
327 fprintf(stderr, "simple return\n");
328 #endif
330 else
332 // complex return via ptr
333 pCppReturn = (bridges::cpp_uno::shared::relatesToInterfaceType( pReturnTypeDescr )
334 ? alloca( pReturnTypeDescr->nSize ) : pUnoReturn);
335 #ifdef CMC_DEBUG
336 fprintf(stderr, "pCppReturn/pUnoReturn is %lx/%lx", pCppReturn, pUnoReturn);
337 #endif
338 if (!ia64::return_via_r8_buffer(pReturnTypeRef))
339 INSERT_INT64( &pCppReturn, nGPR, pGPR, pStack, bOverFlow );
342 // push "this" pointer
343 void * pAdjustedThisPtr = reinterpret_cast< void ** >( pThis->getCppI() ) + aVtableSlot.offset;
345 #ifdef CMC_DEBUG
346 fprintf(stderr, "this pointer is %p\n", pAdjustedThisPtr);
347 #endif
348 INSERT_INT64( &pAdjustedThisPtr, nGPR, pGPR, pStack, bOverFlow );
350 // Args
351 void ** pCppArgs = (void **)alloca( 3 * sizeof(void *) * nParams );
352 // indizes of values this have to be converted (interface conversion cpp<=>uno)
353 sal_Int32 * pTempIndizes = (sal_Int32 *)(pCppArgs + nParams);
354 // type descriptions for reconversions
355 typelib_TypeDescription ** ppTempParamTypeDescr = (typelib_TypeDescription **)(pCppArgs + (2 * nParams));
357 sal_Int32 nTempIndizes = 0;
359 #ifdef CMC_DEBUG
360 fprintf(stderr, "n params is %d\n", nParams);
361 #endif
363 for ( sal_Int32 nPos = 0; nPos < nParams; ++nPos )
365 const typelib_MethodParameter & rParam = pParams[nPos];
366 typelib_TypeDescription * pParamTypeDescr = 0;
367 TYPELIB_DANGER_GET( &pParamTypeDescr, rParam.pTypeRef );
369 #ifdef CMC_DEBUG
370 fprintf(stderr, "param %d is %d %d %d\n", nPos, rParam.bOut, bridges::cpp_uno::shared::isSimpleType( pParamTypeDescr ),
371 pParamTypeDescr->eTypeClass);
372 #endif
374 if (!rParam.bOut && bridges::cpp_uno::shared::isSimpleType( pParamTypeDescr ))
376 // uno_copyAndConvertData( pCppArgs[nPos] = alloca( 8 ), pUnoArgs[nPos], pParamTypeDescr,
377 uno_copyAndConvertData( pCppArgs[nPos] = pStack, pUnoArgs[nPos], pParamTypeDescr,
378 pThis->getBridge()->getUno2Cpp() );
379 switch (pParamTypeDescr->eTypeClass)
381 case typelib_TypeClass_HYPER:
382 case typelib_TypeClass_UNSIGNED_HYPER:
383 #ifdef CMC_DEBUG
384 fprintf(stderr, "hyper is %lx\n", *(unsigned long*)(pCppArgs[nPos]));
385 #endif
386 INSERT_INT64( pCppArgs[nPos], nGPR, pGPR, pStack, bOverFlow );
387 break;
388 case typelib_TypeClass_LONG:
389 case typelib_TypeClass_UNSIGNED_LONG:
390 case typelib_TypeClass_ENUM:
391 #ifdef CMC_DEBUG
392 fprintf(stderr, "long is %lx\n", *(unsigned int*)(pCppArgs[nPos]));
393 #endif
394 INSERT_INT32( pCppArgs[nPos], nGPR, pGPR, pStack, bOverFlow );
395 break;
396 case typelib_TypeClass_SHORT:
397 case typelib_TypeClass_CHAR:
398 case typelib_TypeClass_UNSIGNED_SHORT:
399 #ifdef CMC_DEBUG
400 fprintf(stderr, "short is %x\n", *(unsigned short*)(pCppArgs[nPos]));
401 #endif
402 INSERT_INT16( pCppArgs[nPos], nGPR, pGPR, pStack, bOverFlow );
403 break;
404 case typelib_TypeClass_BOOLEAN:
405 case typelib_TypeClass_BYTE:
406 #ifdef CMC_DEBUG
407 fprintf(stderr, "byte is %x\n", *(unsigned char*)(pCppArgs[nPos]));
408 #endif
409 INSERT_INT8( pCppArgs[nPos], nGPR, pGPR, pStack, bOverFlow );
410 break;
411 case typelib_TypeClass_FLOAT:
412 #ifdef CMC_DEBUG
413 fprintf(stderr, "a float is %f\n", *(float*)(pCppArgs[nPos]));
414 fprintf(stderr, "b float is %f\n", *(double*)(pCppArgs[nPos]));
415 #endif
416 INSERT_FLOAT( pCppArgs[nPos], nFPR, pFPR, nGPR, pGPR, pStack, bOverFlow );
417 break;
418 case typelib_TypeClass_DOUBLE:
419 #ifdef CMC_DEBUG
420 fprintf(stderr, "double is %f\n", *(double*)(pCppArgs[nPos]));
421 #endif
422 INSERT_DOUBLE( pCppArgs[nPos], nFPR, pFPR, nGPR, pGPR, pStack, bOverFlow );
423 break;
424 default:
425 break;
428 // no longer needed
429 TYPELIB_DANGER_RELEASE( pParamTypeDescr );
432 else // ptr to complex value | ref
434 #ifdef CMC_DEBUG
435 fprintf(stderr, "complex type again %d\n", rParam.bIn);
436 #endif
437 if (! rParam.bIn) // is pure out
439 #ifdef CMC_DEBUG
440 fprintf(stderr, "complex size is %d\n", pParamTypeDescr->nSize );
441 #endif
442 // cpp out is constructed mem, uno out is not!
443 uno_constructData(
444 pCppArgs[nPos] = alloca( pParamTypeDescr->nSize ),
445 pParamTypeDescr );
446 pTempIndizes[nTempIndizes] = nPos; // default constructed for cpp call
447 // will be released at reconversion
448 ppTempParamTypeDescr[nTempIndizes++] = pParamTypeDescr;
450 // is in/inout
451 else if (bridges::cpp_uno::shared::relatesToInterfaceType( pParamTypeDescr ))
453 #ifdef CMC_DEBUG
454 fprintf(stderr, "this one\n");
455 #endif
456 uno_copyAndConvertData(
457 pCppArgs[nPos] = alloca( pParamTypeDescr->nSize ),
458 pUnoArgs[nPos], pParamTypeDescr, pThis->getBridge()->getUno2Cpp() );
460 pTempIndizes[nTempIndizes] = nPos; // has to be reconverted
461 // will be released at reconversion
462 ppTempParamTypeDescr[nTempIndizes++] = pParamTypeDescr;
464 else // direct way
466 #ifdef CMC_DEBUG
467 fprintf(stderr, "that one, passing %lx through\n", pUnoArgs[nPos]);
468 #endif
469 pCppArgs[nPos] = pUnoArgs[nPos];
470 // no longer needed
471 TYPELIB_DANGER_RELEASE( pParamTypeDescr );
473 INSERT_INT64( &(pCppArgs[nPos]), nGPR, pGPR, pStack, bOverFlow );
479 callVirtualMethod(
480 pAdjustedThisPtr, aVtableSlot.index,
481 pCppReturn, pReturnTypeDescr, bSimpleReturn,
482 pStackStart, ( pStack - pStackStart ),
483 pGPR, nGPR,
484 pFPR, nFPR );
485 // NO exception occured...
486 *ppUnoExc = 0;
488 // reconvert temporary params
489 for ( ; nTempIndizes--; )
491 sal_Int32 nIndex = pTempIndizes[nTempIndizes];
492 typelib_TypeDescription * pParamTypeDescr = ppTempParamTypeDescr[nTempIndizes];
494 if (pParams[nIndex].bIn)
496 if (pParams[nIndex].bOut) // inout
498 uno_destructData( pUnoArgs[nIndex], pParamTypeDescr, 0 ); // destroy uno value
499 uno_copyAndConvertData( pUnoArgs[nIndex], pCppArgs[nIndex], pParamTypeDescr,
500 pThis->getBridge()->getCpp2Uno() );
503 else // pure out
505 uno_copyAndConvertData( pUnoArgs[nIndex], pCppArgs[nIndex], pParamTypeDescr,
506 pThis->getBridge()->getCpp2Uno() );
508 // destroy temp cpp param => cpp: every param was constructed
509 uno_destructData( pCppArgs[nIndex], pParamTypeDescr, cpp_release );
511 TYPELIB_DANGER_RELEASE( pParamTypeDescr );
513 // return value
514 if (pCppReturn && pUnoReturn != pCppReturn)
516 uno_copyAndConvertData( pUnoReturn, pCppReturn, pReturnTypeDescr,
517 pThis->getBridge()->getCpp2Uno() );
518 uno_destructData( pCppReturn, pReturnTypeDescr, cpp_release );
521 catch (...)
523 // fill uno exception
524 fillUnoException( CPPU_CURRENT_NAMESPACE::__cxa_get_globals()->caughtExceptions,
525 *ppUnoExc, pThis->getBridge()->getCpp2Uno() );
527 // temporary params
528 for ( ; nTempIndizes--; )
530 sal_Int32 nIndex = pTempIndizes[nTempIndizes];
531 // destroy temp cpp param => cpp: every param was constructed
532 uno_destructData( pCppArgs[nIndex], ppTempParamTypeDescr[nTempIndizes], cpp_release );
533 TYPELIB_DANGER_RELEASE( ppTempParamTypeDescr[nTempIndizes] );
535 // return type
536 if (pReturnTypeDescr)
537 TYPELIB_DANGER_RELEASE( pReturnTypeDescr );
543 namespace bridges { namespace cpp_uno { namespace shared {
545 void unoInterfaceProxyDispatch(
546 uno_Interface * pUnoI, const typelib_TypeDescription * pMemberDescr,
547 void * pReturn, void * pArgs[], uno_Any ** ppException )
549 // is my surrogate
550 bridges::cpp_uno::shared::UnoInterfaceProxy * pThis
551 = static_cast< bridges::cpp_uno::shared::UnoInterfaceProxy *> (pUnoI);
553 switch (pMemberDescr->eTypeClass)
555 case typelib_TypeClass_INTERFACE_ATTRIBUTE:
558 VtableSlot aVtableSlot(
559 getVtableSlot(
560 reinterpret_cast<
561 typelib_InterfaceAttributeTypeDescription const * >(
562 pMemberDescr)));
564 if (pReturn)
566 // dependent dispatch
567 cpp_call(
568 pThis, aVtableSlot,
569 ((typelib_InterfaceAttributeTypeDescription *)pMemberDescr)->pAttributeTypeRef,
570 0, 0, // no params
571 pReturn, pArgs, ppException );
573 else
575 // is SET
576 typelib_MethodParameter aParam;
577 aParam.pTypeRef =
578 ((typelib_InterfaceAttributeTypeDescription *)pMemberDescr)->pAttributeTypeRef;
579 aParam.bIn = sal_True;
580 aParam.bOut = sal_False;
582 typelib_TypeDescriptionReference * pReturnTypeRef = 0;
583 OUString aVoidName( RTL_CONSTASCII_USTRINGPARAM("void") );
584 typelib_typedescriptionreference_new(
585 &pReturnTypeRef, typelib_TypeClass_VOID, aVoidName.pData );
587 // dependent dispatch
588 aVtableSlot.index += 1; //get then set method
589 cpp_call(
590 pThis, aVtableSlot,
591 pReturnTypeRef,
592 1, &aParam,
593 pReturn, pArgs, ppException );
595 typelib_typedescriptionreference_release( pReturnTypeRef );
598 break;
600 case typelib_TypeClass_INTERFACE_METHOD:
603 VtableSlot aVtableSlot(
604 getVtableSlot(
605 reinterpret_cast<
606 typelib_InterfaceMethodTypeDescription const * >(
607 pMemberDescr)));
608 switch (aVtableSlot.index)
610 // standard calls
611 case 1: // acquire uno interface
612 (*pUnoI->acquire)( pUnoI );
613 *ppException = 0;
614 break;
615 case 2: // release uno interface
616 (*pUnoI->release)( pUnoI );
617 *ppException = 0;
618 break;
619 case 0: // queryInterface() opt
621 typelib_TypeDescription * pTD = 0;
622 TYPELIB_DANGER_GET( &pTD, reinterpret_cast< Type * >( pArgs[0] )->getTypeLibType() );
623 if (pTD)
625 uno_Interface * pInterface = 0;
626 (*pThis->pBridge->getUnoEnv()->getRegisteredInterface)(
627 pThis->pBridge->getUnoEnv(),
628 (void **)&pInterface, pThis->oid.pData, (typelib_InterfaceTypeDescription *)pTD );
630 if (pInterface)
632 ::uno_any_construct(
633 reinterpret_cast< uno_Any * >( pReturn ),
634 &pInterface, pTD, 0 );
635 (*pInterface->release)( pInterface );
636 TYPELIB_DANGER_RELEASE( pTD );
637 *ppException = 0;
638 break;
640 TYPELIB_DANGER_RELEASE( pTD );
642 } // else perform queryInterface()
643 default:
644 // dependent dispatch
645 cpp_call(
646 pThis, aVtableSlot,
647 ((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->pReturnTypeRef,
648 ((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->nParams,
649 ((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->pParams,
650 pReturn, pArgs, ppException );
652 break;
654 default:
656 ::com::sun::star::uno::RuntimeException aExc(
657 OUString( RTL_CONSTASCII_USTRINGPARAM("illegal member type description!") ),
658 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >() );
660 Type const & rExcType = ::getCppuType( &aExc );
661 // binary identical null reference
662 ::uno_type_any_construct( *ppException, &aExc, rExcType.getTypeLibType(), 0 );
667 } } }
668 /* vi:set tabstop=4 shiftwidth=4 expandtab: */