|
Link Here
|
| 1 |
--- configure.ac.orig |
| 2 |
+++ configure.ac |
| 3 |
@@ -4189,6 +4189,11 @@ |
| 4 |
CPUNAME=X86_64 |
| 5 |
RTL_ARCH=X86_64 |
| 6 |
PLATFORMID=freebsd_x86_64 |
| 7 |
+ ;; |
| 8 |
+ powerpc64) |
| 9 |
+ CPUNAME=POWERPC64 |
| 10 |
+ RTL_ARCH=PowerPC_64 |
| 11 |
+ PLATFORMID=freebsd_powerpc64 |
| 12 |
;; |
| 13 |
*) |
| 14 |
AC_MSG_ERROR([Unsupported host_cpu $host_cpu for host_os $host_os]) |
| 15 |
--- bridges/Library_cpp_uno.mk.orig |
| 16 |
+++ bridges/Library_cpp_uno.mk |
| 17 |
@@ -118,6 +118,12 @@ |
| 18 |
bridge_asm_objects := call |
| 19 |
bridge_noopt_objects := except |
| 20 |
bridge_exception_objects := cpp2uno uno2cpp |
| 21 |
+ |
| 22 |
+else ifeq ($(OS)-$(CPUNAME),FREEBSD-POWERPC64) |
| 23 |
+ |
| 24 |
+bridges_SELECTED_BRIDGE := gcc3_freebsd_powerpc64 |
| 25 |
+bridge_noopt_objects := cpp2uno uno2cpp |
| 26 |
+bridge_exception_objects := except |
| 27 |
|
| 28 |
else ifeq ($(CPUNAME),X86_64) |
| 29 |
|
| 30 |
--- /dev/null |
| 31 |
+++ bridges/source/cpp_uno/gcc3_freebsd_powerpc64/cpp2uno.cxx |
| 32 |
@@ -0,0 +1,743 @@ |
| 33 |
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
| 34 |
+/* |
| 35 |
+ * This file is part of the LibreOffice project. |
| 36 |
+ * |
| 37 |
+ * This Source Code Form is subject to the terms of the Mozilla Public |
| 38 |
+ * License, v. 2.0. If a copy of the MPL was not distributed with this |
| 39 |
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| 40 |
+ * |
| 41 |
+ * This file incorporates work covered by the following license notice: |
| 42 |
+ * |
| 43 |
+ * Licensed to the Apache Software Foundation (ASF) under one or more |
| 44 |
+ * contributor license agreements. See the NOTICE file distributed |
| 45 |
+ * with this work for additional information regarding copyright |
| 46 |
+ * ownership. The ASF licenses this file to you under the Apache |
| 47 |
+ * License, Version 2.0 (the "License"); you may not use this file |
| 48 |
+ * except in compliance with the License. You may obtain a copy of |
| 49 |
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 . |
| 50 |
+ */ |
| 51 |
+ |
| 52 |
+ |
| 53 |
+#include <com/sun/star/uno/genfunc.hxx> |
| 54 |
+#include <uno/data.h> |
| 55 |
+#include <typelib/typedescription.hxx> |
| 56 |
+#include <osl/endian.h> |
| 57 |
+#include "bridges/cpp_uno/shared/bridge.hxx" |
| 58 |
+#include "bridges/cpp_uno/shared/cppinterfaceproxy.hxx" |
| 59 |
+#include "bridges/cpp_uno/shared/types.hxx" |
| 60 |
+#include "bridges/cpp_uno/shared/vtablefactory.hxx" |
| 61 |
+ |
| 62 |
+#include "share.hxx" |
| 63 |
+#include <stdio.h> |
| 64 |
+#include <string.h> |
| 65 |
+ |
| 66 |
+#ifdef OSL_BIGENDIAN |
| 67 |
+#define IS_BIG_ENDIAN 1 |
| 68 |
+#else |
| 69 |
+#define IS_BIG_ENDIAN 0 |
| 70 |
+#endif |
| 71 |
+ |
| 72 |
+using namespace ::com::sun::star::uno; |
| 73 |
+ |
| 74 |
+namespace |
| 75 |
+{ |
| 76 |
+ |
| 77 |
+ |
| 78 |
+static typelib_TypeClass cpp2uno_call( |
| 79 |
+ bridges::cpp_uno::shared::CppInterfaceProxy * pThis, |
| 80 |
+ const typelib_TypeDescription * pMemberTypeDescr, |
| 81 |
+ typelib_TypeDescriptionReference * pReturnTypeRef, // 0 indicates void return |
| 82 |
+ sal_Int32 nParams, typelib_MethodParameter * pParams, |
| 83 |
+ void ** gpreg, void ** fpreg, void ** ovrflw, |
| 84 |
+ sal_Int64 * pRegisterReturn /* space for register return */ ) |
| 85 |
+{ |
| 86 |
+#if OSL_DEBUG_LEVEL > 2 |
| 87 |
+ fprintf(stderr, "as far as cpp2uno_call\n"); |
| 88 |
+#endif |
| 89 |
+ |
| 90 |
+ int ng = 0; //number of gpr registers used |
| 91 |
+ int nf = 0; //number of fpr regsiters used |
| 92 |
+ |
| 93 |
+ // gpreg: [ret *], this, [gpr params] |
| 94 |
+ // fpreg: [fpr params] |
| 95 |
+ // ovrflw: [gpr or fpr params (properly aligned)] |
| 96 |
+ |
| 97 |
+ // return |
| 98 |
+ typelib_TypeDescription * pReturnTypeDescr = 0; |
| 99 |
+ if (pReturnTypeRef) |
| 100 |
+ TYPELIB_DANGER_GET( &pReturnTypeDescr, pReturnTypeRef ); |
| 101 |
+ |
| 102 |
+ void * pUnoReturn = 0; |
| 103 |
+ void * pCppReturn = 0; // complex return ptr: if != 0 && != pUnoReturn, reconversion need |
| 104 |
+ |
| 105 |
+ if (pReturnTypeDescr) |
| 106 |
+ { |
| 107 |
+ if (!ppc64::return_in_hidden_param(pReturnTypeRef)) |
| 108 |
+ { |
| 109 |
+ pUnoReturn = pRegisterReturn; // direct way for simple types |
| 110 |
+ } |
| 111 |
+ else // complex return via ptr (pCppReturn) |
| 112 |
+ { |
| 113 |
+ pCppReturn = *(void **)gpreg; |
| 114 |
+ gpreg++; |
| 115 |
+ ng++; |
| 116 |
+ |
| 117 |
+ pUnoReturn = (bridges::cpp_uno::shared::relatesToInterfaceType( pReturnTypeDescr ) |
| 118 |
+ ? alloca( pReturnTypeDescr->nSize ) |
| 119 |
+ : pCppReturn); // direct way |
| 120 |
+ } |
| 121 |
+ } |
| 122 |
+ // pop this |
| 123 |
+ gpreg++; |
| 124 |
+ ng++; |
| 125 |
+ |
| 126 |
+ // stack space |
| 127 |
+ OSL_ENSURE( sizeof(void *) == sizeof(sal_Int64), "### unexpected size!" ); |
| 128 |
+ // parameters |
| 129 |
+ void ** pUnoArgs = (void **)alloca( 4 * sizeof(void *) * nParams ); |
| 130 |
+ void ** pCppArgs = pUnoArgs + nParams; |
| 131 |
+ // indices of values this have to be converted (interface conversion cpp<=>uno) |
| 132 |
+ sal_Int32 * pTempIndices = (sal_Int32 *)(pUnoArgs + (2 * nParams)); |
| 133 |
+ // type descriptions for reconversions |
| 134 |
+ typelib_TypeDescription ** ppTempParamTypeDescr = (typelib_TypeDescription **)(pUnoArgs + (3 * nParams)); |
| 135 |
+ |
| 136 |
+ sal_Int32 nTempIndices = 0; |
| 137 |
+ bool bOverflowUsed = false; |
| 138 |
+ for ( sal_Int32 nPos = 0; nPos < nParams; ++nPos ) |
| 139 |
+ { |
| 140 |
+ const typelib_MethodParameter & rParam = pParams[nPos]; |
| 141 |
+ typelib_TypeDescription * pParamTypeDescr = 0; |
| 142 |
+ TYPELIB_DANGER_GET( &pParamTypeDescr, rParam.pTypeRef ); |
| 143 |
+ |
| 144 |
+#if OSL_DEBUG_LEVEL > 2 |
| 145 |
+ fprintf(stderr, "arg %d of %d\n", nPos, nParams); |
| 146 |
+#endif |
| 147 |
+ |
| 148 |
+ if (!rParam.bOut && bridges::cpp_uno::shared::isSimpleType( pParamTypeDescr )) |
| 149 |
+ { |
| 150 |
+#if OSL_DEBUG_LEVEL > 2 |
| 151 |
+ fprintf(stderr, "simple\n"); |
| 152 |
+#endif |
| 153 |
+ |
| 154 |
+ switch (pParamTypeDescr->eTypeClass) |
| 155 |
+ { |
| 156 |
+ case typelib_TypeClass_FLOAT: |
| 157 |
+ case typelib_TypeClass_DOUBLE: |
| 158 |
+ if (nf < ppc64::MAX_SSE_REGS) |
| 159 |
+ { |
| 160 |
+ if (pParamTypeDescr->eTypeClass == typelib_TypeClass_FLOAT) |
| 161 |
+ { |
| 162 |
+ float tmp = (float) (*((double *)fpreg)); |
| 163 |
+ (*((float *) fpreg)) = tmp; |
| 164 |
+ } |
| 165 |
+ pCppArgs[nPos] = pUnoArgs[nPos] = fpreg++; |
| 166 |
+ nf++; |
| 167 |
+ } |
| 168 |
+ else |
| 169 |
+ { |
| 170 |
+ pCppArgs[nPos] = pUnoArgs[nPos] = ovrflw; |
| 171 |
+ bOverflowUsed = true; |
| 172 |
+ } |
| 173 |
+ if (bOverflowUsed) ovrflw++; |
| 174 |
+ break; |
| 175 |
+ case typelib_TypeClass_BYTE: |
| 176 |
+ case typelib_TypeClass_BOOLEAN: |
| 177 |
+ if (ng < ppc64::MAX_GPR_REGS) |
| 178 |
+ { |
| 179 |
+ pCppArgs[nPos] = pUnoArgs[nPos] = (((char *)gpreg) + 7*IS_BIG_ENDIAN); |
| 180 |
+ ng++; |
| 181 |
+ gpreg++; |
| 182 |
+ } |
| 183 |
+ else |
| 184 |
+ { |
| 185 |
+ pCppArgs[nPos] = pUnoArgs[nPos] = (((char *)ovrflw) + 7*IS_BIG_ENDIAN); |
| 186 |
+ bOverflowUsed = true; |
| 187 |
+ } |
| 188 |
+ if (bOverflowUsed) ovrflw++; |
| 189 |
+ break; |
| 190 |
+ case typelib_TypeClass_CHAR: |
| 191 |
+ case typelib_TypeClass_SHORT: |
| 192 |
+ case typelib_TypeClass_UNSIGNED_SHORT: |
| 193 |
+ if (ng < ppc64::MAX_GPR_REGS) |
| 194 |
+ { |
| 195 |
+ pCppArgs[nPos] = pUnoArgs[nPos] = (((char *)gpreg) + 6*IS_BIG_ENDIAN); |
| 196 |
+ ng++; |
| 197 |
+ gpreg++; |
| 198 |
+ } |
| 199 |
+ else |
| 200 |
+ { |
| 201 |
+ pCppArgs[nPos] = pUnoArgs[nPos] = (((char *)ovrflw) + 6*IS_BIG_ENDIAN); |
| 202 |
+ bOverflowUsed = true; |
| 203 |
+ } |
| 204 |
+ if (bOverflowUsed) ovrflw++; |
| 205 |
+ break; |
| 206 |
+ case typelib_TypeClass_ENUM: |
| 207 |
+ case typelib_TypeClass_LONG: |
| 208 |
+ case typelib_TypeClass_UNSIGNED_LONG: |
| 209 |
+ if (ng < ppc64::MAX_GPR_REGS) |
| 210 |
+ { |
| 211 |
+ pCppArgs[nPos] = pUnoArgs[nPos] = (((char *)gpreg) + 4*IS_BIG_ENDIAN); |
| 212 |
+ ng++; |
| 213 |
+ gpreg++; |
| 214 |
+ } |
| 215 |
+ else |
| 216 |
+ { |
| 217 |
+ pCppArgs[nPos] = pUnoArgs[nPos] = (((char *)ovrflw) + 4*IS_BIG_ENDIAN); |
| 218 |
+ bOverflowUsed = true; |
| 219 |
+ } |
| 220 |
+ if (bOverflowUsed) ovrflw++; |
| 221 |
+ break; |
| 222 |
+ default: |
| 223 |
+ if (ng < ppc64::MAX_GPR_REGS) |
| 224 |
+ { |
| 225 |
+ pCppArgs[nPos] = pUnoArgs[nPos] = gpreg++; |
| 226 |
+ ng++; |
| 227 |
+ } |
| 228 |
+ else |
| 229 |
+ { |
| 230 |
+ pCppArgs[nPos] = pUnoArgs[nPos] = ovrflw; |
| 231 |
+ bOverflowUsed = true; |
| 232 |
+ } |
| 233 |
+ if (bOverflowUsed) ovrflw++; |
| 234 |
+ break; |
| 235 |
+ } |
| 236 |
+ |
| 237 |
+ // no longer needed |
| 238 |
+ TYPELIB_DANGER_RELEASE( pParamTypeDescr ); |
| 239 |
+ } |
| 240 |
+ else // ptr to complex value | ref |
| 241 |
+ { |
| 242 |
+#if OSL_DEBUG_LEVEL > 2 |
| 243 |
+ fprintf(stderr, "complex, ng is %d\n", ng); |
| 244 |
+#endif |
| 245 |
+ void *pCppStack; //temporary stack pointer |
| 246 |
+ |
| 247 |
+ if (ng < ppc64::MAX_GPR_REGS) |
| 248 |
+ { |
| 249 |
+ pCppArgs[nPos] = pCppStack = *gpreg++; |
| 250 |
+ ng++; |
| 251 |
+ } |
| 252 |
+ else |
| 253 |
+ { |
| 254 |
+ pCppArgs[nPos] = pCppStack = *ovrflw; |
| 255 |
+ bOverflowUsed = true; |
| 256 |
+ } |
| 257 |
+ if (bOverflowUsed) ovrflw++; |
| 258 |
+ |
| 259 |
+ if (! rParam.bIn) // is pure out |
| 260 |
+ { |
| 261 |
+ // uno out is unconstructed mem! |
| 262 |
+ pUnoArgs[nPos] = alloca( pParamTypeDescr->nSize ); |
| 263 |
+ pTempIndices[nTempIndices] = nPos; |
| 264 |
+ // will be released at reconversion |
| 265 |
+ ppTempParamTypeDescr[nTempIndices++] = pParamTypeDescr; |
| 266 |
+ } |
| 267 |
+ // is in/inout |
| 268 |
+ else if (bridges::cpp_uno::shared::relatesToInterfaceType( pParamTypeDescr )) |
| 269 |
+ { |
| 270 |
+ uno_copyAndConvertData( pUnoArgs[nPos] = alloca( pParamTypeDescr->nSize ), |
| 271 |
+ pCppStack, pParamTypeDescr, |
| 272 |
+ pThis->getBridge()->getCpp2Uno() ); |
| 273 |
+ pTempIndices[nTempIndices] = nPos; // has to be reconverted |
| 274 |
+ // will be released at reconversion |
| 275 |
+ ppTempParamTypeDescr[nTempIndices++] = pParamTypeDescr; |
| 276 |
+ } |
| 277 |
+ else // direct way |
| 278 |
+ { |
| 279 |
+ pUnoArgs[nPos] = pCppStack; |
| 280 |
+ // no longer needed |
| 281 |
+ TYPELIB_DANGER_RELEASE( pParamTypeDescr ); |
| 282 |
+ } |
| 283 |
+ } |
| 284 |
+ } |
| 285 |
+ |
| 286 |
+#if OSL_DEBUG_LEVEL > 2 |
| 287 |
+ fprintf(stderr, "end of params\n"); |
| 288 |
+#endif |
| 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->getUnoI()->pDispatcher)( pThis->getUnoI(), pMemberTypeDescr, pUnoReturn, pUnoArgs, &pUnoExc ); |
| 296 |
+ |
| 297 |
+ // in case an exception occurred... |
| 298 |
+ if (pUnoExc) |
| 299 |
+ { |
| 300 |
+ // destruct temporary in/inout params |
| 301 |
+ for ( ; nTempIndices--; ) |
| 302 |
+ { |
| 303 |
+ sal_Int32 nIndex = pTempIndices[nTempIndices]; |
| 304 |
+ |
| 305 |
+ if (pParams[nIndex].bIn) // is in/inout => was constructed |
| 306 |
+ uno_destructData( pUnoArgs[nIndex], ppTempParamTypeDescr[nTempIndices], 0 ); |
| 307 |
+ TYPELIB_DANGER_RELEASE( ppTempParamTypeDescr[nTempIndices] ); |
| 308 |
+ } |
| 309 |
+ if (pReturnTypeDescr) |
| 310 |
+ TYPELIB_DANGER_RELEASE( pReturnTypeDescr ); |
| 311 |
+ |
| 312 |
+ CPPU_CURRENT_NAMESPACE::raiseException( &aUnoExc, pThis->getBridge()->getUno2Cpp() ); |
| 313 |
+ // has to destruct the any |
| 314 |
+ // is here for dummy |
| 315 |
+ return typelib_TypeClass_VOID; |
| 316 |
+ } |
| 317 |
+ else // else no exception occurred... |
| 318 |
+ { |
| 319 |
+ // temporary params |
| 320 |
+ for ( ; nTempIndices--; ) |
| 321 |
+ { |
| 322 |
+ sal_Int32 nIndex = pTempIndices[nTempIndices]; |
| 323 |
+ typelib_TypeDescription * pParamTypeDescr = ppTempParamTypeDescr[nTempIndices]; |
| 324 |
+ |
| 325 |
+ if (pParams[nIndex].bOut) // inout/out |
| 326 |
+ { |
| 327 |
+ // convert and assign |
| 328 |
+ uno_destructData( pCppArgs[nIndex], pParamTypeDescr, cpp_release ); |
| 329 |
+ uno_copyAndConvertData( pCppArgs[nIndex], pUnoArgs[nIndex], pParamTypeDescr, |
| 330 |
+ pThis->getBridge()->getUno2Cpp() ); |
| 331 |
+ } |
| 332 |
+ // destroy temp uno param |
| 333 |
+ uno_destructData( pUnoArgs[nIndex], pParamTypeDescr, 0 ); |
| 334 |
+ |
| 335 |
+ TYPELIB_DANGER_RELEASE( pParamTypeDescr ); |
| 336 |
+ } |
| 337 |
+ // return |
| 338 |
+ if (pCppReturn) // has complex return |
| 339 |
+ { |
| 340 |
+ if (pUnoReturn != pCppReturn) // needs reconversion |
| 341 |
+ { |
| 342 |
+ uno_copyAndConvertData( pCppReturn, pUnoReturn, pReturnTypeDescr, |
| 343 |
+ pThis->getBridge()->getUno2Cpp() ); |
| 344 |
+ // destroy temp uno return |
| 345 |
+ uno_destructData( pUnoReturn, pReturnTypeDescr, 0 ); |
| 346 |
+ } |
| 347 |
+ // complex return ptr is set to return reg |
| 348 |
+ *(void **)pRegisterReturn = pCppReturn; |
| 349 |
+ } |
| 350 |
+ if (pReturnTypeDescr) |
| 351 |
+ { |
| 352 |
+ typelib_TypeClass eRet = (typelib_TypeClass)pReturnTypeDescr->eTypeClass; |
| 353 |
+ TYPELIB_DANGER_RELEASE( pReturnTypeDescr ); |
| 354 |
+ return eRet; |
| 355 |
+ } |
| 356 |
+ else |
| 357 |
+ return typelib_TypeClass_VOID; |
| 358 |
+ } |
| 359 |
+} |
| 360 |
+ |
| 361 |
+#if _CALL_ELF == 2 |
| 362 |
+# define PARAMSAVE 32 |
| 363 |
+#else |
| 364 |
+# define PARAMSAVE 48 |
| 365 |
+#endif |
| 366 |
+ |
| 367 |
+static typelib_TypeClass cpp_mediate( |
| 368 |
+ sal_uInt64 nOffsetAndIndex, |
| 369 |
+ void ** gpreg, void ** fpreg, long sp, |
| 370 |
+ sal_Int64 * pRegisterReturn /* space for register return */ ) |
| 371 |
+{ |
| 372 |
+ OSL_ENSURE( sizeof(sal_Int64)==sizeof(void *), "### unexpected!" ); |
| 373 |
+ |
| 374 |
+ sal_Int32 nVtableOffset = (nOffsetAndIndex >> 32); |
| 375 |
+ sal_Int32 nFunctionIndex = (nOffsetAndIndex & 0xFFFFFFFF); |
| 376 |
+ |
| 377 |
+ long sf = *(long*)sp; |
| 378 |
+ void ** ovrflw = (void**)(sf + PARAMSAVE + 64); |
| 379 |
+ |
| 380 |
+ // gpreg: [ret *], this, [other gpr params] |
| 381 |
+ // fpreg: [fpr params] |
| 382 |
+ // ovrflw: [gpr or fpr params (properly aligned)] |
| 383 |
+ |
| 384 |
+ void * pThis; |
| 385 |
+ if (nFunctionIndex & 0x80000000 ) |
| 386 |
+ { |
| 387 |
+ nFunctionIndex &= 0x7fffffff; |
| 388 |
+ pThis = gpreg[1]; |
| 389 |
+#if OSL_DEBUG_LEVEL > 2 |
| 390 |
+ fprintf(stderr, "pThis is gpreg[1]\n"); |
| 391 |
+#endif |
| 392 |
+ } |
| 393 |
+ else |
| 394 |
+ { |
| 395 |
+ pThis = gpreg[0]; |
| 396 |
+#if OSL_DEBUG_LEVEL > 2 |
| 397 |
+ fprintf(stderr, "pThis is gpreg[0]\n"); |
| 398 |
+#endif |
| 399 |
+ } |
| 400 |
+ |
| 401 |
+#if OSL_DEBUG_LEVEL > 2 |
| 402 |
+ fprintf(stderr, "pThis is %lx\n", pThis); |
| 403 |
+#endif |
| 404 |
+ |
| 405 |
+ pThis = static_cast< char * >(pThis) - nVtableOffset; |
| 406 |
+ |
| 407 |
+#if OSL_DEBUG_LEVEL > 2 |
| 408 |
+ fprintf(stderr, "pThis is now %lx\n", pThis); |
| 409 |
+#endif |
| 410 |
+ |
| 411 |
+ bridges::cpp_uno::shared::CppInterfaceProxy * pCppI |
| 412 |
+ = bridges::cpp_uno::shared::CppInterfaceProxy::castInterfaceToProxy( |
| 413 |
+ pThis); |
| 414 |
+ |
| 415 |
+ typelib_InterfaceTypeDescription * pTypeDescr = pCppI->getTypeDescr(); |
| 416 |
+ |
| 417 |
+#if OSL_DEBUG_LEVEL > 2 |
| 418 |
+ fprintf(stderr, "indexes are %d %d\n", nFunctionIndex, pTypeDescr->nMapFunctionIndexToMemberIndex); |
| 419 |
+#endif |
| 420 |
+ |
| 421 |
+ OSL_ENSURE( nFunctionIndex < pTypeDescr->nMapFunctionIndexToMemberIndex, "### illegal vtable index!" ); |
| 422 |
+ if (nFunctionIndex >= pTypeDescr->nMapFunctionIndexToMemberIndex) |
| 423 |
+ { |
| 424 |
+ throw RuntimeException( |
| 425 |
+ OUString( "illegal vtable index!" ), |
| 426 |
+ (XInterface *)pThis ); |
| 427 |
+ } |
| 428 |
+ |
| 429 |
+ // determine called method |
| 430 |
+ sal_Int32 nMemberPos = pTypeDescr->pMapFunctionIndexToMemberIndex[nFunctionIndex]; |
| 431 |
+ OSL_ENSURE( nMemberPos < pTypeDescr->nAllMembers, "### illegal member index!" ); |
| 432 |
+ |
| 433 |
+#if OSL_DEBUG_LEVEL > 2 |
| 434 |
+ fprintf(stderr, "members are %d %d\n", nMemberPos, pTypeDescr->nAllMembers); |
| 435 |
+#endif |
| 436 |
+ |
| 437 |
+ TypeDescription aMemberDescr( pTypeDescr->ppAllMembers[nMemberPos] ); |
| 438 |
+ |
| 439 |
+ typelib_TypeClass eRet; |
| 440 |
+ switch (aMemberDescr.get()->eTypeClass) |
| 441 |
+ { |
| 442 |
+ case typelib_TypeClass_INTERFACE_ATTRIBUTE: |
| 443 |
+ { |
| 444 |
+ if (pTypeDescr->pMapMemberIndexToFunctionIndex[nMemberPos] == nFunctionIndex) |
| 445 |
+ { |
| 446 |
+ // is GET method |
| 447 |
+ eRet = cpp2uno_call( |
| 448 |
+ pCppI, aMemberDescr.get(), |
| 449 |
+ ((typelib_InterfaceAttributeTypeDescription *)aMemberDescr.get())->pAttributeTypeRef, |
| 450 |
+ 0, 0, // no params |
| 451 |
+ gpreg, fpreg, ovrflw, pRegisterReturn ); |
| 452 |
+ } |
| 453 |
+ else |
| 454 |
+ { |
| 455 |
+ // is SET method |
| 456 |
+ typelib_MethodParameter aParam; |
| 457 |
+ aParam.pTypeRef = |
| 458 |
+ ((typelib_InterfaceAttributeTypeDescription *)aMemberDescr.get())->pAttributeTypeRef; |
| 459 |
+ aParam.bIn = sal_True; |
| 460 |
+ aParam.bOut = sal_False; |
| 461 |
+ |
| 462 |
+ eRet = cpp2uno_call( |
| 463 |
+ pCppI, aMemberDescr.get(), |
| 464 |
+ 0, // indicates void return |
| 465 |
+ 1, &aParam, |
| 466 |
+ gpreg, fpreg, ovrflw, pRegisterReturn ); |
| 467 |
+ } |
| 468 |
+ break; |
| 469 |
+ } |
| 470 |
+ case typelib_TypeClass_INTERFACE_METHOD: |
| 471 |
+ { |
| 472 |
+ // is METHOD |
| 473 |
+ switch (nFunctionIndex) |
| 474 |
+ { |
| 475 |
+ case 1: // acquire() |
| 476 |
+ pCppI->acquireProxy(); // non virtual call! |
| 477 |
+ eRet = typelib_TypeClass_VOID; |
| 478 |
+ break; |
| 479 |
+ case 2: // release() |
| 480 |
+ pCppI->releaseProxy(); // non virtual call! |
| 481 |
+ eRet = typelib_TypeClass_VOID; |
| 482 |
+ break; |
| 483 |
+ case 0: // queryInterface() opt |
| 484 |
+ { |
| 485 |
+ typelib_TypeDescription * pTD = 0; |
| 486 |
+ TYPELIB_DANGER_GET( &pTD, reinterpret_cast< Type * >( gpreg[2] )->getTypeLibType() ); |
| 487 |
+ if (pTD) |
| 488 |
+ { |
| 489 |
+ XInterface * pInterface = 0; |
| 490 |
+ (*pCppI->getBridge()->getCppEnv()->getRegisteredInterface)( |
| 491 |
+ pCppI->getBridge()->getCppEnv(), |
| 492 |
+ (void **)&pInterface, pCppI->getOid().pData, |
| 493 |
+ (typelib_InterfaceTypeDescription *)pTD ); |
| 494 |
+ |
| 495 |
+ if (pInterface) |
| 496 |
+ { |
| 497 |
+ ::uno_any_construct( |
| 498 |
+ reinterpret_cast< uno_Any * >( gpreg[0] ), |
| 499 |
+ &pInterface, pTD, cpp_acquire ); |
| 500 |
+ pInterface->release(); |
| 501 |
+ TYPELIB_DANGER_RELEASE( pTD ); |
| 502 |
+ *(void **)pRegisterReturn = gpreg[0]; |
| 503 |
+ eRet = typelib_TypeClass_ANY; |
| 504 |
+ break; |
| 505 |
+ } |
| 506 |
+ TYPELIB_DANGER_RELEASE( pTD ); |
| 507 |
+ } |
| 508 |
+ } // else perform queryInterface() |
| 509 |
+ default: |
| 510 |
+ eRet = cpp2uno_call( |
| 511 |
+ pCppI, aMemberDescr.get(), |
| 512 |
+ ((typelib_InterfaceMethodTypeDescription *)aMemberDescr.get())->pReturnTypeRef, |
| 513 |
+ ((typelib_InterfaceMethodTypeDescription *)aMemberDescr.get())->nParams, |
| 514 |
+ ((typelib_InterfaceMethodTypeDescription *)aMemberDescr.get())->pParams, |
| 515 |
+ gpreg, fpreg, ovrflw, pRegisterReturn ); |
| 516 |
+ } |
| 517 |
+ break; |
| 518 |
+ } |
| 519 |
+ default: |
| 520 |
+ { |
| 521 |
+#if OSL_DEBUG_LEVEL > 2 |
| 522 |
+ fprintf(stderr, "screwed\n"); |
| 523 |
+#endif |
| 524 |
+ |
| 525 |
+ throw RuntimeException( |
| 526 |
+ OUString( "no member description found!" ), |
| 527 |
+ (XInterface *)pThis ); |
| 528 |
+ } |
| 529 |
+ } |
| 530 |
+ |
| 531 |
+#if OSL_DEBUG_LEVEL > 2 |
| 532 |
+ fprintf(stderr, "end of cpp_mediate\n"); |
| 533 |
+#endif |
| 534 |
+ return eRet; |
| 535 |
+} |
| 536 |
+ |
| 537 |
+extern "C" void privateSnippetExecutor( ... ) |
| 538 |
+{ |
| 539 |
+ sal_uInt64 gpreg[ppc64::MAX_GPR_REGS]; |
| 540 |
+ double fpreg[ppc64::MAX_SSE_REGS]; |
| 541 |
+ |
| 542 |
+ __asm__ __volatile__ ( |
| 543 |
+ "std 3, 0(%0)\t\n" |
| 544 |
+ "std 4, 8(%0)\t\n" |
| 545 |
+ "std 5, 16(%0)\t\n" |
| 546 |
+ "std 6, 24(%0)\t\n" |
| 547 |
+ "std 7, 32(%0)\t\n" |
| 548 |
+ "std 8, 40(%0)\t\n" |
| 549 |
+ "std 9, 48(%0)\t\n" |
| 550 |
+ "std 10, 56(%0)\t\n" |
| 551 |
+ "stfd 1, 0(%1)\t\n" |
| 552 |
+ "stfd 2, 8(%1)\t\n" |
| 553 |
+ "stfd 3, 16(%1)\t\n" |
| 554 |
+ "stfd 4, 24(%1)\t\n" |
| 555 |
+ "stfd 5, 32(%1)\t\n" |
| 556 |
+ "stfd 6, 40(%1)\t\n" |
| 557 |
+ "stfd 7, 48(%1)\t\n" |
| 558 |
+ "stfd 8, 56(%1)\t\n" |
| 559 |
+ "stfd 9, 64(%1)\t\n" |
| 560 |
+ "stfd 10, 72(%1)\t\n" |
| 561 |
+ "stfd 11, 80(%1)\t\n" |
| 562 |
+ "stfd 12, 88(%1)\t\n" |
| 563 |
+ "stfd 13, 96(%1)\t\n" |
| 564 |
+ : : "r" (gpreg), "r" (fpreg) |
| 565 |
+ : "r0", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", |
| 566 |
+ "fr1", "fr2", "fr3", "fr4", "fr5", "fr6", "fr7", "fr8", "fr9", |
| 567 |
+ "fr10", "fr11", "fr12", "fr13" |
| 568 |
+ ); |
| 569 |
+ |
| 570 |
+ volatile long nOffsetAndIndex; |
| 571 |
+ |
| 572 |
+ //mr %r3, %r11 # move into arg1 the 64bit value passed from OOo |
| 573 |
+ __asm__ __volatile__ ( |
| 574 |
+ "mr %0, 11\n\t" |
| 575 |
+ : "=r" (nOffsetAndIndex) : ); |
| 576 |
+ |
| 577 |
+ volatile long sp; |
| 578 |
+ |
| 579 |
+ //stack pointer |
| 580 |
+ __asm__ __volatile__ ( |
| 581 |
+ "mr %0, 1\n\t" |
| 582 |
+ : "=r" (sp) : ); |
| 583 |
+ |
| 584 |
+#if _CALL_ELF == 2 |
| 585 |
+ volatile long nRegReturn[2]; |
| 586 |
+#else |
| 587 |
+ volatile long nRegReturn[1]; |
| 588 |
+#endif |
| 589 |
+ |
| 590 |
+ typelib_TypeClass aType = |
| 591 |
+ cpp_mediate( nOffsetAndIndex, (void**)gpreg, (void**)fpreg, sp, (sal_Int64*)nRegReturn); |
| 592 |
+ |
| 593 |
+ switch( aType ) |
| 594 |
+ { |
| 595 |
+ case typelib_TypeClass_VOID: |
| 596 |
+ break; |
| 597 |
+ case typelib_TypeClass_BOOLEAN: |
| 598 |
+ case typelib_TypeClass_BYTE: |
| 599 |
+ __asm__( "lbz 3,%0\n\t" |
| 600 |
+ : : "m" (nRegReturn[0]) ); |
| 601 |
+ break; |
| 602 |
+ case typelib_TypeClass_CHAR: |
| 603 |
+ case typelib_TypeClass_UNSIGNED_SHORT: |
| 604 |
+ __asm__( "lhz 3,%0\n\t" |
| 605 |
+ : : "m" (nRegReturn[0]) ); |
| 606 |
+ break; |
| 607 |
+ case typelib_TypeClass_SHORT: |
| 608 |
+ __asm__( "lha 3,%0\n\t" |
| 609 |
+ : : "m" (nRegReturn[0]) ); |
| 610 |
+ break; |
| 611 |
+ case typelib_TypeClass_ENUM: |
| 612 |
+ case typelib_TypeClass_UNSIGNED_LONG: |
| 613 |
+ __asm__( "lwz 3,%0\n\t" |
| 614 |
+ : : "m"(nRegReturn[0]) ); |
| 615 |
+ break; |
| 616 |
+ case typelib_TypeClass_LONG: |
| 617 |
+ __asm__( "lwa 3,%0\n\t" |
| 618 |
+ : : "m"(nRegReturn[0]) ); |
| 619 |
+ break; |
| 620 |
+ case typelib_TypeClass_FLOAT: |
| 621 |
+ __asm__( "lfs 1,%0\n\t" |
| 622 |
+ : : "m" (*((float*)nRegReturn)) ); |
| 623 |
+ break; |
| 624 |
+ case typelib_TypeClass_DOUBLE: |
| 625 |
+ __asm__( "lfd 1,%0\n\t" |
| 626 |
+ : : "m" (*((double*)nRegReturn)) ); |
| 627 |
+ break; |
| 628 |
+ default: |
| 629 |
+ __asm__( "ld 3,%0\n\t" |
| 630 |
+ : : "m" (nRegReturn[0]) ); |
| 631 |
+#if _CALL_ELF == 2 |
| 632 |
+ __asm__( "ld 4,%0\n\t" |
| 633 |
+ : : "m" (nRegReturn[1]) ); |
| 634 |
+#endif |
| 635 |
+ break; |
| 636 |
+ } |
| 637 |
+} |
| 638 |
+ |
| 639 |
+#if _CALL_ELF == 2 |
| 640 |
+const int codeSnippetSize = 32; |
| 641 |
+#else |
| 642 |
+const int codeSnippetSize = 24; |
| 643 |
+#endif |
| 644 |
+ |
| 645 |
+unsigned char * codeSnippet( unsigned char * code, sal_Int32 nFunctionIndex, sal_Int32 nVtableOffset, |
| 646 |
+ bool bHasHiddenParam) |
| 647 |
+{ |
| 648 |
+#if OSL_DEBUG_LEVEL > 2 |
| 649 |
+ fprintf(stderr,"in codeSnippet functionIndex is %x\n", nFunctionIndex); |
| 650 |
+ fprintf(stderr,"in codeSnippet vtableOffset is %x\n", nVtableOffset); |
| 651 |
+#endif |
| 652 |
+ |
| 653 |
+ sal_uInt64 nOffsetAndIndex = ( ( (sal_uInt64) nVtableOffset ) << 32 ) | ( (sal_uInt64) nFunctionIndex ); |
| 654 |
+ |
| 655 |
+ if ( bHasHiddenParam ) |
| 656 |
+ nOffsetAndIndex |= 0x80000000; |
| 657 |
+#if _CALL_ELF == 2 |
| 658 |
+ unsigned int *raw = (unsigned int *)&code[0]; |
| 659 |
+ |
| 660 |
+ raw[0] = 0xe96c0018; /* 0: ld 11,2f-0b(12) */ |
| 661 |
+ raw[1] = 0xe98c0010; /* ld 12,1f-0b(12) */ |
| 662 |
+ raw[2] = 0x7d8903a6; /* mtctr 12 */ |
| 663 |
+ raw[3] = 0x4e800420; /* bctr */ |
| 664 |
+ /* 1: .quad function_addr */ |
| 665 |
+ /* 2: .quad context */ |
| 666 |
+ *(void **)&raw[4] = (void *)privateSnippetExecutor; |
| 667 |
+ *(void **)&raw[6] = (void*)nOffsetAndIndex; |
| 668 |
+#else |
| 669 |
+ void ** raw = (void **)&code[0]; |
| 670 |
+ memcpy(raw, (char*) privateSnippetExecutor, 16); |
| 671 |
+ raw[2] = (void*) nOffsetAndIndex; |
| 672 |
+#endif |
| 673 |
+#if OSL_DEBUG_LEVEL > 2 |
| 674 |
+ fprintf(stderr, "in: offset/index is %x %x %d, %lx\n", |
| 675 |
+ nFunctionIndex, nVtableOffset, bHasHiddenParam, raw[2]); |
| 676 |
+#endif |
| 677 |
+ return (code + codeSnippetSize); |
| 678 |
+} |
| 679 |
+ |
| 680 |
+} |
| 681 |
+ |
| 682 |
+void bridges::cpp_uno::shared::VtableFactory::flushCode(unsigned char const * bptr, unsigned char const * eptr) |
| 683 |
+{ |
| 684 |
+ int const lineSize = 32; |
| 685 |
+ for (unsigned char const * p = bptr; p < eptr + lineSize; p += lineSize) { |
| 686 |
+ __asm__ volatile ("dcbst 0, %0" : : "r"(p) : "memory"); |
| 687 |
+ } |
| 688 |
+ __asm__ volatile ("sync" : : : "memory"); |
| 689 |
+ for (unsigned char const * p = bptr; p < eptr + lineSize; p += lineSize) { |
| 690 |
+ __asm__ volatile ("icbi 0, %0" : : "r"(p) : "memory"); |
| 691 |
+ } |
| 692 |
+ __asm__ volatile ("isync" : : : "memory"); |
| 693 |
+} |
| 694 |
+ |
| 695 |
+struct bridges::cpp_uno::shared::VtableFactory::Slot { void * fn; }; |
| 696 |
+ |
| 697 |
+bridges::cpp_uno::shared::VtableFactory::Slot * |
| 698 |
+bridges::cpp_uno::shared::VtableFactory::mapBlockToVtable(void * block) |
| 699 |
+{ |
| 700 |
+ return static_cast< Slot * >(block) + 2; |
| 701 |
+} |
| 702 |
+ |
| 703 |
+sal_Size bridges::cpp_uno::shared::VtableFactory::getBlockSize( |
| 704 |
+ sal_Int32 slotCount) |
| 705 |
+{ |
| 706 |
+ return (slotCount + 2) * sizeof (Slot) + slotCount * codeSnippetSize; |
| 707 |
+} |
| 708 |
+ |
| 709 |
+bridges::cpp_uno::shared::VtableFactory::Slot * |
| 710 |
+bridges::cpp_uno::shared::VtableFactory::initializeBlock( |
| 711 |
+ void * block, sal_Int32 slotCount) |
| 712 |
+{ |
| 713 |
+ Slot * slots = mapBlockToVtable(block); |
| 714 |
+ slots[-2].fn = 0; |
| 715 |
+ slots[-1].fn = 0; |
| 716 |
+ return slots + slotCount; |
| 717 |
+} |
| 718 |
+ |
| 719 |
+unsigned char * bridges::cpp_uno::shared::VtableFactory::addLocalFunctions( |
| 720 |
+ Slot ** slots, unsigned char * code, sal_PtrDiff writetoexecdiff, |
| 721 |
+ typelib_InterfaceTypeDescription const * type, sal_Int32 functionOffset, |
| 722 |
+ sal_Int32 functionCount, sal_Int32 vtableOffset) |
| 723 |
+{ |
| 724 |
+ (*slots) -= functionCount; |
| 725 |
+ Slot * s = *slots; |
| 726 |
+#if OSL_DEBUG_LEVEL > 2 |
| 727 |
+ fprintf(stderr, "in addLocalFunctions functionOffset is %x\n",functionOffset); |
| 728 |
+ fprintf(stderr, "in addLocalFunctions vtableOffset is %x\n",vtableOffset); |
| 729 |
+#endif |
| 730 |
+ |
| 731 |
+ for (sal_Int32 i = 0; i < type->nMembers; ++i) { |
| 732 |
+ typelib_TypeDescription * member = 0; |
| 733 |
+ TYPELIB_DANGER_GET(&member, type->ppMembers[i]); |
| 734 |
+ OSL_ASSERT(member != 0); |
| 735 |
+ switch (member->eTypeClass) { |
| 736 |
+ case typelib_TypeClass_INTERFACE_ATTRIBUTE: |
| 737 |
+ // Getter: |
| 738 |
+ (s++)->fn = code + writetoexecdiff; |
| 739 |
+ code = codeSnippet( |
| 740 |
+ code, functionOffset++, vtableOffset, |
| 741 |
+ ppc64::return_in_hidden_param( |
| 742 |
+ reinterpret_cast< |
| 743 |
+ typelib_InterfaceAttributeTypeDescription * >( |
| 744 |
+ member)->pAttributeTypeRef)); |
| 745 |
+ |
| 746 |
+ // Setter: |
| 747 |
+ if (!reinterpret_cast< |
| 748 |
+ typelib_InterfaceAttributeTypeDescription * >( |
| 749 |
+ member)->bReadOnly) |
| 750 |
+ { |
| 751 |
+ (s++)->fn = code + writetoexecdiff; |
| 752 |
+ code = codeSnippet(code, functionOffset++, vtableOffset, false); |
| 753 |
+ } |
| 754 |
+ break; |
| 755 |
+ |
| 756 |
+ case typelib_TypeClass_INTERFACE_METHOD: |
| 757 |
+ (s++)->fn = code + writetoexecdiff; |
| 758 |
+ code = codeSnippet( |
| 759 |
+ code, functionOffset++, vtableOffset, |
| 760 |
+ ppc64::return_in_hidden_param( |
| 761 |
+ reinterpret_cast< |
| 762 |
+ typelib_InterfaceMethodTypeDescription * >( |
| 763 |
+ member)->pReturnTypeRef)); |
| 764 |
+ break; |
| 765 |
+ |
| 766 |
+ default: |
| 767 |
+ OSL_ASSERT(false); |
| 768 |
+ break; |
| 769 |
+ } |
| 770 |
+ TYPELIB_DANGER_RELEASE(member); |
| 771 |
+ } |
| 772 |
+ return code; |
| 773 |
+} |
| 774 |
+ |
| 775 |
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |
| 776 |
--- /dev/null |
| 777 |
+++ bridges/source/cpp_uno/gcc3_freebsd_powerpc64/except.cxx |
| 778 |
@@ -0,0 +1,274 @@ |
| 779 |
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
| 780 |
+/* |
| 781 |
+ * This file is part of the LibreOffice project. |
| 782 |
+ * |
| 783 |
+ * This Source Code Form is subject to the terms of the Mozilla Public |
| 784 |
+ * License, v. 2.0. If a copy of the MPL was not distributed with this |
| 785 |
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| 786 |
+ * |
| 787 |
+ * This file incorporates work covered by the following license notice: |
| 788 |
+ * |
| 789 |
+ * Licensed to the Apache Software Foundation (ASF) under one or more |
| 790 |
+ * contributor license agreements. See the NOTICE file distributed |
| 791 |
+ * with this work for additional information regarding copyright |
| 792 |
+ * ownership. The ASF licenses this file to you under the Apache |
| 793 |
+ * License, Version 2.0 (the "License"); you may not use this file |
| 794 |
+ * except in compliance with the License. You may obtain a copy of |
| 795 |
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 . |
| 796 |
+ */ |
| 797 |
+ |
| 798 |
+ |
| 799 |
+#include <stdio.h> |
| 800 |
+#include <string.h> |
| 801 |
+#include <dlfcn.h> |
| 802 |
+#include <cxxabi.h> |
| 803 |
+#include <boost/unordered_map.hpp> |
| 804 |
+ |
| 805 |
+#include <rtl/strbuf.hxx> |
| 806 |
+#include <rtl/ustrbuf.hxx> |
| 807 |
+#include <osl/diagnose.h> |
| 808 |
+#include <osl/mutex.hxx> |
| 809 |
+ |
| 810 |
+#include <com/sun/star/uno/genfunc.hxx> |
| 811 |
+#include <typelib/typedescription.hxx> |
| 812 |
+#include <uno/any2.h> |
| 813 |
+ |
| 814 |
+#include "share.hxx" |
| 815 |
+ |
| 816 |
+ |
| 817 |
+using namespace ::std; |
| 818 |
+using namespace ::osl; |
| 819 |
+using namespace ::rtl; |
| 820 |
+using namespace ::com::sun::star::uno; |
| 821 |
+using namespace ::__cxxabiv1; |
| 822 |
+ |
| 823 |
+ |
| 824 |
+namespace CPPU_CURRENT_NAMESPACE |
| 825 |
+{ |
| 826 |
+ |
| 827 |
+void dummy_can_throw_anything( char const * ) |
| 828 |
+{ |
| 829 |
+} |
| 830 |
+ |
| 831 |
+static OUString toUNOname( char const * p ) SAL_THROW(()) |
| 832 |
+{ |
| 833 |
+#if OSL_DEBUG_LEVEL > 1 |
| 834 |
+ char const * start = p; |
| 835 |
+#endif |
| 836 |
+ |
| 837 |
+ // example: N3com3sun4star4lang24IllegalArgumentExceptionE |
| 838 |
+ |
| 839 |
+ OUStringBuffer buf( 64 ); |
| 840 |
+ OSL_ASSERT( 'N' == *p ); |
| 841 |
+ ++p; // skip N |
| 842 |
+ |
| 843 |
+ while ('E' != *p) |
| 844 |
+ { |
| 845 |
+ // read chars count |
| 846 |
+ long n = (*p++ - '0'); |
| 847 |
+ while ('0' <= *p && '9' >= *p) |
| 848 |
+ { |
| 849 |
+ n *= 10; |
| 850 |
+ n += (*p++ - '0'); |
| 851 |
+ } |
| 852 |
+ buf.appendAscii( p, n ); |
| 853 |
+ p += n; |
| 854 |
+ if ('E' != *p) |
| 855 |
+ buf.append( '.' ); |
| 856 |
+ } |
| 857 |
+ |
| 858 |
+#if OSL_DEBUG_LEVEL > 1 |
| 859 |
+ OUString ret( buf.makeStringAndClear() ); |
| 860 |
+ OString c_ret( OUStringToOString( ret, RTL_TEXTENCODING_ASCII_US ) ); |
| 861 |
+ fprintf( stderr, "> toUNOname(): %s => %s\n", start, c_ret.getStr() ); |
| 862 |
+ return ret; |
| 863 |
+#else |
| 864 |
+ return buf.makeStringAndClear(); |
| 865 |
+#endif |
| 866 |
+} |
| 867 |
+ |
| 868 |
+class RTTI |
| 869 |
+{ |
| 870 |
+ typedef boost::unordered_map< OUString, type_info *, OUStringHash > t_rtti_map; |
| 871 |
+ |
| 872 |
+ Mutex m_mutex; |
| 873 |
+ t_rtti_map m_rttis; |
| 874 |
+ t_rtti_map m_generatedRttis; |
| 875 |
+ |
| 876 |
+ void * m_hApp; |
| 877 |
+ |
| 878 |
+public: |
| 879 |
+ RTTI() SAL_THROW(()); |
| 880 |
+ ~RTTI() SAL_THROW(()); |
| 881 |
+ |
| 882 |
+ type_info * getRTTI( typelib_CompoundTypeDescription * ) SAL_THROW(()); |
| 883 |
+}; |
| 884 |
+ |
| 885 |
+RTTI::RTTI() SAL_THROW(()) |
| 886 |
+ : m_hApp( dlopen( 0, RTLD_LAZY ) ) |
| 887 |
+{ |
| 888 |
+} |
| 889 |
+ |
| 890 |
+RTTI::~RTTI() SAL_THROW(()) |
| 891 |
+{ |
| 892 |
+ dlclose( m_hApp ); |
| 893 |
+} |
| 894 |
+ |
| 895 |
+ |
| 896 |
+type_info * RTTI::getRTTI( typelib_CompoundTypeDescription *pTypeDescr ) SAL_THROW(()) |
| 897 |
+{ |
| 898 |
+ type_info * rtti; |
| 899 |
+ |
| 900 |
+ OUString const & unoName = *(OUString const *)&pTypeDescr->aBase.pTypeName; |
| 901 |
+ |
| 902 |
+ MutexGuard guard( m_mutex ); |
| 903 |
+ t_rtti_map::const_iterator iRttiFind( m_rttis.find( unoName ) ); |
| 904 |
+ if (iRttiFind == m_rttis.end()) |
| 905 |
+ { |
| 906 |
+ // RTTI symbol |
| 907 |
+ OStringBuffer buf( 64 ); |
| 908 |
+ buf.append( "_ZTIN" ); |
| 909 |
+ sal_Int32 index = 0; |
| 910 |
+ do |
| 911 |
+ { |
| 912 |
+ OUString token( unoName.getToken( 0, '.', index ) ); |
| 913 |
+ buf.append( token.getLength() ); |
| 914 |
+ OString c_token( OUStringToOString( token, RTL_TEXTENCODING_ASCII_US ) ); |
| 915 |
+ buf.append( c_token ); |
| 916 |
+ } |
| 917 |
+ while (index >= 0); |
| 918 |
+ buf.append( 'E' ); |
| 919 |
+ |
| 920 |
+ OString symName( buf.makeStringAndClear() ); |
| 921 |
+ rtti = (type_info *)dlsym( m_hApp, symName.getStr() ); |
| 922 |
+ |
| 923 |
+ if (rtti) |
| 924 |
+ { |
| 925 |
+ pair< t_rtti_map::iterator, bool > insertion( |
| 926 |
+ m_rttis.insert( t_rtti_map::value_type( unoName, rtti ) ) ); |
| 927 |
+ OSL_ENSURE( insertion.second, "### inserting new rtti failed?!" ); |
| 928 |
+ } |
| 929 |
+ else |
| 930 |
+ { |
| 931 |
+ // try to lookup the symbol in the generated rtti map |
| 932 |
+ t_rtti_map::const_iterator iFind( m_generatedRttis.find( unoName ) ); |
| 933 |
+ if (iFind == m_generatedRttis.end()) |
| 934 |
+ { |
| 935 |
+ // we must generate it ! |
| 936 |
+ // symbol and rtti-name is nearly identical, |
| 937 |
+ // the symbol is prefixed with _ZTI |
| 938 |
+ char const * rttiName = symName.getStr() +4; |
| 939 |
+#if OSL_DEBUG_LEVEL > 1 |
| 940 |
+ fprintf( stderr,"generated rtti for %s\n", rttiName ); |
| 941 |
+#endif |
| 942 |
+ if (pTypeDescr->pBaseTypeDescription) |
| 943 |
+ { |
| 944 |
+ // ensure availability of base |
| 945 |
+ type_info * base_rtti = getRTTI( |
| 946 |
+ (typelib_CompoundTypeDescription *)pTypeDescr->pBaseTypeDescription ); |
| 947 |
+ rtti = new __si_class_type_info( |
| 948 |
+ strdup( rttiName ), (__class_type_info *)base_rtti ); |
| 949 |
+ } |
| 950 |
+ else |
| 951 |
+ { |
| 952 |
+ // this class has no base class |
| 953 |
+ rtti = new __class_type_info( strdup( rttiName ) ); |
| 954 |
+ } |
| 955 |
+ |
| 956 |
+ pair< t_rtti_map::iterator, bool > insertion( |
| 957 |
+ m_generatedRttis.insert( t_rtti_map::value_type( unoName, rtti ) ) ); |
| 958 |
+ OSL_ENSURE( insertion.second, "### inserting new generated rtti failed?!" ); |
| 959 |
+ } |
| 960 |
+ else // taking already generated rtti |
| 961 |
+ { |
| 962 |
+ rtti = iFind->second; |
| 963 |
+ } |
| 964 |
+ } |
| 965 |
+ } |
| 966 |
+ else |
| 967 |
+ { |
| 968 |
+ rtti = iRttiFind->second; |
| 969 |
+ } |
| 970 |
+ |
| 971 |
+ return rtti; |
| 972 |
+} |
| 973 |
+ |
| 974 |
+ |
| 975 |
+static void deleteException( void * pExc ) |
| 976 |
+{ |
| 977 |
+ __cxa_exception const * header = ((__cxa_exception const *)pExc - 1); |
| 978 |
+ typelib_TypeDescription * pTD = 0; |
| 979 |
+ OUString unoName( toUNOname( header->exceptionType->name() ) ); |
| 980 |
+ ::typelib_typedescription_getByName( &pTD, unoName.pData ); |
| 981 |
+ OSL_ENSURE( pTD, "### unknown exception type! leaving out destruction => leaking!!!" ); |
| 982 |
+ if (pTD) |
| 983 |
+ { |
| 984 |
+ ::uno_destructData( pExc, pTD, cpp_release ); |
| 985 |
+ ::typelib_typedescription_release( pTD ); |
| 986 |
+ } |
| 987 |
+} |
| 988 |
+ |
| 989 |
+void raiseException( uno_Any * pUnoExc, uno_Mapping * pUno2Cpp ) |
| 990 |
+{ |
| 991 |
+ void * pCppExc; |
| 992 |
+ type_info * rtti; |
| 993 |
+ |
| 994 |
+ { |
| 995 |
+ // construct cpp exception object |
| 996 |
+ typelib_TypeDescription * pTypeDescr = 0; |
| 997 |
+ TYPELIB_DANGER_GET( &pTypeDescr, pUnoExc->pType ); |
| 998 |
+ OSL_ASSERT( pTypeDescr ); |
| 999 |
+ if (! pTypeDescr) |
| 1000 |
+ terminate(); |
| 1001 |
+ |
| 1002 |
+ pCppExc = __cxa_allocate_exception( pTypeDescr->nSize ); |
| 1003 |
+ ::uno_copyAndConvertData( pCppExc, pUnoExc->pData, pTypeDescr, pUno2Cpp ); |
| 1004 |
+ |
| 1005 |
+ // destruct uno exception |
| 1006 |
+ ::uno_any_destruct( pUnoExc, 0 ); |
| 1007 |
+ // avoiding locked counts |
| 1008 |
+ static RTTI * s_rtti = 0; |
| 1009 |
+ if (! s_rtti) |
| 1010 |
+ { |
| 1011 |
+ MutexGuard guard( Mutex::getGlobalMutex() ); |
| 1012 |
+ if (! s_rtti) |
| 1013 |
+ { |
| 1014 |
+#ifdef LEAK_STATIC_DATA |
| 1015 |
+ s_rtti = new RTTI(); |
| 1016 |
+#else |
| 1017 |
+ static RTTI rtti_data; |
| 1018 |
+ s_rtti = &rtti_data; |
| 1019 |
+#endif |
| 1020 |
+ } |
| 1021 |
+ } |
| 1022 |
+ rtti = (type_info *)s_rtti->getRTTI( (typelib_CompoundTypeDescription *) pTypeDescr ); |
| 1023 |
+ TYPELIB_DANGER_RELEASE( pTypeDescr ); |
| 1024 |
+ OSL_ENSURE( rtti, "### no rtti for throwing exception!" ); |
| 1025 |
+ if (! rtti) |
| 1026 |
+ terminate(); |
| 1027 |
+ } |
| 1028 |
+ |
| 1029 |
+ __cxa_throw( pCppExc, rtti, deleteException ); |
| 1030 |
+} |
| 1031 |
+ |
| 1032 |
+void fillUnoException( __cxa_exception * header, uno_Any * pExc, uno_Mapping * pCpp2Uno ) |
| 1033 |
+{ |
| 1034 |
+ OSL_ENSURE( header, "### no exception header!!!" ); |
| 1035 |
+ if (! header) |
| 1036 |
+ terminate(); |
| 1037 |
+ |
| 1038 |
+ typelib_TypeDescription * pExcTypeDescr = 0; |
| 1039 |
+ OUString unoName( toUNOname( header->exceptionType->name() ) ); |
| 1040 |
+ ::typelib_typedescription_getByName( &pExcTypeDescr, unoName.pData ); |
| 1041 |
+ OSL_ENSURE( pExcTypeDescr, "### can not get type description for exception!!!" ); |
| 1042 |
+ if (! pExcTypeDescr) |
| 1043 |
+ terminate(); |
| 1044 |
+ |
| 1045 |
+ // construct uno exception any |
| 1046 |
+ ::uno_any_constructAndConvert( pExc, header->adjustedPtr, pExcTypeDescr, pCpp2Uno ); |
| 1047 |
+ ::typelib_typedescription_release( pExcTypeDescr ); |
| 1048 |
+} |
| 1049 |
+ |
| 1050 |
+} |
| 1051 |
+ |
| 1052 |
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |
| 1053 |
--- /dev/null |
| 1054 |
+++ bridges/source/cpp_uno/gcc3_freebsd_powerpc64/share.hxx |
| 1055 |
@@ -0,0 +1,92 @@ |
| 1056 |
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
| 1057 |
+/* |
| 1058 |
+ * This file is part of the LibreOffice project. |
| 1059 |
+ * |
| 1060 |
+ * This Source Code Form is subject to the terms of the Mozilla Public |
| 1061 |
+ * License, v. 2.0. If a copy of the MPL was not distributed with this |
| 1062 |
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| 1063 |
+ * |
| 1064 |
+ * This file incorporates work covered by the following license notice: |
| 1065 |
+ * |
| 1066 |
+ * Licensed to the Apache Software Foundation (ASF) under one or more |
| 1067 |
+ * contributor license agreements. See the NOTICE file distributed |
| 1068 |
+ * with this work for additional information regarding copyright |
| 1069 |
+ * ownership. The ASF licenses this file to you under the Apache |
| 1070 |
+ * License, Version 2.0 (the "License"); you may not use this file |
| 1071 |
+ * except in compliance with the License. You may obtain a copy of |
| 1072 |
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 . |
| 1073 |
+ */ |
| 1074 |
+#ifndef INCLUDED_BRIDGES_SOURCE_CPP_UNO_GCC3_FREEBSD_POWERPC64_SHARE_HXX |
| 1075 |
+#define INCLUDED_BRIDGES_SOURCE_CPP_UNO_GCC3_FREEBSD_POWERPC64_SHARE_HXX |
| 1076 |
+ |
| 1077 |
+#include "uno/mapping.h" |
| 1078 |
+ |
| 1079 |
+#include <typeinfo> |
| 1080 |
+#include <exception> |
| 1081 |
+#include <cstddef> |
| 1082 |
+ |
| 1083 |
+namespace CPPU_CURRENT_NAMESPACE |
| 1084 |
+{ |
| 1085 |
+ |
| 1086 |
+ void dummy_can_throw_anything( char const * ); |
| 1087 |
+ |
| 1088 |
+ |
| 1089 |
+// ----- following decl from libstdc++-v3/libsupc++/unwind-cxx.h and unwind.h |
| 1090 |
+ |
| 1091 |
+struct _Unwind_Exception |
| 1092 |
+{ |
| 1093 |
+ unsigned exception_class __attribute__((__mode__(__DI__))); |
| 1094 |
+ void * exception_cleanup; |
| 1095 |
+ unsigned private_1 __attribute__((__mode__(__word__))); |
| 1096 |
+ unsigned private_2 __attribute__((__mode__(__word__))); |
| 1097 |
+} __attribute__((__aligned__)); |
| 1098 |
+ |
| 1099 |
+struct __cxa_exception |
| 1100 |
+{ |
| 1101 |
+ ::std::type_info *exceptionType; |
| 1102 |
+ void (*exceptionDestructor)(void *); |
| 1103 |
+ |
| 1104 |
+ ::std::unexpected_handler unexpectedHandler; |
| 1105 |
+ ::std::terminate_handler terminateHandler; |
| 1106 |
+ |
| 1107 |
+ __cxa_exception *nextException; |
| 1108 |
+ |
| 1109 |
+ int handlerCount; |
| 1110 |
+ |
| 1111 |
+ int handlerSwitchValue; |
| 1112 |
+ const unsigned char *actionRecord; |
| 1113 |
+ const unsigned char *languageSpecificData; |
| 1114 |
+ void *catchTemp; |
| 1115 |
+ void *adjustedPtr; |
| 1116 |
+ |
| 1117 |
+ _Unwind_Exception unwindHeader; |
| 1118 |
+}; |
| 1119 |
+ |
| 1120 |
+extern "C" void *__cxa_allocate_exception( |
| 1121 |
+ std::size_t thrown_size ) throw(); |
| 1122 |
+extern "C" void __cxa_throw ( |
| 1123 |
+ void *thrown_exception, std::type_info *tinfo, void (*dest) (void *) ) __attribute__((noreturn)); |
| 1124 |
+ |
| 1125 |
+struct __cxa_eh_globals |
| 1126 |
+{ |
| 1127 |
+ __cxa_exception *caughtExceptions; |
| 1128 |
+ unsigned int uncaughtExceptions; |
| 1129 |
+}; |
| 1130 |
+extern "C" __cxa_eh_globals *__cxa_get_globals () throw(); |
| 1131 |
+ |
| 1132 |
+ |
| 1133 |
+void raiseException( |
| 1134 |
+ uno_Any * pUnoExc, uno_Mapping * pUno2Cpp ); |
| 1135 |
+ |
| 1136 |
+void fillUnoException( |
| 1137 |
+ __cxa_exception * header, uno_Any *, uno_Mapping * pCpp2Uno ); |
| 1138 |
+} |
| 1139 |
+ |
| 1140 |
+namespace ppc64 |
| 1141 |
+{ |
| 1142 |
+ enum ppclimits { MAX_GPR_REGS = 8, MAX_SSE_REGS = 13 }; |
| 1143 |
+ bool return_in_hidden_param( typelib_TypeDescriptionReference *pTypeRef ); |
| 1144 |
+} |
| 1145 |
+ |
| 1146 |
+#endif |
| 1147 |
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |
| 1148 |
--- /dev/null |
| 1149 |
+++ bridges/source/cpp_uno/gcc3_freebsd_powerpc64/uno2cpp.cxx |
| 1150 |
@@ -0,0 +1,659 @@ |
| 1151 |
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
| 1152 |
+/* |
| 1153 |
+ * This file is part of the LibreOffice project. |
| 1154 |
+ * |
| 1155 |
+ * This Source Code Form is subject to the terms of the Mozilla Public |
| 1156 |
+ * License, v. 2.0. If a copy of the MPL was not distributed with this |
| 1157 |
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| 1158 |
+ * |
| 1159 |
+ * This file incorporates work covered by the following license notice: |
| 1160 |
+ * |
| 1161 |
+ * Licensed to the Apache Software Foundation (ASF) under one or more |
| 1162 |
+ * contributor license agreements. See the NOTICE file distributed |
| 1163 |
+ * with this work for additional information regarding copyright |
| 1164 |
+ * ownership. The ASF licenses this file to you under the Apache |
| 1165 |
+ * License, Version 2.0 (the "License"); you may not use this file |
| 1166 |
+ * except in compliance with the License. You may obtain a copy of |
| 1167 |
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 . |
| 1168 |
+ */ |
| 1169 |
+ |
| 1170 |
+ |
| 1171 |
+#include <stdlib.h> |
| 1172 |
+ |
| 1173 |
+#include <com/sun/star/uno/genfunc.hxx> |
| 1174 |
+#include <uno/data.h> |
| 1175 |
+ |
| 1176 |
+#include "bridges/cpp_uno/shared/bridge.hxx" |
| 1177 |
+#include "bridges/cpp_uno/shared/types.hxx" |
| 1178 |
+#include "bridges/cpp_uno/shared/unointerfaceproxy.hxx" |
| 1179 |
+#include "bridges/cpp_uno/shared/vtables.hxx" |
| 1180 |
+ |
| 1181 |
+#include "share.hxx" |
| 1182 |
+ |
| 1183 |
+#include <stdio.h> |
| 1184 |
+#include <string.h> |
| 1185 |
+ |
| 1186 |
+ |
| 1187 |
+using namespace ::rtl; |
| 1188 |
+using namespace ::com::sun::star::uno; |
| 1189 |
+ |
| 1190 |
+namespace ppc64 |
| 1191 |
+{ |
| 1192 |
+#if _CALL_ELF == 2 |
| 1193 |
+ bool is_complex_struct(const typelib_TypeDescription * type) |
| 1194 |
+ { |
| 1195 |
+ const typelib_CompoundTypeDescription * p |
| 1196 |
+ = reinterpret_cast< const typelib_CompoundTypeDescription * >(type); |
| 1197 |
+ for (sal_Int32 i = 0; i < p->nMembers; ++i) |
| 1198 |
+ { |
| 1199 |
+ if (p->ppTypeRefs[i]->eTypeClass == typelib_TypeClass_STRUCT || |
| 1200 |
+ p->ppTypeRefs[i]->eTypeClass == typelib_TypeClass_EXCEPTION) |
| 1201 |
+ { |
| 1202 |
+ typelib_TypeDescription * t = 0; |
| 1203 |
+ TYPELIB_DANGER_GET(&t, p->ppTypeRefs[i]); |
| 1204 |
+ bool b = is_complex_struct(t); |
| 1205 |
+ TYPELIB_DANGER_RELEASE(t); |
| 1206 |
+ if (b) { |
| 1207 |
+ return true; |
| 1208 |
+ } |
| 1209 |
+ } |
| 1210 |
+ else if (!bridges::cpp_uno::shared::isSimpleType(p->ppTypeRefs[i]->eTypeClass)) |
| 1211 |
+ return true; |
| 1212 |
+ } |
| 1213 |
+ if (p->pBaseTypeDescription != 0) |
| 1214 |
+ return is_complex_struct(&p->pBaseTypeDescription->aBase); |
| 1215 |
+ return false; |
| 1216 |
+ } |
| 1217 |
+#endif |
| 1218 |
+ |
| 1219 |
+ bool return_in_hidden_param( typelib_TypeDescriptionReference *pTypeRef ) |
| 1220 |
+ { |
| 1221 |
+ if (bridges::cpp_uno::shared::isSimpleType(pTypeRef)) |
| 1222 |
+ return false; |
| 1223 |
+#if _CALL_ELF == 2 |
| 1224 |
+ else if (pTypeRef->eTypeClass == typelib_TypeClass_STRUCT || pTypeRef->eTypeClass == typelib_TypeClass_EXCEPTION) |
| 1225 |
+ { |
| 1226 |
+ typelib_TypeDescription * pTypeDescr = 0; |
| 1227 |
+ TYPELIB_DANGER_GET( &pTypeDescr, pTypeRef ); |
| 1228 |
+ |
| 1229 |
+ //A Composite Type not larger than 16 bytes is returned in up to two GPRs |
| 1230 |
+ bool bRet = pTypeDescr->nSize > 16 || is_complex_struct(pTypeDescr); |
| 1231 |
+ |
| 1232 |
+ TYPELIB_DANGER_RELEASE( pTypeDescr ); |
| 1233 |
+ return bRet; |
| 1234 |
+ } |
| 1235 |
+#endif |
| 1236 |
+ return true; |
| 1237 |
+ } |
| 1238 |
+} |
| 1239 |
+ |
| 1240 |
+void MapReturn(long r3, long r4, double dret, typelib_TypeDescriptionReference* pReturnType, void *pRegisterReturn) |
| 1241 |
+{ |
| 1242 |
+ switch (pReturnType->eTypeClass) |
| 1243 |
+ { |
| 1244 |
+ case typelib_TypeClass_HYPER: |
| 1245 |
+ case typelib_TypeClass_UNSIGNED_HYPER: |
| 1246 |
+ *reinterpret_cast<sal_uInt64 *>( pRegisterReturn ) = r3; |
| 1247 |
+ break; |
| 1248 |
+ case typelib_TypeClass_LONG: |
| 1249 |
+ case typelib_TypeClass_UNSIGNED_LONG: |
| 1250 |
+ case typelib_TypeClass_ENUM: |
| 1251 |
+ *reinterpret_cast<sal_uInt32 *>( pRegisterReturn ) = r3; |
| 1252 |
+ break; |
| 1253 |
+ case typelib_TypeClass_CHAR: |
| 1254 |
+ case typelib_TypeClass_SHORT: |
| 1255 |
+ case typelib_TypeClass_UNSIGNED_SHORT: |
| 1256 |
+ *reinterpret_cast<sal_uInt16 *>( pRegisterReturn ) = (unsigned short)r3; |
| 1257 |
+ break; |
| 1258 |
+ case typelib_TypeClass_BOOLEAN: |
| 1259 |
+ case typelib_TypeClass_BYTE: |
| 1260 |
+ *reinterpret_cast<sal_uInt8 *>( pRegisterReturn ) = (unsigned char)r3; |
| 1261 |
+ break; |
| 1262 |
+ case typelib_TypeClass_FLOAT: |
| 1263 |
+ *reinterpret_cast<float *>( pRegisterReturn ) = dret; |
| 1264 |
+ break; |
| 1265 |
+ case typelib_TypeClass_DOUBLE: |
| 1266 |
+ *reinterpret_cast<double *>( pRegisterReturn ) = dret; |
| 1267 |
+ break; |
| 1268 |
+#if _CALL_ELF == 2 |
| 1269 |
+ case typelib_TypeClass_STRUCT: |
| 1270 |
+ case typelib_TypeClass_EXCEPTION: |
| 1271 |
+ if (!ppc64::return_in_hidden_param(pReturnType)) |
| 1272 |
+ { |
| 1273 |
+ sal_uInt64 *pRegisters = reinterpret_cast<sal_uInt64*>(pRegisterReturn); |
| 1274 |
+ pRegisters[0] = r3; |
| 1275 |
+ if (pReturnType->pType->nSize > 8) |
| 1276 |
+ pRegisters[1] = r4; |
| 1277 |
+ } |
| 1278 |
+#endif |
| 1279 |
+ default: |
| 1280 |
+ break; |
| 1281 |
+ } |
| 1282 |
+} |
| 1283 |
+ |
| 1284 |
+namespace |
| 1285 |
+{ |
| 1286 |
+ |
| 1287 |
+static void callVirtualMethod(void * pThis, sal_uInt32 nVtableIndex, |
| 1288 |
+ void * pRegisterReturn, typelib_TypeDescription * pReturnTypeDescr, |
| 1289 |
+ sal_uInt64 *pStack, sal_uInt32 nStack, |
| 1290 |
+ sal_uInt64 *pGPR, sal_uInt32 nGPR, |
| 1291 |
+ double *pFPR, sal_uInt32 nFPR) |
| 1292 |
+{ |
| 1293 |
+ // Stack, if used, must be 16-bytes aligned |
| 1294 |
+ if ( nStack ) |
| 1295 |
+ nStack = ( nStack + 1 ) & ~1; |
| 1296 |
+ |
| 1297 |
+ // Should not happen, but... |
| 1298 |
+ if ( nFPR > ppc64::MAX_SSE_REGS ) |
| 1299 |
+ nFPR = ppc64::MAX_SSE_REGS; |
| 1300 |
+ if ( nGPR > ppc64::MAX_GPR_REGS ) |
| 1301 |
+ nGPR = ppc64::MAX_GPR_REGS; |
| 1302 |
+ |
| 1303 |
+#if OSL_DEBUG_LEVEL > 2 |
| 1304 |
+ // Let's figure out what is really going on here |
| 1305 |
+ { |
| 1306 |
+ fprintf( stderr, "= callVirtualMethod() =\nGPR's (%d): ", nGPR ); |
| 1307 |
+ for ( int i = 0; i < nGPR; ++i ) |
| 1308 |
+ fprintf( stderr, "0x%lx, ", pGPR[i] ); |
| 1309 |
+ fprintf( stderr, "\nFPR's (%d): ", nFPR ); |
| 1310 |
+ for ( int i = 0; i < nFPR; ++i ) |
| 1311 |
+ fprintf( stderr, "0x%lx (%f), ", pFPR[i], pFPR[i] ); |
| 1312 |
+ fprintf( stderr, "\nStack (%d): ", nStack ); |
| 1313 |
+ for ( int i = 0; i < nStack; ++i ) |
| 1314 |
+ fprintf( stderr, "0x%lx, ", pStack[i] ); |
| 1315 |
+ fprintf( stderr, "\n" ); |
| 1316 |
+ } |
| 1317 |
+#endif |
| 1318 |
+ |
| 1319 |
+ // Load parameters to stack, if necessary |
| 1320 |
+ sal_uInt64 *stack = (sal_uInt64 *) __builtin_alloca( nStack * 8 ); |
| 1321 |
+ memcpy( stack, pStack, nStack * 8 ); |
| 1322 |
+ |
| 1323 |
+ // Get pointer to method |
| 1324 |
+ sal_uInt64 pMethod = *((sal_uInt64 *)pThis); |
| 1325 |
+ pMethod += 8 * nVtableIndex; |
| 1326 |
+ pMethod = *((sal_uInt64 *)pMethod); |
| 1327 |
+ |
| 1328 |
+#if _CALL_ELF == 2 |
| 1329 |
+ typedef void (* FunctionCall )(...); |
| 1330 |
+#else |
| 1331 |
+ typedef void (* FunctionCall )( sal_uInt64, sal_uInt64, sal_uInt64, sal_uInt64, sal_uInt64, sal_uInt64, sal_uInt64, sal_uInt64 ); |
| 1332 |
+#endif |
| 1333 |
+ FunctionCall pFunc = (FunctionCall)pMethod; |
| 1334 |
+ |
| 1335 |
+ volatile double dret; |
| 1336 |
+ |
| 1337 |
+ // fill registers |
| 1338 |
+ __asm__ __volatile__ ( |
| 1339 |
+ "ld 3, 0(%0)\n\t" |
| 1340 |
+ "ld 4, 8(%0)\n\t" |
| 1341 |
+ "ld 5, 16(%0)\n\t" |
| 1342 |
+ "ld 6, 24(%0)\n\t" |
| 1343 |
+ "ld 7, 32(%0)\n\t" |
| 1344 |
+ "ld 8, 40(%0)\n\t" |
| 1345 |
+ "ld 9, 48(%0)\n\t" |
| 1346 |
+ "ld 10, 56(%0)\n\t" |
| 1347 |
+ "lfd 1, 0(%1)\n\t" |
| 1348 |
+ "lfd 2, 8(%1)\n\t" |
| 1349 |
+ "lfd 3, 16(%1)\n\t" |
| 1350 |
+ "lfd 4, 24(%1)\n\t" |
| 1351 |
+ "lfd 5, 32(%1)\n\t" |
| 1352 |
+ "lfd 6, 40(%1)\n\t" |
| 1353 |
+ "lfd 7, 48(%1)\n\t" |
| 1354 |
+ "lfd 8, 56(%1)\n\t" |
| 1355 |
+ "lfd 9, 64(%1)\n\t" |
| 1356 |
+ "lfd 10, 72(%1)\n\t" |
| 1357 |
+ "lfd 11, 80(%1)\n\t" |
| 1358 |
+ "lfd 12, 88(%1)\n\t" |
| 1359 |
+ "lfd 13, 96(%1)\n\t" |
| 1360 |
+ : : "r" (pGPR), "r" (pFPR) |
| 1361 |
+ : "r0", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", |
| 1362 |
+ "fr1", "fr2", "fr3", "fr4", "fr5", "fr6", "fr7", "fr8", "fr9", |
| 1363 |
+ "fr10", "fr11", "fr12", "fr13" |
| 1364 |
+ ); |
| 1365 |
+ |
| 1366 |
+ // tell gcc that r3 to r11 are not available to it for doing the TOC and exception munge on the func call |
| 1367 |
+ register sal_uInt64 r3 asm("r3"); |
| 1368 |
+ register sal_uInt64 r4 asm("r4"); |
| 1369 |
+ register sal_uInt64 r5 asm("r5"); |
| 1370 |
+ register sal_uInt64 r6 asm("r6"); |
| 1371 |
+ register sal_uInt64 r7 asm("r7"); |
| 1372 |
+ register sal_uInt64 r8 asm("r8"); |
| 1373 |
+ register sal_uInt64 r9 asm("r9"); |
| 1374 |
+ register sal_uInt64 r10 asm("r10"); |
| 1375 |
+ register sal_uInt64 r11 asm("r11"); |
| 1376 |
+ |
| 1377 |
+ (*pFunc)(r3, r4, r5, r6, r7, r8, r9, r10); |
| 1378 |
+ |
| 1379 |
+ // get return value |
| 1380 |
+ __asm__ __volatile__ ( |
| 1381 |
+ "mr %1, 3\n\t" |
| 1382 |
+ "mr %2, 4\n\t" |
| 1383 |
+ "fmr %0, 1\n\t" |
| 1384 |
+ : "=f" (dret), "=r" (r3), "=r" (r4) : ); |
| 1385 |
+ |
| 1386 |
+ MapReturn(r3, r4, dret, reinterpret_cast<typelib_TypeDescriptionReference *>(pReturnTypeDescr), pRegisterReturn); |
| 1387 |
+} |
| 1388 |
+ |
| 1389 |
+// Macros for easier insertion of values to registers or stack |
| 1390 |
+// pSV - pointer to the source |
| 1391 |
+// nr - order of the value [will be increased if stored to register] |
| 1392 |
+// pFPR, pGPR - pointer to the registers |
| 1393 |
+// pDS - pointer to the stack [will be increased if stored here] |
| 1394 |
+ |
| 1395 |
+// The value in %xmm register is already prepared to be retrieved as a float, |
| 1396 |
+// thus we treat float and double the same |
| 1397 |
+#define INSERT_FLOAT( pSV, nr, pFPR, pDS, bOverflow ) \ |
| 1398 |
+ if ( nr < ppc64::MAX_SSE_REGS ) \ |
| 1399 |
+ pFPR[nr++] = *reinterpret_cast<float *>( pSV ); \ |
| 1400 |
+ else \ |
| 1401 |
+ bOverflow = true; \ |
| 1402 |
+ if (bOverflow) \ |
| 1403 |
+ *pDS++ = *reinterpret_cast<sal_uInt64 *>( pSV ); // verbatim! |
| 1404 |
+ |
| 1405 |
+#define INSERT_DOUBLE( pSV, nr, pFPR, pDS, bOverflow ) \ |
| 1406 |
+ if ( nr < ppc64::MAX_SSE_REGS ) \ |
| 1407 |
+ pFPR[nr++] = *reinterpret_cast<double *>( pSV ); \ |
| 1408 |
+ else \ |
| 1409 |
+ bOverflow = true; \ |
| 1410 |
+ if (bOverflow) \ |
| 1411 |
+ *pDS++ = *reinterpret_cast<sal_uInt64 *>( pSV ); // verbatim! |
| 1412 |
+ |
| 1413 |
+#define INSERT_INT64( pSV, nr, pGPR, pDS, bOverflow ) \ |
| 1414 |
+ if ( nr < ppc64::MAX_GPR_REGS ) \ |
| 1415 |
+ pGPR[nr++] = *reinterpret_cast<sal_uInt64 *>( pSV ); \ |
| 1416 |
+ else \ |
| 1417 |
+ bOverflow = true; \ |
| 1418 |
+ if (bOverflow) \ |
| 1419 |
+ *pDS++ = *reinterpret_cast<sal_uInt64 *>( pSV ); |
| 1420 |
+ |
| 1421 |
+#define INSERT_INT32( pSV, nr, pGPR, pDS, bOverflow ) \ |
| 1422 |
+ if ( nr < ppc64::MAX_GPR_REGS ) \ |
| 1423 |
+ pGPR[nr++] = *reinterpret_cast<sal_uInt32 *>( pSV ); \ |
| 1424 |
+ else \ |
| 1425 |
+ bOverflow = true; \ |
| 1426 |
+ if (bOverflow) \ |
| 1427 |
+ *pDS++ = *reinterpret_cast<sal_uInt32 *>( pSV ); |
| 1428 |
+ |
| 1429 |
+#define INSERT_INT16( pSV, nr, pGPR, pDS, bOverflow ) \ |
| 1430 |
+ if ( nr < ppc64::MAX_GPR_REGS ) \ |
| 1431 |
+ pGPR[nr++] = *reinterpret_cast<sal_uInt16 *>( pSV ); \ |
| 1432 |
+ else \ |
| 1433 |
+ bOverflow = true; \ |
| 1434 |
+ if (bOverflow) \ |
| 1435 |
+ *pDS++ = *reinterpret_cast<sal_uInt16 *>( pSV ); |
| 1436 |
+ |
| 1437 |
+#define INSERT_INT8( pSV, nr, pGPR, pDS, bOverflow ) \ |
| 1438 |
+ if ( nr < ppc64::MAX_GPR_REGS ) \ |
| 1439 |
+ pGPR[nr++] = *reinterpret_cast<sal_uInt8 *>( pSV ); \ |
| 1440 |
+ else \ |
| 1441 |
+ bOverflow = true; \ |
| 1442 |
+ if (bOverflow) \ |
| 1443 |
+ *pDS++ = *reinterpret_cast<sal_uInt8 *>( pSV ); |
| 1444 |
+ |
| 1445 |
+static void cpp_call( |
| 1446 |
+ bridges::cpp_uno::shared::UnoInterfaceProxy * pThis, |
| 1447 |
+ bridges::cpp_uno::shared::VtableSlot aVtableSlot, |
| 1448 |
+ typelib_TypeDescriptionReference * pReturnTypeRef, |
| 1449 |
+ sal_Int32 nParams, typelib_MethodParameter * pParams, |
| 1450 |
+ void * pUnoReturn, void * pUnoArgs[], uno_Any ** ppUnoExc ) |
| 1451 |
+{ |
| 1452 |
+ // max space for: [complex ret ptr], values|ptr ... |
| 1453 |
+ sal_uInt64 * pStack = (sal_uInt64 *)alloca( (nParams+3) * sizeof(sal_Int64) ); |
| 1454 |
+ sal_uInt64 * pStackStart = pStack; |
| 1455 |
+ |
| 1456 |
+ sal_uInt64 pGPR[ppc64::MAX_GPR_REGS]; |
| 1457 |
+ sal_uInt32 nGPR = 0; |
| 1458 |
+ |
| 1459 |
+ double pFPR[ppc64::MAX_SSE_REGS]; |
| 1460 |
+ sal_uInt32 nFPR = 0; |
| 1461 |
+ |
| 1462 |
+ // return |
| 1463 |
+ typelib_TypeDescription * pReturnTypeDescr = 0; |
| 1464 |
+ TYPELIB_DANGER_GET( &pReturnTypeDescr, pReturnTypeRef ); |
| 1465 |
+ OSL_ENSURE( pReturnTypeDescr, "### expected return type description!" ); |
| 1466 |
+ |
| 1467 |
+ void * pCppReturn = 0; // if != 0 && != pUnoReturn, needs reconversion |
| 1468 |
+ |
| 1469 |
+ bool bOverflow = false; |
| 1470 |
+ bool bSimpleReturn = true; |
| 1471 |
+ |
| 1472 |
+ if (pReturnTypeDescr) |
| 1473 |
+ { |
| 1474 |
+#if OSL_DEBUG_LEVEL > 2 |
| 1475 |
+ fprintf(stderr, "return type is %d\n", pReturnTypeDescr->eTypeClass); |
| 1476 |
+#endif |
| 1477 |
+ if (ppc64::return_in_hidden_param(pReturnTypeRef)) |
| 1478 |
+ bSimpleReturn = false; |
| 1479 |
+ |
| 1480 |
+ if (bSimpleReturn) |
| 1481 |
+ { |
| 1482 |
+ pCppReturn = pUnoReturn; // direct way for simple types |
| 1483 |
+#if OSL_DEBUG_LEVEL > 2 |
| 1484 |
+ fprintf(stderr, "simple return\n"); |
| 1485 |
+#endif |
| 1486 |
+ } |
| 1487 |
+ else |
| 1488 |
+ { |
| 1489 |
+ // complex return via ptr |
| 1490 |
+ pCppReturn = (bridges::cpp_uno::shared::relatesToInterfaceType( pReturnTypeDescr ) |
| 1491 |
+ ? alloca( pReturnTypeDescr->nSize ) : pUnoReturn); |
| 1492 |
+#if OSL_DEBUG_LEVEL > 2 |
| 1493 |
+ fprintf(stderr, "pCppReturn/pUnoReturn is %lx/%lx", pCppReturn, pUnoReturn); |
| 1494 |
+#endif |
| 1495 |
+ INSERT_INT64( &pCppReturn, nGPR, pGPR, pStack, bOverflow ); |
| 1496 |
+ } |
| 1497 |
+ } |
| 1498 |
+ // push "this" pointer |
| 1499 |
+ void * pAdjustedThisPtr = reinterpret_cast< void ** >( pThis->getCppI() ) + aVtableSlot.offset; |
| 1500 |
+#if OSL_DEBUG_LEVEL > 2 |
| 1501 |
+ fprintf(stderr, "this pointer is %p\n", pAdjustedThisPtr); |
| 1502 |
+#endif |
| 1503 |
+ INSERT_INT64( &pAdjustedThisPtr, nGPR, pGPR, pStack, bOverflow ); |
| 1504 |
+ |
| 1505 |
+ // Args |
| 1506 |
+ void ** pCppArgs = (void **)alloca( 3 * sizeof(void *) * nParams ); |
| 1507 |
+ // indices of values this have to be converted (interface conversion cpp<=>uno) |
| 1508 |
+ sal_Int32 * pTempIndices = (sal_Int32 *)(pCppArgs + nParams); |
| 1509 |
+ // type descriptions for reconversions |
| 1510 |
+ typelib_TypeDescription ** ppTempParamTypeDescr = (typelib_TypeDescription **)(pCppArgs + (2 * nParams)); |
| 1511 |
+ |
| 1512 |
+ sal_Int32 nTempIndices = 0; |
| 1513 |
+ |
| 1514 |
+#if OSL_DEBUG_LEVEL > 2 |
| 1515 |
+ fprintf(stderr, "n params is %d\n", nParams); |
| 1516 |
+#endif |
| 1517 |
+ |
| 1518 |
+ for ( sal_Int32 nPos = 0; nPos < nParams; ++nPos ) |
| 1519 |
+ { |
| 1520 |
+ const typelib_MethodParameter & rParam = pParams[nPos]; |
| 1521 |
+ typelib_TypeDescription * pParamTypeDescr = 0; |
| 1522 |
+ TYPELIB_DANGER_GET( &pParamTypeDescr, rParam.pTypeRef ); |
| 1523 |
+ |
| 1524 |
+#if OSL_DEBUG_LEVEL > 2 |
| 1525 |
+ fprintf(stderr, "param %d is %d %d %d\n", nPos, rParam.bOut, bridges::cpp_uno::shared::isSimpleType( pParamTypeDescr ), |
| 1526 |
+ pParamTypeDescr->eTypeClass); |
| 1527 |
+#endif |
| 1528 |
+ |
| 1529 |
+ if (!rParam.bOut && bridges::cpp_uno::shared::isSimpleType( pParamTypeDescr )) |
| 1530 |
+ { |
| 1531 |
+// uno_copyAndConvertData( pCppArgs[nPos] = alloca( 8 ), pUnoArgs[nPos], pParamTypeDescr, |
| 1532 |
+ uno_copyAndConvertData( pCppArgs[nPos] = pStack, pUnoArgs[nPos], pParamTypeDescr, |
| 1533 |
+ pThis->getBridge()->getUno2Cpp() ); |
| 1534 |
+ switch (pParamTypeDescr->eTypeClass) |
| 1535 |
+ { |
| 1536 |
+ case typelib_TypeClass_HYPER: |
| 1537 |
+ case typelib_TypeClass_UNSIGNED_HYPER: |
| 1538 |
+#if OSL_DEBUG_LEVEL > 2 |
| 1539 |
+ fprintf(stderr, "hyper is %lx\n", pCppArgs[nPos]); |
| 1540 |
+#endif |
| 1541 |
+ INSERT_INT64( pCppArgs[nPos], nGPR, pGPR, pStack, bOverflow ); |
| 1542 |
+ break; |
| 1543 |
+ case typelib_TypeClass_LONG: |
| 1544 |
+ case typelib_TypeClass_UNSIGNED_LONG: |
| 1545 |
+ case typelib_TypeClass_ENUM: |
| 1546 |
+#if OSL_DEBUG_LEVEL > 2 |
| 1547 |
+ fprintf(stderr, "long is %x\n", pCppArgs[nPos]); |
| 1548 |
+#endif |
| 1549 |
+ INSERT_INT32( pCppArgs[nPos], nGPR, pGPR, pStack, bOverflow ); |
| 1550 |
+ break; |
| 1551 |
+ case typelib_TypeClass_SHORT: |
| 1552 |
+ case typelib_TypeClass_CHAR: |
| 1553 |
+ case typelib_TypeClass_UNSIGNED_SHORT: |
| 1554 |
+ INSERT_INT16( pCppArgs[nPos], nGPR, pGPR, pStack, bOverflow ); |
| 1555 |
+ break; |
| 1556 |
+ case typelib_TypeClass_BOOLEAN: |
| 1557 |
+ case typelib_TypeClass_BYTE: |
| 1558 |
+ INSERT_INT8( pCppArgs[nPos], nGPR, pGPR, pStack, bOverflow ); |
| 1559 |
+ break; |
| 1560 |
+ case typelib_TypeClass_FLOAT: |
| 1561 |
+ INSERT_FLOAT( pCppArgs[nPos], nFPR, pFPR, pStack, bOverflow ); |
| 1562 |
+ break; |
| 1563 |
+ case typelib_TypeClass_DOUBLE: |
| 1564 |
+ INSERT_DOUBLE( pCppArgs[nPos], nFPR, pFPR, pStack, bOverflow ); |
| 1565 |
+ break; |
| 1566 |
+ } |
| 1567 |
+ |
| 1568 |
+ // no longer needed |
| 1569 |
+ TYPELIB_DANGER_RELEASE( pParamTypeDescr ); |
| 1570 |
+ |
| 1571 |
+ } |
| 1572 |
+ else // ptr to complex value | ref |
| 1573 |
+ { |
| 1574 |
+#if OSL_DEBUG_LEVEL > 2 |
| 1575 |
+ fprintf(stderr, "complex type again %d\n", rParam.bIn); |
| 1576 |
+#endif |
| 1577 |
+ if (! rParam.bIn) // is pure out |
| 1578 |
+ { |
| 1579 |
+#if OSL_DEBUG_LEVEL > 2 |
| 1580 |
+ fprintf(stderr, "complex size is %d\n", pParamTypeDescr->nSize ); |
| 1581 |
+#endif |
| 1582 |
+ // cpp out is constructed mem, uno out is not! |
| 1583 |
+ uno_constructData( |
| 1584 |
+ pCppArgs[nPos] = alloca( pParamTypeDescr->nSize ), |
| 1585 |
+ pParamTypeDescr ); |
| 1586 |
+ pTempIndices[nTempIndices] = nPos; // default constructed for cpp call |
| 1587 |
+ // will be released at reconversion |
| 1588 |
+ ppTempParamTypeDescr[nTempIndices++] = pParamTypeDescr; |
| 1589 |
+ } |
| 1590 |
+ // is in/inout |
| 1591 |
+ else if (bridges::cpp_uno::shared::relatesToInterfaceType( pParamTypeDescr )) |
| 1592 |
+ { |
| 1593 |
+#if OSL_DEBUG_LEVEL > 2 |
| 1594 |
+ fprintf(stderr, "this one\n"); |
| 1595 |
+#endif |
| 1596 |
+ uno_copyAndConvertData( |
| 1597 |
+ pCppArgs[nPos] = alloca( pParamTypeDescr->nSize ), |
| 1598 |
+ pUnoArgs[nPos], pParamTypeDescr, pThis->getBridge()->getUno2Cpp() ); |
| 1599 |
+ |
| 1600 |
+ pTempIndices[nTempIndices] = nPos; // has to be reconverted |
| 1601 |
+ // will be released at reconversion |
| 1602 |
+ ppTempParamTypeDescr[nTempIndices++] = pParamTypeDescr; |
| 1603 |
+ } |
| 1604 |
+ else // direct way |
| 1605 |
+ { |
| 1606 |
+#if OSL_DEBUG_LEVEL > 2 |
| 1607 |
+ fprintf(stderr, "that one, passing %lx through\n", pUnoArgs[nPos]); |
| 1608 |
+#endif |
| 1609 |
+ pCppArgs[nPos] = pUnoArgs[nPos]; |
| 1610 |
+ // no longer needed |
| 1611 |
+ TYPELIB_DANGER_RELEASE( pParamTypeDescr ); |
| 1612 |
+ } |
| 1613 |
+ INSERT_INT64( &(pCppArgs[nPos]), nGPR, pGPR, pStack, bOverflow ); |
| 1614 |
+ } |
| 1615 |
+ } |
| 1616 |
+ |
| 1617 |
+ try |
| 1618 |
+ { |
| 1619 |
+ callVirtualMethod( |
| 1620 |
+ pAdjustedThisPtr, aVtableSlot.index, |
| 1621 |
+ pCppReturn, pReturnTypeDescr, |
| 1622 |
+ pStackStart, ( pStack - pStackStart ), |
| 1623 |
+ pGPR, nGPR, |
| 1624 |
+ pFPR, nFPR ); |
| 1625 |
+ // NO exception occurred... |
| 1626 |
+ *ppUnoExc = 0; |
| 1627 |
+ |
| 1628 |
+ // reconvert temporary params |
| 1629 |
+ for ( ; nTempIndices--; ) |
| 1630 |
+ { |
| 1631 |
+ sal_Int32 nIndex = pTempIndices[nTempIndices]; |
| 1632 |
+ typelib_TypeDescription * pParamTypeDescr = ppTempParamTypeDescr[nTempIndices]; |
| 1633 |
+ |
| 1634 |
+ if (pParams[nIndex].bIn) |
| 1635 |
+ { |
| 1636 |
+ if (pParams[nIndex].bOut) // inout |
| 1637 |
+ { |
| 1638 |
+ uno_destructData( pUnoArgs[nIndex], pParamTypeDescr, 0 ); // destroy uno value |
| 1639 |
+ uno_copyAndConvertData( pUnoArgs[nIndex], pCppArgs[nIndex], pParamTypeDescr, |
| 1640 |
+ pThis->getBridge()->getCpp2Uno() ); |
| 1641 |
+ } |
| 1642 |
+ } |
| 1643 |
+ else // pure out |
| 1644 |
+ { |
| 1645 |
+ uno_copyAndConvertData( pUnoArgs[nIndex], pCppArgs[nIndex], pParamTypeDescr, |
| 1646 |
+ pThis->getBridge()->getCpp2Uno() ); |
| 1647 |
+ } |
| 1648 |
+ // destroy temp cpp param => cpp: every param was constructed |
| 1649 |
+ uno_destructData( pCppArgs[nIndex], pParamTypeDescr, cpp_release ); |
| 1650 |
+ |
| 1651 |
+ TYPELIB_DANGER_RELEASE( pParamTypeDescr ); |
| 1652 |
+ } |
| 1653 |
+ // return value |
| 1654 |
+ if (pCppReturn && pUnoReturn != pCppReturn) |
| 1655 |
+ { |
| 1656 |
+ uno_copyAndConvertData( pUnoReturn, pCppReturn, pReturnTypeDescr, |
| 1657 |
+ pThis->getBridge()->getCpp2Uno() ); |
| 1658 |
+ uno_destructData( pCppReturn, pReturnTypeDescr, cpp_release ); |
| 1659 |
+ } |
| 1660 |
+ } |
| 1661 |
+ catch (...) |
| 1662 |
+ { |
| 1663 |
+ // fill uno exception |
| 1664 |
+ fillUnoException( CPPU_CURRENT_NAMESPACE::__cxa_get_globals()->caughtExceptions, |
| 1665 |
+ *ppUnoExc, pThis->getBridge()->getCpp2Uno() ); |
| 1666 |
+ |
| 1667 |
+ // temporary params |
| 1668 |
+ for ( ; nTempIndices--; ) |
| 1669 |
+ { |
| 1670 |
+ sal_Int32 nIndex = pTempIndices[nTempIndices]; |
| 1671 |
+ // destroy temp cpp param => cpp: every param was constructed |
| 1672 |
+ uno_destructData( pCppArgs[nIndex], ppTempParamTypeDescr[nTempIndices], cpp_release ); |
| 1673 |
+ TYPELIB_DANGER_RELEASE( ppTempParamTypeDescr[nTempIndices] ); |
| 1674 |
+ } |
| 1675 |
+ // return type |
| 1676 |
+ if (pReturnTypeDescr) |
| 1677 |
+ TYPELIB_DANGER_RELEASE( pReturnTypeDescr ); |
| 1678 |
+ } |
| 1679 |
+} |
| 1680 |
+ |
| 1681 |
+} |
| 1682 |
+ |
| 1683 |
+namespace bridges { namespace cpp_uno { namespace shared { |
| 1684 |
+ |
| 1685 |
+void unoInterfaceProxyDispatch( |
| 1686 |
+ uno_Interface * pUnoI, const typelib_TypeDescription * pMemberDescr, |
| 1687 |
+ void * pReturn, void * pArgs[], uno_Any ** ppException ) |
| 1688 |
+{ |
| 1689 |
+ // is my surrogate |
| 1690 |
+ bridges::cpp_uno::shared::UnoInterfaceProxy * pThis |
| 1691 |
+ = static_cast< bridges::cpp_uno::shared::UnoInterfaceProxy *> (pUnoI); |
| 1692 |
+ |
| 1693 |
+ switch (pMemberDescr->eTypeClass) |
| 1694 |
+ { |
| 1695 |
+ case typelib_TypeClass_INTERFACE_ATTRIBUTE: |
| 1696 |
+ { |
| 1697 |
+ |
| 1698 |
+ VtableSlot aVtableSlot( |
| 1699 |
+ getVtableSlot( |
| 1700 |
+ reinterpret_cast< |
| 1701 |
+ typelib_InterfaceAttributeTypeDescription const * >( |
| 1702 |
+ pMemberDescr))); |
| 1703 |
+ |
| 1704 |
+ if (pReturn) |
| 1705 |
+ { |
| 1706 |
+ // dependent dispatch |
| 1707 |
+ cpp_call( |
| 1708 |
+ pThis, aVtableSlot, |
| 1709 |
+ ((typelib_InterfaceAttributeTypeDescription *)pMemberDescr)->pAttributeTypeRef, |
| 1710 |
+ 0, 0, // no params |
| 1711 |
+ pReturn, pArgs, ppException ); |
| 1712 |
+ } |
| 1713 |
+ else |
| 1714 |
+ { |
| 1715 |
+ // is SET |
| 1716 |
+ typelib_MethodParameter aParam; |
| 1717 |
+ aParam.pTypeRef = |
| 1718 |
+ ((typelib_InterfaceAttributeTypeDescription *)pMemberDescr)->pAttributeTypeRef; |
| 1719 |
+ aParam.bIn = sal_True; |
| 1720 |
+ aParam.bOut = sal_False; |
| 1721 |
+ |
| 1722 |
+ typelib_TypeDescriptionReference * pReturnTypeRef = 0; |
| 1723 |
+ OUString aVoidName("void"); |
| 1724 |
+ typelib_typedescriptionreference_new( |
| 1725 |
+ &pReturnTypeRef, typelib_TypeClass_VOID, aVoidName.pData ); |
| 1726 |
+ |
| 1727 |
+ // dependent dispatch |
| 1728 |
+ aVtableSlot.index += 1; //get then set method |
| 1729 |
+ cpp_call( |
| 1730 |
+ pThis, aVtableSlot, |
| 1731 |
+ pReturnTypeRef, |
| 1732 |
+ 1, &aParam, |
| 1733 |
+ pReturn, pArgs, ppException ); |
| 1734 |
+ |
| 1735 |
+ typelib_typedescriptionreference_release( pReturnTypeRef ); |
| 1736 |
+ } |
| 1737 |
+ |
| 1738 |
+ break; |
| 1739 |
+ } |
| 1740 |
+ case typelib_TypeClass_INTERFACE_METHOD: |
| 1741 |
+ { |
| 1742 |
+ |
| 1743 |
+ VtableSlot aVtableSlot( |
| 1744 |
+ getVtableSlot( |
| 1745 |
+ reinterpret_cast< |
| 1746 |
+ typelib_InterfaceMethodTypeDescription const * >( |
| 1747 |
+ pMemberDescr))); |
| 1748 |
+ switch (aVtableSlot.index) |
| 1749 |
+ { |
| 1750 |
+ // standard calls |
| 1751 |
+ case 1: // acquire uno interface |
| 1752 |
+ (*pUnoI->acquire)( pUnoI ); |
| 1753 |
+ *ppException = 0; |
| 1754 |
+ break; |
| 1755 |
+ case 2: // release uno interface |
| 1756 |
+ (*pUnoI->release)( pUnoI ); |
| 1757 |
+ *ppException = 0; |
| 1758 |
+ break; |
| 1759 |
+ case 0: // queryInterface() opt |
| 1760 |
+ { |
| 1761 |
+ typelib_TypeDescription * pTD = 0; |
| 1762 |
+ TYPELIB_DANGER_GET( &pTD, reinterpret_cast< Type * >( pArgs[0] )->getTypeLibType() ); |
| 1763 |
+ if (pTD) |
| 1764 |
+ { |
| 1765 |
+ uno_Interface * pInterface = 0; |
| 1766 |
+ (*pThis->pBridge->getUnoEnv()->getRegisteredInterface)( |
| 1767 |
+ pThis->pBridge->getUnoEnv(), |
| 1768 |
+ (void **)&pInterface, pThis->oid.pData, (typelib_InterfaceTypeDescription *)pTD ); |
| 1769 |
+ |
| 1770 |
+ if (pInterface) |
| 1771 |
+ { |
| 1772 |
+ ::uno_any_construct( |
| 1773 |
+ reinterpret_cast< uno_Any * >( pReturn ), |
| 1774 |
+ &pInterface, pTD, 0 ); |
| 1775 |
+ (*pInterface->release)( pInterface ); |
| 1776 |
+ TYPELIB_DANGER_RELEASE( pTD ); |
| 1777 |
+ *ppException = 0; |
| 1778 |
+ break; |
| 1779 |
+ } |
| 1780 |
+ TYPELIB_DANGER_RELEASE( pTD ); |
| 1781 |
+ } |
| 1782 |
+ } // else perform queryInterface() |
| 1783 |
+ default: |
| 1784 |
+ // dependent dispatch |
| 1785 |
+ cpp_call( |
| 1786 |
+ pThis, aVtableSlot, |
| 1787 |
+ ((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->pReturnTypeRef, |
| 1788 |
+ ((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->nParams, |
| 1789 |
+ ((typelib_InterfaceMethodTypeDescription *)pMemberDescr)->pParams, |
| 1790 |
+ pReturn, pArgs, ppException ); |
| 1791 |
+ } |
| 1792 |
+ break; |
| 1793 |
+ } |
| 1794 |
+ default: |
| 1795 |
+ { |
| 1796 |
+ ::com::sun::star::uno::RuntimeException aExc( |
| 1797 |
+ OUString("illegal member type description!"), |
| 1798 |
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >() ); |
| 1799 |
+ |
| 1800 |
+ Type const & rExcType = ::getCppuType( &aExc ); |
| 1801 |
+ // binary identical null reference |
| 1802 |
+ ::uno_type_any_construct( *ppException, &aExc, rExcType.getTypeLibType(), 0 ); |
| 1803 |
+ } |
| 1804 |
+ } |
| 1805 |
+} |
| 1806 |
+ |
| 1807 |
+} } } |
| 1808 |
+ |
| 1809 |
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |
| 1810 |
--- /dev/null |
| 1811 |
+++ solenv/gbuild/platform/FREEBSD_POWERPC64_GCC.mk |
| 1812 |
@@ -0,0 +1,17 @@ |
| 1813 |
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- |
| 1814 |
+# |
| 1815 |
+# This file is part of the LibreOffice project. |
| 1816 |
+# |
| 1817 |
+# This Source Code Form is subject to the terms of the Mozilla Public |
| 1818 |
+# License, v. 2.0. If a copy of the MPL was not distributed with this |
| 1819 |
+# file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| 1820 |
+# |
| 1821 |
+ |
| 1822 |
+#please make generic modifications to unxgcc.mk or linux.mk |
| 1823 |
+gb_CPUDEFS += -DPPC -DPOWERPC64 |
| 1824 |
+gb_COMPILERDEFAULTOPTFLAGS := -O2 |
| 1825 |
+gb_CXXFLAGS += -mminimal-toc |
| 1826 |
+ |
| 1827 |
+include $(GBUILDDIR)/platform/unxgcc.mk |
| 1828 |
+ |
| 1829 |
+# vim: set noet sw=4: |
| 1830 |
--- canvas/source/cairo/cairo_canvashelper.cxx.orig |
| 1831 |
+++ canvas/source/cairo/cairo_canvashelper.cxx |
| 1832 |
@@ -17,6 +17,7 @@ |
| 1833 |
* the License at http://www.apache.org/licenses/LICENSE-2.0 . |
| 1834 |
*/ |
| 1835 |
|
| 1836 |
+#include <osl/endian.h> |
| 1837 |
#include <canvas/debug.hxx> |
| 1838 |
#include <tools/diagnose_ex.h> |
| 1839 |
|
| 1840 |
--- canvas/source/tools/canvastools.cxx.orig |
| 1841 |
+++ canvas/source/tools/canvastools.cxx |
| 1842 |
@@ -58,6 +58,8 @@ |
| 1843 |
#include <vcl/window.hxx> |
| 1844 |
#include <vcl/canvastools.hxx> |
| 1845 |
|
| 1846 |
+#include <osl/endian.h> |
| 1847 |
+ |
| 1848 |
#include <canvas/canvastools.hxx> |
| 1849 |
|
| 1850 |
#include <limits> |
| 1851 |
--- connectivity/source/drivers/odbc/OTools.cxx.orig |
| 1852 |
+++ connectivity/source/drivers/odbc/OTools.cxx |
| 1853 |
@@ -26,7 +26,7 @@ |
| 1854 |
#include <rtl/ustrbuf.hxx> |
| 1855 |
#include <boost/static_assert.hpp> |
| 1856 |
|
| 1857 |
- |
| 1858 |
+#include <osl/endian.h> |
| 1859 |
#include <string.h> |
| 1860 |
#include <string> |
| 1861 |
#include <algorithm> |
| 1862 |
--- cppcanvas/source/inc/implrenderer.hxx.orig |
| 1863 |
+++ cppcanvas/source/inc/implrenderer.hxx |
| 1864 |
@@ -30,6 +30,8 @@ |
| 1865 |
#include <action.hxx> |
| 1866 |
#include <outdevstate.hxx> |
| 1867 |
|
| 1868 |
+#include <osl/endian.h> |
| 1869 |
+ |
| 1870 |
#include <vector> |
| 1871 |
#include <map> |
| 1872 |
|
| 1873 |
--- desktop/source/deployment/misc/dp_platform.cxx.orig |
| 1874 |
+++ desktop/source/deployment/misc/dp_platform.cxx |
| 1875 |
@@ -52,6 +52,7 @@ |
| 1876 |
#define PLATFORM_SOLARIS_SPARC "solaris_sparc" |
| 1877 |
#define PLATFORM_SOLARIS_SPARC64 "solaris_sparc64" |
| 1878 |
#define PLATFORM_SOLARIS_X86 "solaris_x86" |
| 1879 |
+#define PLATFORM_FREEBSD_POWERPC64 "freebsd_powerpc64" |
| 1880 |
#define PLATFORM_FREEBSD_X86 "freebsd_x86" |
| 1881 |
#define PLATFORM_FREEBSD_X86_64 "freebsd_x86_64" |
| 1882 |
#define PLATFORM_NETBSD_X86 "netbsd_x86" |
| 1883 |
@@ -158,6 +159,8 @@ |
| 1884 |
ret = checkOSandCPU("Solaris", "SPARC64"); |
| 1885 |
else if (token == PLATFORM_SOLARIS_X86) |
| 1886 |
ret = checkOSandCPU("Solaris", "x86"); |
| 1887 |
+ else if (token == PLATFORM_FREEBSD_POWERPC64) |
| 1888 |
+ ret = checkOSandCPU("FreeBSD", "POWERPC64"); |
| 1889 |
else if (token == PLATFORM_FREEBSD_X86) |
| 1890 |
ret = checkOSandCPU("FreeBSD", "x86"); |
| 1891 |
else if (token == PLATFORM_FREEBSD_X86_64) |
| 1892 |
--- include/basebmp/rgbmaskpixelformats.hxx.orig |
| 1893 |
+++ include/basebmp/rgbmaskpixelformats.hxx |
| 1894 |
@@ -31,6 +31,8 @@ |
| 1895 |
#include <vigra/numerictraits.hxx> |
| 1896 |
#include <vigra/metaprogramming.hxx> |
| 1897 |
|
| 1898 |
+#include <osl/endian.h> |
| 1899 |
+ |
| 1900 |
#include <functional> |
| 1901 |
|
| 1902 |
namespace basebmp |
| 1903 |
--- include/osl/endian.h.orig |
| 1904 |
+++ include/osl/endian.h |
| 1905 |
@@ -80,13 +80,11 @@ |
| 1906 |
#ifdef FREEBSD |
| 1907 |
# include <sys/param.h> |
| 1908 |
# include <machine/endian.h> |
| 1909 |
-#if __FreeBSD_version < 500000 |
| 1910 |
-# if BYTE_ORDER == LITTLE_ENDIAN |
| 1911 |
-# define _LITTLE_ENDIAN |
| 1912 |
-# elif BYTE_ORDER == BIG_ENDIAN |
| 1913 |
-# define _BIG_ENDIAN |
| 1914 |
-# endif |
| 1915 |
-#endif |
| 1916 |
+# if BYTE_ORDER == LITTLE_ENDIAN |
| 1917 |
+# undef _BIG_ENDIAN |
| 1918 |
+# elif BYTE_ORDER == BIG_ENDIAN |
| 1919 |
+# undef _LITTLE_ENDIAN |
| 1920 |
+# endif |
| 1921 |
#endif |
| 1922 |
|
| 1923 |
#ifdef AIX |
| 1924 |
--- include/tools/stream.hxx.orig |
| 1925 |
+++ include/tools/stream.hxx |
| 1926 |
@@ -27,6 +27,7 @@ |
| 1927 |
#include <tools/ref.hxx> |
| 1928 |
#include <tools/rtti.hxx> |
| 1929 |
#include <rtl/string.hxx> |
| 1930 |
+#include <osl/endian.h> |
| 1931 |
|
| 1932 |
class StreamData; |
| 1933 |
|
| 1934 |
--- lotuswordpro/source/filter/lwpobjstrm.cxx.orig |
| 1935 |
+++ lotuswordpro/source/filter/lwpobjstrm.cxx |
| 1936 |
@@ -61,6 +61,8 @@ |
| 1937 |
#include "lwpobjstrm.hxx" |
| 1938 |
#include "lwptools.hxx" |
| 1939 |
#include <boost/scoped_array.hpp> |
| 1940 |
+ |
| 1941 |
+#include <osl/endian.h> |
| 1942 |
|
| 1943 |
/** |
| 1944 |
* @descr ctor() from LwpSvStream |
| 1945 |
--- oox/source/helper/binaryoutputstream.cxx.orig |
| 1946 |
+++ oox/source/helper/binaryoutputstream.cxx |
| 1947 |
@@ -23,6 +23,8 @@ |
| 1948 |
#include <com/sun/star/io/XSeekable.hpp> |
| 1949 |
#include <osl/diagnose.h> |
| 1950 |
#include <string.h> |
| 1951 |
+ |
| 1952 |
+#include <osl/endian.h> |
| 1953 |
|
| 1954 |
namespace oox { |
| 1955 |
|
| 1956 |
--- store/workben/t_page.cxx.orig |
| 1957 |
+++ store/workben/t_page.cxx |
| 1958 |
@@ -26,6 +26,7 @@ |
| 1959 |
|
| 1960 |
#include "storbase.hxx" |
| 1961 |
|
| 1962 |
+#include "osl/endian.h" |
| 1963 |
#include "osl/file.h" |
| 1964 |
#include "rtl/ustring.hxx" |
| 1965 |
|
| 1966 |
--- sw/source/filter/ww8/ww8scan.cxx.orig |
| 1967 |
+++ sw/source/filter/ww8/ww8scan.cxx |
| 1968 |
@@ -23,6 +23,7 @@ |
| 1969 |
#include <functional> |
| 1970 |
#include <algorithm> |
| 1971 |
|
| 1972 |
+#include <osl/endian.h> |
| 1973 |
#include <string.h> |
| 1974 |
#include <i18nlangtag/mslangid.hxx> |
| 1975 |
#include <sprmids.hxx> |
| 1976 |
--- sw/source/filter/ww8/ww8scan.hxx.orig |
| 1977 |
+++ sw/source/filter/ww8/ww8scan.hxx |
| 1978 |
@@ -31,6 +31,7 @@ |
| 1979 |
#include <algorithm> |
| 1980 |
|
| 1981 |
#include <boost/unordered_map.hpp> |
| 1982 |
+#include <osl/endian.h> |
| 1983 |
#include <tools/solar.h> |
| 1984 |
#include <tools/stream.hxx> |
| 1985 |
#include <rtl/ustring.hxx> |
| 1986 |
--- sw/source/core/uibase/dochdl/swdtflvr.cxx.orig |
| 1987 |
+++ sw/source/core/uibase/dochdl/swdtflvr.cxx |
| 1988 |
@@ -118,6 +118,8 @@ |
| 1989 |
#include <swserv.hxx> |
| 1990 |
#include <switerator.hxx> |
| 1991 |
|
| 1992 |
+#include <osl/endian.h> |
| 1993 |
+ |
| 1994 |
#include <vcl/GraphicNativeTransform.hxx> |
| 1995 |
#include <vcl/GraphicNativeMetadata.hxx> |
| 1996 |
|
| 1997 |
--- testtools/CustomTarget_uno_test.mk.orig |
| 1998 |
+++ testtools/CustomTarget_uno_test.mk |
| 1999 |
@@ -13,17 +13,17 @@ |
| 2000 |
.PHONY : $(call gb_CustomTarget_get_target,testtools/uno_test) |
| 2001 |
|
| 2002 |
$(call gb_CustomTarget_get_target,testtools/uno_test) : \ |
| 2003 |
- $(call gb_Executable_get_runtime_dependencies,uno) \ |
| 2004 |
- $(call gb_InternalUnoApi_get_target,bridgetest) \ |
| 2005 |
- $(call gb_Rdb_get_target,uno_services) \ |
| 2006 |
- $(call gb_Rdb_get_target,ure/services) \ |
| 2007 |
- $(call gb_UnoApi_get_target,udkapi) |
| 2008 |
- $(call gb_Helper_abbreviate_dirs,\ |
| 2009 |
- $(call gb_Executable_get_command,uno) \ |
| 2010 |
- -s com.sun.star.test.bridge.BridgeTest \ |
| 2011 |
- -- com.sun.star.test.bridge.CppTestObject \ |
| 2012 |
- -env:LO_BUILD_LIB_DIR=$(call gb_Helper_make_url,$(gb_Library_WORKDIR_FOR_BUILD)) \ |
| 2013 |
- -env:URE_MORE_SERVICES=$(call gb_Helper_make_url,$(call gb_Rdb_get_target,uno_services)) \ |
| 2014 |
- -env:URE_MORE_TYPES=$(call gb_Helper_make_url,$(WORKDIR)/UnoApiTarget/bridgetest.rdb)) |
| 2015 |
+# $(call gb_Executable_get_runtime_dependencies,uno) \ |
| 2016 |
+# $(call gb_InternalUnoApi_get_target,bridgetest) \ |
| 2017 |
+# $(call gb_Rdb_get_target,uno_services) \ |
| 2018 |
+# $(call gb_Rdb_get_target,ure/services) \ |
| 2019 |
+# $(call gb_UnoApi_get_target,udkapi) |
| 2020 |
+# $(call gb_Helper_abbreviate_dirs,\ |
| 2021 |
+# $(call gb_Executable_get_command,uno) \ |
| 2022 |
+# -s com.sun.star.test.bridge.BridgeTest \ |
| 2023 |
+# -- com.sun.star.test.bridge.CppTestObject \ |
| 2024 |
+# -env:LO_BUILD_LIB_DIR=$(call gb_Helper_make_url,$(gb_Library_WORKDIR_FOR_BUILD)) \ |
| 2025 |
+# -env:URE_MORE_SERVICES=$(call gb_Helper_make_url,$(call gb_Rdb_get_target,uno_services)) \ |
| 2026 |
+# -env:URE_MORE_TYPES=$(call gb_Helper_make_url,$(WORKDIR)/UnoApiTarget/bridgetest.rdb)) |
| 2027 |
|
| 2028 |
# vim:set shiftwidth=4 tabstop=4 noexpandtab: |
| 2029 |
--- vcl/generic/glyphs/gcach_ftyp.cxx.orig |
| 2030 |
+++ vcl/generic/glyphs/gcach_ftyp.cxx |
| 2031 |
@@ -36,6 +36,7 @@ |
| 2032 |
#include "basegfx/matrix/b2dhommatrixtools.hxx" |
| 2033 |
#include "basegfx/polygon/b2dpolypolygon.hxx" |
| 2034 |
|
| 2035 |
+#include "osl/endian.h" |
| 2036 |
#include "osl/file.hxx" |
| 2037 |
#include "osl/thread.hxx" |
| 2038 |
|
| 2039 |
--- vcl/headless/svpvd.cxx.orig |
| 2040 |
+++ vcl/headless/svpvd.cxx |
| 2041 |
@@ -18,6 +18,8 @@ |
| 2042 |
*/ |
| 2043 |
|
| 2044 |
#ifndef IOS |
| 2045 |
+ |
| 2046 |
+#include <osl/endian.h> |
| 2047 |
|
| 2048 |
#include "headless/svpbmp.hxx" |
| 2049 |
#include "headless/svpvd.hxx" |
| 2050 |
--- vcl/headless/svpgdi.cxx.orig |
| 2051 |
+++ vcl/headless/svpgdi.cxx |
| 2052 |
@@ -21,6 +21,8 @@ |
| 2053 |
#include "headless/svpbmp.hxx" |
| 2054 |
#include "saldatabasic.hxx" |
| 2055 |
|
| 2056 |
+#include <osl/endian.h> |
| 2057 |
+ |
| 2058 |
#include <vcl/sysdata.hxx> |
| 2059 |
#include <basegfx/range/b2drange.hxx> |
| 2060 |
#include <basegfx/range/b2ibox.hxx> |
| 2061 |
--- vcl/headless/svpbmp.cxx.orig |
| 2062 |
+++ vcl/headless/svpbmp.cxx |
| 2063 |
@@ -26,6 +26,8 @@ |
| 2064 |
#include <basebmp/scanlineformats.hxx> |
| 2065 |
#include <basebmp/color.hxx> |
| 2066 |
|
| 2067 |
+#include <osl/endian.h> |
| 2068 |
+ |
| 2069 |
#include <vcl/salbtype.hxx> |
| 2070 |
#include <vcl/bitmap.hxx> |
| 2071 |
|
| 2072 |
--- vcl/source/filter/jpeg/Exif.cxx.orig |
| 2073 |
+++ vcl/source/filter/jpeg/Exif.cxx |
| 2074 |
@@ -19,6 +19,7 @@ |
| 2075 |
|
| 2076 |
#include "Exif.hxx" |
| 2077 |
#include <boost/scoped_array.hpp> |
| 2078 |
+#include <osl/endian.h> |
| 2079 |
|
| 2080 |
Exif::Exif() : |
| 2081 |
maOrientation(TOP_LEFT), |