| File: | cppu/source/typelib/static_types.cxx |
| Location: | line 409, column 25 |
| Description: | Access to field 'nSize' results in a dereference of a null pointer (loaded from variable 'pTD') |
| 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 | #include "sal/config.h" | |||||
| 21 | ||||||
| 22 | #include <algorithm> | |||||
| 23 | #include <cassert> | |||||
| 24 | #include <stdarg.h> | |||||
| 25 | ||||||
| 26 | #include <osl/mutex.hxx> | |||||
| 27 | #include <osl/interlck.h> | |||||
| 28 | #include <rtl/ustring.hxx> | |||||
| 29 | #include <rtl/ustrbuf.hxx> | |||||
| 30 | #include <rtl/memory.h> | |||||
| 31 | #include <rtl/instance.hxx> | |||||
| 32 | ||||||
| 33 | #include <typelib/typedescription.h> | |||||
| 34 | ||||||
| 35 | ||||||
| 36 | using namespace osl; | |||||
| 37 | ||||||
| 38 | using ::rtl::OUString; | |||||
| 39 | using ::rtl::OUStringBuffer; | |||||
| 40 | ||||||
| 41 | extern "C" | |||||
| 42 | { | |||||
| 43 | ||||||
| 44 | //------------------------------------------------------------------------ | |||||
| 45 | sal_Int32 SAL_CALL typelib_typedescription_getAlignedUnoSize( | |||||
| 46 | const typelib_TypeDescription * pTypeDescription, | |||||
| 47 | sal_Int32 nOffset, | |||||
| 48 | sal_Int32 & rMaxIntegralTypeSize ) | |||||
| 49 | SAL_THROW_EXTERN_C()throw (); | |||||
| 50 | //------------------------------------------------------------------------ | |||||
| 51 | void SAL_CALL typelib_typedescription_newEmpty( | |||||
| 52 | typelib_TypeDescription ** ppRet, | |||||
| 53 | typelib_TypeClass eTypeClass, | |||||
| 54 | rtl_uString * pTypeName ) | |||||
| 55 | SAL_THROW_EXTERN_C()throw (); | |||||
| 56 | //----------------------------------------------------------------------------- | |||||
| 57 | void SAL_CALL typelib_typedescriptionreference_getByName( | |||||
| 58 | typelib_TypeDescriptionReference ** ppRet, | |||||
| 59 | rtl_uString * pName ) | |||||
| 60 | SAL_THROW_EXTERN_C()throw (); | |||||
| 61 | ||||||
| 62 | #ifdef SAL_W32 | |||||
| 63 | #pragma pack(push, 8) | |||||
| 64 | #endif | |||||
| 65 | ||||||
| 66 | /** | |||||
| 67 | * The double member determin the alignment. | |||||
| 68 | * Under Os2 and MS-Windows the Alignment is min( 8, sizeof( type ) ). | |||||
| 69 | * The aligment of a strukture is min( 8, sizeof( max basic type ) ), the greatest basic type | |||||
| 70 | * determine the aligment. | |||||
| 71 | */ | |||||
| 72 | struct AlignSize_Impl | |||||
| 73 | { | |||||
| 74 | sal_Int16 nInt16; | |||||
| 75 | #ifdef AIX | |||||
| 76 | //double: doubleword aligned if -qalign=natural/-malign=natural | |||||
| 77 | //which isn't the default ABI. Otherwise word aligned, While a long long int | |||||
| 78 | //is always doubleword aligned, so use that instead. | |||||
| 79 | sal_Int64 dDouble; | |||||
| 80 | #else | |||||
| 81 | double dDouble; | |||||
| 82 | #endif | |||||
| 83 | }; | |||||
| 84 | ||||||
| 85 | #ifdef SAL_W32 | |||||
| 86 | #pragma pack(pop) | |||||
| 87 | #endif | |||||
| 88 | ||||||
| 89 | // the value of the maximal alignment | |||||
| 90 | static sal_Int32 nMaxAlignment = (sal_Int32)( (sal_Size)(&((AlignSize_Impl *) 16)->dDouble) - 16); | |||||
| 91 | ||||||
| 92 | static inline sal_Int32 adjustAlignment( sal_Int32 nRequestedAlignment ) | |||||
| 93 | SAL_THROW(()) | |||||
| 94 | { | |||||
| 95 | if( nRequestedAlignment > nMaxAlignment ) | |||||
| 96 | nRequestedAlignment = nMaxAlignment; | |||||
| 97 | return nRequestedAlignment; | |||||
| 98 | } | |||||
| 99 | ||||||
| 100 | /** | |||||
| 101 | * Calculate the new size of the struktur. | |||||
| 102 | */ | |||||
| 103 | static inline sal_Int32 newAlignedSize( | |||||
| 104 | sal_Int32 OldSize, sal_Int32 ElementSize, sal_Int32 NeededAlignment ) | |||||
| 105 | SAL_THROW(()) | |||||
| 106 | { | |||||
| 107 | NeededAlignment = adjustAlignment( NeededAlignment ); | |||||
| 108 | return (OldSize + NeededAlignment -1) / NeededAlignment * NeededAlignment + ElementSize; | |||||
| 109 | } | |||||
| 110 | ||||||
| 111 | //-------------------------------------------------------------------------------------------------- | |||||
| 112 | ||||||
| 113 | namespace | |||||
| 114 | { | |||||
| 115 | struct typelib_StaticInitMutex : public rtl::Static< Mutex, typelib_StaticInitMutex > {}; | |||||
| 116 | } | |||||
| 117 | ||||||
| 118 | // !for NOT REALLY WEAK TYPES only! | |||||
| 119 | static inline typelib_TypeDescriptionReference * igetTypeByName( rtl_uString * pTypeName ) | |||||
| 120 | SAL_THROW(()) | |||||
| 121 | { | |||||
| 122 | typelib_TypeDescriptionReference * pRef = 0; | |||||
| 123 | ::typelib_typedescriptionreference_getByName( &pRef, pTypeName ); | |||||
| 124 | if (pRef && pRef->pType && pRef->pType->pWeakRef) // found initialized td | |||||
| 125 | { | |||||
| 126 | return pRef; | |||||
| 127 | } | |||||
| 128 | else | |||||
| 129 | { | |||||
| 130 | return 0; | |||||
| 131 | } | |||||
| 132 | } | |||||
| 133 | ||||||
| 134 | extern "C" | |||||
| 135 | { | |||||
| 136 | //################################################################################################## | |||||
| 137 | CPPU_DLLPUBLIC__attribute__ ((visibility("default"))) typelib_TypeDescriptionReference ** SAL_CALL typelib_static_type_getByTypeClass( | |||||
| 138 | typelib_TypeClass eTypeClass ) | |||||
| 139 | SAL_THROW_EXTERN_C()throw () | |||||
| 140 | { | |||||
| 141 | static typelib_TypeDescriptionReference * s_aTypes[] = { | |||||
| 142 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |||||
| 143 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |||||
| 144 | 0, 0, 0 }; | |||||
| 145 | ||||||
| 146 | if (! s_aTypes[eTypeClass]) | |||||
| 147 | { | |||||
| 148 | MutexGuard aGuard( typelib_StaticInitMutex::get() ); | |||||
| 149 | if (! s_aTypes[eTypeClass]) | |||||
| 150 | { | |||||
| 151 | static const char * s_aTypeNames[] = { | |||||
| 152 | "void", "char", "boolean", "byte", | |||||
| 153 | "short", "unsigned short", "long", "unsigned long", | |||||
| 154 | "hyper", "unsigned hyper", "float", "double", | |||||
| 155 | "string", "type", "any" }; | |||||
| 156 | ||||||
| 157 | switch (eTypeClass) | |||||
| 158 | { | |||||
| 159 | case typelib_TypeClass_EXCEPTION: | |||||
| 160 | case typelib_TypeClass_INTERFACE: | |||||
| 161 | { | |||||
| 162 | // type | |||||
| 163 | if (! s_aTypes[typelib_TypeClass_TYPE]) | |||||
| 164 | { | |||||
| 165 | OUString sTypeName( RTL_CONSTASCII_USTRINGPARAM("type")(&("type")[0]), ((sal_Int32)((sizeof ("type") / sizeof (( "type")[0]))-1)), (((rtl_TextEncoding) 11)) ); | |||||
| 166 | ::typelib_typedescriptionreference_new( | |||||
| 167 | &s_aTypes[typelib_TypeClass_TYPE], typelib_TypeClass_TYPE, sTypeName.pData ); | |||||
| 168 | // another static ref: | |||||
| 169 | ++s_aTypes[typelib_TypeClass_TYPE]->nStaticRefCount; | |||||
| 170 | } | |||||
| 171 | // any | |||||
| 172 | if (! s_aTypes[typelib_TypeClass_ANY]) | |||||
| 173 | { | |||||
| 174 | OUString sTypeName( RTL_CONSTASCII_USTRINGPARAM("any")(&("any")[0]), ((sal_Int32)((sizeof ("any") / sizeof (("any" )[0]))-1)), (((rtl_TextEncoding) 11)) ); | |||||
| 175 | ::typelib_typedescriptionreference_new( | |||||
| 176 | &s_aTypes[typelib_TypeClass_ANY], typelib_TypeClass_ANY, sTypeName.pData ); | |||||
| 177 | // another static ref: | |||||
| 178 | ++s_aTypes[typelib_TypeClass_ANY]->nStaticRefCount; | |||||
| 179 | } | |||||
| 180 | // string | |||||
| 181 | if (! s_aTypes[typelib_TypeClass_STRING]) | |||||
| 182 | { | |||||
| 183 | OUString sTypeName( RTL_CONSTASCII_USTRINGPARAM("string")(&("string")[0]), ((sal_Int32)((sizeof ("string") / sizeof (("string")[0]))-1)), (((rtl_TextEncoding) 11)) ); | |||||
| 184 | ::typelib_typedescriptionreference_new( | |||||
| 185 | &s_aTypes[typelib_TypeClass_STRING], typelib_TypeClass_STRING, sTypeName.pData ); | |||||
| 186 | // another static ref: | |||||
| 187 | ++s_aTypes[typelib_TypeClass_STRING]->nStaticRefCount; | |||||
| 188 | } | |||||
| 189 | // XInterface | |||||
| 190 | if (! s_aTypes[typelib_TypeClass_INTERFACE]) | |||||
| 191 | { | |||||
| 192 | OUString sTypeName( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.uno.XInterface")(&("com.sun.star.uno.XInterface")[0]), ((sal_Int32)((sizeof ("com.sun.star.uno.XInterface") / sizeof (("com.sun.star.uno.XInterface" )[0]))-1)), (((rtl_TextEncoding) 11)) ); | |||||
| 193 | ||||||
| 194 | typelib_InterfaceTypeDescription * pTD = 0; | |||||
| 195 | ||||||
| 196 | typelib_TypeDescriptionReference * pMembers[3] = { 0,0,0 }; | |||||
| 197 | OUString sMethodName0( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.uno.XInterface::queryInterface")(&("com.sun.star.uno.XInterface::queryInterface")[0]), (( sal_Int32)((sizeof ("com.sun.star.uno.XInterface::queryInterface" ) / sizeof (("com.sun.star.uno.XInterface::queryInterface")[0 ]))-1)), (((rtl_TextEncoding) 11)) ); | |||||
| 198 | ::typelib_typedescriptionreference_new( | |||||
| 199 | &pMembers[0], typelib_TypeClass_INTERFACE_METHOD, sMethodName0.pData ); | |||||
| 200 | OUString sMethodName1( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.uno.XInterface::acquire")(&("com.sun.star.uno.XInterface::acquire")[0]), ((sal_Int32 )((sizeof ("com.sun.star.uno.XInterface::acquire") / sizeof ( ("com.sun.star.uno.XInterface::acquire")[0]))-1)), (((rtl_TextEncoding ) 11)) ); | |||||
| 201 | ::typelib_typedescriptionreference_new( | |||||
| 202 | &pMembers[1], typelib_TypeClass_INTERFACE_METHOD, sMethodName1.pData ); | |||||
| 203 | OUString sMethodName2( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.uno.XInterface::release")(&("com.sun.star.uno.XInterface::release")[0]), ((sal_Int32 )((sizeof ("com.sun.star.uno.XInterface::release") / sizeof ( ("com.sun.star.uno.XInterface::release")[0]))-1)), (((rtl_TextEncoding ) 11)) ); | |||||
| 204 | ::typelib_typedescriptionreference_new( | |||||
| 205 | &pMembers[2], typelib_TypeClass_INTERFACE_METHOD, sMethodName2.pData ); | |||||
| 206 | ||||||
| 207 | ::typelib_typedescription_newInterface( | |||||
| 208 | &pTD, sTypeName.pData, 0xe227a391, 0x33d6, 0x11d1, 0xaabe00a0, 0x249d5590, | |||||
| 209 | 0, 3, pMembers ); | |||||
| 210 | ||||||
| 211 | ::typelib_typedescription_register( (typelib_TypeDescription **)&pTD ); | |||||
| 212 | ::typelib_typedescriptionreference_acquire( | |||||
| 213 | s_aTypes[typelib_TypeClass_INTERFACE] = ((typelib_TypeDescription *)pTD)->pWeakRef ); | |||||
| 214 | // another static ref: | |||||
| 215 | ++s_aTypes[typelib_TypeClass_INTERFACE]->nStaticRefCount; | |||||
| 216 | ::typelib_typedescription_release( (typelib_TypeDescription*)pTD ); | |||||
| 217 | ||||||
| 218 | ::typelib_typedescriptionreference_release( pMembers[0] ); | |||||
| 219 | ::typelib_typedescriptionreference_release( pMembers[1] ); | |||||
| 220 | ::typelib_typedescriptionreference_release( pMembers[2] ); | |||||
| 221 | // Exception | |||||
| 222 | assert( ! s_aTypes[typelib_TypeClass_EXCEPTION] )((! s_aTypes[typelib_TypeClass_EXCEPTION]) ? static_cast<void > (0) : __assert_fail ("! s_aTypes[typelib_TypeClass_EXCEPTION]" , "/usr/local/src/libreoffice/cppu/source/typelib/static_types.cxx" , 222, __PRETTY_FUNCTION__)); | |||||
| 223 | { | |||||
| 224 | typelib_TypeDescription * pTD1 = 0; | |||||
| 225 | OUString sTypeName1( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.uno.Exception")(&("com.sun.star.uno.Exception")[0]), ((sal_Int32)((sizeof ("com.sun.star.uno.Exception") / sizeof (("com.sun.star.uno.Exception" )[0]))-1)), (((rtl_TextEncoding) 11)) ); | |||||
| 226 | ||||||
| 227 | typelib_CompoundMember_Init aMembers[2]; | |||||
| 228 | OUString sMemberType0( RTL_CONSTASCII_USTRINGPARAM("string")(&("string")[0]), ((sal_Int32)((sizeof ("string") / sizeof (("string")[0]))-1)), (((rtl_TextEncoding) 11)) ); | |||||
| 229 | OUString sMemberName0( RTL_CONSTASCII_USTRINGPARAM("Message")(&("Message")[0]), ((sal_Int32)((sizeof ("Message") / sizeof (("Message")[0]))-1)), (((rtl_TextEncoding) 11)) ); | |||||
| 230 | aMembers[0].eTypeClass = typelib_TypeClass_STRING; | |||||
| 231 | aMembers[0].pTypeName = sMemberType0.pData; | |||||
| 232 | aMembers[0].pMemberName = sMemberName0.pData; | |||||
| 233 | OUString sMemberType1( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.uno.XInterface")(&("com.sun.star.uno.XInterface")[0]), ((sal_Int32)((sizeof ("com.sun.star.uno.XInterface") / sizeof (("com.sun.star.uno.XInterface" )[0]))-1)), (((rtl_TextEncoding) 11)) ); | |||||
| 234 | OUString sMemberName1( RTL_CONSTASCII_USTRINGPARAM("Context")(&("Context")[0]), ((sal_Int32)((sizeof ("Context") / sizeof (("Context")[0]))-1)), (((rtl_TextEncoding) 11)) ); | |||||
| 235 | aMembers[1].eTypeClass = typelib_TypeClass_INTERFACE; | |||||
| 236 | aMembers[1].pTypeName = sMemberType1.pData; | |||||
| 237 | aMembers[1].pMemberName = sMemberName1.pData; | |||||
| 238 | ||||||
| 239 | ::typelib_typedescription_new( | |||||
| 240 | &pTD1, typelib_TypeClass_EXCEPTION, sTypeName1.pData, 0, 2, aMembers ); | |||||
| 241 | typelib_typedescription_register( &pTD1 ); | |||||
| 242 | typelib_typedescriptionreference_acquire( | |||||
| 243 | s_aTypes[typelib_TypeClass_EXCEPTION] = pTD1->pWeakRef ); | |||||
| 244 | // another static ref: | |||||
| 245 | ++s_aTypes[typelib_TypeClass_EXCEPTION]->nStaticRefCount; | |||||
| 246 | // RuntimeException | |||||
| 247 | OUString sTypeName2( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.uno.RuntimeException")(&("com.sun.star.uno.RuntimeException")[0]), ((sal_Int32) ((sizeof ("com.sun.star.uno.RuntimeException") / sizeof (("com.sun.star.uno.RuntimeException" )[0]))-1)), (((rtl_TextEncoding) 11)) ); | |||||
| 248 | ::typelib_typedescription_new( | |||||
| 249 | &pTD1, typelib_TypeClass_EXCEPTION, sTypeName2.pData, s_aTypes[typelib_TypeClass_EXCEPTION], 0, 0 ); | |||||
| 250 | ::typelib_typedescription_register( &pTD1 ); | |||||
| 251 | ::typelib_typedescription_release( pTD1 ); | |||||
| 252 | } | |||||
| 253 | // XInterface members | |||||
| 254 | typelib_InterfaceMethodTypeDescription * pMethod = 0; | |||||
| 255 | typelib_Parameter_Init aParameters[1]; | |||||
| 256 | OUString sParamName0( RTL_CONSTASCII_USTRINGPARAM("aType")(&("aType")[0]), ((sal_Int32)((sizeof ("aType") / sizeof ( ("aType")[0]))-1)), (((rtl_TextEncoding) 11)) ); | |||||
| 257 | OUString sParamType0( RTL_CONSTASCII_USTRINGPARAM("type")(&("type")[0]), ((sal_Int32)((sizeof ("type") / sizeof (( "type")[0]))-1)), (((rtl_TextEncoding) 11)) ); | |||||
| 258 | aParameters[0].pParamName = sParamName0.pData; | |||||
| 259 | aParameters[0].eTypeClass = typelib_TypeClass_TYPE; | |||||
| 260 | aParameters[0].pTypeName = sParamType0.pData; | |||||
| 261 | aParameters[0].bIn = sal_True((sal_Bool)1); | |||||
| 262 | aParameters[0].bOut = sal_False((sal_Bool)0); | |||||
| 263 | rtl_uString * pExceptions[1]; | |||||
| 264 | OUString sExceptionName0( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.uno.RuntimeException")(&("com.sun.star.uno.RuntimeException")[0]), ((sal_Int32) ((sizeof ("com.sun.star.uno.RuntimeException") / sizeof (("com.sun.star.uno.RuntimeException" )[0]))-1)), (((rtl_TextEncoding) 11)) ); | |||||
| 265 | pExceptions[0] = sExceptionName0.pData; | |||||
| 266 | OUString sReturnType0( RTL_CONSTASCII_USTRINGPARAM("any")(&("any")[0]), ((sal_Int32)((sizeof ("any") / sizeof (("any" )[0]))-1)), (((rtl_TextEncoding) 11)) ); | |||||
| 267 | typelib_typedescription_newInterfaceMethod( | |||||
| 268 | &pMethod, 0, sal_False((sal_Bool)0), sMethodName0.pData, | |||||
| 269 | typelib_TypeClass_ANY, sReturnType0.pData, | |||||
| 270 | 1, aParameters, 1, pExceptions ); | |||||
| 271 | ::typelib_typedescription_register( (typelib_TypeDescription**)&pMethod ); | |||||
| 272 | ||||||
| 273 | OUString sReturnType1( RTL_CONSTASCII_USTRINGPARAM("void")(&("void")[0]), ((sal_Int32)((sizeof ("void") / sizeof (( "void")[0]))-1)), (((rtl_TextEncoding) 11)) ); | |||||
| 274 | ::typelib_typedescription_newInterfaceMethod( | |||||
| 275 | &pMethod, 1, sal_True((sal_Bool)1), sMethodName1.pData, | |||||
| 276 | typelib_TypeClass_VOID, sReturnType1.pData, 0, 0, 0, 0 ); | |||||
| 277 | ::typelib_typedescription_register( (typelib_TypeDescription**)&pMethod ); | |||||
| 278 | ||||||
| 279 | ::typelib_typedescription_newInterfaceMethod( | |||||
| 280 | &pMethod, 2, sal_True((sal_Bool)1), sMethodName2.pData, | |||||
| 281 | typelib_TypeClass_VOID, sReturnType1.pData, | |||||
| 282 | 0, 0, 0, 0 ); | |||||
| 283 | ::typelib_typedescription_register( (typelib_TypeDescription**)&pMethod ); | |||||
| 284 | ::typelib_typedescription_release( (typelib_TypeDescription*)pMethod ); | |||||
| 285 | } | |||||
| 286 | break; | |||||
| 287 | } | |||||
| 288 | default: | |||||
| 289 | { | |||||
| 290 | OUString aTypeName( OUString::createFromAscii( s_aTypeNames[eTypeClass] ) ); | |||||
| 291 | ::typelib_typedescriptionreference_new( &s_aTypes[eTypeClass], eTypeClass, aTypeName.pData ); | |||||
| 292 | // another static ref: | |||||
| 293 | ++s_aTypes[eTypeClass]->nStaticRefCount; | |||||
| 294 | } | |||||
| 295 | } | |||||
| 296 | } | |||||
| 297 | } | |||||
| 298 | return &s_aTypes[eTypeClass]; | |||||
| 299 | } | |||||
| 300 | ||||||
| 301 | //################################################################################################## | |||||
| 302 | CPPU_DLLPUBLIC__attribute__ ((visibility("default"))) void SAL_CALL typelib_static_type_init( | |||||
| 303 | typelib_TypeDescriptionReference ** ppRef, | |||||
| 304 | typelib_TypeClass eTypeClass, const sal_Char * pTypeName ) | |||||
| 305 | SAL_THROW_EXTERN_C()throw () | |||||
| 306 | { | |||||
| 307 | if (! *ppRef) | |||||
| 308 | { | |||||
| 309 | MutexGuard aGuard( typelib_StaticInitMutex::get() ); | |||||
| 310 | if (! *ppRef) | |||||
| 311 | { | |||||
| 312 | OUString aTypeName( OUString::createFromAscii( pTypeName ) ); | |||||
| 313 | ::typelib_typedescriptionreference_new( ppRef, eTypeClass, aTypeName.pData ); | |||||
| 314 | ||||||
| 315 | // another static ref: | |||||
| 316 | ++((*ppRef)->nStaticRefCount); | |||||
| 317 | } | |||||
| 318 | } | |||||
| 319 | } | |||||
| 320 | ||||||
| 321 | //################################################################################################## | |||||
| 322 | CPPU_DLLPUBLIC__attribute__ ((visibility("default"))) void SAL_CALL typelib_static_sequence_type_init( | |||||
| 323 | typelib_TypeDescriptionReference ** ppRef, | |||||
| 324 | typelib_TypeDescriptionReference * pElementType ) | |||||
| 325 | SAL_THROW_EXTERN_C()throw () | |||||
| 326 | { | |||||
| 327 | if (! *ppRef) | |||||
| 328 | { | |||||
| 329 | MutexGuard aGuard( typelib_StaticInitMutex::get() ); | |||||
| 330 | if (! *ppRef) | |||||
| 331 | { | |||||
| 332 | OUStringBuffer aBuf( 32 ); | |||||
| 333 | aBuf.appendAscii( "[]" ); | |||||
| 334 | aBuf.append( pElementType->pTypeName ); | |||||
| 335 | OUString aTypeName( aBuf.makeStringAndClear() ); | |||||
| 336 | ||||||
| 337 | assert( ! TYPELIB_TYPEDESCRIPTIONREFERENCE_ISREALLYWEAK(typelib_TypeClass_SEQUENCE) )((! ((typelib_TypeClass_SEQUENCE) == typelib_TypeClass_INTERFACE_METHOD || (typelib_TypeClass_SEQUENCE) == typelib_TypeClass_INTERFACE_ATTRIBUTE )) ? static_cast<void> (0) : __assert_fail ("! ((typelib_TypeClass_SEQUENCE) == typelib_TypeClass_INTERFACE_METHOD || (typelib_TypeClass_SEQUENCE) == typelib_TypeClass_INTERFACE_ATTRIBUTE)" , "/usr/local/src/libreoffice/cppu/source/typelib/static_types.cxx" , 337, __PRETTY_FUNCTION__)); | |||||
| 338 | *ppRef = igetTypeByName( aTypeName.pData ); | |||||
| 339 | if (!*ppRef) | |||||
| 340 | { | |||||
| 341 | typelib_TypeDescription * pReg = 0; | |||||
| 342 | ::typelib_typedescription_new( | |||||
| 343 | &pReg, typelib_TypeClass_SEQUENCE, | |||||
| 344 | aTypeName.pData, pElementType, 0, 0 ); | |||||
| 345 | ||||||
| 346 | ::typelib_typedescription_register( &pReg ); | |||||
| 347 | *ppRef = (typelib_TypeDescriptionReference *)pReg; | |||||
| 348 | assert( *ppRef == pReg->pWeakRef )((*ppRef == pReg->pWeakRef) ? static_cast<void> (0) : __assert_fail ("*ppRef == pReg->pWeakRef", "/usr/local/src/libreoffice/cppu/source/typelib/static_types.cxx" , 348, __PRETTY_FUNCTION__)); | |||||
| 349 | } | |||||
| 350 | // another static ref: | |||||
| 351 | ++((*ppRef)->nStaticRefCount); | |||||
| 352 | } | |||||
| 353 | } | |||||
| 354 | } | |||||
| 355 | ||||||
| 356 | //################################################################################################## | |||||
| 357 | namespace { | |||||
| 358 | ||||||
| 359 | void init( | |||||
| 360 | typelib_TypeDescriptionReference ** ppRef, | |||||
| 361 | typelib_TypeClass eTypeClass, const sal_Char * pTypeName, | |||||
| 362 | typelib_TypeDescriptionReference * pBaseType, | |||||
| 363 | sal_Int32 nMembers, typelib_TypeDescriptionReference ** ppMembers, | |||||
| 364 | sal_Bool const * pParameterizedTypes) | |||||
| 365 | { | |||||
| 366 | assert( eTypeClass == typelib_TypeClass_STRUCT || eTypeClass == typelib_TypeClass_EXCEPTION )((eTypeClass == typelib_TypeClass_STRUCT || eTypeClass == typelib_TypeClass_EXCEPTION ) ? static_cast<void> (0) : __assert_fail ("eTypeClass == typelib_TypeClass_STRUCT || eTypeClass == typelib_TypeClass_EXCEPTION" , "/usr/local/src/libreoffice/cppu/source/typelib/static_types.cxx" , 366, __PRETTY_FUNCTION__)); | |||||
| 367 | ||||||
| 368 | if (! *ppRef) | |||||
| 369 | { | |||||
| 370 | MutexGuard aGuard( typelib_StaticInitMutex::get() ); | |||||
| 371 | if (! *ppRef) | |||||
| 372 | { | |||||
| 373 | assert( ! TYPELIB_TYPEDESCRIPTIONREFERENCE_ISREALLYWEAK(eTypeClass) )((! ((eTypeClass) == typelib_TypeClass_INTERFACE_METHOD || (eTypeClass ) == typelib_TypeClass_INTERFACE_ATTRIBUTE)) ? static_cast< void> (0) : __assert_fail ("! ((eTypeClass) == typelib_TypeClass_INTERFACE_METHOD || (eTypeClass) == typelib_TypeClass_INTERFACE_ATTRIBUTE)" , "/usr/local/src/libreoffice/cppu/source/typelib/static_types.cxx" , 373, __PRETTY_FUNCTION__)); | |||||
| 374 | OUString aTypeName( OUString::createFromAscii( pTypeName ) ); | |||||
| 375 | *ppRef = igetTypeByName( aTypeName.pData ); | |||||
| 376 | if (!*ppRef) | |||||
| 377 | { | |||||
| 378 | typelib_CompoundTypeDescription * pComp = 0; | |||||
| 379 | ::typelib_typedescription_newEmpty( | |||||
| 380 | (typelib_TypeDescription **)&pComp, eTypeClass, aTypeName.pData ); | |||||
| 381 | ||||||
| 382 | sal_Int32 nOffset = 0; | |||||
| 383 | if (pBaseType) | |||||
| 384 | { | |||||
| 385 | ::typelib_typedescriptionreference_getDescription( | |||||
| 386 | (typelib_TypeDescription **)&pComp->pBaseTypeDescription, pBaseType ); | |||||
| 387 | assert( pComp->pBaseTypeDescription )((pComp->pBaseTypeDescription) ? static_cast<void> ( 0) : __assert_fail ("pComp->pBaseTypeDescription", "/usr/local/src/libreoffice/cppu/source/typelib/static_types.cxx" , 387, __PRETTY_FUNCTION__)); | |||||
| 388 | nOffset = ((typelib_TypeDescription *)pComp->pBaseTypeDescription)->nSize; | |||||
| 389 | assert( newAlignedSize( 0, ((typelib_TypeDescription *)pComp->pBaseTypeDescription)->nSize, ((typelib_TypeDescription *)pComp->pBaseTypeDescription)->nAlignment ) == ((typelib_TypeDescription *)pComp->pBaseTypeDescription)->nSize )((newAlignedSize( 0, ((typelib_TypeDescription *)pComp->pBaseTypeDescription )->nSize, ((typelib_TypeDescription *)pComp->pBaseTypeDescription )->nAlignment ) == ((typelib_TypeDescription *)pComp->pBaseTypeDescription )->nSize) ? static_cast<void> (0) : __assert_fail ("newAlignedSize( 0, ((typelib_TypeDescription *)pComp->pBaseTypeDescription)->nSize, ((typelib_TypeDescription *)pComp->pBaseTypeDescription)->nAlignment ) == ((typelib_TypeDescription *)pComp->pBaseTypeDescription)->nSize" , "/usr/local/src/libreoffice/cppu/source/typelib/static_types.cxx" , 389, __PRETTY_FUNCTION__)); // unexpected offset | |||||
| 390 | } | |||||
| 391 | ||||||
| 392 | if (nMembers) | |||||
| 393 | { | |||||
| 394 | pComp->nMembers = nMembers; | |||||
| 395 | pComp->pMemberOffsets = new sal_Int32[ nMembers ]; | |||||
| 396 | pComp->ppTypeRefs = new typelib_TypeDescriptionReference *[ nMembers ]; | |||||
| 397 | if (pParameterizedTypes != 0) { | |||||
| 398 | reinterpret_cast< typelib_StructTypeDescription * >( | |||||
| 399 | pComp)->pParameterizedTypes | |||||
| 400 | = new sal_Bool[nMembers]; | |||||
| 401 | } | |||||
| 402 | for ( sal_Int32 i = 0 ; i < nMembers; ++i ) | |||||
| 403 | { | |||||
| 404 | ::typelib_typedescriptionreference_acquire( | |||||
| 405 | pComp->ppTypeRefs[i] = ppMembers[i] ); | |||||
| 406 | // write offset | |||||
| 407 | typelib_TypeDescription * pTD = 0; | |||||
| 408 | TYPELIB_DANGER_GET( &pTD, pComp->ppTypeRefs[i] ){ typelib_TypeDescriptionReference * pMacroTypeRef = (pComp-> ppTypeRefs[i]); typelib_TypeDescription ** ppMacroTypeDescr = (&pTD); if (((pMacroTypeRef->eTypeClass) == typelib_TypeClass_INTERFACE_METHOD || (pMacroTypeRef->eTypeClass) == typelib_TypeClass_INTERFACE_ATTRIBUTE )) { typelib_typedescriptionreference_getDescription( ppMacroTypeDescr , pMacroTypeRef ); } else if (!pMacroTypeRef->pType || !pMacroTypeRef ->pType->pWeakRef) { typelib_typedescriptionreference_getDescription ( ppMacroTypeDescr, pMacroTypeRef ); if (*ppMacroTypeDescr) typelib_typedescription_release ( *ppMacroTypeDescr ); } else { *ppMacroTypeDescr = pMacroTypeRef ->pType; } }; | |||||
| 409 | assert( pTD->nSize )((pTD->nSize) ? static_cast<void> (0) : __assert_fail ("pTD->nSize", "/usr/local/src/libreoffice/cppu/source/typelib/static_types.cxx" , 409, __PRETTY_FUNCTION__)); // void member? | |||||
| ||||||
| 410 | nOffset = newAlignedSize( nOffset, pTD->nSize, pTD->nAlignment ); | |||||
| 411 | pComp->pMemberOffsets[i] = nOffset - pTD->nSize; | |||||
| 412 | TYPELIB_DANGER_RELEASE( pTD ){ if ((((pTD)->eTypeClass) == typelib_TypeClass_INTERFACE_METHOD || ((pTD)->eTypeClass) == typelib_TypeClass_INTERFACE_ATTRIBUTE )) typelib_typedescription_release( pTD ); }; | |||||
| 413 | ||||||
| 414 | if (pParameterizedTypes != 0) { | |||||
| 415 | reinterpret_cast< typelib_StructTypeDescription * >( | |||||
| 416 | pComp)->pParameterizedTypes[i] | |||||
| 417 | = pParameterizedTypes[i]; | |||||
| 418 | } | |||||
| 419 | } | |||||
| 420 | } | |||||
| 421 | ||||||
| 422 | typelib_TypeDescription * pReg = (typelib_TypeDescription *)pComp; | |||||
| 423 | pReg->pWeakRef = (typelib_TypeDescriptionReference *)pReg; | |||||
| 424 | // sizeof( void ) not allowed | |||||
| 425 | pReg->nSize = ::typelib_typedescription_getAlignedUnoSize( pReg, 0, pReg->nAlignment ); | |||||
| 426 | pReg->nAlignment = adjustAlignment( pReg->nAlignment ); | |||||
| 427 | pReg->bComplete = sal_False((sal_Bool)0); | |||||
| 428 | ||||||
| 429 | ::typelib_typedescription_register( &pReg ); | |||||
| 430 | *ppRef = (typelib_TypeDescriptionReference *)pReg; | |||||
| 431 | assert( *ppRef == pReg->pWeakRef )((*ppRef == pReg->pWeakRef) ? static_cast<void> (0) : __assert_fail ("*ppRef == pReg->pWeakRef", "/usr/local/src/libreoffice/cppu/source/typelib/static_types.cxx" , 431, __PRETTY_FUNCTION__)); | |||||
| 432 | } | |||||
| 433 | // another static ref: | |||||
| 434 | ++((*ppRef)->nStaticRefCount); | |||||
| 435 | } | |||||
| 436 | } | |||||
| 437 | } | |||||
| 438 | ||||||
| 439 | } | |||||
| 440 | ||||||
| 441 | CPPU_DLLPUBLIC__attribute__ ((visibility("default"))) void SAL_CALL typelib_static_compound_type_init( | |||||
| 442 | typelib_TypeDescriptionReference ** ppRef, | |||||
| 443 | typelib_TypeClass eTypeClass, const sal_Char * pTypeName, | |||||
| 444 | typelib_TypeDescriptionReference * pBaseType, | |||||
| 445 | sal_Int32 nMembers, typelib_TypeDescriptionReference ** ppMembers ) | |||||
| 446 | SAL_THROW_EXTERN_C()throw () | |||||
| 447 | { | |||||
| 448 | init(ppRef, eTypeClass, pTypeName, pBaseType, nMembers, ppMembers, 0); | |||||
| 449 | } | |||||
| 450 | ||||||
| 451 | CPPU_DLLPUBLIC__attribute__ ((visibility("default"))) void SAL_CALL typelib_static_struct_type_init( | |||||
| 452 | typelib_TypeDescriptionReference ** ppRef, const sal_Char * pTypeName, | |||||
| 453 | typelib_TypeDescriptionReference * pBaseType, | |||||
| 454 | sal_Int32 nMembers, typelib_TypeDescriptionReference ** ppMembers, | |||||
| 455 | sal_Bool const * pParameterizedTypes ) | |||||
| 456 | SAL_THROW_EXTERN_C()throw () | |||||
| 457 | { | |||||
| 458 | init( | |||||
| ||||||
| 459 | ppRef, typelib_TypeClass_STRUCT, pTypeName, pBaseType, nMembers, | |||||
| 460 | ppMembers, pParameterizedTypes); | |||||
| 461 | } | |||||
| 462 | ||||||
| 463 | //################################################################################################## | |||||
| 464 | CPPU_DLLPUBLIC__attribute__ ((visibility("default"))) void SAL_CALL typelib_static_interface_type_init( | |||||
| 465 | typelib_TypeDescriptionReference ** ppRef, | |||||
| 466 | const sal_Char * pTypeName, | |||||
| 467 | typelib_TypeDescriptionReference * pBaseType ) | |||||
| 468 | SAL_THROW_EXTERN_C()throw () | |||||
| 469 | { | |||||
| 470 | typelib_static_mi_interface_type_init( | |||||
| 471 | ppRef, pTypeName, pBaseType == 0 ? 0 : 1, &pBaseType); | |||||
| 472 | } | |||||
| 473 | ||||||
| 474 | //################################################################################################## | |||||
| 475 | CPPU_DLLPUBLIC__attribute__ ((visibility("default"))) void SAL_CALL typelib_static_mi_interface_type_init( | |||||
| 476 | typelib_TypeDescriptionReference ** ppRef, | |||||
| 477 | const sal_Char * pTypeName, | |||||
| 478 | sal_Int32 nBaseTypes, | |||||
| 479 | typelib_TypeDescriptionReference ** ppBaseTypes ) | |||||
| 480 | SAL_THROW_EXTERN_C()throw () | |||||
| 481 | { | |||||
| 482 | if (! *ppRef) | |||||
| 483 | { | |||||
| 484 | MutexGuard aGuard( typelib_StaticInitMutex::get() ); | |||||
| 485 | if (! *ppRef) | |||||
| 486 | { | |||||
| 487 | assert( ! TYPELIB_TYPEDESCRIPTIONREFERENCE_ISREALLYWEAK(typelib_TypeClass_INTERFACE) )((! ((typelib_TypeClass_INTERFACE) == typelib_TypeClass_INTERFACE_METHOD || (typelib_TypeClass_INTERFACE) == typelib_TypeClass_INTERFACE_ATTRIBUTE )) ? static_cast<void> (0) : __assert_fail ("! ((typelib_TypeClass_INTERFACE) == typelib_TypeClass_INTERFACE_METHOD || (typelib_TypeClass_INTERFACE) == typelib_TypeClass_INTERFACE_ATTRIBUTE)" , "/usr/local/src/libreoffice/cppu/source/typelib/static_types.cxx" , 487, __PRETTY_FUNCTION__)); | |||||
| 488 | OUString aTypeName( OUString::createFromAscii( pTypeName ) ); | |||||
| 489 | *ppRef = igetTypeByName( aTypeName.pData ); | |||||
| 490 | if (!*ppRef) | |||||
| 491 | { | |||||
| 492 | typelib_InterfaceTypeDescription * pIface = 0; | |||||
| 493 | ::typelib_typedescription_newEmpty( | |||||
| 494 | (typelib_TypeDescription **)&pIface, typelib_TypeClass_INTERFACE, aTypeName.pData ); | |||||
| 495 | ||||||
| 496 | pIface->nBaseTypes = std::max< sal_Int32 >(nBaseTypes, 1); | |||||
| 497 | pIface->ppBaseTypes = new typelib_InterfaceTypeDescription *[ | |||||
| 498 | pIface->nBaseTypes]; | |||||
| 499 | if (nBaseTypes > 0) | |||||
| 500 | { | |||||
| 501 | for (sal_Int32 i = 0; i < nBaseTypes; ++i) { | |||||
| 502 | pIface->ppBaseTypes[i] = 0; | |||||
| 503 | ::typelib_typedescriptionreference_getDescription( | |||||
| 504 | (typelib_TypeDescription **)&pIface->ppBaseTypes[i], ppBaseTypes[i] ); | |||||
| 505 | assert( pIface->ppBaseTypes[i] )((pIface->ppBaseTypes[i]) ? static_cast<void> (0) : __assert_fail ("pIface->ppBaseTypes[i]", "/usr/local/src/libreoffice/cppu/source/typelib/static_types.cxx" , 505, __PRETTY_FUNCTION__)); | |||||
| 506 | } | |||||
| 507 | } | |||||
| 508 | else | |||||
| 509 | { | |||||
| 510 | pIface->ppBaseTypes[0] = 0; | |||||
| 511 | ::typelib_typedescriptionreference_getDescription( | |||||
| 512 | (typelib_TypeDescription **)&pIface->ppBaseTypes[0], | |||||
| 513 | * ::typelib_static_type_getByTypeClass( typelib_TypeClass_INTERFACE ) ); | |||||
| 514 | assert( pIface->ppBaseTypes[0] )((pIface->ppBaseTypes[0]) ? static_cast<void> (0) : __assert_fail ("pIface->ppBaseTypes[0]", "/usr/local/src/libreoffice/cppu/source/typelib/static_types.cxx" , 514, __PRETTY_FUNCTION__)); | |||||
| 515 | } | |||||
| 516 | pIface->pBaseTypeDescription = pIface->ppBaseTypes[0]; | |||||
| 517 | typelib_typedescription_acquire( | |||||
| 518 | &pIface->pBaseTypeDescription->aBase); | |||||
| 519 | ||||||
| 520 | typelib_TypeDescription * pReg = (typelib_TypeDescription *)pIface; | |||||
| 521 | pReg->pWeakRef = (typelib_TypeDescriptionReference *)pReg; | |||||
| 522 | // sizeof( void ) not allowed | |||||
| 523 | pReg->nSize = ::typelib_typedescription_getAlignedUnoSize( pReg, 0, pReg->nAlignment ); | |||||
| 524 | ||||||
| 525 | pReg->nAlignment = adjustAlignment( pReg->nAlignment ); | |||||
| 526 | pReg->bComplete = sal_False((sal_Bool)0); | |||||
| 527 | ||||||
| 528 | ::typelib_typedescription_register( &pReg ); | |||||
| 529 | *ppRef = (typelib_TypeDescriptionReference *)pReg; | |||||
| 530 | assert( *ppRef == pReg->pWeakRef )((*ppRef == pReg->pWeakRef) ? static_cast<void> (0) : __assert_fail ("*ppRef == pReg->pWeakRef", "/usr/local/src/libreoffice/cppu/source/typelib/static_types.cxx" , 530, __PRETTY_FUNCTION__)); | |||||
| 531 | } | |||||
| 532 | // another static ref: | |||||
| 533 | ++((*ppRef)->nStaticRefCount); | |||||
| 534 | } | |||||
| 535 | } | |||||
| 536 | } | |||||
| 537 | ||||||
| 538 | //################################################################################################## | |||||
| 539 | CPPU_DLLPUBLIC__attribute__ ((visibility("default"))) void SAL_CALL typelib_static_enum_type_init( | |||||
| 540 | typelib_TypeDescriptionReference ** ppRef, | |||||
| 541 | const sal_Char * pTypeName, | |||||
| 542 | sal_Int32 nDefaultValue ) | |||||
| 543 | SAL_THROW_EXTERN_C()throw () | |||||
| 544 | { | |||||
| 545 | if (! *ppRef) | |||||
| 546 | { | |||||
| 547 | MutexGuard aGuard( typelib_StaticInitMutex::get() ); | |||||
| 548 | if (! *ppRef) | |||||
| 549 | { | |||||
| 550 | assert( ! TYPELIB_TYPEDESCRIPTIONREFERENCE_ISREALLYWEAK(typelib_TypeClass_ENUM) )((! ((typelib_TypeClass_ENUM) == typelib_TypeClass_INTERFACE_METHOD || (typelib_TypeClass_ENUM) == typelib_TypeClass_INTERFACE_ATTRIBUTE )) ? static_cast<void> (0) : __assert_fail ("! ((typelib_TypeClass_ENUM) == typelib_TypeClass_INTERFACE_METHOD || (typelib_TypeClass_ENUM) == typelib_TypeClass_INTERFACE_ATTRIBUTE)" , "/usr/local/src/libreoffice/cppu/source/typelib/static_types.cxx" , 550, __PRETTY_FUNCTION__)); | |||||
| 551 | OUString aTypeName( OUString::createFromAscii( pTypeName ) ); | |||||
| 552 | *ppRef = igetTypeByName( aTypeName.pData ); | |||||
| 553 | if (!*ppRef) | |||||
| 554 | { | |||||
| 555 | typelib_TypeDescription * pReg = 0; | |||||
| 556 | ::typelib_typedescription_newEmpty( | |||||
| 557 | &pReg, typelib_TypeClass_ENUM, aTypeName.pData ); | |||||
| 558 | typelib_EnumTypeDescription * pEnum = (typelib_EnumTypeDescription *)pReg; | |||||
| 559 | ||||||
| 560 | pEnum->nDefaultEnumValue = nDefaultValue; | |||||
| 561 | ||||||
| 562 | pReg->pWeakRef = (typelib_TypeDescriptionReference *)pReg; | |||||
| 563 | // sizeof( void ) not allowed | |||||
| 564 | pReg->nSize = ::typelib_typedescription_getAlignedUnoSize( pReg, 0, pReg->nAlignment ); | |||||
| 565 | pReg->nAlignment = ::adjustAlignment( pReg->nAlignment ); | |||||
| 566 | pReg->bComplete = sal_False((sal_Bool)0); | |||||
| 567 | ||||||
| 568 | ::typelib_typedescription_register( &pReg ); | |||||
| 569 | *ppRef = (typelib_TypeDescriptionReference *)pReg; | |||||
| 570 | assert( *ppRef == pReg->pWeakRef )((*ppRef == pReg->pWeakRef) ? static_cast<void> (0) : __assert_fail ("*ppRef == pReg->pWeakRef", "/usr/local/src/libreoffice/cppu/source/typelib/static_types.cxx" , 570, __PRETTY_FUNCTION__)); | |||||
| 571 | } | |||||
| 572 | // another static ref: | |||||
| 573 | ++((*ppRef)->nStaticRefCount); | |||||
| 574 | } | |||||
| 575 | } | |||||
| 576 | } | |||||
| 577 | ||||||
| 578 | //################################################################################################## | |||||
| 579 | CPPU_DLLPUBLIC__attribute__ ((visibility("default"))) void SAL_CALL typelib_static_array_type_init( | |||||
| 580 | typelib_TypeDescriptionReference ** ppRef, | |||||
| 581 | typelib_TypeDescriptionReference * pElementTypeRef, | |||||
| 582 | sal_Int32 nDimensions, ... ) | |||||
| 583 | SAL_THROW_EXTERN_C()throw () | |||||
| 584 | { | |||||
| 585 | if (! *ppRef) | |||||
| 586 | { | |||||
| 587 | MutexGuard aGuard( typelib_StaticInitMutex::get() ); | |||||
| 588 | if (! *ppRef) | |||||
| 589 | { | |||||
| 590 | OUStringBuffer aBuf( 32 ); | |||||
| 591 | aBuf.append( pElementTypeRef->pTypeName ); | |||||
| 592 | ||||||
| 593 | va_list dimArgs; | |||||
| 594 | va_start( dimArgs, nDimensions )__builtin_va_start(dimArgs, nDimensions); | |||||
| 595 | sal_Int32 dim = 0; | |||||
| 596 | sal_Int32 nElements = 1; | |||||
| 597 | sal_Int32* pDimensions = new sal_Int32[nDimensions]; | |||||
| 598 | for (sal_Int32 i=0; i < nDimensions; i++) | |||||
| 599 | { | |||||
| 600 | dim = va_arg( dimArgs, int)__builtin_va_arg(dimArgs, int); | |||||
| 601 | pDimensions[i] = dim; | |||||
| 602 | aBuf.appendAscii("["); | |||||
| 603 | aBuf.append(dim); | |||||
| 604 | aBuf.appendAscii("]"); | |||||
| 605 | nElements *= dim; | |||||
| 606 | } | |||||
| 607 | va_end( dimArgs )__builtin_va_end(dimArgs); | |||||
| 608 | OUString aTypeName( aBuf.makeStringAndClear() ); | |||||
| 609 | ||||||
| 610 | assert( ! TYPELIB_TYPEDESCRIPTIONREFERENCE_ISREALLYWEAK(typelib_TypeClass_ARRAY) )((! ((typelib_TypeClass_ARRAY) == typelib_TypeClass_INTERFACE_METHOD || (typelib_TypeClass_ARRAY) == typelib_TypeClass_INTERFACE_ATTRIBUTE )) ? static_cast<void> (0) : __assert_fail ("! ((typelib_TypeClass_ARRAY) == typelib_TypeClass_INTERFACE_METHOD || (typelib_TypeClass_ARRAY) == typelib_TypeClass_INTERFACE_ATTRIBUTE)" , "/usr/local/src/libreoffice/cppu/source/typelib/static_types.cxx" , 610, __PRETTY_FUNCTION__)); | |||||
| 611 | *ppRef = igetTypeByName( aTypeName.pData ); | |||||
| 612 | if (!*ppRef) | |||||
| 613 | { | |||||
| 614 | typelib_TypeDescription * pReg = 0; | |||||
| 615 | ::typelib_typedescription_newEmpty( | |||||
| 616 | &pReg, typelib_TypeClass_ARRAY, aTypeName.pData ); | |||||
| 617 | typelib_ArrayTypeDescription * pArray = (typelib_ArrayTypeDescription *)pReg; | |||||
| 618 | ||||||
| 619 | pArray->nDimensions = nDimensions; | |||||
| 620 | pArray->nTotalElements = nElements; | |||||
| 621 | pArray->pDimensions = pDimensions; | |||||
| 622 | ||||||
| 623 | typelib_typedescriptionreference_acquire(pElementTypeRef); | |||||
| 624 | ((typelib_IndirectTypeDescription*)pArray)->pType = pElementTypeRef; | |||||
| 625 | ||||||
| 626 | pReg->pWeakRef = (typelib_TypeDescriptionReference *)pReg; | |||||
| 627 | // sizeof( void ) not allowed | |||||
| 628 | pReg->nSize = ::typelib_typedescription_getAlignedUnoSize( pReg, 0, pReg->nAlignment ); | |||||
| 629 | pReg->nAlignment = ::adjustAlignment( pReg->nAlignment ); | |||||
| 630 | pReg->bComplete = sal_True((sal_Bool)1); | |||||
| 631 | ||||||
| 632 | ::typelib_typedescription_register( &pReg ); | |||||
| 633 | *ppRef = (typelib_TypeDescriptionReference *)pReg; | |||||
| 634 | assert( *ppRef == pReg->pWeakRef )((*ppRef == pReg->pWeakRef) ? static_cast<void> (0) : __assert_fail ("*ppRef == pReg->pWeakRef", "/usr/local/src/libreoffice/cppu/source/typelib/static_types.cxx" , 634, __PRETTY_FUNCTION__)); | |||||
| 635 | } else | |||||
| 636 | delete [] pDimensions; | |||||
| 637 | // another static ref: | |||||
| 638 | ++((*ppRef)->nStaticRefCount); | |||||
| 639 | } | |||||
| 640 | } | |||||
| 641 | } | |||||
| 642 | ||||||
| 643 | } // extern "C" | |||||
| 644 | ||||||
| 645 | } | |||||
| 646 | ||||||
| 647 | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |