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