1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #include <com/sun/star/uno/genfunc.hxx>
22 #include <sal/log.hxx>
24 #include <typelib/typedescription.hxx>
25 #include <osl/endian.h>
27 #include "cppinterfaceproxy.hxx"
29 #include "vtablefactory.hxx"
37 #define IS_BIG_ENDIAN 1
39 #define IS_BIG_ENDIAN 0
42 using namespace ::com::sun::star::uno
;
48 static typelib_TypeClass
cpp2uno_call(
49 bridges::cpp_uno::shared::CppInterfaceProxy
* pThis
,
50 const typelib_TypeDescription
* pMemberTypeDescr
,
51 typelib_TypeDescriptionReference
* pReturnTypeRef
, // 0 indicates void return
52 sal_Int32 nParams
, typelib_MethodParameter
* pParams
,
53 void ** gpreg
, void ** fpreg
, void ** ovrflw
,
54 sal_Int64
* pRegisterReturn
/* space for register return */ )
56 #if OSL_DEBUG_LEVEL > 2
57 fprintf(stderr
, "as far as cpp2uno_call\n");
60 int ng
= 0; //number of gpr registers used
61 int nf
= 0; //number of fpr registers used
63 // gpreg: [ret *], this, [gpr params]
64 // fpreg: [fpr params]
65 // ovrflw: [gpr or fpr params (properly aligned)]
68 typelib_TypeDescription
* pReturnTypeDescr
= 0;
70 TYPELIB_DANGER_GET( &pReturnTypeDescr
, pReturnTypeRef
);
72 void * pUnoReturn
= 0;
73 void * pCppReturn
= 0; // complex return ptr: if != 0 && != pUnoReturn, reconversion need
77 if (!ppc64::return_in_hidden_param(pReturnTypeRef
))
79 pUnoReturn
= pRegisterReturn
; // direct way for simple types
81 else // complex return via ptr (pCppReturn)
83 pCppReturn
= *(void **)gpreg
;
87 pUnoReturn
= (bridges::cpp_uno::shared::relatesToInterfaceType( pReturnTypeDescr
)
88 ? alloca( pReturnTypeDescr
->nSize
)
89 : pCppReturn
); // direct way
97 static_assert(sizeof(void *) == sizeof(sal_Int64
), "### unexpected size!");
99 void ** pUnoArgs
= (void **)alloca( 4 * sizeof(void *) * nParams
);
100 void ** pCppArgs
= pUnoArgs
+ nParams
;
101 // indices of values this have to be converted (interface conversion cpp<=>uno)
102 sal_Int32
* pTempIndices
= (sal_Int32
*)(pUnoArgs
+ (2 * nParams
));
103 // type descriptions for reconversions
104 typelib_TypeDescription
** ppTempParamTypeDescr
= (typelib_TypeDescription
**)(pUnoArgs
+ (3 * nParams
));
106 sal_Int32 nTempIndices
= 0;
107 bool bOverflowUsed
= false;
108 for ( sal_Int32 nPos
= 0; nPos
< nParams
; ++nPos
)
110 const typelib_MethodParameter
& rParam
= pParams
[nPos
];
111 typelib_TypeDescription
* pParamTypeDescr
= 0;
112 TYPELIB_DANGER_GET( &pParamTypeDescr
, rParam
.pTypeRef
);
114 #if OSL_DEBUG_LEVEL > 2
115 fprintf(stderr
, "arg %d of %d\n", nPos
, nParams
);
118 if (!rParam
.bOut
&& bridges::cpp_uno::shared::isSimpleType( pParamTypeDescr
))
120 #if OSL_DEBUG_LEVEL > 2
121 fprintf(stderr
, "simple\n");
124 switch (pParamTypeDescr
->eTypeClass
)
126 case typelib_TypeClass_FLOAT
:
127 case typelib_TypeClass_DOUBLE
:
128 if (nf
< ppc64::MAX_SSE_REGS
)
130 if (pParamTypeDescr
->eTypeClass
== typelib_TypeClass_FLOAT
)
132 float tmp
= (float) (*((double *)fpreg
));
133 (*((float *) fpreg
)) = tmp
;
135 pCppArgs
[nPos
] = pUnoArgs
[nPos
] = fpreg
++;
138 if (ng
< ppc64::MAX_GPR_REGS
)
146 pCppArgs
[nPos
] = pUnoArgs
[nPos
] = ovrflw
;
147 bOverflowUsed
= true;
149 if (bOverflowUsed
) ovrflw
++;
151 case typelib_TypeClass_BYTE
:
152 case typelib_TypeClass_BOOLEAN
:
153 if (ng
< ppc64::MAX_GPR_REGS
)
155 pCppArgs
[nPos
] = pUnoArgs
[nPos
] = (((char *)gpreg
) + 7*IS_BIG_ENDIAN
);
161 pCppArgs
[nPos
] = pUnoArgs
[nPos
] = (((char *)ovrflw
) + 7*IS_BIG_ENDIAN
);
162 bOverflowUsed
= true;
164 if (bOverflowUsed
) ovrflw
++;
166 case typelib_TypeClass_CHAR
:
167 case typelib_TypeClass_SHORT
:
168 case typelib_TypeClass_UNSIGNED_SHORT
:
169 if (ng
< ppc64::MAX_GPR_REGS
)
171 pCppArgs
[nPos
] = pUnoArgs
[nPos
] = (((char *)gpreg
) + 6*IS_BIG_ENDIAN
);
177 pCppArgs
[nPos
] = pUnoArgs
[nPos
] = (((char *)ovrflw
) + 6*IS_BIG_ENDIAN
);
178 bOverflowUsed
= true;
180 if (bOverflowUsed
) ovrflw
++;
182 case typelib_TypeClass_ENUM
:
183 case typelib_TypeClass_LONG
:
184 case typelib_TypeClass_UNSIGNED_LONG
:
185 if (ng
< ppc64::MAX_GPR_REGS
)
187 pCppArgs
[nPos
] = pUnoArgs
[nPos
] = (((char *)gpreg
) + 4*IS_BIG_ENDIAN
);
193 pCppArgs
[nPos
] = pUnoArgs
[nPos
] = (((char *)ovrflw
) + 4*IS_BIG_ENDIAN
);
194 bOverflowUsed
= true;
196 if (bOverflowUsed
) ovrflw
++;
199 if (ng
< ppc64::MAX_GPR_REGS
)
201 pCppArgs
[nPos
] = pUnoArgs
[nPos
] = gpreg
++;
206 pCppArgs
[nPos
] = pUnoArgs
[nPos
] = ovrflw
;
207 bOverflowUsed
= true;
209 if (bOverflowUsed
) ovrflw
++;
214 TYPELIB_DANGER_RELEASE( pParamTypeDescr
);
216 else // ptr to complex value | ref
218 #if OSL_DEBUG_LEVEL > 2
219 fprintf(stderr
, "complex, ng is %d\n", ng
);
221 void *pCppStack
; //temporary stack pointer
223 if (ng
< ppc64::MAX_GPR_REGS
)
225 pCppArgs
[nPos
] = pCppStack
= *gpreg
++;
230 pCppArgs
[nPos
] = pCppStack
= *ovrflw
;
231 bOverflowUsed
= true;
233 if (bOverflowUsed
) ovrflw
++;
235 if (! rParam
.bIn
) // is pure out
237 // uno out is unconstructed mem!
238 pUnoArgs
[nPos
] = alloca( pParamTypeDescr
->nSize
);
239 pTempIndices
[nTempIndices
] = nPos
;
240 // will be released at reconversion
241 ppTempParamTypeDescr
[nTempIndices
++] = pParamTypeDescr
;
244 else if (bridges::cpp_uno::shared::relatesToInterfaceType( pParamTypeDescr
))
246 uno_copyAndConvertData( pUnoArgs
[nPos
] = alloca( pParamTypeDescr
->nSize
),
247 pCppStack
, pParamTypeDescr
,
248 pThis
->getBridge()->getCpp2Uno() );
249 pTempIndices
[nTempIndices
] = nPos
; // has to be reconverted
250 // will be released at reconversion
251 ppTempParamTypeDescr
[nTempIndices
++] = pParamTypeDescr
;
255 pUnoArgs
[nPos
] = pCppStack
;
257 TYPELIB_DANGER_RELEASE( pParamTypeDescr
);
262 #if OSL_DEBUG_LEVEL > 2
263 fprintf(stderr
, "end of params\n");
267 uno_Any aUnoExc
; // Any will be constructed by callee
268 uno_Any
* pUnoExc
= &aUnoExc
;
270 // invoke uno dispatch call
271 (*pThis
->getUnoI()->pDispatcher
)( pThis
->getUnoI(), pMemberTypeDescr
, pUnoReturn
, pUnoArgs
, &pUnoExc
);
273 // in case an exception occurred...
276 // destruct temporary in/inout params
277 for ( ; nTempIndices
--; )
279 sal_Int32 nIndex
= pTempIndices
[nTempIndices
];
281 if (pParams
[nIndex
].bIn
) // is in/inout => was constructed
282 uno_destructData( pUnoArgs
[nIndex
], ppTempParamTypeDescr
[nTempIndices
], 0 );
283 TYPELIB_DANGER_RELEASE( ppTempParamTypeDescr
[nTempIndices
] );
285 if (pReturnTypeDescr
)
286 TYPELIB_DANGER_RELEASE( pReturnTypeDescr
);
288 CPPU_CURRENT_NAMESPACE::raiseException( &aUnoExc
, pThis
->getBridge()->getUno2Cpp() );
289 // has to destruct the any
291 return typelib_TypeClass_VOID
;
293 else // else no exception occurred...
296 for ( ; nTempIndices
--; )
298 sal_Int32 nIndex
= pTempIndices
[nTempIndices
];
299 typelib_TypeDescription
* pParamTypeDescr
= ppTempParamTypeDescr
[nTempIndices
];
301 if (pParams
[nIndex
].bOut
) // inout/out
303 // convert and assign
304 uno_destructData( pCppArgs
[nIndex
], pParamTypeDescr
, cpp_release
);
305 uno_copyAndConvertData( pCppArgs
[nIndex
], pUnoArgs
[nIndex
], pParamTypeDescr
,
306 pThis
->getBridge()->getUno2Cpp() );
308 // destroy temp uno param
309 uno_destructData( pUnoArgs
[nIndex
], pParamTypeDescr
, 0 );
311 TYPELIB_DANGER_RELEASE( pParamTypeDescr
);
314 if (pCppReturn
) // has complex return
316 if (pUnoReturn
!= pCppReturn
) // needs reconversion
318 uno_copyAndConvertData( pCppReturn
, pUnoReturn
, pReturnTypeDescr
,
319 pThis
->getBridge()->getUno2Cpp() );
320 // destroy temp uno return
321 uno_destructData( pUnoReturn
, pReturnTypeDescr
, 0 );
323 // complex return ptr is set to return reg
324 *(void **)pRegisterReturn
= pCppReturn
;
326 if (pReturnTypeDescr
)
328 typelib_TypeClass eRet
= (typelib_TypeClass
)pReturnTypeDescr
->eTypeClass
;
329 TYPELIB_DANGER_RELEASE( pReturnTypeDescr
);
333 return typelib_TypeClass_VOID
;
337 #if defined(_CALL_ELF) && _CALL_ELF == 2
338 # define PARAMSAVE 32
340 # define PARAMSAVE 48
343 static typelib_TypeClass
cpp_mediate(
344 sal_uInt64 nOffsetAndIndex
,
345 void ** gpreg
, void ** fpreg
, long sp
,
346 sal_Int64
* pRegisterReturn
/* space for register return */ )
348 static_assert(sizeof(sal_Int64
)==sizeof(void *), "### unexpected!");
350 sal_Int32 nVtableOffset
= (nOffsetAndIndex
>> 32);
351 sal_Int32 nFunctionIndex
= (nOffsetAndIndex
& 0xFFFFFFFF);
353 long sf
= *(long*)sp
;
354 void ** ovrflw
= (void**)(sf
+ PARAMSAVE
+ 64);
356 // gpreg: [ret *], this, [other gpr params]
357 // fpreg: [fpr params]
358 // ovrflw: [gpr or fpr params (properly aligned)]
361 if (nFunctionIndex
& 0x80000000 )
363 nFunctionIndex
&= 0x7fffffff;
365 #if OSL_DEBUG_LEVEL > 2
366 fprintf(stderr
, "pThis is gpreg[1]\n");
372 #if OSL_DEBUG_LEVEL > 2
373 fprintf(stderr
, "pThis is gpreg[0]\n");
377 #if OSL_DEBUG_LEVEL > 2
378 fprintf(stderr
, "pThis is %lx\n", pThis
);
381 pThis
= static_cast< char * >(pThis
) - nVtableOffset
;
383 #if OSL_DEBUG_LEVEL > 2
384 fprintf(stderr
, "pThis is now %lx\n", pThis
);
387 bridges::cpp_uno::shared::CppInterfaceProxy
* pCppI
388 = bridges::cpp_uno::shared::CppInterfaceProxy::castInterfaceToProxy(
391 typelib_InterfaceTypeDescription
* pTypeDescr
= pCppI
->getTypeDescr();
393 #if OSL_DEBUG_LEVEL > 2
394 fprintf(stderr
, "indexes are %d %d\n", nFunctionIndex
, pTypeDescr
->nMapFunctionIndexToMemberIndex
);
397 if (nFunctionIndex
>= pTypeDescr
->nMapFunctionIndexToMemberIndex
)
401 "illegal " << OUString::unacquired(&pTypeDescr
->aBase
.pTypeName
)
402 << " vtable index " << nFunctionIndex
<< "/"
403 << pTypeDescr
->nMapFunctionIndexToMemberIndex
);
404 throw RuntimeException(
405 ("illegal " + OUString::unacquired(&pTypeDescr
->aBase
.pTypeName
)
406 + " vtable index " + OUString::number(nFunctionIndex
) + "/"
407 + OUString::number(pTypeDescr
->nMapFunctionIndexToMemberIndex
)),
408 (XInterface
*)pThis
);
411 // determine called method
412 sal_Int32 nMemberPos
= pTypeDescr
->pMapFunctionIndexToMemberIndex
[nFunctionIndex
];
413 assert(nMemberPos
< pTypeDescr
->nAllMembers
);
415 #if OSL_DEBUG_LEVEL > 2
416 fprintf(stderr
, "members are %d %d\n", nMemberPos
, pTypeDescr
->nAllMembers
);
419 TypeDescription
aMemberDescr( pTypeDescr
->ppAllMembers
[nMemberPos
] );
421 typelib_TypeClass eRet
;
422 switch (aMemberDescr
.get()->eTypeClass
)
424 case typelib_TypeClass_INTERFACE_ATTRIBUTE
:
426 if (pTypeDescr
->pMapMemberIndexToFunctionIndex
[nMemberPos
] == nFunctionIndex
)
430 pCppI
, aMemberDescr
.get(),
431 ((typelib_InterfaceAttributeTypeDescription
*)aMemberDescr
.get())->pAttributeTypeRef
,
433 gpreg
, fpreg
, ovrflw
, pRegisterReturn
);
438 typelib_MethodParameter aParam
;
440 ((typelib_InterfaceAttributeTypeDescription
*)aMemberDescr
.get())->pAttributeTypeRef
;
441 aParam
.bIn
= sal_True
;
442 aParam
.bOut
= sal_False
;
445 pCppI
, aMemberDescr
.get(),
446 0, // indicates void return
448 gpreg
, fpreg
, ovrflw
, pRegisterReturn
);
452 case typelib_TypeClass_INTERFACE_METHOD
:
455 switch (nFunctionIndex
)
458 pCppI
->acquireProxy(); // non virtual call!
459 eRet
= typelib_TypeClass_VOID
;
462 pCppI
->releaseProxy(); // non virtual call!
463 eRet
= typelib_TypeClass_VOID
;
465 case 0: // queryInterface() opt
467 typelib_TypeDescription
* pTD
= 0;
468 TYPELIB_DANGER_GET( &pTD
, reinterpret_cast< Type
* >( gpreg
[2] )->getTypeLibType() );
471 XInterface
* pInterface
= 0;
472 (*pCppI
->getBridge()->getCppEnv()->getRegisteredInterface
)(
473 pCppI
->getBridge()->getCppEnv(),
474 (void **)&pInterface
, pCppI
->getOid().pData
,
475 (typelib_InterfaceTypeDescription
*)pTD
);
480 reinterpret_cast< uno_Any
* >( gpreg
[0] ),
481 &pInterface
, pTD
, cpp_acquire
);
482 pInterface
->release();
483 TYPELIB_DANGER_RELEASE( pTD
);
484 *(void **)pRegisterReturn
= gpreg
[0];
485 eRet
= typelib_TypeClass_ANY
;
488 TYPELIB_DANGER_RELEASE( pTD
);
490 } // else perform queryInterface()
493 pCppI
, aMemberDescr
.get(),
494 ((typelib_InterfaceMethodTypeDescription
*)aMemberDescr
.get())->pReturnTypeRef
,
495 ((typelib_InterfaceMethodTypeDescription
*)aMemberDescr
.get())->nParams
,
496 ((typelib_InterfaceMethodTypeDescription
*)aMemberDescr
.get())->pParams
,
497 gpreg
, fpreg
, ovrflw
, pRegisterReturn
);
503 #if OSL_DEBUG_LEVEL > 2
504 fprintf(stderr
, "screwed\n");
507 throw RuntimeException( "no member description found!", (XInterface
*)pThis
);
511 #if OSL_DEBUG_LEVEL > 2
512 fprintf(stderr
, "end of cpp_mediate\n");
517 extern "C" void privateSnippetExecutor( ... )
519 sal_uInt64 gpreg
[ppc64::MAX_GPR_REGS
];
521 register long r3
asm("r3"); gpreg
[0] = r3
;
522 register long r4
asm("r4"); gpreg
[1] = r4
;
523 register long r5
asm("r5"); gpreg
[2] = r5
;
524 register long r6
asm("r6"); gpreg
[3] = r6
;
525 register long r7
asm("r7"); gpreg
[4] = r7
;
526 register long r8
asm("r8"); gpreg
[5] = r8
;
527 register long r9
asm("r9"); gpreg
[6] = r9
;
528 register long r10
asm("r10"); gpreg
[7] = r10
;
530 double fpreg
[ppc64::MAX_SSE_REGS
];
532 __asm__
__volatile__ (
542 "stfd 10, 72(%0)\t\n"
543 "stfd 11, 80(%0)\t\n"
544 "stfd 12, 88(%0)\t\n"
545 "stfd 13, 96(%0)\t\n"
547 : "fr1", "fr2", "fr3", "fr4", "fr5", "fr6", "fr7", "fr8", "fr9",
548 "fr10", "fr11", "fr12", "fr13"
551 register long r11
asm("r11");
552 const long nOffsetAndIndex
= r11
;
554 register long r1
asm("r1");
557 #if defined(_CALL_ELF) && _CALL_ELF == 2
558 volatile long nRegReturn
[2];
560 volatile long nRegReturn
[1];
563 typelib_TypeClass aType
=
564 cpp_mediate( nOffsetAndIndex
, (void**)gpreg
, (void**)fpreg
, sp
, (sal_Int64
*)nRegReturn
);
568 case typelib_TypeClass_VOID
:
570 case typelib_TypeClass_BOOLEAN
:
571 case typelib_TypeClass_BYTE
:
572 __asm__( "lbz 3,%0\n\t"
573 : : "m" (nRegReturn
[0]) );
575 case typelib_TypeClass_CHAR
:
576 case typelib_TypeClass_UNSIGNED_SHORT
:
577 __asm__( "lhz 3,%0\n\t"
578 : : "m" (nRegReturn
[0]) );
580 case typelib_TypeClass_SHORT
:
581 __asm__( "lha 3,%0\n\t"
582 : : "m" (nRegReturn
[0]) );
584 case typelib_TypeClass_ENUM
:
585 case typelib_TypeClass_UNSIGNED_LONG
:
586 __asm__( "lwz 3,%0\n\t"
587 : : "m"(nRegReturn
[0]) );
589 case typelib_TypeClass_LONG
:
590 __asm__( "lwa 3,%0\n\t"
591 : : "m"(nRegReturn
[0]) );
593 case typelib_TypeClass_FLOAT
:
594 __asm__( "lfs 1,%0\n\t"
595 : : "m" (*((float*)nRegReturn
)) );
597 case typelib_TypeClass_DOUBLE
:
598 __asm__( "lfd 1,%0\n\t"
599 : : "m" (*((double*)nRegReturn
)) );
602 __asm__( "ld 3,%0\n\t"
603 : : "m" (nRegReturn
[0]) );
604 #if defined(_CALL_ELF) && _CALL_ELF == 2
605 __asm__( "ld 4,%0\n\t"
606 : : "m" (nRegReturn
[1]) );
612 #if defined(_CALL_ELF) && _CALL_ELF == 2
613 const int codeSnippetSize
= 32;
615 const int codeSnippetSize
= 24;
618 unsigned char * codeSnippet( unsigned char * code
, sal_Int32 nFunctionIndex
, sal_Int32 nVtableOffset
,
619 bool bHasHiddenParam
)
621 #if OSL_DEBUG_LEVEL > 2
622 fprintf(stderr
,"in codeSnippet functionIndex is %x\n", nFunctionIndex
);
623 fprintf(stderr
,"in codeSnippet vtableOffset is %x\n", nVtableOffset
);
626 sal_uInt64 nOffsetAndIndex
= ( ( (sal_uInt64
) nVtableOffset
) << 32 ) | ( (sal_uInt64
) nFunctionIndex
);
628 if ( bHasHiddenParam
)
629 nOffsetAndIndex
|= 0x80000000;
630 #if defined(_CALL_ELF) && _CALL_ELF == 2
631 unsigned int *raw
= (unsigned int *)&code
[0];
633 raw
[0] = 0xe96c0018; /* 0: ld 11,2f-0b(12) */
634 raw
[1] = 0xe98c0010; /* ld 12,1f-0b(12) */
635 raw
[2] = 0x7d8903a6; /* mtctr 12 */
636 raw
[3] = 0x4e800420; /* bctr */
637 /* 1: .quad function_addr */
638 /* 2: .quad context */
639 *(void **)&raw
[4] = (void *)privateSnippetExecutor
;
640 *(void **)&raw
[6] = (void*)nOffsetAndIndex
;
642 void ** raw
= (void **)&code
[0];
643 memcpy(raw
, (char*) privateSnippetExecutor
, 16);
644 raw
[2] = (void*) nOffsetAndIndex
;
646 #if OSL_DEBUG_LEVEL > 2
647 fprintf(stderr
, "in: offset/index is %x %x %d, %lx\n",
648 nFunctionIndex
, nVtableOffset
, bHasHiddenParam
, raw
[2]);
650 return (code
+ codeSnippetSize
);
655 void bridges::cpp_uno::shared::VtableFactory::flushCode(unsigned char const * bptr
, unsigned char const * eptr
)
657 int const lineSize
= 32;
658 for (unsigned char const * p
= bptr
; p
< eptr
+ lineSize
; p
+= lineSize
) {
659 __asm__
volatile ("dcbst 0, %0" : : "r"(p
) : "memory");
661 __asm__
volatile ("sync" : : : "memory");
662 for (unsigned char const * p
= bptr
; p
< eptr
+ lineSize
; p
+= lineSize
) {
663 __asm__
volatile ("icbi 0, %0" : : "r"(p
) : "memory");
665 __asm__
volatile ("isync" : : : "memory");
668 struct bridges::cpp_uno::shared::VtableFactory::Slot
{ void const * fn
; };
670 bridges::cpp_uno::shared::VtableFactory::Slot
*
671 bridges::cpp_uno::shared::VtableFactory::mapBlockToVtable(void * block
)
673 return static_cast< Slot
* >(block
) + 2;
676 std::size_t bridges::cpp_uno::shared::VtableFactory::getBlockSize(
679 return (slotCount
+ 2) * sizeof (Slot
) + slotCount
* codeSnippetSize
;
683 // Some dummy type whose RTTI is used in the synthesized proxy vtables to make uses of dynamic_cast
684 // on such proxy objects not crash:
688 bridges::cpp_uno::shared::VtableFactory::Slot
*
689 bridges::cpp_uno::shared::VtableFactory::initializeBlock(
690 void * block
, sal_Int32 slotCount
, sal_Int32
,
691 typelib_InterfaceTypeDescription
*)
693 Slot
* slots
= mapBlockToVtable(block
);
695 slots
[-1].fn
= &typeid(ProxyRtti
);
696 return slots
+ slotCount
;
699 unsigned char * bridges::cpp_uno::shared::VtableFactory::addLocalFunctions(
700 Slot
** slots
, unsigned char * code
, sal_PtrDiff writetoexecdiff
,
701 typelib_InterfaceTypeDescription
const * type
, sal_Int32 functionOffset
,
702 sal_Int32 functionCount
, sal_Int32 vtableOffset
)
704 (*slots
) -= functionCount
;
706 #if OSL_DEBUG_LEVEL > 2
707 fprintf(stderr
, "in addLocalFunctions functionOffset is %x\n",functionOffset
);
708 fprintf(stderr
, "in addLocalFunctions vtableOffset is %x\n",vtableOffset
);
711 for (sal_Int32 i
= 0; i
< type
->nMembers
; ++i
) {
712 typelib_TypeDescription
* member
= 0;
713 TYPELIB_DANGER_GET(&member
, type
->ppMembers
[i
]);
715 switch (member
->eTypeClass
) {
716 case typelib_TypeClass_INTERFACE_ATTRIBUTE
:
718 (s
++)->fn
= code
+ writetoexecdiff
;
720 code
, functionOffset
++, vtableOffset
,
721 ppc64::return_in_hidden_param(
723 typelib_InterfaceAttributeTypeDescription
* >(
724 member
)->pAttributeTypeRef
));
727 if (!reinterpret_cast<
728 typelib_InterfaceAttributeTypeDescription
* >(
731 (s
++)->fn
= code
+ writetoexecdiff
;
732 code
= codeSnippet(code
, functionOffset
++, vtableOffset
, false);
736 case typelib_TypeClass_INTERFACE_METHOD
:
737 (s
++)->fn
= code
+ writetoexecdiff
;
739 code
, functionOffset
++, vtableOffset
,
740 ppc64::return_in_hidden_param(
742 typelib_InterfaceMethodTypeDescription
* >(
743 member
)->pReturnTypeRef
));
750 TYPELIB_DANGER_RELEASE(member
);
755 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */