cid#1640468 Dereference after null check
[LibreOffice.git] / bridges / source / cpp_uno / gcc3_linux_ia64 / cpp2uno.cxx
blob0d8303861c28853db68e78e395ada958012d3b3a
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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>
23 #include <uno/data.h>
24 #include <typelib/typedescription.hxx>
26 #include "bridge.hxx"
27 #include "cppinterfaceproxy.hxx"
28 #include "types.hxx"
29 #include "vtablefactory.hxx"
31 #include "share.hxx"
32 #include <stdio.h>
33 #include <typeinfo>
35 extern "C" { extern void (*privateSnippetExecutor)(); }
37 using namespace ::com::sun::star::uno;
39 namespace
42 static typelib_TypeClass cpp2uno_call(
43 bridges::cpp_uno::shared::CppInterfaceProxy * pThis,
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 */ )
50 #if OSL_DEBUG_LEVEL > 2
51 fprintf(stderr, "as far as cpp2uno_call\n");
52 #endif
54 int ng = 0; //number of gpr registers used
55 int nf = 0; //number of fpr registers used
57 // gpreg: [ret *], this, [gpr params]
58 // fpreg: [fpr params]
59 // ovrflw: [gpr or fpr params (properly aligned)]
61 // return
62 typelib_TypeDescription * pReturnTypeDescr = 0;
63 if (pReturnTypeRef)
64 TYPELIB_DANGER_GET( &pReturnTypeDescr, pReturnTypeRef );
66 void * pUnoReturn = 0;
67 void * pCppReturn = 0; // complex return ptr: if != 0 && != pUnoReturn, reconversion need
69 if (pReturnTypeDescr)
71 if ( ia64::return_in_hidden_param( pReturnTypeRef ) ) // complex return via ptr passed as hidden parameter reg (pCppReturn)
73 pCppReturn = *(void **)gpreg;
74 gpreg++;
75 ng++;
77 pUnoReturn = (bridges::cpp_uno::shared::relatesToInterfaceType( pReturnTypeDescr )
78 ? alloca( pReturnTypeDescr->nSize )
79 : pCppReturn); // direct way
81 else if ( ia64::return_via_r8_buffer( pReturnTypeRef ) ) // complex return via ptr passed in r8
83 pCppReturn = (void *)r8;
85 pUnoReturn = (bridges::cpp_uno::shared::relatesToInterfaceType( pReturnTypeDescr )
86 ? alloca( pReturnTypeDescr->nSize )
87 : pCppReturn); // direct way
90 else
91 pUnoReturn = pRegisterReturn; // direct way for simple types
93 // pop this
94 gpreg++;
95 ng++;
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));
107 sal_Int32 nTempIndices = 0;
108 bool bOverflowUsed = false;
109 for ( sal_Int32 nPos = 0; nPos < nParams; ++nPos )
111 const typelib_MethodParameter & rParam = pParams[nPos];
112 typelib_TypeDescription * pParamTypeDescr = 0;
113 TYPELIB_DANGER_GET( &pParamTypeDescr, rParam.pTypeRef );
115 #if OSL_DEBUG_LEVEL > 2
116 fprintf(stderr, "arg %d of %d\n", nPos, nParams);
117 #endif
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 ))
122 #if OSL_DEBUG_LEVEL > 2
123 fprintf(stderr, "simple\n");
124 #endif
126 switch (pParamTypeDescr->eTypeClass)
128 case typelib_TypeClass_FLOAT:
129 if (nf < ia64::MAX_SSE_REGS && ng < ia64::MAX_GPR_REGS)
131 float tmp = (float) (*((double *)fpreg));
132 (*((float *) fpreg)) = tmp;
133 pCppArgs[nPos] = pUnoArgs[nPos] = fpreg++;
134 nf++;
135 gpreg++;
136 ng++;
138 else
140 pCppArgs[nPos] = pUnoArgs[nPos] = ovrflw;
141 bOverflowUsed = true;
143 if (bOverflowUsed) ovrflw++;
144 break;
145 case typelib_TypeClass_DOUBLE:
146 if (nf < ia64::MAX_SSE_REGS && ng < ia64::MAX_GPR_REGS)
148 pCppArgs[nPos] = pUnoArgs[nPos] = fpreg++;
149 nf++;
150 gpreg++;
151 ng++;
153 else
155 pCppArgs[nPos] = pUnoArgs[nPos] = ovrflw;
156 bOverflowUsed = true;
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)
171 pCppArgs[nPos] = pUnoArgs[nPos] = gpreg++;
172 ng++;
174 else
176 pCppArgs[nPos] = pUnoArgs[nPos] = ovrflw;
177 bOverflowUsed = true;
179 if (bOverflowUsed) ovrflw++;
180 break;
183 // no longer needed
184 TYPELIB_DANGER_RELEASE( pParamTypeDescr );
186 else // ptr to complex value | ref
188 #if OSL_DEBUG_LEVEL > 2
189 fprintf(stderr, "complex, ng is %d\n", ng);
190 #endif
191 void *pCppStack; //temporary stack pointer
193 if (ng < ia64::MAX_GPR_REGS)
195 pCppArgs[nPos] = pCppStack = *gpreg++;
196 ng++;
198 else
200 pCppArgs[nPos] = pCppStack = *ovrflw;
201 bOverflowUsed = true;
203 if (bOverflowUsed) ovrflw++;
205 if (! rParam.bIn) // is pure out
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;
213 // is in/inout
214 else if (bridges::cpp_uno::shared::relatesToInterfaceType( pParamTypeDescr ))
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;
223 else // direct way
225 pUnoArgs[nPos] = pCppStack;
226 // no longer needed
227 TYPELIB_DANGER_RELEASE( pParamTypeDescr );
232 #if OSL_DEBUG_LEVEL > 2
233 fprintf(stderr, "end of params\n");
234 #endif
236 // ExceptionHolder
237 uno_Any aUnoExc; // Any will be constructed by callee
238 uno_Any * pUnoExc = &aUnoExc;
240 // invoke uno dispatch call
241 (*pThis->getUnoI()->pDispatcher)( pThis->getUnoI(), pMemberTypeDescr, pUnoReturn, pUnoArgs, &pUnoExc );
243 // in case an exception occurred...
244 if (pUnoExc)
246 // destruct temporary in/inout params
247 for ( ; nTempIndices--; )
249 sal_Int32 nIndex = pTempIndices[nTempIndices];
251 if (pParams[nIndex].bIn) // is in/inout => was constructed
252 uno_destructData( pUnoArgs[nIndex], ppTempParamTypeDescr[nTempIndices], 0 );
253 TYPELIB_DANGER_RELEASE( ppTempParamTypeDescr[nTempIndices] );
255 if (pReturnTypeDescr)
256 TYPELIB_DANGER_RELEASE( pReturnTypeDescr );
258 CPPU_CURRENT_NAMESPACE::raiseException( &aUnoExc, pThis->getBridge()->getUno2Cpp() );
259 // has to destruct the any
260 // is here for dummy
261 return typelib_TypeClass_VOID;
263 else // else no exception occurred...
265 // temporary params
266 for ( ; nTempIndices--; )
268 sal_Int32 nIndex = pTempIndices[nTempIndices];
269 typelib_TypeDescription * pParamTypeDescr = ppTempParamTypeDescr[nTempIndices];
271 if (pParams[nIndex].bOut) // inout/out
273 // convert and assign
274 uno_destructData( pCppArgs[nIndex], pParamTypeDescr, cpp_release );
275 uno_copyAndConvertData( pCppArgs[nIndex], pUnoArgs[nIndex], pParamTypeDescr,
276 pThis->getBridge()->getUno2Cpp() );
278 // destroy temp uno param
279 uno_destructData( pUnoArgs[nIndex], pParamTypeDescr, 0 );
281 TYPELIB_DANGER_RELEASE( pParamTypeDescr );
283 // return
284 if (pCppReturn) // has complex return
286 if (pUnoReturn != pCppReturn) // needs reconversion
288 uno_copyAndConvertData( pCppReturn, pUnoReturn, pReturnTypeDescr,
289 pThis->getBridge()->getUno2Cpp() );
290 // destroy temp uno return
291 uno_destructData( pUnoReturn, pReturnTypeDescr, 0 );
293 // complex return ptr is set to return reg
294 *(void **)pRegisterReturn = pCppReturn;
296 if (pReturnTypeDescr)
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;
302 else
303 return typelib_TypeClass_VOID;
308 static 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 */ )
313 static_assert(sizeof(sal_Int64)==sizeof(void *), "### unexpected!");
315 sal_Int32 nVtableOffset = (nOffsetAndIndex >> 32);
316 sal_Int32 nFunctionIndex = (nOffsetAndIndex & 0xFFFFFFFF);
318 void ** ovrflw = (void**)(sp);
320 // gpreg: [ret *], this, [other gpr params]
321 // fpreg: [fpr params]
322 // ovrflw: [gpr or fpr params (properly aligned)]
324 void * pThis;
325 if (nFunctionIndex & 0x80000000 )
327 nFunctionIndex &= 0x7fffffff;
328 pThis = gpreg[1];
329 #if OSL_DEBUG_LEVEL > 2
330 fprintf(stderr, "pThis is gpreg[1]\n");
331 #endif
333 else
335 pThis = gpreg[0];
336 #if OSL_DEBUG_LEVEL > 2
337 fprintf(stderr, "pThis is gpreg[0]\n");
338 #endif
341 #if OSL_DEBUG_LEVEL > 2
342 fprintf(stderr, "pThis is %p\n", pThis);
343 #endif
345 pThis = static_cast< char * >(pThis) - nVtableOffset;
347 #if OSL_DEBUG_LEVEL > 2
348 fprintf(stderr, "pThis is now %p\n", pThis);
349 #endif
351 bridges::cpp_uno::shared::CppInterfaceProxy * pCppI
352 = bridges::cpp_uno::shared::CppInterfaceProxy::castInterfaceToProxy(
353 pThis);
355 typelib_InterfaceTypeDescription * pTypeDescr = pCppI->getTypeDescr();
357 #if OSL_DEBUG_LEVEL > 2
358 fprintf(stderr, "indexes are %d %d\n", nFunctionIndex, pTypeDescr->nMapFunctionIndexToMemberIndex);
359 #endif
361 if (nFunctionIndex >= pTypeDescr->nMapFunctionIndexToMemberIndex)
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);
375 // determine called method
376 sal_Int32 nMemberPos = pTypeDescr->pMapFunctionIndexToMemberIndex[nFunctionIndex];
377 assert(nMemberPos < pTypeDescr->nAllMembers);
379 #if OSL_DEBUG_LEVEL > 2
380 fprintf(stderr, "members are %d %d\n", nMemberPos, pTypeDescr->nAllMembers);
381 #endif
383 TypeDescription aMemberDescr( pTypeDescr->ppAllMembers[nMemberPos] );
385 typelib_TypeClass eRet;
386 switch (aMemberDescr.get()->eTypeClass)
388 case typelib_TypeClass_INTERFACE_ATTRIBUTE:
390 if (pTypeDescr->pMapMemberIndexToFunctionIndex[nMemberPos] == nFunctionIndex)
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 );
399 else
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;
408 eRet = cpp2uno_call(
409 pCppI, aMemberDescr.get(),
410 0, // indicates void return
411 1, &aParam,
412 r8, gpreg, fpreg, ovrflw, pRegisterReturn );
414 break;
416 case typelib_TypeClass_INTERFACE_METHOD:
418 // is METHOD
419 switch (nFunctionIndex)
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
431 typelib_TypeDescription * pTD = 0;
432 TYPELIB_DANGER_GET( &pTD, reinterpret_cast< Type * >( gpreg[2] )->getTypeLibType() );
433 if (pTD)
435 XInterface * pInterface = 0;
436 (*pCppI->getBridge()->getCppEnv()->getRegisteredInterface)(
437 pCppI->getBridge()->getCppEnv(),
438 (void **)&pInterface, pCppI->getOid().pData,
439 (typelib_InterfaceTypeDescription *)pTD );
441 if (pInterface)
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;
452 TYPELIB_DANGER_RELEASE( pTD );
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 );
463 break;
465 default:
467 #if OSL_DEBUG_LEVEL > 2
468 fprintf(stderr, "screwed\n");
469 #endif
471 throw RuntimeException( "no member description found!", (XInterface *)pThis );
475 #if OSL_DEBUG_LEVEL > 2
476 fprintf(stderr, "end of cpp_mediate\n");
477 #endif
478 return eRet;
482 extern "C" ia64::RegReturn cpp_vtable_call(
483 long in0, long in1, long in2, long in3, long in4, long in5, long in6, long in7,
484 long firstonstack
487 register long r15 asm("r15");
488 long r8 = r15;
490 register long r14 asm("r14");
491 long nOffsetAndIndex = r14;
493 long sp = (long)&firstonstack;
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;
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;
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
521 volatile long nRegReturn[4] = { 0 };
523 typelib_TypeClass aType =
524 cpp_mediate( nOffsetAndIndex, (void**)gpreg, (void**)fpreg, sp, r8, (sal_Int64*)&nRegReturn[0]);
526 ia64::RegReturn ret;
527 switch( aType )
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:
552 ret.r8 = nRegReturn[0];
553 ret.r9 = nRegReturn[1];
554 ret.r10 = nRegReturn[2];
555 ret.r11 = nRegReturn[3];
556 break;
558 default:
559 break;
561 return ret;
564 namespace
566 const int codeSnippetSize = 40;
568 bridges::cpp_uno::shared::VtableFactory::Slot codeSnippet( unsigned char * code, sal_PtrDiff writetoexecdiff, sal_Int32 nFunctionIndex, sal_Int32 nVtableOffset,
569 bool bHasHiddenParam )
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
577 sal_uInt64 nOffsetAndIndex = ( ( (sal_uInt64) nVtableOffset ) << 32 ) | ( (sal_uInt64) nFunctionIndex );
579 if ( bHasHiddenParam )
580 nOffsetAndIndex |= 0x80000000;
582 long *raw = (long *)code;
584 bridges::cpp_uno::shared::VtableFactory::Slot* destination = (bridges::cpp_uno::shared::VtableFactory::Slot*)cpp_vtable_call;
586 raw[0] = (long)&privateSnippetExecutor;
587 raw[1] = (long)&raw[2];
588 raw[2] = nOffsetAndIndex;
589 raw[3] = destination->gp_value;
591 return *(bridges::cpp_uno::shared::VtableFactory::Slot*)(code+writetoexecdiff);
595 void bridges::cpp_uno::shared::VtableFactory::flushCode(unsigned char const *, unsigned char const *)
599 bridges::cpp_uno::shared::VtableFactory::Slot * bridges::cpp_uno::shared::VtableFactory::mapBlockToVtable(void * block)
601 return static_cast< Slot * >(block) + 1;
605 std::size_t bridges::cpp_uno::shared::VtableFactory::getBlockSize(
606 sal_Int32 slotCount)
608 return (slotCount + 1) * sizeof (Slot) + slotCount * codeSnippetSize;
611 namespace {
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:
614 struct ProxyRtti {};
617 bridges::cpp_uno::shared::VtableFactory::Slot* bridges::cpp_uno::shared::VtableFactory::initializeBlock(void * block, sal_Int32 slotCount, sal_Int32, typelib_InterfaceTypeDescription *)
619 Slot * slots = mapBlockToVtable(block);
620 slots[-1] = {0,reinterpret_cast<sal_uInt64>(&typeid(ProxyRtti))};
621 return slots + slotCount;
624 unsigned char * bridges::cpp_uno::shared::VtableFactory::addLocalFunctions(
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)
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
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,
645 ia64::return_in_hidden_param(
646 reinterpret_cast<
647 typelib_InterfaceAttributeTypeDescription * >(
648 member)->pAttributeTypeRef));
649 code += codeSnippetSize;
652 // Setter:
653 if (!reinterpret_cast<
654 typelib_InterfaceAttributeTypeDescription * >(
655 member)->bReadOnly)
657 *slots++ = codeSnippet(code, writetoexecdiff, functionOffset++, vtableOffset, false);
658 code += codeSnippetSize;
660 break;
662 case typelib_TypeClass_INTERFACE_METHOD:
663 *slots++ = codeSnippet(
664 code, writetoexecdiff, functionOffset++, vtableOffset,
665 ia64::return_in_hidden_param(
666 reinterpret_cast<
667 typelib_InterfaceMethodTypeDescription * >(
668 member)->pReturnTypeRef));
669 code += codeSnippetSize;
670 break;
672 default:
673 assert(false);
674 break;
676 TYPELIB_DANGER_RELEASE(member);
678 return code;
681 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */