View | Details | Raw Unified | Return to bug 200020 | Differences between
and this patch

Collapse All | Expand All

(-)configure.ac (+5 lines)
Lines 4189-4194 Link Here
4189
        CPUNAME=X86_64
4189
        CPUNAME=X86_64
4190
        RTL_ARCH=X86_64
4190
        RTL_ARCH=X86_64
4191
        PLATFORMID=freebsd_x86_64
4191
        PLATFORMID=freebsd_x86_64
4192
        ;;
4193
    powerpc64)
4194
        CPUNAME=POWERPC64
4195
        RTL_ARCH=PowerPC_64
4196
        PLATFORMID=freebsd_powerpc64
4192
        ;;
4197
        ;;
4193
    *)
4198
    *)
4194
        AC_MSG_ERROR([Unsupported host_cpu $host_cpu for host_os $host_os])
4199
        AC_MSG_ERROR([Unsupported host_cpu $host_cpu for host_os $host_os])
(-)bridges/Library_cpp_uno.mk (+6 lines)
Lines 118-123 Link Here
118
bridge_asm_objects := call
118
bridge_asm_objects := call
119
bridge_noopt_objects := except
119
bridge_noopt_objects := except
120
bridge_exception_objects := cpp2uno uno2cpp
120
bridge_exception_objects := cpp2uno uno2cpp
121
122
else ifeq ($(OS)-$(CPUNAME),FREEBSD-POWERPC64)
123
124
bridges_SELECTED_BRIDGE := gcc3_freebsd_powerpc64
125
bridge_noopt_objects := cpp2uno uno2cpp
126
bridge_exception_objects := except
121
127
122
else ifeq ($(CPUNAME),X86_64)
128
else ifeq ($(CPUNAME),X86_64)
123
129
(-)bridges/source/cpp_uno/gcc3_freebsd_powerpc64/cpp2uno.cxx (+743 lines)
Added Link Here
1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
/*
3
 * This file is part of the LibreOffice project.
4
 *
5
 * This Source Code Form is subject to the terms of the Mozilla Public
6
 * License, v. 2.0. If a copy of the MPL was not distributed with this
7
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8
 *
9
 * This file incorporates work covered by the following license notice:
10
 *
11
 *   Licensed to the Apache Software Foundation (ASF) under one or more
12
 *   contributor license agreements. See the NOTICE file distributed
13
 *   with this work for additional information regarding copyright
14
 *   ownership. The ASF licenses this file to you under the Apache
15
 *   License, Version 2.0 (the "License"); you may not use this file
16
 *   except in compliance with the License. You may obtain a copy of
17
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
18
 */
