1*61dff127SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*61dff127SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*61dff127SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*61dff127SAndrew Rist  * distributed with this work for additional information
6*61dff127SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*61dff127SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*61dff127SAndrew Rist  * "License"); you may not use this file except in compliance
9*61dff127SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*61dff127SAndrew Rist  *
11*61dff127SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*61dff127SAndrew Rist  *
13*61dff127SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*61dff127SAndrew Rist  * software distributed under the License is distributed on an
15*61dff127SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*61dff127SAndrew Rist  * KIND, either express or implied.  See the License for the
17*61dff127SAndrew Rist  * specific language governing permissions and limitations
18*61dff127SAndrew Rist  * under the License.
19*61dff127SAndrew Rist  *
20*61dff127SAndrew Rist  *************************************************************/
21*61dff127SAndrew Rist 
22*61dff127SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_bridges.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <malloc.h>
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #include <com/sun/star/uno/genfunc.hxx>
30cdf0e10cSrcweir #include <uno/data.h>
31cdf0e10cSrcweir 
32cdf0e10cSrcweir #include "bridges/cpp_uno/shared/bridge.hxx"
33cdf0e10cSrcweir #include "bridges/cpp_uno/shared/types.hxx"
34cdf0e10cSrcweir #include "bridges/cpp_uno/shared/unointerfaceproxy.hxx"
35cdf0e10cSrcweir #include "bridges/cpp_uno/shared/vtables.hxx"
36cdf0e10cSrcweir 
37cdf0e10cSrcweir #include "share.hxx"
38cdf0e10cSrcweir 
39cdf0e10cSrcweir #include <stdio.h>
40cdf0e10cSrcweir #include <string.h>
41cdf0e10cSrcweir 
42cdf0e10cSrcweir 
43cdf0e10cSrcweir using namespace ::rtl;
44cdf0e10cSrcweir using namespace ::com::sun::star::uno;
45cdf0e10cSrcweir 
MapReturn(const ia64::RegReturn & rRet,double dret,typelib_TypeDescription * pReturnTypeDescr,bool bSimpleReturn,sal_uInt64 * pRegisterReturn)46cdf0e10cSrcweir void MapReturn(const ia64::RegReturn &rRet, double dret, typelib_TypeDescription * pReturnTypeDescr, bool bSimpleReturn, sal_uInt64 *pRegisterReturn)
47cdf0e10cSrcweir {
48cdf0e10cSrcweir     switch (pReturnTypeDescr->eTypeClass)
49cdf0e10cSrcweir     {
50cdf0e10cSrcweir     case typelib_TypeClass_HYPER:
51cdf0e10cSrcweir     case typelib_TypeClass_UNSIGNED_HYPER:
52cdf0e10cSrcweir     case typelib_TypeClass_LONG:
53cdf0e10cSrcweir     case typelib_TypeClass_UNSIGNED_LONG:
54cdf0e10cSrcweir     case typelib_TypeClass_ENUM:
55cdf0e10cSrcweir             *pRegisterReturn = rRet.r8;
56cdf0e10cSrcweir             break;
57cdf0e10cSrcweir     case typelib_TypeClass_CHAR:
58cdf0e10cSrcweir     case typelib_TypeClass_SHORT:
59cdf0e10cSrcweir     case typelib_TypeClass_UNSIGNED_SHORT:
60cdf0e10cSrcweir             *pRegisterReturn = (unsigned short)rRet.r8;
61cdf0e10cSrcweir             break;
62cdf0e10cSrcweir     case typelib_TypeClass_BOOLEAN:
63cdf0e10cSrcweir     case typelib_TypeClass_BYTE:
64cdf0e10cSrcweir             *pRegisterReturn = (unsigned char)rRet.r8;
65cdf0e10cSrcweir             break;
66cdf0e10cSrcweir     case typelib_TypeClass_FLOAT:
67cdf0e10cSrcweir             *reinterpret_cast<float *>( pRegisterReturn ) = dret;
68cdf0e10cSrcweir 	    break;
69cdf0e10cSrcweir     case typelib_TypeClass_DOUBLE:
70cdf0e10cSrcweir             *reinterpret_cast<double *>( pRegisterReturn ) = dret;
71cdf0e10cSrcweir             break;
72cdf0e10cSrcweir     case typelib_TypeClass_STRUCT:
73cdf0e10cSrcweir     case typelib_TypeClass_EXCEPTION:
74cdf0e10cSrcweir         {
75cdf0e10cSrcweir             sal_uInt32 nRetSize = pReturnTypeDescr->nSize;
76cdf0e10cSrcweir             if (bSimpleReturn && nRetSize <= 32 && nRetSize > 0)
77cdf0e10cSrcweir                 memcpy(pRegisterReturn, (void*)&rRet, nRetSize);
78cdf0e10cSrcweir             break;
79cdf0e10cSrcweir         }
80cdf0e10cSrcweir     default:
81cdf0e10cSrcweir 	break;
82cdf0e10cSrcweir     }
83cdf0e10cSrcweir }
84cdf0e10cSrcweir 
85cdf0e10cSrcweir namespace ia64
86cdf0e10cSrcweir {
is_complex_struct(const typelib_TypeDescription * type)87cdf0e10cSrcweir     bool is_complex_struct(const typelib_TypeDescription * type)
88cdf0e10cSrcweir     {
89cdf0e10cSrcweir         const typelib_CompoundTypeDescription * p
90cdf0e10cSrcweir             = reinterpret_cast< const typelib_CompoundTypeDescription * >(type);
91cdf0e10cSrcweir         for (sal_Int32 i = 0; i < p->nMembers; ++i)
92cdf0e10cSrcweir         {
93cdf0e10cSrcweir             if (p->ppTypeRefs[i]->eTypeClass == typelib_TypeClass_STRUCT ||
94cdf0e10cSrcweir                 p->ppTypeRefs[i]->eTypeClass == typelib_TypeClass_EXCEPTION)
95cdf0e10cSrcweir             {
96cdf0e10cSrcweir                 typelib_TypeDescription * t = 0;
97cdf0e10cSrcweir                 TYPELIB_DANGER_GET(&t, p->ppTypeRefs[i]);
98cdf0e10cSrcweir                 bool b = is_complex_struct(t);
99cdf0e10cSrcweir                 TYPELIB_DANGER_RELEASE(t);
100cdf0e10cSrcweir                 if (b) {
101cdf0e10cSrcweir                     return true;
102cdf0e10cSrcweir                 }
103cdf0e10cSrcweir             }
104cdf0e10cSrcweir             else if (!bridges::cpp_uno::shared::isSimpleType(p->ppTypeRefs[i]->eTypeClass))
105cdf0e10cSrcweir                 return true;
106cdf0e10cSrcweir         }
107cdf0e10cSrcweir         if (p->pBaseTypeDescription != 0)
108cdf0e10cSrcweir             return is_complex_struct(&p->pBaseTypeDescription->aBase);
109cdf0e10cSrcweir         return false;
110cdf0e10cSrcweir     }
111cdf0e10cSrcweir 
is_complex_struct(typelib_TypeDescriptionReference * pTypeRef)112cdf0e10cSrcweir     bool is_complex_struct( typelib_TypeDescriptionReference *pTypeRef )
113cdf0e10cSrcweir     {
114cdf0e10cSrcweir         if (pTypeRef->eTypeClass == typelib_TypeClass_STRUCT || pTypeRef->eTypeClass == typelib_TypeClass_EXCEPTION)
115cdf0e10cSrcweir 	{
116cdf0e10cSrcweir             typelib_TypeDescription * pTypeDescr = 0;
117cdf0e10cSrcweir             TYPELIB_DANGER_GET( &pTypeDescr, pTypeRef );
118cdf0e10cSrcweir 
119cdf0e10cSrcweir             bool bRet = is_complex_struct( pTypeDescr );
120cdf0e10cSrcweir             TYPELIB_DANGER_RELEASE( pTypeDescr );
121cdf0e10cSrcweir 
122cdf0e10cSrcweir             return bRet;
123cdf0e10cSrcweir        }
124cdf0e10cSrcweir        return false;
125cdf0e10cSrcweir     }
126cdf0e10cSrcweir 
return_via_r8_buffer(typelib_TypeDescriptionReference * pTypeRef)127cdf0e10cSrcweir     bool return_via_r8_buffer( typelib_TypeDescriptionReference *pTypeRef )
128cdf0e10cSrcweir     {
129cdf0e10cSrcweir         if (pTypeRef->eTypeClass == typelib_TypeClass_STRUCT || pTypeRef->eTypeClass == typelib_TypeClass_EXCEPTION)
130cdf0e10cSrcweir 	{
131cdf0e10cSrcweir             if (is_complex_struct( pTypeRef )) return false;
132cdf0e10cSrcweir 
133cdf0e10cSrcweir             typelib_TypeDescription * pTypeDescr = 0;
134cdf0e10cSrcweir             TYPELIB_DANGER_GET( &pTypeDescr, pTypeRef );
135cdf0e10cSrcweir 
136cdf0e10cSrcweir             /* If the struct is larger than 32 bytes, then there is a buffer at r8 to stick the return value into  */
137cdf0e10cSrcweir             bool bRet = pTypeDescr->nSize > 32;
138cdf0e10cSrcweir             TYPELIB_DANGER_RELEASE( pTypeDescr );
139cdf0e10cSrcweir             return bRet;
140cdf0e10cSrcweir        }
141cdf0e10cSrcweir        return false;
142cdf0e10cSrcweir     }
143cdf0e10cSrcweir 
return_in_hidden_param(typelib_TypeDescriptionReference * pTypeRef)144cdf0e10cSrcweir     bool return_in_hidden_param( typelib_TypeDescriptionReference *pTypeRef )
145cdf0e10cSrcweir     {
146cdf0e10cSrcweir         if (bridges::cpp_uno::shared::isSimpleType(pTypeRef))
147cdf0e10cSrcweir             return false;
148cdf0e10cSrcweir         else if (pTypeRef->eTypeClass == typelib_TypeClass_STRUCT || pTypeRef->eTypeClass == typelib_TypeClass_EXCEPTION)
149cdf0e10cSrcweir             return is_complex_struct( pTypeRef );
150cdf0e10cSrcweir         return true;
151cdf0e10cSrcweir     }
152cdf0e10cSrcweir 
153cdf0e10cSrcweir 
154cdf0e10cSrcweir }
155cdf0e10cSrcweir 
156cdf0e10cSrcweir namespace
157cdf0e10cSrcweir {
158cdf0e10cSrcweir //==================================================================================================
callVirtualMethod(void * pThis,sal_uInt32 nVtableIndex,void * pRegisterReturn,typelib_TypeDescription * pReturnTypeDescr,bool bSimpleReturn,sal_uInt64 * pStack,sal_uInt32 nStack,sal_uInt64 * pGPR,sal_uInt32 nGPR,double * pFPR,sal_uInt32 nFPR)159cdf0e10cSrcweir static void callVirtualMethod(void * pThis, sal_uInt32 nVtableIndex,
160cdf0e10cSrcweir 	void * pRegisterReturn, typelib_TypeDescription * pReturnTypeDescr, bool bSimpleReturn,
161cdf0e10cSrcweir         sal_uInt64 *pStack, sal_uInt32 nStack,
162cdf0e10cSrcweir         sal_uInt64 *pGPR, sal_uInt32 nGPR,
163cdf0e10cSrcweir         double *pFPR, sal_uInt32 nFPR)
164cdf0e10cSrcweir {
165cdf0e10cSrcweir     // Stack, if used, must be 16-bytes aligned
166cdf0e10cSrcweir     if ( nStack )
167cdf0e10cSrcweir         nStack = ( nStack + 1 ) & ~1;
168cdf0e10cSrcweir 
169cdf0e10cSrcweir     // Should not happen, but...
170cdf0e10cSrcweir     if ( nFPR > ia64::MAX_SSE_REGS )
171cdf0e10cSrcweir         nFPR = ia64::MAX_SSE_REGS;
172cdf0e10cSrcweir     if ( nGPR > ia64::MAX_GPR_REGS )
173cdf0e10cSrcweir         nGPR = ia64::MAX_GPR_REGS;
174cdf0e10cSrcweir 
175cdf0e10cSrcweir #ifdef CMC_DEBUG
176cdf0e10cSrcweir         // Let's figure out what is really going on here
177cdf0e10cSrcweir         {
178cdf0e10cSrcweir                 fprintf( stderr, "= callVirtualMethod() =\nGPR's (%d): ", nGPR );
179cdf0e10cSrcweir                 for ( unsigned int i = 0; i < nGPR; ++i )
180cdf0e10cSrcweir                         fprintf( stderr, "0x%lx, ", pGPR[i] );
181cdf0e10cSrcweir                 fprintf( stderr, "\nFPR's (%d): ", nFPR );
182cdf0e10cSrcweir                 for ( unsigned int i = 0; i < nFPR; ++i )
183cdf0e10cSrcweir                         fprintf( stderr, "0x%lx (%f), ", pFPR[i], pFPR[i] );
184cdf0e10cSrcweir                 fprintf( stderr, "\nStack (%d): ", nStack );
185cdf0e10cSrcweir                 for ( unsigned int i = 0; i < nStack; ++i )
186cdf0e10cSrcweir                         fprintf( stderr, "0x%lx, ", pStack[i] );
187cdf0e10cSrcweir                 fprintf( stderr, "\n" );
188cdf0e10cSrcweir 		fprintf( stderr, "pRegisterReturn is %p\n", pRegisterReturn);
189cdf0e10cSrcweir         }
190cdf0e10cSrcweir #endif
191cdf0e10cSrcweir 
192cdf0e10cSrcweir     // Load parameters to stack, if necessary
193cdf0e10cSrcweir     sal_uInt64 *stack = (sal_uInt64 *) __builtin_alloca( nStack * 8 );
194cdf0e10cSrcweir     memcpy( stack, pStack, nStack * 8 );
195cdf0e10cSrcweir 
196cdf0e10cSrcweir     // To get pointer to method
197cdf0e10cSrcweir     // a) get the address of the vtable
198cdf0e10cSrcweir     sal_uInt64 pMethod = *((sal_uInt64 *)pThis);
199cdf0e10cSrcweir     // b) get the address from the vtable entry at offset, each entry is 16bytes,
200cdf0e10cSrcweir     // 8 for function pointer, and 8 for global pointer
201cdf0e10cSrcweir     pMethod += 16 * nVtableIndex;
202cdf0e10cSrcweir 
203cdf0e10cSrcweir     typedef void (* FunctionCall )( sal_uInt64, sal_uInt64, sal_uInt64, sal_uInt64, sal_uInt64, sal_uInt64, sal_uInt64, sal_uInt64 );
204cdf0e10cSrcweir     FunctionCall pFunc = (FunctionCall)pMethod;
205cdf0e10cSrcweir 
206cdf0e10cSrcweir     switch (nFPR) //deliberate fall through
207cdf0e10cSrcweir     {
208cdf0e10cSrcweir         case 8:
209cdf0e10cSrcweir             asm volatile("ldfd f15=%0" : : "m"(pFPR[7]) : "f15");
210cdf0e10cSrcweir         case 7:
211cdf0e10cSrcweir             asm volatile("ldfd f14=%0" : : "m"(pFPR[6]) : "f14");
212cdf0e10cSrcweir         case 6:
213cdf0e10cSrcweir             asm volatile("ldfd f13=%0" : : "m"(pFPR[5]) : "f13");
214cdf0e10cSrcweir         case 5:
215cdf0e10cSrcweir             asm volatile("ldfd f12=%0" : : "m"(pFPR[4]) : "f12");
216cdf0e10cSrcweir         case 4:
217cdf0e10cSrcweir             asm volatile("ldfd f11=%0" : : "m"(pFPR[3]) : "f11");
218cdf0e10cSrcweir         case 3:
219cdf0e10cSrcweir             asm volatile("ldfd f10=%0" : : "m"(pFPR[2]) : "f10");
220cdf0e10cSrcweir         case 2:
221cdf0e10cSrcweir             asm volatile("ldfd f9=%0" : : "m"(pFPR[1]) : "f9");
222cdf0e10cSrcweir         case 1:
223cdf0e10cSrcweir             asm volatile("ldfd f8=%0" : : "m"(pFPR[0]) : "f8");
224cdf0e10cSrcweir         default:
225cdf0e10cSrcweir             break;
226cdf0e10cSrcweir     }
227cdf0e10cSrcweir 
228cdf0e10cSrcweir     //stick the return area into r8 for big struct returning
229cdf0e10cSrcweir     asm volatile("ld8 r8=%0" : : "m"(pRegisterReturn) : "r8");
230cdf0e10cSrcweir 
231cdf0e10cSrcweir     (*pFunc)(pGPR[0], pGPR[1], pGPR[2], pGPR[3], pGPR[4], pGPR[5], pGPR[6], pGPR[7]);
232cdf0e10cSrcweir 
233cdf0e10cSrcweir     register double f8 asm("f8");
234cdf0e10cSrcweir     ia64::RegReturn ret;
235cdf0e10cSrcweir     {
236cdf0e10cSrcweir         register long r8 asm("r8"); ret.r8 = r8;
237cdf0e10cSrcweir         register long r9 asm("r9"); ret.r9 = r9;
238cdf0e10cSrcweir         register long r10 asm("r10"); ret.r10 = r10;
239cdf0e10cSrcweir         register long r11 asm("r11"); ret.r11 = r11;
240cdf0e10cSrcweir     }
241cdf0e10cSrcweir 
242cdf0e10cSrcweir     MapReturn(ret, f8, pReturnTypeDescr, bSimpleReturn, (sal_uInt64*)pRegisterReturn);
243cdf0e10cSrcweir }
244cdf0e10cSrcweir 
245cdf0e10cSrcweir // Macros for easier insertion of values to registers or stack
246cdf0e10cSrcweir // pSV - pointer to the source
247cdf0e10cSrcweir // nr - order of the value [will be increased if stored to register]
248cdf0e10cSrcweir // pFPR, pGPR - pointer to the registers
249cdf0e10cSrcweir // pDS - pointer to the stack [will be increased if stored here]
250cdf0e10cSrcweir 
251cdf0e10cSrcweir // The value in %xmm register is already prepared to be retrieved as a float,
252cdf0e10cSrcweir // thus we treat float and double the same
253cdf0e10cSrcweir #define INSERT_FLOAT( pSV, nfr, pFPR, ngr, pGPR, pDS, bOverflow ) \
254cdf0e10cSrcweir         if ( nfr < ia64::MAX_SSE_REGS && ngr < ia64::MAX_GPR_REGS ) \
255cdf0e10cSrcweir                 pFPR[nfr++] = *reinterpret_cast<float *>( pSV ); \
256cdf0e10cSrcweir         if ( ngr < ia64::MAX_GPR_REGS ) \
257cdf0e10cSrcweir                 pGPR[ngr++] = *reinterpret_cast<sal_uInt64 *>( pSV ); \
258cdf0e10cSrcweir         else \
259cdf0e10cSrcweir         	bOverFlow = true; \
260cdf0e10cSrcweir         if (bOverFlow) \
261cdf0e10cSrcweir                 *pDS++ = *reinterpret_cast<sal_uInt64 *>( pSV ); // verbatim!
262cdf0e10cSrcweir 
263cdf0e10cSrcweir #define INSERT_DOUBLE( pSV, nfr, pFPR, ngr, pGPR, pDS, bOverflow ) \
264cdf0e10cSrcweir         if ( nfr < ia64::MAX_SSE_REGS && ngr < ia64::MAX_GPR_REGS ) \
265cdf0e10cSrcweir                 pFPR[nfr++] = *reinterpret_cast<double *>( pSV ); \
266cdf0e10cSrcweir         if ( ngr < ia64::MAX_GPR_REGS ) \
267cdf0e10cSrcweir                 pGPR[ngr++] = *reinterpret_cast<sal_uInt64 *>( pSV ); \
268cdf0e10cSrcweir         else \
269cdf0e10cSrcweir         	bOverFlow = true; \
270cdf0e10cSrcweir         if (bOverFlow) \
271cdf0e10cSrcweir                 *pDS++ = *reinterpret_cast<sal_uInt64 *>( pSV ); // verbatim!
272cdf0e10cSrcweir 
273cdf0e10cSrcweir #define INSERT_INT64( pSV, nr, pGPR, pDS, bOverflow ) \
274cdf0e10cSrcweir         if ( nr < ia64::MAX_GPR_REGS ) \
275cdf0e10cSrcweir                 pGPR[nr++] = *reinterpret_cast<sal_uInt64 *>( pSV ); \
276cdf0e10cSrcweir         else \
277cdf0e10cSrcweir 		bOverFlow = true; \
278cdf0e10cSrcweir 	if (bOverFlow) \
279cdf0e10cSrcweir                 *pDS++ = *reinterpret_cast<sal_uInt64 *>( pSV );
280cdf0e10cSrcweir 
281cdf0e10cSrcweir #define INSERT_INT32( pSV, nr, pGPR, pDS, bOverflow ) \
282cdf0e10cSrcweir         if ( nr < ia64::MAX_GPR_REGS ) \
283cdf0e10cSrcweir                 pGPR[nr++] = *reinterpret_cast<sal_uInt32 *>( pSV ); \
284cdf0e10cSrcweir         else \
285cdf0e10cSrcweir                 bOverFlow = true; \
286cdf0e10cSrcweir         if (bOverFlow) \
287cdf0e10cSrcweir                 *pDS++ = *reinterpret_cast<sal_uInt32 *>( pSV );
288cdf0e10cSrcweir 
289cdf0e10cSrcweir #define INSERT_INT16( pSV, nr, pGPR, pDS, bOverflow ) \
290cdf0e10cSrcweir         if ( nr < ia64::MAX_GPR_REGS ) \
291cdf0e10cSrcweir                 pGPR[nr++] = *reinterpret_cast<sal_uInt16 *>( pSV ); \
292cdf0e10cSrcweir         else \
293cdf0e10cSrcweir                 bOverFlow = true; \
294cdf0e10cSrcweir         if (bOverFlow) \
295cdf0e10cSrcweir                 *pDS++ = *reinterpret_cast<sal_uInt16 *>( pSV );
296cdf0e10cSrcweir 
297cdf0e10cSrcweir #define INSERT_INT8( pSV, nr, pGPR, pDS, bOverflow ) \
298cdf0e10cSrcweir         if ( nr < ia64::MAX_GPR_REGS ) \
299cdf0e10cSrcweir                 pGPR[nr++] = *reinterpret_cast<sal_uInt8 *>( pSV ); \
300cdf0e10cSrcweir         else \
301cdf0e10cSrcweir                 bOverFlow = true; \
302cdf0e10cSrcweir         if (bOverFlow) \
303cdf0e10cSrcweir                 *pDS++ = *reinterpret_cast<sal_uInt8 *>( pSV );
304cdf0e10cSrcweir 
305cdf0e10cSrcweir //==================================================================================================
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)306cdf0e10cSrcweir static void cpp_call(
307cdf0e10cSrcweir 	bridges::cpp_uno::shared::UnoInterfaceProxy * pThis,
308cdf0e10cSrcweir 	bridges::cpp_uno::shared::VtableSlot  aVtableSlot,
309cdf0e10cSrcweir 	typelib_TypeDescriptionReference * pReturnTypeRef,
310cdf0e10cSrcweir 	sal_Int32 nParams, typelib_MethodParameter * pParams,
311cdf0e10cSrcweir 	void * pUnoReturn, void * pUnoArgs[], uno_Any ** ppUnoExc )
312cdf0e10cSrcweir {
313cdf0e10cSrcweir   	// max space for: [complex ret ptr], values|ptr ...
314cdf0e10cSrcweir   	sal_uInt64 * pStack = (sal_uInt64 *)alloca( (nParams+3) * sizeof(sal_Int64) );
315cdf0e10cSrcweir   	sal_uInt64 * pStackStart = pStack;
316cdf0e10cSrcweir 
317cdf0e10cSrcweir 	sal_uInt64 pGPR[ia64::MAX_GPR_REGS];
318cdf0e10cSrcweir 	sal_uInt32 nGPR = 0;
319cdf0e10cSrcweir 
320cdf0e10cSrcweir 	double pFPR[ia64::MAX_SSE_REGS];
321cdf0e10cSrcweir 	sal_uInt32 nFPR = 0;
322cdf0e10cSrcweir 
323cdf0e10cSrcweir 	// return
324cdf0e10cSrcweir 	typelib_TypeDescription * pReturnTypeDescr = 0;
325cdf0e10cSrcweir 	TYPELIB_DANGER_GET( &pReturnTypeDescr, pReturnTypeRef );
326cdf0e10cSrcweir 	OSL_ENSURE( pReturnTypeDescr, "### expected return type description!" );
327cdf0e10cSrcweir 
328cdf0e10cSrcweir 	void * pCppReturn = 0; // if != 0 && != pUnoReturn, needs reconversion
329cdf0e10cSrcweir 
330cdf0e10cSrcweir         bool bOverFlow = false;
331cdf0e10cSrcweir 
332cdf0e10cSrcweir 	bool bSimpleReturn = true;
333cdf0e10cSrcweir 	if (pReturnTypeDescr)
334cdf0e10cSrcweir 	{
335cdf0e10cSrcweir #ifdef CMC_DEBUG
336cdf0e10cSrcweir 		fprintf(stderr, "return type is %d\n", pReturnTypeDescr->eTypeClass);
337cdf0e10cSrcweir #endif
338cdf0e10cSrcweir 		if ( ia64::return_in_hidden_param(pReturnTypeRef) || ia64::return_via_r8_buffer(pReturnTypeRef) )
339cdf0e10cSrcweir                         bSimpleReturn = false;
340cdf0e10cSrcweir 
341cdf0e10cSrcweir                 if ( bSimpleReturn )
342cdf0e10cSrcweir 		{
343cdf0e10cSrcweir 			pCppReturn = pUnoReturn; // direct way for simple types
344cdf0e10cSrcweir #ifdef CMC_DEBUG
345cdf0e10cSrcweir 			fprintf(stderr, "simple return\n");
346cdf0e10cSrcweir #endif
347cdf0e10cSrcweir 		}
348cdf0e10cSrcweir 		else
349cdf0e10cSrcweir 		{
350cdf0e10cSrcweir 			// complex return via ptr
351cdf0e10cSrcweir 			pCppReturn = (bridges::cpp_uno::shared::relatesToInterfaceType( pReturnTypeDescr )
352cdf0e10cSrcweir 			       ? alloca( pReturnTypeDescr->nSize ) : pUnoReturn);
353cdf0e10cSrcweir #ifdef CMC_DEBUG
354cdf0e10cSrcweir 			fprintf(stderr, "pCppReturn/pUnoReturn is %lx/%lx", pCppReturn, pUnoReturn);
355cdf0e10cSrcweir #endif
356cdf0e10cSrcweir                         if (!ia64::return_via_r8_buffer(pReturnTypeRef))
357cdf0e10cSrcweir 			    INSERT_INT64( &pCppReturn, nGPR, pGPR, pStack, bOverFlow );
358cdf0e10cSrcweir 		}
359cdf0e10cSrcweir 	}
360cdf0e10cSrcweir 	// push "this" pointer
361cdf0e10cSrcweir         void * pAdjustedThisPtr = reinterpret_cast< void ** >( pThis->getCppI() ) + aVtableSlot.offset;
362cdf0e10cSrcweir 
363cdf0e10cSrcweir #ifdef CMC_DEBUG
364cdf0e10cSrcweir 	fprintf(stderr, "this pointer is %p\n", pAdjustedThisPtr);
365cdf0e10cSrcweir #endif
366cdf0e10cSrcweir 	INSERT_INT64( &pAdjustedThisPtr, nGPR, pGPR, pStack, bOverFlow );
367cdf0e10cSrcweir 
368cdf0e10cSrcweir         // Args
369cdf0e10cSrcweir         void ** pCppArgs = (void **)alloca( 3 * sizeof(void *) * nParams );
370cdf0e10cSrcweir 	// indizes of values this have to be converted (interface conversion cpp<=>uno)
371cdf0e10cSrcweir 	sal_Int32 * pTempIndizes = (sal_Int32 *)(pCppArgs + nParams);
372cdf0e10cSrcweir 	// type descriptions for reconversions
373cdf0e10cSrcweir 	typelib_TypeDescription ** ppTempParamTypeDescr = (typelib_TypeDescription **)(pCppArgs + (2 * nParams));
374cdf0e10cSrcweir 
375cdf0e10cSrcweir 	sal_Int32 nTempIndizes   = 0;
376cdf0e10cSrcweir 
377cdf0e10cSrcweir #ifdef CMC_DEBUG
378cdf0e10cSrcweir 	fprintf(stderr, "n params is %d\n", nParams);
379cdf0e10cSrcweir #endif
380cdf0e10cSrcweir 
381cdf0e10cSrcweir 	for ( sal_Int32 nPos = 0; nPos < nParams; ++nPos )
382cdf0e10cSrcweir 	{
383cdf0e10cSrcweir 		const typelib_MethodParameter & rParam = pParams[nPos];
384cdf0e10cSrcweir 		typelib_TypeDescription * pParamTypeDescr = 0;
385cdf0e10cSrcweir 		TYPELIB_DANGER_GET( &pParamTypeDescr, rParam.pTypeRef );
386cdf0e10cSrcweir 
387cdf0e10cSrcweir #ifdef CMC_DEBUG
388cdf0e10cSrcweir 		fprintf(stderr, "param %d is %d %d %d\n", nPos, rParam.bOut, bridges::cpp_uno::shared::isSimpleType( pParamTypeDescr ),
389cdf0e10cSrcweir 			pParamTypeDescr->eTypeClass);
390cdf0e10cSrcweir #endif
391cdf0e10cSrcweir 
392cdf0e10cSrcweir 		if (!rParam.bOut && bridges::cpp_uno::shared::isSimpleType( pParamTypeDescr ))
393cdf0e10cSrcweir 		{
394cdf0e10cSrcweir //			uno_copyAndConvertData( pCppArgs[nPos] = alloca( 8 ), pUnoArgs[nPos], pParamTypeDescr,
395cdf0e10cSrcweir 			uno_copyAndConvertData( pCppArgs[nPos] = pStack, pUnoArgs[nPos], pParamTypeDescr,
396cdf0e10cSrcweir 									pThis->getBridge()->getUno2Cpp() );
397cdf0e10cSrcweir 		        switch (pParamTypeDescr->eTypeClass)
398cdf0e10cSrcweir                         {
399cdf0e10cSrcweir                         case typelib_TypeClass_HYPER:
400cdf0e10cSrcweir                         case typelib_TypeClass_UNSIGNED_HYPER:
401cdf0e10cSrcweir #ifdef CMC_DEBUG
402cdf0e10cSrcweir 				fprintf(stderr, "hyper is %lx\n", *(unsigned long*)(pCppArgs[nPos]));
403cdf0e10cSrcweir #endif
404cdf0e10cSrcweir                                 INSERT_INT64( pCppArgs[nPos], nGPR, pGPR, pStack, bOverFlow );
405cdf0e10cSrcweir                                 break;
406cdf0e10cSrcweir                         case typelib_TypeClass_LONG:
407cdf0e10cSrcweir                         case typelib_TypeClass_UNSIGNED_LONG:
408cdf0e10cSrcweir                         case typelib_TypeClass_ENUM:
409cdf0e10cSrcweir #ifdef CMC_DEBUG
410cdf0e10cSrcweir 				fprintf(stderr, "long is %lx\n", *(unsigned int*)(pCppArgs[nPos]));
411cdf0e10cSrcweir #endif
412cdf0e10cSrcweir                                 INSERT_INT32( pCppArgs[nPos], nGPR, pGPR, pStack, bOverFlow );
413cdf0e10cSrcweir                                 break;
414cdf0e10cSrcweir                         case typelib_TypeClass_SHORT:
415cdf0e10cSrcweir                         case typelib_TypeClass_CHAR:
416cdf0e10cSrcweir                         case typelib_TypeClass_UNSIGNED_SHORT:
417cdf0e10cSrcweir #ifdef CMC_DEBUG
418cdf0e10cSrcweir 				fprintf(stderr, "short is %x\n", *(unsigned short*)(pCppArgs[nPos]));
419cdf0e10cSrcweir #endif
420cdf0e10cSrcweir                                 INSERT_INT16( pCppArgs[nPos], nGPR, pGPR, pStack, bOverFlow );
421cdf0e10cSrcweir                                 break;
422cdf0e10cSrcweir                         case typelib_TypeClass_BOOLEAN:
423cdf0e10cSrcweir                         case typelib_TypeClass_BYTE:
424cdf0e10cSrcweir #ifdef CMC_DEBUG
425cdf0e10cSrcweir 				fprintf(stderr, "byte is %x\n", *(unsigned char*)(pCppArgs[nPos]));
426cdf0e10cSrcweir #endif
427cdf0e10cSrcweir                                 INSERT_INT8( pCppArgs[nPos], nGPR, pGPR, pStack, bOverFlow );
428cdf0e10cSrcweir                                 break;
429cdf0e10cSrcweir                         case typelib_TypeClass_FLOAT:
430cdf0e10cSrcweir #ifdef CMC_DEBUG
431cdf0e10cSrcweir 				fprintf(stderr, "a float is %f\n", *(float*)(pCppArgs[nPos]));
432cdf0e10cSrcweir 				fprintf(stderr, "b float is %f\n", *(double*)(pCppArgs[nPos]));
433cdf0e10cSrcweir #endif
434cdf0e10cSrcweir                                 INSERT_FLOAT( pCppArgs[nPos], nFPR, pFPR, nGPR, pGPR, pStack, bOverFlow );
435cdf0e10cSrcweir 				break;
436cdf0e10cSrcweir                         case typelib_TypeClass_DOUBLE:
437cdf0e10cSrcweir #ifdef CMC_DEBUG
438cdf0e10cSrcweir 				fprintf(stderr, "double is %f\n", *(double*)(pCppArgs[nPos]));
439cdf0e10cSrcweir #endif
440cdf0e10cSrcweir                                 INSERT_DOUBLE( pCppArgs[nPos], nFPR, pFPR, nGPR, pGPR, pStack, bOverFlow );
441cdf0e10cSrcweir                                 break;
442cdf0e10cSrcweir 			default:
443cdf0e10cSrcweir 				break;
444cdf0e10cSrcweir                         }
445cdf0e10cSrcweir 
446cdf0e10cSrcweir                         // no longer needed
447cdf0e10cSrcweir                         TYPELIB_DANGER_RELEASE( pParamTypeDescr );
448cdf0e10cSrcweir 
449cdf0e10cSrcweir 		}
450cdf0e10cSrcweir 		else // ptr to complex value | ref
451cdf0e10cSrcweir 		{
452cdf0e10cSrcweir #ifdef CMC_DEBUG
453cdf0e10cSrcweir 			fprintf(stderr, "complex type again %d\n", rParam.bIn);
454cdf0e10cSrcweir #endif
455cdf0e10cSrcweir                         if (! rParam.bIn) // is pure out
456cdf0e10cSrcweir                         {
457cdf0e10cSrcweir #ifdef CMC_DEBUG
458cdf0e10cSrcweir 				fprintf(stderr, "complex size is %d\n", pParamTypeDescr->nSize );
459cdf0e10cSrcweir #endif
460cdf0e10cSrcweir                                 // cpp out is constructed mem, uno out is not!
461cdf0e10cSrcweir                                 uno_constructData(
462cdf0e10cSrcweir                                         pCppArgs[nPos] = alloca( pParamTypeDescr->nSize ),
463cdf0e10cSrcweir                                         pParamTypeDescr );
464cdf0e10cSrcweir                                 pTempIndizes[nTempIndizes] = nPos; // default constructed for cpp call
465cdf0e10cSrcweir                                 // will be released at reconversion
466cdf0e10cSrcweir                                 ppTempParamTypeDescr[nTempIndizes++] = pParamTypeDescr;
467cdf0e10cSrcweir                         }
468cdf0e10cSrcweir                         // is in/inout
469cdf0e10cSrcweir                         else if (bridges::cpp_uno::shared::relatesToInterfaceType( pParamTypeDescr ))
470cdf0e10cSrcweir                         {
471cdf0e10cSrcweir #ifdef CMC_DEBUG
472cdf0e10cSrcweir 				fprintf(stderr, "this one\n");
473cdf0e10cSrcweir #endif
474cdf0e10cSrcweir                                 uno_copyAndConvertData(
475cdf0e10cSrcweir                                         pCppArgs[nPos] = alloca( pParamTypeDescr->nSize ),
476cdf0e10cSrcweir                                         pUnoArgs[nPos], pParamTypeDescr, pThis->getBridge()->getUno2Cpp() );
477cdf0e10cSrcweir 
478cdf0e10cSrcweir                                 pTempIndizes[nTempIndizes] = nPos; // has to be reconverted
479cdf0e10cSrcweir                                 // will be released at reconversion
480cdf0e10cSrcweir                                 ppTempParamTypeDescr[nTempIndizes++] = pParamTypeDescr;
481cdf0e10cSrcweir                         }
482cdf0e10cSrcweir                         else // direct way
483cdf0e10cSrcweir                         {
484cdf0e10cSrcweir #ifdef CMC_DEBUG
485cdf0e10cSrcweir 				fprintf(stderr, "that one, passing %lx through\n", pUnoArgs[nPos]);
486cdf0e10cSrcweir #endif
487cdf0e10cSrcweir                                 pCppArgs[nPos] = pUnoArgs[nPos];
488cdf0e10cSrcweir                                 // no longer needed
489cdf0e10cSrcweir                                 TYPELIB_DANGER_RELEASE( pParamTypeDescr );
490cdf0e10cSrcweir                         }
491cdf0e10cSrcweir                         INSERT_INT64( &(pCppArgs[nPos]), nGPR, pGPR, pStack, bOverFlow );
492cdf0e10cSrcweir 		}
493cdf0e10cSrcweir 	}
494cdf0e10cSrcweir 
495cdf0e10cSrcweir 	try
496cdf0e10cSrcweir 	{
497cdf0e10cSrcweir                callVirtualMethod(
498cdf0e10cSrcweir                         pAdjustedThisPtr, aVtableSlot.index,
499cdf0e10cSrcweir                         pCppReturn, pReturnTypeDescr, bSimpleReturn,
500cdf0e10cSrcweir                         pStackStart, ( pStack - pStackStart ),
501cdf0e10cSrcweir                         pGPR, nGPR,
502cdf0e10cSrcweir                         pFPR, nFPR );
503cdf0e10cSrcweir 		// NO exception occured...
504cdf0e10cSrcweir 		*ppUnoExc = 0;
505cdf0e10cSrcweir 
506cdf0e10cSrcweir 		// reconvert temporary params
507cdf0e10cSrcweir 		for ( ; nTempIndizes--; )
508cdf0e10cSrcweir 		{
509cdf0e10cSrcweir 			sal_Int32 nIndex = pTempIndizes[nTempIndizes];
510cdf0e10cSrcweir 			typelib_TypeDescription * pParamTypeDescr = ppTempParamTypeDescr[nTempIndizes];
511cdf0e10cSrcweir 
512cdf0e10cSrcweir 			if (pParams[nIndex].bIn)
513cdf0e10cSrcweir 			{
514cdf0e10cSrcweir 				if (pParams[nIndex].bOut) // inout
515cdf0e10cSrcweir 				{
516cdf0e10cSrcweir 					uno_destructData( pUnoArgs[nIndex], pParamTypeDescr, 0 ); // destroy uno value
517cdf0e10cSrcweir 					uno_copyAndConvertData( pUnoArgs[nIndex], pCppArgs[nIndex], pParamTypeDescr,
518cdf0e10cSrcweir 											pThis->getBridge()->getCpp2Uno() );
519cdf0e10cSrcweir 				}
520cdf0e10cSrcweir 			}
521cdf0e10cSrcweir 			else // pure out
522cdf0e10cSrcweir 			{
523cdf0e10cSrcweir 				uno_copyAndConvertData( pUnoArgs[nIndex], pCppArgs[nIndex], pParamTypeDescr,
524cdf0e10cSrcweir 										pThis->getBridge()->getCpp2Uno() );
525cdf0e10cSrcweir 			}
526cdf0e10cSrcweir 			// destroy temp cpp param => cpp: every param was constructed
527cdf0e10cSrcweir 			uno_destructData( pCppArgs[nIndex], pParamTypeDescr, cpp_release );
528cdf0e10cSrcweir 
529cdf0e10cSrcweir 			TYPELIB_DANGER_RELEASE( pParamTypeDescr );
530cdf0e10cSrcweir 		}
531cdf0e10cSrcweir 		// return value
532cdf0e10cSrcweir 		if (pCppReturn && pUnoReturn != pCppReturn)
533cdf0e10cSrcweir 		{
534cdf0e10cSrcweir 			uno_copyAndConvertData( pUnoReturn, pCppReturn, pReturnTypeDescr,
535cdf0e10cSrcweir 									pThis->getBridge()->getCpp2Uno() );
536cdf0e10cSrcweir 			uno_destructData( pCppReturn, pReturnTypeDescr, cpp_release );
537cdf0e10cSrcweir 		}
538cdf0e10cSrcweir 	}
539cdf0e10cSrcweir  	catch (...)
540cdf0e10cSrcweir  	{
541cdf0e10cSrcweir   		// fill uno exception
542cdf0e10cSrcweir 		fillUnoException( CPPU_CURRENT_NAMESPACE::__cxa_get_globals()->caughtExceptions,
543cdf0e10cSrcweir                                   *ppUnoExc, pThis->getBridge()->getCpp2Uno() );
544cdf0e10cSrcweir 
545cdf0e10cSrcweir 		// temporary params
546cdf0e10cSrcweir 		for ( ; nTempIndizes--; )
547cdf0e10cSrcweir 		{
548cdf0e10cSrcweir 			sal_Int32 nIndex = pTempIndizes[nTempIndizes];
549cdf0e10cSrcweir 			// destroy temp cpp param => cpp: every param was constructed
550cdf0e10cSrcweir 			uno_destructData( pCppArgs[nIndex], ppTempParamTypeDescr[nTempIndizes], cpp_release );
551cdf0e10cSrcweir 			TYPELIB_DANGER_RELEASE( ppTempParamTypeDescr[nTempIndizes] );
552cdf0e10cSrcweir 		}
553cdf0e10cSrcweir 		// return type
554cdf0e10cSrcweir 		if (pReturnTypeDescr)
555cdf0e10cSrcweir 			TYPELIB_DANGER_RELEASE( pReturnTypeDescr );
556cdf0e10cSrcweir 	}
557cdf0e10cSrcweir }
558cdf0e10cSrcweir 
559cdf0e10cSrcweir }
560cdf0e10cSrcweir 
561cdf0e10cSrcweir namespace bridges { namespace cpp_uno { namespace shared {
562cdf0e10cSrcweir 
unoInterfaceProxyDispatch(uno_Interface * pUnoI,const typelib_TypeDescription * pMemberDescr,void * pReturn,void * pArgs[],uno_Any ** ppException)563cdf0e10cSrcweir void unoInterfaceProxyDispatch(
564cdf0e10cSrcweir 	uno_Interface * pUnoI, const typelib_TypeDescription * pMemberDescr,
565cdf0e10cSrcweir 	void * pReturn, void * pArgs[], uno_Any ** ppException )
566cdf0e10cSrcweir {
567cdf0e10cSrcweir 	// is my surrogate
568cdf0e10cSrcweir         bridges::cpp_uno::shared::UnoInterfaceProxy * pThis
569cdf0e10cSrcweir             = static_cast< bridges::cpp_uno::shared::UnoInterfaceProxy *> (pUnoI);
570cdf0e10cSrcweir 
571cdf0e10cSrcweir 	switch (pMemberDescr->eTypeClass)
572cdf0e10cSrcweir 	{
573cdf0e10cSrcweir 	case typelib_TypeClass_INTERFACE_ATTRIBUTE:
574cdf0e10cSrcweir 	{
575cdf0e10cSrcweir 
576cdf0e10cSrcweir         VtableSlot aVtableSlot(
577cdf0e10cSrcweir             getVtableSlot(
578cdf0e10cSrcweir                 reinterpret_cast<
579cdf0e10cSrcweir                     typelib_InterfaceAttributeTypeDescription const * >(
580cdf0e10cSrcweir                         pMemberDescr)));
581cdf0e10cSrcweir 
582cdf0e10cSrcweir 		if (pReturn)
583cdf0e10cSrcweir 		{
584cdf0e10cSrcweir 			// dependent dispatch
585cdf0e10cSrcweir 			cpp_call(
586cdf0e10cSrcweir 				pThis, aVtableSlot,
587cdf0e10cSrcweir 				((typelib_InterfaceAttributeTypeDescription *)pMemberDescr)->pAttributeTypeRef,
588cdf0e10cSrcweir 				0, 0, // no params
589cdf0e10cSrcweir 				pReturn, pArgs, ppException );
590cdf0e10cSrcweir 		}
591cdf0e10cSrcweir 		else
592cdf0e10cSrcweir 		{
593cdf0e10cSrcweir 			// is SET
594cdf0e10cSrcweir 			typelib_MethodParameter aParam;
595cdf0e10cSrcweir 			aParam.pTypeRef =
596cdf0e10cSrcweir 				((typelib_InterfaceAttributeTypeDescription *)pMemberDescr)->pAttributeTypeRef;
597cdf0e10cSrcweir 			aParam.bIn		= sal_True;
598cdf0e10cSrcweir 			aParam.bOut		= sal_False;
599cdf0e10cSrcweir 
600cdf0e10cSrcweir 			typelib_TypeDescriptionReference * pReturnTypeRef = 0;
601cdf0e10cSrcweir 			OUString aVoidName( RTL_CONSTASCII_USTRINGPARAM("void") );
602cdf0e10cSrcweir 			typelib_typedescriptionreference_new(
603cdf0e10cSrcweir 				&pReturnTypeRef, typelib_TypeClass_VOID, aVoidName.pData );
604cdf0e10cSrcweir 
605cdf0e10cSrcweir 			// dependent dispatch
606cdf0e10cSrcweir                         aVtableSlot.index += 1; //get then set method
607cdf0e10cSrcweir 			cpp_call(
608cdf0e10cSrcweir 				pThis, aVtableSlot,
609cdf0e10cSrcweir 				pReturnTypeRef,
610cdf0e10cSrcweir 				1, &aParam,
611cdf0e10cSrcweir 				pReturn, pArgs, ppException );
612cdf0e10cSrcweir 
613cdf0e10cSrcweir 			typelib_typedescriptionreference_release( pReturnTypeRef );
614cdf0e10cSrcweir 		}
615cdf0e10cSrcweir 
616cdf0e10cSrcweir 		break;
617cdf0e10cSrcweir 	}
618cdf0e10cSrcweir 	case typelib_TypeClass_INTERFACE_METHOD:
619cdf0e10cSrcweir 	{
620cdf0e10cSrcweir 
621cdf0e10cSrcweir         VtableSlot aVtableSlot(
622cdf0e10cSrcweir             getVtableSlot(
623cdf0e10cSrcweir                 reinterpret_cast<
624cdf0e10cSrcweir                     typelib_InterfaceMethodTypeDescription const * >(
625cdf0e10cSrcweir                         pMemberDescr)));
626cdf0e10cSrcweir 		switch (aVtableSlot.index)
627cdf0e10cSrcweir 		{
628cdf0e10cSrcweir 			// standard calls
629cdf0e10cSrcweir 		case 1: // acquire uno interface
630cdf0e10cSrcweir 			(*pUnoI->acquire)( pUnoI );
631cdf0e10cSrcweir 			*ppException = 0;
632cdf0e10cSrcweir 			break;
633cdf0e10cSrcweir 		case 2: // release uno interface
634cdf0e10cSrcweir 			(*pUnoI->release)( pUnoI );
635cdf0e10cSrcweir 			*ppException = 0;
636cdf0e10cSrcweir 			break;
637cdf0e10cSrcweir 		case 0: // queryInterface() opt
638cdf0e10cSrcweir 		{
639cdf0e10cSrcweir 			typelib_TypeDescription * pTD = 0;
640cdf0e10cSrcweir 			TYPELIB_DANGER_GET( &pTD, reinterpret_cast< Type * >( pArgs[0] )->getTypeLibType() );
641cdf0e10cSrcweir 			if (pTD)
642cdf0e10cSrcweir 			{
643cdf0e10cSrcweir                 uno_Interface * pInterface = 0;
644cdf0e10cSrcweir                 (*pThis->pBridge->getUnoEnv()->getRegisteredInterface)(
645cdf0e10cSrcweir                     pThis->pBridge->getUnoEnv(),
646cdf0e10cSrcweir                     (void **)&pInterface, pThis->oid.pData, (typelib_InterfaceTypeDescription *)pTD );
647cdf0e10cSrcweir 
648cdf0e10cSrcweir                 if (pInterface)
649cdf0e10cSrcweir                 {
650cdf0e10cSrcweir                     ::uno_any_construct(
651cdf0e10cSrcweir                         reinterpret_cast< uno_Any * >( pReturn ),
652cdf0e10cSrcweir                         &pInterface, pTD, 0 );
653cdf0e10cSrcweir                     (*pInterface->release)( pInterface );
654cdf0e10cSrcweir                     TYPELIB_DANGER_RELEASE( pTD );
655cdf0e10cSrcweir                     *ppException = 0;
656cdf0e10cSrcweir                     break;
657cdf0e10cSrcweir                 }
658cdf0e10cSrcweir                 TYPELIB_DANGER_RELEASE( pTD );
659cdf0e10cSrcweir             }
660cdf0e10cSrcweir 		} // else perform queryInterface()
661cdf0e10cSrcweir 		default:
662cdf0e10cSrcweir 			// dependent dispatch
663cdf0e10cSrcweir 			cpp_call(
664cdf0e10cSrcweir 				pThis, aVtableSlot,
665cdf0e10cSrcweir 				((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->pReturnTypeRef,
666cdf0e10cSrcweir 				((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->nParams,
667cdf0e10cSrcweir 				((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->pParams,
668cdf0e10cSrcweir 				pReturn, pArgs, ppException );
669cdf0e10cSrcweir 		}
670cdf0e10cSrcweir 		break;
671cdf0e10cSrcweir 	}
672cdf0e10cSrcweir 	default:
673cdf0e10cSrcweir 	{
674cdf0e10cSrcweir 		::com::sun::star::uno::RuntimeException aExc(
675cdf0e10cSrcweir 			OUString( RTL_CONSTASCII_USTRINGPARAM("illegal member type description!") ),
676cdf0e10cSrcweir 			::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >() );
677cdf0e10cSrcweir 
678cdf0e10cSrcweir 		Type const & rExcType = ::getCppuType( &aExc );
679cdf0e10cSrcweir 		// binary identical null reference
680cdf0e10cSrcweir 		::uno_type_any_construct( *ppException, &aExc, rExcType.getTypeLibType(), 0 );
681cdf0e10cSrcweir 	}
682cdf0e10cSrcweir 	}
683cdf0e10cSrcweir }
684cdf0e10cSrcweir 
685cdf0e10cSrcweir } } }
686cdf0e10cSrcweir /* vi:set tabstop=4 shiftwidth=4 expandtab: */
687