LibreOffice Module bridges (master) 1
gcc3_linux_alpha/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
35//Calling Standards:
36// "Calling Standard for Alpha Systems"
37// (Tru64 UNIX Version 5.1 or higher, August 2000)
38//http://www.tru64unix.compaq.com/docs/base_doc/DOCUMENTATION/V51_HTML/ARH9MBTE/TITLE.HTM
39
40using namespace ::com::sun::star::uno;
41
42namespace
43{
44static typelib_TypeClass cpp2uno_call(
46 const typelib_TypeDescription * pMemberTypeDescr,
47 typelib_TypeDescriptionReference * pReturnTypeRef, // 0 indicates void return
48 sal_Int32 nParams, typelib_MethodParameter * pParams,
49 void ** gpreg, void ** fpreg, void ** ovrflw,
50 sal_Int64 * pRegisterReturn /* space for register return */ )
51{
52#if OSL_DEBUG_LEVEL > 2
53 fprintf(stderr, "as far as cpp2uno_call\n");
54#endif
55 int nregs = 0; //number of words passed in registers
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 (bridges::cpp_uno::shared::isSimpleType( pReturnTypeDescr ))
72 {
73 pUnoReturn = pRegisterReturn; // direct way for simple types
74 }
75 else // complex return via ptr (pCppReturn)
76 {
77 pCppReturn = *(void **)gpreg;
78 gpreg++;
79 fpreg++;
80 nregs++;
81
82 pUnoReturn = (bridges::cpp_uno::shared::relatesToInterfaceType( pReturnTypeDescr )
83 ? alloca( pReturnTypeDescr->nSize )
84 : pCppReturn); // direct way
85 }
86 }
87 // pop this
88 gpreg++;
89 fpreg++;
90 nregs++;
91
92 // stack space
93 static_assert(sizeof(void *) == sizeof(sal_Int64), "### unexpected size!");
94 // parameters
95 void ** pUnoArgs = (void **)alloca( 4 * sizeof(void *) * nParams );
96 void ** pCppArgs = pUnoArgs + nParams;
97 // indices of values this have to be converted (interface conversion cpp<=>uno)
98 sal_Int32 * pTempIndices = (sal_Int32 *)(pUnoArgs + (2 * nParams));
99 // type descriptions for reconversions
100 typelib_TypeDescription ** ppTempParamTypeDescr = (typelib_TypeDescription **)(pUnoArgs + (3 * nParams));
101
102 sal_Int32 nTempIndices = 0;
103 for ( sal_Int32 nPos = 0; nPos < nParams; ++nPos )
104 {
105 const typelib_MethodParameter & rParam = pParams[nPos];
106 typelib_TypeDescription * pParamTypeDescr = 0;
107 TYPELIB_DANGER_GET( &pParamTypeDescr, rParam.pTypeRef );
108
109#if OSL_DEBUG_LEVEL > 2
110 fprintf(stderr, "arg %d of %d\n", nPos, nParams);
111#endif
112
113 if (!rParam.bOut && bridges::cpp_uno::shared::isSimpleType( pParamTypeDescr )) // value
114 {
115#if OSL_DEBUG_LEVEL > 2
116 fprintf(stderr, "simple type is %d\n", pParamTypeDescr->eTypeClass);
117#endif
118
119 switch (pParamTypeDescr->eTypeClass)
120 {
121 case typelib_TypeClass_FLOAT:
122 case typelib_TypeClass_DOUBLE:
123 if (nregs < axp::MAX_WORDS_IN_REGS)
124 {
125 if (pParamTypeDescr->eTypeClass == typelib_TypeClass_FLOAT)
126 {
127 float tmp = (float) (*((double *)fpreg));
128 (*((float *) fpreg)) = tmp;
129 }
130
131 pCppArgs[nPos] = pUnoArgs[nPos] = fpreg;
132 gpreg++;
133 fpreg++;
134 nregs++;
135 }
136 else
137 {
138 pCppArgs[nPos] = pUnoArgs[nPos] = ovrflw;
139 ovrflw++;
140 }
141 break;
142 case typelib_TypeClass_BYTE:
143 case typelib_TypeClass_BOOLEAN:
144 if (nregs < axp::MAX_WORDS_IN_REGS)
145 {
146 pCppArgs[nPos] = pUnoArgs[nPos] = gpreg;
147 gpreg++;
148 fpreg++;
149 nregs++;
150 }
151 else
152 {
153 pCppArgs[nPos] = pUnoArgs[nPos] = ovrflw;
154 ovrflw++;
155 }
156 break;
157 case typelib_TypeClass_CHAR:
158 case typelib_TypeClass_SHORT:
159 case typelib_TypeClass_UNSIGNED_SHORT:
160 if (nregs < axp::MAX_WORDS_IN_REGS)
161 {
162 pCppArgs[nPos] = pUnoArgs[nPos] = gpreg;
163 gpreg++;
164 fpreg++;
165 nregs++;
166 }
167 else
168 {
169 pCppArgs[nPos] = pUnoArgs[nPos] = ovrflw;
170 ovrflw++;
171 }
172 break;
173 case typelib_TypeClass_ENUM:
174 case typelib_TypeClass_LONG:
175 case typelib_TypeClass_UNSIGNED_LONG:
176 if (nregs < axp::MAX_WORDS_IN_REGS)
177 {
178 pCppArgs[nPos] = pUnoArgs[nPos] = gpreg;
179 gpreg++;
180 fpreg++;
181 nregs++;
182 }
183 else
184 {
185 pCppArgs[nPos] = pUnoArgs[nPos] = ovrflw;
186 ovrflw++;
187 }
188 break;
189 default:
190 if (nregs < axp::MAX_WORDS_IN_REGS)
191 {
192 pCppArgs[nPos] = pUnoArgs[nPos] = gpreg;
193 gpreg++;
194 fpreg++;
195 nregs++;
196 }
197 else
198 {
199 pCppArgs[nPos] = pUnoArgs[nPos] = ovrflw;
200 ovrflw++;
201 }
202 break;
203 }
204
205 // no longer needed
206 TYPELIB_DANGER_RELEASE( pParamTypeDescr );
207 }
208 else // ptr to complex value | ref
209 {
210#if OSL_DEBUG_LEVEL > 2
211 fprintf(stderr, "complex, nregs is %d\n", nregs);
212#endif
213
214 void *pCppStack; //temporary stack pointer
215
216 if (nregs < axp::MAX_WORDS_IN_REGS)
217 {
218 pCppArgs[nPos] = pCppStack = *gpreg;
219 gpreg++;
220 fpreg++;
221 nregs++;
222 }
223 else
224 {
225 pCppArgs[nPos] = pCppStack = *ovrflw;
226 ovrflw++;
227 }
228
229 if (! rParam.bIn) // is pure out
230 {
231 // uno out is unconstructed mem!
232 pUnoArgs[nPos] = alloca( pParamTypeDescr->nSize );
233 pTempIndices[nTempIndices] = nPos;
234 // will be released at reconversion
235 ppTempParamTypeDescr[nTempIndices++] = pParamTypeDescr;
236 }
237 // is in/inout
238 else if (bridges::cpp_uno::shared::relatesToInterfaceType( pParamTypeDescr ))
239 {
240 uno_copyAndConvertData( pUnoArgs[nPos] = alloca( pParamTypeDescr->nSize ),
241 pCppStack, pParamTypeDescr,
242 pThis->getBridge()->getCpp2Uno() );
243 pTempIndices[nTempIndices] = nPos; // has to be reconverted
244 // will be released at reconversion
245 ppTempParamTypeDescr[nTempIndices++] = pParamTypeDescr;
246 }
247 else // direct way
248 {
249 pUnoArgs[nPos] = pCppStack;
250 // no longer needed
251 TYPELIB_DANGER_RELEASE( pParamTypeDescr );
252 }
253 }
254 }
255
256#if OSL_DEBUG_LEVEL > 2
257 fprintf(stderr, "end of params\n");
258#endif
259
260 // ExceptionHolder
261 uno_Any aUnoExc; // Any will be constructed by callee
262 uno_Any * pUnoExc = &aUnoExc;
263
264 // invoke uno dispatch call
265 (*pThis->getUnoI()->pDispatcher)( pThis->getUnoI(), pMemberTypeDescr, pUnoReturn, pUnoArgs, &pUnoExc );
266
267 // in case an exception occurred...
268 if (pUnoExc)
269 {
270 // destruct temporary in/inout params
271 for ( ; nTempIndices--; )
272 {
273 sal_Int32 nIndex = pTempIndices[nTempIndices];
274
275 if (pParams[nIndex].bIn) // is in/inout => was constructed
276 uno_destructData( pUnoArgs[nIndex], ppTempParamTypeDescr[nTempIndices], 0 );
277 TYPELIB_DANGER_RELEASE( ppTempParamTypeDescr[nTempIndices] );
278 }
279 if (pReturnTypeDescr)
280 TYPELIB_DANGER_RELEASE( pReturnTypeDescr );
281
282 CPPU_CURRENT_NAMESPACE::raiseException( &aUnoExc, pThis->getBridge()->getUno2Cpp() ); // has to destruct the any
283 // is here for dummy
284 return typelib_TypeClass_VOID;
285 }
286 else // else no exception occurred...
287 {
288 // temporary params
289 for ( ; nTempIndices--; )
290 {
291 sal_Int32 nIndex = pTempIndices[nTempIndices];
292 typelib_TypeDescription * pParamTypeDescr = ppTempParamTypeDescr[nTempIndices];
293
294 if (pParams[nIndex].bOut) // inout/out
295 {
296 // convert and assign
297 uno_destructData( pCppArgs[nIndex], pParamTypeDescr, cpp_release );
298 uno_copyAndConvertData( pCppArgs[nIndex], pUnoArgs[nIndex], pParamTypeDescr,
299 pThis->getBridge()->getUno2Cpp() );
300 }
301 // destroy temp uno param
302 uno_destructData( pUnoArgs[nIndex], pParamTypeDescr, 0 );
303
304 TYPELIB_DANGER_RELEASE( pParamTypeDescr );
305 }
306 // return
307 if (pCppReturn) // has complex return
308 {
309 if (pUnoReturn != pCppReturn) // needs reconversion
310 {
311 uno_copyAndConvertData( pCppReturn, pUnoReturn, pReturnTypeDescr,
312 pThis->getBridge()->getUno2Cpp() );
313 // destroy temp uno return
314 uno_destructData( pUnoReturn, pReturnTypeDescr, 0 );
315 }
316 // complex return ptr is set to return reg
317 *(void **)pRegisterReturn = pCppReturn;
318 }
319 if (pReturnTypeDescr)
320 {
321 typelib_TypeClass eRet = (typelib_TypeClass)pReturnTypeDescr->eTypeClass;
322 TYPELIB_DANGER_RELEASE( pReturnTypeDescr );
323 return eRet;
324 }
325 else
326 return typelib_TypeClass_VOID;
327 }
328}
329
330
331static typelib_TypeClass cpp_mediate(
332 sal_uInt64 nOffsetAndIndex,
333 void ** gpreg, void ** fpreg, void ** ovrflw,
334 sal_Int64 * pRegisterReturn /* space for register return */ )
335{
336 static_assert(sizeof(sal_Int64)==sizeof(void *), "### unexpected!");
337
338 sal_Int32 nVtableOffset = (nOffsetAndIndex >> 32);
339 sal_Int32 nFunctionIndex = (nOffsetAndIndex & 0xFFFFFFFF);
340
341#if OSL_DEBUG_LEVEL > 2
342 fprintf(stderr, "nVTableOffset, nFunctionIndex are %x %x\n", nVtableOffset, nFunctionIndex);
343#endif
344
345#if OSL_DEBUG_LEVEL > 2
346 // Let's figure out what is really going on here
347 {
348 fprintf( stderr, "= cpp_mediate () =\nGPR's (%d): ", 6 );
349 for ( unsigned int i = 0; i < 6; ++i )
350 fprintf( stderr, "0x%lx, ", gpreg[i] );
351 fprintf( stderr, "\n");
352 fprintf( stderr, "\nFPR's (%d): ", 6 );
353 for ( unsigned int i = 0; i < 6; ++i )
354 fprintf( stderr, "0x%lx (%f), ", fpreg[i], fpreg[i] );
355 fprintf( stderr, "\n");
356 }
357#endif
358
359
360 // gpreg: [ret *], this, [other gpr params]
361 // fpreg: [fpr params]
362 // ovrflw: [gpr or fpr params (properly aligned)]
363
364 // _this_ ptr is patched cppu_XInterfaceProxy object
365 void * pThis;
366 if( nFunctionIndex & 0x80000000 )
367 {
368 nFunctionIndex &= 0x7fffffff;
369 pThis = gpreg[1];
370 }
371 else
372 {
373 pThis = gpreg[0];
374 }
375
376 pThis = static_cast< char * >(pThis) - nVtableOffset;
377
380 pThis);
381
382 typelib_InterfaceTypeDescription * pTypeDescr = pCppI->getTypeDescr();
383
384
385 if (nFunctionIndex >= pTypeDescr->nMapFunctionIndexToMemberIndex)
386 {
387 SAL_WARN(
388 "bridges",
389 "illegal " << OUString::unacquired(&pTypeDescr->aBase.pTypeName)
390 << " vtable index " << nFunctionIndex << "/"
391 << pTypeDescr->nMapFunctionIndexToMemberIndex);
392 throw RuntimeException(
393 ("illegal " + OUString::unacquired(&pTypeDescr->aBase.pTypeName)
394 + " vtable index " + OUString::number(nFunctionIndex) + "/"
395 + OUString::number(pTypeDescr->nMapFunctionIndexToMemberIndex)),
396 (XInterface *)pCppI);
397 }
398
399 // determine called method
400 assert(nVtableCall < pTypeDescr->nMapFunctionIndexToMemberIndex);
401 sal_Int32 nMemberPos = pTypeDescr->pMapFunctionIndexToMemberIndex[nFunctionIndex];
402 assert(nMemberPos < pTypeDescr->nAllMembers);
403
404 TypeDescription aMemberDescr( pTypeDescr->ppAllMembers[nMemberPos] );
405
406 typelib_TypeClass eRet;
407 switch (aMemberDescr.get()->eTypeClass)
408 {
409 case typelib_TypeClass_INTERFACE_ATTRIBUTE:
410 {
411 if (pTypeDescr->pMapMemberIndexToFunctionIndex[nMemberPos] == nFunctionIndex)
412 {
413 // is GET method
414 eRet = cpp2uno_call(
415 pCppI, aMemberDescr.get(),
416 ((typelib_InterfaceAttributeTypeDescription *)aMemberDescr.get())->pAttributeTypeRef,
417 0, 0, // no params
418 gpreg, fpreg, ovrflw, pRegisterReturn );
419 }
420 else
421 {
422 // is SET method
423 typelib_MethodParameter aParam;
424 aParam.pTypeRef =
425 ((typelib_InterfaceAttributeTypeDescription *)aMemberDescr.get())->pAttributeTypeRef;
426 aParam.bIn = sal_True;
427 aParam.bOut = sal_False;
428
429 eRet = cpp2uno_call(
430 pCppI, aMemberDescr.get(),
431 0, // indicates void return
432 1, &aParam,
433 gpreg, fpreg, ovrflw, pRegisterReturn );
434 }
435 break;
436 }
437 case typelib_TypeClass_INTERFACE_METHOD:
438 {
439 // is METHOD
440 switch (nFunctionIndex)
441 {
442 case 1: // acquire()
443 pCppI->acquireProxy(); // non virtual call!
444 eRet = typelib_TypeClass_VOID;
445 break;
446 case 2: // release()
447 pCppI->releaseProxy(); // non virtual call!
448 eRet = typelib_TypeClass_VOID;
449 break;
450 case 0: // queryInterface() opt
451 {
452 typelib_TypeDescription * pTD = 0;
453 TYPELIB_DANGER_GET( &pTD, reinterpret_cast< Type * >( gpreg[2] )->getTypeLibType() );
454 if (pTD)
455 {
456 XInterface * pInterface = 0;
457 (*pCppI->getBridge()->getCppEnv()->getRegisteredInterface)(
458 pCppI->getBridge()->getCppEnv(),
459 (void **)&pInterface, pCppI->getOid().pData,
460 (typelib_InterfaceTypeDescription *)pTD );
461
462 if (pInterface)
463 {
464 ::uno_any_construct(
465 reinterpret_cast< uno_Any * >( gpreg[0] ),
466 &pInterface, pTD, cpp_acquire );
467 pInterface->release();
468 TYPELIB_DANGER_RELEASE( pTD );
469 *(void **)pRegisterReturn = gpreg[0];
470 eRet = typelib_TypeClass_ANY;
471 break;
472 }
473 TYPELIB_DANGER_RELEASE( pTD );
474 }
475 } // else perform queryInterface()
476 default:
477 eRet = cpp2uno_call(
478 pCppI, aMemberDescr.get(),
479 ((typelib_InterfaceMethodTypeDescription *)aMemberDescr.get())->pReturnTypeRef,
480 ((typelib_InterfaceMethodTypeDescription *)aMemberDescr.get())->nParams,
481 ((typelib_InterfaceMethodTypeDescription *)aMemberDescr.get())->pParams,
482 gpreg, fpreg, ovrflw, pRegisterReturn );
483 }
484 break;
485 }
486 default:
487 {
488 throw RuntimeException( "no member description found!", (XInterface *)pCppI );
489 }
490 }
491
492 return eRet;
493}
494
495long cpp_vtable_call(long r16, long r17, long r18, long r19, long r20, long r21, long firstonstack)
496{
497 register long r1 asm("$1");
498 sal_uInt64 nOffsetAndIndex = r1;
499
500 long sp = (long)&firstonstack;
501
502 sal_uInt64 gpreg[axp::MAX_GPR_REGS];
503 gpreg[0] = r16;
504 gpreg[1] = r17;
505 gpreg[2] = r18;
506 gpreg[3] = r19;
507 gpreg[4] = r20;
508 gpreg[5] = r21;
509
510 double fpreg[axp::MAX_SSE_REGS];
511 register double f16 asm("$f16"); fpreg[0] = f16;
512 register double f17 asm("$f17"); fpreg[1] = f17;
513 register double f18 asm("$f18"); fpreg[2] = f18;
514 register double f19 asm("$f19"); fpreg[3] = f19;
515 register double f20 asm("$f20"); fpreg[4] = f20;
516 register double f21 asm("$f21"); fpreg[5] = f21;
517
518 volatile long nRegReturn[1];
519#if OSL_DEBUG_LEVEL > 2
520 fprintf(stderr, "before mediate with %lx\n",nOffsetAndIndex);
521 fprintf(stderr, "non-doubles are %x %x %x %x %x %x\n", gpreg[0], gpreg[1], gpreg[2], gpreg[3], gpreg[4], gpreg[5]);
522 fprintf(stderr, "doubles are %f %f %f %f %f %f\n", fpreg[0], fpreg[1], fpreg[2], fpreg[3], fpreg[4], fpreg[5]);
523#endif
524 typelib_TypeClass aType =
525 cpp_mediate( nOffsetAndIndex, (void**)gpreg, (void**)fpreg, (void**)sp,
526 (sal_Int64*)nRegReturn );
527#if OSL_DEBUG_LEVEL > 2
528 fprintf(stderr, "after mediate ret is %lx %ld\n", nRegReturn[0], nRegReturn[0]);
529#endif
530
531 switch( aType )
532 {
533 case typelib_TypeClass_BOOLEAN:
534 case typelib_TypeClass_BYTE:
535 nRegReturn[0] = (unsigned long)(*(unsigned char *)nRegReturn);
536 break;
537 case typelib_TypeClass_CHAR:
538 case typelib_TypeClass_UNSIGNED_SHORT:
539 case typelib_TypeClass_SHORT:
540 nRegReturn[0] = (unsigned long)(*(unsigned short *)nRegReturn);
541 break;
542 case typelib_TypeClass_ENUM:
543 case typelib_TypeClass_UNSIGNED_LONG:
544 case typelib_TypeClass_LONG:
545 nRegReturn[0] = (unsigned long)(*(unsigned int *)nRegReturn);
546 break;
547 case typelib_TypeClass_VOID:
548 default:
549 break;
550 case typelib_TypeClass_FLOAT:
551 {
552 double tmp = (double) (*((float *)nRegReturn));
553 (*((double *) nRegReturn)) = tmp;
554 }
555 //deliberate fall through
556 case typelib_TypeClass_DOUBLE:
557 __asm__ ( "ldt $f0,%0\n\t"
558 : : "m" (*((double*)nRegReturn)) : "$f0");
559 break;
560 }
561 return nRegReturn[0];
562}
563
564const int codeSnippetSize = 32;
565
566unsigned char *codeSnippet( unsigned char * code, sal_Int32 nFunctionIndex, sal_Int32 nVtableOffset, bool simple_ret_type )
567{
568 if (! simple_ret_type)
569 nFunctionIndex |= 0x80000000;
570
571 unsigned char * p = code;
572 *(unsigned int*)&p[0] = 0x47fb0401; /* mov $27,$1 */
573 *(unsigned int*)&p[4] = 0xa43b0010; /* ldq $1,16($27) */
574 *(unsigned int*)&p[8] = 0xa77b0018; /* ldq $27,24($27) */
575 *(unsigned int*)&p[12] = 0x6bfb0000; /* jmp $31,($27),0 */
576 *(unsigned int*)&p[16] = nFunctionIndex;
577 *(unsigned int*)&p[20] = nVtableOffset;
578 *(unsigned long*)&p[24] = (unsigned long)cpp_vtable_call;
579 return (code + codeSnippetSize);
580}
581}
582
583void bridges::cpp_uno::shared::VtableFactory::flushCode(unsigned char const *, unsigned char const *)
584{
585 //http://www.gnu.org/software/lightning/manual/html_node/Standard-functions.html
586 __asm__ __volatile__("call_pal 0x86");
587}
588
590
593{
594 return static_cast< Slot * >(block) + 2;
595}
596
598 sal_Int32 slotCount)
599{
600 return (slotCount + 2) * sizeof (Slot) + slotCount * codeSnippetSize;
601}
602
603namespace {
604// Some dummy type whose RTTI is used in the synthesized proxy vtables to make uses of dynamic_cast
605// on such proxy objects not crash:
606struct ProxyRtti {};
607}
608
611 void * block, sal_Int32 slotCount, sal_Int32,
612 typelib_InterfaceTypeDescription *)
613{
614 Slot * slots = mapBlockToVtable(block);
615 slots[-2].fn = 0;
616 slots[-1].fn = &typeid(ProxyRtti);
617 return slots + slotCount;
618}
619
621 Slot ** slots, unsigned char * code, sal_PtrDiff writetoexecdiff,
622 typelib_InterfaceTypeDescription const * type, sal_Int32 functionOffset,
623 sal_Int32 functionCount, sal_Int32 vtableOffset)
624{
625 (*slots) -= functionCount;
626 Slot * s = *slots;
627#if OSL_DEBUG_LEVEL > 2
628 fprintf(stderr, "in addLocalFunctions functionOffset is %x\n",functionOffset);
629 fprintf(stderr, "in addLocalFunctions vtableOffset is %x\n",vtableOffset);
630#endif
631
632 for (sal_Int32 i = 0; i < type->nMembers; ++i) {
633 typelib_TypeDescription * member = 0;
634 TYPELIB_DANGER_GET(&member, type->ppMembers[i]);
635 assert(member != 0);
636 switch (member->eTypeClass) {
637 case typelib_TypeClass_INTERFACE_ATTRIBUTE:
638 // Getter:
639 (s++)->fn = code + writetoexecdiff;
641 code, functionOffset++, vtableOffset,
643 reinterpret_cast<
644 typelib_InterfaceAttributeTypeDescription * >(
645 member)->pAttributeTypeRef));
646
647 // Setter:
648 if (!reinterpret_cast<
649 typelib_InterfaceAttributeTypeDescription * >(
650 member)->bReadOnly)
651 {
652 (s++)->fn = code + writetoexecdiff;
653 code = codeSnippet(code, functionOffset++, vtableOffset, true);
654 }
655 break;
656
657 case typelib_TypeClass_INTERFACE_METHOD:
658 (s++)->fn = code + writetoexecdiff;
660 code, functionOffset++, vtableOffset,
662 reinterpret_cast<
663 typelib_InterfaceMethodTypeDescription * >(
664 member)->pReturnTypeRef));
665 break;
666
667 default:
668 assert(false);
669 break;
670 }
671 TYPELIB_DANGER_RELEASE(member);
672 }
673 return code;
674}
675
676/* 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 cpp_vtable_call(sal_Int32 func, sal_Int32 offset, void **pStack)
is called on incoming vtable calls (called by asm snippets)
register sal_uInt32 r28 __asm__("%r28")
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
void * p
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
sal_Unicode code
#define sal_True
#define sal_False
ResultType type