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

(-)oo_1.0.1_src/bridges/prj/build.lst.bak (+1 lines)
Lines 11-16 Link Here
11
br	bridges\source\cpp_uno\gcc2_freebsd_intel	nmake	-	u	br_gccfi br_unotypes NULL
11
br	bridges\source\cpp_uno\gcc2_freebsd_intel	nmake	-	u	br_gccfi br_unotypes NULL
12
br	bridges\source\cpp_uno\gcc2_linux_powerpc	nmake	-	u	br_gcclp br_unotypes NULL
12
br	bridges\source\cpp_uno\gcc2_linux_powerpc	nmake	-	u	br_gcclp br_unotypes NULL
13
br	bridges\source\cpp_uno\gcc3_linux_powerpc	nmake	-	u	br_gcc3lp br_unotypes NULL
13
br	bridges\source\cpp_uno\gcc3_linux_powerpc	nmake	-	u	br_gcc3lp br_unotypes NULL
14
br	bridges\source\cpp_uno\gcc3_linux_s390		nmake	-	u	br_gcc3l3 br_unotypes NULL
14
br	bridges\source\cpp_uno\gcc2_macosx_powerpc			nmake	-	u	br_gccmacoxp br_unotypes NULL
15
br	bridges\source\cpp_uno\gcc2_macosx_powerpc			nmake	-	u	br_gccmacoxp br_unotypes NULL
15
br	bridges\source\cpp_uno\cc50_solaris_sparc			nmake	-	u	br_cc50sols br_unotypes NULL
16
br	bridges\source\cpp_uno\cc50_solaris_sparc			nmake	-	u	br_cc50sols br_unotypes NULL
16
br	bridges\source\cpp_uno\cc50_solaris_intel			nmake	-	u	br_cc50soli br_unotypes NULL
17
br	bridges\source\cpp_uno\cc50_solaris_intel			nmake	-	u	br_cc50soli br_unotypes NULL
(-)oo_1.0.1_src/bridges/source/cpp_uno/gcc3_linux_s390.old/cpp2uno.cxx (+759 lines)
Line 0 Link Here
1
/*************************************************************************
2
 *
3
 *  $RCSfile: cpp2uno.cxx,v $
4
 *
5
 *  $Revision: 1.1.2.3 $
6
 *
7
 *  last change: $Author: khendricks $ $Date: 2002/05/19 11:25:52 $
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
#include <malloc.h>
63
#include <hash_map>
64
65
#include <rtl/alloc.h>
66
#include <osl/mutex.hxx>
67
68
#include <uno/data.h>
69
#include <typelib/typedescription.hxx>
70
71
#include <bridges/cpp_uno/bridge.hxx>
72
#include <bridges/cpp_uno/type_misc.hxx>
73
74
#include "share.hxx"
75
76
77
using namespace ::osl;
78
using namespace ::rtl;
79
using namespace ::com::sun::star::uno;
80
81
namespace CPPU_CURRENT_NAMESPACE
82
{
83
84
//==================================================================================================
85
rtl_StandardModuleCount g_moduleCount = MODULE_COUNT_INIT;
86
87
//==================================================================================================
88
static typelib_TypeClass cpp2uno_call(
89
	cppu_cppInterfaceProxy * pThis,
90
	const typelib_TypeDescription * pMemberTypeDescr,
91
	typelib_TypeDescriptionReference * pReturnTypeRef, // 0 indicates void return
92
	sal_Int32 nParams, typelib_MethodParameter * pParams,
93
        void ** gpreg, void ** fpreg, void ** ovrflw,
94
	sal_Int64 * pRegisterReturn /* space for register return */ )