19
20
21
#include <com/sun/star/uno/genfunc.hxx>
22
#include <uno/data.h>
23
#include <typelib/typedescription.hxx>
24
#include <osl/endian.h>
25
#include "bridges/cpp_uno/shared/bridge.hxx"
26
#include "bridges/cpp_uno/shared/cppinterfaceproxy.hxx"
27
#include "bridges/cpp_uno/shared/types.hxx"
28
#include "bridges/cpp_uno/shared/vtablefactory.hxx"
29
30
#include "share.hxx"
31
#include <stdio.h>
32
#include <string.h>
33
34
#ifdef OSL_BIGENDIAN
35
#define IS_BIG_ENDIAN 1
36
#else
37
#define IS_BIG_ENDIAN 0
38
#endif
39
40
using namespace ::com::sun::star::uno;
41
42
namespace
43
{
44
45
46
static typelib_TypeClass cpp2uno_call(
47
    bridges::cpp_uno::shared::CppInterfaceProxy * pThis,
48
    const typelib_TypeDescription * pMemberTypeDescr,
49
    typelib_TypeDescriptionReference * pReturnTypeRef, // 0 indicates void return
50
    sal_Int32 nParams, typelib_MethodParameter * pParams,
51
        void ** gpreg, void ** fpreg, void ** ovrflw,
52
    sal_Int64 * pRegisterReturn /* space for register return */ )
53
{
54
#if OSL_DEBUG_LEVEL > 2
55
    fprintf(stderr, "as far as cpp2uno_call\n");
56
#endif
57
58
    int ng = 0; //number of gpr registers used
59
    int nf = 0; //number of fpr regsiters used
60
61
    // gpreg:  [ret *], this, [gpr params]
62
    // fpreg:  [fpr params]
63
    // ovrflw: [gpr or fpr params (properly aligned)]
64
65
    // return
66
    typelib_TypeDescription * pReturnTypeDescr = 0;
67
    if (pReturnTypeRef)
68
        TYPELIB_DANGER_GET( &pReturnTypeDescr, pReturnTypeRef );
69
70
    void * pUnoReturn = 0;
71
    void * pCppReturn = 0; // complex return ptr: if != 0 && != pUnoReturn, reconversion need
72
73
    if (pReturnTypeDescr)
74
    {
75
        if (!ppc64::return_in_hidden_param(pReturnTypeRef))
76
        {
77
            pUnoReturn = pRegisterReturn; // direct way for simple types
78
        }
79
        else // complex return via ptr (pCppReturn)
80
        {
81
            pCppReturn = *(void **)gpreg;
82
            gpreg++;
83
            ng++;
84
85
            pUnoReturn = (bridges::cpp_uno::shared::relatesToInterfaceType( pReturnTypeDescr )
86
                          ? alloca( pReturnTypeDescr->nSize )
87
                          : pCppReturn); // direct way
88
        }
89
    }
90
    // pop this
91
    gpreg++;
92
    ng++;
93
94
    // stack space
95
    OSL_ENSURE( sizeof(void *) == sizeof(sal_Int64), "### unexpected size!" );
96
    // parameters
97
    void ** pUnoArgs = (void **)alloca( 4 * sizeof(void *) * nParams );
98
    void ** pCppArgs = pUnoArgs + nParams;
99
    // indices of values this have to be converted (interface conversion cpp<=>uno)
100
    sal_Int32 * pTempIndices = (sal_Int32 *)(pUnoArgs + (2 * nParams));
101
    // type descriptions for reconversions
102
    typelib_TypeDescription ** ppTempParamTypeDescr = (typelib_TypeDescription **)(pUnoArgs + (3 * nParams));
103
104
    sal_Int32 nTempIndices = 0;
105
    bool bOverflowUsed = false;
106
    for ( sal_Int32 nPos = 0; nPos < nParams; ++nPos )
107
    {
108
        const typelib_MethodParameter & rParam = pParams[nPos];
109
        typelib_TypeDescription * pParamTypeDescr = 0;
110
        TYPELIB_DANGER_GET( &pParamTypeDescr, rParam.pTypeRef );
111
112
#if OSL_DEBUG_LEVEL > 2
113
        fprintf(stderr, "arg %d of %d\n", nPos, nParams);
114
#endif
115
116
        if (!rParam.bOut && bridges::cpp_uno::shared::isSimpleType( pParamTypeDescr ))
117
        {
118
#if OSL_DEBUG_LEVEL > 2
119
            fprintf(stderr, "simple\n");
120
#endif
121
122
            switch (pParamTypeDescr->eTypeClass)
123
            {
124
                case typelib_TypeClass_FLOAT:
125
                case typelib_TypeClass_DOUBLE:
126
                    if (nf < ppc64::MAX_SSE_REGS)
127
                    {
128
                        if (pParamTypeDescr->eTypeClass == typelib_TypeClass_FLOAT)
129
                        {
130
                            float tmp = (float) (*((double *)fpreg));
131
                            (*((float *) fpreg)) = tmp;
132
                        }
133
                        pCppArgs[nPos] = pUnoArgs[nPos] = fpreg++;
134
                        nf++;
135
                    }
136
                    else
137
                    {
138
                        pCppArgs[nPos] = pUnoArgs[nPos] = ovrflw;
139
                        bOverflowUsed = true;
140
                    }
141
                    if (bOverflowUsed) ovrflw++;
142
                    break;
143
                case typelib_TypeClass_BYTE:
144
                case typelib_TypeClass_BOOLEAN:
145
                    if (ng < ppc64::MAX_GPR_REGS)
146
                    {
147
                        pCppArgs[nPos] = pUnoArgs[nPos] = (((char *)gpreg) + 7*IS_BIG_ENDIAN);
148
                        ng++;
149
                        gpreg++;
150
                    }
151
                    else
152
                    {
153
                        pCppArgs[nPos] = pUnoArgs[nPos] = (((char *)ovrflw) + 7*IS_BIG_ENDIAN);
154
                        bOverflowUsed = true;
155
                    }
156
                    if (bOverflowUsed) ovrflw++;
157
                    break;
158
                case typelib_TypeClass_CHAR:
159
                case typelib_TypeClass_SHORT:
160
                case typelib_TypeClass_UNSIGNED_SHORT:
161
                    if (ng < ppc64::MAX_GPR_REGS)
162
                    {
163
                        pCppArgs[nPos] = pUnoArgs[nPos] = (((char *)gpreg) + 6*IS_BIG_ENDIAN);
164
                        ng++;
165
                        gpreg++;
166
                    }
167
                    else
168
                    {
169
                        pCppArgs[nPos] = pUnoArgs[nPos] = (((char *)ovrflw) + 6*IS_BIG_ENDIAN);
170
                        bOverflowUsed = true;
171
                    }
172
                    if (bOverflowUsed) ovrflw++;
173
                    break;
174
        case typelib_TypeClass_ENUM:
175
                case typelib_TypeClass_LONG:
176
                case typelib_TypeClass_UNSIGNED_LONG:
177
                    if (ng < ppc64::MAX_GPR_REGS)
178
                    {
179
                        pCppArgs[nPos] = pUnoArgs[nPos] = (((char *)gpreg) + 4*IS_BIG_ENDIAN);
180
                        ng++;
181
                        gpreg++;
182
                    }
183
                    else
184
                    {
185
                        pCppArgs[nPos] = pUnoArgs[nPos] = (((char *)ovrflw) + 4*IS_BIG_ENDIAN);
186
                        bOverflowUsed = true;
187
                    }
188
                    if (bOverflowUsed) ovrflw++;
189
                    break;
190
                default:
191
                    if (ng < ppc64::MAX_GPR_REGS)
192
                    {
193
                        pCppArgs[nPos] = pUnoArgs[nPos] = gpreg++;
194
                        ng++;
195
                    }
196
                    else
197
                    {
198
                        pCppArgs[nPos] = pUnoArgs[nPos] = ovrflw;
199
                        bOverflowUsed = true;
200
                    }
201
                    if (bOverflowUsed) ovrflw++;
202
                    break;
203
                }
204
205
                // no longer needed
206
                TYPELIB_DANGER_RELEASE( pParamTypeDescr );
207
        }
208
        else // ptr to complex value | ref
209
        {
210
#if OSL_DEBUG_LEVEL > 2
211
            fprintf(stderr, "complex, ng is %d\n", ng);
212
#endif
213
            void *pCppStack; //temporary stack pointer
214
215
            if (ng < ppc64::MAX_GPR_REGS)
216
            {
217
                pCppArgs[nPos] = pCppStack = *gpreg++;
218
                ng++;
219
            }
220
            else
221
            {
222
                pCppArgs[nPos] = pCppStack = *ovrflw;
223
                bOverflowUsed = true;
224
            }
225
            if (bOverflowUsed) ovrflw++;
226
227
            if (! rParam.bIn) // is pure out
228
            {
229
                // uno out is unconstructed mem!
230
                pUnoArgs[nPos] = alloca( pParamTypeDescr->nSize );
231
                pTempIndices[nTempIndices] = nPos;
232
                // will be released at reconversion
233
                ppTempParamTypeDescr[nTempIndices++] = pParamTypeDescr;
234
            }
235
            // is in/inout
236
            else if (bridges::cpp_uno::shared::relatesToInterfaceType( pParamTypeDescr ))
237
            {
238
                uno_copyAndConvertData( pUnoArgs[nPos] = alloca( pParamTypeDescr->nSize ),
239
                                        pCppStack, pParamTypeDescr,
240
                                        pThis->getBridge()->getCpp2Uno() );
241
                pTempIndices[nTempIndices] = nPos; // has to be reconverted
242
                // will be released at reconversion
243
                ppTempParamTypeDescr[nTempIndices++] = pParamTypeDescr;
244
            }
245
            else // direct way
246
            {
247
                pUnoArgs[nPos] = pCppStack;
248
                // no longer needed
249
                TYPELIB_DANGER_RELEASE( pParamTypeDescr );
250
            }
251
        }
252
    }
253
254
#if OSL_DEBUG_LEVEL > 2
255
    fprintf(stderr, "end of params\n");
256
#endif
257
258
    // ExceptionHolder
259
    uno_Any aUnoExc; // Any will be constructed by callee
260
    uno_Any * pUnoExc = &aUnoExc;
261
262
    // invoke uno dispatch call
263
    (*pThis->getUnoI()->pDispatcher)( pThis->getUnoI(), pMemberTypeDescr, pUnoReturn, pUnoArgs, &pUnoExc );
264
265
    // in case an exception occurred...
266
    if (pUnoExc)
267
    {
268
        // destruct temporary in/inout params
269
        for ( ; nTempIndices--; )
270
        {
271
            sal_Int32 nIndex = pTempIndices[nTempIndices];
272
273
            if (pParams[nIndex].bIn) // is in/inout => was constructed
274
                uno_destructData( pUnoArgs[nIndex], ppTempParamTypeDescr[nTempIndices], 0 );
275
            TYPELIB_DANGER_RELEASE( ppTempParamTypeDescr[nTempIndices] );
276
        }
277
        if (pReturnTypeDescr)
278
            TYPELIB_DANGER_RELEASE( pReturnTypeDescr );
279
280
        CPPU_CURRENT_NAMESPACE::raiseException( &aUnoExc, pThis->getBridge()->getUno2Cpp() );
281
                // has to destruct the any
282
        // is here for dummy
283
        return typelib_TypeClass_VOID;
284
    }
285
    else // else no exception occurred...
286
    {
287
        // temporary params
288
        for ( ; nTempIndices--; )
289
        {
290
            sal_Int32 nIndex = pTempIndices[nTempIndices];
291
            typelib_TypeDescription * pParamTypeDescr = ppTempParamTypeDescr[nTempIndices];
292
293
            if (pParams[nIndex].bOut) // inout/out
294
            {
295
                // convert and assign
296
                uno_destructData( pCppArgs[nIndex], pParamTypeDescr, cpp_release );
297
                uno_copyAndConvertData( pCppArgs[nIndex], pUnoArgs[nIndex], pParamTypeDescr,
298
                                        pThis->getBridge()->getUno2Cpp() );
299
            }
300
            // destroy temp uno param
301
            uno_destructData( pUnoArgs[nIndex], pParamTypeDescr, 0 );
302
303
            TYPELIB_DANGER_RELEASE( pParamTypeDescr );
304
        }
305
        // return
306
        if (pCppReturn) // has complex return
307
        {
308
            if (pUnoReturn != pCppReturn) // needs reconversion
309
            {
310
                uno_copyAndConvertData( pCppReturn, pUnoReturn, pReturnTypeDescr,
311
                                        pThis->getBridge()->getUno2Cpp() );
312
                // destroy temp uno return
313
                uno_destructData( pUnoReturn, pReturnTypeDescr, 0 );
314
            }
315
            // complex return ptr is set to return reg
316
            *(void **)pRegisterReturn = pCppReturn;
317
        }
318
        if (pReturnTypeDescr)
319
        {
320
            typelib_TypeClass eRet = (typelib_TypeClass)pReturnTypeDescr->eTypeClass;
321
            TYPELIB_DANGER_RELEASE( pReturnTypeDescr );
322
            return eRet;
323
        }
324
        else
325
            return typelib_TypeClass_VOID;
326
    }
327
}
328
329
#if _CALL_ELF == 2
330
#  define PARAMSAVE 32
331
#else
332
#  define PARAMSAVE 48
333
#endif
334
335
static typelib_TypeClass cpp_mediate(
336
    sal_uInt64 nOffsetAndIndex,
337
        void ** gpreg, void ** fpreg, long sp,
338
    sal_Int64 * pRegisterReturn /* space for register return */ )
339
{
340
    OSL_ENSURE( sizeof(sal_Int64)==sizeof(void *), "### unexpected!" );
341
342
    sal_Int32 nVtableOffset = (nOffsetAndIndex >> 32);
343
    sal_Int32 nFunctionIndex = (nOffsetAndIndex & 0xFFFFFFFF);
344
345
    long sf = *(long*)sp;
346
    void ** ovrflw = (void**)(sf + PARAMSAVE + 64);
347
348
    // gpreg:  [ret *], this, [other gpr params]
349
    // fpreg:  [fpr params]
350
    // ovrflw: [gpr or fpr params (properly aligned)]
351
352
    void * pThis;
353
    if (nFunctionIndex & 0x80000000 )
354
    {
355
    nFunctionIndex &= 0x7fffffff;
356
    pThis = gpreg[1];
357
#if OSL_DEBUG_LEVEL > 2
358
    fprintf(stderr, "pThis is gpreg[1]\n");
359
#endif
360
    }
361
    else
362
    {
363
    pThis = gpreg[0];
364
#if OSL_DEBUG_LEVEL > 2
365
    fprintf(stderr, "pThis is gpreg[0]\n");
366
#endif
367
    }
368
369
#if OSL_DEBUG_LEVEL > 2
370
    fprintf(stderr, "pThis is %lx\n", pThis);
371
#endif
372
373
    pThis = static_cast< char * >(pThis) - nVtableOffset;
374
375
#if OSL_DEBUG_LEVEL > 2
376
    fprintf(stderr, "pThis is now %lx\n", pThis);
377
#endif
378
379
    bridges::cpp_uno::shared::CppInterfaceProxy * pCppI
380
        = bridges::cpp_uno::shared::CppInterfaceProxy::castInterfaceToProxy(
381
            pThis);
382
383
    typelib_InterfaceTypeDescription * pTypeDescr = pCppI->getTypeDescr();
384
385
#if OSL_DEBUG_LEVEL > 2
386
    fprintf(stderr, "indexes are %d %d\n", nFunctionIndex, pTypeDescr->nMapFunctionIndexToMemberIndex);
387
#endif
388
389
    OSL_ENSURE( nFunctionIndex < pTypeDescr->nMapFunctionIndexToMemberIndex, "### illegal vtable index!" );
390
    if (nFunctionIndex >= pTypeDescr->nMapFunctionIndexToMemberIndex)
391
    {
392
        throw RuntimeException(
393
            OUString( "illegal vtable index!" ),
394
            (XInterface *)pThis );
395
    }
396
397
    // determine called method
398
    sal_Int32 nMemberPos = pTypeDescr->pMapFunctionIndexToMemberIndex[nFunctionIndex];
399
    OSL_ENSURE( nMemberPos < pTypeDescr->nAllMembers, "### illegal member index!" );
400
401
#if OSL_DEBUG_LEVEL > 2
402
    fprintf(stderr, "members are %d %d\n", nMemberPos, pTypeDescr->nAllMembers);
403
#endif
404
405
    TypeDescription aMemberDescr( pTypeDescr->ppAllMembers[nMemberPos] );
406
407
    typelib_TypeClass eRet;
408
    switch (aMemberDescr.get()->eTypeClass)
409
    {
410
    case typelib_TypeClass_INTERFACE_ATTRIBUTE:
411
    {
412
        if (pTypeDescr->pMapMemberIndexToFunctionIndex[nMemberPos] == nFunctionIndex)
413
        {
414
            // is GET method
415
            eRet = cpp2uno_call(
416
                pCppI, aMemberDescr.get(),
417
                ((typelib_InterfaceAttributeTypeDescription *)aMemberDescr.get())->pAttributeTypeRef,
418
                0, 0, // no params
419
                gpreg, fpreg, ovrflw, pRegisterReturn );
420
        }
421
        else
422
        {
423
            // is SET method
424
            typelib_MethodParameter aParam;
425
            aParam.pTypeRef =
426
                ((typelib_InterfaceAttributeTypeDescription *)aMemberDescr.get())->pAttributeTypeRef;
427
            aParam.bIn      = sal_True;
428
            aParam.bOut     = sal_False;
429
430
            eRet = cpp2uno_call(
431
                pCppI, aMemberDescr.get(),
432
                0, // indicates void return
433
                1, &aParam,
434
                gpreg, fpreg, ovrflw, pRegisterReturn );
435
        }
436
        break;
437
    }
438
    case typelib_TypeClass_INTERFACE_METHOD:
439
    {
440
        // is METHOD
441
        switch (nFunctionIndex)
442
        {
443
        case 1: // acquire()
444
            pCppI->acquireProxy(); // non virtual call!
445
            eRet = typelib_TypeClass_VOID;
446
            break;
447
        case 2: // release()
448
            pCppI->releaseProxy(); // non virtual call!
449
            eRet = typelib_TypeClass_VOID;
450
            break;
451
        case 0: // queryInterface() opt
452
        {
453
            typelib_TypeDescription * pTD = 0;
454
            TYPELIB_DANGER_GET( &pTD, reinterpret_cast< Type * >( gpreg[2] )->getTypeLibType() );
455
            if (pTD)
456
            {
457
                XInterface * pInterface = 0;
458
                (*pCppI->getBridge()->getCppEnv()->getRegisteredInterface)(
459
                    pCppI->getBridge()->getCppEnv(),
460
                    (void **)&pInterface, pCppI->getOid().pData,
461
                    (typelib_InterfaceTypeDescription *)pTD );
462
463
                if (pInterface)
464
                {
465
                    ::uno_any_construct(
466
                        reinterpret_cast< uno_Any * >( gpreg[0] ),
467
                        &pInterface, pTD, cpp_acquire );
468
                    pInterface->release();
469
                    TYPELIB_DANGER_RELEASE( pTD );
470
                    *(void **)pRegisterReturn = gpreg[0];
471
                    eRet = typelib_TypeClass_ANY;
472
                    break;
473
                }
474
                TYPELIB_DANGER_RELEASE( pTD );
475
            }
476
        } // else perform queryInterface()
477
        default:
478
            eRet = cpp2uno_call(
479
                pCppI, aMemberDescr.get(),
480
                ((typelib_InterfaceMethodTypeDescription *)aMemberDescr.get())->pReturnTypeRef,
481
                ((typelib_InterfaceMethodTypeDescription *)aMemberDescr.get())->nParams,
482
                ((typelib_InterfaceMethodTypeDescription *)aMemberDescr.get())->pParams,
483
                gpreg, fpreg, ovrflw, pRegisterReturn );
484
        }
485
        break;
486
    }
487
    default:
488
    {
489
#if OSL_DEBUG_LEVEL > 2
490
        fprintf(stderr, "screwed\n");
491
#endif
492
493
        throw RuntimeException(
494
            OUString( "no member description found!" ),
495
            (XInterface *)pThis );
496
    }
497
    }
498
499
#if OSL_DEBUG_LEVEL > 2
500
        fprintf(stderr, "end of cpp_mediate\n");
501
#endif
502
    return eRet;
503
}
504
505
extern "C" void privateSnippetExecutor( ... )
506
{
507
    sal_uInt64 gpreg[ppc64::MAX_GPR_REGS];
508
    double fpreg[ppc64::MAX_SSE_REGS];
509
510
    __asm__ __volatile__ (
511
        "std 3,   0(%0)\t\n"
512
        "std 4,   8(%0)\t\n"
513
        "std 5,  16(%0)\t\n"
514
        "std 6,  24(%0)\t\n"
515
        "std 7,  32(%0)\t\n"
516
        "std 8,  40(%0)\t\n"
517
        "std 9,  48(%0)\t\n"
518
        "std 10, 56(%0)\t\n"
519
        "stfd 1,   0(%1)\t\n"
520
        "stfd 2,   8(%1)\t\n"
521
        "stfd 3,  16(%1)\t\n"
522
        "stfd 4,  24(%1)\t\n"
523
        "stfd 5,  32(%1)\t\n"
524
        "stfd 6,  40(%1)\t\n"
525
        "stfd 7,  48(%1)\t\n"
526
        "stfd 8,  56(%1)\t\n"
527
        "stfd 9,  64(%1)\t\n"
528
        "stfd 10, 72(%1)\t\n"
529
        "stfd 11, 80(%1)\t\n"
530
        "stfd 12, 88(%1)\t\n"
531
        "stfd 13, 96(%1)\t\n"
532
    : : "r" (gpreg), "r" (fpreg)
533
        : "r0", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11",
534
          "fr1", "fr2", "fr3", "fr4", "fr5", "fr6", "fr7", "fr8", "fr9",
535
          "fr10", "fr11", "fr12", "fr13"
536
    );
537
538
    volatile long nOffsetAndIndex;
539
540
    //mr %r3, %r11            # move into arg1 the 64bit value passed from OOo
541
    __asm__ __volatile__ (
542
                "mr     %0,    11\n\t"
543
                : "=r" (nOffsetAndIndex) : );
544
545
    volatile long sp;
546
547
    //stack pointer
548
    __asm__ __volatile__ (
549
                "mr     %0,    1\n\t"
550
                : "=r" (sp) : );
551
552
#if _CALL_ELF == 2
553
    volatile long nRegReturn[2];
554
#else
555
    volatile long nRegReturn[1];
556
#endif
557
558
    typelib_TypeClass aType =
559
        cpp_mediate( nOffsetAndIndex, (void**)gpreg, (void**)fpreg, sp, (sal_Int64*)nRegReturn);
560
561
    switch( aType )
562
    {
563
        case typelib_TypeClass_VOID:
564
        break;
565
        case typelib_TypeClass_BOOLEAN:
566
        case typelib_TypeClass_BYTE:
567
            __asm__( "lbz 3,%0\n\t"
568
                : : "m" (nRegReturn[0]) );
569
            break;
570
        case typelib_TypeClass_CHAR:
571
        case typelib_TypeClass_UNSIGNED_SHORT:
572
            __asm__( "lhz 3,%0\n\t"
573
                : : "m" (nRegReturn[0]) );
574
            break;
575
        case typelib_TypeClass_SHORT:
576
            __asm__( "lha 3,%0\n\t"
577
                : : "m" (nRegReturn[0]) );
578
            break;
579
        case typelib_TypeClass_ENUM:
580
        case typelib_TypeClass_UNSIGNED_LONG:
581
            __asm__( "lwz 3,%0\n\t"
582
                : : "m"(nRegReturn[0]) );
583
            break;
584
        case typelib_TypeClass_LONG:
585
            __asm__( "lwa 3,%0\n\t"
586
                : : "m"(nRegReturn[0]) );
587
            break;
588
        case typelib_TypeClass_FLOAT:
589
            __asm__( "lfs 1,%0\n\t"
590
                : : "m" (*((float*)nRegReturn)) );
591
            break;
592
        case typelib_TypeClass_DOUBLE:
593
            __asm__( "lfd 1,%0\n\t"
594
                : : "m" (*((double*)nRegReturn)) );
595
            break;
596
        default:
597
            __asm__( "ld 3,%0\n\t"
598
                : : "m" (nRegReturn[0]) );
599
#if _CALL_ELF == 2
600
            __asm__( "ld 4,%0\n\t"
601
                : : "m" (nRegReturn[1]) );
602
#endif
603
            break;
604
    }
605
}
606
607
#if _CALL_ELF == 2
608
const int codeSnippetSize = 32;
609
#else
610
const int codeSnippetSize = 24;
611
#endif
612
613
unsigned char *  codeSnippet( unsigned char * code, sal_Int32 nFunctionIndex, sal_Int32 nVtableOffset,
614
                              bool bHasHiddenParam)
615
{
616
#if OSL_DEBUG_LEVEL > 2
617
    fprintf(stderr,"in codeSnippet functionIndex is %x\n", nFunctionIndex);
618
    fprintf(stderr,"in codeSnippet vtableOffset is %x\n", nVtableOffset);
619
#endif
620
621
    sal_uInt64 nOffsetAndIndex = ( ( (sal_uInt64) nVtableOffset ) << 32 ) | ( (sal_uInt64) nFunctionIndex );
622
623
    if ( bHasHiddenParam )
624
        nOffsetAndIndex |= 0x80000000;
625
#if _CALL_ELF == 2
626
    unsigned int *raw = (unsigned int *)&code[0];
627
628
    raw[0] = 0xe96c0018;        /* 0:   ld      11,2f-0b(12)    */
629
    raw[1] = 0xe98c0010;        /*      ld      12,1f-0b(12)    */
630
    raw[2] = 0x7d8903a6;        /*      mtctr   12              */
631
    raw[3] = 0x4e800420;        /*      bctr                    */
632
                                /* 1:   .quad   function_addr   */
633
                                /* 2:   .quad   context         */
634
    *(void **)&raw[4] = (void *)privateSnippetExecutor;
635
    *(void **)&raw[6] = (void*)nOffsetAndIndex;
636
#else
637
    void ** raw = (void **)&code[0];
638
    memcpy(raw, (char*) privateSnippetExecutor, 16);
639
    raw[2] = (void*) nOffsetAndIndex;
640
#endif
641
#if OSL_DEBUG_LEVEL > 2
642
    fprintf(stderr, "in: offset/index is %x %x %d, %lx\n",
643
    nFunctionIndex, nVtableOffset, bHasHiddenParam, raw[2]);
644
#endif
645
    return (code + codeSnippetSize);
646
}
647
648
}
649
650
void bridges::cpp_uno::shared::VtableFactory::flushCode(unsigned char const * bptr, unsigned char const * eptr)
651
{
652
    int const lineSize = 32;
653
    for (unsigned char const * p = bptr; p < eptr + lineSize; p += lineSize) {
654
        __asm__ volatile ("dcbst 0, %0" : : "r"(p) : "memory");
655
    }
656
    __asm__ volatile ("sync" : : : "memory");
657
    for (unsigned char const * p = bptr; p < eptr + lineSize; p += lineSize) {
658
        __asm__ volatile ("icbi 0, %0" : : "r"(p) : "memory");
659
    }
660
    __asm__ volatile ("isync" : : : "memory");
661
}
662
663
struct bridges::cpp_uno::shared::VtableFactory::Slot { void * fn; };
664
665
bridges::cpp_uno::shared::VtableFactory::Slot *
666
bridges::cpp_uno::shared::VtableFactory::mapBlockToVtable(void * block)
667
{
668
    return static_cast< Slot * >(block) + 2;
669
}
670
671
sal_Size bridges::cpp_uno::shared::VtableFactory::getBlockSize(
672
    sal_Int32 slotCount)
