View | Details | Raw Unified | Return to issue 42547
Collapse All | Expand All

(-)ooo/bridges/source/cpp_uno/gcc3_solaris_sparc.orig/cpp2uno.cxx (+585 lines)
Line 0 Link Here
1
/*************************************************************************
2
 *
3
 *  $RCSfile: cpp2uno.cxx,v $
4
 *
5
 *  $Revision: 1.6 $
6
 *
7
 *  last change: $Author: obo $ $Date: 2005/01/25 13:11:46 $
8
 *
9
 *  The Contents of this file are made available subject to the terms of
10
 *  either of the following licenses
11
 *
12
 *         - GNU Lesser General Public License Version 2.1
13
 *         - Sun Industry Standards Source License Version 1.1
14
 *
15
 *  Sun Microsystems Inc., October, 2000
16
 *
17
 *  GNU Lesser General Public License Version 2.1
18
 *  =============================================
19
 *  Copyright 2000 by Sun Microsystems, Inc.
20
 *  901 San Antonio Road, Palo Alto, CA 94303, USA
21
 *
22
 *  This library is free software; you can redistribute it and/or
23
 *  modify it under the terms of the GNU Lesser General Public
24
 *  License version 2.1, as published by the Free Software Foundation.
25
 *
26
 *  This library is distributed in the hope that it will be useful,
27
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
28
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
29
 *  Lesser General Public License for more details.
30
 *
31
 *  You should have received a copy of the GNU Lesser General Public
32
 *  License along with this library; if not, write to the Free Software
33
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
34
 *  MA  02111-1307  USA
35
 *
36
 *
37
 *  Sun Industry Standards Source License Version 1.1
38
 *  =================================================
39
 *  The contents of this file are subject to the Sun Industry Standards
40
 *  Source License Version 1.1 (the "License"); You may not use this file
41
 *  except in compliance with the License. You may obtain a copy of the
42
 *  License at http://www.openoffice.org/license.html.
43
 *
44
 *  Software provided under this License is provided on an "AS IS" basis,
45
 *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
46
 *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
47
 *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
48
 *  See the License for the specific provisions governing your rights and
49
 *  obligations concerning the Software.
50
 *
51
 *  The Initial Developer of the Original Code is: Sun Microsystems, Inc.
52
 *
53
 *  Copyright: 2000 by Sun Microsystems, Inc.
54
 *
55
 *  All Rights Reserved.
56
 *
57
 *  Contributor(s): _______________________________________
58
 *
59
 *
60
 ************************************************************************/
61
#include <com/sun/star/uno/genfunc.hxx>
62
#include <typelib/typedescription.hxx>
63
#include <uno/data.h>
64
#include "bridges/cpp_uno/shared/bridge.hxx"
65
#include "bridges/cpp_uno/shared/cppinterfaceproxy.hxx"
66
#include "bridges/cpp_uno/shared/types.hxx"
67
#include "bridges/cpp_uno/shared/vtablefactory.hxx"
68
#include "share.hxx"
69
#include <alloca.h>
70
71
using namespace com::sun::star::uno;
72
73
namespace
74
{
75
//==================================================================================================
76
static typelib_TypeClass cpp2uno_call(
77
	 bridges::cpp_uno::shared::CppInterfaceProxy * pThis,
78
	const typelib_TypeDescription * pMemberTypeDescr,
79
	typelib_TypeDescriptionReference * pReturnTypeRef, // 0 indicates void return
80
	sal_Int32 nParams, typelib_MethodParameter * pParams,
81
	void ** pCallStack,
82
	sal_Int64 * pRegisterReturn /* space for register return */ )
83
{
84
	// pCallStack: [ret ptr], this, params
85
	char * pCppStack = (char *)pCallStack;
86
87
	// return
88
	typelib_TypeDescription * pReturnTypeDescr = 0;
89
	if (pReturnTypeRef)
90
		TYPELIB_DANGER_GET( &pReturnTypeDescr, pReturnTypeRef );
91
	
92
	void * pUnoReturn = 0;
93
	void * pCppReturn = 0; // complex return ptr: if != 0 && != pUnoReturn, reconversion need
94
	
95
	if (pReturnTypeDescr)
96
	{
97
		if (bridges::cpp_uno::shared::isSimpleType( pReturnTypeDescr ))
98
			pUnoReturn = pRegisterReturn; // direct way for simple types
99
		else // complex return via ptr (pCppReturn)
100
		{
101
			pCppReturn = *(void**)pCppStack;
102
			pUnoReturn = (bridges::cpp_uno::shared::relatesToInterfaceType(
103
  	                             pReturnTypeDescr )
104
						  ? alloca( pReturnTypeDescr->nSize )
105
						  : pCppReturn); // direct way
106
			pCppStack += sizeof( void* );
107
		}
108
	}
109
	// pop this
110
	pCppStack += sizeof( void* );
111
112
	// stack space
113
	OSL_ENSURE( sizeof(void *) == sizeof(sal_Int32), "### unexpected size!" );
114
	// parameters
115
	void ** pUnoArgs = (void **)alloca( 4 * sizeof(void *) * nParams );
116
	void ** pCppArgs = pUnoArgs + nParams;
117
	// indizes of values this have to be converted (interface conversion cpp<=>uno)
118
	sal_Int32 * pTempIndizes = (sal_Int32 *)(pUnoArgs + (2 * nParams));
119
	// type descriptions for reconversions
120
	typelib_TypeDescription ** ppTempParamTypeDescr = (typelib_TypeDescription **)(pUnoArgs + (3 * nParams));
121
	
122
	sal_Int32 nTempIndizes   = 0;
123
	
124
	for ( sal_Int32 nPos = 0; nPos < nParams; ++nPos )
125
	{
126
		const typelib_MethodParameter & rParam = pParams[nPos];
127
		typelib_TypeDescription * pParamTypeDescr = 0;
128
		TYPELIB_DANGER_GET( &pParamTypeDescr, rParam.pTypeRef );
129
130
	 	if (!rParam.bOut && bridges::cpp_uno::shared::isSimpleType( pParamTypeDescr ))  // value
131
		{
132
			pCppArgs[nPos] = pUnoArgs[nPos] = CPPU_CURRENT_NAMESPACE::adjustPointer(pCppStack, pParamTypeDescr);
133
			switch (pParamTypeDescr->eTypeClass)
134
			{
135
			case typelib_TypeClass_HYPER:
136
			case typelib_TypeClass_UNSIGNED_HYPER:
137
            		case typelib_TypeClass_DOUBLE:
138
            		{
139
			if ((reinterpret_cast< long >(pCppStack) & 7) != 0)
140
              		{
141
		   		OSL_ASSERT( sizeof (double) == sizeof (sal_Int64) );
142
                   		void * pDest = alloca( sizeof (sal_Int64) );
143
                  	 	*reinterpret_cast< sal_Int32 * >(pDest) =
144
                   		*reinterpret_cast< sal_Int32 const * >(pCppStack);
145
                   		*(reinterpret_cast< sal_Int32 * >(pDest) + 1) =
146
                   		*(reinterpret_cast< sal_Int32 const * >(pCppStack) + 1);
147
                   		pCppArgs[nPos] = pUnoArgs[nPos] = pDest;
148
			}
149
		   	pCppStack += sizeof (sal_Int32); // extra long
150
                   	break;
151
			}
152
			}
153
			// no longer needed
154
			TYPELIB_DANGER_RELEASE( pParamTypeDescr );
155
		}
156
		else // ptr to complex value | ref
157
		{
158
			pCppArgs[nPos] = *(void **)pCppStack;
159
160
			if (! rParam.bIn) // is pure out
161
			{
162
				// uno out is unconstructed mem!
163
				pUnoArgs[nPos] = alloca( pParamTypeDescr->nSize );
164
				pTempIndizes[nTempIndizes] = nPos;
165
				// will be released at reconversion
166
				ppTempParamTypeDescr[nTempIndizes++] = pParamTypeDescr;
167
			}
168
			// is in/inout
169
			else if (bridges::cpp_uno::shared::relatesToInterfaceType(
170
  	                        pParamTypeDescr ))
171
			{
172
				uno_copyAndConvertData( pUnoArgs[nPos] = alloca( pParamTypeDescr->nSize ),
173
										*(void **)pCppStack, pParamTypeDescr,
174
										  pThis->getBridge()->getCpp2Uno() );
175
				pTempIndizes[nTempIndizes] = nPos; // has to be reconverted
176
				// will be released at reconversion
177
				ppTempParamTypeDescr[nTempIndizes++] = pParamTypeDescr;
178
			}
179
			else // direct way
180
			{
181
				pUnoArgs[nPos] = *(void **)pCppStack;
182
				// no longer needed
183
				TYPELIB_DANGER_RELEASE( pParamTypeDescr );
184
			}
185
		}
186
		pCppStack += sizeof(sal_Int32); // standard parameter length
187
	}
188
	
189
	// ExceptionHolder
190
	uno_Any aUnoExc; // Any will be constructed by callee
191
	uno_Any * pUnoExc = &aUnoExc;
192
193
	// invoke uno dispatch call
194
	(*pThis->getUnoI()->pDispatcher)(pThis->getUnoI(), pMemberTypeDescr, pUnoReturn, pUnoArgs, &pUnoExc );
195
	
196
	// in case an exception occured...
197
	if (pUnoExc)
198
	{
199
		// destruct temporary in/inout params
200
		for ( ; nTempIndizes--; )
201
		{
202
			sal_Int32 nIndex = pTempIndizes[nTempIndizes];
203
			
204
			if (pParams[nIndex].bIn) // is in/inout => was constructed
205
				uno_destructData( pUnoArgs[nIndex], ppTempParamTypeDescr[nTempIndizes], 0 );
206
			TYPELIB_DANGER_RELEASE( ppTempParamTypeDescr[nTempIndizes] );
207
		}
208
		if (pReturnTypeDescr)
209
			TYPELIB_DANGER_RELEASE( pReturnTypeDescr );
210
		CPPU_CURRENT_NAMESPACE::raiseException(&aUnoExc, pThis->getBridge()->getUno2Cpp() );
211
  	           // has to destruct the any
212
		// is here for dummy
213
		return typelib_TypeClass_VOID;
214
	}
215
	else // else no exception occured...
216
	{
217
		// temporary params
218
		for ( ; nTempIndizes--; )
219
		{
220
			sal_Int32 nIndex = pTempIndizes[nTempIndizes];
221
			typelib_TypeDescription * pParamTypeDescr = ppTempParamTypeDescr[nTempIndizes];
222
			
223
			if (pParams[nIndex].bOut) // inout/out
224
			{
225
				// convert and assign
226
				uno_destructData( pCppArgs[nIndex], pParamTypeDescr, cpp_release );
227
				uno_copyAndConvertData( pCppArgs[nIndex], pUnoArgs[nIndex], pParamTypeDescr,
228
									pThis->getBridge()->getUno2Cpp() );
229
			}
230
			// destroy temp uno param
231
			uno_destructData( pUnoArgs[nIndex], pParamTypeDescr, 0 );
232
			
233
			TYPELIB_DANGER_RELEASE( pParamTypeDescr );
234
		}
235
		// return
236
		if (pCppReturn) // has complex return
237
		{
238
			if (pUnoReturn != pCppReturn) // needs reconversion
239
			{
240
				uno_copyAndConvertData( pCppReturn, pUnoReturn, pReturnTypeDescr,
241
										pThis->getBridge()->getUno2Cpp() );
242
				// destroy temp uno return
243
				uno_destructData( pUnoReturn, pReturnTypeDescr, 0 );
244
			}
245
			// complex return ptr is set to eax
246
			*(void **)pRegisterReturn = pCppReturn;
247
		}
248
		if (pReturnTypeDescr)
249
		{
250
			typelib_TypeClass eRet = (typelib_TypeClass)pReturnTypeDescr->eTypeClass;
251
			TYPELIB_DANGER_RELEASE( pReturnTypeDescr );
252
			return eRet;
253
		}
254
		else
255
			return typelib_TypeClass_VOID;
256
	}
257
}
258
259
260
//==================================================================================================
261
static typelib_TypeClass cpp_mediate(
262
	sal_Int32	nFunctionIndex,
263
	sal_Int32	nVtableOffset,
264
	void **	pCallStack,
265
	sal_Int64 * pRegisterReturn /* space for register return */ )
266
{
267
	OSL_ENSURE( sizeof(sal_Int32)==sizeof(void *), "### unexpected!" );
268
269
	// pCallStack: this, params
270
	// eventual [ret*] lies at pCallStack -1
271
	// so count down pCallStack by one to keep it simple
272
	// pCallStack: this, params
273
	// eventual [ret*] lies at pCallStack -1
274
	// so count down pCallStack by one to keep it simple
275
	bridges::cpp_uno::shared::CppInterfaceProxy * pCppI
276
		= bridges::cpp_uno::shared::CppInterfaceProxy::castInterfaceToProxy(
277
	static_cast< char * >(*pCallStack) - nVtableOffset);
278
	if ((nFunctionIndex & 0x80000000) != 0) {
279
		nFunctionIndex &= 0x7FFFFFFF;
280
		--pCallStack;
281
	}
282
283
	typelib_InterfaceTypeDescription * pTypeDescr = pCppI->getTypeDescr();
284
285
	OSL_ENSURE( nFunctionIndex < pTypeDescr->nMapFunctionIndexToMemberIndex,
286
				 "### illegal vtable index!" );
287
	if (nFunctionIndex >= pTypeDescr->nMapFunctionIndexToMemberIndex)
288
	{
289
		throw RuntimeException( rtl::OUString::createFromAscii("illegal vtable index!"), (XInterface *)pCppI );
290
	}
291
	
292
	// determine called method
293
	sal_Int32 nMemberPos = pTypeDescr->pMapFunctionIndexToMemberIndex[nFunctionIndex];
294
	OSL_ENSURE( nMemberPos < pTypeDescr->nAllMembers, "### illegal member index!" );
295
296
	TypeDescription aMemberDescr( pTypeDescr->ppAllMembers[nMemberPos] );
297
298
#if defined BRIDGES_DEBUG
299
	OString cstr( OUStringToOString( aMemberDescr.get()->pTypeName, RTL_TEXTENCODING_ASCII_US ) );
300
	fprintf( stderr, "calling %s, nFunctionIndex=%d\n", cstr.getStr(), nFunctionIndex );
301
#endif
302
303
	typelib_TypeClass eRet;
304
	switch (aMemberDescr.get()->eTypeClass)
305
	{
306
	case typelib_TypeClass_INTERFACE_ATTRIBUTE:
307
	{
308
		if (pTypeDescr->pMapMemberIndexToFunctionIndex[nMemberPos] == nFunctionIndex)
309
		{
310
			// is GET method
311
			eRet = cpp2uno_call(
312
				pCppI, aMemberDescr.get(),
313
				((typelib_InterfaceAttributeTypeDescription *)aMemberDescr.get())->pAttributeTypeRef,
314
				0, 0, // no params
315
				pCallStack, pRegisterReturn );
316
		}
317
		else
318
		{
319
			// is SET method
320
			typelib_MethodParameter aParam;
321
			aParam.pTypeRef =
322
				((typelib_InterfaceAttributeTypeDescription *)aMemberDescr.get())->pAttributeTypeRef;
323
			aParam.bIn		= sal_True;
324
			aParam.bOut		= sal_False;
325
			
326
			eRet = cpp2uno_call(
327
				pCppI, aMemberDescr.get(),
328
				0, // indicates void return
329
				1, &aParam,
330
				pCallStack, pRegisterReturn );
331
		}
332
		break;
333
	}
334
	case typelib_TypeClass_INTERFACE_METHOD:
335
	{
336
		// is METHOD
337
		switch (nFunctionIndex)
338
		{
339
		case 1: // acquire()
340
			pCppI->acquireProxy(); // non virtual call!
341
			eRet = typelib_TypeClass_VOID;
342
			break;
343
		case 2: // release()
344
			pCppI->releaseProxy(); // non virtual call!
345
			eRet = typelib_TypeClass_VOID;
346
			break;
347
		case 0: // queryInterface() opt
348
		{
349
			typelib_TypeDescription * pTD = 0;
350
			TYPELIB_DANGER_GET( &pTD, reinterpret_cast< Type * >( pCallStack[2] )->getTypeLibType() );
351
			if (pTD)
352
			{
353
                XInterface * pInterface = 0;
354
		(*pCppI->getBridge()->getCppEnv()->getRegisteredInterface)(
355
		    pCppI->getBridge()->getCppEnv(),
356
		    (void **)&pInterface, pCppI->getOid().pData, (typelib_InterfaceTypeDescription *)pTD );
357
			
358
                if (pInterface)
359
                {
360
                    ::uno_any_construct(
361
                        reinterpret_cast< uno_Any * >( pCallStack[0] ),
362
                        &pInterface, pTD, cpp_acquire );
363
                    pInterface->release();
364
                    TYPELIB_DANGER_RELEASE( pTD );
365
                    *(void **)pRegisterReturn = pCallStack[0];
366
                    eRet = typelib_TypeClass_ANY;
367
                    break;
368
                }
369
                TYPELIB_DANGER_RELEASE( pTD );
370
            }
371
		} // else perform queryInterface()
372
		default:
373
			eRet = cpp2uno_call(
374
				pCppI, aMemberDescr.get(),
375
				((typelib_InterfaceMethodTypeDescription *)aMemberDescr.get())->pReturnTypeRef,
376
				((typelib_InterfaceMethodTypeDescription *)aMemberDescr.get())->nParams,
377
				((typelib_InterfaceMethodTypeDescription *)aMemberDescr.get())->pParams,
378
				pCallStack, pRegisterReturn );
379
		}
380
		break;
381
	}
382
	default:
383
	{
384
		throw RuntimeException(rtl::OUString::createFromAscii("no member description found!"), (XInterface *)pCppI );
385
		// is here for dummy
386
		eRet = typelib_TypeClass_VOID;
387
	}
388
	}
389
	return eRet;
390
}
391
392
393
394
//==================================================================================================
395
/**
396
 * is called on incoming vtable calls
397
 * (called by asm snippets)
398
 */
399
static void cpp_vtable_call()
400
{
401
	volatile sal_Int64 nRegReturn;
402
	int nFunctionIndex;
403
	void** pCallStack;
404
	int vTableOffset;
405
406
	__asm__( "st %%i0, %0\n\t"
407
			"st %%i1, %1\n\t"
408
 			"st %%i2, %2\n\t"
409
			: : "m"(nFunctionIndex), "m"(pCallStack), "m"(vTableOffset) );
410
411
//	fprintf(stderr,"cpp_mediate nFunctionIndex=%x\n",nFunctionIndex);
412
//	fflush(stderr);
413
414
	sal_Bool bComplex = nFunctionIndex & 0x80000000 ? sal_True : sal_False;
415
	typelib_TypeClass aType =
416
		cpp_mediate( nFunctionIndex, vTableOffset, pCallStack+17, (sal_Int64*)&nRegReturn );
417
418
	switch( aType )
419
	{
420
		case typelib_TypeClass_BOOLEAN:
421
		case typelib_TypeClass_BYTE:
422
			__asm__( "ld %0, %%l0\n\t"
423
					 "ldsb [%%l0], %%i0\n"
424
					 : : "m"(&nRegReturn) );
425
			break;
426
		case typelib_TypeClass_CHAR:
427
		case typelib_TypeClass_SHORT:
428
		case typelib_TypeClass_UNSIGNED_SHORT:
429
			__asm__( "ld %0, %%l0\n\t"
430
					 "ldsh [%%l0], %%i0\n"
431
					 : : "m"(&nRegReturn) );
432
			break;
433
		case typelib_TypeClass_HYPER:
434
		case typelib_TypeClass_UNSIGNED_HYPER:
435
436
			__asm__( "ld %0, %%l0\n\t"
437
					 "ld [%%l0], %%i0\n\t"
438
					 "ld %1, %%l0\n\t"
439
					 "ld [%%l0], %%i1\n\t"
440
					 : : "m"(&nRegReturn), "m"(((long*)&nRegReturn) +1) );
441
442
			break;
443
		case typelib_TypeClass_FLOAT:
444
			__asm__( "ld %0, %%l0\n\t"
445
					 "ld [%%l0], %%f0\n"
446
					 : : "m"(&nRegReturn) );
447
			break;
448
		case typelib_TypeClass_DOUBLE:
449
			__asm__( "ld %0, %%l0\n\t"
450
					 "ldd [%%l0], %%f0\n"
451
					 : : "m"(&nRegReturn) );
452
			break;
453
		case typelib_TypeClass_VOID:
454
			break;
455
		default:
456
			__asm__( "ld %0, %%l0\n\t"
457
					 "ld [%%l0], %%i0\n"
458
					 : : "m"(&nRegReturn) );
459
			break;
460
	}
461
462
	if( bComplex )
463
	{
464
		__asm__( "add %i7, 4, %i7\n\t" );
465
		// after call to complex return valued funcion there is an unimp instruction
466
	}
467
468
}
469
//__________________________________________________________________________________________________
470
471
int const codeSnippetSize = 56;
472
unsigned char * codeSnippet(
473
    unsigned char * code, sal_Int32 functionIndex, sal_Int32 vtableOffset,
474
    bool simpleRetType)
475
{
476
    sal_uInt32 index = functionIndex;
477
    if (!simpleRetType) {
478
        index |= 0x80000000;
479
    }
480
    unsigned int * p = reinterpret_cast< unsigned int * >(code);
481
    OSL_ASSERT(sizeof (unsigned int) == 4);
482
    // st %o0, [%sp+68]:
483
    *p++ = 0xD023A044;
484
    // st %o1, [%sp+72]:
485
    *p++ = 0xD223A048;
486
    // st %o2, [%sp+76]:
487
    *p++ = 0xD423A04C;
488
    // st %o3, [%sp+80]:
489
    *p++ = 0xD623A050;
490
    // st %o4, [%sp+84]:
491
    *p++ = 0xD823A054;
492
    // st %o5, [%sp+88]:
493
    *p++ = 0xDA23A058;
494
    // sethi %hi(index), %o0:
495
    *p++ = 0x11000000 | (index >> 10);
496
    // or %o0, %lo(index), %o0:
497
    *p++ = 0x90122000 | (index & 0x3FF);
498
    // sethi %hi(vtableOffset), %o2:
499
    *p++ = 0x15000000 | (vtableOffset >> 10);
500
    // or %o2, %lo(vtableOffset), %o2:
501
    *p++ = 0x9412A000 | (vtableOffset & 0x3FF);
502
    // sethi %hi(cpp_vtable_call), %o3:
503
    *p++ = 0x17000000 | (reinterpret_cast< unsigned int >(cpp_vtable_call) >> 10);
504
    // or %o3, %lo(cpp_vtable_call), %o3:
505
    *p++ = 0x9612E000 | (reinterpret_cast< unsigned int >(cpp_vtable_call) & 0x3FF);
506
    // jmpl %o3, %g0:
507
    *p++ = 0x81C2C000;
508
    // mov %sp, %o1:
509
    *p++ = 0x9210000E;
510
    OSL_ASSERT(
511
        reinterpret_cast< unsigned char * >(p) - code <= codeSnippetSize);
512
    return code + codeSnippetSize;
513
}
514
515
} //end of namespace
516
517
void ** bridges::cpp_uno::shared::VtableFactory::mapBlockToVtable(char * block)
518
{
519
    return reinterpret_cast< void ** >(block) + 2;
520
}
521
522
char * bridges::cpp_uno::shared::VtableFactory::createBlock(
523
    sal_Int32 slotCount, void *** slots)
524
{
525
    char * block = new char[
526
        (slotCount + 2) * sizeof (void *) + slotCount * codeSnippetSize];
527
    *slots = mapBlockToVtable(block);
528
     (*slots)[-2] = 0; //null
529
     (*slots)[-1] = 0; //destructor
530
    return block;
531
}
532
533
unsigned char * bridges::cpp_uno::shared::VtableFactory::addLocalFunctions(
534
    void ** slots, unsigned char * code,
535
    typelib_InterfaceTypeDescription const * type, sal_Int32 functionOffset,
536
    sal_Int32 functionCount, sal_Int32 vTableOffset)
537
{
538
	for (sal_Int32 i = 0; i < type->nMembers; ++i) {
539
        typelib_TypeDescription * member = 0;
540
        TYPELIB_DANGER_GET(&member, type->ppMembers[i]);
541
        OSL_ASSERT(member != 0);
542
        switch (member->eTypeClass) {
543
        case typelib_TypeClass_INTERFACE_ATTRIBUTE:
544
            // Getter:
545
            *slots++ = code;
546
            code = codeSnippet(
547
                code, functionOffset++, vTableOffset,
548
                bridges::cpp_uno::shared::isSimpleType(
549
                    reinterpret_cast<
550
		    typelib_InterfaceAttributeTypeDescription * >(
551
		    member)->pAttributeTypeRef));
552
            // Setter:
553
            if (!reinterpret_cast<
554
                typelib_InterfaceAttributeTypeDescription * >(
555
                    member)->bReadOnly)
556
            {
557
                *slots++ = code;
558
                code = codeSnippet(code, functionOffset++, vTableOffset, true);
559
            }
560
            break;
561
562
        case typelib_TypeClass_INTERFACE_METHOD:
563
            *slots++ = code;
564
            code = codeSnippet(
565
                code, functionOffset++, vTableOffset,
566
                bridges::cpp_uno::shared::isSimpleType(
567
                    reinterpret_cast<
568
                    typelib_InterfaceMethodTypeDescription * >(
569
                        member)->pReturnTypeRef));
570
            break;
571
572
        default:
573
            OSL_ASSERT(false);
574
            break;
575
        }
576
        TYPELIB_DANGER_RELEASE(member);
577
    }
578
    return code;
579
}
580
581
void bridges::cpp_uno::shared::VtableFactory::flushCode(
582
	   unsigned char const *, unsigned char const *)
583
  	{
584
        //TODO: IZ 25819  flush the instruction cache (there probably is OS support for this)
585
	}
(-)ooo/bridges/source/cpp_uno/gcc3_solaris_sparc.orig/except.cxx (+358 lines)
Line 0 Link Here
1
/*************************************************************************
2
 *
3
 *  $RCSfile: except.cxx,v $
4
 *
5
 *  $Revision: 1.3 $
6
 *
7
 *  last change: $Author: svesik $ $Date: 2004/04/21 13:41:00 $
8
 *
9
 *  The Contents of this file are made available subject to the terms of
10
 *  either of the following licenses
11
 *
12
 *         - GNU Lesser General Public License Version 2.1
13
 *         - Sun Industry Standards Source License Version 1.1
14
 *
15
 *  Sun Microsystems Inc., October, 2000
16
 *
17
 *  GNU Lesser General Public License Version 2.1
18
 *  =============================================
19
 *  Copyright 2000 by Sun Microsystems, Inc.
20
 *  901 San Antonio Road, Palo Alto, CA 94303, USA
21
 *
22
 *  This library is free software; you can redistribute it and/or
23
 *  modify it under the terms of the GNU Lesser General Public
24
 *  License version 2.1, as published by the Free Software Foundation.
25
 *
26
 *  This library is distributed in the hope that it will be useful,
27
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
28
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
29
 *  Lesser General Public License for more details.
30
 *
31
 *  You should have received a copy of the GNU Lesser General Public
32
 *  License along with this library; if not, write to the Free Software
33
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
34
 *  MA  02111-1307  USA
35
 *
36
 *
37
 *  Sun Industry Standards Source License Version 1.1
38
 *  =================================================
39
 *  The contents of this file are subject to the Sun Industry Standards
40
 *  Source License Version 1.1 (the "License"); You may not use this file
41
 *  except in compliance with the License. You may obtain a copy of the
42
 *  License at http://www.openoffice.org/license.html.
43
 *
44
 *  Software provided under this License is provided on an "AS IS" basis,
45
 *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
46
 *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
47
 *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
48
 *  See the License for the specific provisions governing your rights and
49
 *  obligations concerning the Software.
50
 *
51
 *  The Initial Developer of the Original Code is: Sun Microsystems, Inc.
52
 *
53
 *  Copyright: 2000 by Sun Microsystems, Inc.
54
 *
55
 *  All Rights Reserved.
56
 *
57
 *  Contributor(s): _______________________________________
58
 *
59
 *
60
 ************************************************************************/
61
#include <stdio.h>
62
#include <dlfcn.h>
63
#include <cxxabi.h>
64
#include <hash_map>
65
66
#include <rtl/strbuf.hxx>
67
#include <rtl/ustrbuf.hxx>
68
#include <osl/diagnose.h>
69
#include <osl/mutex.hxx>
70
71
#include <com/sun/star/uno/genfunc.hxx>
72
#include <typelib/typedescription.hxx>
73
#include <uno/any2.h>
74
75
#include "share.hxx"
76
77
78
using namespace ::std;
79
using namespace ::osl;
80
using namespace ::rtl;
81
using namespace ::com::sun::star::uno;
82
using namespace ::__cxxabiv1;
83
84
85
namespace CPPU_CURRENT_NAMESPACE
86
{
87
    
88
void dummy_can_throw_anything( char const * )
89
{
90
}
91
92
//==================================================================================================
93
static OUString toUNOname( char const * p ) SAL_THROW( () )
94
{
95
#if defined BRIDGES_DEBUG
96
    char const * start = p;
97
#endif
98
    
99
    // example: N3com3sun4star4lang24IllegalArgumentExceptionE
100
    
101
	OUStringBuffer buf( 64 );
102
    OSL_ASSERT( 'N' == *p );
103
    ++p; // skip N
104
    
105
    while ('E' != *p)
106
    {
107
        // read chars count
108
        long n = (*p++ - '0');
109
        while ('0' <= *p && '9' >= *p)
110
        {
111
            n *= 10;
112
            n += (*p++ - '0');
113
        }
114
        buf.appendAscii( p, n );
115
        p += n;
116
        if ('E' != *p)
117
            buf.append( (sal_Unicode)'.' );
118
    }
119
    
120
#if defined BRIDGES_DEBUG
121
    OUString ret( buf.makeStringAndClear() );
122
    OString c_ret( OUStringToOString( ret, RTL_TEXTENCODING_ASCII_US ) );
123
    fprintf( stderr, "> toUNOname(): %s => %s\n", start, c_ret.getStr() );
124
    return ret;
125
#else
126
    return buf.makeStringAndClear();
127
#endif
128
}
129
130
//==================================================================================================
131
class RTTI
132
{
133
    typedef hash_map< OUString, type_info *, OUStringHash > t_rtti_map;
134
    
135
    Mutex m_mutex;
136
	t_rtti_map m_rttis;
137
    t_rtti_map m_generatedRttis;
138
139
    void * m_hApp;
140
    
141
public:
142
    RTTI() SAL_THROW( () );
143
    ~RTTI() SAL_THROW( () );
144
    
145
    type_info * getRTTI( typelib_CompoundTypeDescription * ) SAL_THROW( () );
146
};
147
//__________________________________________________________________________________________________
148
RTTI::RTTI() SAL_THROW( () )
149
    : m_hApp( dlopen( 0, RTLD_LAZY ) )
150
{
151
}
152
//__________________________________________________________________________________________________
153
RTTI::~RTTI() SAL_THROW( () )
154
{
155
    dlclose( m_hApp );
156
}
157
158
//__________________________________________________________________________________________________
159
type_info * RTTI::getRTTI( typelib_CompoundTypeDescription *pTypeDescr ) SAL_THROW( () )
160
{
161
    type_info * rtti;
162
    
163
    OUString const & unoName = *(OUString const *)&pTypeDescr->aBase.pTypeName;
164
    
165
    MutexGuard guard( m_mutex );
166
    t_rtti_map::const_iterator iFind( m_rttis.find( unoName ) );
167
    if (iFind == m_rttis.end())
168
    {
169
        // RTTI symbol
170
        OStringBuffer buf( 64 );
171
        buf.append( RTL_CONSTASCII_STRINGPARAM("_ZTIN") );
172
        sal_Int32 index = 0;
173
        do
174
        {
175
            OUString token( unoName.getToken( 0, '.', index ) );
176
            buf.append( token.getLength() );
177
            OString c_token( OUStringToOString( token, RTL_TEXTENCODING_ASCII_US ) );
178
            buf.append( c_token );
179
        }
180
        while (index >= 0);
181
        buf.append( 'E' );
182
        
183
        OString symName( buf.makeStringAndClear() );
184
        rtti = (type_info *)dlsym( m_hApp, symName.getStr() );
185
186
        if (rtti)
187
        {
188
            pair< t_rtti_map::iterator, bool > insertion(
189
                m_rttis.insert( t_rtti_map::value_type( unoName, rtti ) ) );
190
            OSL_ENSURE( insertion.second, "### inserting new rtti failed?!" );
191
        }
192
        else
193
        {
194
            // try to lookup the symbol in the generated rtti map
195
            t_rtti_map::const_iterator iFind( m_generatedRttis.find( unoName ) );
196
            if (iFind == m_generatedRttis.end())
197
            {
198
                // we must generate it !
199
                // symbol and rtti-name is nearly identical,
200
                // the symbol is prefixed with _ZTI
201
                char const * rttiName = symName.getStr() +4;
202
#if defined BRIDGES_DEBUG
203
                fprintf( stderr,"generated rtti for %s\n", rttiName );
204
#endif
205
                if (pTypeDescr->pBaseTypeDescription)
206
                {
207
                    // ensure availability of base
208
                    type_info * base_rtti = getRTTI(
209
                        (typelib_CompoundTypeDescription *)pTypeDescr->pBaseTypeDescription );
210
                    rtti = new __si_class_type_info(
211
                        strdup( rttiName ), (__class_type_info *)base_rtti );
212
                }
213
                else
214
                {
215
                    // this class has no base class
216
                    rtti = new __class_type_info( strdup( rttiName ) );
217
                }
218
                
219
                pair< t_rtti_map::iterator, bool > insertion(
220
                    m_generatedRttis.insert( t_rtti_map::value_type( unoName, rtti ) ) );
221
                OSL_ENSURE( insertion.second, "### inserting new generated rtti failed?!" );
222
            }
223
            else // taking already generated rtti
224
            {
225
                rtti = iFind->second;
226
            }
227
        }
228
    }
229
    else
230
    {
231
        rtti = iFind->second;
232
    }
233
    
234
    return rtti;
235
}
236
237
//--------------------------------------------------------------------------------------------------
238
static void deleteException( void * pExc )
239
{
240
    __cxa_exception const * header = ((__cxa_exception const *)pExc - 1);
241
    typelib_TypeDescription * pTD = 0;
242
    OUString unoName( toUNOname( header->exceptionType->name() ) );
243
    ::typelib_typedescription_getByName( &pTD, unoName.pData );
244
    OSL_ENSURE( pTD, "### unknown exception type! leaving out destruction => leaking!!!" );
245
    if (pTD)
246
    {
247
		::uno_destructData( pExc, pTD, cpp_release );
248
		::typelib_typedescription_release( pTD );
249
	}
250
}
251
252
//==================================================================================================
253
void raiseException( uno_Any * pUnoExc, uno_Mapping * pUno2Cpp )
254
{
255
#if defined BRIDGES_DEBUG
256
    OString cstr(
257
        OUStringToOString(
258
            *reinterpret_cast< OUString const * >( &pUnoExc->pType->pTypeName ),
259
            RTL_TEXTENCODING_ASCII_US ) );
260
    fprintf( stderr, "> uno exception occured: %s\n", cstr.getStr() );
261
#endif
262
    void * pCppExc;
263
    type_info * rtti;
264
265
    {
266
    // construct cpp exception object
267
	typelib_TypeDescription * pTypeDescr = 0;
268
	TYPELIB_DANGER_GET( &pTypeDescr, pUnoExc->pType );
269
    OSL_ASSERT( pTypeDescr );
270
    if (! pTypeDescr)
271
    {
272
        throw RuntimeException(
273
            OUString( RTL_CONSTASCII_USTRINGPARAM("cannot get typedescription for type ") ) +
274
            *reinterpret_cast< OUString const * >( &pUnoExc->pType->pTypeName ),
275
            Reference< XInterface >() );
276
    }
277
    
278
	pCppExc = __cxa_allocate_exception( pTypeDescr->nSize );
279
	::uno_copyAndConvertData( pCppExc, pUnoExc->pData, pTypeDescr, pUno2Cpp );
280
	
281
	// destruct uno exception
282
	::uno_any_destruct( pUnoExc, 0 );
283
    // avoiding locked counts
284
    static RTTI * s_rtti = 0;
285
    if (! s_rtti)
286
    {
287
        MutexGuard guard( Mutex::getGlobalMutex() );
288
        if (! s_rtti)
289
        {
290
#ifdef LEAK_STATIC_DATA
291
            s_rtti = new RTTI();
292
#else
293
            static RTTI rtti_data;
294
            s_rtti = &rtti_data;
295
#endif
296
        }
297
    }
298
	rtti = (type_info *)s_rtti->getRTTI( (typelib_CompoundTypeDescription *) pTypeDescr );
299
    TYPELIB_DANGER_RELEASE( pTypeDescr );
300
    OSL_ENSURE( rtti, "### no rtti for throwing exception!" );
301
    if (! rtti)
302
    {
303
        throw RuntimeException(
304
            OUString( RTL_CONSTASCII_USTRINGPARAM("no rtti for type ") ) +
305
            *reinterpret_cast< OUString const * >( &pUnoExc->pType->pTypeName ),
306
            Reference< XInterface >() );
307
    }
308
    }
309
    
310
	__cxa_throw( pCppExc, rtti, deleteException );
311
}
312
313
//==================================================================================================
314
void fillUnoException( __cxa_exception * header, uno_Any * pUnoExc, uno_Mapping * pCpp2Uno )
315
{
316
    if (! header)
317
    {
318
        RuntimeException aRE(
319
            OUString( RTL_CONSTASCII_USTRINGPARAM("no exception header!") ),
320
            Reference< XInterface >() );
321
        Type const & rType = ::getCppuType( &aRE );
322
        uno_type_any_constructAndConvert( pUnoExc, &aRE, rType.getTypeLibType(), pCpp2Uno );
323
#if defined _DEBUG
324
        OString cstr( OUStringToOString( aRE.Message, RTL_TEXTENCODING_ASCII_US ) );
325
        OSL_ENSURE( 0, cstr.getStr() );
326
#endif
327
        return;
328
    }
329
    
330
	typelib_TypeDescription * pExcTypeDescr = 0;
331
    OUString unoName( toUNOname( header->exceptionType->name() ) );
332
#if defined BRIDGES_DEBUG
333
    OString cstr_unoName( OUStringToOString( unoName, RTL_TEXTENCODING_ASCII_US ) );
334
    fprintf( stderr, "> c++ exception occured: %s\n", cstr_unoName.getStr() );
335
#endif
336
	typelib_typedescription_getByName( &pExcTypeDescr, unoName.pData );
337
    if (0 == pExcTypeDescr)
338
    {
339
        RuntimeException aRE(
340
            OUString( RTL_CONSTASCII_USTRINGPARAM("exception type not found: ") ) + unoName,
341
            Reference< XInterface >() );
342
        Type const & rType = ::getCppuType( &aRE );
343
        uno_type_any_constructAndConvert( pUnoExc, &aRE, rType.getTypeLibType(), pCpp2Uno );
344
#if defined _DEBUG
345
        OString cstr( OUStringToOString( aRE.Message, RTL_TEXTENCODING_ASCII_US ) );
346
        OSL_ENSURE( 0, cstr.getStr() );
347
#endif
348
    }
349
    else
350
    {
351
        // construct uno exception any
352
        uno_any_constructAndConvert( pUnoExc, header->adjustedPtr, pExcTypeDescr, pCpp2Uno );
353
        typelib_typedescription_release( pExcTypeDescr );
354
    }
355
}
356
357
}
358
(-)ooo/bridges/source/cpp_uno/gcc3_solaris_sparc.orig/makefile.mk (+114 lines)
Line 0 Link Here
1
#*************************************************************************
2
#
3
#   $RCSfile: makefile.mk,v $
4
#
5
#   $Revision: 1.3 $
6
#
7
#   last change: $Author: svesik $ $Date: 2004/04/21 13:41:21 $
8
#
9
#   The Contents of this file are made available subject to the terms of
10
#   either of the following licenses
11
#
12
#          - GNU Lesser General Public License Version 2.1
13
#          - Sun Industry Standards Source License Version 1.1
14
#
15
#   Sun Microsystems Inc., October, 2000
16
#
17
#   GNU Lesser General Public License Version 2.1
18
#   =============================================
19
#   Copyright 2000 by Sun Microsystems, Inc.
20
#   901 San Antonio Road, Palo Alto, CA 94303, USA
21
#
22
#   This library is free software; you can redistribute it and/or
23
#   modify it under the terms of the GNU Lesser General Public
24
#   License version 2.1, as published by the Free Software Foundation.
25
#
26
#   This library is distributed in the hope that it will be useful,
27
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
28
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
29
#   Lesser General Public License for more details.
30
#
31
#   You should have received a copy of the GNU Lesser General Public
32
#   License along with this library; if not, write to the Free Software
33
#   Foundation, Inc., 59 Temple Place, Suite 330, Boston,
34
#   MA  02111-1307  USA
35
#
36
#
37
#   Sun Industry Standards Source License Version 1.1
38
#   =================================================
39
#   The contents of this file are subject to the Sun Industry Standards
40
#   Source License Version 1.1 (the "License"); You may not use this file
41
#   except in compliance with the License. You may obtain a copy of the
42
#   License at http://www.openoffice.org/license.html.
43
#
44
#   Software provided under this License is provided on an "AS IS" basis,
45
#   WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
46
#   WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
47
#   MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
48
#   See the License for the specific provisions governing your rights and
49
#   obligations concerning the Software.
50
#
51
#   The Initial Developer of the Original Code is: Sun Microsystems, Inc.
52
#
53
#   Copyright: 2000 by Sun Microsystems, Inc.
54
#
55
#   All Rights Reserved.
56
#
57
#   Contributor(s): _______________________________________
58
#
59
#
60
#
61
#*************************************************************************
62
PRJ=..$/..$/..
63
64
PRJNAME=bridges
65
TARGET=gcc3_uno
66
LIBTARGET=no
67
ENABLE_EXCEPTIONS=TRUE
68
NO_BSYMBOLIC=TRUE
69
70
# --- Settings -----------------------------------------------------
71
72
.INCLUDE :  svpre.mk
73
.INCLUDE :  settings.mk
74
.INCLUDE :  sv.mk
75
76
# --- Files --------------------------------------------------------
77
78
.IF "$(COM)$(OS)$(CPU)" == "GCCSOLARISS"
79
80
.IF "$(cppu_no_leak)" == ""
81
CFLAGS += -DLEAK_STATIC_DATA
82
.ENDIF
83
84
CFLAGSNOOPT=-O0
85
86
NOOPTFILES = \
87
	$(SLO)$/uno2cpp.obj	\
88
	$(SLO)$/cpp2uno.obj
89
90
SLOFILES= \
91
	$(SLO)$/except.obj		\
92
	$(SLO)$/cpp2uno.obj		\
93
	$(SLO)$/uno2cpp.obj
94
95
96
SHL1TARGET=$(TARGET)
97
98
SHL1DEF=$(MISC)$/$(SHL1TARGET).def
99
SHL1IMPLIB=i$(TARGET)
100
SHL1VERSIONMAP=..$/..$/bridge_exports.map
101
102
SHL1OBJS= $(SLOFILES)
103
SHL1LIBS =$(SLB)$/cpp_uno_shared.lib
104
105
SHL1STDLIBS= \
106
	$(CPPULIB) \
107
	$(SALLIB)
108
109
.ENDIF
110
111
# --- Targets ------------------------------------------------------
112
113
.INCLUDE :  target.mk
114
(-)ooo/bridges/source/cpp_uno/gcc3_solaris_sparc.orig/share.hxx (+131 lines)
Line 0 Link Here
1
/*************************************************************************
2
 *
3
 *  $RCSfile: share.hxx,v $
4
 *
5
 *  $Revision: 1.3 $
6
 *
7
 *  last change: $Author: svesik $ $Date: 2004/04/21 13:41:36 $
8
 *
9
 *  The Contents of this file are made available subject to the terms of
10
 *  either of the following licenses
11
 *
12
 *         - GNU Lesser General Public License Version 2.1
13
 *         - Sun Industry Standards Source License Version 1.1
14
 *
15
 *  Sun Microsystems Inc., October, 2000
16
 *
17
 *  GNU Lesser General Public License Version 2.1
18
 *  =============================================
19
 *  Copyright 2000 by Sun Microsystems, Inc.
20
 *  901 San Antonio Road, Palo Alto, CA 94303, USA
21
 *
22
 *  This library is free software; you can redistribute it and/or
23
 *  modify it under the terms of the GNU Lesser General Public
24
 *  License version 2.1, as published by the Free Software Foundation.
25
 *
26
 *  This library is distributed in the hope that it will be useful,
27
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
28
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
29
 *  Lesser General Public License for more details.
30
 *
31
 *  You should have received a copy of the GNU Lesser General Public
32
 *  License along with this library; if not, write to the Free Software
33
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
34
 *  MA  02111-1307  USA
35
 *
36
 *
37
 *  Sun Industry Standards Source License Version 1.1
38
 *  =================================================
39
 *  The contents of this file are subject to the Sun Industry Standards
40
 *  Source License Version 1.1 (the "License"); You may not use this file
41
 *  except in compliance with the License. You may obtain a copy of the
42
 *  License at http://www.openoffice.org/license.html.
43
 *
44
 *  Software provided under this License is provided on an "AS IS" basis,
45
 *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
46
 *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
47
 *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
48
 *  See the License for the specific provisions governing your rights and
49
 *  obligations concerning the Software.
50
 *
51
 *  The Initial Developer of the Original Code is: Sun Microsystems, Inc.
52
 *
53
 *  Copyright: 2000 by Sun Microsystems, Inc.
54
 *
55
 *  All Rights Reserved.
56
 *
57
 *  Contributor(s): _______________________________________
58
 *
59
 *
60
 ************************************************************************/
61
#include "uno/mapping.h"
62
#include <typeinfo>
63
#include <exception>
64
#include <cstddef>
65
namespace CPPU_CURRENT_NAMESPACE
66
{
67
void dummy_can_throw_anything( char const * );
68
// ----- following decl from libstdc++-v3/libsupc++/unwind-cxx.h and unwind.h
69
70
struct _Unwind_Exception
71
{
72
    unsigned exception_class __attribute__((__mode__(__DI__)));
73
    void * exception_cleanup;
74
    unsigned private_1 __attribute__((__mode__(__word__)));
75
    unsigned private_2 __attribute__((__mode__(__word__)));
76
} __attribute__((__aligned__));
77
78
struct __cxa_exception
79
{ 
80
    ::std::type_info *exceptionType;
81
    void (*exceptionDestructor)(void *); 
82
    
83
    ::std::unexpected_handler unexpectedHandler;
84
    ::std::terminate_handler terminateHandler;
85
    
86
    __cxa_exception *nextException;
87
    
88
    int handlerCount;
89
    
90
    int handlerSwitchValue;
91
    const unsigned char *actionRecord;
92
    const unsigned char *languageSpecificData;
93
    void *catchTemp;
94
    void *adjustedPtr;
95
    
96
    _Unwind_Exception unwindHeader;
97
};    
98
99
extern "C" void *__cxa_allocate_exception(
100
    std::size_t thrown_size ) throw();
101
extern "C" void __cxa_throw (
102
    void *thrown_exception, std::type_info *tinfo, void (*dest) (void *) ) __attribute__((noreturn));
103
104
struct __cxa_eh_globals
105
{
106
    __cxa_exception *caughtExceptions;
107
    unsigned int uncaughtExceptions;
108
};
109
extern "C" __cxa_eh_globals *__cxa_get_globals () throw();
110
111
//==================================================================================================
112
void raiseException(
113
    uno_Any * pUnoExc, uno_Mapping * pUno2Cpp );
114
//==================================================================================================
115
void fillUnoException(
116
    __cxa_exception * header, uno_Any *, uno_Mapping * pCpp2Uno );
117
118
inline char* adjustPointer( char* pIn, typelib_TypeDescription* pType )
119
{
120
	switch( pType->nSize )
121
	{
122
		case 1: return pIn + 3;
123
		case 2: return pIn + 2;
124
		case 3: return pIn + 1;
125
			// Huh ? perhaps a char[3] ? Though that would be a pointer
126
			// well, we have it anyway for symmetry
127
	}
128
	return pIn;
129
}
130
131
}
(-)ooo/bridges/source/cpp_uno/gcc3_solaris_sparc.orig/uno2cpp.cxx (+626 lines)
Line 0 Link Here
1
/*************************************************************************
2
 *
3
 *  $RCSfile: uno2cpp.cxx,v $
4
 *
5
 *  $Revision: 1.6 $
6
 *
7
 *  last change: $Author: obo $ $Date: 2005/01/25 13:12:00 $
8
 *
9
 *  The Contents of this file are made available subject to the terms of
10
 *  either of the following licenses
11
 *
12
 *         - GNU Lesser General Public License Version 2.1
13
 *         - Sun Industry Standards Source License Version 1.1
14
 *
15
 *  Sun Microsystems Inc., October, 2000
16
 *
17
 *  GNU Lesser General Public License Version 2.1
18
 *  =============================================
19
 *  Copyright 2000 by Sun Microsystems, Inc.
20
 *  901 San Antonio Road, Palo Alto, CA 94303, USA
21
 *
22
 *  This library is free software; you can redistribute it and/or
23
 *  modify it under the terms of the GNU Lesser General Public
24
 *  License version 2.1, as published by the Free Software Foundation.
25
 *
26
 *  This library is distributed in the hope that it will be useful,
27
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
28
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
29
 *  Lesser General Public License for more details.
30
 *
31
 *  You should have received a copy of the GNU Lesser General Public
32
 *  License along with this library; if not, write to the Free Software
33
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
34
 *  MA  02111-1307  USA
35
 *
36
 *
37
 *  Sun Industry Standards Source License Version 1.1
38
 *  =================================================
39
 *  The contents of this file are subject to the Sun Industry Standards
40
 *  Source License Version 1.1 (the "License"); You may not use this file
41
 *  except in compliance with the License. You may obtain a copy of the
42
 *  License at http://www.openoffice.org/license.html.
43
 *
44
 *  Software provided under this License is provided on an "AS IS" basis,
45
 *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
46
 *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
47
 *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
48
 *  See the License for the specific provisions governing your rights and
49
 *  obligations concerning the Software.
50
 *
51
 *  The Initial Developer of the Original Code is: Sun Microsystems, Inc.
52
 *
53
 *  Copyright: 2000 by Sun Microsystems, Inc.
54
 *
55
 *  All Rights Reserved.
56
 *
57
 *  Contributor(s): _______________________________________
58
 *
59
 *
60
 ************************************************************************/
