xref: /trunk/main/bridges/source/cpp_uno/cc50_solaris_sparc/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 
29cdf0e10cSrcweir #include <com/sun/star/uno/genfunc.hxx>
30cdf0e10cSrcweir #include "com/sun/star/uno/RuntimeException.hpp"
31cdf0e10cSrcweir #include <uno/data.h>
32cdf0e10cSrcweir 
33cdf0e10cSrcweir #include "bridges/cpp_uno/shared/bridge.hxx"
34cdf0e10cSrcweir #include "bridges/cpp_uno/shared/types.hxx"
35cdf0e10cSrcweir #include "bridges/cpp_uno/shared/unointerfaceproxy.hxx"
36cdf0e10cSrcweir #include "bridges/cpp_uno/shared/vtables.hxx"
37cdf0e10cSrcweir 
38cdf0e10cSrcweir #include "cc50_solaris_sparc.hxx"
39cdf0e10cSrcweir 
40cdf0e10cSrcweir using namespace rtl;
41cdf0e10cSrcweir using namespace com::sun::star::uno;
42cdf0e10cSrcweir 
43cdf0e10cSrcweir namespace
44cdf0e10cSrcweir {
45cdf0e10cSrcweir 
46cdf0e10cSrcweir extern "C" void callVirtualMethod(
47cdf0e10cSrcweir         void * pAdjustedThisPtr,
48cdf0e10cSrcweir         sal_Int32 nVtableIndex,
49cdf0e10cSrcweir         void * pRegisterReturn,
50cdf0e10cSrcweir         typelib_TypeClass eReturnType,
51cdf0e10cSrcweir         sal_Int32 * pStackLongs,
52cdf0e10cSrcweir         sal_Int32 nStackLongs
53cdf0e10cSrcweir     );
54cdf0e10cSrcweir 
55cdf0e10cSrcweir //==================================================================================================
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)56cdf0e10cSrcweir static void cpp_call(
57cdf0e10cSrcweir     bridges::cpp_uno::shared::UnoInterfaceProxy * pThis,
58cdf0e10cSrcweir     bridges::cpp_uno::shared::VtableSlot aVtableSlot,
59cdf0e10cSrcweir     typelib_TypeDescriptionReference * pReturnTypeRef,
60cdf0e10cSrcweir     sal_Int32 nParams, typelib_MethodParameter * pParams,
61cdf0e10cSrcweir     void * pUnoReturn, void * pUnoArgs[], uno_Any ** ppUnoExc )
62cdf0e10cSrcweir {
63cdf0e10cSrcweir     // pCppI is cc50_solaris_sparc this pointer
64cdf0e10cSrcweir     OSL_ENSURE( pThis, "### no interface given!" );
65cdf0e10cSrcweir 
66cdf0e10cSrcweir     // max space for: [complex ret ptr], values|ptr ...
67cdf0e10cSrcweir     char * pCppStack        = (char *)alloca( ((nParams+3) * sizeof(sal_Int64)) );
68cdf0e10cSrcweir     char * pCppStackStart   = pCppStack;
69cdf0e10cSrcweir 
70cdf0e10cSrcweir     // return
71cdf0e10cSrcweir     typelib_TypeDescription * pReturnTypeDescr = 0;
72cdf0e10cSrcweir     TYPELIB_DANGER_GET( &pReturnTypeDescr, pReturnTypeRef );
73cdf0e10cSrcweir     OSL_ENSURE( pReturnTypeDescr, "### expected return type description!" );
74cdf0e10cSrcweir 
75cdf0e10cSrcweir     void * pCppReturn = 0; // if != 0 && != pUnoReturn, needs reconversion
76cdf0e10cSrcweir 
77cdf0e10cSrcweir     if (pReturnTypeDescr)
78cdf0e10cSrcweir     {
79cdf0e10cSrcweir         if (bridges::cpp_uno::shared::isSimpleType( pReturnTypeDescr ))
80cdf0e10cSrcweir         {
81cdf0e10cSrcweir             pCppReturn = pUnoReturn; // direct way for simple types
82cdf0e10cSrcweir         }
83cdf0e10cSrcweir         else
84cdf0e10cSrcweir         {
85cdf0e10cSrcweir             // complex return via ptr
86cdf0e10cSrcweir             pCppReturn = *(void **)pCppStack
87cdf0e10cSrcweir                 = (bridges::cpp_uno::shared::relatesToInterfaceType(
88cdf0e10cSrcweir                        pReturnTypeDescr )
89cdf0e10cSrcweir                    ? alloca( pReturnTypeDescr->nSize )
90cdf0e10cSrcweir                    : pUnoReturn); // direct way
91cdf0e10cSrcweir             pCppStack += sizeof(void *);
92cdf0e10cSrcweir         }
93cdf0e10cSrcweir     }
94cdf0e10cSrcweir     // push this
95cdf0e10cSrcweir     void * pAdjustedThisPtr = reinterpret_cast< void ** >(pThis->getCppI())
96cdf0e10cSrcweir         + aVtableSlot.offset;
97cdf0e10cSrcweir     *(void**)pCppStack = pAdjustedThisPtr;
98cdf0e10cSrcweir     pCppStack += sizeof( void* );
99cdf0e10cSrcweir 
100cdf0e10cSrcweir     // args
101cdf0e10cSrcweir     void ** pCppArgs  = (void **)alloca( 3 * sizeof(void *) * nParams );
102cdf0e10cSrcweir     // indizes of values this have to be converted (interface conversion cpp<=>uno)
103cdf0e10cSrcweir     sal_Int32 * pTempIndizes = (sal_Int32 *)(pCppArgs + nParams);
104cdf0e10cSrcweir     // type descriptions for reconversions
105cdf0e10cSrcweir     typelib_TypeDescription ** ppTempParamTypeDescr = (typelib_TypeDescription **)(pCppArgs + (2 * nParams));
106cdf0e10cSrcweir 
107cdf0e10cSrcweir     sal_Int32 nTempIndizes   = 0;
108cdf0e10cSrcweir 
109cdf0e10cSrcweir     for ( sal_Int32 nPos = 0; nPos < nParams; ++nPos )
110cdf0e10cSrcweir     {
111cdf0e10cSrcweir         const typelib_MethodParameter & rParam = pParams[nPos];
112cdf0e10cSrcweir         typelib_TypeDescription * pParamTypeDescr = 0;
113cdf0e10cSrcweir         TYPELIB_DANGER_GET( &pParamTypeDescr, rParam.pTypeRef );
114cdf0e10cSrcweir 
115cdf0e10cSrcweir         if (!rParam.bOut
116cdf0e10cSrcweir             && bridges::cpp_uno::shared::isSimpleType( pParamTypeDescr ))
117cdf0e10cSrcweir         {
118cdf0e10cSrcweir             pCppArgs[ nPos ] = CPPU_CURRENT_NAMESPACE::adjustPointer(
119cdf0e10cSrcweir                 pCppStack, pParamTypeDescr );
120cdf0e10cSrcweir             uno_copyAndConvertData( pCppArgs[nPos], pUnoArgs[nPos], pParamTypeDescr,
121cdf0e10cSrcweir                                     pThis->getBridge()->getUno2Cpp() );
122cdf0e10cSrcweir 
123cdf0e10cSrcweir             switch (pParamTypeDescr->eTypeClass)
124cdf0e10cSrcweir             {
125cdf0e10cSrcweir             case typelib_TypeClass_HYPER:
126cdf0e10cSrcweir             case typelib_TypeClass_UNSIGNED_HYPER:
127cdf0e10cSrcweir             case typelib_TypeClass_DOUBLE:
128cdf0e10cSrcweir                 pCppStack += sizeof(sal_Int32); // extra long
129cdf0e10cSrcweir             }
130cdf0e10cSrcweir             // no longer needed
131cdf0e10cSrcweir             TYPELIB_DANGER_RELEASE( pParamTypeDescr );
132cdf0e10cSrcweir         }
133cdf0e10cSrcweir         else // ptr to complex value | ref
134cdf0e10cSrcweir         {
135cdf0e10cSrcweir             if (! rParam.bIn) // is pure out
136cdf0e10cSrcweir             {
137cdf0e10cSrcweir                 // cpp out is constructed mem, uno out is not!
138cdf0e10cSrcweir                 uno_constructData(
139cdf0e10cSrcweir                     *(void **)pCppStack = pCppArgs[nPos] = alloca( pParamTypeDescr->nSize ),
140cdf0e10cSrcweir                     pParamTypeDescr );
141cdf0e10cSrcweir                 pTempIndizes[nTempIndizes] = nPos; // default constructed for cpp call
142cdf0e10cSrcweir                 // will be released at reconversion
143cdf0e10cSrcweir                 ppTempParamTypeDescr[nTempIndizes++] = pParamTypeDescr;
144cdf0e10cSrcweir             }
145cdf0e10cSrcweir             // is in/inout
146cdf0e10cSrcweir             else if (bridges::cpp_uno::shared::relatesToInterfaceType(
147cdf0e10cSrcweir                          pParamTypeDescr ))
148cdf0e10cSrcweir             {
149cdf0e10cSrcweir                 uno_copyAndConvertData(
150cdf0e10cSrcweir                     *(void **)pCppStack = pCppArgs[nPos] = alloca( pParamTypeDescr->nSize ),
151cdf0e10cSrcweir                     pUnoArgs[nPos], pParamTypeDescr,
152cdf0e10cSrcweir                     pThis->getBridge()->getUno2Cpp() );
153cdf0e10cSrcweir 
154cdf0e10cSrcweir                 pTempIndizes[nTempIndizes] = nPos; // has to be reconverted
155cdf0e10cSrcweir                 // will be released at reconversion
156cdf0e10cSrcweir                 ppTempParamTypeDescr[nTempIndizes++] = pParamTypeDescr;
157cdf0e10cSrcweir             }
158cdf0e10cSrcweir             else // direct way
159cdf0e10cSrcweir             {
160cdf0e10cSrcweir                 *(void **)pCppStack = pCppArgs[nPos] = pUnoArgs[nPos];
161cdf0e10cSrcweir                 // no longer needed
162cdf0e10cSrcweir                 TYPELIB_DANGER_RELEASE( pParamTypeDescr );
163cdf0e10cSrcweir             }
164cdf0e10cSrcweir         }
165cdf0e10cSrcweir         pCppStack += sizeof(sal_Int32); // standard parameter length
166cdf0e10cSrcweir     }
167cdf0e10cSrcweir 
168cdf0e10cSrcweir // seems that EH registration for callVirtualMethod is not really
169cdf0e10cSrcweir // necessary
170cdf0e10cSrcweir 
171cdf0e10cSrcweir //  static unsigned long* pFrameInfo = NULL;
172cdf0e10cSrcweir 
173cdf0e10cSrcweir //  if( ! pFrameInfo )
174cdf0e10cSrcweir //  {
175cdf0e10cSrcweir //      pFrameInfo = new unsigned long[ 7 ];
176cdf0e10cSrcweir //      pFrameInfo[ 0 ] = 0x40000000 | (((unsigned long)__Crun::ex_rethrow_q) >> 2);
177cdf0e10cSrcweir //      pFrameInfo[ 1 ] = 0x01000000;
178cdf0e10cSrcweir //      pFrameInfo[ 2 ] = (unsigned long)callVirtualMethodExceptionHandler;
179cdf0e10cSrcweir //      pFrameInfo[ 3 ] = 0;
180cdf0e10cSrcweir //          pFrameInfo[ 4 ] = (unsigned long)pFrameInfo - (unsigned long)callVirtualMethodExceptionHandler;
181cdf0e10cSrcweir //      pFrameInfo[ 5 ] = 0;
182cdf0e10cSrcweir //      pFrameInfo[ 6 ] = 0;
183cdf0e10cSrcweir //      _ex_register( pFrameInfo+2, 1 );
184cdf0e10cSrcweir //  }
185cdf0e10cSrcweir 
186cdf0e10cSrcweir     try
187cdf0e10cSrcweir     {
188cdf0e10cSrcweir         int nStackLongs = (pCppStack - pCppStackStart)/sizeof(sal_Int32);
189cdf0e10cSrcweir         if( nStackLongs & 1 )
190cdf0e10cSrcweir             // stack has to be 8 byte aligned
191cdf0e10cSrcweir             nStackLongs++;
192cdf0e10cSrcweir 
193cdf0e10cSrcweir         callVirtualMethod(
194cdf0e10cSrcweir             pAdjustedThisPtr,
195cdf0e10cSrcweir             aVtableSlot.index,
196cdf0e10cSrcweir             pCppReturn,
197cdf0e10cSrcweir             pReturnTypeDescr->eTypeClass,
198cdf0e10cSrcweir             (sal_Int32 *)pCppStackStart,
199cdf0e10cSrcweir             nStackLongs
200cdf0e10cSrcweir             );
201cdf0e10cSrcweir 
202*07a3d7f1SPedro Giffuni         // NO exception occurred...
203cdf0e10cSrcweir         *ppUnoExc = 0;
204cdf0e10cSrcweir 
205cdf0e10cSrcweir         // reconvert temporary params
206cdf0e10cSrcweir         for ( ; nTempIndizes--; )
207cdf0e10cSrcweir         {
208cdf0e10cSrcweir             sal_Int32 nIndex = pTempIndizes[nTempIndizes];
209cdf0e10cSrcweir             typelib_TypeDescription * pParamTypeDescr = ppTempParamTypeDescr[nTempIndizes];
210cdf0e10cSrcweir 
211cdf0e10cSrcweir             if (pParams[nIndex].bIn)
212cdf0e10cSrcweir             {
213cdf0e10cSrcweir                 if (pParams[nIndex].bOut) // inout
214cdf0e10cSrcweir                 {
215cdf0e10cSrcweir                     uno_destructData( pUnoArgs[nIndex], pParamTypeDescr, 0 ); // destroy uno value
216cdf0e10cSrcweir                     uno_copyAndConvertData( pUnoArgs[nIndex], pCppArgs[nIndex], pParamTypeDescr,
217cdf0e10cSrcweir                                             pThis->getBridge()->getCpp2Uno() );
218cdf0e10cSrcweir                 }
219cdf0e10cSrcweir             }
220cdf0e10cSrcweir             else // pure out
221cdf0e10cSrcweir             {
222cdf0e10cSrcweir                 uno_copyAndConvertData( pUnoArgs[nIndex], pCppArgs[nIndex], pParamTypeDescr,
223cdf0e10cSrcweir                                         pThis->getBridge()->getCpp2Uno() );
224cdf0e10cSrcweir             }
225cdf0e10cSrcweir             // destroy temp cpp param => cpp: every param was constructed
226cdf0e10cSrcweir             uno_destructData(
227cdf0e10cSrcweir                 pCppArgs[nIndex], pParamTypeDescr,
228cdf0e10cSrcweir                 reinterpret_cast< uno_ReleaseFunc >(cpp_release) );
229cdf0e10cSrcweir 
230cdf0e10cSrcweir             TYPELIB_DANGER_RELEASE( pParamTypeDescr );
231cdf0e10cSrcweir         }
232cdf0e10cSrcweir         // return value
233cdf0e10cSrcweir         if (pCppReturn && pUnoReturn != pCppReturn)
234cdf0e10cSrcweir         {
235cdf0e10cSrcweir             uno_copyAndConvertData( pUnoReturn, pCppReturn, pReturnTypeDescr,
236cdf0e10cSrcweir                                     pThis->getBridge()->getCpp2Uno() );
237cdf0e10cSrcweir             uno_destructData(
238cdf0e10cSrcweir                 pCppReturn, pReturnTypeDescr,
239cdf0e10cSrcweir                 reinterpret_cast< uno_ReleaseFunc >(cpp_release) );
240cdf0e10cSrcweir         }
241cdf0e10cSrcweir     }
242cdf0e10cSrcweir     catch( ... )
243cdf0e10cSrcweir     {
244cdf0e10cSrcweir         void* pExc = __Crun::ex_get();
245cdf0e10cSrcweir         const char* pName = __Cimpl::ex_name();
246cdf0e10cSrcweir 
247cdf0e10cSrcweir         // get exception
248cdf0e10cSrcweir         CPPU_CURRENT_NAMESPACE::cc50_solaris_sparc_fillUnoException(
249cdf0e10cSrcweir             pExc, pName, *ppUnoExc, pThis->getBridge()->getCpp2Uno());
250cdf0e10cSrcweir 
251cdf0e10cSrcweir         // temporary params
252cdf0e10cSrcweir         for ( ; nTempIndizes--; )
253cdf0e10cSrcweir         {
254cdf0e10cSrcweir             sal_Int32 nIndex = pTempIndizes[nTempIndizes];
255cdf0e10cSrcweir             // destroy temp cpp param => cpp: every param was constructed
256cdf0e10cSrcweir             uno_destructData(
257cdf0e10cSrcweir                 pCppArgs[nIndex],
258cdf0e10cSrcweir                 ppTempParamTypeDescr[nTempIndizes],
259cdf0e10cSrcweir                 reinterpret_cast< uno_ReleaseFunc >(cpp_release) );
260cdf0e10cSrcweir             TYPELIB_DANGER_RELEASE( ppTempParamTypeDescr[nTempIndizes] );
261cdf0e10cSrcweir         }
262cdf0e10cSrcweir         // return type
263cdf0e10cSrcweir         if (pReturnTypeDescr)
264cdf0e10cSrcweir             TYPELIB_DANGER_RELEASE( pReturnTypeDescr );
265cdf0e10cSrcweir     }
266cdf0e10cSrcweir }
267cdf0e10cSrcweir 
268cdf0e10cSrcweir }
269cdf0e10cSrcweir 
270cdf0e10cSrcweir namespace bridges { namespace cpp_uno { namespace shared {
271cdf0e10cSrcweir 
unoInterfaceProxyDispatch(uno_Interface * pUnoI,const typelib_TypeDescription * pMemberDescr,void * pReturn,void * pArgs[],uno_Any ** ppException)272cdf0e10cSrcweir void unoInterfaceProxyDispatch(
273cdf0e10cSrcweir     uno_Interface * pUnoI, const typelib_TypeDescription * pMemberDescr,
274cdf0e10cSrcweir     void * pReturn, void * pArgs[], uno_Any ** ppException )
275cdf0e10cSrcweir {
276cdf0e10cSrcweir     // is my surrogate
277cdf0e10cSrcweir     bridges::cpp_uno::shared::UnoInterfaceProxy * pThis
278cdf0e10cSrcweir         = static_cast< bridges::cpp_uno::shared::UnoInterfaceProxy * >(pUnoI);
279cdf0e10cSrcweir     typelib_InterfaceTypeDescription * pTypeDescr = pThis->pTypeDescr;
280cdf0e10cSrcweir 
281cdf0e10cSrcweir     switch (pMemberDescr->eTypeClass)
282cdf0e10cSrcweir     {
283cdf0e10cSrcweir     case typelib_TypeClass_INTERFACE_ATTRIBUTE:
284cdf0e10cSrcweir     {
285cdf0e10cSrcweir         VtableSlot aVtableSlot(
286cdf0e10cSrcweir             getVtableSlot(
287cdf0e10cSrcweir                 reinterpret_cast<
288cdf0e10cSrcweir                     typelib_InterfaceAttributeTypeDescription const * >(
289cdf0e10cSrcweir                         pMemberDescr)));
290cdf0e10cSrcweir         if (pReturn)
291cdf0e10cSrcweir         {
292cdf0e10cSrcweir             // dependent dispatch
293cdf0e10cSrcweir             cpp_call(
294cdf0e10cSrcweir                 pThis, aVtableSlot,
295cdf0e10cSrcweir                 ((typelib_InterfaceAttributeTypeDescription *)pMemberDescr)->pAttributeTypeRef,
296cdf0e10cSrcweir                 0, 0, // no params
297cdf0e10cSrcweir                 pReturn, pArgs, ppException );
298cdf0e10cSrcweir         }
299cdf0e10cSrcweir         else
300cdf0e10cSrcweir         {
301cdf0e10cSrcweir             // is SET
302cdf0e10cSrcweir             typelib_MethodParameter aParam;
303cdf0e10cSrcweir             aParam.pTypeRef =
304cdf0e10cSrcweir                 ((typelib_InterfaceAttributeTypeDescription *)pMemberDescr)->pAttributeTypeRef;
305cdf0e10cSrcweir             aParam.bIn      = sal_True;
306cdf0e10cSrcweir             aParam.bOut     = sal_False;
307cdf0e10cSrcweir 
308cdf0e10cSrcweir             typelib_TypeDescriptionReference * pReturnTypeRef = 0;
309cdf0e10cSrcweir             OUString aVoidName( RTL_CONSTASCII_USTRINGPARAM("void") );
310cdf0e10cSrcweir             typelib_typedescriptionreference_new(
311cdf0e10cSrcweir                 &pReturnTypeRef, typelib_TypeClass_VOID, aVoidName.pData );
312cdf0e10cSrcweir 
313cdf0e10cSrcweir             // dependent dispatch
314cdf0e10cSrcweir             aVtableSlot.index += 1; // get, then set method
315cdf0e10cSrcweir             cpp_call(
316cdf0e10cSrcweir                 pThis, aVtableSlot,
317cdf0e10cSrcweir                 pReturnTypeRef,
318cdf0e10cSrcweir                 1, &aParam,
319cdf0e10cSrcweir                 pReturn, pArgs, ppException );
320cdf0e10cSrcweir 
321cdf0e10cSrcweir             typelib_typedescriptionreference_release( pReturnTypeRef );
322cdf0e10cSrcweir         }
323cdf0e10cSrcweir 
324cdf0e10cSrcweir         break;
325cdf0e10cSrcweir     }
326cdf0e10cSrcweir     case typelib_TypeClass_INTERFACE_METHOD:
327cdf0e10cSrcweir     {
328cdf0e10cSrcweir         VtableSlot aVtableSlot(
329cdf0e10cSrcweir             getVtableSlot(
330cdf0e10cSrcweir                 reinterpret_cast<
331cdf0e10cSrcweir                     typelib_InterfaceMethodTypeDescription const * >(
332cdf0e10cSrcweir                         pMemberDescr)));
333cdf0e10cSrcweir         switch (aVtableSlot.index)
334cdf0e10cSrcweir         {
335cdf0e10cSrcweir             // standard calls
336cdf0e10cSrcweir         case 1: // acquire uno interface
337cdf0e10cSrcweir             (*pUnoI->acquire)( pUnoI );
338cdf0e10cSrcweir             *ppException = 0;
339cdf0e10cSrcweir             break;
340cdf0e10cSrcweir         case 2: // release uno interface
341cdf0e10cSrcweir             (*pUnoI->release)( pUnoI );
342cdf0e10cSrcweir             *ppException = 0;
343cdf0e10cSrcweir             break;
344cdf0e10cSrcweir         case 0: // queryInterface() opt
345cdf0e10cSrcweir         {
346cdf0e10cSrcweir             typelib_TypeDescription * pTD = 0;
347cdf0e10cSrcweir             TYPELIB_DANGER_GET( &pTD, reinterpret_cast< Type * >( pArgs[0] )->getTypeLibType() );
348cdf0e10cSrcweir             if (pTD)
349cdf0e10cSrcweir             {
350cdf0e10cSrcweir                 uno_Interface * pInterface = 0;
351cdf0e10cSrcweir                 (*pThis->pBridge->getUnoEnv()->getRegisteredInterface)(
352cdf0e10cSrcweir                     pThis->pBridge->getUnoEnv(),
353cdf0e10cSrcweir                     (void **)&pInterface, pThis->oid.pData, (typelib_InterfaceTypeDescription *)pTD );
354cdf0e10cSrcweir 
355cdf0e10cSrcweir                 if (pInterface)
356cdf0e10cSrcweir                 {
357cdf0e10cSrcweir                     ::uno_any_construct(
358cdf0e10cSrcweir                         reinterpret_cast< uno_Any * >( pReturn ),
359cdf0e10cSrcweir                         &pInterface, pTD, 0 );
360cdf0e10cSrcweir                     (*pInterface->release)( pInterface );
361cdf0e10cSrcweir                     TYPELIB_DANGER_RELEASE( pTD );
362cdf0e10cSrcweir                     *ppException = 0;
363cdf0e10cSrcweir                     break;
364cdf0e10cSrcweir                 }
365cdf0e10cSrcweir                 TYPELIB_DANGER_RELEASE( pTD );
366cdf0e10cSrcweir             }
367cdf0e10cSrcweir         } // else perform queryInterface()
368cdf0e10cSrcweir         default:
369cdf0e10cSrcweir             // dependent dispatch
370cdf0e10cSrcweir             cpp_call(
371cdf0e10cSrcweir                 pThis, aVtableSlot,
372cdf0e10cSrcweir                 ((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->pReturnTypeRef,
373cdf0e10cSrcweir                 ((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->nParams,
374cdf0e10cSrcweir                 ((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->pParams,
375cdf0e10cSrcweir                 pReturn, pArgs, ppException );
376cdf0e10cSrcweir         }
377cdf0e10cSrcweir         break;
378cdf0e10cSrcweir     }
379cdf0e10cSrcweir     default:
380cdf0e10cSrcweir     {
381cdf0e10cSrcweir         ::com::sun::star::uno::RuntimeException aExc(
382cdf0e10cSrcweir             OUString( RTL_CONSTASCII_USTRINGPARAM("illegal member type description!") ),
383cdf0e10cSrcweir             ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >() );
384cdf0e10cSrcweir 
385cdf0e10cSrcweir         Type const & rExcType = ::getCppuType( &aExc );
386cdf0e10cSrcweir         // binary identical null reference
387cdf0e10cSrcweir         ::uno_type_any_construct( *ppException, &aExc, rExcType.getTypeLibType(), 0 );
388cdf0e10cSrcweir     }
389cdf0e10cSrcweir     }
390cdf0e10cSrcweir }
391cdf0e10cSrcweir 
392cdf0e10cSrcweir } } }
393