673
{
674
    return (slotCount + 2) * sizeof (Slot) + slotCount * codeSnippetSize;
675
}
676
677
bridges::cpp_uno::shared::VtableFactory::Slot *
678
bridges::cpp_uno::shared::VtableFactory::initializeBlock(
679
    void * block, sal_Int32 slotCount)
680
{
681
    Slot * slots = mapBlockToVtable(block);
682
    slots[-2].fn = 0;
683
    slots[-1].fn = 0;
684
    return slots + slotCount;
685
}
686
687
unsigned char * bridges::cpp_uno::shared::VtableFactory::addLocalFunctions(
688
    Slot ** slots, unsigned char * code, sal_PtrDiff writetoexecdiff,
689
    typelib_InterfaceTypeDescription const * type, sal_Int32 functionOffset,
690
    sal_Int32 functionCount, sal_Int32 vtableOffset)
691
{
692
     (*slots) -= functionCount;
693
     Slot * s = *slots;
694
#if OSL_DEBUG_LEVEL > 2
695
    fprintf(stderr, "in addLocalFunctions functionOffset is %x\n",functionOffset);
696
    fprintf(stderr, "in addLocalFunctions vtableOffset is %x\n",vtableOffset);
697
#endif
698
699
    for (sal_Int32 i = 0; i < type->nMembers; ++i) {
700
        typelib_TypeDescription * member = 0;
701
        TYPELIB_DANGER_GET(&member, type->ppMembers[i]);
702
        OSL_ASSERT(member != 0);
703
        switch (member->eTypeClass) {
704
        case typelib_TypeClass_INTERFACE_ATTRIBUTE:
705
            // Getter:
706
            (s++)->fn = code + writetoexecdiff;
707
            code = codeSnippet(
708
                code, functionOffset++, vtableOffset,
709
                ppc64::return_in_hidden_param(
710
                    reinterpret_cast<
711
                    typelib_InterfaceAttributeTypeDescription * >(
712
                        member)->pAttributeTypeRef));
713
714
            // Setter:
715
            if (!reinterpret_cast<
716
                typelib_InterfaceAttributeTypeDescription * >(
717
                    member)->bReadOnly)
718
            {
719
                (s++)->fn = code + writetoexecdiff;
720
                code = codeSnippet(code, functionOffset++, vtableOffset, false);
721
            }
722
            break;
723
724
        case typelib_TypeClass_INTERFACE_METHOD:
725
            (s++)->fn = code + writetoexecdiff;
726
            code = codeSnippet(
727
                code, functionOffset++, vtableOffset,
728
                ppc64::return_in_hidden_param(
729
                    reinterpret_cast<
730
                    typelib_InterfaceMethodTypeDescription * >(
731
                        member)->pReturnTypeRef));
732
            break;
733
734
        default:
735
            OSL_ASSERT(false);
736
            break;
737
        }
738
        TYPELIB_DANGER_RELEASE(member);
739
    }
740
    return code;
741
}
742
743
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
(-)bridges/source/cpp_uno/gcc3_freebsd_powerpc64/except.cxx (+274 lines)
Added Link Here
1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
/*
3
 * This file is part of the LibreOffice project.
4
 *
5
 * This Source Code Form is subject to the terms of the Mozilla Public
6
 * License, v. 2.0. If a copy of the MPL was not distributed with this
7
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8
 *
9
 * This file incorporates work covered by the following license notice:
10
 *
11
 *   Licensed to the Apache Software Foundation (ASF) under one or more
12
 *   contributor license agreements. See the NOTICE file distributed
13
 *   with this work for additional information regarding copyright
14
 *   ownership. The ASF licenses this file to you under the Apache
15
 *   License, Version 2.0 (the "License"); you may not use this file
16
 *   except in compliance with the License. You may obtain a copy of
17
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
18
 */
