LibreOffice Module bridges (master) 1
gcc3_linux_ia64/cpp2uno.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
21#include <com/sun/star/uno/genfunc.hxx>
22#include <sal/log.hxx>
23#include <uno/data.h>
24#include <typelib/typedescription.hxx>
25
26#include "bridge.hxx"
27#include "cppinterfaceproxy.hxx"
28#include "types.hxx"
29#include "vtablefactory.hxx"
30
31#include "share.hxx"
32#include <stdio.h>
33#include <typeinfo>
34
35extern "C" { extern void (*privateSnippetExecutor)(); }
36
37using namespace ::com::sun::star::uno;
38
39namespace
40{
41
42static typelib_TypeClass cpp2uno_call(
44 const typelib_TypeDescription * pMemberTypeDescr,
45 typelib_TypeDescriptionReference * pReturnTypeRef, // 0 indicates void return
46 sal_Int32 nParams, typelib_MethodParameter * pParams, long r8,
47 void ** gpreg, void ** fpreg, void ** ovrflw,
48 sal_Int64 * pRegisterReturn /* space for register return */ )
49{
50#if OSL_DEBUG_LEVEL > 2
51 fprintf(stderr, "as far as cpp2uno_call\n");
52#endif
53
54 int ng = 0; //number of gpr registers used
55 int nf = 0; //number of fpr registers used
56
57 // gpreg: [ret *], this, [gpr params]
58 // fpreg: [fpr params]
59 // ovrflw: [gpr or fpr params (properly aligned)]
60
61 // return
62 typelib_TypeDescription * pReturnTypeDescr = 0;
63 if (pReturnTypeRef)
64 TYPELIB_DANGER_GET( &pReturnTypeDescr, pReturnTypeRef );
65
66 void * pUnoReturn = 0;
67 void * pCppReturn = 0; // complex return ptr: if != 0 && != pUnoReturn, reconversion need
68
69 if (pReturnTypeDescr)
70 {
71 if ( ia64::return_in_hidden_param( pReturnTypeRef ) ) // complex return via ptr passed as hidden parameter reg (pCppReturn)
72 {
73 pCppReturn = *(void **)gpreg;
74 gpreg++;
75 ng++;
76
77 pUnoReturn = (bridges::cpp_uno::shared::relatesToInterfaceType( pReturnTypeDescr )
78 ? alloca( pReturnTypeDescr->nSize )
79 : pCppReturn); // direct way
80 }
81 else if ( ia64::return_via_r8_buffer( pReturnTypeRef ) ) // complex return via ptr passed in r8
82 {
83 pCppReturn = (void *)r8;
84
85 pUnoReturn = (bridges::cpp_uno::shared::relatesToInterfaceType( pReturnTypeDescr )
86 ? alloca( pReturnTypeDescr->nSize )
87 : pCppReturn); // direct way
88 }
89
90 else
91 pUnoReturn = pRegisterReturn; // direct way for simple types
92 }
93 // pop this
94 gpreg++;
95 ng++;
96
97 // stack space
98 static_assert(sizeof(void *) == sizeof(sal_Int64), "### unexpected size!");
99 // parameters
100 void ** pUnoArgs = (void **)alloca( 4 * sizeof(void *) * nParams );
101 void ** pCppArgs = pUnoArgs + nParams;
102 // indices of values this have to be converted (interface conversion cpp<=>uno)
103 sal_Int32 * pTempIndices = (sal_Int32 *)(pUnoArgs + (2 * nParams));
104 // type descriptions for reconversions
105 typelib_TypeDescription ** ppTempParamTypeDescr = (typelib_TypeDescription **)(pUnoArgs + (3 * nParams));
106
107 sal_Int32 nTempIndices = 0;
108 bool bOverflowUsed = false;
109 for ( sal_Int32 nPos = 0; nPos < nParams; ++nPos )
110 {
111 const typelib_MethodParameter & rParam = pParams[nPos];
112 typelib_TypeDescription * pParamTypeDescr = 0;
113 TYPELIB_DANGER_GET( &pParamTypeDescr, rParam.pTypeRef );
114
115#if OSL_DEBUG_LEVEL > 2
116 fprintf(stderr, "arg %d of %d\n", nPos, nParams);
117#endif
118
119 //I think it is impossible to get UNO to pass structs as parameters by copy
120 if (!rParam.bOut && bridges::cpp_uno::shared::isSimpleType( pParamTypeDescr ))
121 {
122#if OSL_DEBUG_LEVEL > 2
123 fprintf(stderr, "simple\n");
124#endif
125
126 switch (pParamTypeDescr->eTypeClass)
127 {
128 case typelib_TypeClass_FLOAT:
129 if (nf < ia64::MAX_SSE_REGS && ng < ia64::MAX_GPR_REGS)
130 {
131 float tmp = (float) (*((double *)fpreg));
132 (*((float *) fpreg)) = tmp;
133 pCppArgs[nPos] = pUnoArgs[nPos] = fpreg++;
134 nf++;
135 gpreg++;
136 ng++;
137 }
138 else
139 {
140 pCppArgs[nPos] = pUnoArgs[nPos] = ovrflw;
141 bOverflowUsed = true;
142 }
143 if (bOverflowUsed) ovrflw++;
144 break;
145 case typelib_TypeClass_DOUBLE:
146 if (nf < ia64::MAX_SSE_REGS && ng < ia64::MAX_GPR_REGS)
147 {
148 pCppArgs[nPos] = pUnoArgs[nPos] = fpreg++;
149 nf++;
150 gpreg++;
151 ng++;
152 }
153 else
154 {
155 pCppArgs[nPos] = pUnoArgs[nPos] = ovrflw;
156 bOverflowUsed = true;
157 }
158 if (bOverflowUsed) ovrflw++;
159 break;
160 case typelib_TypeClass_BYTE:
161 case typelib_TypeClass_BOOLEAN:
162 case typelib_TypeClass_CHAR:
163 case typelib_TypeClass_SHORT:
164 case typelib_TypeClass_UNSIGNED_SHORT:
165 case typelib_TypeClass_ENUM:
166 case typelib_TypeClass_LONG:
167 case typelib_TypeClass_UNSIGNED_LONG:
168 default:
169 if (ng < ia64::MAX_GPR_REGS)
170 {
171 pCppArgs[nPos] = pUnoArgs[nPos] = gpreg++;
172 ng++;
173 }
174 else
175 {
176 pCppArgs[nPos] = pUnoArgs[nPos] = ovrflw;
177 bOverflowUsed = true;
178 }
179 if (bOverflowUsed) ovrflw++;
180 break;
181 }
182
183 // no longer needed
184 TYPELIB_DANGER_RELEASE( pParamTypeDescr );
185 }
186 else // ptr to complex value | ref
187 {
188#if OSL_DEBUG_LEVEL > 2
189 fprintf(stderr, "complex, ng is %d\n", ng);
190#endif
191 void *pCppStack; //temporary stack pointer
192
193 if (ng < ia64::MAX_GPR_REGS)
194 {
195 pCppArgs[nPos] = pCppStack = *gpreg++;
196 ng++;
197 }
198 else
199 {
200 pCppArgs[nPos] = pCppStack = *ovrflw;
201 bOverflowUsed = true;
202 }
203 if (bOverflowUsed) ovrflw++;
204
205 if (! rParam.bIn) // is pure out
206 {
207 // uno out is unconstructed mem!
208 pUnoArgs[nPos] = alloca( pParamTypeDescr->nSize );
209 pTempIndices[nTempIndices] = nPos;
210 // will be released at reconversion
211 ppTempParamTypeDescr[nTempIndices++] = pParamTypeDescr;
212 }
213 // is in/inout
214 else if (bridges::cpp_uno::shared::relatesToInterfaceType( pParamTypeDescr ))
215 {
216 uno_copyAndConvertData( pUnoArgs[nPos] = alloca( pParamTypeDescr->nSize ),
217 pCppStack, pParamTypeDescr,
218 pThis->getBridge()->getCpp2Uno() );
219 pTempIndices[nTempIndices] = nPos; // has to be reconverted
220 // will be released at reconversion
221 ppTempParamTypeDescr[nTempIndices++] = pParamTypeDescr;
222 }
223 else // direct way
224 {
225 pUnoArgs[nPos] = pCppStack;
226 // no longer needed
227 TYPELIB_DANGER_RELEASE( pParamTypeDescr );
228 }
229 }
230 }
231
232#if OSL_DEBUG_LEVEL > 2
233 fprintf(stderr, "end of params\n");
234#endif
235
236 // ExceptionHolder
237 uno_Any aUnoExc; // Any will be constructed by callee
238 uno_Any * pUnoExc = &aUnoExc;
239
240 // invoke uno dispatch call
241 (*pThis->getUnoI()->pDispatcher)( pThis->getUnoI(), pMemberTypeDescr, pUnoReturn, pUnoArgs, &pUnoExc );
242
243 // in case an exception occurred...
244 if (pUnoExc)
245 {
246 // destruct temporary in/inout params
247 for ( ; nTempIndices--; )
248 {
249 sal_Int32 nIndex = pTempIndices[nTempIndices];
250
251 if (pParams[nIndex].bIn) // is in/inout => was constructed
252 uno_destructData( pUnoArgs[nIndex], ppTempParamTypeDescr[nTempIndices], 0 );
253 TYPELIB_DANGER_RELEASE( ppTempParamTypeDescr[nTempIndices] );
254 }
255 if (pReturnTypeDescr)
256 TYPELIB_DANGER_RELEASE( pReturnTypeDescr );
257
259 // has to destruct the any
260 // is here for dummy
261 return typelib_TypeClass_VOID;
262 }
263 else // else no exception occurred...
264 {
265 // temporary params
266 for ( ; nTempIndices--; )
267 {
268 sal_Int32 nIndex = pTempIndices[nTempIndices];
269 typelib_TypeDescription * pParamTypeDescr = ppTempParamTypeDescr[nTempIndices];
270
271 if (pParams[nIndex].bOut) // inout/out
272 {
273 // convert and assign
274 uno_destructData( pCppArgs[nIndex], pParamTypeDescr, cpp_release );
275 uno_copyAndConvertData( pCppArgs[nIndex], pUnoArgs[nIndex], pParamTypeDescr,
276 pThis->getBridge()->getUno2Cpp() );
277 }
278 // destroy temp uno param
279 uno_destructData( pUnoArgs[nIndex], pParamTypeDescr, 0 );
280
281 TYPELIB_DANGER_RELEASE( pParamTypeDescr );
282 }
283 // return
284 if (pCppReturn) // has complex return
285 {
286 if (pUnoReturn != pCppReturn) // needs reconversion
287 {
288 uno_copyAndConvertData( pCppReturn, pUnoReturn, pReturnTypeDescr,
289 pThis->getBridge()->getUno2Cpp() );
290 // destroy temp uno return
291 uno_destructData( pUnoReturn, pReturnTypeDescr, 0 );
292 }
293 // complex return ptr is set to return reg
294 *(void **)pRegisterReturn = pCppReturn;
295 }
296 if (pReturnTypeDescr)
297 {
298 typelib_TypeClass eRet = ia64::return_via_r8_buffer(pReturnTypeRef) ? typelib_TypeClass_VOID : (typelib_TypeClass)pReturnTypeDescr->eTypeClass;
299 TYPELIB_DANGER_RELEASE( pReturnTypeDescr );
300 return eRet;
301 }
302 else
303 return typelib_TypeClass_VOID;
304 }
305}
306
307
308static typelib_TypeClass cpp_mediate(
309 sal_uInt64 nOffsetAndIndex,
310 void ** gpreg, void ** fpreg, long sp, long r8,
311 sal_Int64 * pRegisterReturn /* space for register return */ )
312{
313 static_assert(sizeof(sal_Int64)==sizeof(void *), "### unexpected!");
314
315 sal_Int32 nVtableOffset = (nOffsetAndIndex >> 32);
316 sal_Int32 nFunctionIndex = (nOffsetAndIndex & 0xFFFFFFFF);
317
318 void ** ovrflw = (void**)(sp);
319
320 // gpreg: [ret *], this, [other gpr params]
321 // fpreg: [fpr params]
322 // ovrflw: [gpr or fpr params (properly aligned)]
323
324 void * pThis;
325 if (nFunctionIndex & 0x80000000 )
326 {
327 nFunctionIndex &= 0x7fffffff;
328 pThis = gpreg[1];
329#if OSL_DEBUG_LEVEL > 2
330 fprintf(stderr, "pThis is gpreg[1]\n");
331#endif
332 }
333 else
334 {
335 pThis = gpreg[0];
336#if OSL_DEBUG_LEVEL > 2
337 fprintf(stderr, "pThis is gpreg[0]\n");
338#endif
339 }
340
341#if OSL_DEBUG_LEVEL > 2
342 fprintf(stderr, "pThis is %p\n", pThis);
343#endif
344
345 pThis = static_cast< char * >(pThis) - nVtableOffset;
346
347#if OSL_DEBUG_LEVEL > 2
348 fprintf(stderr, "pThis is now %p\n", pThis);
349#endif
350
353 pThis);
354
355 typelib_InterfaceTypeDescription * pTypeDescr = pCppI->getTypeDescr();
356
357#if OSL_DEBUG_LEVEL > 2
358 fprintf(stderr, "indexes are %d %d\n", nFunctionIndex, pTypeDescr->nMapFunctionIndexToMemberIndex);
359#endif
360
361 if (nFunctionIndex >= pTypeDescr->nMapFunctionIndexToMemberIndex)
362 {
363 SAL_WARN(
364 "bridges",
365 "illegal " << OUString::unacquired(&pTypeDescr->aBase.pTypeName)
366 << " vtable index " << nFunctionIndex << "/"
367 << pTypeDescr->nMapFunctionIndexToMemberIndex);
368 throw RuntimeException(
369 ("illegal " + OUString::unacquired(&pTypeDescr->aBase.pTypeName)
370 + " vtable index " + OUString::number(nFunctionIndex) + "/"
371 + OUString::number(pTypeDescr->nMapFunctionIndexToMemberIndex)),
372 (XInterface *)pThis);
373 }
374
375 // determine called method
376 sal_Int32 nMemberPos = pTypeDescr->pMapFunctionIndexToMemberIndex[nFunctionIndex];
377 assert(nMemberPos < pTypeDescr->nAllMembers);
378
379#if OSL_DEBUG_LEVEL > 2
380 fprintf(stderr, "members are %d %d\n", nMemberPos, pTypeDescr->nAllMembers);
381#endif
382
383 TypeDescription aMemberDescr( pTypeDescr->ppAllMembers[nMemberPos] );
384
385 typelib_TypeClass eRet;
386 switch (aMemberDescr.get()->eTypeClass)
387 {
388 case typelib_TypeClass_INTERFACE_ATTRIBUTE:
389 {
390 if (pTypeDescr->pMapMemberIndexToFunctionIndex[nMemberPos] == nFunctionIndex)
391 {
392 // is GET method
393 eRet = cpp2uno_call(
394 pCppI, aMemberDescr.get(),
395 ((typelib_InterfaceAttributeTypeDescription *)aMemberDescr.get())->pAttributeTypeRef,
396 0, 0, // no params
397 r8, gpreg, fpreg, ovrflw, pRegisterReturn );
398 }
399 else
400 {
401 // is SET method
402 typelib_MethodParameter aParam;
403 aParam.pTypeRef =
404 ((typelib_InterfaceAttributeTypeDescription *)aMemberDescr.get())->pAttributeTypeRef;
405 aParam.bIn = sal_True;
406 aParam.bOut = sal_False;
407
408 eRet = cpp2uno_call(
409 pCppI, aMemberDescr.get(),
410 0, // indicates void return
411 1, &aParam,
412 r8, gpreg, fpreg, ovrflw, pRegisterReturn );
413 }
414 break;
415 }
416 case typelib_TypeClass_INTERFACE_METHOD:
417 {
418 // is METHOD
419 switch (nFunctionIndex)
420 {
421 case 1: // acquire()
422 pCppI->acquireProxy(); // non virtual call!
423 eRet = typelib_TypeClass_VOID;
424 break;
425 case 2: // release()
426 pCppI->releaseProxy(); // non virtual call!
427 eRet = typelib_TypeClass_VOID;
428 break;
429 case 0: // queryInterface() opt
430 {
431 typelib_TypeDescription * pTD = 0;
432 TYPELIB_DANGER_GET( &pTD, reinterpret_cast< Type * >( gpreg[2] )->getTypeLibType() );
433 if (pTD)
434 {
435 XInterface * pInterface = 0;
436 (*pCppI->getBridge()->getCppEnv()->getRegisteredInterface)(
437 pCppI->getBridge()->getCppEnv(),
438 (void **)&pInterface, pCppI->getOid().pData,
439 (typelib_InterfaceTypeDescription *)pTD );
440
441 if (pInterface)
442 {
443 ::uno_any_construct(
444 reinterpret_cast< uno_Any * >( gpreg[0] ),
445 &pInterface, pTD, cpp_acquire );
446 pInterface->release();
447 TYPELIB_DANGER_RELEASE( pTD );
448 *(void **)pRegisterReturn = gpreg[0];
449 eRet = typelib_TypeClass_ANY;
450 break;
451 }
452 TYPELIB_DANGER_RELEASE( pTD );
453 }
454 } // else perform queryInterface()
455 default:
456 eRet = cpp2uno_call(
457 pCppI, aMemberDescr.get(),
458 ((typelib_InterfaceMethodTypeDescription *)aMemberDescr.get())->pReturnTypeRef,
459 ((typelib_InterfaceMethodTypeDescription *)aMemberDescr.get())->nParams,
460 ((typelib_InterfaceMethodTypeDescription *)aMemberDescr.get())->pParams,
461 r8, gpreg, fpreg, ovrflw, pRegisterReturn );
462 }
463 break;
464 }
465 default:
466 {
467#if OSL_DEBUG_LEVEL > 2
468 fprintf(stderr, "screwed\n");
469#endif
470
471 throw RuntimeException( "no member description found!", (XInterface *)pThis );
472 }
473 }
474
475#if OSL_DEBUG_LEVEL > 2
476 fprintf(stderr, "end of cpp_mediate\n");
477#endif
478 return eRet;
479}
480}
481
483 long in0, long in1, long in2, long in3, long in4, long in5, long in6, long in7,
484 long firstonstack
485 )
486{
487 register long r15 asm("r15");
488 long r8 = r15;
489
490 register long r14 asm("r14");
491 long nOffsetAndIndex = r14;
492
493 long sp = (long)&firstonstack;
494
495 sal_uInt64 gpreg[ia64::MAX_GPR_REGS];
496 gpreg[0] = in0;
497 gpreg[1] = in1;
498 gpreg[2] = in2;
499 gpreg[3] = in3;
500 gpreg[4] = in4;
501 gpreg[5] = in5;
502 gpreg[6] = in6;
503 gpreg[7] = in7;
504
505 double fpreg[ia64::MAX_SSE_REGS];
506 register double f8 asm("f8"); fpreg[0] = f8;
507 register double f9 asm("f9"); fpreg[1] = f9;
508 register double f10 asm("f10"); fpreg[2] = f10;
509 register double f11 asm("f11"); fpreg[3] = f11;
510 register double f12 asm("f12"); fpreg[4] = f12;
511 register double f13 asm("f13"); fpreg[5] = f13;
512 register double f14 asm("f14"); fpreg[6] = f14;
513 register double f15 asm("f15"); fpreg[7] = f15;
514
515#if OSL_DEBUG_LEVEL > 2
516 fprintf(stderr, "cpp_vtable_call called with %lx\n", nOffsetAndIndex);
517 fprintf(stderr, "adump is %lx %lx %lx %lx %lx %lx %lx %lx\n", in0, in1, in2, in3, in4, in5, in6, in7);
518 fprintf(stderr, "bdump is %f %f %f %f %f %f %f %f\n", f8, f9, f10, f11, f12, f13, f14, f15);
519#endif
520
521 volatile long nRegReturn[4] = { 0 };
522
523 typelib_TypeClass aType =
524 cpp_mediate( nOffsetAndIndex, (void**)gpreg, (void**)fpreg, sp, r8, (sal_Int64*)&nRegReturn[0]);
525
526 ia64::RegReturn ret;
527 switch( aType )
528 {
529 case typelib_TypeClass_VOID:
530 break;
531 case typelib_TypeClass_BOOLEAN:
532 case typelib_TypeClass_BYTE:
533 case typelib_TypeClass_CHAR:
534 case typelib_TypeClass_UNSIGNED_SHORT:
535 case typelib_TypeClass_SHORT:
536 case typelib_TypeClass_ENUM:
537 case typelib_TypeClass_UNSIGNED_LONG:
538 case typelib_TypeClass_LONG:
539 case typelib_TypeClass_UNSIGNED_HYPER:
540 case typelib_TypeClass_HYPER:
541 ret.r8 = nRegReturn[0];
542 break;
543 case typelib_TypeClass_FLOAT:
544 asm volatile("ldfs f8=%0" : : "m"((*((float*)&nRegReturn))) : "f8");
545 break;
546 case typelib_TypeClass_DOUBLE:
547 asm volatile("ldfd f8=%0" : : "m"((*((double*)&nRegReturn))) : "f8");
548 break;
549 case typelib_TypeClass_STRUCT:
550 case typelib_TypeClass_EXCEPTION:
551 {
552 ret.r8 = nRegReturn[0];
553 ret.r9 = nRegReturn[1];
554 ret.r10 = nRegReturn[2];
555 ret.r11 = nRegReturn[3];
556 break;
557 }
558 default:
559 break;
560 }
561 return ret;
562}
563
564namespace
565{
566const int codeSnippetSize = 40;
567
568bridges::cpp_uno::shared::VtableFactory::Slot codeSnippet( unsigned char * code, sal_PtrDiff writetoexecdiff, sal_Int32 nFunctionIndex, sal_Int32 nVtableOffset,
569 bool bHasHiddenParam )
570{
571#if OSL_DEBUG_LEVEL > 2
572 fprintf(stderr, "size is %d\n", codeSnippetSize);
573 fprintf(stderr,"in codeSnippet functionIndex is %x\n", nFunctionIndex);
574 fprintf(stderr,"in codeSnippet vtableOffset is %x\n", nVtableOffset);
575#endif
576
577 sal_uInt64 nOffsetAndIndex = ( ( (sal_uInt64) nVtableOffset ) << 32 ) | ( (sal_uInt64) nFunctionIndex );
578
579 if ( bHasHiddenParam )
580 nOffsetAndIndex |= 0x80000000;
581
582 long *raw = (long *)code;
583
585
586 raw[0] = (long)&privateSnippetExecutor;
587 raw[1] = (long)&raw[2];
588 raw[2] = nOffsetAndIndex;
589 raw[3] = destination->gp_value;
590
591 return *(bridges::cpp_uno::shared::VtableFactory::Slot*)(code+writetoexecdiff);
592}
593}
594
595void bridges::cpp_uno::shared::VtableFactory::flushCode(unsigned char const *, unsigned char const *)
596{
597}
598
600{
601 return static_cast< Slot * >(block) + 1;
602}
603
604
606 sal_Int32 slotCount)
607{
608 return (slotCount + 1) * sizeof (Slot) + slotCount * codeSnippetSize;
609}
610
611namespace {
612// Some dummy type whose RTTI is used in the synthesized proxy vtables to make uses of dynamic_cast
613// on such proxy objects not crash:
614struct ProxyRtti {};
615}
616
617bridges::cpp_uno::shared::VtableFactory::Slot* bridges::cpp_uno::shared::VtableFactory::initializeBlock(void * block, sal_Int32 slotCount, sal_Int32, typelib_InterfaceTypeDescription *)
618{
619 Slot * slots = mapBlockToVtable(block);
620 slots[-1] = {0,reinterpret_cast<sal_uInt64>(&typeid(ProxyRtti))};
621 return slots + slotCount;
622}
623
625 Slot ** in_slots, unsigned char * code, sal_PtrDiff writetoexecdiff,
626 typelib_InterfaceTypeDescription const * type, sal_Int32 functionOffset,
627 sal_Int32 functionCount, sal_Int32 vtableOffset)
628{
629 (*in_slots) -= functionCount;
630 Slot * slots = *in_slots;
631#if OSL_DEBUG_LEVEL > 2
632 fprintf(stderr, "in addLocalFunctions functionOffset is %x\n",functionOffset);
633 fprintf(stderr, "in addLocalFunctions vtableOffset is %x\n",vtableOffset);
634#endif
635
636 for (sal_Int32 i = 0; i < type->nMembers; ++i) {
637 typelib_TypeDescription * member = 0;
638 TYPELIB_DANGER_GET(&member, type->ppMembers[i]);
639 assert(member != 0);
640 switch (member->eTypeClass) {
641 case typelib_TypeClass_INTERFACE_ATTRIBUTE:
642 // Getter:
643 *slots++ = codeSnippet(
644 code, writetoexecdiff, functionOffset++, vtableOffset,
646 reinterpret_cast<
647 typelib_InterfaceAttributeTypeDescription * >(
648 member)->pAttributeTypeRef));
650
651
652 // Setter:
653 if (!reinterpret_cast<
654 typelib_InterfaceAttributeTypeDescription * >(
655 member)->bReadOnly)
656 {
657 *slots++ = codeSnippet(code, writetoexecdiff, functionOffset++, vtableOffset, false);
659 }
660 break;
661
662 case typelib_TypeClass_INTERFACE_METHOD:
663 *slots++ = codeSnippet(
664 code, writetoexecdiff, functionOffset++, vtableOffset,
666 reinterpret_cast<
667 typelib_InterfaceMethodTypeDescription * >(
668 member)->pReturnTypeRef));
670 break;
671
672 default:
673 assert(false);
674 break;
675 }
676 TYPELIB_DANGER_RELEASE(member);
677 }
678 return code;
679}
680
681/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
uno_Mapping * getUno2Cpp()
Definition: bridge.hxx:73
uno_ExtEnvironment * getCppEnv()
Definition: bridge.hxx:69
uno_Mapping * getCpp2Uno()
Definition: bridge.hxx:72
A cpp proxy wrapping a uno interface.
static CppInterfaceProxy * castInterfaceToProxy(void *pInterface)
typelib_InterfaceTypeDescription * getTypeDescr()
static Slot * mapBlockToVtable(void *block)
Given a pointer to a block, turn it into a vtable pointer.
static void flushCode(unsigned char const *begin, unsigned char const *end)
Flush all the generated code snippets of a vtable, on platforms that require it.
static unsigned char * addLocalFunctions(Slot **slots, unsigned char *code, sal_PtrDiff writetoexecdiff, typelib_InterfaceTypeDescription const *type, sal_Int32 functionOffset, sal_Int32 functionCount, sal_Int32 vtableOffset)
Fill the vtable slots corresponding to all local (i.e., not inherited) functions of a given interface...
static Slot * initializeBlock(void *block, sal_Int32 slotCount, sal_Int32 vtableNumber, typelib_InterfaceTypeDescription *type)
Initialize a raw vtable block.
static std::size_t getBlockSize(sal_Int32 slotCount)
Calculate the size of a raw vtable block.
void SAL_CALL uno_destructData(void *pValue, typelib_TypeDescription *pTypeDescr, uno_ReleaseFunc release) SAL_THROW_EXTERN_C()
void SAL_CALL uno_copyAndConvertData(void *pDest, void *pSource, typelib_TypeDescription *pTypeDescr, uno_Mapping *mapping) SAL_THROW_EXTERN_C()
void(* privateSnippetExecutor)()
ia64::RegReturn cpp_vtable_call(long in0, long in1, long in2, long in3, long in4, long in5, long in6, long in7, long firstonstack)
const int codeSnippetSize
static unsigned char * codeSnippet(unsigned char *code, sal_Int32 nFunctionIndex, sal_Int32 nVtableOffset, bool bHasHiddenParam)
static int cpp2uno_call(bridges::cpp_uno::shared::CppInterfaceProxy *pThis, const typelib_TypeDescription *pMemberTypeDescr, typelib_TypeDescriptionReference *pReturnTypeRef, sal_Int32 nParams, typelib_MethodParameter *pParams, void **gpreg, void **fpreg, void **ovrflw, sal_uInt64 *pRegisterReturn)
sal_Int32 nIndex
sal_uInt16 nPos
#define SAL_WARN(area, stream)
struct _typelib_TypeDescription typelib_TypeDescription
Definition: msvc/except.hxx:53
struct _uno_Any uno_Any
Definition: msvc/except.hxx:32
typelib_TypeClass __cdecl cpp_mediate(void **pCallStack, const sal_Int32 nFunctionIndex, const sal_Int32 nVtableOffset, sal_Int64 *const pRegisterReturn)
void raiseException(uno_Any *pUnoExc, uno_Mapping *pUno2Cpp)
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
bool return_via_r8_buffer(typelib_TypeDescriptionReference *pTypeRef)
bool return_in_hidden_param(typelib_TypeDescriptionReference *pTypeRef)
sal_Unicode code
#define sal_True
#define sal_False
ResultType type