95
{
96
        int ng = 0; //number of gpr registers used 
97
        int nf = 0; //number of fpr regsiters used
98
        void ** pCppStack; //temporary stack pointer
99
       
100
        // gpreg:  [ret *], this, [gpr params]
101
        // fpreg:  [fpr params]
102
        // ovrflw: [gpr or fpr params (properly aligned)]
103
104
	// return
105
	typelib_TypeDescription * pReturnTypeDescr = 0;
106
	if (pReturnTypeRef)
107
		TYPELIB_DANGER_GET( &pReturnTypeDescr, pReturnTypeRef );
108
	
109
	void * pUnoReturn = 0;
110
	void * pCppReturn = 0; // complex return ptr: if != 0 && != pUnoReturn, reconversion need
111
	
112
	if (pReturnTypeDescr)
113
	{
114
		if (cppu_isSimpleType( pReturnTypeDescr ))
115
		{
116
			pUnoReturn = pRegisterReturn; // direct way for simple types
117
		}
118
		else // complex return via ptr (pCppReturn)
119
		{
120
			pCppReturn = *(void **)gpreg;
121
                        gpreg++;
122
                        ng++;
123
			
124
			pUnoReturn = (cppu_relatesToInterface( pReturnTypeDescr )
125
						  ? alloca( pReturnTypeDescr->nSize )
126
						  : pCppReturn); // direct way
127
		}
128
	}
129
	// pop this
130
        gpreg++; 
131
        ng++;
132
133
	// stack space
134
	OSL_ENSURE( sizeof(void *) == sizeof(sal_Int32), "### unexpected size!" );
135
	// parameters
136
	void ** pUnoArgs = (void **)alloca( 4 * sizeof(void *) * nParams );
137
	void ** pCppArgs = pUnoArgs + nParams;
138
	// indizes of values this have to be converted (interface conversion cpp<=>uno)
139
	sal_Int32 * pTempIndizes = (sal_Int32 *)(pUnoArgs + (2 * nParams));
140
	// type descriptions for reconversions
141
	typelib_TypeDescription ** ppTempParamTypeDescr = (typelib_TypeDescription **)(pUnoArgs + (3 * nParams));
142
	
143
	sal_Int32 nTempIndizes   = 0;
144
	
145
	for ( sal_Int32 nPos = 0; nPos < nParams; ++nPos )
146
	{
147
		const typelib_MethodParameter & rParam = pParams[nPos];
148
		typelib_TypeDescription * pParamTypeDescr = 0;
149
		TYPELIB_DANGER_GET( &pParamTypeDescr, rParam.pTypeRef );
150
151
		if (!rParam.bOut && cppu_isSimpleType( pParamTypeDescr )) // value
152
		{
153
154
			switch (pParamTypeDescr->eTypeClass)
155
			{
156
157
			  case typelib_TypeClass_DOUBLE:
158
			   if (nf < 2) {
159
			      pCppArgs[nPos] = fpreg;
160
			      pUnoArgs[nPos] = fpreg;
161
			      nf++;
162
			      fpreg += 2;
163
			   } else {
164
				pCppArgs[nPos] = ovrflw;
165
				pUnoArgs[nPos] = ovrflw;
166
			        ovrflw += 2;
167
			   }
168
			   break;
169
170
			   case typelib_TypeClass_FLOAT:
171
			    // fpreg are all double values so need to
172
			    // modify fpreg to be a single word float value
173
			    if (nf < 2) {
174
//			       float tmp = (float) (*((double *)fpreg));
175
//			       (*((float *) fpreg)) = tmp;
176
			       pCppArgs[nPos] = fpreg;
177
			       pUnoArgs[nPos] = fpreg;
178
			       nf++;
179
			       fpreg += 2;
180
			    } else {
181
                              pCppArgs[nPos] = ovrflw;
182
			      pUnoArgs[nPos] = ovrflw;
183
			      ovrflw += 1;
184
                            }
185
			    break;
186
187
			case typelib_TypeClass_HYPER:
188
			case typelib_TypeClass_UNSIGNED_HYPER:
189
			 if (ng < 4) {
190
			    pCppArgs[nPos] = gpreg;
191
			    pUnoArgs[nPos] = gpreg;
192
			    ng += 2;
193
			    gpreg += 2;
194
			 } else {
195
			    pCppArgs[nPos] = ovrflw;
196
			    pUnoArgs[nPos] = ovrflw;
197
			    ovrflw += 2;
198
			  }
199
			  break;
200
201
			case typelib_TypeClass_BYTE:
202
			case typelib_TypeClass_BOOLEAN:
203
			 if (ng < 5) {
204
			      pCppArgs[nPos] = (((char *)gpreg) + 3);
205
			      pUnoArgs[nPos] = (((char *)gpreg) + 3);
206
			      ng++;
207
			      gpreg++;
208
			 } else {
209
			      pCppArgs[nPos] = (((char *)ovrflw) + 3);
210
			      pUnoArgs[nPos] = (((char *)ovrflw) + 3);
211
			      ovrflw++;
212
			 }
213
			 break;
214
215
216
		       case typelib_TypeClass_CHAR:
217
		       case typelib_TypeClass_SHORT:
218
		       case typelib_TypeClass_UNSIGNED_SHORT:
219
			if (ng < 5) {
220
			      pCppArgs[nPos] = (((char *)gpreg)+ 2);
221
			      pUnoArgs[nPos] = (((char *)gpreg)+ 2);
222
			      ng++;
223
			      gpreg++;
224
			} else {
225
			      pCppArgs[nPos] = (((char *)ovrflw) + 2);
226
			      pUnoArgs[nPos] = (((char *)ovrflw) + 2);
227
			      ovrflw++;
228
			}
229
			break;
230
231
232
		      default:
233
			if (ng < 5) {
234
			      pCppArgs[nPos] = gpreg;
235
			      pUnoArgs[nPos] = gpreg;
236
			      ng++;
237
			      gpreg++;
238
			} else {
239
			      pCppArgs[nPos] = ovrflw;
240
			      pUnoArgs[nPos] = ovrflw;
241
			      ovrflw++;
242
			}
243
                        break;
244
245
		        }
246
		        // no longer needed
247
			TYPELIB_DANGER_RELEASE( pParamTypeDescr );
248
		}
249
		else // ptr to complex value | ref
250
		{
251
252
		        if (ng < 5) { 
253
		          pCppArgs[nPos] = *(void **)gpreg;
254
		          pCppStack = gpreg;
255
		          ng++;
256
		          gpreg++;
257
		        } else {
258
		          pCppArgs[nPos] = *(void **)ovrflw;
259
		          pCppStack = ovrflw;
260
		         ovrflw++;
261
		        }
262
263
			if (! rParam.bIn) // is pure out
264
			{
265
				// uno out is unconstructed mem!
266
				pUnoArgs[nPos] = alloca( pParamTypeDescr->nSize );
267
				pTempIndizes[nTempIndizes] = nPos;
268
				// will be released at reconversion
269
				ppTempParamTypeDescr[nTempIndizes++] = pParamTypeDescr;
270
			}
271
			// is in/inout
272
			else if (cppu_relatesToInterface( pParamTypeDescr ))
273
			{
274
				uno_copyAndConvertData( pUnoArgs[nPos] = alloca( pParamTypeDescr->nSize ),
275
										*(void **)pCppStack, pParamTypeDescr,
276
										&pThis->pBridge->aCpp2Uno );
277
				pTempIndizes[nTempIndizes] = nPos; // has to be reconverted
278
				// will be released at reconversion
279
				ppTempParamTypeDescr[nTempIndizes++] = pParamTypeDescr;
280
			}
281
			else // direct way
282
			{
283
				pUnoArgs[nPos] = *(void **)pCppStack;
284
				// no longer needed
285
				TYPELIB_DANGER_RELEASE( pParamTypeDescr );
286
			}
287
		}
288
	}
289
	
290
	// ExceptionHolder
291
	uno_Any aUnoExc; // Any will be constructed by callee
292
	uno_Any * pUnoExc = &aUnoExc;
293
294
	// invoke uno dispatch call
295
	(*pThis->pUnoI->pDispatcher)( pThis->pUnoI, pMemberTypeDescr, pUnoReturn, pUnoArgs, &pUnoExc );
296
	
297
	// in case an exception occured...
298
	if (pUnoExc)
299
	{
300
		// destruct temporary in/inout params
301
		for ( ; nTempIndizes--; )
302
		{
303
			sal_Int32 nIndex = pTempIndizes[nTempIndizes];
304
			
305
			if (pParams[nIndex].bIn) // is in/inout => was constructed
306
				uno_destructData( pUnoArgs[nIndex], ppTempParamTypeDescr[nTempIndizes], 0 );
307
			TYPELIB_DANGER_RELEASE( ppTempParamTypeDescr[nTempIndizes] );
308
		}
309
		if (pReturnTypeDescr)
310
			TYPELIB_DANGER_RELEASE( pReturnTypeDescr );
311
		
312
		raiseException( &aUnoExc, &pThis->pBridge->aUno2Cpp ); // has to destruct the any
313
		// is here for dummy
314
		return typelib_TypeClass_VOID;
315
	}
316
	else // else no exception occured...
317
	{
318
		// temporary params
319
		for ( ; nTempIndizes--; )
320
		{
321
			sal_Int32 nIndex = pTempIndizes[nTempIndizes];
322
			typelib_TypeDescription * pParamTypeDescr = ppTempParamTypeDescr[nTempIndizes];
323
			
324
			if (pParams[nIndex].bOut) // inout/out
325
			{
326
				// convert and assign
327
				uno_destructData( pCppArgs[nIndex], pParamTypeDescr, cpp_release );
328
				uno_copyAndConvertData( pCppArgs[nIndex], pUnoArgs[nIndex], pParamTypeDescr,
329
										&pThis->pBridge->aUno2Cpp );
330
			}
331
			// destroy temp uno param
332
			uno_destructData( pUnoArgs[nIndex], pParamTypeDescr, 0 );
333
			
334
			TYPELIB_DANGER_RELEASE( pParamTypeDescr );
335
		}
336
		// return
337
		if (pCppReturn) // has complex return
338
		{
339
			if (pUnoReturn != pCppReturn) // needs reconversion
340
			{
341
				uno_copyAndConvertData( pCppReturn, pUnoReturn, pReturnTypeDescr,
342
										&pThis->pBridge->aUno2Cpp );
343
				// destroy temp uno return
344
				uno_destructData( pUnoReturn, pReturnTypeDescr, 0 );
345
			}
346
			// complex return ptr is set to return reg
347
			*(void **)pRegisterReturn = pCppReturn;
348
		}
349
		if (pReturnTypeDescr)
350
		{
351
			typelib_TypeClass eRet = (typelib_TypeClass)pReturnTypeDescr->eTypeClass;
352
			TYPELIB_DANGER_RELEASE( pReturnTypeDescr );
353
			return eRet;
354
		}
355
		else
356
			return typelib_TypeClass_VOID;
357
	}
358
}
359
360
361
//==================================================================================================
362
static typelib_TypeClass cpp_mediate(
363
	sal_Int32 nVtableCall,
364
        void ** gpreg, void ** fpreg, void ** ovrflw,
365
	sal_Int64 * pRegisterReturn /* space for register return */ )
366
{
367
	OSL_ENSURE( sizeof(sal_Int32)==sizeof(void *), "### unexpected!" );
368
	
369
	// gpreg:  [ret *], this, [other gpr params]
370
	// fpreg:  [fpr params]
371
	// ovrflw: [gpr or fpr params (properly aligned)]
372
373
	// _this_ ptr is patched cppu_XInterfaceProxy object
374
	cppu_cppInterfaceProxy * pCppI = NULL;
375
	if( nVtableCall & 0x80000000 )
376
	{
377
		nVtableCall &= 0x7fffffff;
378
		pCppI = (cppu_cppInterfaceProxy *)(XInterface *)*(gpreg +1);
379
	}
380
	else
381
    {
382
		pCppI = (cppu_cppInterfaceProxy *)(XInterface *)*(gpreg);
383
    }
384
    
385
	typelib_InterfaceTypeDescription * pTypeDescr = pCppI->pTypeDescr;
386
	
387
	OSL_ENSURE( nVtableCall < pTypeDescr->nMapFunctionIndexToMemberIndex, "### illegal vtable index!" );
388
	if (nVtableCall >= pTypeDescr->nMapFunctionIndexToMemberIndex)
389
	{
390
		throw RuntimeException(
391
            OUString::createFromAscii("illegal vtable index!"),
392
            (XInterface *)pCppI );
393
	}
394
	
395
	// determine called method
396
	OSL_ENSURE( nVtableCall < pTypeDescr->nMapFunctionIndexToMemberIndex, "### illegal vtable index!" );
397
	sal_Int32 nMemberPos = pTypeDescr->pMapFunctionIndexToMemberIndex[nVtableCall];
398
	OSL_ENSURE( nMemberPos < pTypeDescr->nAllMembers, "### illegal member index!" );
399
400
	TypeDescription aMemberDescr( pTypeDescr->ppAllMembers[nMemberPos] );
401
    
402
	typelib_TypeClass eRet;
403
	switch (aMemberDescr.get()->eTypeClass)
404
	{
405
	case typelib_TypeClass_INTERFACE_ATTRIBUTE:
406
	{
407
		if (pTypeDescr->pMapMemberIndexToFunctionIndex[nMemberPos] == nVtableCall)
408
		{
409
			// is GET method
410
			eRet = cpp2uno_call(
411
				pCppI, aMemberDescr.get(),
412
				((typelib_InterfaceAttributeTypeDescription *)aMemberDescr.get())->pAttributeTypeRef,
413
				0, 0, // no params
414
				gpreg, fpreg, ovrflw, pRegisterReturn );
415
		}
416
		else
417
		{
418
			// is SET method
419
			typelib_MethodParameter aParam;
420
			aParam.pTypeRef =
421
				((typelib_InterfaceAttributeTypeDescription *)aMemberDescr.get())->pAttributeTypeRef;
422
			aParam.bIn		= sal_True;
423
			aParam.bOut		= sal_False;
424
			
425
			eRet = cpp2uno_call(
426
				pCppI, aMemberDescr.get(),
427
				0, // indicates void return
428
				1, &aParam,
429
				gpreg, fpreg, ovrflw, pRegisterReturn );
430
		}
431
		break;
432
	}
433
	case typelib_TypeClass_INTERFACE_METHOD:
434
	{
435
		// is METHOD
436
		switch (nVtableCall)
437
		{
438
		case 1: // acquire()
439
			pCppI->acquireProxy(); // non virtual call!
440
			eRet = typelib_TypeClass_VOID;
441
			break;
442
		case 2: // release()
443
			pCppI->releaseProxy(); // non virtual call!
444
			eRet = typelib_TypeClass_VOID;
445
			break;
446
		case 0: // queryInterface() opt
447
		{
448
			typelib_TypeDescription * pTD = 0;
449
			TYPELIB_DANGER_GET( &pTD, reinterpret_cast< Type * >( gpreg[2] )->getTypeLibType() );
450
			if (pTD)
451
			{
452
                XInterface * pInterface = 0;
453
                (*pCppI->pBridge->pCppEnv->getRegisteredInterface)(
454
                    pCppI->pBridge->pCppEnv,
455
                    (void **)&pInterface, pCppI->oid.pData, (typelib_InterfaceTypeDescription *)pTD );
456
			
457
                if (pInterface)
458
                {
459
                    ::uno_any_construct(
460
                        reinterpret_cast< uno_Any * >( gpreg[0] ),
461
                        &pInterface, pTD, cpp_acquire );
462
                    pInterface->release();
463
                    TYPELIB_DANGER_RELEASE( pTD );
464
                    *(void **)pRegisterReturn = gpreg[0];
465
                    eRet = typelib_TypeClass_ANY;
466
                    break;
467
                }
468
                TYPELIB_DANGER_RELEASE( pTD );
469
            }
470
		} // else perform queryInterface()
471
		default:
472
			eRet = cpp2uno_call(
473
				pCppI, aMemberDescr.get(),
474
				((typelib_InterfaceMethodTypeDescription *)aMemberDescr.get())->pReturnTypeRef,
475
				((typelib_InterfaceMethodTypeDescription *)aMemberDescr.get())->nParams,
476
				((typelib_InterfaceMethodTypeDescription *)aMemberDescr.get())->pParams,
477
				gpreg, fpreg, ovrflw, pRegisterReturn );
478
		}
479
		break;
480
	}
481
	default:
482
	{
483
		throw RuntimeException(
484
            OUString::createFromAscii("no member description found!"),
485
            (XInterface *)pCppI );
486
		// is here for dummy
487
		eRet = typelib_TypeClass_VOID;
488
	}
489
	}
490
491
	return eRet;
492
}
493
494
//==================================================================================================
495
/**
496
 * is called on incoming vtable calls
497
 * (called by asm snippets)
498
 */