61
#include <malloc.h>
62
#include <com/sun/star/uno/genfunc.hxx>
63
#ifndef _UNO_DATA_H_
64
#include <uno/data.h>
65
#endif
66
67
#include "bridges/cpp_uno/shared/bridge.hxx"
68
#include "bridges/cpp_uno/shared/types.hxx"
69
#include "bridges/cpp_uno/shared/unointerfaceproxy.hxx"
70
#include "bridges/cpp_uno/shared/vtables.hxx"
71
72
#include "share.hxx"
73
74
#include <alloca.h>
75
76
using namespace rtl;
77
using namespace com::sun::star::uno;
78
79
namespace
80
{
81
//==================================================================================================
82
// The call instruction within the asm section of callVirtualMethod may throw
83
// exceptions.  So that the compiler handles this correctly, it is important
84
// that (a) callVirtualMethod might call dummy_can_throw_anything (although this
85
// never happens at runtime), which in turn can throw exceptions, and (b)
86
// callVirtualMethod is not inlined at its call site (so that any exceptions are
87
// caught which are thrown from the instruction calling callVirtualMethod):
88
89
void callVirtualMethod( void * pAdjustedThisPtr,
90
                        sal_Int32 nVtableIndex,
91
                        void * pRegisterReturn,
92
                        typelib_TypeClass eReturnType,
93
                        sal_Int32 * pStackLongs,
94
                        sal_Int32 nStackLongs ) __attribute__((noinline));
95
96
void callVirtualMethod( void * pAdjustedThisPtr,
97
                        sal_Int32 nVtableIndex,
98
                        void * pRegisterReturn,
99
                        typelib_TypeClass eReturnType,
100
                        sal_Int32 * pStackLongs,
101
                        sal_Int32 nStackLongs )
102
{
103
	// parameter list is mixed list of * and values
104
	// reference parameters are pointers
105
106
	OSL_ENSURE( pStackLongs && pAdjustedThisPtr, "### null ptr!" );
107
	OSL_ENSURE( (sizeof(void *) == 4) &&
108
				 (sizeof(sal_Int32) == 4), "### unexpected size of int!" );
109
	OSL_ENSURE( nStackLongs && pStackLongs, "### no stack in callVirtualMethod !" );
110
111
    // never called
112
    if (! pAdjustedThisPtr) CPPU_CURRENT_NAMESPACE::dummy_can_throw_anything("xxx"); // address something
113
114
	volatile long o0 = 0, o1 = 0; // for register returns
115
	volatile double f0d = 0;
116
	volatile float f0f = 0;
117
	volatile long long saveReg[7];
118
119
	__asm__ (
120
		// save registers
121
		"std %%l0, [%4]\n\t"
122
		"mov %4, %%l0\n\t"
123
		"mov %%l0, %%l1\n\t"
124
		"add %%l0, 8, %%l0\n\t"
125
		"std %%l2, [%%l0]\n\t"
126
		"add %%l0, 8, %%l0\n\t"
127
		"std %%l4, [%%l0]\n\t"
128
		"add %%l0, 8, %%l0\n\t"
129
		"std %%o0, [%%l0]\n\t"
130
		"add %%l0, 8, %%l0\n\t"
131
		"std %%o2, [%%l0]\n\t"
132
		"add %%l0, 8, %%l0\n\t"
133
		"std %%o4, [%%l0]\n\t"
134
		"add %%l0, 8, %%l0\n\t"
135
		"std %%l6, [%%l0]\n\t"
136
		"mov %%l1, %%l7\n\t"
137
138
		// increase our own stackframe if necessary
139
		"mov %%sp, %%l3\n\t"		// save stack ptr for readjustment
140
141
		"subcc %%i5, 7, %%l0\n\t"
142
		"ble .LmoveOn\n\t"
143
		"nop\n\t"
144
145
		"sll %%l0, 2, %%l0\n\t"
146
		"add %%l0, 96, %%l0\n\t"
147
		"mov %%sp, %%l1\n\t"		// old stack ptr
148
		"sub %%sp, %%l0, %%l0\n\t"	// future stack ptr
149
		"andcc %%l0, 7, %%g0\n\t"	// align stack to 8
150
		"be .LisAligned\n\t"
151
		"nop\n\t"
152
		"sub %%l0, 4, %%l0\n"
153
	".LisAligned:\n\t"
154
		"mov %%l0, %%o5\n\t"			// save newly computed stack ptr
155
		"add %%g0, 16, %%o4\n"
156
157
		// now copy longs down to save register window
158
		// and local variables
159
	".LcopyDown:\n\t"
160
		"ld [%%l1], %%l2\n\t"
161
		"st %%l2,[%%l0]\n\t"
162
		"add %%l0, 4, %%l0\n\t"
163
		"add %%l1, 4, %%l1\n\t"
164
		"subcc %%o4, 1, %%o4\n\t"
165
		"bne .LcopyDown\n\t"
166
167
		"mov %%o5, %%sp\n\t"		// move new stack ptr (hopefully) atomically
168
		// while register window is valid in both spaces
169
		// (scheduling might hit in copyDown loop)
170
171
		"sub %%i5, 7, %%l0\n\t"		// copy parameters past the sixth to stack
172
		"add %%i4, 28, %%l1\n\t"
173
		"add %%sp, 92, %%l2\n"
174
	".LcopyLong:\n\t"
175
		"ld [%%l1], %%o0\n\t"
176
		"st %%o0, [%%l2]\n\t"
177
		"add %%l1, 4, %%l1\n\t"
178
		"add %%l2, 4, %%l2\n\t"
179
		"subcc %%l0, 1, %%l0\n\t"
180
		"bne .LcopyLong\n\t"
181
		"nop\n"
182
183
	".LmoveOn:\n\t"
184
		"mov %%i5, %%l0\n\t"		// prepare out registers
185
		"mov %%i4, %%l1\n\t"
186
187
		"ld [%%l1], %%o0\n\t"		// prepare complex return ptr
188
		"st %%o0, [%%sp+64]\n\t"
189
		"sub %%l0, 1, %%l0\n\t"
190
		"add %%l1, 4, %%l1\n\t"
191
192
		"ld [%%l1], %%o0\n\t"
193
		"subcc %%l0, 1, %%l0\n\t"
194
		"be .LdoCall\n\t"
195
		"nop\n\t"
196
197
		"add %%l1, 4, %%l1\n\t"
198
		"ld [%%l1], %%o1\n\t"
199
		"subcc %%l0, 1, %%l0\n\t"
200
		"be .LdoCall\n\t"
201
		"nop\n\t"
202
203
		"add %%l1, 4, %%l1\n\t"
204
		"ld [%%l1], %%o2\n\t"
205
		"subcc %%l0, 1, %%l0\n\t"
206
		"be .LdoCall\n\t"
207
		"nop\n\t"
208
209
		"add %%l1, 4, %%l1\n\t"
210
		"ld [%%l1], %%o3\n\t"
211
		"subcc %%l0, 1, %%l0\n\t"
212
		"be .LdoCall\n\t"
213
		"nop\n\t"
214
215
		"add %%l1, 4, %%l1\n\t"
216
		"ld [%%l1], %%o4\n\t"
217
		"subcc %%l0, 1, %%l0\n\t"
218
		"be .LdoCall\n\t"
219
		"nop\n\t"
220
221
		"add %%l1, 4, %%l1\n\t"
222
		"ld [%%l1], %%o5\n"
223
224
	".LdoCall:\n\t"
225
		"ld [%%i0], %%l0\n\t"		// get vtable ptr
226
227
"sll %%i1, 2, %%l6\n\t"
228
//        "add %%l6, 8, %%l6\n\t"
229
		"add %%l6, %%l0, %%l0\n\t"
230
// 		// vtable has 8byte wide entries,
231
// 		// upper half contains 2 half words, of which the first
232
// 		// is the this ptr patch !
233
// 		// first entry is (or __tf)
234
235
// 		"ldsh [%%l0], %%l6\n\t"		// load this ptr patch
236
// 		"add %%l6, %%o0, %%o0\n\t"	// patch this ptr
237
238
// 		"add %%l0, 4, %%l0\n\t"		// get virtual function ptr
239
		"ld [%%l0], %%l0\n\t"
240
241
		"ld [%%i4], %%l2\n\t"
242
		"subcc %%l2, %%g0, %%l2\n\t"
243
		"bne .LcomplexCall\n\t"
244
		"nop\n\t"
245
		"call %%l0\n\t"
246
		"nop\n\t"
247
		"ba .LcallReturned\n\t"
248
		"nop\n"
249
	".LcomplexCall:\n\t"
250
		"call %%l0\n\t"
251
		"nop\n\t"
252
		"unimp\n"
253
254
	".LcallReturned:\n\t"
255
		"mov %%l3, %%sp\n\t"		// readjust stack so that our locals are where they belong
256
		"st %%o0, %0\n\t"			// save possible return registers into our locals
257
		"st %%o1, %1\n\t"
258
		"std %%f0, %2\n\t"
259
		"st %%f0, %3\n\t"
260
261
		// restore registers
262
		"ldd [%%l7], %%l0\n\t"
263
		"add %%l7, 8, %%l7\n\t"
264
		"ldd [%%l7], %%l2\n\t"
265
		"add %%l7, 8, %%l7\n\t"
266
		"ldd [%%l7], %%l4\n\t"
267
		"add %%l7, 8, %%l7\n\t"
268
		"ldd [%%l7], %%o0\n\t"
269
		"add %%l7, 8, %%l7\n\t"
270
		"ldd [%%l7], %%o2\n\t"
271
		"add %%l7, 8, %%l7\n\t"
272
		"ldd [%%l7], %%o4\n\t"
273
		"add %%l7, 8, %%l7\n\t"
274
		"ldd [%%l7], %%l6\n\t"
275
		: :
276
		"m"(o0),
277
		"m"(o1),
278
		"m"(f0d),
279
		"m"(f0f),
280
		"r"(&saveReg[0])
281
		);
282
	switch( eReturnType )
283
	{
284
		case typelib_TypeClass_HYPER:
285
		case typelib_TypeClass_UNSIGNED_HYPER:
286
			((long*)pRegisterReturn)[1] = o1;
287
		case typelib_TypeClass_LONG:
288
		case typelib_TypeClass_UNSIGNED_LONG:
289
		case typelib_TypeClass_ENUM:
290
			((long*)pRegisterReturn)[0] = o0;
291
			break;
292
		case typelib_TypeClass_CHAR:
293
		case typelib_TypeClass_SHORT:
294
		case typelib_TypeClass_UNSIGNED_SHORT:
295
			*(unsigned short*)pRegisterReturn = (unsigned short)o0;
296
			break;
297
		case typelib_TypeClass_BOOLEAN:
298
		case typelib_TypeClass_BYTE:
299
			*(unsigned char*)pRegisterReturn = (unsigned char)o0;
300
			break;
301
		case typelib_TypeClass_FLOAT:
302
			*(float*)pRegisterReturn = f0f;
303
			break;
304
		case typelib_TypeClass_DOUBLE:
305
			*(double*)pRegisterReturn = f0d;
306
			break;
307
	}
308
}
309
310
//=================================================================================================
311
static void cpp_call(
312
	bridges::cpp_uno::shared::UnoInterfaceProxy * pThis,
313
	bridges::cpp_uno::shared::VtableSlot aVtableSlot,
314
	typelib_TypeDescriptionReference * pReturnTypeRef,
315
	sal_Int32 nParams, typelib_MethodParameter * pParams,
316
	void * pUnoReturn, void * pUnoArgs[], uno_Any ** ppUnoExc )
317
{
318
  	// max space for: complex ret ptr, this, values|ptr ...
319
  	char * pCppStack	=
320
  		(char *)alloca( (nParams+2) * sizeof(sal_Int64) );
321
  	char * pCppStackStart	= pCppStack;
322
	
323
	// return
324
	typelib_TypeDescription * pReturnTypeDescr = 0;
325
	TYPELIB_DANGER_GET( &pReturnTypeDescr, pReturnTypeRef );
326
	OSL_ENSURE( pReturnTypeDescr, "### expected return type description!" );
327
	
328
	void * pCppReturn = 0; // if != 0 && != pUnoReturn, needs reconversion
329
	
330
	if (pReturnTypeDescr)
331
	{
332
		if (bridges::cpp_uno::shared::isSimpleType( pReturnTypeDescr ))
333
		{
334
			pCppReturn = pUnoReturn; // direct way for simple types
335
			*(void**)pCppStack = NULL;
336
		}
337
		else
338
		{
339
			// complex return via ptr
340
			pCppReturn = *(void **)pCppStack = (bridges::cpp_uno::shared::relatesToInterfaceType(pReturnTypeDescr )
341
												? alloca( pReturnTypeDescr->nSize )
342
												: pUnoReturn); // direct way
343
		}
344
		pCppStack += sizeof(void*);
345
	}
346
	// push this
347
	void * pAdjustedThisPtr = reinterpret_cast< void ** >(pThis->getCppI())
348
  	       + aVtableSlot.offset;
349
  	       *(void**)pCppStack = pAdjustedThisPtr;
350
	pCppStack += sizeof( void* );
351
352
	// stack space
353
	OSL_ENSURE( sizeof(void *) == sizeof(sal_Int32), "### unexpected size!" );
354
	// args
355
	void ** pCppArgs  = (void **)alloca( 3 * sizeof(void *) * nParams );
356
	// indizes of values this have to be converted (interface conversion cpp<=>uno)
357
	sal_Int32 * pTempIndizes = (sal_Int32 *)(pCppArgs + nParams);
358
	// type descriptions for reconversions
359
	typelib_TypeDescription ** ppTempParamTypeDescr = (typelib_TypeDescription **)(pCppArgs + (2 * nParams));
360
	
361
	sal_Int32 nTempIndizes   = 0;
362
	
363
	for ( sal_Int32 nPos = 0; nPos < nParams; ++nPos )
364
	{
365
		const typelib_MethodParameter & rParam = pParams[nPos];
366
		typelib_TypeDescription * pParamTypeDescr = 0;
367
		TYPELIB_DANGER_GET( &pParamTypeDescr, rParam.pTypeRef );
368
		if (!rParam.bOut && bridges::cpp_uno::shared::isSimpleType( pParamTypeDescr ))
369
		{
370
			pCppArgs[ nPos ] = CPPU_CURRENT_NAMESPACE::adjustPointer(pCppStack, pParamTypeDescr );
371
			
372
			switch (pParamTypeDescr->eTypeClass)
373
			{
374
			case typelib_TypeClass_HYPER:
375
			case typelib_TypeClass_UNSIGNED_HYPER:
376
			case typelib_TypeClass_DOUBLE:
377
                        OSL_ASSERT( sizeof (double) == sizeof (sal_Int64) );
378
                          *reinterpret_cast< sal_Int32 * >(pCppStack) =
379
                          *reinterpret_cast< sal_Int32 const * >(pUnoArgs[ nPos ]);
380
                          pCppStack += sizeof (sal_Int32);
381
                          *reinterpret_cast< sal_Int32 * >(pCppStack) =
382
                          *(reinterpret_cast< sal_Int32 const * >(pUnoArgs[ nPos ] ) + 1);
383
                          break;
384
            		default:
385
                          uno_copyAndConvertData(
386
                             pCppArgs[nPos], pUnoArgs[nPos], pParamTypeDescr,
387
                            pThis->getBridge()->getUno2Cpp() );
388
                          break;
389
                        }
390
			// no longer needed
391
			TYPELIB_DANGER_RELEASE( pParamTypeDescr );
392
		}
393
		else // ptr to complex value | ref
394
		{
395
			if (! rParam.bIn) // is pure out
396
			{
397
				// cpp out is constructed mem, uno out is not!
398
				uno_constructData(
399
					*(void **)pCppStack = pCppArgs[nPos] = alloca( pParamTypeDescr->nSize ),
400
					pParamTypeDescr );
401
				pTempIndizes[nTempIndizes] = nPos; // default constructed for cpp call
402
				// will be released at reconversion
403
				ppTempParamTypeDescr[nTempIndizes++] = pParamTypeDescr;
404
			}
405
			// is in/inout
406
			else if (bridges::cpp_uno::shared::relatesToInterfaceType(
407
  	                        pParamTypeDescr ))
408
			{
409
				uno_copyAndConvertData(
410
					*(void **)pCppStack = pCppArgs[nPos] = alloca( pParamTypeDescr->nSize ),
411
                                	pUnoArgs[nPos], pParamTypeDescr,
412
					pThis->getBridge()->getUno2Cpp() );
413
				
414
				pTempIndizes[nTempIndizes] = nPos; // has to be reconverted
415
				// will be released at reconversion
416
				ppTempParamTypeDescr[nTempIndizes++] = pParamTypeDescr;
417
			}
418
			else // direct way
419
			{
420
				*(void **)pCppStack = pCppArgs[nPos] = pUnoArgs[nPos];
421
				// no longer needed
422
				TYPELIB_DANGER_RELEASE( pParamTypeDescr );
423
			}
424
		}
425
		pCppStack += sizeof(sal_Int32); // standard parameter length
426
	}
427
428
	try
429
	{
430
		int nStackLongs = (pCppStack - pCppStackStart)/sizeof(sal_Int32);
431
		OSL_ENSURE( !( (pCppStack - pCppStackStart ) & 3), "UNALIGNED STACK !!! (Please DO panic" );
432
		
433
		if( nStackLongs & 1 )
434
			// stack has to be 8 byte aligned
435
			nStackLongs++;
436
		callVirtualMethod(
437
			pAdjustedThisPtr,
438
			aVtableSlot.index,
439
			pCppReturn,
440
			pReturnTypeDescr->eTypeClass,
441
			(sal_Int32 *)pCppStackStart,
442
			 nStackLongs);
443
		// NO exception occured...
444
		*ppUnoExc = 0;
445
446
		// reconvert temporary params
447
		for ( ; nTempIndizes--; )
448
		{
449
			sal_Int32 nIndex = pTempIndizes[nTempIndizes];
450
			typelib_TypeDescription * pParamTypeDescr = ppTempParamTypeDescr[nTempIndizes];
451
			
452
			if (pParams[nIndex].bIn)
453
			{
454
				if (pParams[nIndex].bOut) // inout
455
				{
456
					uno_destructData( pUnoArgs[nIndex], pParamTypeDescr, 0 ); // destroy uno value
457
					uno_copyAndConvertData( pUnoArgs[nIndex], pCppArgs[nIndex], pParamTypeDescr,
458
											pThis->getBridge()->getCpp2Uno() );
459
				}
460
			}
461
			else // pure out
462
			{
463
				uno_copyAndConvertData( pUnoArgs[nIndex], pCppArgs[nIndex], pParamTypeDescr,
464
										pThis->getBridge()->getCpp2Uno() );
465
			}
466
			// destroy temp cpp param => cpp: every param was constructed
467
			uno_destructData( pCppArgs[nIndex], pParamTypeDescr, cpp_release );
468
			
469
			TYPELIB_DANGER_RELEASE( pParamTypeDescr );
470
		}
471
		// return value
472
		if (pCppReturn && pUnoReturn != pCppReturn)
473
		{
474
			uno_copyAndConvertData( pUnoReturn, pCppReturn, pReturnTypeDescr,
475
									pThis->getBridge()->getCpp2Uno() );
476
			uno_destructData( pCppReturn, pReturnTypeDescr, cpp_release );
477
		}
478
	}
479
 	catch( ... )
480
 	{
481
 		// get exception
482
		   fillUnoException( CPPU_CURRENT_NAMESPACE::__cxa_get_globals()->caughtExceptions, 
483
								*ppUnoExc, pThis->getBridge()->getCpp2Uno() );
484
485
		// temporary params
486
		for ( ; nTempIndizes--; )
487
		{
488
			sal_Int32 nIndex = pTempIndizes[nTempIndizes];
489
			// destroy temp cpp param => cpp: every param was constructed
490
			uno_destructData( pCppArgs[nIndex], ppTempParamTypeDescr[nTempIndizes], cpp_release );
491
			TYPELIB_DANGER_RELEASE( ppTempParamTypeDescr[nTempIndizes] );
492
		}
493
		// return type
494
		if (pReturnTypeDescr)
495
			TYPELIB_DANGER_RELEASE( pReturnTypeDescr );
496
	}
497
}
498
499
500
//==================================================================================================
501
void bridges::cpp_uno::shared::UnoInterfaceProxy::dispatch(
502
	uno_Interface * pUnoI, const typelib_TypeDescription * pMemberDescr,
503
void * pReturn, void * pArgs[], uno_Any ** ppException ) SAL_THROW(())
504
{
505
#if defined BRIDGES_DEBUG
506
    OString cstr( OUStringToOString( pMemberDescr->pTypeName, RTL_TEXTENCODING_ASCII_US ) );
507
    fprintf( stderr, "received dispatch( %s )\n", cstr.getStr() );
508
#endif
509
    
510
	// is my surrogate
511
	bridges::cpp_uno::shared::UnoInterfaceProxy * pThis
512
       = static_cast< bridges::cpp_uno::shared::UnoInterfaceProxy * >(pUnoI);
513
	typelib_InterfaceTypeDescription * pTypeDescr = pThis->pTypeDescr;
514
	
515
	switch (pMemberDescr->eTypeClass)
516
	{
517
	case typelib_TypeClass_INTERFACE_ATTRIBUTE:
518
	{
519
	 VtableSlot aVtableSlot(
520
  	           getVtableSlot(
521
  	               reinterpret_cast<
522
  	                   typelib_InterfaceAttributeTypeDescription const * >(
523
  	                       pMemberDescr)));
524
		if (pReturn)
525
		{
526
			// dependent dispatch
527
			cpp_call(
528
				pThis, aVtableSlot,
529
				((typelib_InterfaceAttributeTypeDescription *)pMemberDescr)->pAttributeTypeRef,
530
				0, 0, // no params
531
				pReturn, pArgs, ppException );
532
		}
533
		else
534
		{
535
			// is SET
536
			typelib_MethodParameter aParam;
537
			aParam.pTypeRef =
538
				((typelib_InterfaceAttributeTypeDescription *)pMemberDescr)->pAttributeTypeRef;
539
			aParam.bIn		= sal_True;
540
			aParam.bOut		= sal_False;
541
542
			typelib_TypeDescriptionReference * pReturnTypeRef = 0;
543
			OUString aVoidName( RTL_CONSTASCII_USTRINGPARAM("void") );
544
			typelib_typedescriptionreference_new(
545
				&pReturnTypeRef, typelib_TypeClass_VOID, aVoidName.pData );
546
			
547
			// dependent dispatch
548
			aVtableSlot.index += 1; // get, then set method
549
			cpp_call(
550
				pThis, aVtableSlot,
551
				pReturnTypeRef,
552
				1, &aParam,
553
				pReturn, pArgs, ppException );
554
555
			typelib_typedescriptionreference_release( pReturnTypeRef );
556
		}
557
		
558
		break;
559
	}
560
	case typelib_TypeClass_INTERFACE_METHOD:
561
	{
562
		VtableSlot aVtableSlot(
563
		getVtableSlot(
564
		 reinterpret_cast<
565
		  typelib_InterfaceMethodTypeDescription const * >(
566
		  pMemberDescr)));
567
		switch (aVtableSlot.index)
568
		{
569
			// standard calls
570
		case 1: // acquire uno interface
571
			(*pUnoI->acquire)( pUnoI );
572
			*ppException = 0;
573
			break;
574
		case 2: // release uno interface
575
			(*pUnoI->release)( pUnoI );
576
			*ppException = 0;
577
			break;
578
		case 0: // queryInterface() opt
579
		{
580
			typelib_TypeDescription * pTD = 0;
581
			TYPELIB_DANGER_GET( &pTD, reinterpret_cast< Type * >( pArgs[0] )->getTypeLibType() );
582
			if (pTD)
583
			{
584
                uno_Interface * pInterface = 0;
585
 		(*pThis->pBridge->getUnoEnv()->getRegisteredInterface)(
586
 		  pThis->pBridge->getUnoEnv(),
587
				   (void **)&pInterface, pThis->oid.pData, (typelib_InterfaceTypeDescription *)pTD );
588
			
589
                if (pInterface)
590
                {
591
                    ::uno_any_construct(
592
                        reinterpret_cast< uno_Any * >( pReturn ),
593
                        &pInterface, pTD, 0 );
594
                    (*pInterface->release)( pInterface );
595
                    TYPELIB_DANGER_RELEASE( pTD );
596
                    *ppException = 0;
597
                    break;
598
                }
599
                TYPELIB_DANGER_RELEASE( pTD );
600
            }
601
		} // else perform queryInterface()
602
		default:
603
			// dependent dispatch
604
			cpp_call(
605
				pThis, aVtableSlot,
606
				((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->pReturnTypeRef,
607
				((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->nParams,
608
				((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->pParams,
609
				pReturn, pArgs, ppException );
610
		}
611
		break;
612
	}
613
	default:
614
	{
615
		::com::sun::star::uno::RuntimeException aExc(
616
			OUString( RTL_CONSTASCII_USTRINGPARAM("illegal member type description!") ),
617
			::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >() );
618
		
619
		Type const & rExcType = ::getCppuType( &aExc );
620
		// binary identical null reference
621
		::uno_type_any_construct( *ppException, &aExc, rExcType.getTypeLibType(), 0 );
622
	}
623
	}
624
}
625
626
}

Return to issue 42547