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 "msci.hxx"
38cdf0e10cSrcweir 
39cdf0e10cSrcweir using namespace ::rtl;
40cdf0e10cSrcweir using namespace ::com::sun::star::uno;
41cdf0e10cSrcweir 
42cdf0e10cSrcweir namespace
43cdf0e10cSrcweir {
44cdf0e10cSrcweir 
45cdf0e10cSrcweir //==================================================================================================
callVirtualMethod(void * pAdjustedThisPtr,sal_Int32 nVtableIndex,void * pRegisterReturn,typelib_TypeClass eReturnTypeClass,sal_Int32 * pStackLongs,sal_Int32 nStackLongs)46cdf0e10cSrcweir inline static void callVirtualMethod(
47cdf0e10cSrcweir 	void * pAdjustedThisPtr, sal_Int32 nVtableIndex,
48cdf0e10cSrcweir 	void * pRegisterReturn, typelib_TypeClass eReturnTypeClass,
49cdf0e10cSrcweir 	sal_Int32 * pStackLongs, sal_Int32 nStackLongs )
50cdf0e10cSrcweir {
51cdf0e10cSrcweir 	// parameter list is mixed list of * and values
52cdf0e10cSrcweir 	// reference parameters are pointers
53cdf0e10cSrcweir 
54cdf0e10cSrcweir 	OSL_ENSURE( pStackLongs && pAdjustedThisPtr, "### null ptr!" );
55cdf0e10cSrcweir 	OSL_ENSURE( (sizeof(void *) == 4) &&
56cdf0e10cSrcweir 				 (sizeof(sal_Int32) == 4), "### unexpected size of int!" );
57cdf0e10cSrcweir 
58cdf0e10cSrcweir __asm
59cdf0e10cSrcweir 	{
60cdf0e10cSrcweir 		mov		eax, nStackLongs
61cdf0e10cSrcweir 		test	eax, eax
62cdf0e10cSrcweir 		je		Lcall
63cdf0e10cSrcweir 		// copy values
64cdf0e10cSrcweir 		mov		ecx, eax
65cdf0e10cSrcweir 		shl		eax, 2			 // sizeof(sal_Int32) == 4
66cdf0e10cSrcweir 		add		eax, pStackLongs // params stack space
67cdf0e10cSrcweir Lcopy:	sub		eax, 4
68cdf0e10cSrcweir 		push	dword ptr [eax]
69cdf0e10cSrcweir 		dec		ecx
70cdf0e10cSrcweir 		jne		Lcopy
71cdf0e10cSrcweir Lcall:
72cdf0e10cSrcweir 		// call
73cdf0e10cSrcweir 		mov		ecx, pAdjustedThisPtr
74cdf0e10cSrcweir 		push	ecx				// this ptr
75cdf0e10cSrcweir 		mov		edx, [ecx]		// pvft
76cdf0e10cSrcweir 		mov		eax, nVtableIndex
77cdf0e10cSrcweir 		shl		eax, 2			// sizeof(void *) == 4
78cdf0e10cSrcweir 		add		edx, eax
79cdf0e10cSrcweir 		call	[edx]			// interface method call must be __cdecl!!!
80cdf0e10cSrcweir 
81cdf0e10cSrcweir 		// register return
82cdf0e10cSrcweir 		mov		ecx, eReturnTypeClass
83cdf0e10cSrcweir 		cmp		ecx, typelib_TypeClass_VOID
84cdf0e10cSrcweir 		je		Lcleanup
85cdf0e10cSrcweir 		mov		ebx, pRegisterReturn
86cdf0e10cSrcweir // int32
87cdf0e10cSrcweir 		cmp		ecx, typelib_TypeClass_LONG
88cdf0e10cSrcweir 		je		Lint32
89cdf0e10cSrcweir 		cmp		ecx, typelib_TypeClass_UNSIGNED_LONG
90cdf0e10cSrcweir 		je		Lint32
91cdf0e10cSrcweir 		cmp		ecx, typelib_TypeClass_ENUM
92cdf0e10cSrcweir 		je		Lint32
93cdf0e10cSrcweir // int8
94cdf0e10cSrcweir 		cmp		ecx, typelib_TypeClass_BOOLEAN
95cdf0e10cSrcweir 		je		Lint8
96cdf0e10cSrcweir 		cmp		ecx, typelib_TypeClass_BYTE
97cdf0e10cSrcweir 		je		Lint8
98cdf0e10cSrcweir // int16
99cdf0e10cSrcweir 		cmp		ecx, typelib_TypeClass_CHAR
100cdf0e10cSrcweir 		je		Lint16
101cdf0e10cSrcweir 		cmp		ecx, typelib_TypeClass_SHORT
102cdf0e10cSrcweir 		je		Lint16
103cdf0e10cSrcweir 		cmp		ecx, typelib_TypeClass_UNSIGNED_SHORT
104cdf0e10cSrcweir 		je		Lint16
105cdf0e10cSrcweir // float
106cdf0e10cSrcweir 		cmp		ecx, typelib_TypeClass_FLOAT
107cdf0e10cSrcweir 		je		Lfloat
108cdf0e10cSrcweir // double
109cdf0e10cSrcweir 		cmp		ecx, typelib_TypeClass_DOUBLE
110cdf0e10cSrcweir 		je		Ldouble
111cdf0e10cSrcweir // int64
112cdf0e10cSrcweir 		cmp		ecx, typelib_TypeClass_HYPER
113cdf0e10cSrcweir 		je		Lint64
114cdf0e10cSrcweir 		cmp		ecx, typelib_TypeClass_UNSIGNED_HYPER
115cdf0e10cSrcweir   		je		Lint64
116cdf0e10cSrcweir 		jmp		Lcleanup // no simple type
117cdf0e10cSrcweir Lint8:
118cdf0e10cSrcweir 		mov		byte ptr [ebx], al
119cdf0e10cSrcweir 		jmp		Lcleanup
120cdf0e10cSrcweir Lint16:
121cdf0e10cSrcweir 		mov		word ptr [ebx], ax
122cdf0e10cSrcweir 		jmp		Lcleanup
123cdf0e10cSrcweir Lfloat:
124cdf0e10cSrcweir 		fstp	dword ptr [ebx]
125cdf0e10cSrcweir 		jmp		Lcleanup
126cdf0e10cSrcweir Ldouble:
127cdf0e10cSrcweir 		fstp	qword ptr [ebx]
128cdf0e10cSrcweir 		jmp		Lcleanup
129cdf0e10cSrcweir Lint64:
130cdf0e10cSrcweir 		mov		dword ptr [ebx], eax
131cdf0e10cSrcweir 		mov		dword ptr [ebx+4], edx
132cdf0e10cSrcweir 		jmp		Lcleanup
133cdf0e10cSrcweir Lint32:
134cdf0e10cSrcweir 		mov		dword ptr [ebx], eax
135cdf0e10cSrcweir 		jmp		Lcleanup
136cdf0e10cSrcweir Lcleanup:
137cdf0e10cSrcweir 		// cleanup stack (obsolete though because of function)
138cdf0e10cSrcweir 		mov		eax, nStackLongs
139cdf0e10cSrcweir 		shl		eax, 2			// sizeof(sal_Int32) == 4
140cdf0e10cSrcweir 		add		eax, 4			// this ptr
141cdf0e10cSrcweir 		add		esp, eax
142cdf0e10cSrcweir 	}
143cdf0e10cSrcweir }
144cdf0e10cSrcweir 
145cdf0e10cSrcweir //==================================================================================================
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)146cdf0e10cSrcweir static void cpp_call(
147cdf0e10cSrcweir 	bridges::cpp_uno::shared::UnoInterfaceProxy * pThis,
148cdf0e10cSrcweir 	bridges::cpp_uno::shared::VtableSlot aVtableSlot,
149cdf0e10cSrcweir 	typelib_TypeDescriptionReference * pReturnTypeRef,
150cdf0e10cSrcweir 	sal_Int32 nParams, typelib_MethodParameter * pParams,
151cdf0e10cSrcweir 	void * pUnoReturn, void * pUnoArgs[], uno_Any ** ppUnoExc ) throw ()
152cdf0e10cSrcweir {
153cdf0e10cSrcweir 	// max space for: [complex ret ptr], values|ptr ...
154cdf0e10cSrcweir 	char * pCppStack		= (char *)alloca( sizeof(sal_Int32) + (nParams * sizeof(sal_Int64)) );
155cdf0e10cSrcweir 	char * pCppStackStart	= pCppStack;
156cdf0e10cSrcweir 
157cdf0e10cSrcweir 	// return
158cdf0e10cSrcweir 	typelib_TypeDescription * pReturnTypeDescr = 0;
159cdf0e10cSrcweir 	TYPELIB_DANGER_GET( &pReturnTypeDescr, pReturnTypeRef );
160cdf0e10cSrcweir 	OSL_ENSURE( pReturnTypeDescr, "### expected return type description!" );
161cdf0e10cSrcweir 
162cdf0e10cSrcweir 	void * pCppReturn = 0; // if != 0 && != pUnoReturn, needs reconversion
163cdf0e10cSrcweir 
164cdf0e10cSrcweir 	if (pReturnTypeDescr)
165cdf0e10cSrcweir 	{
166cdf0e10cSrcweir 		if (bridges::cpp_uno::shared::isSimpleType( pReturnTypeDescr ))
167cdf0e10cSrcweir 		{
168cdf0e10cSrcweir 			pCppReturn = pUnoReturn; // direct way for simple types
169cdf0e10cSrcweir 		}
170cdf0e10cSrcweir 		else
171cdf0e10cSrcweir 		{
172cdf0e10cSrcweir 			// complex return via ptr
173cdf0e10cSrcweir 			pCppReturn = *(void **)pCppStack
174cdf0e10cSrcweir                 = (bridges::cpp_uno::shared::relatesToInterfaceType(
175cdf0e10cSrcweir                        pReturnTypeDescr )
176cdf0e10cSrcweir                    ? alloca( pReturnTypeDescr->nSize )
177cdf0e10cSrcweir                    : pUnoReturn); // direct way
178cdf0e10cSrcweir 			pCppStack += sizeof(void *);
179cdf0e10cSrcweir 		}
180cdf0e10cSrcweir 	}
181cdf0e10cSrcweir 
182cdf0e10cSrcweir 	// stack space
183cdf0e10cSrcweir 
184cdf0e10cSrcweir 	OSL_ENSURE( sizeof(void *) == sizeof(sal_Int32), "### unexpected size!" );
185cdf0e10cSrcweir 	// args
186cdf0e10cSrcweir 	void ** pCppArgs  = (void **)alloca( 3 * sizeof(void *) * nParams );
187cdf0e10cSrcweir 	// indizes of values this have to be converted (interface conversion cpp<=>uno)
188cdf0e10cSrcweir 	sal_Int32 * pTempIndizes = (sal_Int32 *)(pCppArgs + nParams);
189cdf0e10cSrcweir 	// type descriptions for reconversions
190cdf0e10cSrcweir 	typelib_TypeDescription ** ppTempParamTypeDescr = (typelib_TypeDescription **)(pCppArgs + (2 * nParams));
191cdf0e10cSrcweir 
192cdf0e10cSrcweir 	sal_Int32 nTempIndizes   = 0;
193cdf0e10cSrcweir 
194cdf0e10cSrcweir 	for ( sal_Int32 nPos = 0; nPos < nParams; ++nPos )
195cdf0e10cSrcweir 	{
196cdf0e10cSrcweir 		const typelib_MethodParameter & rParam = pParams[nPos];
197cdf0e10cSrcweir 		typelib_TypeDescription * pParamTypeDescr = 0;
198cdf0e10cSrcweir 		TYPELIB_DANGER_GET( &pParamTypeDescr, rParam.pTypeRef );
199cdf0e10cSrcweir 
200cdf0e10cSrcweir 		if (!rParam.bOut
201cdf0e10cSrcweir             && bridges::cpp_uno::shared::isSimpleType( pParamTypeDescr ))
202cdf0e10cSrcweir 		{
203cdf0e10cSrcweir 			::uno_copyAndConvertData(
204cdf0e10cSrcweir                 pCppArgs[nPos] = pCppStack, pUnoArgs[nPos], pParamTypeDescr,
205cdf0e10cSrcweir                 pThis->getBridge()->getUno2Cpp() );
206cdf0e10cSrcweir 
207cdf0e10cSrcweir 			switch (pParamTypeDescr->eTypeClass)
208cdf0e10cSrcweir 			{
209cdf0e10cSrcweir 			case typelib_TypeClass_HYPER:
210cdf0e10cSrcweir 			case typelib_TypeClass_UNSIGNED_HYPER:
211cdf0e10cSrcweir 			case typelib_TypeClass_DOUBLE:
212cdf0e10cSrcweir 				pCppStack += sizeof(sal_Int32); // extra long
213cdf0e10cSrcweir                 break;
214cdf0e10cSrcweir             default:
215cdf0e10cSrcweir                 break;
216cdf0e10cSrcweir 			}
217cdf0e10cSrcweir 			// no longer needed
218cdf0e10cSrcweir 			TYPELIB_DANGER_RELEASE( pParamTypeDescr );
219cdf0e10cSrcweir 		}
220cdf0e10cSrcweir 		else // ptr to complex value | ref
221cdf0e10cSrcweir 		{
222cdf0e10cSrcweir 			if (! rParam.bIn) // is pure out
223cdf0e10cSrcweir 			{
224cdf0e10cSrcweir 				// cpp out is constructed mem, uno out is not!
225cdf0e10cSrcweir 				::uno_constructData(
226cdf0e10cSrcweir 					*(void **)pCppStack = pCppArgs[nPos] = alloca( pParamTypeDescr->nSize ),
227cdf0e10cSrcweir 					pParamTypeDescr );
228cdf0e10cSrcweir 				pTempIndizes[nTempIndizes] = nPos; // default constructed for cpp call
229cdf0e10cSrcweir 				// will be released at reconversion
230cdf0e10cSrcweir 				ppTempParamTypeDescr[nTempIndizes++] = pParamTypeDescr;
231cdf0e10cSrcweir 			}
232cdf0e10cSrcweir 			// is in/inout
233cdf0e10cSrcweir 			else if (bridges::cpp_uno::shared::relatesToInterfaceType(
234cdf0e10cSrcweir                          pParamTypeDescr ))
235cdf0e10cSrcweir 			{
236cdf0e10cSrcweir 				::uno_copyAndConvertData(
237cdf0e10cSrcweir 					*(void **)pCppStack = pCppArgs[nPos] = alloca( pParamTypeDescr->nSize ),
238cdf0e10cSrcweir 					pUnoArgs[nPos], pParamTypeDescr,
239cdf0e10cSrcweir 					pThis->getBridge()->getUno2Cpp() );
240cdf0e10cSrcweir 
241cdf0e10cSrcweir 				pTempIndizes[nTempIndizes] = nPos; // has to be reconverted
242cdf0e10cSrcweir 				// will be released at reconversion
243cdf0e10cSrcweir 				ppTempParamTypeDescr[nTempIndizes++] = pParamTypeDescr;
244cdf0e10cSrcweir 			}
245cdf0e10cSrcweir 			else // direct way
246cdf0e10cSrcweir 			{
247cdf0e10cSrcweir 				*(void **)pCppStack = pCppArgs[nPos] = pUnoArgs[nPos];
248cdf0e10cSrcweir 				// no longer needed
249cdf0e10cSrcweir 				TYPELIB_DANGER_RELEASE( pParamTypeDescr );
250cdf0e10cSrcweir 			}
251cdf0e10cSrcweir 		}
252cdf0e10cSrcweir 		pCppStack += sizeof(sal_Int32); // standard parameter length
253cdf0e10cSrcweir 	}
254cdf0e10cSrcweir 
255cdf0e10cSrcweir     __try
256cdf0e10cSrcweir     {
257cdf0e10cSrcweir         // pCppI is msci this pointer
258cdf0e10cSrcweir         callVirtualMethod(
259cdf0e10cSrcweir             reinterpret_cast< void ** >(pThis->getCppI()) + aVtableSlot.offset,
260cdf0e10cSrcweir             aVtableSlot.index,
261cdf0e10cSrcweir             pCppReturn, pReturnTypeDescr->eTypeClass,
262cdf0e10cSrcweir             (sal_Int32 *)pCppStackStart,
263cdf0e10cSrcweir             (pCppStack - pCppStackStart) / sizeof(sal_Int32) );
264cdf0e10cSrcweir     }
265cdf0e10cSrcweir     __except (CPPU_CURRENT_NAMESPACE::msci_filterCppException(
266cdf0e10cSrcweir                   GetExceptionInformation(),
267cdf0e10cSrcweir                   *ppUnoExc, pThis->getBridge()->getCpp2Uno() ))
268cdf0e10cSrcweir    {
269cdf0e10cSrcweir         // *ppUnoExc was constructed by filter function
270cdf0e10cSrcweir         // temporary params
271cdf0e10cSrcweir         while (nTempIndizes--)
272cdf0e10cSrcweir         {
273cdf0e10cSrcweir             sal_Int32 nIndex = pTempIndizes[nTempIndizes];
274cdf0e10cSrcweir             // destroy temp cpp param => cpp: every param was constructed
275cdf0e10cSrcweir             ::uno_destructData(
276cdf0e10cSrcweir                 pCppArgs[nIndex], ppTempParamTypeDescr[nTempIndizes],
277cdf0e10cSrcweir                 cpp_release );
278cdf0e10cSrcweir             TYPELIB_DANGER_RELEASE( ppTempParamTypeDescr[nTempIndizes] );
279cdf0e10cSrcweir         }
280cdf0e10cSrcweir 		// return type
281cdf0e10cSrcweir 		if (pReturnTypeDescr)
282cdf0e10cSrcweir         {
283cdf0e10cSrcweir 			TYPELIB_DANGER_RELEASE( pReturnTypeDescr );
284cdf0e10cSrcweir         }
285cdf0e10cSrcweir         // end here
286cdf0e10cSrcweir         return;
287cdf0e10cSrcweir 	}
288cdf0e10cSrcweir 
289cdf0e10cSrcweir     // NO exception occured
290cdf0e10cSrcweir     *ppUnoExc = 0;
291cdf0e10cSrcweir 
292cdf0e10cSrcweir     // reconvert temporary params
293cdf0e10cSrcweir     while (nTempIndizes--)
294cdf0e10cSrcweir     {
295cdf0e10cSrcweir         sal_Int32 nIndex = pTempIndizes[nTempIndizes];
296cdf0e10cSrcweir         typelib_TypeDescription * pParamTypeDescr =
297cdf0e10cSrcweir             ppTempParamTypeDescr[nTempIndizes];
298cdf0e10cSrcweir 
299cdf0e10cSrcweir         if (pParams[nIndex].bIn)
300cdf0e10cSrcweir         {
301cdf0e10cSrcweir             if (pParams[nIndex].bOut) // inout
302cdf0e10cSrcweir             {
303cdf0e10cSrcweir                 ::uno_destructData(
304cdf0e10cSrcweir                     pUnoArgs[nIndex], pParamTypeDescr, 0 ); // destroy uno value
305cdf0e10cSrcweir                 ::uno_copyAndConvertData(
306cdf0e10cSrcweir                     pUnoArgs[nIndex], pCppArgs[nIndex], pParamTypeDescr,
307cdf0e10cSrcweir                     pThis->getBridge()->getCpp2Uno() );
308cdf0e10cSrcweir             }
309cdf0e10cSrcweir         }
310cdf0e10cSrcweir         else // pure out
311cdf0e10cSrcweir         {
312cdf0e10cSrcweir             ::uno_copyAndConvertData(
313cdf0e10cSrcweir                 pUnoArgs[nIndex], pCppArgs[nIndex], pParamTypeDescr,
314cdf0e10cSrcweir                 pThis->getBridge()->getCpp2Uno() );
315cdf0e10cSrcweir         }
316cdf0e10cSrcweir         // destroy temp cpp param => cpp: every param was constructed
317cdf0e10cSrcweir         ::uno_destructData(
318cdf0e10cSrcweir             pCppArgs[nIndex], pParamTypeDescr, cpp_release );
319cdf0e10cSrcweir 
320cdf0e10cSrcweir         TYPELIB_DANGER_RELEASE( pParamTypeDescr );
321cdf0e10cSrcweir     }
322cdf0e10cSrcweir     // return value
323cdf0e10cSrcweir     if (pCppReturn && pUnoReturn != pCppReturn)
324cdf0e10cSrcweir     {
325cdf0e10cSrcweir         ::uno_copyAndConvertData(
326cdf0e10cSrcweir             pUnoReturn, pCppReturn, pReturnTypeDescr,
327cdf0e10cSrcweir             pThis->getBridge()->getCpp2Uno() );
328cdf0e10cSrcweir         ::uno_destructData(
329cdf0e10cSrcweir             pCppReturn, pReturnTypeDescr, cpp_release );
330cdf0e10cSrcweir     }
331cdf0e10cSrcweir     // return type
332cdf0e10cSrcweir     if (pReturnTypeDescr)
333cdf0e10cSrcweir     {
334cdf0e10cSrcweir         TYPELIB_DANGER_RELEASE( pReturnTypeDescr );
335cdf0e10cSrcweir     }
336cdf0e10cSrcweir }
337cdf0e10cSrcweir 
338cdf0e10cSrcweir }
339cdf0e10cSrcweir 
340cdf0e10cSrcweir namespace bridges { namespace cpp_uno { namespace shared {
341cdf0e10cSrcweir 
unoInterfaceProxyDispatch(uno_Interface * pUnoI,const typelib_TypeDescription * pMemberDescr,void * pReturn,void * pArgs[],uno_Any ** ppException)342cdf0e10cSrcweir void unoInterfaceProxyDispatch(
343cdf0e10cSrcweir 	uno_Interface * pUnoI, const typelib_TypeDescription * pMemberDescr,
344cdf0e10cSrcweir     void * pReturn, void * pArgs[], uno_Any ** ppException )
345cdf0e10cSrcweir {
346cdf0e10cSrcweir 	// is my surrogate
347cdf0e10cSrcweir 	bridges::cpp_uno::shared::UnoInterfaceProxy * pThis
348cdf0e10cSrcweir         = static_cast< bridges::cpp_uno::shared::UnoInterfaceProxy * >(pUnoI);
349cdf0e10cSrcweir 
350cdf0e10cSrcweir 	switch (pMemberDescr->eTypeClass)
351cdf0e10cSrcweir 	{
352cdf0e10cSrcweir 	case typelib_TypeClass_INTERFACE_ATTRIBUTE:
353cdf0e10cSrcweir 	{
354cdf0e10cSrcweir         VtableSlot aVtableSlot(
355cdf0e10cSrcweir             getVtableSlot(
356cdf0e10cSrcweir                 reinterpret_cast<
357cdf0e10cSrcweir                     typelib_InterfaceAttributeTypeDescription const * >(
358cdf0e10cSrcweir                         pMemberDescr)));
359cdf0e10cSrcweir 		if (pReturn)
360cdf0e10cSrcweir 		{
361cdf0e10cSrcweir 			// dependent dispatch
362cdf0e10cSrcweir 			cpp_call(
363cdf0e10cSrcweir 				pThis, aVtableSlot,
364cdf0e10cSrcweir 				((typelib_InterfaceAttributeTypeDescription *)pMemberDescr)->pAttributeTypeRef,
365cdf0e10cSrcweir 				0, 0, // no params
366cdf0e10cSrcweir 				pReturn, pArgs, ppException );
367cdf0e10cSrcweir 		}
368cdf0e10cSrcweir 		else
369cdf0e10cSrcweir 		{
370cdf0e10cSrcweir 			// is SET
371cdf0e10cSrcweir 			typelib_MethodParameter aParam;
372cdf0e10cSrcweir 			aParam.pTypeRef =
373cdf0e10cSrcweir 				((typelib_InterfaceAttributeTypeDescription *)pMemberDescr)->pAttributeTypeRef;
374cdf0e10cSrcweir 			aParam.bIn		= sal_True;
375cdf0e10cSrcweir 			aParam.bOut		= sal_False;
376cdf0e10cSrcweir 
377cdf0e10cSrcweir 			typelib_TypeDescriptionReference * pReturnTypeRef = 0;
378cdf0e10cSrcweir 			OUString aVoidName( RTL_CONSTASCII_USTRINGPARAM("void") );
379cdf0e10cSrcweir 			typelib_typedescriptionreference_new(
380cdf0e10cSrcweir 				&pReturnTypeRef, typelib_TypeClass_VOID, aVoidName.pData );
381cdf0e10cSrcweir 
382cdf0e10cSrcweir 			// dependent dispatch
383cdf0e10cSrcweir             aVtableSlot.index += 1; // get, then set method
384cdf0e10cSrcweir 			cpp_call(
385cdf0e10cSrcweir 				pThis, aVtableSlot,
386cdf0e10cSrcweir 				pReturnTypeRef,
387cdf0e10cSrcweir 				1, &aParam,
388cdf0e10cSrcweir 				pReturn, pArgs, ppException );
389cdf0e10cSrcweir 
390cdf0e10cSrcweir 			typelib_typedescriptionreference_release( pReturnTypeRef );
391cdf0e10cSrcweir 		}
392cdf0e10cSrcweir 
393cdf0e10cSrcweir 		break;
394cdf0e10cSrcweir 	}
395cdf0e10cSrcweir 	case typelib_TypeClass_INTERFACE_METHOD:
396cdf0e10cSrcweir 	{
397cdf0e10cSrcweir         VtableSlot aVtableSlot(
398cdf0e10cSrcweir             getVtableSlot(
399cdf0e10cSrcweir                 reinterpret_cast<
400cdf0e10cSrcweir                     typelib_InterfaceMethodTypeDescription const * >(
401cdf0e10cSrcweir                         pMemberDescr)));
402cdf0e10cSrcweir 		switch (aVtableSlot.index)
403cdf0e10cSrcweir 		{
404cdf0e10cSrcweir 			// standard calls
405cdf0e10cSrcweir 		case 1: // acquire uno interface
406cdf0e10cSrcweir 			(*pUnoI->acquire)( pUnoI );
407cdf0e10cSrcweir 			*ppException = 0;
408cdf0e10cSrcweir 			break;
409cdf0e10cSrcweir 		case 2: // release uno interface
410cdf0e10cSrcweir 			(*pUnoI->release)( pUnoI );
411cdf0e10cSrcweir 			*ppException = 0;
412cdf0e10cSrcweir 			break;
413cdf0e10cSrcweir 		case 0: // queryInterface() opt
414cdf0e10cSrcweir 		{
415cdf0e10cSrcweir 			typelib_TypeDescription * pTD = 0;
416cdf0e10cSrcweir 			TYPELIB_DANGER_GET( &pTD, reinterpret_cast< Type * >( pArgs[0] )->getTypeLibType() );
417cdf0e10cSrcweir 			if (pTD)
418cdf0e10cSrcweir             {
419cdf0e10cSrcweir                 uno_Interface * pInterface = 0;
420cdf0e10cSrcweir                 (*pThis->pBridge->getUnoEnv()->getRegisteredInterface)(
421cdf0e10cSrcweir                     pThis->pBridge->getUnoEnv(),
422cdf0e10cSrcweir                     (void **)&pInterface, pThis->oid.pData, (typelib_InterfaceTypeDescription *)pTD );
423cdf0e10cSrcweir 
424cdf0e10cSrcweir                 if (pInterface)
425cdf0e10cSrcweir                 {
426cdf0e10cSrcweir                     ::uno_any_construct(
427cdf0e10cSrcweir                         reinterpret_cast< uno_Any * >( pReturn ),
428cdf0e10cSrcweir                         &pInterface, pTD, 0 );
429cdf0e10cSrcweir                     (*pInterface->release)( pInterface );
430cdf0e10cSrcweir                     TYPELIB_DANGER_RELEASE( pTD );
431cdf0e10cSrcweir                     *ppException = 0;
432cdf0e10cSrcweir                     break;
433cdf0e10cSrcweir                 }
434cdf0e10cSrcweir                 TYPELIB_DANGER_RELEASE( pTD );
435cdf0e10cSrcweir             }
436cdf0e10cSrcweir 		} // else perform queryInterface()
437cdf0e10cSrcweir 		default:
438cdf0e10cSrcweir 			// dependent dispatch
439cdf0e10cSrcweir 			cpp_call(
440cdf0e10cSrcweir 				pThis, aVtableSlot,
441cdf0e10cSrcweir 				((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->pReturnTypeRef,
442cdf0e10cSrcweir 				((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->nParams,
443cdf0e10cSrcweir 				((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->pParams,
444cdf0e10cSrcweir 				pReturn, pArgs, ppException );
445cdf0e10cSrcweir 		}
446cdf0e10cSrcweir 		break;
447cdf0e10cSrcweir 	}
448cdf0e10cSrcweir 	default:
449cdf0e10cSrcweir 	{
450cdf0e10cSrcweir 		::com::sun::star::uno::RuntimeException aExc(
451cdf0e10cSrcweir 			OUString( RTL_CONSTASCII_USTRINGPARAM("illegal member type description!") ),
452cdf0e10cSrcweir 			::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >() );
453cdf0e10cSrcweir 
454cdf0e10cSrcweir 		Type const & rExcType = ::getCppuType( &aExc );
455cdf0e10cSrcweir 		// binary identical null reference
456cdf0e10cSrcweir 		::uno_type_any_construct( *ppException, &aExc, rExcType.getTypeLibType(), 0 );
457cdf0e10cSrcweir 	}
458cdf0e10cSrcweir 	}
459cdf0e10cSrcweir }
460cdf0e10cSrcweir 
461cdf0e10cSrcweir } } }
462