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

(-)prj/build.lst (-1 / +1 lines)
Lines 15-21 Link Here
15
br	bridges\source\cpp_uno\gcc2_linux_powerpc	nmake	-	u	br_gcclp br_unotypes NULL
15
br	bridges\source\cpp_uno\gcc2_linux_powerpc	nmake	-	u	br_gcclp br_unotypes NULL
16
br	bridges\source\cpp_uno\gcc3_linux_powerpc	nmake	-	u	br_gcclp3 br_unotypes NULL
16
br	bridges\source\cpp_uno\gcc3_linux_powerpc	nmake	-	u	br_gcclp3 br_unotypes NULL
17
br	bridges\source\cpp_uno\gcc3_linux_s390		nmake	-	u	br_gccl33 br_unotypes NULL
17
br	bridges\source\cpp_uno\gcc3_linux_s390		nmake	-	u	br_gccl33 br_unotypes NULL
18
br	bridges\source\cpp_uno\gcc3_linux_sparc		nmake	-	u	br_gccl3s br_unotypes NULL
18
br	bridges\source\cpp_uno\gcc3_linux_sparc		nmake	-	u	br_gccl3s br_unotypes br_cppuno_shared NULL
19
br	bridges\source\cpp_uno\gcc2_macosx_powerpc			nmake	-	u	br_gccmacoxp br_unotypes NULL
19
br	bridges\source\cpp_uno\gcc2_macosx_powerpc			nmake	-	u	br_gccmacoxp br_unotypes NULL
20
br	bridges\source\cpp_uno\gcc3_macosx_powerpc			nmake	-	u	br_gcc3macoxp br_unotypes NULL
20
br	bridges\source\cpp_uno\gcc3_macosx_powerpc			nmake	-	u	br_gcc3macoxp br_unotypes NULL
21
br	bridges\source\cpp_uno\cc50_solaris_sparc			nmake	-	u	br_cc50sols br_unotypes br_cppuno_shared NULL
21
br	bridges\source\cpp_uno\cc50_solaris_sparc			nmake	-	u	br_cc50sols br_unotypes br_cppuno_shared NULL
(-)source/cpp_uno/gcc3_linux_sparc/cpp2uno.cxx (-314 / +218 lines)
Lines 60-108 Link Here
60
 ************************************************************************/
60
 ************************************************************************/
61
61
62
#define LEAK_STATIC_DATA
62
#define LEAK_STATIC_DATA
63
//  #define TRACE(x) OSL_TRACE(x)
63
#define TRACE(x) OSL_TRACE(x)
64
#define TRACE(x)
64
#define TRACE(x)
65
65
66
#include <malloc.h>
67
#include <list>
66
#include <list>
68
#include <map>
67
#include <map>
69
#include <typeinfo>
68
#include <typeinfo>
70
#ifndef _RTL_ALLOC_H_
69
#include <com/sun/star/uno/genfunc.hxx>
71
#include <rtl/alloc.h>
72
#endif
73
#ifndef _OSL_MUTEX_HXX_
74
#include <osl/mutex.hxx>
75
#endif
76
77
#ifndef _TYPELIB_TYPEDESCRIPTION_HXX_
70
#ifndef _TYPELIB_TYPEDESCRIPTION_HXX_
78
#include <typelib/typedescription.hxx>
71
#include <typelib/typedescription.hxx>
79
#endif
72
#endif
80
#ifndef _UNO_DATA_H_
73
#ifndef _UNO_DATA_H_
81
#include <uno/data.h>
74
#include <uno/data.h>
82
#endif
75
#endif
83
#ifndef _BRIDGES_CPP_UNO_BRIDGE_HXX_
76
#include "bridges/cpp_uno/shared/bridge.hxx"
84
#include <bridges/cpp_uno/bridge.hxx>
77
#include "bridges/cpp_uno/shared/cppinterfaceproxy.hxx"
85
#endif
78
#include "bridges/cpp_uno/shared/types.hxx"
86
#ifndef _BRIDGES_CPP_UNO_TYPE_MISC_HXX_
79
#include "bridges/cpp_uno/shared/vtablefactory.hxx"
87
#include <bridges/cpp_uno/type_misc.hxx>
88
#endif
89
90
#include "share.hxx"
80
#include "share.hxx"
91
81
92
using namespace com::sun::star::uno;
82
using namespace com::sun::star::uno;
93
using namespace std;
83
using namespace std;
94
using namespace osl;
95
using namespace rtl;
84
using namespace rtl;
96
85
97
namespace CPPU_CURRENT_NAMESPACE
86
namespace
98
{
87
{
99
88
100
//==================================================================================================
89
//==================================================================================================
101
rtl_StandardModuleCount g_moduleCount = MODULE_COUNT_INIT;
102
103
//==================================================================================================
104
static typelib_TypeClass cpp2uno_call(
90
static typelib_TypeClass cpp2uno_call(
105
	cppu_cppInterfaceProxy * pThis,
91
	 bridges::cpp_uno::shared::CppInterfaceProxy * pThis,
106
	const typelib_TypeDescription * pMemberTypeDescr,
92
	const typelib_TypeDescription * pMemberTypeDescr,
107
	typelib_TypeDescriptionReference * pReturnTypeRef, // 0 indicates void return
93
	typelib_TypeDescriptionReference * pReturnTypeRef, // 0 indicates void return
108
	sal_Int32 nParams, typelib_MethodParameter * pParams,
94
	sal_Int32 nParams, typelib_MethodParameter * pParams,
Lines 122-137 Link Here
122
	
108
	
123
	if (pReturnTypeDescr)
109
	if (pReturnTypeDescr)
124
	{
110
	{
125
		if (cppu_isSimpleType( pReturnTypeDescr ))
111
	if (bridges::cpp_uno::shared::isSimpleType( pReturnTypeDescr ))
112
	{
126
			pUnoReturn = pRegisterReturn; // direct way for simple types
113
			pUnoReturn = pRegisterReturn; // direct way for simple types
114
	}
127
		else // complex return via ptr (pCppReturn)
115
		else // complex return via ptr (pCppReturn)
128
		{
116
		{
129
			pCppReturn = *(void**)pCppStack;
117
			pCppReturn = *(void**)pCppStack;
130
			
118
			pCppStack += sizeof( void* );
131
			pUnoReturn = (cppu_relatesToInterface( pReturnTypeDescr )
119
			pUnoReturn = (bridges::cpp_uno::shared::relatesToInterfaceType(
120
  	                             pReturnTypeDescr )
132
						  ? alloca( pReturnTypeDescr->nSize )
121
						  ? alloca( pReturnTypeDescr->nSize )
133
						  : pCppReturn); // direct way
122
						  : pCppReturn); // direct way
134
			pCppStack += sizeof( void* );
123
135
		}
124
		}
136
	}
125
	}
137
	// pop this
126
	// pop this
Lines 155-170 Link Here
155
		typelib_TypeDescription * pParamTypeDescr = 0;
144
		typelib_TypeDescription * pParamTypeDescr = 0;
156
		TYPELIB_DANGER_GET( &pParamTypeDescr, rParam.pTypeRef );
145
		TYPELIB_DANGER_GET( &pParamTypeDescr, rParam.pTypeRef );
157
146
158
		if (!rParam.bOut && cppu_isSimpleType( pParamTypeDescr )) // value
147
	 	if (!rParam.bOut && bridges::cpp_uno::shared::isSimpleType( pParamTypeDescr ))  // value
159
		{
148
		{
160
			pCppArgs[nPos] = pUnoArgs[nPos] =
149
			pCppArgs[nPos] = pUnoArgs[nPos] =
161
				adjustPointer( pCppStack, pParamTypeDescr );
150
				CPPU_CURRENT_NAMESPACE::adjustPointer( pCppStack, pParamTypeDescr );
162
			switch (pParamTypeDescr->eTypeClass)
151
			switch (pParamTypeDescr->eTypeClass)
163
			{
152
			{
164
			case typelib_TypeClass_HYPER:
153
			case typelib_TypeClass_HYPER:
165
			case typelib_TypeClass_UNSIGNED_HYPER:
154
			case typelib_TypeClass_UNSIGNED_HYPER:
166
			case typelib_TypeClass_DOUBLE:
155
            		case typelib_TypeClass_DOUBLE:
167
				pCppStack += sizeof(sal_Int32); // extra long
156
            		{
157
			if ((reinterpret_cast< long >(pCppStack) & 7) != 0)
158
              		{
159
		   		OSL_ASSERT( sizeof (double) == sizeof (sal_Int64) );
160
                   		void * pDest = alloca( sizeof (sal_Int64) );
161
                  	 	*reinterpret_cast< sal_Int32 * >(pDest) =
162
                   		*reinterpret_cast< sal_Int32 const * >(pCppStack);
163
                   		*(reinterpret_cast< sal_Int32 * >(pDest) + 1) =
164
                   		*(reinterpret_cast< sal_Int32 const * >(pCppStack) + 1);
165
                   		pCppArgs[nPos] = pUnoArgs[nPos] = pDest;
166
			}
167
		   	pCppStack += sizeof (sal_Int32); // extra long
168
                   	break;
169
			}
168
			}
170
			}
169
			// no longer needed
171
			// no longer needed
170
			TYPELIB_DANGER_RELEASE( pParamTypeDescr );
172
			TYPELIB_DANGER_RELEASE( pParamTypeDescr );
Lines 182-192 Link Here
182
				ppTempParamTypeDescr[nTempIndizes++] = pParamTypeDescr;
184
				ppTempParamTypeDescr[nTempIndizes++] = pParamTypeDescr;
183
			}
185
			}
184
			// is in/inout
186
			// is in/inout
185
			else if (cppu_relatesToInterface( pParamTypeDescr ))
187
			else if (bridges::cpp_uno::shared::relatesToInterfaceType(
188
  	                        pParamTypeDescr ))
186
			{
189
			{
187
				uno_copyAndConvertData( pUnoArgs[nPos] = alloca( pParamTypeDescr->nSize ),
190
				uno_copyAndConvertData( pUnoArgs[nPos] = alloca( pParamTypeDescr->nSize ),
188
										*(void **)pCppStack, pParamTypeDescr,
191
										*(void **)pCppStack, pParamTypeDescr,
189
										&pThis->pBridge->aCpp2Uno );
192
										  pThis->getBridge()->getCpp2Uno() );
190
				pTempIndizes[nTempIndizes] = nPos; // has to be reconverted
193
				pTempIndizes[nTempIndizes] = nPos; // has to be reconverted
191
				// will be released at reconversion
194
				// will be released at reconversion
192
				ppTempParamTypeDescr[nTempIndizes++] = pParamTypeDescr;
195
				ppTempParamTypeDescr[nTempIndizes++] = pParamTypeDescr;
Lines 206-213 Link Here
206
	uno_Any * pUnoExc = &aUnoExc;
209
	uno_Any * pUnoExc = &aUnoExc;
207
210
208
	// invoke uno dispatch call
211
	// invoke uno dispatch call
209
	(*pThis->pUnoI->pDispatcher)( pThis->pUnoI, pMemberTypeDescr, pUnoReturn, pUnoArgs, &pUnoExc );
212
	(*pThis->getUnoI()->pDispatcher)(pThis->getUnoI(), pMemberTypeDescr, pUnoReturn, pUnoArgs, &pUnoExc );
210
	
211
	// in case an exception occured...
213
	// in case an exception occured...
212
	if (pUnoExc)
214
	if (pUnoExc)
213
	{
215
	{
Lines 222-230 Link Here
222
		}
224
		}
223
		if (pReturnTypeDescr)
225
		if (pReturnTypeDescr)
224
			TYPELIB_DANGER_RELEASE( pReturnTypeDescr );
226
			TYPELIB_DANGER_RELEASE( pReturnTypeDescr );
225
		
227
		CPPU_CURRENT_NAMESPACE::raiseException(
226
		raiseException( &aUnoExc, &pThis->pBridge->aUno2Cpp ); // has to destruct the any
228
  	           &aUnoExc, pThis->getBridge()->getUno2Cpp() );
227
		// is here for dummy
229
  	           // has to destruct the any
230
               // is here for dummy
228
		return typelib_TypeClass_VOID;
231
		return typelib_TypeClass_VOID;
229
	}
232
	}
230
	else // else no exception occured...
233
	else // else no exception occured...
Lines 240-246 Link Here
240
				// convert and assign
243
				// convert and assign
241
				uno_destructData( pCppArgs[nIndex], pParamTypeDescr, cpp_release );
244
				uno_destructData( pCppArgs[nIndex], pParamTypeDescr, cpp_release );
242
				uno_copyAndConvertData( pCppArgs[nIndex], pUnoArgs[nIndex], pParamTypeDescr,
245
				uno_copyAndConvertData( pCppArgs[nIndex], pUnoArgs[nIndex], pParamTypeDescr,
243
										&pThis->pBridge->aUno2Cpp );
246
									pThis->getBridge()->getUno2Cpp() );
244
			}
247
			}
245
			// destroy temp uno param
248
			// destroy temp uno param
246
			uno_destructData( pUnoArgs[nIndex], pParamTypeDescr, 0 );
249
			uno_destructData( pUnoArgs[nIndex], pParamTypeDescr, 0 );
Lines 253-259 Link Here
253
			if (pUnoReturn != pCppReturn) // needs reconversion
256
			if (pUnoReturn != pCppReturn) // needs reconversion
254
			{
257
			{
255
				uno_copyAndConvertData( pCppReturn, pUnoReturn, pReturnTypeDescr,
258
				uno_copyAndConvertData( pCppReturn, pUnoReturn, pReturnTypeDescr,
256
										&pThis->pBridge->aUno2Cpp );
259
					pThis->getBridge()->getUno2Cpp() );
257
				// destroy temp uno return
260
				// destroy temp uno return
258
				uno_destructData( pUnoReturn, pReturnTypeDescr, 0 );
261
				uno_destructData( pUnoReturn, pReturnTypeDescr, 0 );
259
			}
262
			}
Lines 274-324 Link Here
274
277
275
//==================================================================================================
278
//==================================================================================================
276
static typelib_TypeClass cpp_mediate(
279
static typelib_TypeClass cpp_mediate(
277
	sal_Int32 nVtableCall,
280
	sal_Int32		nFunctionIndex,
278
	void ** pCallStack,
281
	sal_Int32		nVtableOffset,
279
	sal_Int64 * pRegisterReturn /* space for register return */ )
282
		void **		pCallStack,
283
	sal_Int64 *	pRegisterReturn /* space for register return */ )
280
{
284
{
281
	OSL_ENSURE( sizeof(sal_Int32)==sizeof(void *), "### unexpected!" );
285
	OSL_ENSURE( sizeof(sal_Int32)==sizeof(void *), "### unexpected!" );
282
	
286
283
	// pCallStack: this, params
287
	// pCallStack: this, params
284
	// eventual [ret*] lies at pCallStack -1
288
	// eventual [ret*] lies at pCallStack -1
285
	// so count down pCallStack by one to keep it simple
289
	// so count down pCallStack by one to keep it simple
286
	// _this_ ptr is patched cppu_XInterfaceProxy object
290
void * pThis;
287
	cppu_cppInterfaceProxy * pCppI = NULL;
291
288
	pCppI = (cppu_cppInterfaceProxy *)(XInterface *)*pCallStack;
292
 if( (nFunctionIndex & 0x80000000) )
289
	if( nVtableCall & 0x80000000 )
293
	{
294
		nFunctionIndex &= 0x7fffffff;
295
		 pThis = pCallStack[1];
296
	}
297
else
290
	{
298
	{
291
		pCallStack--;
299
		pThis = pCallStack[0];
292
		nVtableCall &= 0x7fffffff;
293
	}
300
	}
301
	pThis = static_cast< char * >(pThis) - nVtableOffset;
302
	bridges::cpp_uno::shared::CppInterfaceProxy * pCppI
303
		= bridges::cpp_uno::shared::CppInterfaceProxy::castInterfaceToProxy(
304
		pThis);
294
305
295
	typelib_InterfaceTypeDescription * pTypeDescr = pCppI->pTypeDescr;
306
	typelib_InterfaceTypeDescription * pTypeDescr = pCppI->getTypeDescr();
296
	
307
297
	OSL_ENSURE( nVtableCall < pTypeDescr->nMapFunctionIndexToMemberIndex,
308
	OSL_ENSURE( nFunctionIndex < pTypeDescr->nMapFunctionIndexToMemberIndex,
298
				 "### illegal vtable index!" );
309
				 "### illegal vtable index!" );
299
	if (nVtableCall >= pTypeDescr->nMapFunctionIndexToMemberIndex)
310
  if (nFunctionIndex >= pTypeDescr->nMapFunctionIndexToMemberIndex)
300
	{
311
	{
301
		throw RuntimeException( OUString::createFromAscii("illegal vtable index!"), (XInterface *)pCppI );
312
		throw RuntimeException( OUString::createFromAscii("illegal vtable index!"), (XInterface *)pCppI );
302
	}
313
	}
303
	
314
304
	// determine called method
315
	// determine called method
305
	OSL_ENSURE( nVtableCall < pTypeDescr->nMapFunctionIndexToMemberIndex, "### illegal vtable index!" );
316
	sal_Int32 nMemberPos = pTypeDescr->pMapFunctionIndexToMemberIndex[nFunctionIndex];
306
	sal_Int32 nMemberPos = pTypeDescr->pMapFunctionIndexToMemberIndex[nVtableCall];
307
	OSL_ENSURE( nMemberPos < pTypeDescr->nAllMembers, "### illegal member index!" );
317
	OSL_ENSURE( nMemberPos < pTypeDescr->nAllMembers, "### illegal member index!" );
308
318
309
	TypeDescription aMemberDescr( pTypeDescr->ppAllMembers[nMemberPos] );
319
	TypeDescription aMemberDescr( pTypeDescr->ppAllMembers[nMemberPos] );
310
320
311
#if defined BRIDGES_DEBUG
321
//#if defined BRIDGES_DEBUG
312
    OString cstr( OUStringToOString( aMemberDescr.get()->pTypeName, RTL_TEXTENCODING_ASCII_US ) );
322
//    OString cstr( OUStringToOString( aMemberDescr.get()->pTypeName, RTL_TEXTENCODING_ASCII_US ) );
313
    fprintf( stderr, "calling %s, nVtableCall=%d\n", cstr.getStr(), nVtableCall );
323
//    fprintf( stderr, "calling %s, nVtableCall=%d\n", cstr.getStr(), nVtableCall );
314
#endif
324
//#endif
315
325
316
	typelib_TypeClass eRet;
326
	typelib_TypeClass eRet;
317
	switch (aMemberDescr.get()->eTypeClass)
327
	switch (aMemberDescr.get()->eTypeClass)
318
	{
328
	{
319
	case typelib_TypeClass_INTERFACE_ATTRIBUTE:
329
	case typelib_TypeClass_INTERFACE_ATTRIBUTE:
320
	{
330
	{
321
		if (pTypeDescr->pMapMemberIndexToFunctionIndex[nMemberPos] == nVtableCall)
331
	if (pTypeDescr->pMapMemberIndexToFunctionIndex[nMemberPos] == nFunctionIndex)
322
		{
332
		{
323
			// is GET method
333
			// is GET method
324
			eRet = cpp2uno_call(
334
			eRet = cpp2uno_call(
Lines 347-353 Link Here
347
	case typelib_TypeClass_INTERFACE_METHOD:
357
	case typelib_TypeClass_INTERFACE_METHOD:
348
	{
358
	{
349
		// is METHOD
359
		// is METHOD
350
		switch (nVtableCall)
360
		switch (nFunctionIndex)
351
		{
361
		{
352
		case 1: // acquire()
362
		case 1: // acquire()
353
			pCppI->acquireProxy(); // non virtual call!
363
			pCppI->acquireProxy(); // non virtual call!
Lines 364-372 Link Here
364
			if (pTD)
374
			if (pTD)
365
			{
375
			{
366
                XInterface * pInterface = 0;
376
                XInterface * pInterface = 0;
367
                (*pCppI->pBridge->pCppEnv->getRegisteredInterface)(
377
		(*pCppI->getBridge()->getCppEnv()->getRegisteredInterface)(
368
                    pCppI->pBridge->pCppEnv,
378
		pCppI->getBridge()->getCppEnv(),
369
                    (void **)&pInterface, pCppI->oid.pData, (typelib_InterfaceTypeDescription *)pTD );
379
		(void **)&pInterface, pCppI->getOid().pData,
380
		(typelib_InterfaceTypeDescription *)pTD );
370
			
381
			
371
                if (pInterface)
382
                if (pInterface)
372
                {
383
                {
Lines 392-678 Link Here
392
		}
403
		}
393
		break;
404
		break;
394
	}
405
	}
395
	default:
406
//	default:
396
	{
407
//	{
397
		throw RuntimeException( OUString::createFromAscii("no member description found!"), (XInterface *)pCppI );
408
//		throw RuntimeException(
398
		// is here for dummy
409
//		rtl::OUString::createFromAscii("no member description found!"),
399
		eRet = typelib_TypeClass_VOID;
410
//		(XInterface *)pThis );
411
//		// is here for dummy
412
//		eRet = typelib_TypeClass_VOID;
413
//	}
400
	}
414
	}
401
	}
402
    
403
	return eRet;
404
}
405
406
//==================================================================================================
407
class MediateClassData
408
{
409
public:
410
	struct ClassDataBuffer
411
	{
412
		void*			m_pVTable;
413
414
		~ClassDataBuffer();
415
	};
416
private:
417
418
	map< OUString, ClassDataBuffer* >		m_aClassData;
419
	Mutex									m_aMutex;
420
415
421
	void createVTable( ClassDataBuffer*, typelib_InterfaceTypeDescription* );
416
	return eRet;
422
public:
423
	const ClassDataBuffer* getClassData( typelib_InterfaceTypeDescription* );
424
	
425
	MediateClassData() {}
426
	~MediateClassData();
427
};
428
//__________________________________________________________________________________________________
429
MediateClassData::ClassDataBuffer::~ClassDataBuffer()
430
{
431
	delete m_pVTable;
432
}
433
434
//__________________________________________________________________________________________________
435
MediateClassData::~MediateClassData()
436
{
437
	TRACE( "> calling ~MediateClassData(): freeing mediate vtables... <\n" );
438
	
439
	// this MUST be the absolute last one which is called!
440
	for ( map< OUString, ClassDataBuffer* >::iterator iPos( m_aClassData.begin() ); iPos != m_aClassData.end(); ++iPos )
441
	{
442
		// todo
443
//  		delete (*iPos).second;
444
	}
445
}
417
}
446
418
447
//__________________________________________________________________________________________________
448
449
const MediateClassData::ClassDataBuffer* MediateClassData::getClassData( typelib_InterfaceTypeDescription* pType )
450
{
451
	MutexGuard aGuard( m_aMutex );
452
453
	map< OUString, ClassDataBuffer* >::iterator element = m_aClassData.find( pType->aBase.pTypeName );
454
	if( element != m_aClassData.end() )
455
		return (*element).second;
456
457
	ClassDataBuffer* pBuffer = new ClassDataBuffer();
458
	createVTable( pBuffer, pType );
459
	m_aClassData[ pType->aBase.pTypeName ] = pBuffer;
460
	return pBuffer;
461
}
419
}
462
420
463
464
//==================================================================================================
421
//==================================================================================================
465
/**
422
/**
466
 * is called on incoming vtable calls
423
 * is called on incoming vtable calls
467
 * (called by asm snippets)
424
 * (called by asm snippets)
468
 */
425
 */
469
static void cpp_vtable_call()
426
int cpp_vtable_call(
427
	sal_Int32 nFunctionIndex, sal_Int32 nVtableOffset, void** pCallStack)
470
{
428
{
471
	int nTableEntry;
472
	void** pCallStack;
473
	volatile sal_Int64 nRegReturn;
429
	volatile sal_Int64 nRegReturn;
474
475
	// nTableEntry and pCallStack are delivered in registers as usual
476
	// but cpp_vtable_call is declared void.
477
	// the reason is that this way the compiler won't clobber the
478
	// call stack prepared by the assembler snippet to save its input
479
	// registers
480
	// also restore %i2 here which was clobbered to jump here
481
	__asm__( "st %%i0, %0\n\t"
482
			 "st %%i1, %1\n\t"
483
			 "ld [%%fp+68], %%i0\n\t"
484
			 "ld [%%fp+72], %%i1\n\t"
485
			 "ld [%%fp+76], %%i2\n\t"
486
			 : : "m"(nTableEntry), "m"(pCallStack) );
487
488
	sal_Bool bComplex = nTableEntry & 0x80000000 ? sal_True : sal_False;
489
490
	typelib_TypeClass aType =
430
	typelib_TypeClass aType =
491
		cpp_mediate( nTableEntry, pCallStack+17, (sal_Int64*)&nRegReturn );
431
		cpp_mediate( nFunctionIndex, nVtableOffset, pCallStack,  (sal_Int64*)&nRegReturn );
492
432
    OSL_ASSERT( sizeof(void *) == sizeof(sal_Int32) );
493
	switch( aType )
433
	switch( aType )
494
	{
434
	{
435
	// move return value into register space
436
	// (will be loaded by machine code snippet)
437
        // Use pCallStack[1/2] instead of pCallStack[0/1], because the former is
438
        // properly dword aligned:
495
		case typelib_TypeClass_BOOLEAN:
439
		case typelib_TypeClass_BOOLEAN:
496
		case typelib_TypeClass_BYTE:
440
		case typelib_TypeClass_BYTE:
497
			__asm__( "ld %0, %%l0\n\t"
441
			pCallStack[1] = (void*)*(char*)&nRegReturn;
498
					 "ldsb [%%l0], %%i0\n"
499
					 : : "m"(&nRegReturn) );
500
			break;
442
			break;
501
		case typelib_TypeClass_CHAR:
443
		case typelib_TypeClass_CHAR:
502
		case typelib_TypeClass_SHORT:
444
		case typelib_TypeClass_SHORT:
503
		case typelib_TypeClass_UNSIGNED_SHORT:
445
		case typelib_TypeClass_UNSIGNED_SHORT:
504
			__asm__( "ld %0, %%l0\n\t"
446
			pCallStack[1] = (void*)*(short*)&nRegReturn;
505
					 "ldsh [%%l0], %%i0\n"
506
					 : : "m"(&nRegReturn) );
507
			break;
447
			break;
448
		case typelib_TypeClass_DOUBLE:
508
		case typelib_TypeClass_HYPER:
449
		case typelib_TypeClass_HYPER:
509
		case typelib_TypeClass_UNSIGNED_HYPER:
450
		case typelib_TypeClass_UNSIGNED_HYPER:
510
451
                        // move long to %i1
511
			__asm__( "ld %0, %%l0\n\t"
452
			pCallStack[2] = ((void **)&nRegReturn)[ 1 ];
512
					 "ld [%%l0], %%i0\n\t"
513
					 "ld %1, %%l0\n\t"
514
					 "ld [%%l0], %%i1\n\t"
515
					 : : "m"(&nRegReturn), "m"(((long*)&nRegReturn) +1) );
516
517
			break;
453
			break;
518
		case typelib_TypeClass_FLOAT:
454
		case typelib_TypeClass_FLOAT:
519
			__asm__( "ld %0, %%l0\n\t"
520
					 "ld [%%l0], %%f0\n"
521
					 : : "m"(&nRegReturn) );
522
			break;
523
		case typelib_TypeClass_DOUBLE:
524
			__asm__( "ld %0, %%l0\n\t"
525
					 "ldd [%%l0], %%f0\n"
526
					 : : "m"(&nRegReturn) );
527
			break;
528
		case typelib_TypeClass_VOID:
529
			break;
530
		default:
455
		default:
531
			__asm__( "ld %0, %%l0\n\t"
456
			// move long to %i0
532
					 "ld [%%l0], %%i0\n"
457
			pCallStack[1] = ((void **)&nRegReturn)[ 0 ];
533
					 : : "m"(&nRegReturn) );
534
			break;
458
			break;
535
	}
459
	}
536
460
	return aType;
537
	if( bComplex )
538
	{
539
		__asm__( "add %i7, 4, %i7\n\t" );
540
		// after call to complex return valued funcion there is an unimp instruction
541
	}
542
543
}
461
}
544
//__________________________________________________________________________________________________
462
//__________________________________________________________________________________________________
463
namespace {
545
464
546
void MediateClassData::createVTable( ClassDataBuffer* pBuffer, typelib_InterfaceTypeDescription* pType )
465
int const codeSnippetSize = 56;
547
{
548
	// get all member functions
549
	list< sal_Bool > aComplexReturn;
550
466
551
	for( int n = 0; n < pType->nAllMembers; n++ )
467
unsigned char * codeSnippet(
552
	{
468
    unsigned char * code, sal_Int32 functionIndex, sal_Int32 vtableOffset,
553
		typelib_TypeDescription* pMember = NULL;
469
    bool simpleRetType)
554
		TYPELIB_DANGER_GET( &pMember, pType->ppAllMembers[n] );
470
{
555
		if( pMember->eTypeClass == typelib_TypeClass_INTERFACE_ATTRIBUTE )
471
556
		{
472
	sal_uInt32 index = functionIndex;
557
			typelib_TypeDescription * pRetTD = 0;
473
	if (!simpleRetType) {
558
			TYPELIB_DANGER_GET( &pRetTD, ((typelib_InterfaceAttributeTypeDescription *)pMember)->pAttributeTypeRef );
474
        index |= 0x80000000;
559
			// get method
475
    }
560
			aComplexReturn.push_back( !cppu_isSimpleType( pRetTD ) );
476
    unsigned int * p = reinterpret_cast< unsigned int * >(code);
561
			// set method
477
    OSL_ASSERT(sizeof (unsigned int) == 4);
562
			if( ! ((typelib_InterfaceAttributeTypeDescription*)pMember)->bReadOnly )
478
    // st %o0, [%sp+68]:
563
				aComplexReturn.push_back( sal_False );
479
    *p++ = 0xD023A044;
564
			TYPELIB_DANGER_RELEASE( pRetTD );
480
    // st %o1, [%sp+72]:
565
		}
481
    *p++ = 0xD223A048;
566
		else
482
    // st %o2, [%sp+76]:
567
		{
483
    *p++ = 0xD423A04C;
568
			typelib_TypeDescription * pRetTD = 0;
484
    // st %o3, [%sp+80]:
569
			TYPELIB_DANGER_GET( &pRetTD, ((typelib_InterfaceMethodTypeDescription *)pMember)->pReturnTypeRef );
485
    *p++ = 0xD623A050;
570
			aComplexReturn.push_back( !cppu_isSimpleType( pRetTD ) );
486
    // st %o4, [%sp+84]:
571
			TYPELIB_DANGER_RELEASE( pRetTD );
487
    *p++ = 0xD823A054;
572
		}
488
    // st %o5, [%sp+88]:
573
		TYPELIB_DANGER_RELEASE( pMember );
489
    *p++ = 0xDA23A058;
574
	}
490
    // sethi %hi(index), %o0:
575
491
    *p++ = 0x11000000 | (index >> 10);
576
	int nSize = aComplexReturn.size();
492
    // or %o0, %lo(index), %o0:
577
	const int nSnippetSize = 64;
493
    *p++ = 0x90122000 | (index & 0x3FF);
578
	char * pSpace = (char *)rtl_allocateMemory( (2*(nSize+2)*sizeof(void *)) + (nSize*nSnippetSize) );
494
    // sethi %hi(vtableOffset), %o2:
579
	pBuffer->m_pVTable = (void*)pSpace;
495
    *p++ = 0x15000000 | (vtableOffset >> 10);
580
	
496
    // or %o2, %lo(vtableOffset), %o2:
581
	char * pCode	= pSpace + (2*(nSize+2)*sizeof(void *));
497
    *p++ = 0x9412A000 | (vtableOffset & 0x3FF);
582
	void ** pvft	= (void **)pSpace;
498
    // sethi %hi(cpp_vtable_call), %o3:
583
499
    *p++ = 0x17000000 | (reinterpret_cast< unsigned int >(cpp_vtable_call) >> 10);
584
	// setup vft and code
500
    // or %o3, %lo(cpp_vtable_call), %o3:
585
	for ( sal_Int32 nPos = 0; nPos < nSize; ++nPos )
501
    *p++ = 0x9612E000 | (reinterpret_cast< unsigned int >(cpp_vtable_call) & 0x3FF);
586
	{
502
    // jmpl %o3, %g0:
587
		unsigned long * codeSnip = (unsigned long *)(pCode + (nPos*nSnippetSize));
503
    *p++ = 0x81C2C000;
588
		pvft[ nPos ] = codeSnip;
504
    // mov %sp, %o1:
589
		unsigned long nTablePos = nPos;
505
    *p++ = 0x9210000E;
590
		sal_Bool bComplex = aComplexReturn.front();
506
    OSL_ASSERT(
591
		if( bComplex )
507
        reinterpret_cast< unsigned char * >(p) - code <= codeSnippetSize);
592
			nTablePos |= 0x80000000;
508
    return code + codeSnippetSize;
593
		aComplexReturn.pop_front();
509
}
594
510
595
		/*
511
}
596
		 *	generate this code
512
597
		 * 
513
void ** bridges::cpp_uno::shared::VtableFactory::mapBlockToVtable(char * block)
598
		 *	st %o0, [%sp+68]				save registers
514
{
599
 		 *	st %o1, [%sp+72]
515
    return reinterpret_cast< void ** >(block) + 1;
600
 		 *	st %o2, [%sp+76]
516
}
601
 		 *	st %o3, [%sp+80]
517
602
 		 *	st %o4, [%sp+84]
518
char * bridges::cpp_uno::shared::VtableFactory::createBlock(
603
 		 *	st %o5, [%sp+88]
519
    sal_Int32 slotCount, void *** slots)
604
		 *
520
{
605
		 *	mov %sp, %o1					prepare stack ptr for cpp_vtable_call
521
    char * block = new char[
606
		 *	sethi %hi( nTablePos ), %o0		prepare table entry
522
        (slotCount + 3) * sizeof (void *) + slotCount * codeSnippetSize];
607
		 *	or %lo( nTablePos ), %o0		(on complex return set high bit
523
    *slots = mapBlockToVtable(block) + 2;
608
		 *
524
     (*slots)[-3] = 0; //RTTI
609
		 *	sethi $hi( cpp_vtable_call ), %l0
525
     (*slots)[-2] = 0; //null
610
		 *	or %l0, %lo( cpp_vtable_call ), %l0
526
     (*slots)[-1] = 0; //destructor
611
		 *	jmp %l0
527
    return block;
612
		 *	nop
528
}
613
		 *
529
614
		 *	Note: %o0 should be restored by cpp_vtable_call if void returned
530
unsigned char * bridges::cpp_uno::shared::VtableFactory::addLocalFunctions(
615
		 *	%o1 should be restored if not hyper returned
531
    void ** slots, unsigned char * code,
616
		 *	%o2 must be restored
532
    typelib_InterfaceTypeDescription const * type, sal_Int32 functionOffset,
617
		 *
533
    sal_Int32 functionCount, sal_Int32 vtableOffset)
618
		 */
534
{
619
		*codeSnip++	= 0xd023a044;
535
    for (sal_Int32 i = 0; i < type->nMembers; ++i) {
620
		*codeSnip++ = 0xd223a048;
536
        typelib_TypeDescription * member = 0;
621
		*codeSnip++ = 0xd423a04c;
537
        TYPELIB_DANGER_GET(&member, type->ppMembers[i]);
622
		*codeSnip++ = 0xd623a050;
538
        OSL_ASSERT(member != 0);
623
		*codeSnip++ = 0xd823a054;
539
        switch (member->eTypeClass) {
624
		*codeSnip++ = 0xda23a058;
540
        case typelib_TypeClass_INTERFACE_ATTRIBUTE:
625
541
            // Getter:
626
		*codeSnip++ = 0x9210000e;
542
            *slots++ = code;
627
		*codeSnip++ = 0x11000000 | ( nTablePos >> 10 );
543
            code = codeSnippet(
628
		*codeSnip++ = 0x90122000 | ( nTablePos & 1023 );
544
                code, functionOffset++, vtableOffset,
629
		*codeSnip++ = 0x15000000 | ( ((unsigned long)cpp_vtable_call) >> 10 );
545
                bridges::cpp_uno::shared::isSimpleType(
630
		*codeSnip++	= 0x9412a000 | ( ((unsigned long)cpp_vtable_call) & 1023 );
546
                    reinterpret_cast<
631
		*codeSnip++ = 0x81c28000;
547
		    typelib_InterfaceAttributeTypeDescription * >(
632
		*codeSnip++ = 0x01000000;		
548
		    member)->pAttributeTypeRef));
633
	}
549
            // Setter:
634
}
550
            if (!reinterpret_cast<
635
551
                typelib_InterfaceAttributeTypeDescription * >(
636
//==================================================================================================
552
                    member)->bReadOnly)
637
void SAL_CALL cppu_cppInterfaceProxy_patchVtable(
553
            {
638
	XInterface * pCppI, typelib_InterfaceTypeDescription * pTypeDescr ) throw ()
554
                *slots++ = code;
639
{
555
                code = codeSnippet(code, functionOffset++, vtableOffset, true);
640
	static MediateClassData * s_pMediateClassData = 0;
556
            }
641
	if (! s_pMediateClassData)
557
            break;
642
	{
643
		MutexGuard aGuard( Mutex::getGlobalMutex() );
644
		if (! s_pMediateClassData)
645
		{
646
#ifdef LEAK_STATIC_DATA
647
			s_pMediateClassData = new MediateClassData();
648
#else
649
			static MediateClassData s_aMediateClassData;
650
			s_pMediateClassData = &s_aMediateClassData;
651
#endif
652
		}
653
	}
654
	*(const void **)pCppI = s_pMediateClassData->getClassData( pTypeDescr )->m_pVTable;
655
}
656
657
}
658
659
//##################################################################################################
660
extern "C" SAL_DLLEXPORT sal_Bool SAL_CALL component_canUnload( TimeValue * pTime )
661
	SAL_THROW_EXTERN_C()
662
{
663
	return CPPU_CURRENT_NAMESPACE::g_moduleCount.canUnload( &CPPU_CURRENT_NAMESPACE::g_moduleCount, pTime );
664
}
665
//##################################################################################################
666
extern "C" SAL_DLLEXPORT void SAL_CALL uno_initEnvironment( uno_Environment * pCppEnv )
667
	SAL_THROW_EXTERN_C()
668
{
669
	CPPU_CURRENT_NAMESPACE::cppu_cppenv_initEnvironment( pCppEnv );
670
}
671
//##################################################################################################
672
extern "C" SAL_DLLEXPORT void SAL_CALL uno_ext_getMapping(
673
	uno_Mapping ** ppMapping, uno_Environment * pFrom, uno_Environment * pTo )
674
	SAL_THROW_EXTERN_C()
675
{
676
	CPPU_CURRENT_NAMESPACE::cppu_ext_getMapping( ppMapping, pFrom, pTo );
677
}
678
558
559
        case typelib_TypeClass_INTERFACE_METHOD:
560
            *slots++ = code;
561
            code = codeSnippet(
562
                code, functionOffset++, vtableOffset,
563
                bridges::cpp_uno::shared::isSimpleType(
564
                    reinterpret_cast<
565
                    typelib_InterfaceMethodTypeDescription * >(
566
                        member)->pReturnTypeRef));
567
            break;
568
569
        default:
570
            OSL_ASSERT(false);
571
            break;
572
        }
573
        TYPELIB_DANGER_RELEASE(member);
574
    }
575
    return code;
576
}
577
578
void bridges::cpp_uno::shared::VtableFactory::flushCode(
579
  	   unsigned char const *, unsigned char const *)
580
  	{
581
        //TODO: flush the instruction cache (there probably is OS support for this)
582
	}
(-)source/cpp_uno/gcc3_linux_sparc/except.cxx (-1 / +1 lines)
Lines 69-75 Link Here
69
#include <osl/diagnose.h>
69
#include <osl/diagnose.h>
70
#include <osl/mutex.hxx>
70
#include <osl/mutex.hxx>
71
71
72
#include <bridges/cpp_uno/bridge.hxx>
72
#include <com/sun/star/uno/genfunc.hxx>
73
#include <typelib/typedescription.hxx>
73
#include <typelib/typedescription.hxx>
74
#include <uno/any2.h>
74
#include <uno/any2.h>
75
75
(-)source/cpp_uno/gcc3_linux_sparc/makefile.mk (-9 / +9 lines)
Lines 78-88 Link Here
78
78
79
.IF "$(COM)$(OS)$(CPU)" == "GCCLINUXS"
79
.IF "$(COM)$(OS)$(CPU)" == "GCCLINUXS"
80
80
81
.IF "$(bridges_debug)" != ""
81
.IF "$(cppu_no_leak)" == ""
82
CFLAGS += -DBRIDGES_DEBUG
82
CFLAGS += -DLEAK_STATIC_DATA
83
.ENDIF
83
.ENDIF
84
84
85
CFLAGSNOOPT=-O0
85
CFLAGSNOOPT=-O0
86
86
NOOPTFILES = \
87
NOOPTFILES = \
87
	$(SLO)$/uno2cpp.obj	\
88
	$(SLO)$/uno2cpp.obj	\
88
	$(SLO)$/cpp2uno.obj
89
	$(SLO)$/cpp2uno.obj
Lines 92-107 Link Here
92
	$(SLO)$/cpp2uno.obj		\
93
	$(SLO)$/cpp2uno.obj		\
93
	$(SLO)$/uno2cpp.obj
94
	$(SLO)$/uno2cpp.obj
94
95
95
SHL1TARGET= $(TARGET)
96
96
97
SHL1DEF=    $(MISC)$/$(SHL1TARGET).def
97
SHL1TARGET=$(TARGET)
98
SHL1IMPLIB= i$(TARGET)
98
99
SHL1DEF=$(MISC)$/$(SHL1TARGET).def
100
SHL1IMPLIB=i$(TARGET)
99
SHL1VERSIONMAP=..$/..$/bridge_exports.map
101
SHL1VERSIONMAP=..$/..$/bridge_exports.map
100
102
101
SHL1OBJS= \
103
SHL1OBJS= $(SLOFILES)
102
	$(SLO)$/except.obj		\
104
SHL1LIBS =$(SLB)$/cpp_uno_shared.lib
103
	$(SLO)$/cpp2uno.obj		\
104
	$(SLO)$/uno2cpp.obj
105
105
106
SHL1STDLIBS= \
106
SHL1STDLIBS= \
107
	$(CPPULIB) \
107
	$(CPPULIB) \
(-)source/cpp_uno/gcc3_linux_sparc/share.hxx (-2 / +2 lines)
Lines 58-71 Link Here
58
 *
58
 *
59
 *
59
 *
60
 ************************************************************************/
60
 ************************************************************************/
61
61
#include "uno/mapping.h"
62
#include <typeinfo>
62
#include <typeinfo>
63
#include <exception>
63
#include <exception>
64
#include <cstddef>
64
#include <cstddef>
65
65
66
namespace CPPU_CURRENT_NAMESPACE
66
namespace CPPU_CURRENT_NAMESPACE
67
{
67
{
68
68
void dummy_can_throw_anything( char const * );
69
// ----- following decl from libstdc++-v3/libsupc++/unwind-cxx.h and unwind.h
69
// ----- following decl from libstdc++-v3/libsupc++/unwind-cxx.h and unwind.h
70
70
71
struct _Unwind_Exception
71
struct _Unwind_Exception
(-)source/cpp_uno/gcc3_linux_sparc/uno2cpp.cxx (-79 / +94 lines)
Lines 60-91 Link Here
60
 ************************************************************************/
60
 ************************************************************************/
61
61
62
#include <malloc.h>
62
#include <malloc.h>
63
#ifndef _RTL_ALLOC_H_
63
#include <com/sun/star/uno/genfunc.hxx>
64
#include <rtl/alloc.h>
65
#endif
66
67
#ifndef _UNO_DATA_H_
64
#ifndef _UNO_DATA_H_
68
#include <uno/data.h>
65
#include <uno/data.h>
69
#endif
66
#endif
70
#ifndef _BRIDGES_CPP_UNO_BRIDGE_HXX_
67
71
#include <bridges/cpp_uno/bridge.hxx>
68
#include "bridges/cpp_uno/shared/bridge.hxx"
72
#endif
69
#include "bridges/cpp_uno/shared/types.hxx"
73
#ifndef _BRIDGES_CPP_UNO_TYPE_MISC_HXX_
70
#include "bridges/cpp_uno/shared/unointerfaceproxy.hxx"
74
#include <bridges/cpp_uno/type_misc.hxx>
71
#include "bridges/cpp_uno/shared/vtables.hxx"
75
#endif
76
72
77
#include "share.hxx"
73
#include "share.hxx"
78
74
79
using namespace rtl;
75
using namespace rtl;
80
using namespace com::sun::star::uno;
76
using namespace com::sun::star::uno;
81
77
82
namespace CPPU_CURRENT_NAMESPACE
78
namespace
83
{
79
{
84
85
void dummy_can_throw_anything( char const * );
86
87
//==================================================================================================
80
//==================================================================================================
88
static void callVirtualMethod( void * pThis,
81
static void callVirtualMethod( void * pAdjustedThisPtr,
89
									  sal_Int32 nVtableIndex,
82
									  sal_Int32 nVtableIndex,
90
									  void * pRegisterReturn,
83
									  void * pRegisterReturn,
91
									  typelib_TypeClass eReturnType,
84
									  typelib_TypeClass eReturnType,
Lines 95-107 Link Here
95
	// parameter list is mixed list of * and values
88
	// parameter list is mixed list of * and values
96
	// reference parameters are pointers
89
	// reference parameters are pointers
97
90
98
	OSL_ENSURE( pStackLongs && pThis, "### null ptr!" );
91
	OSL_ENSURE( pStackLongs && pAdjustedThisPtr, "### null ptr!" );
99
	OSL_ENSURE( (sizeof(void *) == 4) &&
92
	OSL_ENSURE( (sizeof(void *) == 4) &&
100
				 (sizeof(sal_Int32) == 4), "### unexpected size of int!" );
93
				 (sizeof(sal_Int32) == 4), "### unexpected size of int!" );
101
	OSL_ENSURE( nStackLongs && pStackLongs, "### no stack in callVirtualMethod !" );
94
	OSL_ENSURE( nStackLongs && pStackLongs, "### no stack in callVirtualMethod !" );
102
95
103
    // never called
96
    // never called
104
    if (! pThis) dummy_can_throw_anything("xxx"); // address something
97
    if (! pAdjustedThisPtr) CPPU_CURRENT_NAMESPACE::dummy_can_throw_anything("xxx"); // address something
105
98
106
	volatile long o0 = 0, o1 = 0; // for register returns
99
	volatile long o0 = 0, o1 = 0; // for register returns
107
	volatile double f0d = 0;
100
	volatile double f0d = 0;
Lines 217-223 Link Here
217
		"ld [%%i0], %%l0\n\t"		// get vtable ptr
210
		"ld [%%i0], %%l0\n\t"		// get vtable ptr
218
211
219
"sll %%i1, 2, %%l6\n\t"
212
"sll %%i1, 2, %%l6\n\t"
220
//         "add %%l6, 8, %%l6\n\t"		
213
//         "add %%l6, 8, %%l6\n\t"
221
		"add %%l6, %%l0, %%l0\n\t"
214
		"add %%l6, %%l0, %%l0\n\t"
222
// 		// vtable has 8byte wide entries,
215
// 		// vtable has 8byte wide entries,
223
// 		// upper half contains 2 half words, of which the first
216
// 		// upper half contains 2 half words, of which the first
Lines 299-317 Link Here
299
	}
292
	}
300
}
293
}
301
294
302
//================================================================================================== 
295
296
//==================================================================================================
303
static void cpp_call(
297
static void cpp_call(
304
	cppu_unoInterfaceProxy * pThis,
298
	bridges::cpp_uno::shared::UnoInterfaceProxy * pThis,
305
	sal_Int32 nVtableCall,
299
	bridges::cpp_uno::shared::VtableSlot aVtableSlot,
306
	typelib_TypeDescriptionReference * pReturnTypeRef,
300
	typelib_TypeDescriptionReference * pReturnTypeRef,
307
	sal_Int32 nParams, typelib_MethodParameter * pParams,
301
	sal_Int32 nParams, typelib_MethodParameter * pParams,
308
	void * pUnoReturn, void * pUnoArgs[], uno_Any ** ppUnoExc )
302
	void * pUnoReturn, void * pUnoArgs[], uno_Any ** ppUnoExc )
309
{
303
{
310
  	// max space for: complex ret ptr, this, values|ptr ...
304
  	// max space for: complex ret ptr, this, values|ptr ...
311
  	char * pCppStack		=
305
  	char * pCppStack	= (char *)alloca( (nParams+3) * sizeof(sal_Int64) );
312
  		(char *)alloca( (nParams+2) * sizeof(sal_Int64) );
313
  	char * pCppStackStart	= pCppStack;
306
  	char * pCppStackStart	= pCppStack;
314
	
307
315
	// return
308
	// return
316
	typelib_TypeDescription * pReturnTypeDescr = 0;
309
	typelib_TypeDescription * pReturnTypeDescr = 0;
317
	TYPELIB_DANGER_GET( &pReturnTypeDescr, pReturnTypeRef );
310
	TYPELIB_DANGER_GET( &pReturnTypeDescr, pReturnTypeRef );
Lines 321-342 Link Here
321
	
314
	
322
	if (pReturnTypeDescr)
315
	if (pReturnTypeDescr)
323
	{
316
	{
324
		if (cppu_isSimpleType( pReturnTypeDescr ))
317
		if (bridges::cpp_uno::shared::isSimpleType( pReturnTypeDescr ))
325
		{
318
		{
326
			pCppReturn = pUnoReturn; // direct way for simple types
319
			pCppReturn = pUnoReturn; // direct way for simple types
327
			*(void**)pCppStack = NULL;
328
		}
320
		}
329
		else
321
		else
330
		{
322
		{
331
			// complex return via ptr
323
			// complex return via ptr
332
			pCppReturn = *(void **)pCppStack = (cppu_relatesToInterface( pReturnTypeDescr )
324
			pCppReturn = *(void **)pCppStack
333
												? alloca( pReturnTypeDescr->nSize )
325
			= (bridges::cpp_uno::shared::relatesToInterfaceType(
334
												: pUnoReturn); // direct way
326
			 pReturnTypeDescr )
327
			? alloca( pReturnTypeDescr->nSize )
328
			: pUnoReturn); // direct way
335
		}
329
		}
336
		pCppStack += sizeof(void*);
330
		pCppStack += sizeof(void*);
337
	}
331
	}
338
	// push this
332
	// push this
339
	*(void**)pCppStack = pThis->pCppI;
333
	void * pAdjustedThisPtr = reinterpret_cast< void ** >(pThis->getCppI())
334
  	       + aVtableSlot.offset;
335
  	       *(void**)pCppStack = pAdjustedThisPtr;
340
	pCppStack += sizeof( void* );
336
	pCppStack += sizeof( void* );
341
337
342
	// stack space
338
	// stack space
Lines 355-374 Link Here
355
		const typelib_MethodParameter & rParam = pParams[nPos];
351
		const typelib_MethodParameter & rParam = pParams[nPos];
356
		typelib_TypeDescription * pParamTypeDescr = 0;
352
		typelib_TypeDescription * pParamTypeDescr = 0;
357
		TYPELIB_DANGER_GET( &pParamTypeDescr, rParam.pTypeRef );
353
		TYPELIB_DANGER_GET( &pParamTypeDescr, rParam.pTypeRef );
358
		
354
		if (!rParam.bOut
359
		if (!rParam.bOut && cppu_isSimpleType( pParamTypeDescr ))
355
  	           && bridges::cpp_uno::shared::isSimpleType( pParamTypeDescr ))
360
		{
356
		{
361
			pCppArgs[ nPos ] = adjustPointer( pCppStack, pParamTypeDescr );
357
			pCppArgs[ nPos ] = CPPU_CURRENT_NAMESPACE::adjustPointer(
358
				pCppStack, pParamTypeDescr );
362
			uno_copyAndConvertData( pCppArgs[nPos], pUnoArgs[nPos], pParamTypeDescr,
359
			uno_copyAndConvertData( pCppArgs[nPos], pUnoArgs[nPos], pParamTypeDescr,
363
									&pThis->pBridge->aUno2Cpp );
360
									pThis->getBridge()->getUno2Cpp() );
364
			
361
365
			switch (pParamTypeDescr->eTypeClass)
362
			switch (pParamTypeDescr->eTypeClass)
366
			{
363
			{
367
			case typelib_TypeClass_HYPER:
364
			case typelib_TypeClass_HYPER:
368
			case typelib_TypeClass_UNSIGNED_HYPER:
365
			case typelib_TypeClass_UNSIGNED_HYPER:
369
			case typelib_TypeClass_DOUBLE:
366
			case typelib_TypeClass_DOUBLE:
370
				pCppStack += sizeof(sal_Int32); // extra long
367
371
			}
368
                          OSL_ASSERT( sizeof (double) == sizeof (sal_Int64) );
369
                          *reinterpret_cast< sal_Int32 * >(pCppStack) =
370
                          *reinterpret_cast< sal_Int32 const * >(pUnoArgs[ nPos ]);
371
                          pCppStack += sizeof (sal_Int32);
372
                          *reinterpret_cast< sal_Int32 * >(pCppStack) =
373
                          *(reinterpret_cast< sal_Int32 const * >(pUnoArgs[ nPos ] ) + 1);
374
                          break;
375
            		default:
376
                          uno_copyAndConvertData(
377
                             pCppArgs[nPos], pUnoArgs[nPos], pParamTypeDescr,
378
                            pThis->getBridge()->getUno2Cpp() );
379
                          break;
380
                        }
372
			// no longer needed
381
			// no longer needed
373
			TYPELIB_DANGER_RELEASE( pParamTypeDescr );
382
			TYPELIB_DANGER_RELEASE( pParamTypeDescr );
374
		}
383
		}
Lines 385-396 Link Here
385
				ppTempParamTypeDescr[nTempIndizes++] = pParamTypeDescr;
394
				ppTempParamTypeDescr[nTempIndizes++] = pParamTypeDescr;
386
			}
395
			}
387
			// is in/inout
396
			// is in/inout
388
			else if (cppu_relatesToInterface( pParamTypeDescr ))
397
			else if (bridges::cpp_uno::shared::relatesToInterfaceType(
398
  	                        pParamTypeDescr ))
389
			{
399
			{
390
				uno_copyAndConvertData(
400
				uno_copyAndConvertData(
391
					*(void **)pCppStack = pCppArgs[nPos] = alloca( pParamTypeDescr->nSize ),
401
					*(void **)pCppStack = pCppArgs[nPos] = alloca( pParamTypeDescr->nSize ),
392
					pUnoArgs[nPos], pParamTypeDescr, &pThis->pBridge->aUno2Cpp );
402
                                pUnoArgs[nPos], pParamTypeDescr,
393
				
403
  	                   pThis->getBridge()->getUno2Cpp() );
404
394
				pTempIndizes[nTempIndizes] = nPos; // has to be reconverted
405
				pTempIndizes[nTempIndizes] = nPos; // has to be reconverted
395
				// will be released at reconversion
406
				// will be released at reconversion
396
				ppTempParamTypeDescr[nTempIndizes++] = pParamTypeDescr;
407
				ppTempParamTypeDescr[nTempIndizes++] = pParamTypeDescr;
Lines 408-420 Link Here
408
	try
419
	try
409
	{
420
	{
410
		OSL_ENSURE( !( (pCppStack - pCppStackStart ) & 3), "UNALIGNED STACK !!! (Please DO panic" );
421
		OSL_ENSURE( !( (pCppStack - pCppStackStart ) & 3), "UNALIGNED STACK !!! (Please DO panic" );
422
		int nStackLongs = (pCppStack - pCppStackStart)/sizeof(sal_Int32);
423
		if( nStackLongs & 1 )
424
			// stack has to be 8 byte aligned
425
			nStackLongs++;
411
		callVirtualMethod(
426
		callVirtualMethod(
412
			pThis->pCppI, nVtableCall,
427
			pAdjustedThisPtr,
413
			pCppReturn, pReturnTypeDescr->eTypeClass,
428
			aVtableSlot.index,
414
			(sal_Int32 *)pCppStackStart, (pCppStack - pCppStackStart) / sizeof(sal_Int32) );
429
			pCppReturn,
430
			pReturnTypeDescr->eTypeClass,
431
			(sal_Int32 *)pCppStackStart,
432
			nStackLongs);
415
		// NO exception occured...
433
		// NO exception occured...
416
		*ppUnoExc = 0;
434
		*ppUnoExc = 0;
417
		
435
418
		// reconvert temporary params
436
		// reconvert temporary params
419
		for ( ; nTempIndizes--; )
437
		for ( ; nTempIndizes--; )
420
		{
438
		{
Lines 427-439 Link Here
427
				{
445
				{
428
					uno_destructData( pUnoArgs[nIndex], pParamTypeDescr, 0 ); // destroy uno value
446
					uno_destructData( pUnoArgs[nIndex], pParamTypeDescr, 0 ); // destroy uno value
429
					uno_copyAndConvertData( pUnoArgs[nIndex], pCppArgs[nIndex], pParamTypeDescr,
447
					uno_copyAndConvertData( pUnoArgs[nIndex], pCppArgs[nIndex], pParamTypeDescr,
430
											&pThis->pBridge->aCpp2Uno );
448
											pThis->getBridge()->getCpp2Uno() );
431
				}
449
				}
432
			}
450
			}
433
			else // pure out
451
			else // pure out
434
			{
452
			{
435
				uno_copyAndConvertData( pUnoArgs[nIndex], pCppArgs[nIndex], pParamTypeDescr,
453
				uno_copyAndConvertData( pUnoArgs[nIndex], pCppArgs[nIndex], pParamTypeDescr,
436
										&pThis->pBridge->aCpp2Uno );
454
										pThis->getBridge()->getCpp2Uno() );
437
			}
455
			}
438
			// destroy temp cpp param => cpp: every param was constructed
456
			// destroy temp cpp param => cpp: every param was constructed
439
			uno_destructData( pCppArgs[nIndex], pParamTypeDescr, cpp_release );
457
			uno_destructData( pCppArgs[nIndex], pParamTypeDescr, cpp_release );
Lines 444-459 Link Here
444
		if (pCppReturn && pUnoReturn != pCppReturn)
462
		if (pCppReturn && pUnoReturn != pCppReturn)
445
		{
463
		{
446
			uno_copyAndConvertData( pUnoReturn, pCppReturn, pReturnTypeDescr,
464
			uno_copyAndConvertData( pUnoReturn, pCppReturn, pReturnTypeDescr,
447
									&pThis->pBridge->aCpp2Uno );
465
									pThis->getBridge()->getCpp2Uno() );
448
			uno_destructData( pCppReturn, pReturnTypeDescr, cpp_release );
466
			uno_destructData( pCppReturn, pReturnTypeDescr, cpp_release );
449
		}
467
		}
450
	}
468
	}
451
 	catch( ... )
469
 	catch( ... )
452
 	{
470
 	{
453
  		// get exception
471
                printf("uno2cpp catch got exception!!!\n"); // why is the following __cxa ???
454
		fillUnoException(
472
		// get exception
455
            __cxa_get_globals()->caughtExceptions, *ppUnoExc, &pThis->pBridge->aCpp2Uno );
473
		   fillUnoException( CPPU_CURRENT_NAMESPACE::__cxa_get_globals()->caughtExceptions, *ppUnoExc, pThis->getBridge()->getCpp2Uno() );
456
        
474
457
		// temporary params
475
		// temporary params
458
		for ( ; nTempIndizes--; )
476
		for ( ; nTempIndizes--; )
459
		{
477
		{
Lines 468-478 Link Here
468
	}
486
	}
469
}
487
}
470
488
489
}
471
490
472
//==================================================================================================
491
//==================================================================================================
473
void SAL_CALL cppu_unoInterfaceProxy_dispatch(
492
void bridges::cpp_uno::shared::UnoInterfaceProxy::dispatch(
474
	uno_Interface * pUnoI, const typelib_TypeDescription * pMemberDescr,
493
	uno_Interface * pUnoI, const typelib_TypeDescription * pMemberDescr,
475
	void * pReturn, void * pArgs[], uno_Any ** ppException ) throw ()
494
void * pReturn, void * pArgs[], uno_Any ** ppException ) SAL_THROW(())
476
{
495
{
477
#if defined BRIDGES_DEBUG
496
#if defined BRIDGES_DEBUG
478
    OString cstr( OUStringToOString( pMemberDescr->pTypeName, RTL_TEXTENCODING_ASCII_US ) );
497
    OString cstr( OUStringToOString( pMemberDescr->pTypeName, RTL_TEXTENCODING_ASCII_US ) );
Lines 480-504 Link Here
480
#endif
499
#endif
481
    
500
    
482
	// is my surrogate
501
	// is my surrogate
483
	cppu_unoInterfaceProxy * pThis = (cppu_unoInterfaceProxy *)pUnoI;
502
	bridges::cpp_uno::shared::UnoInterfaceProxy * pThis
503
       = static_cast< bridges::cpp_uno::shared::UnoInterfaceProxy * >(pUnoI);
484
	typelib_InterfaceTypeDescription * pTypeDescr = pThis->pTypeDescr;
504
	typelib_InterfaceTypeDescription * pTypeDescr = pThis->pTypeDescr;
485
	
505
486
	switch (pMemberDescr->eTypeClass)
506
	switch (pMemberDescr->eTypeClass)
487
	{
507
	{
488
	case typelib_TypeClass_INTERFACE_ATTRIBUTE:
508
	case typelib_TypeClass_INTERFACE_ATTRIBUTE:
489
	{
509
	{
490
		// determine vtable call index
510
	 VtableSlot aVtableSlot(
491
		sal_Int32 nMemberPos = ((typelib_InterfaceMemberTypeDescription *)pMemberDescr)->nPosition;
511
  	           getVtableSlot(
492
		OSL_ENSURE( nMemberPos < pTypeDescr->nAllMembers, "### member pos out of range!" );
512
  	               reinterpret_cast<
493
		
513
  	                   typelib_InterfaceAttributeTypeDescription const * >(
494
		sal_Int32 nVtableCall = pTypeDescr->pMapMemberIndexToFunctionIndex[nMemberPos];
514
  	                       pMemberDescr)));
495
		OSL_ENSURE( nVtableCall < pTypeDescr->nMapFunctionIndexToMemberIndex, "### illegal vtable index!" );
496
		
497
		if (pReturn)
515
		if (pReturn)
498
		{
516
		{
499
			// dependent dispatch
517
			// dependent dispatch
500
			cpp_call(
518
			cpp_call(
501
				pThis, nVtableCall,
519
				pThis, aVtableSlot,
502
				((typelib_InterfaceAttributeTypeDescription *)pMemberDescr)->pAttributeTypeRef,
520
				((typelib_InterfaceAttributeTypeDescription *)pMemberDescr)->pAttributeTypeRef,
503
				0, 0, // no params
521
				0, 0, // no params
504
				pReturn, pArgs, ppException );
522
				pReturn, pArgs, ppException );
Lines 518-529 Link Here
518
				&pReturnTypeRef, typelib_TypeClass_VOID, aVoidName.pData );
536
				&pReturnTypeRef, typelib_TypeClass_VOID, aVoidName.pData );
519
			
537
			
520
			// dependent dispatch
538
			// dependent dispatch
539
			aVtableSlot.index += 1; // get, then set method
521
			cpp_call(
540
			cpp_call(
522
				pThis, nVtableCall +1, // get, then set method
541
				pThis, aVtableSlot,
523
				pReturnTypeRef,
542
				pReturnTypeRef,
524
				1, &aParam,
543
				1, &aParam,
525
				pReturn, pArgs, ppException );
544
				pReturn, pArgs, ppException );
526
			
545
527
			typelib_typedescriptionreference_release( pReturnTypeRef );
546
			typelib_typedescriptionreference_release( pReturnTypeRef );
528
		}
547
		}
529
		
548
		
Lines 531-544 Link Here
531
	}
550
	}
532
	case typelib_TypeClass_INTERFACE_METHOD:
551
	case typelib_TypeClass_INTERFACE_METHOD:
533
	{
552
	{
534
		// determine vtable call index
553
		VtableSlot aVtableSlot(
535
		sal_Int32 nMemberPos = ((typelib_InterfaceMemberTypeDescription *)pMemberDescr)->nPosition;
554
		getVtableSlot(
536
		OSL_ENSURE( nMemberPos < pTypeDescr->nAllMembers, "### member pos out of range!" );
555
		 reinterpret_cast<
537
		
556
		  typelib_InterfaceMethodTypeDescription const * >(
538
		sal_Int32 nVtableCall = pTypeDescr->pMapMemberIndexToFunctionIndex[nMemberPos];
557
		  pMemberDescr)));
539
		OSL_ENSURE( nVtableCall < pTypeDescr->nMapFunctionIndexToMemberIndex, "### illegal vtable index!" );
558
		switch (aVtableSlot.index)
540
		
541
		switch (nVtableCall)
542
		{
559
		{
543
			// standard calls
560
			// standard calls
544
		case 1: // acquire uno interface
561
		case 1: // acquire uno interface
Lines 556-564 Link Here
556
			if (pTD)
573
			if (pTD)
557
			{
574
			{
558
                uno_Interface * pInterface = 0;
575
                uno_Interface * pInterface = 0;
559
                (*pThis->pBridge->pUnoEnv->getRegisteredInterface)(
576
 		(*pThis->pBridge->getUnoEnv()->getRegisteredInterface)(
560
                    pThis->pBridge->pUnoEnv,
577
 		  pThis->pBridge->getUnoEnv(),
561
                    (void **)&pInterface, pThis->oid.pData, (typelib_InterfaceTypeDescription *)pTD );
578
				   (void **)&pInterface, pThis->oid.pData, (typelib_InterfaceTypeDescription *)pTD );
562
			
579
			
563
                if (pInterface)
580
                if (pInterface)
564
                {
581
                {
Lines 576-582 Link Here
576
		default:
593
		default:
577
			// dependent dispatch
594
			// dependent dispatch
578
			cpp_call(
595
			cpp_call(
579
				pThis, nVtableCall,
596
				pThis, aVtableSlot,
580
				((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->pReturnTypeRef,
597
				((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->pReturnTypeRef,
581
				((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->nParams,
598
				((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->nParams,
582
				((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->pParams,
599
				((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->pParams,
Lines 595-601 Link Here
595
		::uno_type_any_construct( *ppException, &aExc, rExcType.getTypeLibType(), 0 );
612
		::uno_type_any_construct( *ppException, &aExc, rExcType.getTypeLibType(), 0 );
596
	}
613
	}
597
	}
614
	}
598
}
599
600
}
615
}
601
616

Return to issue 24507