LibreOffice Module bridges (master) 1
gcc3_linux_riscv64/uno2cpp.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
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 <cstring>
25#include <typeinfo>
26
27#include <com/sun/star/uno/Exception.hpp>
28#include <com/sun/star/uno/RuntimeException.hpp>
29#include <com/sun/star/uno/genfunc.hxx>
31#include <uno/data.h>
32
33#include "bridge.hxx"
34#include "types.hxx"
35#include "unointerfaceproxy.hxx"
36#include "vtables.hxx"
37
38#include "share.hxx"
39#include "abi.hxx"
40
41//#define BRIDGE_DEBUG
42#ifdef BRIDGE_DEBUG
43#include <stdio.h>
44#endif
45
46// FP reg -> GP reg -> stack
47#define INSERT_FLOAT_DOUBLE(pSV, nfr, pFPR, ngr, pGPR, pDS) \
48 if (nfr < MAX_FP_REGS) \
49 pFPR[nfr++] = *reinterpret_cast<double*>(pSV); \
50 else if (ngr < MAX_FP_REGS) \
51 pGPR[ngr++] = *reinterpret_cast<sal_Int64*>(pSV); \
52 else \
53 *pDS++ = *reinterpret_cast<sal_uInt64*>(pSV); // verbatim!
54
55#define INSERT_INT64(pSV, nr, pGPR, pDS) \
56 if (nr < MAX_GP_REGS) \
57 pGPR[nr++] = *reinterpret_cast<sal_Int64*>(pSV); \
58 else \
59 *pDS++ = *reinterpret_cast<sal_Int64*>(pSV);
60
61#define INSERT_INT32(pSV, nr, pGPR, pDS) \
62 if (nr < MAX_GP_REGS) \
63 pGPR[nr++] = *reinterpret_cast<sal_Int32*>(pSV); \
64 else \
65 *pDS++ = *reinterpret_cast<sal_Int32*>(pSV);
66
67#define INSERT_INT16(pSV, nr, pGPR, pDS) \
68 if (nr < MAX_GP_REGS) \
69 pGPR[nr++] = *reinterpret_cast<sal_Int16*>(pSV); \
70 else \
71 *pDS++ = *reinterpret_cast<sal_Int16*>(pSV);
72
73#define INSERT_UINT16(pSV, nr, pGPR, pDS) \
74 if (nr < MAX_GP_REGS) \
75 pGPR[nr++] = *reinterpret_cast<sal_uInt16*>(pSV); \
76 else \
77 *pDS++ = *reinterpret_cast<sal_uInt16*>(pSV);
78
79#define INSERT_INT8(pSV, nr, pGPR, pDS) \
80 if (nr < MAX_GP_REGS) \
81 pGPR[nr++] = *reinterpret_cast<sal_Int8*>(pSV); \
82 else \
83 *pDS++ = *reinterpret_cast<sal_Int8*>(pSV);
84
85using namespace ::com::sun::star::uno;
86
87namespace
88{
89bool isReturnInFPR(const typelib_TypeDescription* pTypeDescr, sal_uInt32& nSize)
90{
91#ifdef BRIDGE_DEBUG
92 printf("In isReturnInFPR, pTypeDescr = %p, nSize = %d\n", pTypeDescr, nSize);
93#endif
94 const typelib_CompoundTypeDescription* p
95 = reinterpret_cast<const typelib_CompoundTypeDescription*>(pTypeDescr);
96
97 for (sal_Int32 i = 0; i < p->nMembers; ++i)
98 {
99 typelib_TypeDescriptionReference* pTypeInStruct = p->ppTypeRefs[i];
100
101 switch (pTypeInStruct->eTypeClass)
102 {
103 case typelib_TypeClass_STRUCT:
104 case typelib_TypeClass_EXCEPTION:
105 {
107 TYPELIB_DANGER_GET(&t, pTypeInStruct);
108 bool isFPR = isReturnInFPR(t, nSize);
109 TYPELIB_DANGER_RELEASE(t);
110 if (!isFPR)
111 return false;
112 }
113 break;
114 case typelib_TypeClass_FLOAT:
115 case typelib_TypeClass_DOUBLE:
116 if (nSize >= 16)
117 return false;
118 nSize += 8;
119 break;
120 default:
121 return false;
122 }
123 }
124 return true;
125}
126
127void fillReturn(const typelib_TypeDescription* pTypeDescr, sal_Int64* gret, double* fret,
128 void* pRegisterReturn)
129{
130#ifdef BRIDGE_DEBUG
131 printf("In fillReturn, pTypeDescr = %p, gret = %p, fret = %p, pRegisterReturn = %p\n",
132 pTypeDescr, gret, fret, pRegisterReturn);
133#endif
134 sal_uInt32 nSize = 0;
135 if (isReturnInFPR(pTypeDescr, nSize))
136 {
137 reinterpret_cast<double*>(pRegisterReturn)[0] = fret[0];
138 reinterpret_cast<double*>(pRegisterReturn)[1] = fret[1];
139 }
140 else
141 {
142 reinterpret_cast<sal_Int64*>(pRegisterReturn)[0] = gret[0];
143 reinterpret_cast<sal_Int64*>(pRegisterReturn)[1] = gret[1];
144 }
145}
146
147static void callVirtualMethod(void* pAdjustedThisPtr, sal_Int32 nVtableIndex, void* pRegisterReturn,
148 typelib_TypeDescriptionReference* pReturnTypeRef, bool bSimpleReturn,
149 sal_uInt64* pStack, sal_uInt32 nStack, sal_uInt64* pGPR, double* pFPR,
150 typelib_TypeDescription* pReturnTypeDescr)
151{
152#ifdef BRIDGE_DEBUG
153 printf("In callVirtualMethod:\n");
154 printf("pAdjustedThisPtr = %p, nVtableIndex = %d, pRegisterReturn = %p, pReturnTypeRef = %p\n",
155 pAdjustedThisPtr, nVtableIndex, pRegisterReturn, pReturnTypeRef);
156 printf("bSimpleReturn = %d, pStack = %p, nStack = %d, pGPR = %p, pFPR = %p, pReturnTypeDescr = "
157 "%p\n",
158 bSimpleReturn, pStack, nStack, pGPR, pFPR, pReturnTypeDescr);
159#endif
160 // Get pointer to method
161 sal_uInt64 pMethod = *((sal_uInt64*)pAdjustedThisPtr);
162 pMethod += 8 * nVtableIndex;
163 void* mfunc = (void*)*((sal_uInt64*)pMethod);
164#ifdef BRIDGE_DEBUG
165 fprintf(stdout, "calling function %p\n", mfunc);
166#endif
167
168 // Load parameters to stack, if necessary
169 sal_uInt64* pCallStack = NULL;
170 if (nStack)
171 {
172 // 16-bytes aligned
173 sal_uInt32 nStackBytes = ((nStack + 1) >> 1) * 16;
174 pCallStack = (sal_uInt64*)__builtin_alloca(nStackBytes);
175 std::memcpy(pCallStack, pStack, nStackBytes);
176 }
177
178 sal_Int64* gret = (sal_Int64*)malloc(2 * sizeof(sal_Int64));
179 sal_Int64* gret1 = gret;
180 sal_Int64* gret2 = gret + 1;
181 double* fret = (double*)malloc(2 * sizeof(double));
182 double* fret1 = fret;
183 double* fret2 = fret + 1;
184 asm volatile(
185 //".set push \n\t"
186 //".set riscv64 \n\t"
187 // Fill the general purpose registers
188 "ld a0, 0(%[gpr]) \n\t"
189 "ld a1, 8(%[gpr]) \n\t"
190 "ld a2, 16(%[gpr]) \n\t"
191 "ld a3, 24(%[gpr]) \n\t"
192 "ld a4, 32(%[gpr]) \n\t"
193 "ld a5, 40(%[gpr]) \n\t"
194 "ld a6, 48(%[gpr]) \n\t"
195 "ld a7, 56(%[gpr]) \n\t"
196 // Fill the floating pointer registers
197 "fld fa0, 0(%[fpr]) \n\t"
198 "fld fa1, 8(%[fpr]) \n\t"
199 "fld fa2, 16(%[fpr]) \n\t"
200 "fld fa3, 24(%[fpr]) \n\t"
201 "fld fa4, 32(%[fpr]) \n\t"
202 "fld fa5, 40(%[fpr]) \n\t"
203 "fld fa6, 48(%[fpr]) \n\t"
204 "fld fa7, 56(%[fpr]) \n\t"
205 // Perform the call
206 "jalr ra,%[mfunc],0 \n\t"
207 // Fill the return values
208 "add %[gret1], a0,zero \n\t"
209 "add %[gret2], a1,zero \n\t"
210 "fmv.d %[fret1], fa0 \n\t"
211 "fmv.d %[fret2], fa1 \n\t"
212 //".set pop \n\t"
213 : [gret1] "=&r"(*gret1), [gret2] "=&r"(*gret2), [fret1] "=&f"(*fret1), [fret2] "=&f"(*fret2)
214 : [gpr] "r"(pGPR), [fpr] "r"(pFPR), [mfunc] "r"(mfunc),
215 [stack] "m"(
216 pCallStack) // dummy input to prevent the compiler from optimizing the alloca out
217 : "a0", "a1", "a2", "a3", "a4", "a5", "a6", "a7", "ra", "fa0", "fa1", "fa2", "fa3", "fa4",
218 "fa5", "fa6", "fa7", "memory");
219#ifdef BRIDGE_DEBUG
220 printf("In callVirtualMethod, fret = %p, gret = %p\n", fret, gret);
221#endif
222
223 switch (pReturnTypeRef->eTypeClass)
224 {
225 case typelib_TypeClass_HYPER:
226 case typelib_TypeClass_UNSIGNED_HYPER:
227 case typelib_TypeClass_LONG:
228 case typelib_TypeClass_UNSIGNED_LONG:
229 case typelib_TypeClass_ENUM:
230 case typelib_TypeClass_CHAR:
231 case typelib_TypeClass_SHORT:
232 case typelib_TypeClass_UNSIGNED_SHORT:
233 case typelib_TypeClass_BOOLEAN:
234 case typelib_TypeClass_BYTE:
235 *reinterpret_cast<sal_Int64*>(pRegisterReturn) = gret[0];
236 break;
237 case typelib_TypeClass_FLOAT:
238 case typelib_TypeClass_DOUBLE:
239 *reinterpret_cast<double*>(pRegisterReturn) = fret[0];
240 break;
241 case typelib_TypeClass_STRUCT:
242 case typelib_TypeClass_EXCEPTION:
243 {
244 sal_Int32 const nRetSize = pReturnTypeRef->pType->nSize;
245#ifdef BRIDGE_DEBUG
246 printf("nRetSize = %d\n", nRetSize);
247#endif
248 if (bSimpleReturn && nRetSize <= 16 && nRetSize > 0)
249 {
250 typelib_TypeDescription* pTypeDescr = 0;
251 TYPELIB_DANGER_GET(&pTypeDescr, pReturnTypeRef);
252 abi_riscv64::fillStruct(pTypeDescr, gret, fret, pRegisterReturn);
253 TYPELIB_DANGER_RELEASE(pTypeDescr);
254 }
255 break;
256 }
257 default:
258#ifdef BRIDGE_DEBUG
259 fprintf(stdout, "unhandled return type %u\n", pReturnTypeRef->eTypeClass);
260#endif
261 break;
262 }
263}
264
267 typelib_TypeDescriptionReference* pReturnTypeRef, sal_Int32 nParams,
268 typelib_MethodParameter* pParams, void* pUnoReturn, void* pUnoArgs[],
269 uno_Any** ppUnoExc)
270{
271#ifdef BRIDGE_DEBUG
272 printf("In cpp_call\n");
273 printf("pThis = %p, aVtableSlot = %p, pReturnTypeRef = %p, nParams = %d\n", pThis, aVtableSlot,
274 pReturnTypeRef, nParams);
275 printf("pParams = %p , pUnoReturn = %p, pUnoArgs = %p\n", pParams, pUnoReturn, pUnoArgs);
276#endif
277 // max space for: [complex ret ptr], values|ptr ...
278 sal_uInt64* pStack = (sal_uInt64*)__builtin_alloca(((nParams + 3) * sizeof(sal_Int64)));
279 sal_uInt64* pStackStart = pStack;
280
281 sal_uInt64 pGPR[MAX_GP_REGS];
282 sal_uInt64 nREG = 0;
283
284 double pFPR[MAX_FP_REGS];
285 sal_uInt32 nFPR = 0;
286#ifdef BRIDGE_DEBUG
287 printf("pGPR = %p, pFPR = %p\n", pGPR, pFPR);
288#endif
289
290 // return
291 typelib_TypeDescription* pReturnTypeDescr = 0;
292 TYPELIB_DANGER_GET(&pReturnTypeDescr, pReturnTypeRef);
293 assert(pReturnTypeDescr);
294
295 void* pCppReturn = 0; // if != 0 && != pUnoReturn, needs reconversion
296
297 bool bSimpleReturn = true;
298 if (pReturnTypeDescr)
299 {
301 {
302 bSimpleReturn = false;
303 // complex return via ptr
304 pCppReturn = bridges::cpp_uno::shared::relatesToInterfaceType(pReturnTypeDescr)
305 ? __builtin_alloca(pReturnTypeDescr->nSize)
306 : pUnoReturn;
307 INSERT_INT64(&pCppReturn, nREG, pGPR, pStack);
308 }
309 else
310 {
311 pCppReturn = pUnoReturn; // direct way for simple types
312 }
313 }
314
315 // push this
316 void* pAdjustedThisPtr = reinterpret_cast<void**>(pThis->getCppI()) + aVtableSlot.offset;
317 INSERT_INT64(&pAdjustedThisPtr, nREG, pGPR, pStack);
318
319 // args
320 void** pCppArgs = (void**)alloca(3 * sizeof(void*) * nParams);
321 // indices of values this have to be converted (interface conversion cpp<=>uno)
322 sal_Int32* pTempIndices = (sal_Int32*)(pCppArgs + nParams);
323 // type descriptions for reconversions
324 typelib_TypeDescription** ppTempParamTypeDescr
325 = (typelib_TypeDescription**)(pCppArgs + (2 * nParams));
326
327 sal_Int32 nTempIndices = 0;
328#ifdef BRIDGE_DEBUG
329 printf("In cpp_call, nParams = %d\n", nParams);
330 printf("pCppArgs = %p, pStack = %p\n", pCppArgs, pStack);
331#endif
332 for (sal_Int32 nPos = 0; nPos < nParams; ++nPos)
333 {
334#ifdef BRIDGE_DEBUG
335 printf("In cpp_call, nPos = %d\n", nPos);
336#endif
337 const typelib_MethodParameter& rParam = pParams[nPos];
338 typelib_TypeDescription* pParamTypeDescr = 0;
339 TYPELIB_DANGER_GET(&pParamTypeDescr, rParam.pTypeRef);
340
341 if (!rParam.bOut && bridges::cpp_uno::shared::isSimpleType(pParamTypeDescr))
342 {
343#ifdef BRIDGE_DEBUG
344 printf("Before uno_copyAndConvertData and tons of switch.\n");
345#endif
346 uno_copyAndConvertData(pCppArgs[nPos] = alloca(8), pUnoArgs[nPos], pParamTypeDescr,
347 pThis->getBridge()->getUno2Cpp());
348#ifdef BRIDGE_DEBUG
349 printf("Type = %d, Param = 0x%lx\n", pParamTypeDescr->eTypeClass,
350 *reinterpret_cast<sal_uInt64*>(pCppArgs[nPos]));
351#endif
352 switch (pParamTypeDescr->eTypeClass)
353 {
354 case typelib_TypeClass_LONG:
355 case typelib_TypeClass_UNSIGNED_LONG:
356 case typelib_TypeClass_ENUM:
357 INSERT_INT32(pCppArgs[nPos], nREG, pGPR, pStack);
358 break;
359 case typelib_TypeClass_CHAR:
360 case typelib_TypeClass_SHORT:
361 INSERT_INT16(pCppArgs[nPos], nREG, pGPR, pStack);
362 break;
363 case typelib_TypeClass_UNSIGNED_SHORT:
364 INSERT_UINT16(pCppArgs[nPos], nREG, pGPR, pStack);
365 break;
366 case typelib_TypeClass_BOOLEAN:
367 case typelib_TypeClass_BYTE:
368 INSERT_INT8(pCppArgs[nPos], nREG, pGPR, pStack);
369 break;
370 case typelib_TypeClass_FLOAT:
371 case typelib_TypeClass_DOUBLE:
372 INSERT_FLOAT_DOUBLE(pCppArgs[nPos], nFPR, pFPR, nREG, pGPR, pStack);
373 break;
374 case typelib_TypeClass_HYPER:
375 case typelib_TypeClass_UNSIGNED_HYPER:
376 INSERT_INT64(pCppArgs[nPos], nREG, pGPR, pStack);
377 break;
378 default:
379 break;
380 }
381
382 // no longer needed
383 TYPELIB_DANGER_RELEASE(pParamTypeDescr);
384 }
385 else // ptr to complex value | ref
386 {
387 if (!rParam.bIn) // is pure out
388 {
389 // cpp out is constructed mem, uno out is not!
390 uno_constructData(pCppArgs[nPos] = alloca(pParamTypeDescr->nSize), pParamTypeDescr);
391 pTempIndices[nTempIndices] = nPos; // default constructed for cpp call
392 // will be released at reconversion
393 ppTempParamTypeDescr[nTempIndices++] = pParamTypeDescr;
394 }
395 // is in/inout
396 else if (bridges::cpp_uno::shared::relatesToInterfaceType(pParamTypeDescr))
397 {
398 uno_copyAndConvertData(pCppArgs[nPos] = alloca(pParamTypeDescr->nSize),
399 pUnoArgs[nPos], pParamTypeDescr,
400 pThis->getBridge()->getUno2Cpp());
401
402 pTempIndices[nTempIndices] = nPos; // has to be reconverted
403 // will be released at reconversion
404 ppTempParamTypeDescr[nTempIndices++] = pParamTypeDescr;
405 }
406 else // direct way
407 {
408 pCppArgs[nPos] = pUnoArgs[nPos];
409 // no longer needed
410 TYPELIB_DANGER_RELEASE(pParamTypeDescr);
411 }
412 INSERT_INT64(&(pCppArgs[nPos]), nREG, pGPR, pStack);
413 }
414 }
415
416 try
417 {
418 try
419 {
420 callVirtualMethod(pAdjustedThisPtr, aVtableSlot.index, pCppReturn, pReturnTypeRef,
421 bSimpleReturn, pStackStart, (pStack - pStackStart), pGPR, pFPR,
422 pReturnTypeDescr);
423 }
424 catch (css::uno::Exception&)
425 {
426 throw;
427 }
428 catch (std::exception& e)
429 {
430 throw css::uno::RuntimeException("C++ code threw "
431 + o3tl::runtimeToOUString(typeid(e).name()) + ": "
432 + o3tl::runtimeToOUString(e.what()));
433 }
434 catch (...)
435 {
436 throw css::uno::RuntimeException("C++ code threw unknown exception");
437 }
438 // NO exception occurred...
439 *ppUnoExc = 0;
440
441 // reconvert temporary params
442 for (; nTempIndices--;)
443 {
444 sal_Int32 nIndex = pTempIndices[nTempIndices];
445 typelib_TypeDescription* pParamTypeDescr = ppTempParamTypeDescr[nTempIndices];
446
447 if (pParams[nIndex].bIn)
448 {
449 if (pParams[nIndex].bOut) // inout
450 {
451 uno_destructData(pUnoArgs[nIndex], pParamTypeDescr, 0); // destroy uno value
452 uno_copyAndConvertData(pUnoArgs[nIndex], pCppArgs[nIndex], pParamTypeDescr,
453 pThis->getBridge()->getCpp2Uno());
454 }
455 }
456 else // pure out
457 {
458 uno_copyAndConvertData(pUnoArgs[nIndex], pCppArgs[nIndex], pParamTypeDescr,
459 pThis->getBridge()->getCpp2Uno());
460 }
461 // destroy temp cpp param => cpp: every param was constructed
462 uno_destructData(pCppArgs[nIndex], pParamTypeDescr, cpp_release);
463
464 TYPELIB_DANGER_RELEASE(pParamTypeDescr);
465 }
466 // return value
467 if (pCppReturn && pUnoReturn != pCppReturn)
468 {
469 uno_copyAndConvertData(pUnoReturn, pCppReturn, pReturnTypeDescr,
470 pThis->getBridge()->getCpp2Uno());
471 uno_destructData(pCppReturn, pReturnTypeDescr, cpp_release);
472 }
473 }
474 catch (...)
475 {
476 // fill uno exception
478
479 // temporary params
480 for (; nTempIndices--;)
481 {
482 sal_Int32 nIndex = pTempIndices[nTempIndices];
483 // destroy temp cpp param => cpp: every param was constructed
484 uno_destructData(pCppArgs[nIndex], ppTempParamTypeDescr[nTempIndices], cpp_release);
485 TYPELIB_DANGER_RELEASE(ppTempParamTypeDescr[nTempIndices]);
486 }
487 // return type
488 if (pReturnTypeDescr)
489 TYPELIB_DANGER_RELEASE(pReturnTypeDescr);
490 }
491}
492}
493
495{
496void unoInterfaceProxyDispatch(uno_Interface* pUnoI, const typelib_TypeDescription* pMemberDescr,
497 void* pReturn, void* pArgs[], uno_Any** ppException)
498{
499#ifdef BRIDGE_DEBUG
500 printf("In unoInterfaceProxyDispatch:\n");
501 printf("pMemberDescr = %p, pReturn = %p, pArgs = %p, ppExeption = %p\n", pMemberDescr, pReturn,
502 pArgs, ppException);
503#endif
504 // is my surrogate
506 = static_cast<bridges::cpp_uno::shared::UnoInterfaceProxy*>(pUnoI);
507 //typelib_InterfaceTypeDescription * pTypeDescr = pThis->pTypeDescr;
508
509#ifdef BRIDGE_DEBUG
510 fprintf(stdout, "in dispatch\n");
511#endif
512
513 switch (pMemberDescr->eTypeClass)
514 {
515 case typelib_TypeClass_INTERFACE_ATTRIBUTE:
516 {
517 VtableSlot aVtableSlot(getVtableSlot(
518 reinterpret_cast<typelib_InterfaceAttributeTypeDescription const*>(pMemberDescr)));
519
520 if (pReturn)
521 {
522 // dependent dispatch
523 cpp_call(
524 pThis, aVtableSlot,
525 ((typelib_InterfaceAttributeTypeDescription*)pMemberDescr)->pAttributeTypeRef,
526 0, 0, // no params
527 pReturn, pArgs, ppException);
528 }
529 else
530 {
531 // is SET
532 typelib_MethodParameter aParam;
533 aParam.pTypeRef
534 = ((typelib_InterfaceAttributeTypeDescription*)pMemberDescr)->pAttributeTypeRef;
535 aParam.bIn = sal_True;
536 aParam.bOut = sal_False;
537
538 typelib_TypeDescriptionReference* pReturnTypeRef = 0;
539 OUString aVoidName("void");
540 typelib_typedescriptionreference_new(&pReturnTypeRef, typelib_TypeClass_VOID,
541 aVoidName.pData);
542
543 // dependent dispatch
544 aVtableSlot.index += 1; //get then set method
545 cpp_call(pThis, aVtableSlot, pReturnTypeRef, 1, &aParam, pReturn, pArgs,
546 ppException);
547
549 }
550
551 break;
552 }
553 case typelib_TypeClass_INTERFACE_METHOD:
554 {
555 VtableSlot aVtableSlot(getVtableSlot(
556 reinterpret_cast<typelib_InterfaceMethodTypeDescription const*>(pMemberDescr)));
557 switch (aVtableSlot.index)
558 {
559 // standard calls
560 case 1: // acquire uno interface
561 (*pUnoI->acquire)(pUnoI);
562 *ppException = 0;
563 break;
564 case 2: // release uno interface
565 (*pUnoI->release)(pUnoI);
566 *ppException = 0;
567 break;
568 case 0: // queryInterface() opt
569 {
571 TYPELIB_DANGER_GET(&pTD, reinterpret_cast<Type*>(pArgs[0])->getTypeLibType());
572 if (pTD)
573 {
574 uno_Interface* pInterface = 0;
575 (*pThis->pBridge->getUnoEnv()->getRegisteredInterface)(
576 pThis->pBridge->getUnoEnv(), (void**)&pInterface, pThis->oid.pData,
577 (typelib_InterfaceTypeDescription*)pTD);
578
579 if (pInterface)
580 {
581 ::uno_any_construct(reinterpret_cast<uno_Any*>(pReturn), &pInterface,
582 pTD, 0);
583 (*pInterface->release)(pInterface);
584 TYPELIB_DANGER_RELEASE(pTD);
585 *ppException = 0;
586 break;
587 }
588 TYPELIB_DANGER_RELEASE(pTD);
589 }
590 } // else perform queryInterface()
591 default:
592 // dependent dispatch
593 cpp_call(
594 pThis, aVtableSlot,
595 ((typelib_InterfaceMethodTypeDescription*)pMemberDescr)->pReturnTypeRef,
596 ((typelib_InterfaceMethodTypeDescription*)pMemberDescr)->nParams,
597 ((typelib_InterfaceMethodTypeDescription*)pMemberDescr)->pParams, pReturn,
598 pArgs, ppException);
599 }
600 break;
601 }
602 default:
603 {
604 ::com::sun::star::uno::RuntimeException aExc(
605 "illegal member type description!",
607
608 Type const& rExcType = cppu::UnoType<decltype(aExc)>::get();
609 // binary identical null reference
610 ::uno_type_any_construct(*ppException, &aExc, rExcType.getTypeLibType(), 0);
611 }
612 }
613}
614}
615
616/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
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
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 MAX_FP_REGS
#define MAX_GP_REGS
#define INSERT_INT32(pSV, nr, pGPR, pDS)
#define INSERT_INT8(pSV, nr, pGPR, pDS)
#define INSERT_FLOAT_DOUBLE(pSV, nfr, pFPR, ngr, pGPR, pDS)
#define INSERT_INT16(pSV, nr, pGPR, pDS)
#define INSERT_INT64(pSV, nr, pGPR, pDS)
#define INSERT_UINT16(pSV, nr, pGPR, pDS)
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
return NULL
struct _typelib_TypeDescription typelib_TypeDescription
Definition: msvc/except.hxx:53
struct _uno_Any uno_Any
Definition: msvc/except.hxx:32
bool return_in_hidden_param(typelib_TypeDescriptionReference *pTypeRef)
void fillUnoException(uno_Any *pUnoExc, uno_Mapping *pCpp2Uno)
void fillStruct(const typelib_TypeDescription *pTypeDescr, sal_Int64 *gret, double *fret, void *pRegisterReturn)
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
void fillReturn(typelib_TypeDescriptionReference *pTypeRef, sal_Int64 *gret, double *fret, void *pRegisterReturn)
OUString runtimeToOUString(char const *runtimeString)
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
#define sal_False