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 <string.h>
28cdf0e10cSrcweir
29cdf0e10cSrcweir #include <com/sun/star/uno/genfunc.hxx>
30cdf0e10cSrcweir #include <uno/data.h>
31cdf0e10cSrcweir #include <typelib/typedescription.hxx>
32cdf0e10cSrcweir
33cdf0e10cSrcweir #include "bridges/cpp_uno/shared/bridge.hxx"
34cdf0e10cSrcweir #include "bridges/cpp_uno/shared/cppinterfaceproxy.hxx"
35cdf0e10cSrcweir #include "bridges/cpp_uno/shared/types.hxx"
36cdf0e10cSrcweir #include "bridges/cpp_uno/shared/vtablefactory.hxx"
37cdf0e10cSrcweir
38cdf0e10cSrcweir #include "share.hxx"
39cdf0e10cSrcweir // #include <stdio.h>
40cdf0e10cSrcweir
41cdf0e10cSrcweir
42cdf0e10cSrcweir using namespace ::com::sun::star::uno;
43cdf0e10cSrcweir
44cdf0e10cSrcweir namespace
45cdf0e10cSrcweir {
46cdf0e10cSrcweir
47cdf0e10cSrcweir //==================================================================================================
cpp2uno_call(bridges::cpp_uno::shared::CppInterfaceProxy * pThis,const typelib_TypeDescription * pMemberTypeDescr,typelib_TypeDescriptionReference * pReturnTypeRef,sal_Int32 nParams,typelib_MethodParameter * pParams,void ** gpreg,void ** fpreg,void ** ovrflw,sal_Int64 * pRegisterReturn)48cdf0e10cSrcweir static typelib_TypeClass cpp2uno_call(
49cdf0e10cSrcweir bridges::cpp_uno::shared::CppInterfaceProxy * pThis,
50cdf0e10cSrcweir const typelib_TypeDescription * pMemberTypeDescr,
51cdf0e10cSrcweir typelib_TypeDescriptionReference * pReturnTypeRef, // 0 indicates void return
52cdf0e10cSrcweir sal_Int32 nParams, typelib_MethodParameter * pParams,
53cdf0e10cSrcweir void ** gpreg, void ** fpreg, void ** ovrflw,
54cdf0e10cSrcweir sal_Int64 * pRegisterReturn /* space for register return */ )
55cdf0e10cSrcweir {
56cdf0e10cSrcweir int ng = 0; //number of gpr registers used
57cdf0e10cSrcweir #ifndef __NO_FPRS__
58cdf0e10cSrcweir int nf = 0; //number of fpr regsiters used
59cdf0e10cSrcweir #endif
60cdf0e10cSrcweir void ** pCppStack; //temporary stack pointer
61cdf0e10cSrcweir
62cdf0e10cSrcweir // gpreg: [ret *], this, [gpr params]
63cdf0e10cSrcweir // fpreg: [fpr params]
64cdf0e10cSrcweir // ovrflw: [gpr or fpr params (properly aligned)]
65cdf0e10cSrcweir
66cdf0e10cSrcweir // return
67cdf0e10cSrcweir typelib_TypeDescription * pReturnTypeDescr = 0;
68cdf0e10cSrcweir if (pReturnTypeRef)
69cdf0e10cSrcweir TYPELIB_DANGER_GET( &pReturnTypeDescr, pReturnTypeRef );
70cdf0e10cSrcweir
71cdf0e10cSrcweir void * pUnoReturn = 0;
72cdf0e10cSrcweir void * pCppReturn = 0; // complex return ptr: if != 0 && != pUnoReturn, reconversion need
73cdf0e10cSrcweir
74cdf0e10cSrcweir if (pReturnTypeDescr)
75cdf0e10cSrcweir {
76cdf0e10cSrcweir if (bridges::cpp_uno::shared::isSimpleType( pReturnTypeDescr ))
77cdf0e10cSrcweir {
78cdf0e10cSrcweir pUnoReturn = pRegisterReturn; // direct way for simple types
79cdf0e10cSrcweir }
80cdf0e10cSrcweir else // complex return via ptr (pCppReturn)
81cdf0e10cSrcweir {
82cdf0e10cSrcweir pCppReturn = *(void **)gpreg;
83cdf0e10cSrcweir gpreg++;
84cdf0e10cSrcweir ng++;
85cdf0e10cSrcweir
86cdf0e10cSrcweir pUnoReturn = (bridges::cpp_uno::shared::relatesToInterfaceType( pReturnTypeDescr )
87cdf0e10cSrcweir ? alloca( pReturnTypeDescr->nSize )
88cdf0e10cSrcweir : pCppReturn); // direct way
89cdf0e10cSrcweir }
90cdf0e10cSrcweir }
91cdf0e10cSrcweir // pop this
92cdf0e10cSrcweir gpreg++;
93cdf0e10cSrcweir ng++;
94cdf0e10cSrcweir
95cdf0e10cSrcweir // stack space
96cdf0e10cSrcweir OSL_ENSURE( sizeof(void *) == sizeof(sal_Int32), "### unexpected size!" );
97cdf0e10cSrcweir // parameters
98cdf0e10cSrcweir void ** pUnoArgs = (void **)alloca( 4 * sizeof(void *) * nParams );
99cdf0e10cSrcweir void ** pCppArgs = pUnoArgs + nParams;
100cdf0e10cSrcweir // indizes of values this have to be converted (interface conversion cpp<=>uno)
101cdf0e10cSrcweir sal_Int32 * pTempIndizes = (sal_Int32 *)(pUnoArgs + (2 * nParams));
102cdf0e10cSrcweir // type descriptions for reconversions
103cdf0e10cSrcweir typelib_TypeDescription ** ppTempParamTypeDescr = (typelib_TypeDescription **)(pUnoArgs + (3 * nParams));
104cdf0e10cSrcweir
105cdf0e10cSrcweir sal_Int32 nTempIndizes = 0;
106cdf0e10cSrcweir
107cdf0e10cSrcweir for ( sal_Int32 nPos = 0; nPos < nParams; ++nPos )
108cdf0e10cSrcweir {
109cdf0e10cSrcweir const typelib_MethodParameter & rParam = pParams[nPos];
110cdf0e10cSrcweir typelib_TypeDescription * pParamTypeDescr = 0;
111cdf0e10cSrcweir TYPELIB_DANGER_GET( &pParamTypeDescr, rParam.pTypeRef );
112cdf0e10cSrcweir
113cdf0e10cSrcweir if (!rParam.bOut && bridges::cpp_uno::shared::isSimpleType( pParamTypeDescr ))
114cdf0e10cSrcweir // value
115cdf0e10cSrcweir {
116cdf0e10cSrcweir
117cdf0e10cSrcweir switch (pParamTypeDescr->eTypeClass)
118cdf0e10cSrcweir {
119cdf0e10cSrcweir
120cdf0e10cSrcweir case typelib_TypeClass_DOUBLE:
121cdf0e10cSrcweir #ifndef __NO_FPRS__
122cdf0e10cSrcweir if (nf < 8) {
123cdf0e10cSrcweir pCppArgs[nPos] = fpreg;
124cdf0e10cSrcweir pUnoArgs[nPos] = fpreg;
125cdf0e10cSrcweir nf++;
126cdf0e10cSrcweir fpreg += 2;
127cdf0e10cSrcweir #else
128cdf0e10cSrcweir if (ng & 1) {
129cdf0e10cSrcweir ng++;
130cdf0e10cSrcweir gpreg++;
131cdf0e10cSrcweir }
132cdf0e10cSrcweir if (ng < 8) {
133cdf0e10cSrcweir pCppArgs[nPos] = gpreg;
134cdf0e10cSrcweir pUnoArgs[nPos] = gpreg;
135cdf0e10cSrcweir ng += 2;
136cdf0e10cSrcweir gpreg += 2;
137cdf0e10cSrcweir #endif
138cdf0e10cSrcweir } else {
139cdf0e10cSrcweir if (((long)ovrflw) & 4) ovrflw++;
140cdf0e10cSrcweir pCppArgs[nPos] = ovrflw;
141cdf0e10cSrcweir pUnoArgs[nPos] = ovrflw;
142cdf0e10cSrcweir ovrflw += 2;
143cdf0e10cSrcweir }
144cdf0e10cSrcweir break;
145cdf0e10cSrcweir
146cdf0e10cSrcweir case typelib_TypeClass_FLOAT:
147cdf0e10cSrcweir // fpreg are all double values so need to
148cdf0e10cSrcweir // modify fpreg to be a single word float value
149cdf0e10cSrcweir #ifndef __NO_FPRS__
150cdf0e10cSrcweir if (nf < 8) {
151cdf0e10cSrcweir float tmp = (float) (*((double *)fpreg));
152cdf0e10cSrcweir (*((float *) fpreg)) = tmp;
153cdf0e10cSrcweir pCppArgs[nPos] = fpreg;
154cdf0e10cSrcweir pUnoArgs[nPos] = fpreg;
155cdf0e10cSrcweir nf++;
156cdf0e10cSrcweir fpreg += 2;
157cdf0e10cSrcweir #else
158cdf0e10cSrcweir if (ng < 8) {
159cdf0e10cSrcweir pCppArgs[nPos] = gpreg;
160cdf0e10cSrcweir pUnoArgs[nPos] = gpreg;
161cdf0e10cSrcweir ng++;
162cdf0e10cSrcweir gpreg++;
163cdf0e10cSrcweir #endif
164cdf0e10cSrcweir } else {
165cdf0e10cSrcweir #if 0 /* abi is not being followed correctly */
166cdf0e10cSrcweir if (((long)ovrflw) & 4) ovrflw++;
167cdf0e10cSrcweir float tmp = (float) (*((double *)ovrflw));
168cdf0e10cSrcweir (*((float *) ovrflw)) = tmp;
169cdf0e10cSrcweir pCppArgs[nPos] = ovrflw;
170cdf0e10cSrcweir pUnoArgs[nPos] = ovrflw;
171cdf0e10cSrcweir ovrflw += 2;
172cdf0e10cSrcweir #else
173cdf0e10cSrcweir pCppArgs[nPos] = ovrflw;
174cdf0e10cSrcweir pUnoArgs[nPos] = ovrflw;
175cdf0e10cSrcweir ovrflw += 1;
176cdf0e10cSrcweir #endif
177cdf0e10cSrcweir }
178cdf0e10cSrcweir break;
179cdf0e10cSrcweir
180cdf0e10cSrcweir case typelib_TypeClass_HYPER:
181cdf0e10cSrcweir case typelib_TypeClass_UNSIGNED_HYPER:
182cdf0e10cSrcweir if (ng & 1) {
183cdf0e10cSrcweir ng++;
184cdf0e10cSrcweir gpreg++;
185cdf0e10cSrcweir }
186cdf0e10cSrcweir if (ng < 8) {
187cdf0e10cSrcweir pCppArgs[nPos] = gpreg;
188cdf0e10cSrcweir pUnoArgs[nPos] = gpreg;
189cdf0e10cSrcweir ng += 2;
190cdf0e10cSrcweir gpreg += 2;
191cdf0e10cSrcweir } else {
192cdf0e10cSrcweir if (((long)ovrflw) & 4) ovrflw++;
193cdf0e10cSrcweir pCppArgs[nPos] = ovrflw;
194cdf0e10cSrcweir pUnoArgs[nPos] = ovrflw;
195cdf0e10cSrcweir ovrflw += 2;
196cdf0e10cSrcweir }
197cdf0e10cSrcweir break;
198cdf0e10cSrcweir
199cdf0e10cSrcweir case typelib_TypeClass_BYTE:
200cdf0e10cSrcweir case typelib_TypeClass_BOOLEAN:
201cdf0e10cSrcweir if (ng < 8) {
202cdf0e10cSrcweir pCppArgs[nPos] = (((char *)gpreg) + 3);
203cdf0e10cSrcweir pUnoArgs[nPos] = (((char *)gpreg) + 3);
204cdf0e10cSrcweir ng++;
205cdf0e10cSrcweir gpreg++;
206cdf0e10cSrcweir } else {
207cdf0e10cSrcweir pCppArgs[nPos] = (((char *)ovrflw) + 3);
208cdf0e10cSrcweir pUnoArgs[nPos] = (((char *)ovrflw) + 3);
209cdf0e10cSrcweir ovrflw++;
210cdf0e10cSrcweir }
211cdf0e10cSrcweir break;
212cdf0e10cSrcweir
213cdf0e10cSrcweir
214cdf0e10cSrcweir case typelib_TypeClass_CHAR:
215cdf0e10cSrcweir case typelib_TypeClass_SHORT:
216cdf0e10cSrcweir case typelib_TypeClass_UNSIGNED_SHORT:
217cdf0e10cSrcweir if (ng < 8) {
218cdf0e10cSrcweir pCppArgs[nPos] = (((char *)gpreg)+ 2);
219cdf0e10cSrcweir pUnoArgs[nPos] = (((char *)gpreg)+ 2);
220cdf0e10cSrcweir ng++;
221cdf0e10cSrcweir gpreg++;
222cdf0e10cSrcweir } else {
223cdf0e10cSrcweir pCppArgs[nPos] = (((char *)ovrflw) + 2);
224cdf0e10cSrcweir pUnoArgs[nPos] = (((char *)ovrflw) + 2);
225cdf0e10cSrcweir ovrflw++;
226cdf0e10cSrcweir }
227cdf0e10cSrcweir break;
228cdf0e10cSrcweir
229cdf0e10cSrcweir
230cdf0e10cSrcweir default:
231cdf0e10cSrcweir if (ng < 8) {
232cdf0e10cSrcweir pCppArgs[nPos] = gpreg;
233cdf0e10cSrcweir pUnoArgs[nPos] = gpreg;
234cdf0e10cSrcweir ng++;
235cdf0e10cSrcweir gpreg++;
236cdf0e10cSrcweir } else {
237cdf0e10cSrcweir pCppArgs[nPos] = ovrflw;
238cdf0e10cSrcweir pUnoArgs[nPos] = ovrflw;
239cdf0e10cSrcweir ovrflw++;
240cdf0e10cSrcweir }
241cdf0e10cSrcweir break;
242cdf0e10cSrcweir
243cdf0e10cSrcweir }
244cdf0e10cSrcweir // no longer needed
245cdf0e10cSrcweir TYPELIB_DANGER_RELEASE( pParamTypeDescr );
246cdf0e10cSrcweir }
247cdf0e10cSrcweir else // ptr to complex value | ref
248cdf0e10cSrcweir {
249cdf0e10cSrcweir
250cdf0e10cSrcweir if (ng < 8) {
251cdf0e10cSrcweir pCppArgs[nPos] = *(void **)gpreg;
252cdf0e10cSrcweir pCppStack = gpreg;
253cdf0e10cSrcweir ng++;
254cdf0e10cSrcweir gpreg++;
255cdf0e10cSrcweir } else {
256cdf0e10cSrcweir pCppArgs[nPos] = *(void **)ovrflw;
257cdf0e10cSrcweir pCppStack = ovrflw;
258cdf0e10cSrcweir ovrflw++;
259cdf0e10cSrcweir }
260cdf0e10cSrcweir
261cdf0e10cSrcweir if (! rParam.bIn) // is pure out
262cdf0e10cSrcweir {
263cdf0e10cSrcweir // uno out is unconstructed mem!
264cdf0e10cSrcweir pUnoArgs[nPos] = alloca( pParamTypeDescr->nSize );
265cdf0e10cSrcweir pTempIndizes[nTempIndizes] = nPos;
266cdf0e10cSrcweir // will be released at reconversion
267cdf0e10cSrcweir ppTempParamTypeDescr[nTempIndizes++] = pParamTypeDescr;
268cdf0e10cSrcweir }
269cdf0e10cSrcweir // is in/inout
270cdf0e10cSrcweir else if (bridges::cpp_uno::shared::relatesToInterfaceType( pParamTypeDescr ))
271cdf0e10cSrcweir {
272cdf0e10cSrcweir uno_copyAndConvertData( pUnoArgs[nPos] = alloca( pParamTypeDescr->nSize ),
273cdf0e10cSrcweir *(void **)pCppStack, pParamTypeDescr,
274cdf0e10cSrcweir pThis->getBridge()->getCpp2Uno() );
275cdf0e10cSrcweir pTempIndizes[nTempIndizes] = nPos; // has to be reconverted
276cdf0e10cSrcweir // will be released at reconversion
277cdf0e10cSrcweir ppTempParamTypeDescr[nTempIndizes++] = pParamTypeDescr;
278cdf0e10cSrcweir }
279cdf0e10cSrcweir else // direct way
280cdf0e10cSrcweir {
281cdf0e10cSrcweir pUnoArgs[nPos] = *(void **)pCppStack;
282cdf0e10cSrcweir // no longer needed
283cdf0e10cSrcweir TYPELIB_DANGER_RELEASE( pParamTypeDescr );
284cdf0e10cSrcweir }
285cdf0e10cSrcweir }
286cdf0e10cSrcweir }
287cdf0e10cSrcweir
288cdf0e10cSrcweir // ExceptionHolder
289cdf0e10cSrcweir uno_Any aUnoExc; // Any will be constructed by callee
290cdf0e10cSrcweir uno_Any * pUnoExc = &aUnoExc;
291cdf0e10cSrcweir
292cdf0e10cSrcweir // invoke uno dispatch call
293cdf0e10cSrcweir (*pThis->getUnoI()->pDispatcher)( pThis->getUnoI(), pMemberTypeDescr, pUnoReturn, pUnoArgs, &pUnoExc );
294cdf0e10cSrcweir
295cdf0e10cSrcweir // in case an exception occured...
296cdf0e10cSrcweir if (pUnoExc)
297cdf0e10cSrcweir {
298cdf0e10cSrcweir // destruct temporary in/inout params
299cdf0e10cSrcweir for ( ; nTempIndizes--; )
300cdf0e10cSrcweir {
301cdf0e10cSrcweir sal_Int32 nIndex = pTempIndizes[nTempIndizes];
302cdf0e10cSrcweir
303cdf0e10cSrcweir if (pParams[nIndex].bIn) // is in/inout => was constructed
304cdf0e10cSrcweir uno_destructData( pUnoArgs[nIndex], ppTempParamTypeDescr[nTempIndizes], 0 );
305cdf0e10cSrcweir TYPELIB_DANGER_RELEASE( ppTempParamTypeDescr[nTempIndizes] );
306cdf0e10cSrcweir }
307cdf0e10cSrcweir if (pReturnTypeDescr)
308cdf0e10cSrcweir TYPELIB_DANGER_RELEASE( pReturnTypeDescr );
309cdf0e10cSrcweir
310cdf0e10cSrcweir CPPU_CURRENT_NAMESPACE::raiseException( &aUnoExc, pThis->getBridge()->getUno2Cpp() );
311cdf0e10cSrcweir // has to destruct the any
312cdf0e10cSrcweir // is here for dummy
313cdf0e10cSrcweir return typelib_TypeClass_VOID;
314cdf0e10cSrcweir }
315cdf0e10cSrcweir else // else no exception occured...
316cdf0e10cSrcweir {
317cdf0e10cSrcweir // temporary params
318cdf0e10cSrcweir for ( ; nTempIndizes--; )
319cdf0e10cSrcweir {
320cdf0e10cSrcweir sal_Int32 nIndex = pTempIndizes[nTempIndizes];
321cdf0e10cSrcweir typelib_TypeDescription * pParamTypeDescr = ppTempParamTypeDescr[nTempIndizes];
322cdf0e10cSrcweir
323cdf0e10cSrcweir if (pParams[nIndex].bOut) // inout/out
324cdf0e10cSrcweir {
325cdf0e10cSrcweir // convert and assign
326cdf0e10cSrcweir uno_destructData( pCppArgs[nIndex], pParamTypeDescr, cpp_release );
327cdf0e10cSrcweir uno_copyAndConvertData( pCppArgs[nIndex], pUnoArgs[nIndex], pParamTypeDescr,
328cdf0e10cSrcweir pThis->getBridge()->getUno2Cpp() );
329cdf0e10cSrcweir }
330cdf0e10cSrcweir // destroy temp uno param
331cdf0e10cSrcweir uno_destructData( pUnoArgs[nIndex], pParamTypeDescr, 0 );
332cdf0e10cSrcweir
333cdf0e10cSrcweir TYPELIB_DANGER_RELEASE( pParamTypeDescr );
334cdf0e10cSrcweir }
335cdf0e10cSrcweir // return
336cdf0e10cSrcweir if (pCppReturn) // has complex return
337cdf0e10cSrcweir {
338cdf0e10cSrcweir if (pUnoReturn != pCppReturn) // needs reconversion
339cdf0e10cSrcweir {
340cdf0e10cSrcweir uno_copyAndConvertData( pCppReturn, pUnoReturn, pReturnTypeDescr,
341cdf0e10cSrcweir pThis->getBridge()->getUno2Cpp() );
342cdf0e10cSrcweir // destroy temp uno return
343cdf0e10cSrcweir uno_destructData( pUnoReturn, pReturnTypeDescr, 0 );
344cdf0e10cSrcweir }
345cdf0e10cSrcweir // complex return ptr is set to return reg
346cdf0e10cSrcweir *(void **)pRegisterReturn = pCppReturn;
347cdf0e10cSrcweir }
348cdf0e10cSrcweir if (pReturnTypeDescr)
349cdf0e10cSrcweir {
350cdf0e10cSrcweir typelib_TypeClass eRet = (typelib_TypeClass)pReturnTypeDescr->eTypeClass;
351cdf0e10cSrcweir TYPELIB_DANGER_RELEASE( pReturnTypeDescr );
352cdf0e10cSrcweir return eRet;
353cdf0e10cSrcweir }
354cdf0e10cSrcweir else
355cdf0e10cSrcweir return typelib_TypeClass_VOID;
356cdf0e10cSrcweir }
357cdf0e10cSrcweir }
358cdf0e10cSrcweir
359cdf0e10cSrcweir
360cdf0e10cSrcweir //==================================================================================================
361cdf0e10cSrcweir static typelib_TypeClass cpp_mediate(
362cdf0e10cSrcweir sal_Int32 nFunctionIndex,
363cdf0e10cSrcweir sal_Int32 nVtableOffset,
364cdf0e10cSrcweir void ** gpreg, void ** fpreg, void ** ovrflw,
365cdf0e10cSrcweir sal_Int64 * pRegisterReturn /* space for register return */ )
366cdf0e10cSrcweir {
367cdf0e10cSrcweir OSL_ENSURE( sizeof(sal_Int32)==sizeof(void *), "### unexpected!" );
368cdf0e10cSrcweir
369cdf0e10cSrcweir // gpreg: [ret *], this, [other gpr params]
370cdf0e10cSrcweir // fpreg: [fpr params]
371cdf0e10cSrcweir // ovrflw: [gpr or fpr params (properly aligned)]
372cdf0e10cSrcweir
373cdf0e10cSrcweir void * pThis;
374cdf0e10cSrcweir if (nFunctionIndex & 0x80000000 )
375cdf0e10cSrcweir {
376cdf0e10cSrcweir nFunctionIndex &= 0x7fffffff;
377cdf0e10cSrcweir pThis = gpreg[1];
378cdf0e10cSrcweir }
379cdf0e10cSrcweir else
380cdf0e10cSrcweir {
381cdf0e10cSrcweir pThis = gpreg[0];
382cdf0e10cSrcweir }
383cdf0e10cSrcweir
384cdf0e10cSrcweir pThis = static_cast< char * >(pThis) - nVtableOffset;
385cdf0e10cSrcweir bridges::cpp_uno::shared::CppInterfaceProxy * pCppI
386cdf0e10cSrcweir = bridges::cpp_uno::shared::CppInterfaceProxy::castInterfaceToProxy(
387cdf0e10cSrcweir pThis);
388cdf0e10cSrcweir
389cdf0e10cSrcweir typelib_InterfaceTypeDescription * pTypeDescr = pCppI->getTypeDescr();
390cdf0e10cSrcweir
391cdf0e10cSrcweir OSL_ENSURE( nFunctionIndex < pTypeDescr->nMapFunctionIndexToMemberIndex, "### illegal vtable index!" );
392cdf0e10cSrcweir if (nFunctionIndex >= pTypeDescr->nMapFunctionIndexToMemberIndex)
393cdf0e10cSrcweir {
394cdf0e10cSrcweir throw RuntimeException(
395cdf0e10cSrcweir rtl::OUString::createFromAscii("illegal vtable index!"),
396cdf0e10cSrcweir (XInterface *)pThis );
397cdf0e10cSrcweir }
398cdf0e10cSrcweir
399cdf0e10cSrcweir // determine called method
400cdf0e10cSrcweir sal_Int32 nMemberPos = pTypeDescr->pMapFunctionIndexToMemberIndex[nFunctionIndex];
401cdf0e10cSrcweir OSL_ENSURE( nMemberPos < pTypeDescr->nAllMembers, "### illegal member index!" );
402cdf0e10cSrcweir
403cdf0e10cSrcweir TypeDescription aMemberDescr( pTypeDescr->ppAllMembers[nMemberPos] );
404cdf0e10cSrcweir
405cdf0e10cSrcweir typelib_TypeClass eRet;
406cdf0e10cSrcweir switch (aMemberDescr.get()->eTypeClass)
407cdf0e10cSrcweir {
408cdf0e10cSrcweir case typelib_TypeClass_INTERFACE_ATTRIBUTE:
409cdf0e10cSrcweir {
410cdf0e10cSrcweir if (pTypeDescr->pMapMemberIndexToFunctionIndex[nMemberPos] == nFunctionIndex)
411cdf0e10cSrcweir {
412cdf0e10cSrcweir // is GET method
413cdf0e10cSrcweir eRet = cpp2uno_call(
414cdf0e10cSrcweir pCppI, aMemberDescr.get(),
415cdf0e10cSrcweir ((typelib_InterfaceAttributeTypeDescription *)aMemberDescr.get())->pAttributeTypeRef,
416cdf0e10cSrcweir 0, 0, // no params
417cdf0e10cSrcweir gpreg, fpreg, ovrflw, pRegisterReturn );
418cdf0e10cSrcweir }
419cdf0e10cSrcweir else
420cdf0e10cSrcweir {
421cdf0e10cSrcweir // is SET method
422cdf0e10cSrcweir typelib_MethodParameter aParam;
423cdf0e10cSrcweir aParam.pTypeRef =
424cdf0e10cSrcweir ((typelib_InterfaceAttributeTypeDescription *)aMemberDescr.get())->pAttributeTypeRef;
425cdf0e10cSrcweir aParam.bIn = sal_True;
426cdf0e10cSrcweir aParam.bOut = sal_False;
427cdf0e10cSrcweir
428cdf0e10cSrcweir eRet = cpp2uno_call(
429cdf0e10cSrcweir pCppI, aMemberDescr.get(),
430cdf0e10cSrcweir 0, // indicates void return
431cdf0e10cSrcweir 1, &aParam,
432cdf0e10cSrcweir gpreg, fpreg, ovrflw, pRegisterReturn );
433cdf0e10cSrcweir }
434cdf0e10cSrcweir break;
435cdf0e10cSrcweir }
436cdf0e10cSrcweir case typelib_TypeClass_INTERFACE_METHOD:
437cdf0e10cSrcweir {
438cdf0e10cSrcweir // is METHOD
439cdf0e10cSrcweir switch (nFunctionIndex)
440cdf0e10cSrcweir {
441cdf0e10cSrcweir case 1: // acquire()
442cdf0e10cSrcweir pCppI->acquireProxy(); // non virtual call!
443cdf0e10cSrcweir eRet = typelib_TypeClass_VOID;
444cdf0e10cSrcweir break;
445cdf0e10cSrcweir case 2: // release()
446cdf0e10cSrcweir pCppI->releaseProxy(); // non virtual call!
447cdf0e10cSrcweir eRet = typelib_TypeClass_VOID;
448cdf0e10cSrcweir break;
449cdf0e10cSrcweir case 0: // queryInterface() opt
450cdf0e10cSrcweir {
451cdf0e10cSrcweir typelib_TypeDescription * pTD = 0;
452cdf0e10cSrcweir TYPELIB_DANGER_GET( &pTD, reinterpret_cast< Type * >( gpreg[2] )->getTypeLibType() );
453cdf0e10cSrcweir if (pTD)
454cdf0e10cSrcweir {
455cdf0e10cSrcweir XInterface * pInterface = 0;
456cdf0e10cSrcweir (*pCppI->getBridge()->getCppEnv()->getRegisteredInterface)(
457cdf0e10cSrcweir pCppI->getBridge()->getCppEnv(),
458cdf0e10cSrcweir (void **)&pInterface, pCppI->getOid().pData,
459cdf0e10cSrcweir (typelib_InterfaceTypeDescription *)pTD );
460cdf0e10cSrcweir
461cdf0e10cSrcweir if (pInterface)
462cdf0e10cSrcweir {
463cdf0e10cSrcweir ::uno_any_construct(
464cdf0e10cSrcweir reinterpret_cast< uno_Any * >( gpreg[0] ),
465cdf0e10cSrcweir &pInterface, pTD, cpp_acquire );
466cdf0e10cSrcweir pInterface->release();
467cdf0e10cSrcweir TYPELIB_DANGER_RELEASE( pTD );
468cdf0e10cSrcweir *(void **)pRegisterReturn = gpreg[0];
469cdf0e10cSrcweir eRet = typelib_TypeClass_ANY;
470cdf0e10cSrcweir break;
471cdf0e10cSrcweir }
472cdf0e10cSrcweir TYPELIB_DANGER_RELEASE( pTD );
473cdf0e10cSrcweir }
474cdf0e10cSrcweir } // else perform queryInterface()
475cdf0e10cSrcweir default:
476cdf0e10cSrcweir eRet = cpp2uno_call(
477cdf0e10cSrcweir pCppI, aMemberDescr.get(),
478cdf0e10cSrcweir ((typelib_InterfaceMethodTypeDescription *)aMemberDescr.get())->pReturnTypeRef,
479cdf0e10cSrcweir ((typelib_InterfaceMethodTypeDescription *)aMemberDescr.get())->nParams,
480cdf0e10cSrcweir ((typelib_InterfaceMethodTypeDescription *)aMemberDescr.get())->pParams,
481cdf0e10cSrcweir gpreg, fpreg, ovrflw, pRegisterReturn );
482cdf0e10cSrcweir }
483cdf0e10cSrcweir break;
484cdf0e10cSrcweir }
485cdf0e10cSrcweir default:
486cdf0e10cSrcweir {
487cdf0e10cSrcweir throw RuntimeException(
488cdf0e10cSrcweir rtl::OUString::createFromAscii("no member description found!"),
489cdf0e10cSrcweir (XInterface *)pThis );
490cdf0e10cSrcweir // is here for dummy
491cdf0e10cSrcweir eRet = typelib_TypeClass_VOID;
492cdf0e10cSrcweir }
493cdf0e10cSrcweir }
494cdf0e10cSrcweir
495cdf0e10cSrcweir return eRet;
496cdf0e10cSrcweir }
497cdf0e10cSrcweir
498cdf0e10cSrcweir //==================================================================================================
499cdf0e10cSrcweir /**
500cdf0e10cSrcweir * is called on incoming vtable calls
501cdf0e10cSrcweir * (called by asm snippets)
502cdf0e10cSrcweir */
503cdf0e10cSrcweir static void cpp_vtable_call( int nFunctionIndex, int nVtableOffset, void** gpregptr, void** fpregptr, void** ovrflw)
504cdf0e10cSrcweir {
505cdf0e10cSrcweir sal_Int32 gpreg[8];
506cdf0e10cSrcweir memcpy( gpreg, gpregptr, 32);
507cdf0e10cSrcweir
508cdf0e10cSrcweir #ifndef __NO_FPRS__
509cdf0e10cSrcweir double fpreg[8];
510cdf0e10cSrcweir memcpy( fpreg, fpregptr, 64);
511cdf0e10cSrcweir #endif
512cdf0e10cSrcweir
513cdf0e10cSrcweir volatile long nRegReturn[2];
514cdf0e10cSrcweir
515cdf0e10cSrcweir // fprintf(stderr,"in cpp_vtable_call nFunctionIndex is %x\n",nFunctionIndex);
516cdf0e10cSrcweir // fprintf(stderr,"in cpp_vtable_call nVtableOffset is %x\n",nVtableOffset);
517cdf0e10cSrcweir // fflush(stderr);
518cdf0e10cSrcweir
519cdf0e10cSrcweir typelib_TypeClass aType =
520cdf0e10cSrcweir cpp_mediate( nFunctionIndex, nVtableOffset, (void**)gpreg,
521cdf0e10cSrcweir #ifndef __NO_FPRS__
522cdf0e10cSrcweir (void**)fpreg,
523cdf0e10cSrcweir #else
524cdf0e10cSrcweir NULL,
525cdf0e10cSrcweir #endif
526cdf0e10cSrcweir ovrflw, (sal_Int64*)nRegReturn );
527cdf0e10cSrcweir
528cdf0e10cSrcweir switch( aType )
529cdf0e10cSrcweir {
530cdf0e10cSrcweir
531cdf0e10cSrcweir // move return value into register space
532cdf0e10cSrcweir // (will be loaded by machine code snippet)
533cdf0e10cSrcweir
534cdf0e10cSrcweir case typelib_TypeClass_BOOLEAN:
535cdf0e10cSrcweir case typelib_TypeClass_BYTE:
536cdf0e10cSrcweir __asm__( "lbz 3,%0\n\t" : :
537cdf0e10cSrcweir "m"(nRegReturn[0]) );
538cdf0e10cSrcweir break;
539cdf0e10cSrcweir
540cdf0e10cSrcweir case typelib_TypeClass_CHAR:
541cdf0e10cSrcweir case typelib_TypeClass_SHORT:
542cdf0e10cSrcweir case typelib_TypeClass_UNSIGNED_SHORT:
543cdf0e10cSrcweir __asm__( "lhz 3,%0\n\t" : :
544cdf0e10cSrcweir "m"(nRegReturn[0]) );
545cdf0e10cSrcweir break;
546cdf0e10cSrcweir
547cdf0e10cSrcweir case typelib_TypeClass_FLOAT:
548cdf0e10cSrcweir #ifndef __NO_FPRS__
549cdf0e10cSrcweir __asm__( "lfs 1,%0\n\t" : :
550cdf0e10cSrcweir "m" (*((float*)nRegReturn)) );
551cdf0e10cSrcweir #else
552cdf0e10cSrcweir __asm__( "lwz 3,%0\n\t" : :
553cdf0e10cSrcweir "m"(nRegReturn[0]) );
554cdf0e10cSrcweir #endif
555cdf0e10cSrcweir break;
556cdf0e10cSrcweir
557cdf0e10cSrcweir case typelib_TypeClass_DOUBLE:
558cdf0e10cSrcweir #ifndef __NO_FPRS__
559cdf0e10cSrcweir __asm__( "lfd 1,%0\n\t" : :
560cdf0e10cSrcweir "m" (*((double*)nRegReturn)) );
561cdf0e10cSrcweir #else
562cdf0e10cSrcweir __asm__( "lwz 3,%0\n\t" : :
563cdf0e10cSrcweir "m"(nRegReturn[0]) );
564cdf0e10cSrcweir __asm__( "lwz 4,%0\n\t" : :
565cdf0e10cSrcweir "m"(nRegReturn[1]) );
566cdf0e10cSrcweir #endif
567cdf0e10cSrcweir break;
568cdf0e10cSrcweir
569cdf0e10cSrcweir case typelib_TypeClass_HYPER:
570cdf0e10cSrcweir case typelib_TypeClass_UNSIGNED_HYPER:
571cdf0e10cSrcweir __asm__( "lwz 4,%0\n\t" : :
572cdf0e10cSrcweir "m"(nRegReturn[1]) ); // fall through
573cdf0e10cSrcweir
574cdf0e10cSrcweir default:
575cdf0e10cSrcweir __asm__( "lwz 3,%0\n\t" : :
576cdf0e10cSrcweir "m"(nRegReturn[0]) );
577cdf0e10cSrcweir break;
578cdf0e10cSrcweir }
579cdf0e10cSrcweir }
580cdf0e10cSrcweir
581cdf0e10cSrcweir
582cdf0e10cSrcweir int const codeSnippetSize = 108;
583cdf0e10cSrcweir
584cdf0e10cSrcweir unsigned char * codeSnippet( unsigned char * code, sal_Int32 functionIndex, sal_Int32 vtableOffset,
585cdf0e10cSrcweir bool simpleRetType)
586cdf0e10cSrcweir {
587cdf0e10cSrcweir
588cdf0e10cSrcweir // fprintf(stderr,"in codeSnippet functionIndex is %x\n", functionIndex);
589cdf0e10cSrcweir // fprintf(stderr,"in codeSnippet vtableOffset is %x\n", vtableOffset);
590cdf0e10cSrcweir // fflush(stderr);
591cdf0e10cSrcweir
592cdf0e10cSrcweir if (! simpleRetType )
593cdf0e10cSrcweir functionIndex |= 0x80000000;
594cdf0e10cSrcweir
595cdf0e10cSrcweir unsigned long * p = (unsigned long *) code;
596cdf0e10cSrcweir
597cdf0e10cSrcweir // OSL_ASSERT( sizeof (long) == 4 );
598cdf0e10cSrcweir OSL_ASSERT((((unsigned long)code) & 0x3) == 0 ); //aligned to 4 otherwise a mistake
599cdf0e10cSrcweir
600cdf0e10cSrcweir /* generate this code */
601cdf0e10cSrcweir // # so first save gpr 3 to gpr 10 (aligned to 4)
602cdf0e10cSrcweir // stw r3,-2048(r1)
603cdf0e10cSrcweir // stw r4,-2044(r1)
604cdf0e10cSrcweir // stw r5,-2040(r1)
605cdf0e10cSrcweir // stw r6,-2036(r1)
606cdf0e10cSrcweir // stw r7,-2032(r1)
607cdf0e10cSrcweir // stw r8,-2028(r1)
608cdf0e10cSrcweir // stw r9,-2024(r1)
609cdf0e10cSrcweir // stw r10,-2020(r1)
610cdf0e10cSrcweir
611cdf0e10cSrcweir
612cdf0e10cSrcweir // # next save fpr 1 to fpr 8 (aligned to 8)
613cdf0e10cSrcweir // if dedicated floating point registers are used
614cdf0e10cSrcweir // stfd f1,-2016(r1)
615cdf0e10cSrcweir // stfd f2,-2008(r1)
616cdf0e10cSrcweir // stfd f3,-2000(r1)
617cdf0e10cSrcweir // stfd f4,-1992(r1)
618cdf0e10cSrcweir // stfd f5,-1984(r1)
619cdf0e10cSrcweir // stfd f6,-1976(r1)
620cdf0e10cSrcweir // stfd f7,-1968(r1)
621cdf0e10cSrcweir // stfd f8,-1960(r1)
622cdf0e10cSrcweir
623cdf0e10cSrcweir // # now here is where cpp_vtable_call must go
624cdf0e10cSrcweir // lis r3,-8531
625cdf0e10cSrcweir // ori r3,r3,48879
626cdf0e10cSrcweir // mtctr r3
627cdf0e10cSrcweir
628cdf0e10cSrcweir // # now load up the functionIndex
629cdf0e10cSrcweir // lis r3,-8531
630cdf0e10cSrcweir // ori r3,r3,48879
631cdf0e10cSrcweir
632cdf0e10cSrcweir // # now load up the vtableOffset
633cdf0e10cSrcweir // lis r4,-8531
634cdf0e10cSrcweir // ori r4,r4,48879
635cdf0e10cSrcweir
636cdf0e10cSrcweir // #now load up the pointer to the saved gpr registers
637cdf0e10cSrcweir // addi r5,r1,-2048
638cdf0e10cSrcweir
639cdf0e10cSrcweir // #now load up the pointer to the saved fpr registers
640cdf0e10cSrcweir // addi r6,r1,-2016
641cdf0e10cSrcweir // if no dedicated floating point registers are used than we have NULL
642cdf0e10cSrcweir // pointer there
643cdf0e10cSrcweir // li r6, 0
644cdf0e10cSrcweir //
645cdf0e10cSrcweir
646cdf0e10cSrcweir // #now load up the pointer to the overflow call stack
647cdf0e10cSrcweir // addi r7,r1,8
648cdf0e10cSrcweir // bctr
649cdf0e10cSrcweir
650cdf0e10cSrcweir * p++ = 0x9061f800;
651cdf0e10cSrcweir * p++ = 0x9081f804;
652cdf0e10cSrcweir * p++ = 0x90a1f808;
653cdf0e10cSrcweir * p++ = 0x90c1f80c;
654cdf0e10cSrcweir * p++ = 0x90e1f810;
655cdf0e10cSrcweir * p++ = 0x9101f814;
656cdf0e10cSrcweir * p++ = 0x9121f818;
657cdf0e10cSrcweir * p++ = 0x9141f81c;
658cdf0e10cSrcweir #ifndef __NO_FPRS__
659cdf0e10cSrcweir * p++ = 0xd821f820;
660cdf0e10cSrcweir * p++ = 0xd841f828;
661cdf0e10cSrcweir * p++ = 0xd861f830;
662cdf0e10cSrcweir * p++ = 0xd881f838;
663cdf0e10cSrcweir * p++ = 0xd8a1f840;
664cdf0e10cSrcweir * p++ = 0xd8c1f848;
665cdf0e10cSrcweir * p++ = 0xd8e1f850;
666cdf0e10cSrcweir * p++ = 0xd901f858;
667cdf0e10cSrcweir #else
668cdf0e10cSrcweir /* these nops could be replaced with a smaller codeSnippetSize - 8 * 4 */
669cdf0e10cSrcweir * p++ = 0x60000000;
670cdf0e10cSrcweir * p++ = 0x60000000;
671cdf0e10cSrcweir * p++ = 0x60000000;
672cdf0e10cSrcweir * p++ = 0x60000000;
673cdf0e10cSrcweir * p++ = 0x60000000;
674cdf0e10cSrcweir * p++ = 0x60000000;
675cdf0e10cSrcweir * p++ = 0x60000000;
676cdf0e10cSrcweir * p++ = 0x60000000;
677cdf0e10cSrcweir #endif
678cdf0e10cSrcweir * p++ = 0x3c600000 | (((unsigned long)cpp_vtable_call) >> 16);
679cdf0e10cSrcweir * p++ = 0x60630000 | (((unsigned long)cpp_vtable_call) & 0x0000FFFF);
680cdf0e10cSrcweir * p++ = 0x7c6903a6;
681cdf0e10cSrcweir * p++ = 0x3c600000 | (((unsigned long)functionIndex) >> 16);
682cdf0e10cSrcweir * p++ = 0x60630000 | (((unsigned long)functionIndex) & 0x0000FFFF);
683cdf0e10cSrcweir * p++ = 0x3c800000 | (((unsigned long)vtableOffset) >> 16);
684cdf0e10cSrcweir * p++ = 0x60840000 | (((unsigned long)vtableOffset) & 0x0000FFFF);
685cdf0e10cSrcweir * p++ = 0x38a1f800;
686cdf0e10cSrcweir #ifndef __NO_FPRS__
687cdf0e10cSrcweir * p++ = 0x38c1f820;
688cdf0e10cSrcweir #else
689cdf0e10cSrcweir * p++ = 0x38c00000;
690cdf0e10cSrcweir #endif
691cdf0e10cSrcweir * p++ = 0x38e10008;
692cdf0e10cSrcweir * p++ = 0x4e800420;
693cdf0e10cSrcweir return (code + codeSnippetSize);
694cdf0e10cSrcweir
695cdf0e10cSrcweir }
696cdf0e10cSrcweir
697cdf0e10cSrcweir
698cdf0e10cSrcweir }
699cdf0e10cSrcweir
700cdf0e10cSrcweir void bridges::cpp_uno::shared::VtableFactory::flushCode(unsigned char const * bptr, unsigned char const * eptr)
701cdf0e10cSrcweir {
702cdf0e10cSrcweir int const lineSize = 32;
703cdf0e10cSrcweir for (unsigned char const * p = bptr; p < eptr + lineSize; p += lineSize) {
704cdf0e10cSrcweir __asm__ volatile ("dcbst 0, %0" : : "r"(p) : "memory");
705cdf0e10cSrcweir }
706cdf0e10cSrcweir __asm__ volatile ("sync" : : : "memory");
707cdf0e10cSrcweir for (unsigned char const * p = bptr; p < eptr + lineSize; p += lineSize) {
708cdf0e10cSrcweir __asm__ volatile ("icbi 0, %0" : : "r"(p) : "memory");
709cdf0e10cSrcweir }
710cdf0e10cSrcweir __asm__ volatile ("isync" : : : "memory");
711cdf0e10cSrcweir }
712cdf0e10cSrcweir
713cdf0e10cSrcweir struct bridges::cpp_uno::shared::VtableFactory::Slot { void * fn; };
714cdf0e10cSrcweir
715cdf0e10cSrcweir bridges::cpp_uno::shared::VtableFactory::Slot *
716cdf0e10cSrcweir bridges::cpp_uno::shared::VtableFactory::mapBlockToVtable(void * block)
717cdf0e10cSrcweir {
718cdf0e10cSrcweir return static_cast< Slot * >(block) + 2;
719cdf0e10cSrcweir }
720cdf0e10cSrcweir
721cdf0e10cSrcweir sal_Size bridges::cpp_uno::shared::VtableFactory::getBlockSize(
722cdf0e10cSrcweir sal_Int32 slotCount)
723cdf0e10cSrcweir {
724cdf0e10cSrcweir return (slotCount + 2) * sizeof (Slot) + slotCount * codeSnippetSize;
725cdf0e10cSrcweir }
726cdf0e10cSrcweir
727cdf0e10cSrcweir bridges::cpp_uno::shared::VtableFactory::Slot *
728cdf0e10cSrcweir bridges::cpp_uno::shared::VtableFactory::initializeBlock(
729cdf0e10cSrcweir void * block, sal_Int32 slotCount)
730cdf0e10cSrcweir {
731cdf0e10cSrcweir Slot * slots = mapBlockToVtable(block);
732cdf0e10cSrcweir slots[-2].fn = 0;
733cdf0e10cSrcweir slots[-1].fn = 0;
734cdf0e10cSrcweir return slots + slotCount;
735cdf0e10cSrcweir }
736cdf0e10cSrcweir
737cdf0e10cSrcweir unsigned char * bridges::cpp_uno::shared::VtableFactory::addLocalFunctions(
738cdf0e10cSrcweir Slot ** slots, unsigned char * code, sal_PtrDiff writetoexecdiff,
739cdf0e10cSrcweir typelib_InterfaceTypeDescription const * type, sal_Int32 functionOffset,
740cdf0e10cSrcweir sal_Int32 functionCount, sal_Int32 vtableOffset)
741cdf0e10cSrcweir {
742cdf0e10cSrcweir (*slots) -= functionCount;
743cdf0e10cSrcweir Slot * s = *slots;
744cdf0e10cSrcweir // fprintf(stderr, "in addLocalFunctions functionOffset is %x\n",functionOffset);
745cdf0e10cSrcweir // fprintf(stderr, "in addLocalFunctions vtableOffset is %x\n",vtableOffset);
746cdf0e10cSrcweir // fflush(stderr);
747cdf0e10cSrcweir
748cdf0e10cSrcweir for (sal_Int32 i = 0; i < type->nMembers; ++i) {
749cdf0e10cSrcweir typelib_TypeDescription * member = 0;
750cdf0e10cSrcweir TYPELIB_DANGER_GET(&member, type->ppMembers[i]);
751cdf0e10cSrcweir OSL_ASSERT(member != 0);
752cdf0e10cSrcweir switch (member->eTypeClass) {
753cdf0e10cSrcweir case typelib_TypeClass_INTERFACE_ATTRIBUTE:
754cdf0e10cSrcweir // Getter:
755cdf0e10cSrcweir (s++)->fn = code + writetoexecdiff;
756cdf0e10cSrcweir code = codeSnippet(
757cdf0e10cSrcweir code, functionOffset++, vtableOffset,
758cdf0e10cSrcweir bridges::cpp_uno::shared::isSimpleType(
759cdf0e10cSrcweir reinterpret_cast<
760cdf0e10cSrcweir typelib_InterfaceAttributeTypeDescription * >(
761cdf0e10cSrcweir member)->pAttributeTypeRef));
762cdf0e10cSrcweir
763cdf0e10cSrcweir // Setter:
764cdf0e10cSrcweir if (!reinterpret_cast<
765cdf0e10cSrcweir typelib_InterfaceAttributeTypeDescription * >(
766cdf0e10cSrcweir member)->bReadOnly)
767cdf0e10cSrcweir {
768cdf0e10cSrcweir (s++)->fn = code + writetoexecdiff;
769cdf0e10cSrcweir code = codeSnippet(code, functionOffset++, vtableOffset, true);
770cdf0e10cSrcweir }
771cdf0e10cSrcweir break;
772cdf0e10cSrcweir
773cdf0e10cSrcweir case typelib_TypeClass_INTERFACE_METHOD:
774cdf0e10cSrcweir (s++)->fn = code + writetoexecdiff;
775cdf0e10cSrcweir code = codeSnippet(
776cdf0e10cSrcweir code, functionOffset++, vtableOffset,
777cdf0e10cSrcweir bridges::cpp_uno::shared::isSimpleType(
778cdf0e10cSrcweir reinterpret_cast<
779cdf0e10cSrcweir typelib_InterfaceMethodTypeDescription * >(
780cdf0e10cSrcweir member)->pReturnTypeRef));
781cdf0e10cSrcweir break;
782cdf0e10cSrcweir
783cdf0e10cSrcweir default:
784cdf0e10cSrcweir OSL_ASSERT(false);
785cdf0e10cSrcweir break;
786cdf0e10cSrcweir }
787cdf0e10cSrcweir TYPELIB_DANGER_RELEASE(member);
788cdf0e10cSrcweir }
789cdf0e10cSrcweir return code;
790cdf0e10cSrcweir }
791cdf0e10cSrcweir
792