LibreOffice Module bridges (master) 1
gcc3_linux_powerpc64/uno2cpp.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#include <sal/config.h>
21
22#include <exception>
23#include <malloc.h>
24#include <typeinfo>
25
26#include <com/sun/star/uno/Exception.hpp>
27#include <com/sun/star/uno/RuntimeException.hpp>
28#include <com/sun/star/uno/genfunc.hxx>
30#include <uno/data.h>
31
32#include "bridge.hxx"
33#include "types.hxx"
34#include "unointerfaceproxy.hxx"
35#include "vtables.hxx"
36
37#include "share.hxx"
38
39#include <stdio.h>
40#include <string.h>
41
42
43using namespace ::com::sun::star::uno;
44
45namespace ppc64
46{
47#if defined(_CALL_ELF) && _CALL_ELF == 2
49 {
50 const typelib_CompoundTypeDescription * p
51 = reinterpret_cast< const typelib_CompoundTypeDescription * >(type);
52 for (sal_Int32 i = 0; i < p->nMembers; ++i)
53 {
54 if (p->ppTypeRefs[i]->eTypeClass == typelib_TypeClass_STRUCT ||
55 p->ppTypeRefs[i]->eTypeClass == typelib_TypeClass_EXCEPTION)
56 {
58 TYPELIB_DANGER_GET(&t, p->ppTypeRefs[i]);
59 bool b = is_complex_struct(t);
60 TYPELIB_DANGER_RELEASE(t);
61 if (b) {
62 return true;
63 }
64 }
65 else if (!bridges::cpp_uno::shared::isSimpleType(p->ppTypeRefs[i]->eTypeClass))
66 return true;
67 }
68 if (p->pBaseTypeDescription != 0)
69 return is_complex_struct(&p->pBaseTypeDescription->aBase);
70 return false;
71 }
72#endif
73
74 bool return_in_hidden_param( typelib_TypeDescriptionReference *pTypeRef )
75 {
77 return false;
78#if defined(_CALL_ELF) && _CALL_ELF == 2
79 else if (pTypeRef->eTypeClass == typelib_TypeClass_STRUCT || pTypeRef->eTypeClass == typelib_TypeClass_EXCEPTION)
80 {
81 typelib_TypeDescription * pTypeDescr = 0;
82 TYPELIB_DANGER_GET( &pTypeDescr, pTypeRef );
83
84 //A Composite Type not larger than 16 bytes is returned in up to two GPRs
85 bool bRet = pTypeDescr->nSize > 16 || is_complex_struct(pTypeDescr);
86
87 TYPELIB_DANGER_RELEASE( pTypeDescr );
88 return bRet;
89 }
90#endif
91 return true;
92 }
93}
94
95void MapReturn(long r3, long r4, double dret, typelib_TypeDescriptionReference* pReturnType, void *pRegisterReturn)
96{
97 switch (pReturnType->eTypeClass)
98 {
99 case typelib_TypeClass_HYPER:
100 case typelib_TypeClass_UNSIGNED_HYPER:
101 *reinterpret_cast<sal_uInt64 *>( pRegisterReturn ) = r3;
102 break;
103 case typelib_TypeClass_LONG:
104 case typelib_TypeClass_UNSIGNED_LONG:
105 case typelib_TypeClass_ENUM:
106 *reinterpret_cast<sal_uInt32 *>( pRegisterReturn ) = r3;
107 break;
108 case typelib_TypeClass_CHAR:
109 case typelib_TypeClass_SHORT:
110 case typelib_TypeClass_UNSIGNED_SHORT:
111 *reinterpret_cast<sal_uInt16 *>( pRegisterReturn ) = (unsigned short)r3;
112 break;
113 case typelib_TypeClass_BOOLEAN:
114 case typelib_TypeClass_BYTE:
115 *reinterpret_cast<sal_uInt8 *>( pRegisterReturn ) = (unsigned char)r3;
116 break;
117 case typelib_TypeClass_FLOAT:
118 *reinterpret_cast<float *>( pRegisterReturn ) = dret;
119 break;
120 case typelib_TypeClass_DOUBLE:
121 *reinterpret_cast<double *>( pRegisterReturn ) = dret;
122 break;
123#if defined(_CALL_ELF) && _CALL_ELF == 2
124 case typelib_TypeClass_STRUCT:
125 case typelib_TypeClass_EXCEPTION:
126 if (!ppc64::return_in_hidden_param(pReturnType))
127 {
128 sal_uInt64 *pRegisters = reinterpret_cast<sal_uInt64*>(pRegisterReturn);
129 pRegisters[0] = r3;
130 if (pReturnType->pType->nSize > 8)
131 pRegisters[1] = r4;
132 }
133#else
134 (void)r4;
135#endif
136 default:
137 break;
138 }
139}
140
141namespace
142{
143
144static void callVirtualMethod(void * pThis, sal_uInt32 nVtableIndex,
145 void * pRegisterReturn, typelib_TypeDescription * pReturnTypeDescr,
146 sal_uInt64 *pStack, sal_uInt32 nStack,
147 sal_uInt64 *pGPR, sal_uInt32 nGPR,
148 double *pFPR, sal_uInt32 nFPR)
149{
150 // Stack, if used, must be 16-bytes aligned
151 if ( nStack )
152 nStack = ( nStack + 1 ) & ~1;
153
154 // Should not happen, but...
155 if ( nFPR > ppc64::MAX_SSE_REGS )
156 nFPR = ppc64::MAX_SSE_REGS;
157 if ( nGPR > ppc64::MAX_GPR_REGS )
158 nGPR = ppc64::MAX_GPR_REGS;
159
160#if OSL_DEBUG_LEVEL > 2
161 // Let's figure out what is really going on here
162 {
163 fprintf( stderr, "= callVirtualMethod() =\nGPR's (%d): ", nGPR );
164 for ( int i = 0; i < nGPR; ++i )
165 fprintf( stderr, "0x%lx, ", pGPR[i] );
166 fprintf( stderr, "\nFPR's (%d): ", nFPR );
167 for ( int i = 0; i < nFPR; ++i )
168 fprintf( stderr, "0x%lx (%f), ", pFPR[i], pFPR[i] );
169 fprintf( stderr, "\nStack (%d): ", nStack );
170 for ( int i = 0; i < nStack; ++i )
171 fprintf( stderr, "0x%lx, ", pStack[i] );
172 fprintf( stderr, "\n" );
173 }
174#endif
175
176 // Load parameters to stack, if necessary
177 sal_uInt64 *stack = (sal_uInt64 *) __builtin_alloca( nStack * 8 );
178 memcpy( stack, pStack, nStack * 8 );
179
180 // Get pointer to method
181 sal_uInt64 pMethod = *((sal_uInt64 *)pThis);
182 pMethod += 8 * nVtableIndex;
183 pMethod = *((sal_uInt64 *)pMethod);
184
185#if defined(_CALL_ELF) && _CALL_ELF == 2
186 typedef void (* FunctionCall )(...);
187#else
188 typedef void (* FunctionCall )( sal_uInt64, sal_uInt64, sal_uInt64, sal_uInt64, sal_uInt64, sal_uInt64, sal_uInt64, sal_uInt64 );
189#endif
190 FunctionCall pFunc = (FunctionCall)pMethod;
191
192 volatile double dret;
193
194 // fill registers
195 __asm__ __volatile__ (
196 "lfd 1, 0(%0)\n\t"
197 "lfd 2, 8(%0)\n\t"
198 "lfd 3, 16(%0)\n\t"
199 "lfd 4, 24(%0)\n\t"
200 "lfd 5, 32(%0)\n\t"
201 "lfd 6, 40(%0)\n\t"
202 "lfd 7, 48(%0)\n\t"
203 "lfd 8, 56(%0)\n\t"
204 "lfd 9, 64(%0)\n\t"
205 "lfd 10, 72(%0)\n\t"
206 "lfd 11, 80(%0)\n\t"
207 "lfd 12, 88(%0)\n\t"
208 "lfd 13, 96(%0)\n\t"
209 : : "r" (pFPR)
210 : "fr1", "fr2", "fr3", "fr4", "fr5", "fr6", "fr7", "fr8", "fr9",
211 "fr10", "fr11", "fr12", "fr13"
212 );
213
214 // tell gcc that r3 to r11 are not available to it for doing the TOC and exception munge on the func call
215 register sal_uInt64 r3 asm("r3");
216 register sal_uInt64 r4 asm("r4");
217
218 (*pFunc)(pGPR[0], pGPR[1], pGPR[2], pGPR[3], pGPR[4], pGPR[5], pGPR[6], pGPR[7]);
219
220 // get return value
221 __asm__ __volatile__ (
222 "mr %1, 3\n\t"
223 "mr %2, 4\n\t"
224 "fmr %0, 1\n\t"
225 : "=f" (dret), "=r" (r3), "=r" (r4) : );
226
227 MapReturn(r3, r4, dret, reinterpret_cast<typelib_TypeDescriptionReference *>(pReturnTypeDescr), pRegisterReturn);
228}
229
230// Macros for easier insertion of values to registers or stack
231// pSV - pointer to the source
232// nr - order of the value [will be increased if stored to register]
233// pFPR, pGPR - pointer to the registers
234// pDS - pointer to the stack [will be increased if stored here]
235
236// The value in %xmm register is already prepared to be retrieved as a float,
237// thus we treat float and double the same
238#define INSERT_FLOAT( pSV, nr, pFPR, nGPR, pDS, bOverflow ) \
239 if ( nGPR < ppc64::MAX_GPR_REGS ) \
240 ++nGPR; \
241 if ( nr < ppc64::MAX_SSE_REGS ) \
242 pFPR[nr++] = *reinterpret_cast<float *>( pSV ); \
243 else \
244 bOverflow = true; \
245 if (bOverflow) \
246 *pDS++ = *reinterpret_cast<sal_uInt64 *>( pSV ); // verbatim!
247
248#define INSERT_DOUBLE( pSV, nr, pFPR, nGPR, pDS, bOverflow ) \
249 if ( nGPR < ppc64::MAX_GPR_REGS ) \
250 ++nGPR; \
251 if ( nr < ppc64::MAX_SSE_REGS ) \
252 pFPR[nr++] = *reinterpret_cast<double *>( pSV ); \
253 else \
254 bOverflow = true; \
255 if (bOverflow) \
256 *pDS++ = *reinterpret_cast<sal_uInt64 *>( pSV ); // verbatim!
257
258#define INSERT_INT64( pSV, nr, pGPR, pDS, bOverflow ) \
259 if ( nr < ppc64::MAX_GPR_REGS ) \
260 pGPR[nr++] = *reinterpret_cast<sal_uInt64 *>( pSV ); \
261 else \
262 bOverflow = true; \
263 if (bOverflow) \
264 *pDS++ = *reinterpret_cast<sal_uInt64 *>( pSV );
265
266#define INSERT_INT32( pSV, nr, pGPR, pDS, bOverflow ) \
267 if ( nr < ppc64::MAX_GPR_REGS ) \
268 pGPR[nr++] = *reinterpret_cast<sal_uInt32 *>( pSV ); \
269 else \
270 bOverflow = true; \
271 if (bOverflow) \
272 *pDS++ = *reinterpret_cast<sal_uInt32 *>( pSV );
273
274#define INSERT_INT16( pSV, nr, pGPR, pDS, bOverflow ) \
275 if ( nr < ppc64::MAX_GPR_REGS ) \
276 pGPR[nr++] = *reinterpret_cast<sal_uInt16 *>( pSV ); \
277 else \
278 bOverflow = true; \
279 if (bOverflow) \
280 *pDS++ = *reinterpret_cast<sal_uInt16 *>( pSV );
281
282#define INSERT_INT8( pSV, nr, pGPR, pDS, bOverflow ) \
283 if ( nr < ppc64::MAX_GPR_REGS ) \
284 pGPR[nr++] = *reinterpret_cast<sal_uInt8 *>( pSV ); \
285 else \
286 bOverflow = true; \
287 if (bOverflow) \
288 *pDS++ = *reinterpret_cast<sal_uInt8 *>( pSV );
289
290static void cpp_call(
293 typelib_TypeDescriptionReference * pReturnTypeRef,
294 sal_Int32 nParams, typelib_MethodParameter * pParams,
295 void * pUnoReturn, void * pUnoArgs[], uno_Any ** ppUnoExc )
296{
297 // max space for: [complex ret ptr], values|ptr ...
298 sal_uInt64 * pStack = (sal_uInt64 *)alloca( (nParams+3) * sizeof(sal_Int64) );
299 sal_uInt64 * pStackStart = pStack;
300
301 sal_uInt64 pGPR[ppc64::MAX_GPR_REGS];
302 sal_uInt32 nGPR = 0;
303
304 double pFPR[ppc64::MAX_SSE_REGS];
305 sal_uInt32 nFPR = 0;
306
307 // return
308 typelib_TypeDescription * pReturnTypeDescr = 0;
309 TYPELIB_DANGER_GET( &pReturnTypeDescr, pReturnTypeRef );
310 assert(pReturnTypeDescr);
311
312 void * pCppReturn = 0; // if != 0 && != pUnoReturn, needs reconversion
313
314 bool bOverflow = false;
315
316 if (pReturnTypeDescr)
317 {
318#if OSL_DEBUG_LEVEL > 2
319 fprintf(stderr, "return type is %d\n", pReturnTypeDescr->eTypeClass);
320#endif
321 bool bSimpleReturn =!ppc64::return_in_hidden_param(pReturnTypeRef);
322
323 if (bSimpleReturn)
324 {
325 pCppReturn = pUnoReturn; // direct way for simple types
326#if OSL_DEBUG_LEVEL > 2
327 fprintf(stderr, "simple return\n");
328#endif
329 }
330 else
331 {
332 // complex return via ptr
333 pCppReturn = (bridges::cpp_uno::shared::relatesToInterfaceType( pReturnTypeDescr )
334 ? alloca( pReturnTypeDescr->nSize ) : pUnoReturn);
335#if OSL_DEBUG_LEVEL > 2
336 fprintf(stderr, "pCppReturn/pUnoReturn is %lx/%lx", pCppReturn, pUnoReturn);
337#endif
338 INSERT_INT64( &pCppReturn, nGPR, pGPR, pStack, bOverflow );
339 }
340 }
341 // push "this" pointer
342 void * pAdjustedThisPtr = reinterpret_cast< void ** >( pThis->getCppI() ) + aVtableSlot.offset;
343#if OSL_DEBUG_LEVEL > 2
344 fprintf(stderr, "this pointer is %p\n", pAdjustedThisPtr);
345#endif
346 INSERT_INT64( &pAdjustedThisPtr, nGPR, pGPR, pStack, bOverflow );
347
348 // Args
349 void ** pCppArgs = (void **)alloca( 3 * sizeof(void *) * nParams );
350 // indices of values this have to be converted (interface conversion cpp<=>uno)
351 sal_Int32 * pTempIndices = (sal_Int32 *)(pCppArgs + nParams);
352 // type descriptions for reconversions
353 typelib_TypeDescription ** ppTempParamTypeDescr = (typelib_TypeDescription **)(pCppArgs + (2 * nParams));
354
355 sal_Int32 nTempIndices = 0;
356
357#if OSL_DEBUG_LEVEL > 2
358 fprintf(stderr, "n params is %d\n", nParams);
359#endif
360
361 for ( sal_Int32 nPos = 0; nPos < nParams; ++nPos )
362 {
363 const typelib_MethodParameter & rParam = pParams[nPos];
364 typelib_TypeDescription * pParamTypeDescr = 0;
365 TYPELIB_DANGER_GET( &pParamTypeDescr, rParam.pTypeRef );
366
367#if OSL_DEBUG_LEVEL > 2
368 fprintf(stderr, "param %d is %d %d %d\n", nPos, rParam.bOut, bridges::cpp_uno::shared::isSimpleType( pParamTypeDescr ),
369 pParamTypeDescr->eTypeClass);
370#endif
371
372 if (!rParam.bOut && bridges::cpp_uno::shared::isSimpleType( pParamTypeDescr ))
373 {
374 uno_copyAndConvertData( pCppArgs[nPos] = pStack, pUnoArgs[nPos], pParamTypeDescr,
375 pThis->getBridge()->getUno2Cpp() );
376 switch (pParamTypeDescr->eTypeClass)
377 {
378 case typelib_TypeClass_HYPER:
379 case typelib_TypeClass_UNSIGNED_HYPER:
380#if OSL_DEBUG_LEVEL > 2
381 fprintf(stderr, "hyper is %lx\n", pCppArgs[nPos]);
382#endif
383 INSERT_INT64( pCppArgs[nPos], nGPR, pGPR, pStack, bOverflow );
384 break;
385 case typelib_TypeClass_LONG:
386 case typelib_TypeClass_UNSIGNED_LONG:
387 case typelib_TypeClass_ENUM:
388#if OSL_DEBUG_LEVEL > 2
389 fprintf(stderr, "long is %x\n", pCppArgs[nPos]);
390#endif
391 INSERT_INT32( pCppArgs[nPos], nGPR, pGPR, pStack, bOverflow );
392 break;
393 case typelib_TypeClass_SHORT:
394 case typelib_TypeClass_CHAR:
395 case typelib_TypeClass_UNSIGNED_SHORT:
396 INSERT_INT16( pCppArgs[nPos], nGPR, pGPR, pStack, bOverflow );
397 break;
398 case typelib_TypeClass_BOOLEAN:
399 case typelib_TypeClass_BYTE:
400 INSERT_INT8( pCppArgs[nPos], nGPR, pGPR, pStack, bOverflow );
401 break;
402 case typelib_TypeClass_FLOAT:
403 INSERT_FLOAT( pCppArgs[nPos], nFPR, pFPR, nGPR, pStack, bOverflow );
404 break;
405 case typelib_TypeClass_DOUBLE:
406 INSERT_DOUBLE( pCppArgs[nPos], nFPR, pFPR, nGPR, pStack, bOverflow );
407 break;
408 default:
409 break;
410 }
411
412 // no longer needed
413 TYPELIB_DANGER_RELEASE( pParamTypeDescr );
414
415 }
416 else // ptr to complex value | ref
417 {
418#if OSL_DEBUG_LEVEL > 2
419 fprintf(stderr, "complex type again %d\n", rParam.bIn);
420#endif
421 if (! rParam.bIn) // is pure out
422 {
423#if OSL_DEBUG_LEVEL > 2
424 fprintf(stderr, "complex size is %d\n", pParamTypeDescr->nSize );
425#endif
426 // cpp out is constructed mem, uno out is not!
428 pCppArgs[nPos] = alloca( pParamTypeDescr->nSize ),
429 pParamTypeDescr );
430 pTempIndices[nTempIndices] = nPos; // default constructed for cpp call
431 // will be released at reconversion
432 ppTempParamTypeDescr[nTempIndices++] = pParamTypeDescr;
433 }
434 // is in/inout
435 else if (bridges::cpp_uno::shared::relatesToInterfaceType( pParamTypeDescr ))
436 {
437#if OSL_DEBUG_LEVEL > 2
438 fprintf(stderr, "this one\n");
439#endif
441 pCppArgs[nPos] = alloca( pParamTypeDescr->nSize ),
442 pUnoArgs[nPos], pParamTypeDescr, pThis->getBridge()->getUno2Cpp() );
443
444 pTempIndices[nTempIndices] = nPos; // has to be reconverted
445 // will be released at reconversion
446 ppTempParamTypeDescr[nTempIndices++] = pParamTypeDescr;
447 }
448 else // direct way
449 {
450#if OSL_DEBUG_LEVEL > 2
451 fprintf(stderr, "that one, passing %lx through\n", pUnoArgs[nPos]);
452#endif
453 pCppArgs[nPos] = pUnoArgs[nPos];
454 // no longer needed
455 TYPELIB_DANGER_RELEASE( pParamTypeDescr );
456 }
457 INSERT_INT64( &(pCppArgs[nPos]), nGPR, pGPR, pStack, bOverflow );
458 }
459 }
460
461 try
462 {
463 try {
465 pAdjustedThisPtr, aVtableSlot.index,
466 pCppReturn, pReturnTypeDescr,
467 pStackStart, ( pStack - pStackStart ),
468 pGPR, nGPR,
469 pFPR, nFPR );
470 } catch (css::uno::Exception &) {
471 throw;
472 } catch (std::exception & e) {
473 throw css::uno::RuntimeException(
474 "C++ code threw " + o3tl::runtimeToOUString(typeid(e).name()) + ": "
475 + o3tl::runtimeToOUString(e.what()));
476 } catch (...) {
477 throw css::uno::RuntimeException("C++ code threw unknown exception");
478 }
479 // NO exception occurred...
480 *ppUnoExc = 0;
481
482 // reconvert temporary params
483 for ( ; nTempIndices--; )
484 {
485 sal_Int32 nIndex = pTempIndices[nTempIndices];
486 typelib_TypeDescription * pParamTypeDescr = ppTempParamTypeDescr[nTempIndices];
487
488 if (pParams[nIndex].bIn)
489 {
490 if (pParams[nIndex].bOut) // inout
491 {
492 uno_destructData( pUnoArgs[nIndex], pParamTypeDescr, 0 ); // destroy uno value
493 uno_copyAndConvertData( pUnoArgs[nIndex], pCppArgs[nIndex], pParamTypeDescr,
494 pThis->getBridge()->getCpp2Uno() );
495 }
496 }
497 else // pure out
498 {
499 uno_copyAndConvertData( pUnoArgs[nIndex], pCppArgs[nIndex], pParamTypeDescr,
500 pThis->getBridge()->getCpp2Uno() );
501 }
502 // destroy temp cpp param => cpp: every param was constructed
503 uno_destructData( pCppArgs[nIndex], pParamTypeDescr, cpp_release );
504
505 TYPELIB_DANGER_RELEASE( pParamTypeDescr );
506 }
507 // return value
508 if (pCppReturn && pUnoReturn != pCppReturn)
509 {
510 uno_copyAndConvertData( pUnoReturn, pCppReturn, pReturnTypeDescr,
511 pThis->getBridge()->getCpp2Uno() );
512 uno_destructData( pCppReturn, pReturnTypeDescr, cpp_release );
513 }
514 }
515 catch (...)
516 {
517 // fill uno exception
519
520 // temporary params
521 for ( ; nTempIndices--; )
522 {
523 sal_Int32 nIndex = pTempIndices[nTempIndices];
524 // destroy temp cpp param => cpp: every param was constructed
525 uno_destructData( pCppArgs[nIndex], ppTempParamTypeDescr[nTempIndices], cpp_release );
526 TYPELIB_DANGER_RELEASE( ppTempParamTypeDescr[nTempIndices] );
527 }
528 // return type
529 if (pReturnTypeDescr)
530 TYPELIB_DANGER_RELEASE( pReturnTypeDescr );
531 }
532}
533
534}
535
536namespace bridges::cpp_uno::shared {
537
539 uno_Interface * pUnoI, const typelib_TypeDescription * pMemberDescr,
540 void * pReturn, void * pArgs[], uno_Any ** ppException )
541{
542 // is my surrogate
544 = static_cast< bridges::cpp_uno::shared::UnoInterfaceProxy *> (pUnoI);
545
546 switch (pMemberDescr->eTypeClass)
547 {
548 case typelib_TypeClass_INTERFACE_ATTRIBUTE:
549 {
550
551 VtableSlot aVtableSlot(
553 reinterpret_cast<
554 typelib_InterfaceAttributeTypeDescription const * >(
555 pMemberDescr)));
556
557 if (pReturn)
558 {
559 // dependent dispatch
560 cpp_call(
561 pThis, aVtableSlot,
562 ((typelib_InterfaceAttributeTypeDescription *)pMemberDescr)->pAttributeTypeRef,
563 0, 0, // no params
564 pReturn, pArgs, ppException );
565 }
566 else
567 {
568 // is SET
569 typelib_MethodParameter aParam;
570 aParam.pTypeRef =
571 ((typelib_InterfaceAttributeTypeDescription *)pMemberDescr)->pAttributeTypeRef;
572 aParam.bIn = sal_True;
573 aParam.bOut = sal_False;
574
575 typelib_TypeDescriptionReference * pReturnTypeRef = 0;
576 OUString aVoidName("void");
578 &pReturnTypeRef, typelib_TypeClass_VOID, aVoidName.pData );
579
580 // dependent dispatch
581 aVtableSlot.index += 1; //get then set method
582 cpp_call(
583 pThis, aVtableSlot,
584 pReturnTypeRef,
585 1, &aParam,
586 pReturn, pArgs, ppException );
587
589 }
590
591 break;
592 }
593 case typelib_TypeClass_INTERFACE_METHOD:
594 {
595
596 VtableSlot aVtableSlot(
598 reinterpret_cast<
599 typelib_InterfaceMethodTypeDescription const * >(
600 pMemberDescr)));
601 switch (aVtableSlot.index)
602 {
603 // standard calls
604 case 1: // acquire uno interface
605 (*pUnoI->acquire)( pUnoI );
606 *ppException = 0;
607 break;
608 case 2: // release uno interface
609 (*pUnoI->release)( pUnoI );
610 *ppException = 0;
611 break;
612 case 0: // queryInterface() opt
613 {
614 typelib_TypeDescription * pTD = 0;
615 TYPELIB_DANGER_GET( &pTD, reinterpret_cast< Type * >( pArgs[0] )->getTypeLibType() );
616 if (pTD)
617 {
618 uno_Interface * pInterface = 0;
619 (*pThis->pBridge->getUnoEnv()->getRegisteredInterface)(
620 pThis->pBridge->getUnoEnv(),
621 (void **)&pInterface, pThis->oid.pData, (typelib_InterfaceTypeDescription *)pTD );
622
623 if (pInterface)
624 {
625 ::uno_any_construct(
626 reinterpret_cast< uno_Any * >( pReturn ),
627 &pInterface, pTD, 0 );
628 (*pInterface->release)( pInterface );
629 TYPELIB_DANGER_RELEASE( pTD );
630 *ppException = 0;
631 break;
632 }
633 TYPELIB_DANGER_RELEASE( pTD );
634 }
635 } // else perform queryInterface()
636 default:
637 // dependent dispatch
638 cpp_call(
639 pThis, aVtableSlot,
640 ((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->pReturnTypeRef,
641 ((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->nParams,
642 ((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->pParams,
643 pReturn, pArgs, ppException );
644 }
645 break;
646 }
647 default:
648 {
649 ::com::sun::star::uno::RuntimeException aExc(
650 "illegal member type description!",
652
653 Type const & rExcType = cppu::UnoType<decltype(aExc)>::get();
654 // binary identical null reference
655 ::uno_type_any_construct( *ppException, &aExc, rExcType.getTypeLibType(), 0 );
656 }
657 }
658}
659
660}
661
662/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
XPropertyListType t
uno_Mapping * getUno2Cpp()
Definition: bridge.hxx:73
uno_ExtEnvironment * getUnoEnv()
Definition: bridge.hxx:70
uno_Mapping * getCpp2Uno()
Definition: bridge.hxx:72
A uno proxy wrapping a cpp interface.
com::sun::star::uno::XInterface * getCppI()
void SAL_CALL uno_destructData(void *pValue, typelib_TypeDescription *pTypeDescr, uno_ReleaseFunc release) SAL_THROW_EXTERN_C()
void SAL_CALL uno_constructData(void *pMem, typelib_TypeDescription *pTypeDescr) SAL_THROW_EXTERN_C()
void SAL_CALL uno_copyAndConvertData(void *pDest, void *pSource, typelib_TypeDescription *pTypeDescr, uno_Mapping *mapping) SAL_THROW_EXTERN_C()
char const * name
register sal_uInt32 r28 __asm__("%r28")
void callVirtualMethod(void *pThis, sal_uInt32 nVtableIndex, void *pRegisterReturn, typelib_TypeDescription *pReturnTypeDescr, bool bRegisterReturn, sal_uInt32 *pStack, sal_uInt32 nStack, sal_uInt32 *pGPR, double *pFPR) __attribute__((noinline))
#define INSERT_INT32(pSV, nr, pGPR, pDS, bOverflow)
#define INSERT_FLOAT(pSV, nr, pFPR, nGPR, pDS, bOverflow)
#define INSERT_DOUBLE(pSV, nr, pFPR, nGPR, pDS, bOverflow)
#define INSERT_INT64(pSV, nr, pGPR, pDS, bOverflow)
#define INSERT_INT16(pSV, nr, pGPR, pDS, bOverflow)
#define INSERT_INT8(pSV, nr, pGPR, pDS, bOverflow)
void MapReturn(long r3, long r4, double dret, typelib_TypeDescriptionReference *pReturnType, void *pRegisterReturn)
static void cpp_call(bridges::cpp_uno::shared::UnoInterfaceProxy *pThis, bridges::cpp_uno::shared::VtableSlot aVtableSlot, typelib_TypeDescriptionReference *pReturnTypeRef, sal_Int32 nParams, typelib_MethodParameter *pParams, void *pUnoReturn, void *pUnoArgs[], uno_Any **ppUnoExc)
sal_Int32 nIndex
void * p
sal_uInt16 nPos
struct _typelib_TypeDescription typelib_TypeDescription
Definition: msvc/except.hxx:53
struct _uno_Any uno_Any
Definition: msvc/except.hxx:32
void fillUnoException(uno_Any *pUnoExc, uno_Mapping *pCpp2Uno)
static bool is_complex_struct(const typelib_TypeDescription *type)
void unoInterfaceProxyDispatch(uno_Interface *pUnoI, typelib_TypeDescription const *pMemberDescr, void *pReturn, void **pArgs, uno_Any **ppException)
VtableSlot getVtableSlot(typelib_InterfaceAttributeTypeDescription const *ifcMember)
Calculates the vtable slot associated with an interface attribute member.
Definition: vtables.cxx:132
bool isSimpleType(typelib_TypeClass typeClass)
Determines whether a type is a "simple" type (VOID, BOOLEAN, BYTE, SHORT, UNSIGNED SHORT,...
Definition: types.cxx:28
bool relatesToInterfaceType(typelib_TypeDescription const *type)
Determines whether a type relates to an interface type (is itself an interface type,...
Definition: types.cxx:41
Type
int i
OUString runtimeToOUString(char const *runtimeString)
bool return_in_hidden_param(typelib_TypeDescriptionReference *pTypeRef)
Represents a vtable slot of a C++ class.
Definition: vtables.hxx:60
sal_Int32 index
The index within the vtable.
Definition: vtables.hxx:76
sal_Int32 offset
The offset of the vtable.
Definition: vtables.hxx:68
void SAL_CALL typelib_typedescriptionreference_new(typelib_TypeDescriptionReference **ppTDR, typelib_TypeClass eTypeClass, rtl_uString *pTypeName) SAL_THROW_EXTERN_C()
void SAL_CALL typelib_typedescriptionreference_release(typelib_TypeDescriptionReference *pRef) SAL_THROW_EXTERN_C()
#define sal_True
unsigned char sal_uInt8
#define sal_False
ResultType type