xref: /trunk/main/bridges/source/cpp_uno/gcc3_netbsd_intel/uno2cpp.cxx (revision cf6516809c57e1bb0a940545cca99cdad54d4ce2)
161dff127SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
361dff127SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
461dff127SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
561dff127SAndrew Rist  * distributed with this work for additional information
661dff127SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
761dff127SAndrew Rist  * to you under the Apache License, Version 2.0 (the
861dff127SAndrew Rist  * "License"); you may not use this file except in compliance
961dff127SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
1161dff127SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
1361dff127SAndrew Rist  * Unless required by applicable law or agreed to in writing,
1461dff127SAndrew Rist  * software distributed under the License is distributed on an
1561dff127SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1661dff127SAndrew Rist  * KIND, either express or implied.  See the License for the
1761dff127SAndrew Rist  * specific language governing permissions and limitations
1861dff127SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
2061dff127SAndrew Rist  *************************************************************/
2161dff127SAndrew Rist 
2261dff127SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_bridges.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <sal/alloca.h>
28cdf0e10cSrcweir #include <rtl/alloc.h>
29cdf0e10cSrcweir 
30cdf0e10cSrcweir #include <uno/data.h>
31cdf0e10cSrcweir #include <bridges/cpp_uno/bridge.hxx>
32cdf0e10cSrcweir #include <bridges/cpp_uno/type_misc.hxx>
33cdf0e10cSrcweir 
34cdf0e10cSrcweir #include "share.hxx"
35cdf0e10cSrcweir 
36cdf0e10cSrcweir 
37cdf0e10cSrcweir using namespace ::rtl;
38cdf0e10cSrcweir using namespace ::com::sun::star::uno;
39cdf0e10cSrcweir 
40cdf0e10cSrcweir namespace CPPU_CURRENT_NAMESPACE
41cdf0e10cSrcweir {
42cdf0e10cSrcweir 
43cdf0e10cSrcweir void dummy_can_throw_anything( char const * );
44cdf0e10cSrcweir 
45cdf0e10cSrcweir //==================================================================================================
46cdf0e10cSrcweir // The call instruction within the asm section of callVirtualMethod may throw
47cdf0e10cSrcweir // exceptions.  So that the compiler handles this correctly, it is important
48cdf0e10cSrcweir // that (a) callVirtualMethod might call dummy_can_throw_anything (although this
49cdf0e10cSrcweir // never happens at runtime), which in turn can throw exceptions, and (b)
50cdf0e10cSrcweir // callVirtualMethod is not inlined at its call site (so that any exceptions are
51cdf0e10cSrcweir // caught which are thrown from the instruction calling callVirtualMethod):
52cdf0e10cSrcweir void callVirtualMethod(
53cdf0e10cSrcweir     void * pThis,
54cdf0e10cSrcweir     sal_Int32 nVtableIndex,
55cdf0e10cSrcweir     void * pRegisterReturn,
56cdf0e10cSrcweir     typelib_TypeClass eReturnType,
57cdf0e10cSrcweir     sal_Int32 * pStackLongs,
58cdf0e10cSrcweir     sal_Int32 nStackLongs ) __attribute__((noinline));
59cdf0e10cSrcweir 
callVirtualMethod(void * pThis,sal_Int32 nVtableIndex,void * pRegisterReturn,typelib_TypeClass eReturnType,sal_Int32 * pStackLongs,sal_Int32 nStackLongs)60cdf0e10cSrcweir void callVirtualMethod(
61cdf0e10cSrcweir     void * pThis,
62cdf0e10cSrcweir     sal_Int32 nVtableIndex,
63cdf0e10cSrcweir     void * pRegisterReturn,
64cdf0e10cSrcweir     typelib_TypeClass eReturnType,
65cdf0e10cSrcweir     sal_Int32 * pStackLongs,
66cdf0e10cSrcweir     sal_Int32 nStackLongs )
67cdf0e10cSrcweir {
68cdf0e10cSrcweir     // parameter list is mixed list of * and values
69cdf0e10cSrcweir     // reference parameters are pointers
70cdf0e10cSrcweir 
71cdf0e10cSrcweir     OSL_ENSURE( pStackLongs && pThis, "### null ptr!" );
72cdf0e10cSrcweir     OSL_ENSURE( (sizeof(void *) == 4) && (sizeof(sal_Int32) == 4), "### unexpected size of int!" );
73cdf0e10cSrcweir     OSL_ENSURE( nStackLongs && pStackLongs, "### no stack in callVirtualMethod !" );
74cdf0e10cSrcweir 
75cdf0e10cSrcweir     // never called
76cdf0e10cSrcweir     if (! pThis) dummy_can_throw_anything("xxx"); // address something
77cdf0e10cSrcweir 
78cdf0e10cSrcweir     volatile long edx = 0, eax = 0; // for register returns
79cdf0e10cSrcweir     void * stackptr;
80cdf0e10cSrcweir     asm volatile (
81cdf0e10cSrcweir         "mov   %%esp, %6\n\t"
82cdf0e10cSrcweir         // copy values
83cdf0e10cSrcweir         "mov   %0, %%eax\n\t"
84cdf0e10cSrcweir         "mov   %%eax, %%edx\n\t"
85cdf0e10cSrcweir         "dec   %%edx\n\t"
86cdf0e10cSrcweir         "shl   $2, %%edx\n\t"
87cdf0e10cSrcweir         "add   %1, %%edx\n"
88cdf0e10cSrcweir         "Lcopy:\n\t"
89cdf0e10cSrcweir         "pushl 0(%%edx)\n\t"
90cdf0e10cSrcweir         "sub   $4, %%edx\n\t"
91cdf0e10cSrcweir         "dec   %%eax\n\t"
92cdf0e10cSrcweir         "jne   Lcopy\n\t"
93cdf0e10cSrcweir         // do the actual call
94cdf0e10cSrcweir         "mov   %2, %%edx\n\t"
95cdf0e10cSrcweir         "mov   0(%%edx), %%edx\n\t"
96cdf0e10cSrcweir         "mov   %3, %%eax\n\t"
97cdf0e10cSrcweir         "shl   $2, %%eax\n\t"
98cdf0e10cSrcweir         "add   %%eax, %%edx\n\t"
99cdf0e10cSrcweir         "mov   0(%%edx), %%edx\n\t"
100cdf0e10cSrcweir         "call  *%%edx\n\t"
101cdf0e10cSrcweir         // save return registers
102cdf0e10cSrcweir         "mov   %%eax, %4\n\t"
103cdf0e10cSrcweir         "mov   %%edx, %5\n\t"
104cdf0e10cSrcweir         // cleanup stack
105cdf0e10cSrcweir         "mov   %6, %%esp\n\t"
106cdf0e10cSrcweir         :
107cdf0e10cSrcweir         : "m"(nStackLongs), "m"(pStackLongs), "m"(pThis), "m"(nVtableIndex),
108cdf0e10cSrcweir           "m"(eax), "m"(edx), "m"(stackptr)
109cdf0e10cSrcweir         : "eax", "edx" );
110cdf0e10cSrcweir     switch( eReturnType )
111cdf0e10cSrcweir     {
112cdf0e10cSrcweir         case typelib_TypeClass_HYPER:
113cdf0e10cSrcweir         case typelib_TypeClass_UNSIGNED_HYPER:
114cdf0e10cSrcweir             ((long*)pRegisterReturn)[1] = edx;
115cdf0e10cSrcweir         case typelib_TypeClass_LONG:
116cdf0e10cSrcweir         case typelib_TypeClass_UNSIGNED_LONG:
117cdf0e10cSrcweir         case typelib_TypeClass_CHAR:
118cdf0e10cSrcweir         case typelib_TypeClass_ENUM:
119cdf0e10cSrcweir             ((long*)pRegisterReturn)[0] = eax;
120cdf0e10cSrcweir             break;
121cdf0e10cSrcweir         case typelib_TypeClass_SHORT:
122cdf0e10cSrcweir         case typelib_TypeClass_UNSIGNED_SHORT:
123cdf0e10cSrcweir             *(unsigned short*)pRegisterReturn = eax;
124cdf0e10cSrcweir             break;
125cdf0e10cSrcweir         case typelib_TypeClass_BOOLEAN:
126cdf0e10cSrcweir         case typelib_TypeClass_BYTE:
127cdf0e10cSrcweir             *(unsigned char*)pRegisterReturn = eax;
128cdf0e10cSrcweir             break;
129cdf0e10cSrcweir         case typelib_TypeClass_FLOAT:
130cdf0e10cSrcweir             asm ( "fstps %0" : : "m"(*(char *)pRegisterReturn) );
131cdf0e10cSrcweir             break;
132cdf0e10cSrcweir         case typelib_TypeClass_DOUBLE:
133cdf0e10cSrcweir             asm ( "fstpl %0\n\t" : : "m"(*(char *)pRegisterReturn) );
134cdf0e10cSrcweir             break;
135cdf0e10cSrcweir     }
136cdf0e10cSrcweir }
137cdf0e10cSrcweir 
138cdf0e10cSrcweir //==================================================================================================
cpp_call(cppu_unoInterfaceProxy * pThis,sal_Int32 nVtableCall,typelib_TypeDescriptionReference * pReturnTypeRef,sal_Int32 nParams,typelib_MethodParameter * pParams,void * pUnoReturn,void * pUnoArgs[],uno_Any ** ppUnoExc)139cdf0e10cSrcweir static void cpp_call(
140cdf0e10cSrcweir     cppu_unoInterfaceProxy * pThis,
141cdf0e10cSrcweir     sal_Int32 nVtableCall,
142cdf0e10cSrcweir     typelib_TypeDescriptionReference * pReturnTypeRef,
143cdf0e10cSrcweir     sal_Int32 nParams, typelib_MethodParameter * pParams,
144cdf0e10cSrcweir     void * pUnoReturn, void * pUnoArgs[], uno_Any ** ppUnoExc )
145cdf0e10cSrcweir {
146cdf0e10cSrcweir     // max space for: [complex ret ptr], values|ptr ...
147cdf0e10cSrcweir     char * pCppStack        =
148cdf0e10cSrcweir         (char *)alloca( sizeof(sal_Int32) + ((nParams+2) * sizeof(sal_Int64)) );
149cdf0e10cSrcweir     char * pCppStackStart   = pCppStack;
150cdf0e10cSrcweir 
151cdf0e10cSrcweir     // return
152cdf0e10cSrcweir     typelib_TypeDescription * pReturnTypeDescr = 0;
153cdf0e10cSrcweir     TYPELIB_DANGER_GET( &pReturnTypeDescr, pReturnTypeRef );
154cdf0e10cSrcweir     OSL_ENSURE( pReturnTypeDescr, "### expected return type description!" );
155cdf0e10cSrcweir 
156cdf0e10cSrcweir     void * pCppReturn = 0; // if != 0 && != pUnoReturn, needs reconversion
157cdf0e10cSrcweir 
158cdf0e10cSrcweir     if (pReturnTypeDescr)
159cdf0e10cSrcweir     {
160cdf0e10cSrcweir         if (cppu_isSimpleType( pReturnTypeDescr ))
161cdf0e10cSrcweir         {
162cdf0e10cSrcweir             pCppReturn = pUnoReturn; // direct way for simple types
163cdf0e10cSrcweir         }
164cdf0e10cSrcweir         else
165cdf0e10cSrcweir         {
166cdf0e10cSrcweir             // complex return via ptr
167cdf0e10cSrcweir             pCppReturn = *(void **)pCppStack = (cppu_relatesToInterface( pReturnTypeDescr )
168cdf0e10cSrcweir                                                 ? alloca( pReturnTypeDescr->nSize )
169cdf0e10cSrcweir                                                 : pUnoReturn); // direct way
170cdf0e10cSrcweir             pCppStack += sizeof(void *);
171cdf0e10cSrcweir         }
172cdf0e10cSrcweir     }
173cdf0e10cSrcweir     // push this
174cdf0e10cSrcweir     *(void**)pCppStack = pThis->pCppI;
175cdf0e10cSrcweir     pCppStack += sizeof( void* );
176cdf0e10cSrcweir 
177cdf0e10cSrcweir     // stack space
178cdf0e10cSrcweir     OSL_ENSURE( sizeof(void *) == sizeof(sal_Int32), "### unexpected size!" );
179cdf0e10cSrcweir     // args
180cdf0e10cSrcweir     void ** pCppArgs  = (void **)alloca( 3 * sizeof(void *) * nParams );
181cdf0e10cSrcweir     // indizes of values this have to be converted (interface conversion cpp<=>uno)
182cdf0e10cSrcweir     sal_Int32 * pTempIndizes = (sal_Int32 *)(pCppArgs + nParams);
183cdf0e10cSrcweir     // type descriptions for reconversions
184cdf0e10cSrcweir     typelib_TypeDescription ** ppTempParamTypeDescr = (typelib_TypeDescription **)(pCppArgs + (2 * nParams));
185cdf0e10cSrcweir 
186cdf0e10cSrcweir     sal_Int32 nTempIndizes   = 0;
187cdf0e10cSrcweir 
188cdf0e10cSrcweir     for ( sal_Int32 nPos = 0; nPos < nParams; ++nPos )
189cdf0e10cSrcweir     {
190cdf0e10cSrcweir         const typelib_MethodParameter & rParam = pParams[nPos];
191cdf0e10cSrcweir         typelib_TypeDescription * pParamTypeDescr = 0;
192cdf0e10cSrcweir         TYPELIB_DANGER_GET( &pParamTypeDescr, rParam.pTypeRef );
193cdf0e10cSrcweir 
194cdf0e10cSrcweir         if (!rParam.bOut && cppu_isSimpleType( pParamTypeDescr ))
195cdf0e10cSrcweir         {
196cdf0e10cSrcweir             uno_copyAndConvertData( pCppArgs[nPos] = pCppStack, pUnoArgs[nPos], pParamTypeDescr,
197cdf0e10cSrcweir                                     &pThis->pBridge->aUno2Cpp );
198cdf0e10cSrcweir 
199cdf0e10cSrcweir             switch (pParamTypeDescr->eTypeClass)
200cdf0e10cSrcweir             {
201cdf0e10cSrcweir             case typelib_TypeClass_HYPER:
202cdf0e10cSrcweir             case typelib_TypeClass_UNSIGNED_HYPER:
203cdf0e10cSrcweir             case typelib_TypeClass_DOUBLE:
204cdf0e10cSrcweir                 pCppStack += sizeof(sal_Int32); // extra long
205cdf0e10cSrcweir             }
206cdf0e10cSrcweir             // no longer needed
207cdf0e10cSrcweir             TYPELIB_DANGER_RELEASE( pParamTypeDescr );
208cdf0e10cSrcweir         }
209cdf0e10cSrcweir         else // ptr to complex value | ref
210cdf0e10cSrcweir         {
211cdf0e10cSrcweir             if (! rParam.bIn) // is pure out
212cdf0e10cSrcweir             {
213cdf0e10cSrcweir                 // cpp out is constructed mem, uno out is not!
214cdf0e10cSrcweir                 uno_constructData(
215cdf0e10cSrcweir                     *(void **)pCppStack = pCppArgs[nPos] = alloca( pParamTypeDescr->nSize ),
216cdf0e10cSrcweir                     pParamTypeDescr );
217cdf0e10cSrcweir                 pTempIndizes[nTempIndizes] = nPos; // default constructed for cpp call
218cdf0e10cSrcweir                 // will be released at reconversion
219cdf0e10cSrcweir                 ppTempParamTypeDescr[nTempIndizes++] = pParamTypeDescr;
220cdf0e10cSrcweir             }
221cdf0e10cSrcweir             // is in/inout
222cdf0e10cSrcweir             else if (cppu_relatesToInterface( pParamTypeDescr ))
223cdf0e10cSrcweir             {
224cdf0e10cSrcweir                 uno_copyAndConvertData(
225cdf0e10cSrcweir                     *(void **)pCppStack = pCppArgs[nPos] = alloca( pParamTypeDescr->nSize ),
226cdf0e10cSrcweir                     pUnoArgs[nPos], pParamTypeDescr, &pThis->pBridge->aUno2Cpp );
227cdf0e10cSrcweir 
228cdf0e10cSrcweir                 pTempIndizes[nTempIndizes] = nPos; // has to be reconverted
229cdf0e10cSrcweir                 // will be released at reconversion
230cdf0e10cSrcweir                 ppTempParamTypeDescr[nTempIndizes++] = pParamTypeDescr;
231cdf0e10cSrcweir             }
232cdf0e10cSrcweir             else // direct way
233cdf0e10cSrcweir             {
234cdf0e10cSrcweir                 *(void **)pCppStack = pCppArgs[nPos] = pUnoArgs[nPos];
235cdf0e10cSrcweir                 // no longer needed
236cdf0e10cSrcweir                 TYPELIB_DANGER_RELEASE( pParamTypeDescr );
237cdf0e10cSrcweir             }
238cdf0e10cSrcweir         }
239cdf0e10cSrcweir         pCppStack += sizeof(sal_Int32); // standard parameter length
240cdf0e10cSrcweir     }
241cdf0e10cSrcweir 
242cdf0e10cSrcweir     try
243cdf0e10cSrcweir     {
244cdf0e10cSrcweir         OSL_ENSURE( !( (pCppStack - pCppStackStart ) & 3), "UNALIGNED STACK !!! (Please DO panic)" );
245cdf0e10cSrcweir         callVirtualMethod(
246cdf0e10cSrcweir             pThis->pCppI, nVtableCall,
247cdf0e10cSrcweir             pCppReturn, pReturnTypeDescr->eTypeClass,
248cdf0e10cSrcweir             (sal_Int32 *)pCppStackStart, (pCppStack - pCppStackStart) / sizeof(sal_Int32) );
249*07a3d7f1SPedro Giffuni         // NO exception occurred...
250cdf0e10cSrcweir         *ppUnoExc = 0;
251cdf0e10cSrcweir 
252cdf0e10cSrcweir         // reconvert temporary params
253cdf0e10cSrcweir         for ( ; nTempIndizes--; )
254cdf0e10cSrcweir         {
255cdf0e10cSrcweir             sal_Int32 nIndex = pTempIndizes[nTempIndizes];
256cdf0e10cSrcweir             typelib_TypeDescription * pParamTypeDescr = ppTempParamTypeDescr[nTempIndizes];
257cdf0e10cSrcweir 
258cdf0e10cSrcweir             if (pParams[nIndex].bIn)
259cdf0e10cSrcweir             {
260cdf0e10cSrcweir                 if (pParams[nIndex].bOut) // inout
261cdf0e10cSrcweir                 {
262cdf0e10cSrcweir                     uno_destructData( pUnoArgs[nIndex], pParamTypeDescr, 0 ); // destroy uno value
263cdf0e10cSrcweir                     uno_copyAndConvertData( pUnoArgs[nIndex], pCppArgs[nIndex], pParamTypeDescr,
264cdf0e10cSrcweir                                             &pThis->pBridge->aCpp2Uno );
265cdf0e10cSrcweir                 }
266cdf0e10cSrcweir             }
267cdf0e10cSrcweir             else // pure out
268cdf0e10cSrcweir             {
269cdf0e10cSrcweir                 uno_copyAndConvertData( pUnoArgs[nIndex], pCppArgs[nIndex], pParamTypeDescr,
270cdf0e10cSrcweir                                         &pThis->pBridge->aCpp2Uno );
271cdf0e10cSrcweir             }
272cdf0e10cSrcweir             // destroy temp cpp param => cpp: every param was constructed
273cdf0e10cSrcweir             uno_destructData( pCppArgs[nIndex], pParamTypeDescr, cpp_release );
274cdf0e10cSrcweir 
275cdf0e10cSrcweir             TYPELIB_DANGER_RELEASE( pParamTypeDescr );
276cdf0e10cSrcweir         }
277cdf0e10cSrcweir         // return value
278cdf0e10cSrcweir         if (pCppReturn && pUnoReturn != pCppReturn)
279cdf0e10cSrcweir         {
280cdf0e10cSrcweir             uno_copyAndConvertData( pUnoReturn, pCppReturn, pReturnTypeDescr,
281cdf0e10cSrcweir                                     &pThis->pBridge->aCpp2Uno );
282cdf0e10cSrcweir             uno_destructData( pCppReturn, pReturnTypeDescr, cpp_release );
283cdf0e10cSrcweir         }
284cdf0e10cSrcweir     }
285cdf0e10cSrcweir     catch (...)
286cdf0e10cSrcweir     {
287cdf0e10cSrcweir         // fill uno exception
288cdf0e10cSrcweir         fillUnoException( __cxa_get_globals()->caughtExceptions, *ppUnoExc, &pThis->pBridge->aCpp2Uno );
289cdf0e10cSrcweir 
290cdf0e10cSrcweir         // temporary params
291cdf0e10cSrcweir         for ( ; nTempIndizes--; )
292cdf0e10cSrcweir         {
293cdf0e10cSrcweir             sal_Int32 nIndex = pTempIndizes[nTempIndizes];
294cdf0e10cSrcweir             // destroy temp cpp param => cpp: every param was constructed
295cdf0e10cSrcweir             uno_destructData( pCppArgs[nIndex], ppTempParamTypeDescr[nTempIndizes], cpp_release );
296cdf0e10cSrcweir             TYPELIB_DANGER_RELEASE( ppTempParamTypeDescr[nTempIndizes] );
297cdf0e10cSrcweir         }
298cdf0e10cSrcweir         // return type
299cdf0e10cSrcweir         if (pReturnTypeDescr)
300cdf0e10cSrcweir             TYPELIB_DANGER_RELEASE( pReturnTypeDescr );
301cdf0e10cSrcweir     }
302cdf0e10cSrcweir }
303cdf0e10cSrcweir 
304cdf0e10cSrcweir 
305cdf0e10cSrcweir //==================================================================================================
cppu_unoInterfaceProxy_dispatch(uno_Interface * pUnoI,const typelib_TypeDescription * pMemberDescr,void * pReturn,void * pArgs[],uno_Any ** ppException)306cdf0e10cSrcweir void SAL_CALL cppu_unoInterfaceProxy_dispatch(
307cdf0e10cSrcweir     uno_Interface * pUnoI, const typelib_TypeDescription * pMemberDescr,
308cdf0e10cSrcweir     void * pReturn, void * pArgs[], uno_Any ** ppException ) throw ()
309cdf0e10cSrcweir {
310cdf0e10cSrcweir     // is my surrogate
311cdf0e10cSrcweir     cppu_unoInterfaceProxy * pThis = (cppu_unoInterfaceProxy *)pUnoI;
312cdf0e10cSrcweir     typelib_InterfaceTypeDescription * pTypeDescr = pThis->pTypeDescr;
313cdf0e10cSrcweir 
314cdf0e10cSrcweir     switch (pMemberDescr->eTypeClass)
315cdf0e10cSrcweir     {
316cdf0e10cSrcweir     case typelib_TypeClass_INTERFACE_ATTRIBUTE:
317cdf0e10cSrcweir     {
318cdf0e10cSrcweir         // determine vtable call index
319cdf0e10cSrcweir         sal_Int32 nMemberPos = ((typelib_InterfaceMemberTypeDescription *)pMemberDescr)->nPosition;
320cdf0e10cSrcweir         OSL_ENSURE( nMemberPos < pTypeDescr->nAllMembers, "### member pos out of range!" );
321cdf0e10cSrcweir 
322cdf0e10cSrcweir         sal_Int32 nVtableCall = pTypeDescr->pMapMemberIndexToFunctionIndex[nMemberPos];
323cdf0e10cSrcweir         OSL_ENSURE( nVtableCall < pTypeDescr->nMapFunctionIndexToMemberIndex, "### illegal vtable index!" );
324cdf0e10cSrcweir 
325cdf0e10cSrcweir         if (pReturn)
326cdf0e10cSrcweir         {
327cdf0e10cSrcweir             // dependent dispatch
328cdf0e10cSrcweir             cpp_call(
329cdf0e10cSrcweir                 pThis, nVtableCall,
330cdf0e10cSrcweir                 ((typelib_InterfaceAttributeTypeDescription *)pMemberDescr)->pAttributeTypeRef,
331cdf0e10cSrcweir                 0, 0, // no params
332cdf0e10cSrcweir                 pReturn, pArgs, ppException );
333cdf0e10cSrcweir         }
334cdf0e10cSrcweir         else
335cdf0e10cSrcweir         {
336cdf0e10cSrcweir             // is SET
337cdf0e10cSrcweir             typelib_MethodParameter aParam;
338cdf0e10cSrcweir             aParam.pTypeRef =
339cdf0e10cSrcweir                 ((typelib_InterfaceAttributeTypeDescription *)pMemberDescr)->pAttributeTypeRef;
340cdf0e10cSrcweir             aParam.bIn      = sal_True;
341cdf0e10cSrcweir             aParam.bOut     = sal_False;
342cdf0e10cSrcweir 
343cdf0e10cSrcweir             typelib_TypeDescriptionReference * pReturnTypeRef = 0;
344cdf0e10cSrcweir             OUString aVoidName( RTL_CONSTASCII_USTRINGPARAM("void") );
345cdf0e10cSrcweir             typelib_typedescriptionreference_new(
346cdf0e10cSrcweir                 &pReturnTypeRef, typelib_TypeClass_VOID, aVoidName.pData );
347cdf0e10cSrcweir 
348cdf0e10cSrcweir             // dependent dispatch
349cdf0e10cSrcweir             cpp_call(
350cdf0e10cSrcweir                 pThis, nVtableCall +1, // get, then set method
351cdf0e10cSrcweir                 pReturnTypeRef,
352cdf0e10cSrcweir                 1, &aParam,
353cdf0e10cSrcweir                 pReturn, pArgs, ppException );
354cdf0e10cSrcweir 
355cdf0e10cSrcweir             typelib_typedescriptionreference_release( pReturnTypeRef );
356cdf0e10cSrcweir         }
357cdf0e10cSrcweir 
358cdf0e10cSrcweir         break;
359cdf0e10cSrcweir     }
360cdf0e10cSrcweir     case typelib_TypeClass_INTERFACE_METHOD:
361cdf0e10cSrcweir     {
362cdf0e10cSrcweir         // determine vtable call index
363cdf0e10cSrcweir         sal_Int32 nMemberPos = ((typelib_InterfaceMemberTypeDescription *)pMemberDescr)->nPosition;
364cdf0e10cSrcweir         OSL_ENSURE( nMemberPos < pTypeDescr->nAllMembers, "### member pos out of range!" );
365cdf0e10cSrcweir 
366cdf0e10cSrcweir         sal_Int32 nVtableCall = pTypeDescr->pMapMemberIndexToFunctionIndex[nMemberPos];
367cdf0e10cSrcweir         OSL_ENSURE( nVtableCall < pTypeDescr->nMapFunctionIndexToMemberIndex, "### illegal vtable index!" );
368cdf0e10cSrcweir 
369cdf0e10cSrcweir         switch (nVtableCall)
370cdf0e10cSrcweir         {
371cdf0e10cSrcweir             // standard calls
372cdf0e10cSrcweir         case 1: // acquire uno interface
373cdf0e10cSrcweir             (*pUnoI->acquire)( pUnoI );
374cdf0e10cSrcweir             *ppException = 0;
375cdf0e10cSrcweir             break;
376cdf0e10cSrcweir         case 2: // release uno interface
377cdf0e10cSrcweir             (*pUnoI->release)( pUnoI );
378cdf0e10cSrcweir             *ppException = 0;
379cdf0e10cSrcweir             break;
380cdf0e10cSrcweir         case 0: // queryInterface() opt
381cdf0e10cSrcweir         {
382cdf0e10cSrcweir             typelib_TypeDescription * pTD = 0;
383cdf0e10cSrcweir             TYPELIB_DANGER_GET( &pTD, reinterpret_cast< Type * >( pArgs[0] )->getTypeLibType() );
384cdf0e10cSrcweir             if (pTD)
385cdf0e10cSrcweir             {
386cdf0e10cSrcweir                 uno_Interface * pInterface = 0;
387cdf0e10cSrcweir                 (*pThis->pBridge->pUnoEnv->getRegisteredInterface)(
388cdf0e10cSrcweir                     pThis->pBridge->pUnoEnv,
389cdf0e10cSrcweir                     (void **)&pInterface, pThis->oid.pData, (typelib_InterfaceTypeDescription *)pTD );
390cdf0e10cSrcweir 
391cdf0e10cSrcweir                 if (pInterface)
392cdf0e10cSrcweir                 {
393cdf0e10cSrcweir                     ::uno_any_construct(
394cdf0e10cSrcweir                         reinterpret_cast< uno_Any * >( pReturn ),
395cdf0e10cSrcweir                         &pInterface, pTD, 0 );
396cdf0e10cSrcweir                     (*pInterface->release)( pInterface );
397cdf0e10cSrcweir                     TYPELIB_DANGER_RELEASE( pTD );
398cdf0e10cSrcweir                     *ppException = 0;
399cdf0e10cSrcweir                     break;
400cdf0e10cSrcweir                 }
401cdf0e10cSrcweir                 TYPELIB_DANGER_RELEASE( pTD );
402cdf0e10cSrcweir             }
403cdf0e10cSrcweir         } // else perform queryInterface()
404cdf0e10cSrcweir         default:
405cdf0e10cSrcweir             // dependent dispatch
406cdf0e10cSrcweir             cpp_call(
407cdf0e10cSrcweir                 pThis, nVtableCall,
408cdf0e10cSrcweir                 ((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->pReturnTypeRef,
409cdf0e10cSrcweir                 ((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->nParams,
410cdf0e10cSrcweir                 ((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->pParams,
411cdf0e10cSrcweir                 pReturn, pArgs, ppException );
412cdf0e10cSrcweir         }
413cdf0e10cSrcweir         break;
414cdf0e10cSrcweir     }
415cdf0e10cSrcweir     default:
416cdf0e10cSrcweir     {
417cdf0e10cSrcweir         ::com::sun::star::uno::RuntimeException aExc(
418cdf0e10cSrcweir             OUString( RTL_CONSTASCII_USTRINGPARAM("illegal member type description!") ),
419cdf0e10cSrcweir             ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >() );
420cdf0e10cSrcweir 
421cdf0e10cSrcweir         Type const & rExcType = ::getCppuType( &aExc );
422cdf0e10cSrcweir         // binary identical null reference
423cdf0e10cSrcweir         ::uno_type_any_construct( *ppException, &aExc, rExcType.getTypeLibType(), 0 );
424cdf0e10cSrcweir     }
425cdf0e10cSrcweir     }
426cdf0e10cSrcweir }
427cdf0e10cSrcweir 
428cdf0e10cSrcweir }
429