19
20
21
#include <stdio.h>
22
#include <string.h>
23
#include <dlfcn.h>
24
#include <cxxabi.h>
25
#include <boost/unordered_map.hpp>
26
27
#include <rtl/strbuf.hxx>
28
#include <rtl/ustrbuf.hxx>
29
#include <osl/diagnose.h>
30
#include <osl/mutex.hxx>
31
32
#include <com/sun/star/uno/genfunc.hxx>
33
#include <typelib/typedescription.hxx>
34
#include <uno/any2.h>
35
36
#include "share.hxx"
37
38
39
using namespace ::std;
40
using namespace ::osl;
41
using namespace ::rtl;
42
using namespace ::com::sun::star::uno;
43
using namespace ::__cxxabiv1;
44
45
46
namespace CPPU_CURRENT_NAMESPACE
47
{
48
49
void dummy_can_throw_anything( char const * )
50
{
51
}
52
53
static OUString toUNOname( char const * p ) SAL_THROW(())
54
{
55
#if OSL_DEBUG_LEVEL > 1
56
    char const * start = p;
57
#endif
58
59
    // example: N3com3sun4star4lang24IllegalArgumentExceptionE
60
61
    OUStringBuffer buf( 64 );
62
    OSL_ASSERT( 'N' == *p );
63
    ++p; // skip N
64
65
    while ('E' != *p)
66
    {
67
        // read chars count
68
        long n = (*p++ - '0');
69
        while ('0' <= *p && '9' >= *p)
70
        {
71
            n *= 10;
72
            n += (*p++ - '0');
73
        }
74
        buf.appendAscii( p, n );
75
        p += n;
76
        if ('E' != *p)
77
            buf.append( '.' );
78
    }
79
80
#if OSL_DEBUG_LEVEL > 1
81
    OUString ret( buf.makeStringAndClear() );
82
    OString c_ret( OUStringToOString( ret, RTL_TEXTENCODING_ASCII_US ) );
83
    fprintf( stderr, "> toUNOname(): %s => %s\n", start, c_ret.getStr() );
84
    return ret;
85
#else
86
    return buf.makeStringAndClear();
87
#endif
88
}
89
90
class RTTI
91
{
92
    typedef boost::unordered_map< OUString, type_info *, OUStringHash > t_rtti_map;
93
94
    Mutex m_mutex;
95
    t_rtti_map m_rttis;
96
    t_rtti_map m_generatedRttis;
97
98
    void * m_hApp;
99
100
public:
101
    RTTI() SAL_THROW(());
102
    ~RTTI() SAL_THROW(());
103
104
    type_info * getRTTI( typelib_CompoundTypeDescription * ) SAL_THROW(());
105
};
106
107
RTTI::RTTI() SAL_THROW(())
108
    : m_hApp( dlopen( 0, RTLD_LAZY ) )
109
{
110
}
111
112
RTTI::~RTTI() SAL_THROW(())
113
{
114
    dlclose( m_hApp );
115
}
116
117
118
type_info * RTTI::getRTTI( typelib_CompoundTypeDescription *pTypeDescr ) SAL_THROW(())
119
{
120
    type_info * rtti;
121
122
    OUString const & unoName = *(OUString const *)&pTypeDescr->aBase.pTypeName;
123
124
    MutexGuard guard( m_mutex );
125
    t_rtti_map::const_iterator iRttiFind( m_rttis.find( unoName ) );
126
    if (iRttiFind == m_rttis.end())
127
    {
128
        // RTTI symbol
129
        OStringBuffer buf( 64 );
130
        buf.append( "_ZTIN" );
131
        sal_Int32 index = 0;
132
        do
133
        {
134
            OUString token( unoName.getToken( 0, '.', index ) );
135
            buf.append( token.getLength() );
136
            OString c_token( OUStringToOString( token, RTL_TEXTENCODING_ASCII_US ) );
137
            buf.append( c_token );
138
        }
139
        while (index >= 0);
140
        buf.append( 'E' );
141
142
        OString symName( buf.makeStringAndClear() );
143
        rtti = (type_info *)dlsym( m_hApp, symName.getStr() );
144
145
        if (rtti)
146
        {
147
            pair< t_rtti_map::iterator, bool > insertion(
148
                m_rttis.insert( t_rtti_map::value_type( unoName, rtti ) ) );
149
            OSL_ENSURE( insertion.second, "### inserting new rtti failed?!" );
150
        }
151
        else
152
        {
153
            // try to lookup the symbol in the generated rtti map
154
            t_rtti_map::const_iterator iFind( m_generatedRttis.find( unoName ) );
155
            if (iFind == m_generatedRttis.end())
156
            {
157
                // we must generate it !
158
                // symbol and rtti-name is nearly identical,
159
                // the symbol is prefixed with _ZTI
160
                char const * rttiName = symName.getStr() +4;
161
#if OSL_DEBUG_LEVEL > 1
162
                fprintf( stderr,"generated rtti for %s\n", rttiName );
163
#endif
164
                if (pTypeDescr->pBaseTypeDescription)
165
                {
166
                    // ensure availability of base
167
                    type_info * base_rtti = getRTTI(
168
                        (typelib_CompoundTypeDescription *)pTypeDescr->pBaseTypeDescription );
169
                    rtti = new __si_class_type_info(
170
                        strdup( rttiName ), (__class_type_info *)base_rtti );
171
                }
172
                else
173
                {
174
                    // this class has no base class
175
                    rtti = new __class_type_info( strdup( rttiName ) );
176
                }
177
178
                pair< t_rtti_map::iterator, bool > insertion(
179
                    m_generatedRttis.insert( t_rtti_map::value_type( unoName, rtti ) ) );
180
                OSL_ENSURE( insertion.second, "### inserting new generated rtti failed?!" );
181
            }
182
            else // taking already generated rtti
183
            {
184
                rtti = iFind->second;
185
            }
186
        }
187
    }
188
    else
189
    {
190
        rtti = iRttiFind->second;
191
    }
192
193
    return rtti;
194
}
195
196
197
static void deleteException( void * pExc )
198
{
199
    __cxa_exception const * header = ((__cxa_exception const *)pExc - 1);
200
    typelib_TypeDescription * pTD = 0;
201
    OUString unoName( toUNOname( header->exceptionType->name() ) );
202
    ::typelib_typedescription_getByName( &pTD, unoName.pData );
203
    OSL_ENSURE( pTD, "### unknown exception type! leaving out destruction => leaking!!!" );
204
    if (pTD)
205
    {
206
        ::uno_destructData( pExc, pTD, cpp_release );
207
        ::typelib_typedescription_release( pTD );
208
    }
209
}
210
211
void raiseException( uno_Any * pUnoExc, uno_Mapping * pUno2Cpp )
212
{
213
    void * pCppExc;
214
    type_info * rtti;
215
216
    {
217
    // construct cpp exception object
218
    typelib_TypeDescription * pTypeDescr = 0;
219
    TYPELIB_DANGER_GET( &pTypeDescr, pUnoExc->pType );
220
    OSL_ASSERT( pTypeDescr );
221
    if (! pTypeDescr)
222
        terminate();
223
224
    pCppExc = __cxa_allocate_exception( pTypeDescr->nSize );
225
    ::uno_copyAndConvertData( pCppExc, pUnoExc->pData, pTypeDescr, pUno2Cpp );
226
227
    // destruct uno exception
228
    ::uno_any_destruct( pUnoExc, 0 );
229
    // avoiding locked counts
230
    static RTTI * s_rtti = 0;
231
    if (! s_rtti)
232
    {
233
        MutexGuard guard( Mutex::getGlobalMutex() );
234
        if (! s_rtti)
235
        {
236
#ifdef LEAK_STATIC_DATA
237
            s_rtti = new RTTI();
238
#else
239
            static RTTI rtti_data;
240
            s_rtti = &rtti_data;
241
#endif
242
        }
243
    }
244
    rtti = (type_info *)s_rtti->getRTTI( (typelib_CompoundTypeDescription *) pTypeDescr );
245
    TYPELIB_DANGER_RELEASE( pTypeDescr );
246
    OSL_ENSURE( rtti, "### no rtti for throwing exception!" );
247
    if (! rtti)
248
        terminate();
249
    }
250
251
    __cxa_throw( pCppExc, rtti, deleteException );
252
}
253
254
void fillUnoException( __cxa_exception * header, uno_Any * pExc, uno_Mapping * pCpp2Uno )
255
{
256
    OSL_ENSURE( header, "### no exception header!!!" );
257
    if (! header)
258
        terminate();
259
260
    typelib_TypeDescription * pExcTypeDescr = 0;
261
    OUString unoName( toUNOname( header->exceptionType->name() ) );
262
    ::typelib_typedescription_getByName( &pExcTypeDescr, unoName.pData );
263
    OSL_ENSURE( pExcTypeDescr, "### can not get type description for exception!!!" );
264
    if (! pExcTypeDescr)
265
        terminate();
266
267
    // construct uno exception any
268
    ::uno_any_constructAndConvert( pExc, header->adjustedPtr, pExcTypeDescr, pCpp2Uno );
269
    ::typelib_typedescription_release( pExcTypeDescr );
270
}
271
272
}
273
274
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
(-)bridges/source/cpp_uno/gcc3_freebsd_powerpc64/share.hxx (+92 lines)
Added Link Here
1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
/*
3
 * This file is part of the LibreOffice project.
4
 *
5
 * This Source Code Form is subject to the terms of the Mozilla Public
6
 * License, v. 2.0. If a copy of the MPL was not distributed with this
7
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8
 *
9
 * This file incorporates work covered by the following license notice:
10
 *
11
 *   Licensed to the Apache Software Foundation (ASF) under one or more
12
 *   contributor license agreements. See the NOTICE file distributed
13
 *   with this work for additional information regarding copyright
14
 *   ownership. The ASF licenses this file to you under the Apache
15
 *   License, Version 2.0 (the "License"); you may not use this file
16
 *   except in compliance with the License. You may obtain a copy of
17
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
18
 */
19
#ifndef INCLUDED_BRIDGES_SOURCE_CPP_UNO_GCC3_FREEBSD_POWERPC64_SHARE_HXX
20
#define INCLUDED_BRIDGES_SOURCE_CPP_UNO_GCC3_FREEBSD_POWERPC64_SHARE_HXX
21
22
#include "uno/mapping.h"
23
24
#include <typeinfo>
25
#include <exception>
26
#include <cstddef>
27
28
namespace CPPU_CURRENT_NAMESPACE
29
{
30
31
  void dummy_can_throw_anything( char const * );
32
33
34
// ----- following decl from libstdc++-v3/libsupc++/unwind-cxx.h and unwind.h
35
36
struct _Unwind_Exception
37
{
38
    unsigned exception_class __attribute__((__mode__(__DI__)));
39
    void * exception_cleanup;
40
    unsigned private_1 __attribute__((__mode__(__word__)));
41
    unsigned private_2 __attribute__((__mode__(__word__)));
42
} __attribute__((__aligned__));
43
44
struct __cxa_exception
45
{
46
    ::std::type_info *exceptionType;
47
    void (*exceptionDestructor)(void *);
48
49
    ::std::unexpected_handler unexpectedHandler;
50
    ::std::terminate_handler terminateHandler;
51
52
    __cxa_exception *nextException;
53
54
    int handlerCount;
55
56
    int handlerSwitchValue;
57
    const unsigned char *actionRecord;
58
    const unsigned char *languageSpecificData;
59
    void *catchTemp;
60
    void *adjustedPtr;
61
62
    _Unwind_Exception unwindHeader;
63
};
64
65
extern "C" void *__cxa_allocate_exception(
66
    std::size_t thrown_size ) throw();
67
extern "C" void __cxa_throw (
68
    void *thrown_exception, std::type_info *tinfo, void (*dest) (void *) ) __attribute__((noreturn));
69
70
struct __cxa_eh_globals
71
{
72
    __cxa_exception *caughtExceptions;
73
    unsigned int uncaughtExceptions;
74
};
75
extern "C" __cxa_eh_globals *__cxa_get_globals () throw();
76
77
78
void raiseException(
79
    uno_Any * pUnoExc, uno_Mapping * pUno2Cpp );
80
81
void fillUnoException(
82
    __cxa_exception * header, uno_Any *, uno_Mapping * pCpp2Uno );
83
}
84
85
namespace ppc64
86
{
87
    enum ppclimits { MAX_GPR_REGS = 8, MAX_SSE_REGS = 13 };
88
    bool return_in_hidden_param( typelib_TypeDescriptionReference *pTypeRef );
89
}
90
91
#endif
92
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
(-)bridges/source/cpp_uno/gcc3_freebsd_powerpc64/uno2cpp.cxx (+659 lines)
Added Link Here
1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
/*
3
 * This file is part of the LibreOffice project.
4
 *
5
 * This Source Code Form is subject to the terms of the Mozilla Public
6
 * License, v. 2.0. If a copy of the MPL was not distributed with this
7
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8
 *
9
 * This file incorporates work covered by the following license notice:
10
 *
11
 *   Licensed to the Apache Software Foundation (ASF) under one or more
12
 *   contributor license agreements. See the NOTICE file distributed
13
 *   with this work for additional information regarding copyright
14
 *   ownership. The ASF licenses this file to you under the Apache
15
 *   License, Version 2.0 (the "License"); you may not use this file
16
 *   except in compliance with the License. You may obtain a copy of
17
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
18
 */
19
20
21
#include <stdlib.h>
22
23
#include <com/sun/star/uno/genfunc.hxx>
24
#include <uno/data.h>
25
26
#include "bridges/cpp_uno/shared/bridge.hxx"
27
#include "bridges/cpp_uno/shared/types.hxx"
28
#include "bridges/cpp_uno/shared/unointerfaceproxy.hxx"
29
#include "bridges/cpp_uno/shared/vtables.hxx"
30
31
#include "share.hxx"
32
33
#include <stdio.h>
34
#include <string.h>
35
36
37
using namespace ::rtl;
38
using namespace ::com::sun::star::uno;
39
40
namespace ppc64
41
{
42
#if _CALL_ELF == 2
43
    bool is_complex_struct(const typelib_TypeDescription * type)
44
    {
45
        const typelib_CompoundTypeDescription * p
46
            = reinterpret_cast< const typelib_CompoundTypeDescription * >(type);
47
        for (sal_Int32 i = 0; i < p->nMembers; ++i)
48
        {
49
            if (p->ppTypeRefs[i]->eTypeClass == typelib_TypeClass_STRUCT ||
50
                p->ppTypeRefs[i]->eTypeClass == typelib_TypeClass_EXCEPTION)
51
            {
52
                typelib_TypeDescription * t = 0;
53
                TYPELIB_DANGER_GET(&t, p->ppTypeRefs[i]);
54
                bool b = is_complex_struct(t);
55
                TYPELIB_DANGER_RELEASE(t);
56
                if (b) {
57
                    return true;
58
                }
59
            }
60
            else if (!bridges::cpp_uno::shared::isSimpleType(p->ppTypeRefs[i]->eTypeClass))
61
                return true;
62
        }
63
        if (p->pBaseTypeDescription != 0)
64
            return is_complex_struct(&p->pBaseTypeDescription->aBase);
65
        return false;
66
    }
67
#endif
68
69
    bool return_in_hidden_param( typelib_TypeDescriptionReference *pTypeRef )
70
    {
71
        if (bridges::cpp_uno::shared::isSimpleType(pTypeRef))
72
            return false;
73
#if _CALL_ELF == 2
74
        else if (pTypeRef->eTypeClass == typelib_TypeClass_STRUCT || pTypeRef->eTypeClass == typelib_TypeClass_EXCEPTION)
75
        {
76
            typelib_TypeDescription * pTypeDescr = 0;
77
            TYPELIB_DANGER_GET( &pTypeDescr, pTypeRef );
78
79
            //A Composite Type not larger than 16 bytes is returned in up to two GPRs
80
            bool bRet = pTypeDescr->nSize > 16 || is_complex_struct(pTypeDescr);
81
82
            TYPELIB_DANGER_RELEASE( pTypeDescr );
83
            return bRet;
84
        }
85
#endif
86
        return true;
87
    }
88
}
89
90
void MapReturn(long r3, long r4, double dret, typelib_TypeDescriptionReference* pReturnType, void *pRegisterReturn)
91
{
92
    switch (pReturnType->eTypeClass)
93
    {
94
    case typelib_TypeClass_HYPER:
95
    case typelib_TypeClass_UNSIGNED_HYPER:
96
            *reinterpret_cast<sal_uInt64 *>( pRegisterReturn ) = r3;
97
            break;
98
    case typelib_TypeClass_LONG:
99
    case typelib_TypeClass_UNSIGNED_LONG:
100
    case typelib_TypeClass_ENUM:
101
            *reinterpret_cast<sal_uInt32 *>( pRegisterReturn ) = r3;
102
            break;
103
    case typelib_TypeClass_CHAR:
104
    case typelib_TypeClass_SHORT:
105
    case typelib_TypeClass_UNSIGNED_SHORT:
106
            *reinterpret_cast<sal_uInt16 *>( pRegisterReturn ) = (unsigned short)r3;
107
            break;
108
    case typelib_TypeClass_BOOLEAN:
109
    case typelib_TypeClass_BYTE:
110
            *reinterpret_cast<sal_uInt8 *>( pRegisterReturn ) = (unsigned char)r3;
111
            break;
112
    case typelib_TypeClass_FLOAT:
113
            *reinterpret_cast<float *>( pRegisterReturn ) = dret;
114
        break;
115
    case typelib_TypeClass_DOUBLE:
116
            *reinterpret_cast<double *>( pRegisterReturn ) = dret;
117
            break;
118
#if _CALL_ELF == 2
119
    case typelib_TypeClass_STRUCT:
120
    case typelib_TypeClass_EXCEPTION:
121
            if (!ppc64::return_in_hidden_param(pReturnType))
122
            {
123
                sal_uInt64 *pRegisters = reinterpret_cast<sal_uInt64*>(pRegisterReturn);
124
                pRegisters[0] = r3;
125
                if (pReturnType->pType->nSize > 8)
126
                    pRegisters[1] = r4;
127
            }
128
#endif
129
    default:
130
            break;
131
    }
132
}
133
134
namespace
135
{
136
137
static void callVirtualMethod(void * pThis, sal_uInt32 nVtableIndex,
138
    void * pRegisterReturn, typelib_TypeDescription * pReturnTypeDescr,
139
        sal_uInt64 *pStack, sal_uInt32 nStack,
140
        sal_uInt64 *pGPR, sal_uInt32 nGPR,
141
        double *pFPR, sal_uInt32 nFPR)
142
{
143
    // Stack, if used, must be 16-bytes aligned
144
    if ( nStack )
145
        nStack = ( nStack + 1 ) & ~1;
146
147
    // Should not happen, but...
148
    if ( nFPR > ppc64::MAX_SSE_REGS )
149
        nFPR = ppc64::MAX_SSE_REGS;
150
    if ( nGPR > ppc64::MAX_GPR_REGS )
151
        nGPR = ppc64::MAX_GPR_REGS;
152
153
#if OSL_DEBUG_LEVEL > 2
154
        // Let's figure out what is really going on here
155
        {
156
                fprintf( stderr, "= callVirtualMethod() =\nGPR's (%d): ", nGPR );
157
                for ( int i = 0; i < nGPR; ++i )
158
                        fprintf( stderr, "0x%lx, ", pGPR[i] );
159
                fprintf( stderr, "\nFPR's (%d): ", nFPR );
160
                for ( int i = 0; i < nFPR; ++i )
161
                        fprintf( stderr, "0x%lx (%f), ", pFPR[i], pFPR[i] );
162
                fprintf( stderr, "\nStack (%d): ", nStack );
163
                for ( int i = 0; i < nStack; ++i )
164
                        fprintf( stderr, "0x%lx, ", pStack[i] );
165
                fprintf( stderr, "\n" );
166
        }
167
#endif
168
169
    // Load parameters to stack, if necessary
170
    sal_uInt64 *stack = (sal_uInt64 *) __builtin_alloca( nStack * 8 );
171
    memcpy( stack, pStack, nStack * 8 );
172
173
    // Get pointer to method
174
    sal_uInt64 pMethod = *((sal_uInt64 *)pThis);
175
    pMethod += 8 * nVtableIndex;
176
    pMethod = *((sal_uInt64 *)pMethod);
177
178
#if _CALL_ELF == 2
179
    typedef void (* FunctionCall )(...);
180
#else
181
    typedef void (* FunctionCall )( sal_uInt64, sal_uInt64, sal_uInt64, sal_uInt64, sal_uInt64, sal_uInt64, sal_uInt64, sal_uInt64 );
182
#endif
183
    FunctionCall pFunc = (FunctionCall)pMethod;
184
185
    volatile double dret;
186
187
    //  fill registers
188
    __asm__ __volatile__ (
189
                "ld   3,  0(%0)\n\t"
190
                "ld   4,  8(%0)\n\t"
191
                "ld   5, 16(%0)\n\t"
192
                "ld   6, 24(%0)\n\t"
193
                "ld   7, 32(%0)\n\t"
194
                "ld   8, 40(%0)\n\t"
195
                "ld   9, 48(%0)\n\t"
196
                "ld  10, 56(%0)\n\t"
197
                "lfd  1,  0(%1)\n\t"
198
                "lfd  2,  8(%1)\n\t"
199
                "lfd  3, 16(%1)\n\t"
200
                "lfd  4, 24(%1)\n\t"
201
                "lfd  5, 32(%1)\n\t"
202
                "lfd  6, 40(%1)\n\t"
203
                "lfd  7, 48(%1)\n\t"
204
                "lfd  8, 56(%1)\n\t"
205
                "lfd  9, 64(%1)\n\t"
206
                "lfd 10, 72(%1)\n\t"
207
                "lfd 11, 80(%1)\n\t"
208
                "lfd 12, 88(%1)\n\t"
209
                "lfd 13, 96(%1)\n\t"
210
                : : "r" (pGPR), "r" (pFPR)
211
              : "r0", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10",
212
                  "fr1", "fr2", "fr3", "fr4", "fr5", "fr6", "fr7", "fr8", "fr9",
213
                  "fr10", "fr11", "fr12", "fr13"
214
    );
215
216
    // tell gcc that r3 to r11 are not available to it for doing the TOC and exception munge on the func call
217
    register sal_uInt64 r3 asm("r3");
218
    register sal_uInt64 r4 asm("r4");
219
    register sal_uInt64 r5 asm("r5");
220
    register sal_uInt64 r6 asm("r6");
221
    register sal_uInt64 r7 asm("r7");
222
    register sal_uInt64 r8 asm("r8");
223
    register sal_uInt64 r9 asm("r9");
224
    register sal_uInt64 r10 asm("r10");
225
    register sal_uInt64 r11 asm("r11");
226
227
    (*pFunc)(r3, r4, r5, r6, r7, r8, r9, r10);
228
229
    // get return value
230
    __asm__ __volatile__ (
231
                "mr     %1,     3\n\t"
232
                "mr     %2,     4\n\t"
233
                "fmr    %0,     1\n\t"
234
                : "=f" (dret), "=r" (r3), "=r" (r4) : );
235
236
    MapReturn(r3, r4, dret, reinterpret_cast<typelib_TypeDescriptionReference *>(pReturnTypeDescr), pRegisterReturn);
237
}
238
239
// Macros for easier insertion of values to registers or stack
240
// pSV - pointer to the source
241
// nr - order of the value [will be increased if stored to register]
242
// pFPR, pGPR - pointer to the registers
243
// pDS - pointer to the stack [will be increased if stored here]
244
245
// The value in %xmm register is already prepared to be retrieved as a float,
246
// thus we treat float and double the same
247
#define INSERT_FLOAT( pSV, nr, pFPR, pDS, bOverflow ) \
248
        if ( nr < ppc64::MAX_SSE_REGS ) \
249
                pFPR[nr++] = *reinterpret_cast<float *>( pSV ); \
250
        else \
251
            bOverflow = true; \
252
        if (bOverflow) \
253
                *pDS++ = *reinterpret_cast<sal_uInt64 *>( pSV ); // verbatim!
254
255
#define INSERT_DOUBLE( pSV, nr, pFPR, pDS, bOverflow ) \
256
        if ( nr < ppc64::MAX_SSE_REGS ) \
257
                pFPR[nr++] = *reinterpret_cast<double *>( pSV ); \
258
        else \
259
            bOverflow = true; \
260
        if (bOverflow) \
261
                *pDS++ = *reinterpret_cast<sal_uInt64 *>( pSV ); // verbatim!
262
263
#define INSERT_INT64( pSV, nr, pGPR, pDS, bOverflow ) \
264
        if ( nr < ppc64::MAX_GPR_REGS ) \
265
                pGPR[nr++] = *reinterpret_cast<sal_uInt64 *>( pSV ); \
266
        else \
267
        bOverflow = true; \
268
    if (bOverflow) \
269
                *pDS++ = *reinterpret_cast<sal_uInt64 *>( pSV );
270
271
#define INSERT_INT32( pSV, nr, pGPR, pDS, bOverflow ) \
272
        if ( nr < ppc64::MAX_GPR_REGS ) \
273
                pGPR[nr++] = *reinterpret_cast<sal_uInt32 *>( pSV ); \
274
        else \
275
                bOverflow = true; \
276
        if (bOverflow) \
277
                *pDS++ = *reinterpret_cast<sal_uInt32 *>( pSV );
278
279
#define INSERT_INT16( pSV, nr, pGPR, pDS, bOverflow ) \
280
        if ( nr < ppc64::MAX_GPR_REGS ) \
281
                pGPR[nr++] = *reinterpret_cast<sal_uInt16 *>( pSV ); \
282
        else \
283
                bOverflow = true; \
284
        if (bOverflow) \
285
                *pDS++ = *reinterpret_cast<sal_uInt16 *>( pSV );
286
287
#define INSERT_INT8( pSV, nr, pGPR, pDS, bOverflow ) \
288
        if ( nr < ppc64::MAX_GPR_REGS ) \
289
                pGPR[nr++] = *reinterpret_cast<sal_uInt8 *>( pSV ); \
290
        else \
291
                bOverflow = true; \
292
        if (bOverflow) \
293
                *pDS++ = *reinterpret_cast<sal_uInt8 *>( pSV );
294
295
static void cpp_call(
296
    bridges::cpp_uno::shared::UnoInterfaceProxy * pThis,
297
    bridges::cpp_uno::shared::VtableSlot  aVtableSlot,
298
    typelib_TypeDescriptionReference * pReturnTypeRef,
299
    sal_Int32 nParams, typelib_MethodParameter * pParams,
300
    void * pUnoReturn, void * pUnoArgs[], uno_Any ** ppUnoExc )
301
{
302
      // max space for: [complex ret ptr], values|ptr ...
303
      sal_uInt64 * pStack = (sal_uInt64 *)alloca( (nParams+3) * sizeof(sal_Int64) );
304
      sal_uInt64 * pStackStart = pStack;
305
306
    sal_uInt64 pGPR[ppc64::MAX_GPR_REGS];
307
    sal_uInt32 nGPR = 0;
308
309
    double pFPR[ppc64::MAX_SSE_REGS];
310
    sal_uInt32 nFPR = 0;
311
312
    // return
313
    typelib_TypeDescription * pReturnTypeDescr = 0;
314
    TYPELIB_DANGER_GET( &pReturnTypeDescr, pReturnTypeRef );
315
    OSL_ENSURE( pReturnTypeDescr, "### expected return type description!" );
316
317
    void * pCppReturn = 0; // if != 0 && != pUnoReturn, needs reconversion
318
319
    bool bOverflow = false;
320
    bool bSimpleReturn = true;
321
322
    if (pReturnTypeDescr)
323
    {
324
#if OSL_DEBUG_LEVEL > 2
325
        fprintf(stderr, "return type is %d\n", pReturnTypeDescr->eTypeClass);
326
#endif
327
        if (ppc64::return_in_hidden_param(pReturnTypeRef))
328
            bSimpleReturn = false;
329
330
        if (bSimpleReturn)
331
        {
332
            pCppReturn = pUnoReturn; // direct way for simple types
333
#if OSL_DEBUG_LEVEL > 2
334
            fprintf(stderr, "simple return\n");
335
#endif
336
        }
337
        else
338
        {
339
            // complex return via ptr
340
            pCppReturn = (bridges::cpp_uno::shared::relatesToInterfaceType( pReturnTypeDescr )
341
                   ? alloca( pReturnTypeDescr->nSize ) : pUnoReturn);
342
#if OSL_DEBUG_LEVEL > 2
343
            fprintf(stderr, "pCppReturn/pUnoReturn is %lx/%lx", pCppReturn, pUnoReturn);
344
#endif
345
            INSERT_INT64( &pCppReturn, nGPR, pGPR, pStack, bOverflow );
346
        }
347
    }
348
    // push "this" pointer
349
        void * pAdjustedThisPtr = reinterpret_cast< void ** >( pThis->getCppI() ) + aVtableSlot.offset;
350
#if OSL_DEBUG_LEVEL > 2
351
    fprintf(stderr, "this pointer is %p\n", pAdjustedThisPtr);
352
#endif
353
    INSERT_INT64( &pAdjustedThisPtr, nGPR, pGPR, pStack, bOverflow );
354
355
        // Args
356
        void ** pCppArgs = (void **)alloca( 3 * sizeof(void *) * nParams );
357
    // indices of values this have to be converted (interface conversion cpp<=>uno)
358
    sal_Int32 * pTempIndices = (sal_Int32 *)(pCppArgs + nParams);
359
    // type descriptions for reconversions
360
    typelib_TypeDescription ** ppTempParamTypeDescr = (typelib_TypeDescription **)(pCppArgs + (2 * nParams));
361
362
    sal_Int32 nTempIndices   = 0;
363
364
#if OSL_DEBUG_LEVEL > 2
365
    fprintf(stderr, "n params is %d\n", nParams);
366
#endif
367
368
    for ( sal_Int32 nPos = 0; nPos < nParams; ++nPos )
369
    {
370
        const typelib_MethodParameter & rParam = pParams[nPos];
371
        typelib_TypeDescription * pParamTypeDescr = 0;
372
        TYPELIB_DANGER_GET( &pParamTypeDescr, rParam.pTypeRef );
373
374
#if OSL_DEBUG_LEVEL > 2
375
        fprintf(stderr, "param %d is %d %d %d\n", nPos, rParam.bOut, bridges::cpp_uno::shared::isSimpleType( pParamTypeDescr ),
376
            pParamTypeDescr->eTypeClass);
377
#endif
378
379
        if (!rParam.bOut && bridges::cpp_uno::shared::isSimpleType( pParamTypeDescr ))
380
        {
381
//          uno_copyAndConvertData( pCppArgs[nPos] = alloca( 8 ), pUnoArgs[nPos], pParamTypeDescr,
382
            uno_copyAndConvertData( pCppArgs[nPos] = pStack, pUnoArgs[nPos], pParamTypeDescr,
383
                                    pThis->getBridge()->getUno2Cpp() );
384
                switch (pParamTypeDescr->eTypeClass)
385
                        {
386
                        case typelib_TypeClass_HYPER:
387
                        case typelib_TypeClass_UNSIGNED_HYPER:
388
#if OSL_DEBUG_LEVEL > 2
389
                fprintf(stderr, "hyper is %lx\n", pCppArgs[nPos]);
390
#endif
391
                                INSERT_INT64( pCppArgs[nPos], nGPR, pGPR, pStack, bOverflow );
392
                                break;
393
                        case typelib_TypeClass_LONG:
394
                        case typelib_TypeClass_UNSIGNED_LONG:
395
                        case typelib_TypeClass_ENUM:
396
#if OSL_DEBUG_LEVEL > 2
397
                fprintf(stderr, "long is %x\n", pCppArgs[nPos]);
398
#endif
399
                                INSERT_INT32( pCppArgs[nPos], nGPR, pGPR, pStack, bOverflow );
400
                                break;
401
                        case typelib_TypeClass_SHORT:
402
                        case typelib_TypeClass_CHAR:
403
                        case typelib_TypeClass_UNSIGNED_SHORT:
404
                                INSERT_INT16( pCppArgs[nPos], nGPR, pGPR, pStack, bOverflow );
405
                                break;
406
                        case typelib_TypeClass_BOOLEAN:
407
                        case typelib_TypeClass_BYTE:
408
                                INSERT_INT8( pCppArgs[nPos], nGPR, pGPR, pStack, bOverflow );
409
                                break;
410
                        case typelib_TypeClass_FLOAT:
411
                                INSERT_FLOAT( pCppArgs[nPos], nFPR, pFPR, pStack, bOverflow );
412
                break;
413
                        case typelib_TypeClass_DOUBLE:
414
                                INSERT_DOUBLE( pCppArgs[nPos], nFPR, pFPR, pStack, bOverflow );
415
                                break;
416
                        }
417
418
                        // no longer needed
419
                        TYPELIB_DANGER_RELEASE( pParamTypeDescr );
420
421
        }
422
        else // ptr to complex value | ref
423
        {
424
#if OSL_DEBUG_LEVEL > 2
425
            fprintf(stderr, "complex type again %d\n", rParam.bIn);
426
#endif
427
                        if (! rParam.bIn) // is pure out
428
                        {
429
#if OSL_DEBUG_LEVEL > 2
430
                fprintf(stderr, "complex size is %d\n", pParamTypeDescr->nSize );
431
#endif
432
                                // cpp out is constructed mem, uno out is not!
433
                                uno_constructData(
434
                                        pCppArgs[nPos] = alloca( pParamTypeDescr->nSize ),
435
                                        pParamTypeDescr );
436
                                pTempIndices[nTempIndices] = nPos; // default constructed for cpp call
437
                                // will be released at reconversion
438
                                ppTempParamTypeDescr[nTempIndices++] = pParamTypeDescr;
439
                        }
440
                        // is in/inout
441
                        else if (bridges::cpp_uno::shared::relatesToInterfaceType( pParamTypeDescr ))
442
                        {
443
#if OSL_DEBUG_LEVEL > 2
444
                fprintf(stderr, "this one\n");
445
#endif
446
                                uno_copyAndConvertData(
447
                                        pCppArgs[nPos] = alloca( pParamTypeDescr->nSize ),
448
                                        pUnoArgs[nPos], pParamTypeDescr, pThis->getBridge()->getUno2Cpp() );
449
450
                                pTempIndices[nTempIndices] = nPos; // has to be reconverted
451
                                // will be released at reconversion
452
                                ppTempParamTypeDescr[nTempIndices++] = pParamTypeDescr;
453
                        }
454
                        else // direct way
455
                        {
456
#if OSL_DEBUG_LEVEL > 2
457
                fprintf(stderr, "that one, passing %lx through\n", pUnoArgs[nPos]);
458
#endif
459
                                pCppArgs[nPos] = pUnoArgs[nPos];
460
                                // no longer needed
461
                                TYPELIB_DANGER_RELEASE( pParamTypeDescr );
462
                        }
463
                        INSERT_INT64( &(pCppArgs[nPos]), nGPR, pGPR, pStack, bOverflow );
464
        }
465
    }
466
467
    try
468
    {
469
               callVirtualMethod(
470
                        pAdjustedThisPtr, aVtableSlot.index,
471
                        pCppReturn, pReturnTypeDescr,
472
                        pStackStart, ( pStack - pStackStart ),
473
                        pGPR, nGPR,
474
                        pFPR, nFPR );
475
        // NO exception occurred...
476
        *ppUnoExc = 0;
477
478
        // reconvert temporary params
479
        for ( ; nTempIndices--; )
480
        {
481
            sal_Int32 nIndex = pTempIndices[nTempIndices];
482
            typelib_TypeDescription * pParamTypeDescr = ppTempParamTypeDescr[nTempIndices];
483
484
            if (pParams[nIndex].bIn)
485
            {
486
                if (pParams[nIndex].bOut) // inout
487
                {
488
                    uno_destructData( pUnoArgs[nIndex], pParamTypeDescr, 0 ); // destroy uno value
489
                    uno_copyAndConvertData( pUnoArgs[nIndex], pCppArgs[nIndex], pParamTypeDescr,
490
                                            pThis->getBridge()->getCpp2Uno() );
491
                }
492
            }
493
            else // pure out
494
            {
495
                uno_copyAndConvertData( pUnoArgs[nIndex], pCppArgs[nIndex], pParamTypeDescr,
496
                                        pThis->getBridge()->getCpp2Uno() );
497
            }
498
            // destroy temp cpp param => cpp: every param was constructed
499
            uno_destructData( pCppArgs[nIndex], pParamTypeDescr, cpp_release );
500
501
            TYPELIB_DANGER_RELEASE( pParamTypeDescr );
502
        }
503
        // return value
504
        if (pCppReturn && pUnoReturn != pCppReturn)
505
        {
506
            uno_copyAndConvertData( pUnoReturn, pCppReturn, pReturnTypeDescr,
507
                                    pThis->getBridge()->getCpp2Uno() );
508
            uno_destructData( pCppReturn, pReturnTypeDescr, cpp_release );
509
        }
510
    }
511
     catch (...)
512
     {
513
          // fill uno exception
514
        fillUnoException( CPPU_CURRENT_NAMESPACE::__cxa_get_globals()->caughtExceptions,
515
                                  *ppUnoExc, pThis->getBridge()->getCpp2Uno() );
516
517
        // temporary params
518
        for ( ; nTempIndices--; )
519
        {
520
            sal_Int32 nIndex = pTempIndices[nTempIndices];
521
            // destroy temp cpp param => cpp: every param was constructed
522
            uno_destructData( pCppArgs[nIndex], ppTempParamTypeDescr[nTempIndices], cpp_release );
523
            TYPELIB_DANGER_RELEASE( ppTempParamTypeDescr[nTempIndices] );
524
        }
525
        // return type
526
        if (pReturnTypeDescr)
527
            TYPELIB_DANGER_RELEASE( pReturnTypeDescr );
528
    }
529
}
530
531
}
532
533
namespace bridges { namespace cpp_uno { namespace shared {
534
535
void unoInterfaceProxyDispatch(
536
    uno_Interface * pUnoI, const typelib_TypeDescription * pMemberDescr,
537
    void * pReturn, void * pArgs[], uno_Any ** ppException )
538
{
539
    // is my surrogate
540
    bridges::cpp_uno::shared::UnoInterfaceProxy * pThis
541
        = static_cast< bridges::cpp_uno::shared::UnoInterfaceProxy *> (pUnoI);
542
543
    switch (pMemberDescr->eTypeClass)
544
    {
545
    case typelib_TypeClass_INTERFACE_ATTRIBUTE:
546
    {
547
548
        VtableSlot aVtableSlot(
549
            getVtableSlot(
550
                reinterpret_cast<
551
                    typelib_InterfaceAttributeTypeDescription const * >(
552
                        pMemberDescr)));
553
554
        if (pReturn)
555
        {
556
            // dependent dispatch
557
            cpp_call(
558
                pThis, aVtableSlot,
559
                ((typelib_InterfaceAttributeTypeDescription *)pMemberDescr)->pAttributeTypeRef,
560
                0, 0, // no params
561
                pReturn, pArgs, ppException );
562
        }
563
        else
564
        {
565
            // is SET
566
            typelib_MethodParameter aParam;
567
            aParam.pTypeRef =
568
                ((typelib_InterfaceAttributeTypeDescription *)pMemberDescr)->pAttributeTypeRef;
569
            aParam.bIn      = sal_True;
570
            aParam.bOut     = sal_False;
571
572
            typelib_TypeDescriptionReference * pReturnTypeRef = 0;
573
            OUString aVoidName("void");
574
            typelib_typedescriptionreference_new(
575
                &pReturnTypeRef, typelib_TypeClass_VOID, aVoidName.pData );
576
577
            // dependent dispatch
578
                        aVtableSlot.index += 1; //get then set method
579
            cpp_call(
580
                pThis, aVtableSlot,
581
                pReturnTypeRef,
582
                1, &aParam,
583
                pReturn, pArgs, ppException );
584
585
            typelib_typedescriptionreference_release( pReturnTypeRef );
586
        }
587
588
        break;
589
    }
590
    case typelib_TypeClass_INTERFACE_METHOD:
591
    {
592
593
        VtableSlot aVtableSlot(
594
            getVtableSlot(
595
                reinterpret_cast<
596
                    typelib_InterfaceMethodTypeDescription const * >(
597
                        pMemberDescr)));
598
        switch (aVtableSlot.index)
599
        {
600
            // standard calls
601
        case 1: // acquire uno interface
602
            (*pUnoI->acquire)( pUnoI );
603
            *ppException = 0;
604
            break;
605
        case 2: // release uno interface
606
            (*pUnoI->release)( pUnoI );
607
            *ppException = 0;
608
            break;
609
        case 0: // queryInterface() opt
610
        {
611
            typelib_TypeDescription * pTD = 0;
612
            TYPELIB_DANGER_GET( &pTD, reinterpret_cast< Type * >( pArgs[0] )->getTypeLibType() );
613
            if (pTD)
614
            {
615
                uno_Interface * pInterface = 0;
616
                (*pThis->pBridge->getUnoEnv()->getRegisteredInterface)(
617
                    pThis->pBridge->getUnoEnv(),
618
                    (void **)&pInterface, pThis->oid.pData, (typelib_InterfaceTypeDescription *)pTD );
619
620
                if (pInterface)
621
                {
622
                    ::uno_any_construct(
623
                        reinterpret_cast< uno_Any * >( pReturn ),
624
                        &pInterface, pTD, 0 );
625
                    (*pInterface->release)( pInterface );
626
                    TYPELIB_DANGER_RELEASE( pTD );
627
                    *ppException = 0;
628
                    break;
629
                }
630
                TYPELIB_DANGER_RELEASE( pTD );
631
            }
632
        } // else perform queryInterface()
633
        default:
634
            // dependent dispatch
635
            cpp_call(
636
                pThis, aVtableSlot,
637
                ((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->pReturnTypeRef,
638
                ((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->nParams,
639
                ((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->pParams,
640
                pReturn, pArgs, ppException );
641
        }
642
        break;
643
    }
644
    default:
645
    {
646
        ::com::sun::star::uno::RuntimeException aExc(
647
            OUString("illegal member type description!"),
648
            ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >() );
649
650
        Type const & rExcType = ::getCppuType( &aExc );
651
        // binary identical null reference
652
        ::uno_type_any_construct( *ppException, &aExc, rExcType.getTypeLibType(), 0 );
653
    }
654
    }
655
}
656
657
} } }
658
659
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
(-)solenv/gbuild/platform/FREEBSD_POWERPC64_GCC.mk (+17 lines)
Added Link Here
1
# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
2
#
3
# This file is part of the LibreOffice project.
4
#
5
# This Source Code Form is subject to the terms of the Mozilla Public
6
# License, v. 2.0. If a copy of the MPL was not distributed with this
7
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
8
#
9
10
#please make generic modifications to unxgcc.mk or linux.mk
11
gb_CPUDEFS += -DPPC -DPOWERPC64
12
gb_COMPILERDEFAULTOPTFLAGS := -O2
13
gb_CXXFLAGS += -mminimal-toc
14
15
include $(GBUILDDIR)/platform/unxgcc.mk
16
17
# vim: set noet sw=4:
(-)canvas/source/cairo/cairo_canvashelper.cxx (+1 lines)
Lines 17-22 Link Here
17
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
17
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
18
 */
18
 */
19
19
20
#include <osl/endian.h>
20
#include <canvas/debug.hxx>
21
#include <canvas/debug.hxx>
21
#include <tools/diagnose_ex.h>
22
#include <tools/diagnose_ex.h>
22
23
(-)canvas/source/tools/canvastools.cxx (+2 lines)
Lines 58-63 Link Here
58
#include <vcl/window.hxx>
58
#include <vcl/window.hxx>
59
#include <vcl/canvastools.hxx>
59
#include <vcl/canvastools.hxx>
60
60
61
#include <osl/endian.h>
62
61
#include <canvas/canvastools.hxx>
63
#include <canvas/canvastools.hxx>
62
64
63
#include <limits>
65
#include <limits>
(-)connectivity/source/drivers/odbc/OTools.cxx (-1 / +1 lines)
Lines 26-32 Link Here
26
#include <rtl/ustrbuf.hxx>
26
#include <rtl/ustrbuf.hxx>
27
#include <boost/static_assert.hpp>
27
#include <boost/static_assert.hpp>
28
28
29
29
#include <osl/endian.h>
30
#include <string.h>
30
#include <string.h>
31
#include <string>
31
#include <string>
32
#include <algorithm>
32
#include <algorithm>
(-)cppcanvas/source/inc/implrenderer.hxx (+2 lines)
Lines 30-35 Link Here
30
#include <action.hxx>
30
#include <action.hxx>
31
#include <outdevstate.hxx>
31
#include <outdevstate.hxx>
32
32
33
#include <osl/endian.h>
34
33
#include <vector>
35
#include <vector>
34
#include <map>
36
#include <map>
35
37
(-)desktop/source/deployment/misc/dp_platform.cxx (+3 lines)
Lines 52-57 Link Here
52
#define PLATFORM_SOLARIS_SPARC      "solaris_sparc"
52
#define PLATFORM_SOLARIS_SPARC      "solaris_sparc"
53
#define PLATFORM_SOLARIS_SPARC64    "solaris_sparc64"
53
#define PLATFORM_SOLARIS_SPARC64    "solaris_sparc64"
54
#define PLATFORM_SOLARIS_X86        "solaris_x86"
54
#define PLATFORM_SOLARIS_X86        "solaris_x86"
55
#define PLATFORM_FREEBSD_POWERPC64  "freebsd_powerpc64"
55
#define PLATFORM_FREEBSD_X86        "freebsd_x86"
56
#define PLATFORM_FREEBSD_X86        "freebsd_x86"
56
#define PLATFORM_FREEBSD_X86_64     "freebsd_x86_64"
57
#define PLATFORM_FREEBSD_X86_64     "freebsd_x86_64"
57
#define PLATFORM_NETBSD_X86         "netbsd_x86"
58
#define PLATFORM_NETBSD_X86         "netbsd_x86"
Lines 158-163 Link Here
158
            ret = checkOSandCPU("Solaris", "SPARC64");
159
            ret = checkOSandCPU("Solaris", "SPARC64");
159
        else if (token == PLATFORM_SOLARIS_X86)
160
        else if (token == PLATFORM_SOLARIS_X86)
160
            ret = checkOSandCPU("Solaris", "x86");
161
            ret = checkOSandCPU("Solaris", "x86");
162
        else if (token == PLATFORM_FREEBSD_POWERPC64)
163
            ret = checkOSandCPU("FreeBSD", "POWERPC64");
161
        else if (token == PLATFORM_FREEBSD_X86)
164
        else if (token == PLATFORM_FREEBSD_X86)
162
            ret = checkOSandCPU("FreeBSD", "x86");
165
            ret = checkOSandCPU("FreeBSD", "x86");
163
        else if (token == PLATFORM_FREEBSD_X86_64)
166
        else if (token == PLATFORM_FREEBSD_X86_64)
(-)include/basebmp/rgbmaskpixelformats.hxx (+2 lines)
Lines 31-36 Link Here
31
#include <vigra/numerictraits.hxx>
31
#include <vigra/numerictraits.hxx>
32
#include <vigra/metaprogramming.hxx>
32
#include <vigra/metaprogramming.hxx>
33
33
34
#include <osl/endian.h>
35
34
#include <functional>
36
#include <functional>
35
37
36
namespace basebmp
38
namespace basebmp
(-)include/osl/endian.h (-7 / +5 lines)
Lines 80-92 Link Here
80
#ifdef FREEBSD
80
#ifdef FREEBSD
81
#   include <sys/param.h>
81
#   include <sys/param.h>
82
#   include <machine/endian.h>
82
#   include <machine/endian.h>
83
#if __FreeBSD_version < 500000
83
#   if BYTE_ORDER == LITTLE_ENDIAN
84
#   if BYTE_ORDER == LITTLE_ENDIAN
84
#   undef _BIG_ENDIAN
85
#       define _LITTLE_ENDIAN
85
#   elif BYTE_ORDER == BIG_ENDIAN
86
#   elif BYTE_ORDER == BIG_ENDIAN
86
#   undef _LITTLE_ENDIAN
87
#       define _BIG_ENDIAN
87
#   endif
88
#   endif
89
#endif
90
#endif
88
#endif
91
89
92
#ifdef AIX
90
#ifdef AIX
(-)include/tools/stream.hxx (+1 lines)
Lines 27-32 Link Here
27
#include <tools/ref.hxx>
27
#include <tools/ref.hxx>
28
#include <tools/rtti.hxx>
28
#include <tools/rtti.hxx>
29
#include <rtl/string.hxx>
29
#include <rtl/string.hxx>
30
#include <osl/endian.h>
30
31
31
class StreamData;
32
class StreamData;
32
33
(-)lotuswordpro/source/filter/lwpobjstrm.cxx (+2 lines)
Lines 61-66 Link Here
61
#include "lwpobjstrm.hxx"
61
#include "lwpobjstrm.hxx"
62
#include "lwptools.hxx"
62
#include "lwptools.hxx"
63
#include <boost/scoped_array.hpp>
63
#include <boost/scoped_array.hpp>
64
65
#include <osl/endian.h>
64
66
65
/**
67
/**
66
 * @descr  ctor() from LwpSvStream
68
 * @descr  ctor() from LwpSvStream
(-)oox/source/helper/binaryoutputstream.cxx (+2 lines)
Lines 23-28 Link Here
23
#include <com/sun/star/io/XSeekable.hpp>
23
#include <com/sun/star/io/XSeekable.hpp>
24
#include <osl/diagnose.h>
24
#include <osl/diagnose.h>
25
#include <string.h>
25
#include <string.h>
26
27
#include <osl/endian.h>
26
28
27
namespace oox {
29
namespace oox {
28
30
(-)store/workben/t_page.cxx (+1 lines)
Lines 26-31 Link Here
26
26
27
#include "storbase.hxx"
27
#include "storbase.hxx"
28
28
29
#include "osl/endian.h"
29
#include "osl/file.h"
30
#include "osl/file.h"
30
#include "rtl/ustring.hxx"
31
#include "rtl/ustring.hxx"
31
32
(-)sw/source/filter/ww8/ww8scan.cxx (+1 lines)
Lines 23-28 Link Here
23
#include <functional>
23
#include <functional>
24
#include <algorithm>
24
#include <algorithm>
25
25
26
#include <osl/endian.h>
26
#include <string.h>
27
#include <string.h>
27
#include <i18nlangtag/mslangid.hxx>
28
#include <i18nlangtag/mslangid.hxx>
28
#include <sprmids.hxx>
29
#include <sprmids.hxx>
(-)sw/source/filter/ww8/ww8scan.hxx (+1 lines)
Lines 31-36 Link Here
31
#include <algorithm>
31
#include <algorithm>
32
32
33
#include <boost/unordered_map.hpp>
33
#include <boost/unordered_map.hpp>
34
#include <osl/endian.h>
34
#include <tools/solar.h>
35
#include <tools/solar.h>
35
#include <tools/stream.hxx>
36
#include <tools/stream.hxx>
36
#include <rtl/ustring.hxx>
37
#include <rtl/ustring.hxx>
(-)sw/source/core/uibase/dochdl/swdtflvr.cxx (+2 lines)
Lines 118-123 Link Here
118
#include <swserv.hxx>
118
#include <swserv.hxx>
119
#include <switerator.hxx>
119
#include <switerator.hxx>
120
120
121
#include <osl/endian.h>
122
121
#include <vcl/GraphicNativeTransform.hxx>
123
#include <vcl/GraphicNativeTransform.hxx>
122
#include <vcl/GraphicNativeMetadata.hxx>
124
#include <vcl/GraphicNativeMetadata.hxx>
123
125
(-)testtools/CustomTarget_uno_test.mk (-12 / +12 lines)
Lines 13-29 Link Here
13
.PHONY : $(call gb_CustomTarget_get_target,testtools/uno_test)
13
.PHONY : $(call gb_CustomTarget_get_target,testtools/uno_test)
14
14
15
$(call gb_CustomTarget_get_target,testtools/uno_test) : \
15
$(call gb_CustomTarget_get_target,testtools/uno_test) : \
16
		$(call gb_Executable_get_runtime_dependencies,uno) \
16
#		$(call gb_Executable_get_runtime_dependencies,uno) \
17
		$(call gb_InternalUnoApi_get_target,bridgetest) \
17
#		$(call gb_InternalUnoApi_get_target,bridgetest) \
18
		$(call gb_Rdb_get_target,uno_services) \
18
#		$(call gb_Rdb_get_target,uno_services) \
19
		$(call gb_Rdb_get_target,ure/services) \
19
#		$(call gb_Rdb_get_target,ure/services) \
20
		$(call gb_UnoApi_get_target,udkapi)
20
#		$(call gb_UnoApi_get_target,udkapi)
21
	$(call gb_Helper_abbreviate_dirs,\
21
#	$(call gb_Helper_abbreviate_dirs,\
22
		$(call gb_Executable_get_command,uno) \
22
#		$(call gb_Executable_get_command,uno) \
23
		-s com.sun.star.test.bridge.BridgeTest \
23
#		-s com.sun.star.test.bridge.BridgeTest \
24
		-- com.sun.star.test.bridge.CppTestObject \
24
#		-- com.sun.star.test.bridge.CppTestObject \
25
		-env:LO_BUILD_LIB_DIR=$(call gb_Helper_make_url,$(gb_Library_WORKDIR_FOR_BUILD)) \
25
#		-env:LO_BUILD_LIB_DIR=$(call gb_Helper_make_url,$(gb_Library_WORKDIR_FOR_BUILD)) \
26
		-env:URE_MORE_SERVICES=$(call gb_Helper_make_url,$(call gb_Rdb_get_target,uno_services)) \
26
#		-env:URE_MORE_SERVICES=$(call gb_Helper_make_url,$(call gb_Rdb_get_target,uno_services)) \
27
		-env:URE_MORE_TYPES=$(call gb_Helper_make_url,$(WORKDIR)/UnoApiTarget/bridgetest.rdb))
27
#		-env:URE_MORE_TYPES=$(call gb_Helper_make_url,$(WORKDIR)/UnoApiTarget/bridgetest.rdb))
28
28
29
# vim:set shiftwidth=4 tabstop=4 noexpandtab:
29
# vim:set shiftwidth=4 tabstop=4 noexpandtab:
(-)vcl/generic/glyphs/gcach_ftyp.cxx (+1 lines)
Lines 36-41 Link Here
36
#include "basegfx/matrix/b2dhommatrixtools.hxx"
36
#include "basegfx/matrix/b2dhommatrixtools.hxx"
37
#include "basegfx/polygon/b2dpolypolygon.hxx"
37
#include "basegfx/polygon/b2dpolypolygon.hxx"
38
38
39
#include "osl/endian.h"
39
#include "osl/file.hxx"
40
#include "osl/file.hxx"
40
#include "osl/thread.hxx"
41
#include "osl/thread.hxx"
41
42
(-)vcl/headless/svpvd.cxx (+2 lines)
Lines 18-23 Link Here
18
 */
18
 */
19
19
20
#ifndef IOS
20
#ifndef IOS
21
22
#include <osl/endian.h>
21
23
22
#include "headless/svpbmp.hxx"
24
#include "headless/svpbmp.hxx"
23
#include "headless/svpvd.hxx"
25
#include "headless/svpvd.hxx"
(-)vcl/headless/svpgdi.cxx (+2 lines)
Lines 21-26 Link Here
21
#include "headless/svpbmp.hxx"
21
#include "headless/svpbmp.hxx"
22
#include "saldatabasic.hxx"
22
#include "saldatabasic.hxx"
23
23
24
#include <osl/endian.h>
25
24
#include <vcl/sysdata.hxx>
26
#include <vcl/sysdata.hxx>
25
#include <basegfx/range/b2drange.hxx>
27
#include <basegfx/range/b2drange.hxx>
26
#include <basegfx/range/b2ibox.hxx>
28
#include <basegfx/range/b2ibox.hxx>
(-)vcl/headless/svpbmp.cxx (+2 lines)
Lines 26-31 Link Here
26
#include <basebmp/scanlineformats.hxx>
26
#include <basebmp/scanlineformats.hxx>
27
#include <basebmp/color.hxx>
27
#include <basebmp/color.hxx>
28
28
29
#include <osl/endian.h>
30
29
#include <vcl/salbtype.hxx>
31
#include <vcl/salbtype.hxx>
30
#include <vcl/bitmap.hxx>
32
#include <vcl/bitmap.hxx>
31
33
(-)vcl/source/filter/jpeg/Exif.cxx (+1 lines)
Lines 19-24 Link Here
19
19
20
#include "Exif.hxx"
20
#include "Exif.hxx"
21
#include <boost/scoped_array.hpp>
21
#include <boost/scoped_array.hpp>
22
#include <osl/endian.h>
22
23
23
Exif::Exif() :
24
Exif::Exif() :
24
    maOrientation(TOP_LEFT),
25
    maOrientation(TOP_LEFT),

Return to bug 200020