499
static void cpp_vtable_call( int nTableEntry, void** gpregptr, void** fpregptr, void** ovrflw)
500
{
501
        sal_Int32     gpreg[8];
502
        double        fpreg[8];
503
504
        memcpy( gpreg, gpregptr, 32);
505
        memcpy( fpreg, fpregptr, 64);
506
507
	volatile long nRegReturn[2];
508
509
        sal_Bool bComplex = nTableEntry & 0x80000000 ? sal_True : sal_False;
510
511
	typelib_TypeClass aType = 
512
             cpp_mediate( nTableEntry, (void**)gpreg, (void**)fpreg, ovrflw, (sal_Int64*)nRegReturn );
513
    
514
	switch( aType )
515
	{
516
517
                // move return value into register space
518
                // (will be loaded by machine code snippet)
519
520
                case typelib_TypeClass_BOOLEAN:
521
		  {
522
                  unsigned long tmp = (unsigned long)(*(unsigned char *)nRegReturn);
523
                  __asm__ volatile ( "l 2,%0\n\t" : :
524
			   "m"(tmp) : "2" );
525
                  break;
526
		  }
527
                case typelib_TypeClass_BYTE:
528
		  {
529
                  long tmp = (long)(*(signed char *)nRegReturn);
530
                  __asm__ volatile ( "l 2,%0\n\t" : :
531
			   "m"(tmp) : "2" );
532
                  break;
533
		  }
534
                case typelib_TypeClass_CHAR:
535
                case typelib_TypeClass_UNSIGNED_SHORT:
536
		  {
537
                  unsigned long tmp = (unsigned long)(*(unsigned short *)nRegReturn);
538
                  __asm__ volatile ( "l 2,%0\n\t" : :
539
			   "m"(tmp) : "2" );
540
                  break;
541
		  }
542
                case typelib_TypeClass_SHORT:
543
		  {
544
                  long tmp = (long)(*(short *)nRegReturn);
545
                  __asm__ volatile ( "l 2,%0\n\t" : :
546
			   "m"(tmp) : "2" );
547
                  break;
548
		  }
549
		case typelib_TypeClass_FLOAT:
550
                  __asm__ volatile ( "le 0,%0\n\t" : :
551
                           "m" (*((float*)nRegReturn)) : "16" );
552
		  break;
553
554
		case typelib_TypeClass_DOUBLE:
555
		  __asm__ volatile ( "ld 0,%0\n\t" : :
556
                           "m" (*((double*)nRegReturn)) : "16" );
557
		  break;
558
559
		case typelib_TypeClass_HYPER:
560
		case typelib_TypeClass_UNSIGNED_HYPER:
561
		  __asm__ volatile ( "lm 2,3,%0\n\t" : :
562
                           "m"(nRegReturn[0]) : "2", "3" );
563
		  break;
564
565
		default:
566
		  __asm__ volatile ( "l 2,%0\n\t" : :
567
                           "m"(nRegReturn[0]) : "2" );
568
		  break;
569
	}
570
}
571
572
573
//==================================================================================================
574
class MediateClassData
575
{
576
    typedef ::std::hash_map< OUString, void *, OUStringHash > t_classdata_map;
577
	t_classdata_map m_map;
578
	Mutex m_mutex;
579
    
580
public:
581
	void const * get_vtable( typelib_InterfaceTypeDescription * pTD ) SAL_THROW( () );
582
    
583
	inline MediateClassData() SAL_THROW( () )
584
        {}
585
	~MediateClassData() SAL_THROW( () );
586
};
587
//__________________________________________________________________________________________________
588
MediateClassData::~MediateClassData() SAL_THROW( () )
589
{
590
	OSL_TRACE( "> calling ~MediateClassData(): freeing mediate vtables." );
591
	
592
	for ( t_classdata_map::const_iterator iPos( m_map.begin() ); iPos != m_map.end(); ++iPos )
593
	{
594
		::rtl_freeMemory( iPos->second );
595
	}
596
}
597
//--------------------------------------------------------------------------------------------------
598
static inline void codeSnippet( long * code, sal_uInt32 vtable_pos, bool simple_ret_type ) SAL_THROW( () )
599
{
600
    if (! simple_ret_type)
601
        vtable_pos |= 0x80000000;
602
    OSL_ASSERT( sizeof (long) == 4 );
603
604
     /* generate this code */
605
     // lr      %r0,%r13
606
     // bras    %r13,0x6
607
     // .long   cpp_vtable_call 
608
     // .long   vtable_pos
609
     // stm     %r2,%r6,8(%r15)
610
     // std     %f0,64(%r15)
611
     // std     %f2,72(%r15)
612
613
     // l       %r2,4(%r13)
614
     // la      %r3,8(%r15)
615
     // la      %r4,64(%r15)
616
     // la      %r5,96(%r15)   
617
     // l       %r1,0(%r13)
618
     // lr      %r13,%r0
619
     // br      %r1
620
621
622
      * ((short*)code)++ = 0x180d;
623
      * code++ = 0xa7d50006;
624
      * code++ = cpp_vtable_call;
625
      * code++ = vtable_pos;
626
      * code++ = 0x9026f008;
627
      * code++ = 0x6000f040;
628
      * code++ = 0x6020f048;
629
      * code++ = 0x5820d004;
630
      * code++ = 0x4130f008;
631
      * code++ = 0x4140f040;
632
      * code++ = 0x4150f060;
633
      * code++ = 0x5810d000;
634
      * ((short*)code)++ = 0x18d0;
635
      * ((short*)code)++ = 0x07f1;
636
637
}
638
//__________________________________________________________________________________________________
639
void const * MediateClassData::get_vtable( typelib_InterfaceTypeDescription * pTD ) SAL_THROW( () )
640
{
641
    void * buffer;
642
    const int nSnippetSize = 50;
643
644
    // avoiding locked counts
645
    OUString const & unoName = *(OUString const *)&((typelib_TypeDescription *)pTD)->pTypeName;
646
    {
647
	MutexGuard aGuard( m_mutex );
648
	t_classdata_map::const_iterator iFind( m_map.find( unoName ) );
649
	if (iFind == m_map.end())
650
    {
651
        // create new vtable
652
        sal_Int32 nSlots = pTD->nMapFunctionIndexToMemberIndex;
653
        buffer = ::rtl_allocateMemory( ((2+ nSlots) * sizeof (void *)) + (nSlots *nSnippetSize) );
654
        
655
        ::std::pair< t_classdata_map::iterator, bool > insertion(
656
            m_map.insert( t_classdata_map::value_type( unoName, buffer ) ) );
657
        OSL_ENSURE( insertion.second, "### inserting new vtable buffer failed?!" );
658
        
659
        void ** slots = (void **)buffer;
660
        *slots++ = 0;
661
        *slots++ = 0; // rtti
662
        char * code = (char *)(slots + nSlots);
663
        
664
        sal_uInt32 vtable_pos = 0;
665
        sal_Int32 nAllMembers = pTD->nAllMembers;
666
        typelib_TypeDescriptionReference ** ppAllMembers = pTD->ppAllMembers;
667
        for ( sal_Int32 nPos = 0; nPos < nAllMembers; ++nPos )
668
        {
669
            typelib_TypeDescription * pTD = 0;
670
            TYPELIB_DANGER_GET( &pTD, ppAllMembers[ nPos ] );
671
            OSL_ASSERT( pTD );
672
            if (typelib_TypeClass_INTERFACE_ATTRIBUTE == pTD->eTypeClass)
673
            {
674
                bool simple_ret = cppu_isSimpleType(
675
                    ((typelib_InterfaceAttributeTypeDescription *)pTD)->pAttributeTypeRef->eTypeClass );
676
                // get method
677
                *slots = code;
678
                codeSnippet( (long *)code, vtable_pos++, simple_ret );
679
                code += nSnippetSize;
680
                slots++;
681
                if (! ((typelib_InterfaceAttributeTypeDescription *)pTD)->bReadOnly)
682
                {
683
                    // set method
684
                    *slots = code;
685
                    codeSnippet( (long *)code, vtable_pos++, true );
686
                    code += nSnippetSize;
687
                    slots++;
688
                }
689
            }
690
            else
691
            {
692
                bool simple_ret = cppu_isSimpleType(
693
                    ((typelib_InterfaceMethodTypeDescription *)pTD)->pReturnTypeRef->eTypeClass );
694
                *slots = code;
695
                codeSnippet( (long *)code, vtable_pos++, simple_ret );
696
                code += nSnippetSize;
697
                slots++;
698
            }
699
            TYPELIB_DANGER_RELEASE( pTD );
700
        }
701
        OSL_ASSERT( vtable_pos == nSlots );
702
    }
703
    else
704
    {
705
        buffer = iFind->second;
706
    }
707
    }
708
    
709
    return ((void **)buffer +2);
710
}
711
712
//==================================================================================================
713
void SAL_CALL cppu_cppInterfaceProxy_patchVtable(
714
	XInterface * pCppI, typelib_InterfaceTypeDescription * pTypeDescr ) throw ()
715
{
716
	static MediateClassData * s_pMediateClassData = 0;
717
	if (! s_pMediateClassData)
718
	{
719
		MutexGuard aGuard( Mutex::getGlobalMutex() );
720
		if (! s_pMediateClassData)
721
		{
722
#ifdef LEAK_STATIC_DATA
723
			s_pMediateClassData = new MediateClassData();
724
#else
725
			static MediateClassData s_aMediateClassData;
726
			s_pMediateClassData = &s_aMediateClassData;
727
#endif
728
		}
729
	}
730
	*(void const **)pCppI = s_pMediateClassData->get_vtable( pTypeDescr );
731
}
732
733
}
734
735
extern "C"
736
{
737
//##################################################################################################
738
sal_Bool SAL_CALL component_canUnload( TimeValue * pTime )
739
	SAL_THROW_EXTERN_C()
740
{
741
	return CPPU_CURRENT_NAMESPACE::g_moduleCount.canUnload(
742
        &CPPU_CURRENT_NAMESPACE::g_moduleCount, pTime );
743
}
744
//##################################################################################################
745
void SAL_CALL uno_initEnvironment( uno_Environment * pCppEnv )
746
	SAL_THROW_EXTERN_C()
747
{
748
	CPPU_CURRENT_NAMESPACE::cppu_cppenv_initEnvironment(
749
        pCppEnv );
750
}
751
//##################################################################################################
752
void SAL_CALL uno_ext_getMapping(
753
	uno_Mapping ** ppMapping, uno_Environment * pFrom, uno_Environment * pTo )
754
	SAL_THROW_EXTERN_C()
755
{
756
	CPPU_CURRENT_NAMESPACE::cppu_ext_getMapping(
757
        ppMapping, pFrom, pTo );
758
}
759
}
(-)oo_1.0.1_src/bridges/source/cpp_uno/gcc3_linux_s390.old/except.cxx (+317 lines)
Line 0 Link Here
1
/*************************************************************************
2
 *
3
 *  $RCSfile: except.cxx,v $
4
 *
5
 *  $Revision: 1.6 $
6
 *
7
 *  last change: $Author: dbo $ $Date: 2001/11/08 12:35:28 $
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
#include <stdio.h>
63
#include <dlfcn.h>
64
#include <cxxabi.h>
65
#include <hash_map>
66
67
#include <rtl/strbuf.hxx>
68
#include <rtl/ustrbuf.hxx>
69
#include <osl/diagnose.h>
70
#include <osl/mutex.hxx>
71
72
#include <bridges/cpp_uno/bridge.hxx>
73
#include <typelib/typedescription.hxx>
74
#include <uno/any2.h>
75
76
#include "share.hxx"
77
78
79
using namespace ::std;
80
using namespace ::osl;
81
using namespace ::rtl;
82
using namespace ::com::sun::star::uno;
83
using namespace ::__cxxabiv1;
84
85
86
namespace CPPU_CURRENT_NAMESPACE
87
{
88
    
89
void dummy_can_throw_anything( char const * )
90
{
91
}
92
93
//==================================================================================================
94
static OUString toUNOname( char const * p ) SAL_THROW( () )
95
{
96
#ifdef DEBUG
97
    char const * start = p;
98
#endif
99
    
100
    // example: N3com3sun4star4lang24IllegalArgumentExceptionE
101
    
102
	OUStringBuffer buf( 64 );
103
    OSL_ASSERT( 'N' == *p );
104
    ++p; // skip N
105
    
106
    while ('E' != *p)
107
    {
108
        // read chars count
109
        long n = (*p++ - '0');
110
        while ('0' <= *p && '9' >= *p)
111
        {
112
            n *= 10;
113
            n += (*p++ - '0');
114
        }
115
        buf.appendAscii( p, n );
116
        p += n;
117
        if ('E' != *p)
118
            buf.append( (sal_Unicode)'.' );
119
    }
120
    
121
#ifdef DEBUG
122
    OUString ret( buf.makeStringAndClear() );
123
    OString c_ret( OUStringToOString( ret, RTL_TEXTENCODING_ASCII_US ) );
124
    fprintf( stderr, "> toUNOname(): %s => %s\n", start, c_ret.getStr() );
125
    return ret;
126
#else
127
    return buf.makeStringAndClear();
128
#endif
129
}
130
131
//==================================================================================================
132
class RTTI
133
{
134
    typedef hash_map< OUString, type_info *, OUStringHash > t_rtti_map;
135
    
136
    Mutex m_mutex;
137
	t_rtti_map m_rttis;
138
    t_rtti_map m_generatedRttis;
139
140
    void * m_hApp;
141
    
142
public:
143
    RTTI() SAL_THROW( () );
144
    ~RTTI() SAL_THROW( () );
145
    
146
    type_info * getRTTI( typelib_CompoundTypeDescription * ) SAL_THROW( () );
147
};
148
//__________________________________________________________________________________________________
149
RTTI::RTTI() SAL_THROW( () )
150
    : m_hApp( dlopen( 0, RTLD_LAZY ) )
151
{
152
}
153
//__________________________________________________________________________________________________
154
RTTI::~RTTI() SAL_THROW( () )
155
{
156
    dlclose( m_hApp );
157
}
158
159
//__________________________________________________________________________________________________
160
type_info * RTTI::getRTTI( typelib_CompoundTypeDescription *pTypeDescr ) SAL_THROW( () )
161
{
162
    type_info * rtti;
163
    
164
    OUString const & unoName = *(OUString const *)&pTypeDescr->aBase.pTypeName;
165
    
166
    MutexGuard guard( m_mutex );
167
    t_rtti_map::const_iterator iFind( m_rttis.find( unoName ) );
168
    if (iFind == m_rttis.end())
169
    {
170
        // RTTI symbol
171
        OStringBuffer buf( 64 );
172
        buf.append( RTL_CONSTASCII_STRINGPARAM("_ZTIN") );
173
        sal_Int32 index = 0;
174
        do
175
        {
176
            OUString token( unoName.getToken( 0, '.', index ) );
177
            buf.append( token.getLength() );
178
            OString c_token( OUStringToOString( token, RTL_TEXTENCODING_ASCII_US ) );
179
            buf.append( c_token );
180
        }
181
        while (index >= 0);
182
        buf.append( 'E' );
183
        
184
        OString symName( buf.makeStringAndClear() );
185
        rtti = (type_info *)dlsym( m_hApp, symName.getStr() );
186
187
        if (rtti)
188
        {
189
            pair< t_rtti_map::iterator, bool > insertion(
190
                m_rttis.insert( t_rtti_map::value_type( unoName, rtti ) ) );
191
            OSL_ENSURE( insertion.second, "### inserting new rtti failed?!" );
192
        }
193
        else
194
        {
195
            // try to lookup the symbol in the generated rtti map
196
            t_rtti_map::const_iterator iFind( m_generatedRttis.find( unoName ) );
197
            if (iFind == m_generatedRttis.end())
198
            {
199
                // we must generate it !
200
                // symbol and rtti-name is nearly identical,
201
                // the symbol is prefixed with _ZTI
202
                char const * rttiName = symName.getStr() +4;
203
#ifdef DEBUG
204
                fprintf( stderr,"generated rtti for %s\n", rttiName );
205
#endif
206
                if (pTypeDescr->pBaseTypeDescription)
207
                {
208
                    // ensure availability of base
209
                    type_info * base_rtti = getRTTI(
210
                        (typelib_CompoundTypeDescription *)pTypeDescr->pBaseTypeDescription );
211
                    rtti = new __si_class_type_info(
212
                        strdup( rttiName ), (__class_type_info *)base_rtti );
213
                }
214
                else
215
                {
216
                    // this class has no base class
217
                    rtti = new __class_type_info( strdup( rttiName ) );
218
                }
219
                
220
                pair< t_rtti_map::iterator, bool > insertion(
221
                    m_generatedRttis.insert( t_rtti_map::value_type( unoName, rtti ) ) );
222
                OSL_ENSURE( insertion.second, "### inserting new generated rtti failed?!" );
223
            }
224
            else // taking already generated rtti
225
            {
226
                rtti = iFind->second;
227
            }
228
        }
229
    }
230
    else
231
    {
232
        rtti = iFind->second;
233
    }
234
    
235
    return rtti;
236
}
237
238
//--------------------------------------------------------------------------------------------------
239
static void deleteException( void * pExc )
240
{
241
    __cxa_exception const * header = ((__cxa_exception const *)pExc - 1);
242
    typelib_TypeDescription * pTD = 0;
243
    OUString unoName( toUNOname( header->exceptionType->name() ) );
244
    ::typelib_typedescription_getByName( &pTD, unoName.pData );
245
    OSL_ENSURE( pTD, "### unknown exception type! leaving out destruction => leaking!!!" );
246
    if (pTD)
247
    {
248
		::uno_destructData( pExc, pTD, cpp_release );
249
		::typelib_typedescription_release( pTD );
250
	}
251
}
252
253
//==================================================================================================
254
void raiseException( uno_Any * pUnoExc, uno_Mapping * pUno2Cpp )
255
{
256
    void * pCppExc;
257
    type_info * rtti;
258
259
    {
260
    // construct cpp exception object
261
	typelib_TypeDescription * pTypeDescr = 0;
262
	TYPELIB_DANGER_GET( &pTypeDescr, pUnoExc->pType );
263
    OSL_ASSERT( pTypeDescr );
264
    if (! pTypeDescr)
265
        terminate();
266
    
267
	pCppExc = __cxa_allocate_exception( pTypeDescr->nSize );
268
	::uno_copyAndConvertData( pCppExc, pUnoExc->pData, pTypeDescr, pUno2Cpp );
269
	
270
	// destruct uno exception
271
	::uno_any_destruct( pUnoExc, 0 );
272
    // avoiding locked counts
273
    static RTTI * s_rtti = 0;
274
    if (! s_rtti)
275
    {
276
        MutexGuard guard( Mutex::getGlobalMutex() );
277
        if (! s_rtti)
278
        {
279
#ifdef LEAK_STATIC_DATA
280
            s_rtti = new RTTI();
281
#else
282
            static RTTI rtti_data;
283
            s_rtti = &rtti_data;
284
#endif
285
        }
286
    }
287
	rtti = (type_info *)s_rtti->getRTTI( (typelib_CompoundTypeDescription *) pTypeDescr );
288
    TYPELIB_DANGER_RELEASE( pTypeDescr );
289
    OSL_ENSURE( rtti, "### no rtti for throwing exception!" );
290
    if (! rtti)
291
        terminate();
292
    }
293
    
294
	__cxa_throw( pCppExc, rtti, deleteException );
295
}
296
297
//==================================================================================================
298
void fillUnoException( __cxa_exception * header, uno_Any * pExc, uno_Mapping * pCpp2Uno )
299
{
300
    OSL_ENSURE( header, "### no exception header!!!" );
301
    if (! header)
302
        terminate();
303
    
304
	typelib_TypeDescription * pExcTypeDescr = 0;
305
    OUString unoName( toUNOname( header->exceptionType->name() ) );
306
	::typelib_typedescription_getByName( &pExcTypeDescr, unoName.pData );
307
    OSL_ENSURE( pExcTypeDescr, "### can not get type description for exception!!!" );
308
    if (! pExcTypeDescr)
309
        terminate();
310
    
311
    // construct uno exception any
312
    ::uno_any_constructAndConvert( pExc, header->adjustedPtr, pExcTypeDescr, pCpp2Uno );
313
    ::typelib_typedescription_release( pExcTypeDescr );
314
}
315
316
}
317
(-)oo_1.0.1_src/bridges/source/cpp_uno/gcc3_linux_s390.old/makefile.mk (+112 lines)
Line 0 Link Here
1
#*************************************************************************
2
#
3
#   $RCSfile: makefile.mk,v $
4
#
5
#   $Revision: 1.2 $
6
#
7
#   last change: $Author: dbo $ $Date: 2001/10/26 14:23:30 $
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
63
PRJ=..$/..$/..
64
65
PRJNAME=bridges
66
TARGET=gcc3_uno
67
LIBTARGET=no
68
ENABLE_EXCEPTIONS=TRUE
69
NO_BSYMBOLIC=TRUE
70
71
# --- Settings -----------------------------------------------------
72
73
.INCLUDE :  svpre.mk
74
.INCLUDE :  settings.mk
75
.INCLUDE :  sv.mk
76
77
# --- Files --------------------------------------------------------
78
79
.IF "$(COM)$(OS)$(CPU)$(COMNAME)" == "GCCLINUX3gcc3"
80
81
.IF "$(cppu_no_leak)" == ""
82
CFLAGS += -DLEAK_STATIC_DATA
83
.ENDIF
84
85
CFLAGSNOOPT=-O0
86
87
SLOFILES= \
88
	$(SLO)$/except.obj		\
89
	$(SLO)$/cpp2uno.obj		\
90
	$(SLO)$/uno2cpp.obj
91
92
SHL1TARGET= $(TARGET)
93
94
SHL1DEF=$(MISC)$/$(SHL1TARGET).def
95
SHL1IMPLIB=i$(TARGET)
96
SHL1VERSIONMAP=..$/..$/bridge_exports.map
97
98
SHL1OBJS= \
99
	$(SLO)$/except.obj		\
100
	$(SLO)$/cpp2uno.obj		\
101
	$(SLO)$/uno2cpp.obj
102
103
SHL1STDLIBS= \
104
	$(CPPULIB)			\
105
	$(SALLIB)
106
107
.ENDIF
108
109
# --- Targets ------------------------------------------------------
110
111
.INCLUDE :  target.mk
112
(-)oo_1.0.1_src/bridges/source/cpp_uno/gcc3_linux_s390.old/share.hxx (+120 lines)
Line 0 Link Here
1
/*************************************************************************
2
 *
3
 *  $RCSfile: share.hxx,v $
4
 *
5
 *  $Revision: 1.1 $
6
 *
7
 *  last change: $Author: dbo $ $Date: 2001/10/19 13:32:39 $
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
#include <typeinfo>
63
#include <exception>
64
#include <cstddef>
65
66
namespace CPPU_CURRENT_NAMESPACE
67
{
68
69
// ----- following decl from libstdc++-v3/libsupc++/unwind-cxx.h and unwind.h
70
71
struct _Unwind_Exception
72
{
73
    unsigned exception_class __attribute__((__mode__(__DI__)));
74
    void * exception_cleanup;
75
    unsigned private_1 __attribute__((__mode__(__word__)));
76
    unsigned private_2 __attribute__((__mode__(__word__)));
77
} __attribute__((__aligned__));
78
79
struct __cxa_exception
80
{ 
81
    ::std::type_info *exceptionType;
82
    void (*exceptionDestructor)(void *); 
83
    
84
    ::std::unexpected_handler unexpectedHandler;
85
    ::std::terminate_handler terminateHandler;
86
    
87
    __cxa_exception *nextException;
88
    
89
    int handlerCount;
90
    
91
    int handlerSwitchValue;
92
    const unsigned char *actionRecord;
93
    const unsigned char *languageSpecificData;
94
    void *catchTemp;
95
    void *adjustedPtr;
96
    
97
    _Unwind_Exception unwindHeader;
98
};    
99
100
extern "C" void *__cxa_allocate_exception(
101
    std::size_t thrown_size ) throw();
102
extern "C" void __cxa_throw (
103
    void *thrown_exception, std::type_info *tinfo, void (*dest) (void *) ) __attribute__((noreturn));
104
105
struct __cxa_eh_globals
106
{
107
    __cxa_exception *caughtExceptions;
108
    unsigned int uncaughtExceptions;
109
};
110
extern "C" __cxa_eh_globals *__cxa_get_globals () throw();
111
112
// -----
113
114
//==================================================================================================
115
void raiseException(
116
    uno_Any * pUnoExc, uno_Mapping * pUno2Cpp );
117
//==================================================================================================
118
void fillUnoException(
119
    __cxa_exception * header, uno_Any *, uno_Mapping * pCpp2Uno );
120
}
(-)oo_1.0.1_src/bridges/source/cpp_uno/gcc3_linux_s390.old/uno2cpp.cxx (+653 lines)
Line 0 Link Here
1
/*************************************************************************
2
 *
3
 *  $RCSfile: uno2cpp.cxx,v $
4
 *
5
 *  $Revision: 1.1.2.3 $
6
 *
7
 *  last change: $Author: khendricks $ $Date: 2002/05/19 11:25:52 $
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
#include <malloc.h>
63
#include <rtl/alloc.h>
64
65
#include <uno/data.h>
66
#include <bridges/cpp_uno/bridge.hxx>
67
#include <bridges/cpp_uno/type_misc.hxx>
68
69
#include "share.hxx"
70
71
72
using namespace ::rtl;
73
using namespace ::com::sun::star::uno;
74
75
namespace CPPU_CURRENT_NAMESPACE
76
{
77
78
void dummy_can_throw_anything( char const * );
79
80
static sal_Int32
81
invoke_count_words(char * pPT)
82
{
83
     sal_Int32 overflow = 0, gpr = 0, fpr = 0;
84
     int c;                        // character of parameter type being decoded
85
86
     while (*pPT != 'X') {
87
       c = *pPT;
88
       switch (c) {
89
       case 'D':                   /* type is double */
90
            if (fpr < 2) fpr++; else overflow+=2;
91
            break;
92
93
       case 'F':                   /* type is float */
94
            if (fpr < 2) fpr++; else overflow++;
95
            break;
96
97
       case 'H':                /* type is long long */
98
            if (gpr < 4) gpr+=2; else gpr=5, overflow+=2;
99
            break;
100
101
       case 'S':
102
       case 'T':
103
       case 'B':
104
       case 'C':
105
            if (gpr < 5) gpr++; else overflow++;
106
            break;
107
108
       default:
109
            if (gpr < 5) gpr++; else overflow++;
110
            break;
111
       }
112
       pPT++;
113
     }
114
     /* Round up number of overflow words to ensure stack
115
       stays aligned to 8 bytes.  */
116
     return (overflow + 1) & ~1;
117
}
118
119
static void
120
//invoke_copy_to_stack(sal_Int32 paramCount, sal_Int32 * pStackLongs, char * pPT, sal_Int32* d_ov, sal_Int32 overflow)
121
invoke_copy_to_stack(sal_Int32 * pStackLongs, char * pPT, sal_Int32* d_ov, sal_Int32 overflow)
122
{
123
    sal_Int32 *d_gpr = d_ov + overflow; 
124
    sal_Int64 *d_fpr = (sal_Int64 *)(d_gpr + 5);
125
    sal_Int32 gpr = 0, fpr = 0;
126
    char c;
127
128
     while (*pPT != 'X') {
129
       c = *pPT;
130
       switch (c) {
131
       case 'D':                   /* type is double */
132
            if (fpr < 2)
133
                *((double*)  d_fpr) = *((double *)pStackLongs), d_fpr++, fpr++;
134
            else
135
                *((double*)  d_ov ) = *((double *)pStackLongs), d_ov+=2;
136
137
            pStackLongs += 2;
138
            break;
139
140
       case 'F':                   /* type is float */
141
            if (fpr < 2) {
142
                *((sal_Int64*) d_fpr) = 0;
143
                *((float*)   d_fpr) = *((float *)pStackLongs), d_fpr++, fpr++;
144
              }
145
            else {
146
                *((sal_Int64*) d_ov) = 0;
147
                *((float*)   d_ov ) = *((float *)pStackLongs), d_ov++;
148
              }
149
150
            pStackLongs += 1;
151
            break;
152
153
       case 'H':                /* type is long long */
154
            if (gpr < 4) {
155
                *((sal_Int64*) d_gpr) = *((sal_Int64*) pStackLongs), d_gpr+=2, gpr+=2;
156
              }
157
            else {
158
                *((sal_Int64*) d_ov ) = *((sal_Int64*) pStackLongs), d_ov+=2, gpr=5;
159
              }
160
            pStackLongs += 2;
161
            break;
162
163
       case 'S':
164
            if (gpr < 5)
165
                *((sal_uInt32*)d_gpr) = *((unsigned short*)pStackLongs), d_gpr++, gpr++;
166
            else
167
                *((sal_uInt32*)d_ov ) = *((unsigned short*)pStackLongs), d_ov++;
168
            pStackLongs += 1;
169
            break;
170
171
       case 'T':
172
            if (gpr < 5)
173
                *((sal_Int32*)d_gpr) = *((signed short*)pStackLongs), d_gpr++, gpr++;
174
            else
175
                *((sal_Int32*)d_ov ) = *((signed short*)pStackLongs), d_ov++;
176
            pStackLongs += 1;
177
            break;
178
179
       case 'B':
180
            if (gpr < 5)
181
                *((sal_uInt32*)d_gpr) = *((unsigned char*)pStackLongs), d_gpr++, gpr++;
182
            else
183
                *((sal_uInt32*)d_ov ) = *((unsigned char*)pStackLongs), d_ov++;
184
            pStackLongs += 1;
185
            break;
186
187
       case 'C':
188
            if (gpr < 5)
189
                *((sal_Int32*)d_gpr) = *((signed char*)pStackLongs), d_gpr++, gpr++;
190
            else
191
                *((sal_Int32*)d_ov ) = *((signed char*)pStackLongs), d_ov++;
192
            pStackLongs += 1;
193
            break;
194
195
       default:
196
            if (gpr < 5)
197
                *((sal_Int32*)d_gpr) = *pStackLongs, d_gpr++, gpr++;
198
            else
199
                *((sal_Int32*)d_ov ) = *pStackLongs, d_ov++;
200
            pStackLongs += 1;
201
            break;
202
       }
203
       pPT++;
204
     }
205
}
206
207
//==================================================================================================
208
static void callVirtualMethod(
209
    void * pThis,
210
    sal_Int32 nVtableIndex,
211
    void * pRegisterReturn,
212
    typelib_TypeClass eReturnType,
213
    char * pPT,
214
    sal_Int32 * pStackLongs,
215
    sal_Int32 nStackLongs)
216
{
217
218
  // parameter list is mixed list of * and values
219
  // reference parameters are pointers
220
221
  // the basic idea here is to use gpr[5] as a storage area for
222
  // the future values of registers r2 to r6 needed for the call, 
223
  // and similarly fpr[2] as a storage area for the future values
224
  // of floating point registers f0 to f2
225
226
     sal_Int32 *vtable = *(sal_Int32 **)pThis;
227
//    sal_Int32 method = vtable[nVtableIndex + 2];
228
     sal_Int32 method = vtable[nVtableIndex];
229
     sal_Int32 overflow = invoke_count_words (pPT);
230
     sal_Int32 result;
231
     volatile double dret;                  // temporary function return values
232
     volatile float fret;
233
     volatile int iret, iret2;
234
235
     char * dummy = alloca(32); // dummy alloca to force r11 usage for exception handling
236
237
    __asm__ __volatile__
238
     (
239
        "lr    7,15\n\t"
240
        "ahi   7,-48\n\t"
241
242
        "lr    3,%2\n\t"
243
        "sll   3,2\n\t"
244
        "lcr   3,3\n\t"
245
        "l     2,0(15)\n\t"
246
        "la    15,0(3,7)\n\t"
247
        "st    2,0(15)\n\t"
248
249
        "lr    2,%0\n\t"
250
        "lr    3,%1\n\t"
251
        "la    4,96(15)\n\t"
252
        "lr    5,%2\n\t"
253
        "basr  14,%3\n\t"
254
255
        "ld    0,116(7)\n\t"
256
        "ld    2,124(7)\n\t"
257
        "lm    2,6,96(7)\n\t"
258
        : 
259
        : "r" (pStackLongs),
260
          "r" (pPT), 
261
          "r" (overflow),
262
          "a" (invoke_copy_to_stack),
263
          "a" (method),
264
          "X" (dummy)
265
        : "2", "3", "4", "5", "6", "7", "memory"
266
    );
267
//	"basr  14,%8\n\t"
268
269
    (*(void (*)())method)();
270
271
    __asm__ __volatile__
272
     (
273
        "la    15,48(7)\n\t" 
274
 
275
        "lr    %2,2\n\t"
276
        "lr    %3,3\n\t"
277
        "ler   %0,0\n\t"
278
        "ldr   %1,0\n\t"
279
280
        : "=f" (fret), "=f" (dret), "=r" (iret), "=r" (iret2)
281
    );
282
283
    switch( eReturnType )
284
	{
285
		case typelib_TypeClass_HYPER:
286
		case typelib_TypeClass_UNSIGNED_HYPER:
287
//		        ((long*)pRegisterReturn)[0] = iret;
288
			((long*)pRegisterReturn)[1] = iret2;
289
		case typelib_TypeClass_LONG:
290
		case typelib_TypeClass_UNSIGNED_LONG:
291
		case typelib_TypeClass_ENUM:
292
			((long*)pRegisterReturn)[0] = iret;
293
			break;
294
		case typelib_TypeClass_CHAR:
295
		case typelib_TypeClass_SHORT:
296
		case typelib_TypeClass_UNSIGNED_SHORT:
297
		        *(unsigned short*)pRegisterReturn = (unsigned short)iret;
298
			break;
299
		case typelib_TypeClass_BOOLEAN:
300
		case typelib_TypeClass_BYTE:
301
		        *(unsigned char*)pRegisterReturn = (unsigned char)iret;
302
			break;
303
		case typelib_TypeClass_FLOAT:
304
		        *(float*)pRegisterReturn = fret;
305
			break;
306
		case typelib_TypeClass_DOUBLE:
307
			*(double*)pRegisterReturn = dret;
308
			break;
309
	}
310
}
311
312
313
//================================================================================================== 
314
static void cpp_call(
315
	cppu_unoInterfaceProxy * pThis,
316
	sal_Int32 nVtableCall,
317
	typelib_TypeDescriptionReference * pReturnTypeRef,
318
	sal_Int32 nParams, typelib_MethodParameter * pParams,
319
	void * pUnoReturn, void * pUnoArgs[], uno_Any ** ppUnoExc )
320
{
321
  	// max space for: [complex ret ptr], values|ptr ...
322
  	char * pCppStack		=
323
  		(char *)alloca( sizeof(sal_Int32) + ((nParams+2) * sizeof(sal_Int64)) );
324
  	char * pCppStackStart	= pCppStack;
325
	
326
        // need to know parameter types for callVirtualMethod so generate a signature string
327
        char * pParamType = (char *) alloca(nParams+2);
328
        char * pPT = pParamType;
329
330
	// return
331
	typelib_TypeDescription * pReturnTypeDescr = 0;
332
	TYPELIB_DANGER_GET( &pReturnTypeDescr, pReturnTypeRef );
333
	OSL_ENSURE( pReturnTypeDescr, "### expected return type description!" );
334
	
335
	void * pCppReturn = 0; // if != 0 && != pUnoReturn, needs reconversion
336
	
337
	if (pReturnTypeDescr)
338
	{
339
		if (cppu_isSimpleType( pReturnTypeDescr ))
340
		{
341
			pCppReturn = pUnoReturn; // direct way for simple types
342
		}
343
		else
344
		{
345
			// complex return via ptr
346
			pCppReturn = *(void **)pCppStack = (cppu_relatesToInterface( pReturnTypeDescr )
347
												? alloca( pReturnTypeDescr->nSize )
348
												: pUnoReturn); // direct way
349
                        *pPT++ = 'I'; //signify that a complex return type on stack
350
			pCppStack += sizeof(void *);
351
		}
352
	}
353
	// push this
354
	*(void**)pCppStack = pThis->pCppI;
355
	pCppStack += sizeof( void* );
356
        *pPT++ = 'I';
357
358
	// stack space
359
	OSL_ENSURE( sizeof(void *) == sizeof(sal_Int32), "### unexpected size!" );
360
	// args
361
	void ** pCppArgs  = (void **)alloca( 3 * sizeof(void *) * nParams );
362
	// indizes of values this have to be converted (interface conversion cpp<=>uno)
363
	sal_Int32 * pTempIndizes = (sal_Int32 *)(pCppArgs + nParams);
364
	// type descriptions for reconversions
365
	typelib_TypeDescription ** ppTempParamTypeDescr = (typelib_TypeDescription **)(pCppArgs + (2 * nParams));
366
	
367
	sal_Int32 nTempIndizes   = 0;
368
	
369
	for ( sal_Int32 nPos = 0; nPos < nParams; ++nPos )
370
	{
371
		const typelib_MethodParameter & rParam = pParams[nPos];
372
		typelib_TypeDescription * pParamTypeDescr = 0;
373
		TYPELIB_DANGER_GET( &pParamTypeDescr, rParam.pTypeRef );
374
		
375
		if (!rParam.bOut && cppu_isSimpleType( pParamTypeDescr ))
376
		{
377
			uno_copyAndConvertData( pCppArgs[nPos] = pCppStack, pUnoArgs[nPos], pParamTypeDescr,
378
									&pThis->pBridge->aUno2Cpp );
379
380
			switch (pParamTypeDescr->eTypeClass)
381
			{
382
383
                          // we need to know type of each param so that we know whether to use
384
                          // gpr or fpr to pass in parameters:
385
                          // Key: I - int, long, pointer, etc means pass in gpr
386
                          //      B - byte value passed in gpr
387
                          //      S - short value passed in gpr
388
                          //      F - float value pass in fpr
389
                          //      D - double value pass in fpr
390
                          //      H - long long int pass in proper pairs of gpr (3,4) (5,6), etc
391
                          //      X - indicates end of parameter description string
392
393
		          case typelib_TypeClass_LONG:
394
		          case typelib_TypeClass_UNSIGNED_LONG:
395
		          case typelib_TypeClass_ENUM:
396
			    *pPT++ = 'I';
397
			    break;
398
 		          case typelib_TypeClass_SHORT:
399
                            *pPT++ = 'T';
400
                            break;
401
		          case typelib_TypeClass_CHAR:
402
		          case typelib_TypeClass_UNSIGNED_SHORT:
403
                            *pPT++ = 'S';
404
                            break;
405
		          case typelib_TypeClass_BOOLEAN:
406
                            *pPT++ = 'B';
407
                            break;
408
		          case typelib_TypeClass_BYTE:
409
                            *pPT++ = 'C';
410
                            break;
411
		          case typelib_TypeClass_FLOAT:
412
                            *pPT++ = 'F';
413
			    break;
414
		        case typelib_TypeClass_DOUBLE:
415
			    *pPT++ = 'D';
416
			    pCppStack += sizeof(sal_Int32); // extra long
417
			    break;
418
			case typelib_TypeClass_HYPER:
419
			case typelib_TypeClass_UNSIGNED_HYPER:
420
			    *pPT++ = 'H';
421
			    pCppStack += sizeof(sal_Int32); // extra long
422
			}
423
424
			// no longer needed
425
			TYPELIB_DANGER_RELEASE( pParamTypeDescr );
426
		}
427
		else // ptr to complex value | ref
428
		{
429
			if (! rParam.bIn) // is pure out
430
			{
431
				// cpp out is constructed mem, uno out is not!
432
				uno_constructData(
433
					*(void **)pCppStack = pCppArgs[nPos] = alloca( pParamTypeDescr->nSize ),
434
					pParamTypeDescr );
435
				pTempIndizes[nTempIndizes] = nPos; // default constructed for cpp call
436
				// will be released at reconversion
437
				ppTempParamTypeDescr[nTempIndizes++] = pParamTypeDescr;
438
			}
439
			// is in/inout
440
			else if (cppu_relatesToInterface( pParamTypeDescr ))
441
			{
442
				uno_copyAndConvertData(
443
					*(void **)pCppStack = pCppArgs[nPos] = alloca( pParamTypeDescr->nSize ),
444
					pUnoArgs[nPos], pParamTypeDescr, &pThis->pBridge->aUno2Cpp );
445
				
446
				pTempIndizes[nTempIndizes] = nPos; // has to be reconverted
447
				// will be released at reconversion
448
				ppTempParamTypeDescr[nTempIndizes++] = pParamTypeDescr;
449
			}
450
			else // direct way
451
			{
452
				*(void **)pCppStack = pCppArgs[nPos] = pUnoArgs[nPos];
453
				// no longer needed
454
				TYPELIB_DANGER_RELEASE( pParamTypeDescr );
455
			}
456
                        // KBH: FIXME: is this the right way to pass these
457
                        *pPT++='I';
458
		}
459
		pCppStack += sizeof(sal_Int32); // standard parameter length
460
	}
461
  
462
        // terminate the signature string
463
        *pPT++='X';
464
        *pPT=0;
465
466
	try
467
	{
468
		OSL_ENSURE( !( (pCppStack - pCppStackStart ) & 3), "UNALIGNED STACK !!! (Please DO panic)" );
469
		callVirtualMethod(
470
			pThis->pCppI, nVtableCall,
471
			pCppReturn, pReturnTypeDescr->eTypeClass, pParamType,
472
			(sal_Int32 *)pCppStackStart, (pCppStack - pCppStackStart) / sizeof(sal_Int32) );
473
		// NO exception occured...
474
		*ppUnoExc = 0;
475
		
476
		// reconvert temporary params
477
		for ( ; nTempIndizes--; )
478
		{
479
			sal_Int32 nIndex = pTempIndizes[nTempIndizes];
480
			typelib_TypeDescription * pParamTypeDescr = ppTempParamTypeDescr[nTempIndizes];
481
			
482
			if (pParams[nIndex].bIn)
483
			{
484
				if (pParams[nIndex].bOut) // inout
485
				{
486
					uno_destructData( pUnoArgs[nIndex], pParamTypeDescr, 0 ); // destroy uno value
487
					uno_copyAndConvertData( pUnoArgs[nIndex], pCppArgs[nIndex], pParamTypeDescr,
488
											&pThis->pBridge->aCpp2Uno );
489
				}
490
			}
491
			else // pure out
492
			{
493
				uno_copyAndConvertData( pUnoArgs[nIndex], pCppArgs[nIndex], pParamTypeDescr,
494
										&pThis->pBridge->aCpp2Uno );
495
			}
496
			// destroy temp cpp param => cpp: every param was constructed
497
			uno_destructData( pCppArgs[nIndex], pParamTypeDescr, cpp_release );
498
			
499
			TYPELIB_DANGER_RELEASE( pParamTypeDescr );
500
		}
501
		// return value
502
		if (pCppReturn && pUnoReturn != pCppReturn)
503
		{
504
			uno_copyAndConvertData( pUnoReturn, pCppReturn, pReturnTypeDescr,
505
									&pThis->pBridge->aCpp2Uno );
506
			uno_destructData( pCppReturn, pReturnTypeDescr, cpp_release );
507
		}
508
	}
509
 	catch (...)
510
 	{
511
  		// fill uno exception
512
		fillUnoException( __cxa_get_globals()->caughtExceptions, *ppUnoExc, &pThis->pBridge->aCpp2Uno );
513
        
514
		// temporary params
515
		for ( ; nTempIndizes--; )
516
		{
517
			sal_Int32 nIndex = pTempIndizes[nTempIndizes];
518
			// destroy temp cpp param => cpp: every param was constructed
519
			uno_destructData( pCppArgs[nIndex], ppTempParamTypeDescr[nTempIndizes], cpp_release );
520
			TYPELIB_DANGER_RELEASE( ppTempParamTypeDescr[nTempIndizes] );
521
		}
522
		// return type
523
		if (pReturnTypeDescr)
524
			TYPELIB_DANGER_RELEASE( pReturnTypeDescr );
525
	}
526
}
527
528
529
//==================================================================================================
530
void SAL_CALL cppu_unoInterfaceProxy_dispatch(
531
	uno_Interface * pUnoI, const typelib_TypeDescription * pMemberDescr,
532
	void * pReturn, void * pArgs[], uno_Any ** ppException ) throw ()
533
{
534
	// is my surrogate
535
	cppu_unoInterfaceProxy * pThis = (cppu_unoInterfaceProxy *)pUnoI;
536
	typelib_InterfaceTypeDescription * pTypeDescr = pThis->pTypeDescr;
537
	
538
	switch (pMemberDescr->eTypeClass)
539
	{
540
	case typelib_TypeClass_INTERFACE_ATTRIBUTE:
541
	{
542
		// determine vtable call index
543
		sal_Int32 nMemberPos = ((typelib_InterfaceMemberTypeDescription *)pMemberDescr)->nPosition;
544
		OSL_ENSURE( nMemberPos < pTypeDescr->nAllMembers, "### member pos out of range!" );
545
		
546
		sal_Int32 nVtableCall = pTypeDescr->pMapMemberIndexToFunctionIndex[nMemberPos];
547
		OSL_ENSURE( nVtableCall < pTypeDescr->nMapFunctionIndexToMemberIndex, "### illegal vtable index!" );
548
		
549
		if (pReturn)
550
		{
551
			// dependent dispatch
552
			cpp_call(
553
				pThis, nVtableCall,
554
				((typelib_InterfaceAttributeTypeDescription *)pMemberDescr)->pAttributeTypeRef,
555
				0, 0, // no params
556
				pReturn, pArgs, ppException );
557
		}
558
		else
559
		{
560
			// is SET
561
			typelib_MethodParameter aParam;
562
			aParam.pTypeRef =
563
				((typelib_InterfaceAttributeTypeDescription *)pMemberDescr)->pAttributeTypeRef;
564
			aParam.bIn		= sal_True;
565
			aParam.bOut		= sal_False;
566
567
			typelib_TypeDescriptionReference * pReturnTypeRef = 0;
568
			OUString aVoidName( RTL_CONSTASCII_USTRINGPARAM("void") );
569
			typelib_typedescriptionreference_new(
570
				&pReturnTypeRef, typelib_TypeClass_VOID, aVoidName.pData );
571
			
572
			// dependent dispatch
573
			cpp_call(
574
				pThis, nVtableCall +1, // get, then set method
575
				pReturnTypeRef,
576
				1, &aParam,
577
				pReturn, pArgs, ppException );
578
			
579
			typelib_typedescriptionreference_release( pReturnTypeRef );
580
		}
581
		
582
		break;
583
	}
584
	case typelib_TypeClass_INTERFACE_METHOD:
585
	{
586
		// determine vtable call index
587
		sal_Int32 nMemberPos = ((typelib_InterfaceMemberTypeDescription *)pMemberDescr)->nPosition;
588
		OSL_ENSURE( nMemberPos < pTypeDescr->nAllMembers, "### member pos out of range!" );
589
		
590
		sal_Int32 nVtableCall = pTypeDescr->pMapMemberIndexToFunctionIndex[nMemberPos];
591
		OSL_ENSURE( nVtableCall < pTypeDescr->nMapFunctionIndexToMemberIndex, "### illegal vtable index!" );
592
		
593
		switch (nVtableCall)
594
		{
595
			// standard calls
596
		case 1: // acquire uno interface
597
			(*pUnoI->acquire)( pUnoI );
598
			*ppException = 0;
599
			break;
600
		case 2: // release uno interface
601
			(*pUnoI->release)( pUnoI );
602
			*ppException = 0;
603
			break;
604
		case 0: // queryInterface() opt
605
		{
606
			typelib_TypeDescription * pTD = 0;
607
			TYPELIB_DANGER_GET( &pTD, reinterpret_cast< Type * >( pArgs[0] )->getTypeLibType() );
608
			if (pTD)
609
			{
610
                uno_Interface * pInterface = 0;
611
                (*pThis->pBridge->pUnoEnv->getRegisteredInterface)(
612
                    pThis->pBridge->pUnoEnv,
613
                    (void **)&pInterface, pThis->oid.pData, (typelib_InterfaceTypeDescription *)pTD );
614
			
615
                if (pInterface)
616
                {
617
                    ::uno_any_construct(
618
                        reinterpret_cast< uno_Any * >( pReturn ),
619
                        &pInterface, pTD, 0 );
620
                    (*pInterface->release)( pInterface );
621
                    TYPELIB_DANGER_RELEASE( pTD );
622
                    *ppException = 0;
623
                    break;
624
                }
625
                TYPELIB_DANGER_RELEASE( pTD );
626
            }
627
		} // else perform queryInterface()
628
		default:
629
			// dependent dispatch
630
			cpp_call(
631
				pThis, nVtableCall,
632
				((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->pReturnTypeRef,
633
				((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->nParams,
634
				((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->pParams,
635
				pReturn, pArgs, ppException );
636
		}
637
		break;
638
	}
639
	default:
640
	{
641
		::com::sun::star::uno::RuntimeException aExc(
642
			OUString( RTL_CONSTASCII_USTRINGPARAM("illegal member type description!") ),
643
			::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >() );
644
		
645
		Type const & rExcType = ::getCppuType( &aExc );
646
		// binary identical null reference
647
		::uno_type_any_construct( *ppException, &aExc, rExcType.getTypeLibType(), 0 );
648
	}
649
	}
650
}
651
652
}
653

Return to issue 10152