xref: /AOO41X/main/registry/source/reflwrit.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_registry.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include <new>
32*cdf0e10cSrcweir #include <sal/types.h>
33*cdf0e10cSrcweir #include <sal/macros.h>
34*cdf0e10cSrcweir #include <osl/endian.h>
35*cdf0e10cSrcweir #include <rtl/alloc.h>
36*cdf0e10cSrcweir #include "rtl/string.hxx"
37*cdf0e10cSrcweir #include "rtl/ustring.hxx"
38*cdf0e10cSrcweir 
39*cdf0e10cSrcweir #include "registry/reflwrit.hxx"
40*cdf0e10cSrcweir #include "registry/version.h"
41*cdf0e10cSrcweir #include "registry/writer.h"
42*cdf0e10cSrcweir 
43*cdf0e10cSrcweir #include "reflcnst.hxx"
44*cdf0e10cSrcweir 
45*cdf0e10cSrcweir using namespace rtl;
46*cdf0e10cSrcweir 
47*cdf0e10cSrcweir namespace {
48*cdf0e10cSrcweir 
49*cdf0e10cSrcweir // Throws std::bad_alloc:
50*cdf0e10cSrcweir inline rtl::OString toByteString(rtl_uString const * str) {
51*cdf0e10cSrcweir     return rtl::OString(
52*cdf0e10cSrcweir         str->buffer, str->length, RTL_TEXTENCODING_UTF8,
53*cdf0e10cSrcweir         OUSTRING_TO_OSTRING_CVTFLAGS);
54*cdf0e10cSrcweir }
55*cdf0e10cSrcweir 
56*cdf0e10cSrcweir }
57*cdf0e10cSrcweir 
58*cdf0e10cSrcweir static sal_Unicode NULL_WSTRING[1] = { 0 };
59*cdf0e10cSrcweir 
60*cdf0e10cSrcweir #if defined ( GCC ) && ( defined ( SCO ) )
61*cdf0e10cSrcweir ORealDynamicLoader* ODynamicLoader<RegistryTypeWriter_Api>::m_pLoader = NULL;
62*cdf0e10cSrcweir #endif
63*cdf0e10cSrcweir 
64*cdf0e10cSrcweir #define BLOP_OFFSET_MAGIC       0
65*cdf0e10cSrcweir #define BLOP_OFFSET_SIZE        (BLOP_OFFSET_MAGIC + sizeof(sal_uInt32))
66*cdf0e10cSrcweir #define BLOP_OFFSET_MINOR       (BLOP_OFFSET_SIZE + sizeof(sal_uInt32))
67*cdf0e10cSrcweir #define BLOP_OFFSET_MAJOR       (BLOP_OFFSET_MINOR + sizeof(sal_uInt16))
68*cdf0e10cSrcweir #define BLOP_OFFSET_N_ENTRIES	(BLOP_OFFSET_MAJOR + sizeof(sal_uInt16))
69*cdf0e10cSrcweir #define BLOP_OFFSET_TYPE_SOURCE (BLOP_OFFSET_N_ENTRIES + sizeof(sal_uInt16))
70*cdf0e10cSrcweir #define BLOP_OFFSET_TYPE_CLASS  (BLOP_OFFSET_TYPE_SOURCE + sizeof(sal_uInt16))
71*cdf0e10cSrcweir #define BLOP_OFFSET_THIS        (BLOP_OFFSET_TYPE_CLASS + sizeof(sal_uInt16))
72*cdf0e10cSrcweir #define BLOP_OFFSET_UIK         (BLOP_OFFSET_THIS + sizeof(sal_uInt16))
73*cdf0e10cSrcweir #define BLOP_OFFSET_DOKU        (BLOP_OFFSET_UIK + sizeof(sal_uInt16))
74*cdf0e10cSrcweir #define BLOP_OFFSET_FILENAME    (BLOP_OFFSET_DOKU + sizeof(sal_uInt16))
75*cdf0e10cSrcweir #define BLOP_HEADER_N_ENTRIES   6
76*cdf0e10cSrcweir 
77*cdf0e10cSrcweir #define BLOP_OFFSET_N_SUPERTYPES 	0
78*cdf0e10cSrcweir #define BLOP_OFFSET_SUPERTYPES 		(BLOP_OFFSET_N_SUPERTYPES + sizeof(sal_uInt16))
79*cdf0e10cSrcweir 
80*cdf0e10cSrcweir #define BLOP_FIELD_ENTRY_ACCESS 	0
81*cdf0e10cSrcweir #define BLOP_FIELD_ENTRY_NAME       (BLOP_FIELD_ENTRY_ACCESS + sizeof(sal_uInt16))
82*cdf0e10cSrcweir #define BLOP_FIELD_ENTRY_TYPE       (BLOP_FIELD_ENTRY_NAME + sizeof(sal_uInt16))
83*cdf0e10cSrcweir #define BLOP_FIELD_ENTRY_VALUE      (BLOP_FIELD_ENTRY_TYPE + sizeof(sal_uInt16))
84*cdf0e10cSrcweir #define BLOP_FIELD_ENTRY_DOKU       (BLOP_FIELD_ENTRY_VALUE + sizeof(sal_uInt16))
85*cdf0e10cSrcweir #define BLOP_FIELD_ENTRY_FILENAME   (BLOP_FIELD_ENTRY_DOKU + sizeof(sal_uInt16))
86*cdf0e10cSrcweir #define BLOP_FIELD_N_ENTRIES   		6
87*cdf0e10cSrcweir 
88*cdf0e10cSrcweir #define BLOP_METHOD_SIZE        0
89*cdf0e10cSrcweir #define BLOP_METHOD_MODE        (BLOP_METHOD_SIZE + sizeof(sal_uInt16))
90*cdf0e10cSrcweir #define BLOP_METHOD_NAME        (BLOP_METHOD_MODE + sizeof(sal_uInt16))
91*cdf0e10cSrcweir #define BLOP_METHOD_RETURN      (BLOP_METHOD_NAME + sizeof(sal_uInt16))
92*cdf0e10cSrcweir #define BLOP_METHOD_DOKU        (BLOP_METHOD_RETURN + sizeof(sal_uInt16))
93*cdf0e10cSrcweir #define BLOP_METHOD_N_ENTRIES   5
94*cdf0e10cSrcweir 
95*cdf0e10cSrcweir #define BLOP_PARAM_TYPE         0
96*cdf0e10cSrcweir #define BLOP_PARAM_MODE         (BLOP_PARAM_TYPE + sizeof(sal_uInt16))
97*cdf0e10cSrcweir #define BLOP_PARAM_NAME         (BLOP_PARAM_MODE + sizeof(sal_uInt16))
98*cdf0e10cSrcweir #define BLOP_PARAM_N_ENTRIES    3
99*cdf0e10cSrcweir 
100*cdf0e10cSrcweir #define BLOP_REFERENCE_TYPE         0
101*cdf0e10cSrcweir #define BLOP_REFERENCE_NAME         (BLOP_REFERENCE_TYPE + sizeof(sal_uInt16))
102*cdf0e10cSrcweir #define BLOP_REFERENCE_DOKU         (BLOP_REFERENCE_NAME + sizeof(sal_uInt16))
103*cdf0e10cSrcweir #define BLOP_REFERENCE_ACCESS   	(BLOP_REFERENCE_DOKU + sizeof(sal_uInt16))
104*cdf0e10cSrcweir #define BLOP_REFERENCE_N_ENTRIES    4
105*cdf0e10cSrcweir 
106*cdf0e10cSrcweir sal_uInt32 UINT16StringLen(const sal_uInt8* wstring)
107*cdf0e10cSrcweir {
108*cdf0e10cSrcweir     if (!wstring) return 0;
109*cdf0e10cSrcweir 
110*cdf0e10cSrcweir     const sal_uInt8* b = wstring;
111*cdf0e10cSrcweir 
112*cdf0e10cSrcweir     while (b[0] || b[1]) b += sizeof(sal_uInt16);
113*cdf0e10cSrcweir 
114*cdf0e10cSrcweir     return ((b - wstring) / sizeof(sal_uInt16));
115*cdf0e10cSrcweir }
116*cdf0e10cSrcweir 
117*cdf0e10cSrcweir sal_uInt32 writeString(sal_uInt8* buffer, const sal_Unicode* v)
118*cdf0e10cSrcweir {
119*cdf0e10cSrcweir     sal_uInt32 len = rtl_ustr_getLength(v) + 1;
120*cdf0e10cSrcweir     sal_uInt32 i;
121*cdf0e10cSrcweir     sal_uInt8* buff = buffer;
122*cdf0e10cSrcweir 
123*cdf0e10cSrcweir     for (i = 0; i < len; i++)
124*cdf0e10cSrcweir     {
125*cdf0e10cSrcweir         buff += writeUINT16(buff, (sal_uInt16) v[i]);
126*cdf0e10cSrcweir     }
127*cdf0e10cSrcweir 
128*cdf0e10cSrcweir     return (buff - buffer);
129*cdf0e10cSrcweir }
130*cdf0e10cSrcweir 
131*cdf0e10cSrcweir sal_uInt32 readString(const sal_uInt8* buffer, sal_Unicode* v, sal_uInt32 maxSize)
132*cdf0e10cSrcweir {
133*cdf0e10cSrcweir     sal_uInt32 len = SAL_MIN(UINT16StringLen(buffer) + 1, maxSize / 2);
134*cdf0e10cSrcweir     sal_uInt32 i;
135*cdf0e10cSrcweir     sal_uInt8* buff = (sal_uInt8*)buffer;
136*cdf0e10cSrcweir 
137*cdf0e10cSrcweir     for (i = 0; i < (len - 1); i++)
138*cdf0e10cSrcweir     {
139*cdf0e10cSrcweir         sal_uInt16 aChar;
140*cdf0e10cSrcweir 
141*cdf0e10cSrcweir         buff += readUINT16(buff, aChar);
142*cdf0e10cSrcweir 
143*cdf0e10cSrcweir         v[i] = (sal_Unicode) aChar;
144*cdf0e10cSrcweir     }
145*cdf0e10cSrcweir 
146*cdf0e10cSrcweir     v[len - 1] = L'\0';
147*cdf0e10cSrcweir 
148*cdf0e10cSrcweir     return (buff - ((sal_uInt8*)buffer));
149*cdf0e10cSrcweir }
150*cdf0e10cSrcweir 
151*cdf0e10cSrcweir sal_uInt32 writeFloat(sal_uInt8* buffer, float v)
152*cdf0e10cSrcweir {
153*cdf0e10cSrcweir     union
154*cdf0e10cSrcweir     {
155*cdf0e10cSrcweir         float   v;
156*cdf0e10cSrcweir         sal_uInt32  b;
157*cdf0e10cSrcweir     } x;
158*cdf0e10cSrcweir 
159*cdf0e10cSrcweir     x.v = v;
160*cdf0e10cSrcweir 
161*cdf0e10cSrcweir #ifdef REGTYPE_IEEE_NATIVE
162*cdf0e10cSrcweir     writeUINT32(buffer, x.b);
163*cdf0e10cSrcweir #else
164*cdf0e10cSrcweir #   error no IEEE
165*cdf0e10cSrcweir #endif
166*cdf0e10cSrcweir 
167*cdf0e10cSrcweir     return sizeof(sal_uInt32);
168*cdf0e10cSrcweir }
169*cdf0e10cSrcweir 
170*cdf0e10cSrcweir sal_uInt32 writeDouble(sal_uInt8* buffer, double v)
171*cdf0e10cSrcweir {
172*cdf0e10cSrcweir     union
173*cdf0e10cSrcweir     {
174*cdf0e10cSrcweir         double v;
175*cdf0e10cSrcweir         struct
176*cdf0e10cSrcweir         {
177*cdf0e10cSrcweir             sal_uInt32  b1;
178*cdf0e10cSrcweir             sal_uInt32  b2;
179*cdf0e10cSrcweir         } b;
180*cdf0e10cSrcweir     } x;
181*cdf0e10cSrcweir 
182*cdf0e10cSrcweir     x.v = v;
183*cdf0e10cSrcweir 
184*cdf0e10cSrcweir #ifdef REGTYPE_IEEE_NATIVE
185*cdf0e10cSrcweir #   ifdef OSL_BIGENDIAN
186*cdf0e10cSrcweir     writeUINT32(buffer, x.b.b1);
187*cdf0e10cSrcweir     writeUINT32(buffer + sizeof(sal_uInt32), x.b.b2);
188*cdf0e10cSrcweir #   else
189*cdf0e10cSrcweir     writeUINT32(buffer, x.b.b2);
190*cdf0e10cSrcweir     writeUINT32(buffer + sizeof(sal_uInt32), x.b.b1);
191*cdf0e10cSrcweir #   endif
192*cdf0e10cSrcweir #else
193*cdf0e10cSrcweir #   error no IEEE
194*cdf0e10cSrcweir #endif
195*cdf0e10cSrcweir 
196*cdf0e10cSrcweir     return (sizeof(sal_uInt32) + sizeof(sal_uInt32));
197*cdf0e10cSrcweir }
198*cdf0e10cSrcweir 
199*cdf0e10cSrcweir /**************************************************************************
200*cdf0e10cSrcweir 
201*cdf0e10cSrcweir     buffer write functions
202*cdf0e10cSrcweir 
203*cdf0e10cSrcweir **************************************************************************/
204*cdf0e10cSrcweir 
205*cdf0e10cSrcweir 
206*cdf0e10cSrcweir /**************************************************************************
207*cdf0e10cSrcweir 
208*cdf0e10cSrcweir     struct CPInfo
209*cdf0e10cSrcweir 
210*cdf0e10cSrcweir **************************************************************************/
211*cdf0e10cSrcweir 
212*cdf0e10cSrcweir struct CPInfo
213*cdf0e10cSrcweir {
214*cdf0e10cSrcweir     CPInfoTag   m_tag;
215*cdf0e10cSrcweir     union
216*cdf0e10cSrcweir     {
217*cdf0e10cSrcweir         const sal_Char*     aUtf8;
218*cdf0e10cSrcweir         RTUik*          	aUik;
219*cdf0e10cSrcweir         RTConstValueUnion   aConst;
220*cdf0e10cSrcweir     } m_value;
221*cdf0e10cSrcweir 
222*cdf0e10cSrcweir     sal_uInt16		m_index;
223*cdf0e10cSrcweir     struct CPInfo*	m_next;
224*cdf0e10cSrcweir 
225*cdf0e10cSrcweir     CPInfo(CPInfoTag tag, struct CPInfo* prev);
226*cdf0e10cSrcweir 
227*cdf0e10cSrcweir     sal_uInt32 getBlopSize();
228*cdf0e10cSrcweir 
229*cdf0e10cSrcweir     sal_uInt32 toBlop(sal_uInt8* buffer);
230*cdf0e10cSrcweir };
231*cdf0e10cSrcweir 
232*cdf0e10cSrcweir CPInfo::CPInfo(CPInfoTag tag, struct CPInfo* prev)
233*cdf0e10cSrcweir     : m_tag(tag)
234*cdf0e10cSrcweir     , m_index(0)
235*cdf0e10cSrcweir     , m_next(NULL)
236*cdf0e10cSrcweir {
237*cdf0e10cSrcweir     if (prev)
238*cdf0e10cSrcweir     {
239*cdf0e10cSrcweir         m_index = prev->m_index + 1;
240*cdf0e10cSrcweir         prev->m_next = this;
241*cdf0e10cSrcweir     }
242*cdf0e10cSrcweir }
243*cdf0e10cSrcweir 
244*cdf0e10cSrcweir sal_uInt32 CPInfo::getBlopSize()
245*cdf0e10cSrcweir {
246*cdf0e10cSrcweir     sal_uInt32 size = sizeof(sal_uInt32) /* size */ + sizeof(sal_uInt16) /* tag */;
247*cdf0e10cSrcweir 
248*cdf0e10cSrcweir     switch (m_tag)
249*cdf0e10cSrcweir     {
250*cdf0e10cSrcweir         case CP_TAG_CONST_BOOL:
251*cdf0e10cSrcweir             size += sizeof(sal_uInt8);
252*cdf0e10cSrcweir             break;
253*cdf0e10cSrcweir         case CP_TAG_CONST_BYTE:
254*cdf0e10cSrcweir             size += sizeof(sal_uInt8);
255*cdf0e10cSrcweir             break;
256*cdf0e10cSrcweir         case CP_TAG_CONST_INT16:
257*cdf0e10cSrcweir             size += sizeof(sal_Int16);
258*cdf0e10cSrcweir             break;
259*cdf0e10cSrcweir         case CP_TAG_CONST_UINT16:
260*cdf0e10cSrcweir             size += sizeof(sal_uInt16);
261*cdf0e10cSrcweir             break;
262*cdf0e10cSrcweir         case CP_TAG_CONST_INT32:
263*cdf0e10cSrcweir             size += sizeof(sal_Int32);
264*cdf0e10cSrcweir             break;
265*cdf0e10cSrcweir         case CP_TAG_CONST_UINT32:
266*cdf0e10cSrcweir             size += sizeof(sal_uInt32);
267*cdf0e10cSrcweir             break;
268*cdf0e10cSrcweir         case CP_TAG_CONST_INT64:
269*cdf0e10cSrcweir           	size += sizeof(sal_Int64);
270*cdf0e10cSrcweir             break;
271*cdf0e10cSrcweir         case CP_TAG_CONST_UINT64:
272*cdf0e10cSrcweir 			size += sizeof(sal_uInt64);
273*cdf0e10cSrcweir             break;
274*cdf0e10cSrcweir         case CP_TAG_CONST_FLOAT:
275*cdf0e10cSrcweir             size += sizeof(sal_uInt32);
276*cdf0e10cSrcweir             break;
277*cdf0e10cSrcweir         case CP_TAG_CONST_DOUBLE:
278*cdf0e10cSrcweir             size += sizeof(sal_uInt32) + sizeof(sal_uInt32);
279*cdf0e10cSrcweir             break;
280*cdf0e10cSrcweir         case CP_TAG_CONST_STRING:
281*cdf0e10cSrcweir             size += (rtl_ustr_getLength(m_value.aConst.aString) + 1) * sizeof(sal_uInt16);
282*cdf0e10cSrcweir             break;
283*cdf0e10cSrcweir         case CP_TAG_UTF8_NAME:
284*cdf0e10cSrcweir             size += strlen(m_value.aUtf8) + 1;
285*cdf0e10cSrcweir             break;
286*cdf0e10cSrcweir         case CP_TAG_UIK:
287*cdf0e10cSrcweir             size += sizeof(sal_uInt32) + sizeof(sal_uInt16) + sizeof(sal_uInt16) + sizeof(sal_uInt32) + sizeof(sal_uInt32);
288*cdf0e10cSrcweir             break;
289*cdf0e10cSrcweir         default:
290*cdf0e10cSrcweir             break;
291*cdf0e10cSrcweir     }
292*cdf0e10cSrcweir 
293*cdf0e10cSrcweir     return size;
294*cdf0e10cSrcweir }
295*cdf0e10cSrcweir 
296*cdf0e10cSrcweir 
297*cdf0e10cSrcweir sal_uInt32 CPInfo::toBlop(sal_uInt8* buffer)
298*cdf0e10cSrcweir {
299*cdf0e10cSrcweir     sal_uInt8* buff = buffer;
300*cdf0e10cSrcweir 
301*cdf0e10cSrcweir     buff += writeUINT32(buff, getBlopSize());
302*cdf0e10cSrcweir     buff += writeUINT16(buff, (sal_uInt16) m_tag);
303*cdf0e10cSrcweir 
304*cdf0e10cSrcweir     switch (m_tag)
305*cdf0e10cSrcweir     {
306*cdf0e10cSrcweir         case CP_TAG_CONST_BOOL:
307*cdf0e10cSrcweir             buff += writeBYTE(buff, (sal_uInt8) m_value.aConst.aBool);
308*cdf0e10cSrcweir             break;
309*cdf0e10cSrcweir         case CP_TAG_CONST_BYTE:
310*cdf0e10cSrcweir             buff += writeBYTE(buff, m_value.aConst.aByte);
311*cdf0e10cSrcweir             break;
312*cdf0e10cSrcweir         case CP_TAG_CONST_INT16:
313*cdf0e10cSrcweir             buff += writeINT16(buff, m_value.aConst.aShort);
314*cdf0e10cSrcweir             break;
315*cdf0e10cSrcweir         case CP_TAG_CONST_UINT16:
316*cdf0e10cSrcweir             buff += writeINT16(buff, m_value.aConst.aUShort);
317*cdf0e10cSrcweir             break;
318*cdf0e10cSrcweir         case CP_TAG_CONST_INT32:
319*cdf0e10cSrcweir             buff += writeINT32(buff, m_value.aConst.aLong);
320*cdf0e10cSrcweir             break;
321*cdf0e10cSrcweir         case CP_TAG_CONST_UINT32:
322*cdf0e10cSrcweir             buff += writeUINT32(buff, m_value.aConst.aULong);
323*cdf0e10cSrcweir             break;
324*cdf0e10cSrcweir         case CP_TAG_CONST_INT64:
325*cdf0e10cSrcweir 			buff += writeUINT64(buff, m_value.aConst.aHyper);
326*cdf0e10cSrcweir             break;
327*cdf0e10cSrcweir         case CP_TAG_CONST_UINT64:
328*cdf0e10cSrcweir 			buff += writeUINT64(buff, m_value.aConst.aUHyper);
329*cdf0e10cSrcweir             break;
330*cdf0e10cSrcweir         case CP_TAG_CONST_FLOAT:
331*cdf0e10cSrcweir             buff += writeFloat(buff, m_value.aConst.aFloat);
332*cdf0e10cSrcweir             break;
333*cdf0e10cSrcweir         case CP_TAG_CONST_DOUBLE:
334*cdf0e10cSrcweir             buff += writeDouble(buff, m_value.aConst.aDouble);
335*cdf0e10cSrcweir             break;
336*cdf0e10cSrcweir         case CP_TAG_CONST_STRING:
337*cdf0e10cSrcweir             buff += writeString(buff, m_value.aConst.aString);
338*cdf0e10cSrcweir             break;
339*cdf0e10cSrcweir         case CP_TAG_UTF8_NAME:
340*cdf0e10cSrcweir             buff += writeUtf8(buff, m_value.aUtf8);
341*cdf0e10cSrcweir             break;
342*cdf0e10cSrcweir         case CP_TAG_UIK:
343*cdf0e10cSrcweir             buff += writeUINT32(buff, m_value.aUik->m_Data1);
344*cdf0e10cSrcweir             buff += writeUINT16(buff, m_value.aUik->m_Data2);
345*cdf0e10cSrcweir             buff += writeUINT16(buff, m_value.aUik->m_Data3);
346*cdf0e10cSrcweir             buff += writeUINT32(buff, m_value.aUik->m_Data4);
347*cdf0e10cSrcweir             buff += writeUINT32(buff, m_value.aUik->m_Data5);
348*cdf0e10cSrcweir             break;
349*cdf0e10cSrcweir         default:
350*cdf0e10cSrcweir             break;
351*cdf0e10cSrcweir     }
352*cdf0e10cSrcweir 
353*cdf0e10cSrcweir     return (buff - buffer);
354*cdf0e10cSrcweir }
355*cdf0e10cSrcweir 
356*cdf0e10cSrcweir 
357*cdf0e10cSrcweir /**************************************************************************
358*cdf0e10cSrcweir 
359*cdf0e10cSrcweir     class FieldEntry
360*cdf0e10cSrcweir 
361*cdf0e10cSrcweir **************************************************************************/
362*cdf0e10cSrcweir 
363*cdf0e10cSrcweir class FieldEntry
364*cdf0e10cSrcweir {
365*cdf0e10cSrcweir 
366*cdf0e10cSrcweir public:
367*cdf0e10cSrcweir 
368*cdf0e10cSrcweir     OString           m_name;
369*cdf0e10cSrcweir     OString           m_typeName;
370*cdf0e10cSrcweir     OString           m_doku;
371*cdf0e10cSrcweir     OString           m_fileName;
372*cdf0e10cSrcweir     RTFieldAccess     m_access;
373*cdf0e10cSrcweir     RTValueType       m_constValueType;
374*cdf0e10cSrcweir     RTConstValueUnion m_constValue;
375*cdf0e10cSrcweir 
376*cdf0e10cSrcweir     FieldEntry();
377*cdf0e10cSrcweir     ~FieldEntry();
378*cdf0e10cSrcweir 
379*cdf0e10cSrcweir     void setData(const OString&    name,
380*cdf0e10cSrcweir                  const OString&    typeName,
381*cdf0e10cSrcweir                  const OString&    doku,
382*cdf0e10cSrcweir                  const OString&    fileName,
383*cdf0e10cSrcweir                  RTFieldAccess     access,
384*cdf0e10cSrcweir                  RTValueType       constValueType,
385*cdf0e10cSrcweir                  RTConstValueUnion constValue);
386*cdf0e10cSrcweir         // throws std::bad_alloc
387*cdf0e10cSrcweir };
388*cdf0e10cSrcweir 
389*cdf0e10cSrcweir FieldEntry::FieldEntry()
390*cdf0e10cSrcweir     : m_access(RT_ACCESS_INVALID)
391*cdf0e10cSrcweir     , m_constValueType(RT_TYPE_NONE)
392*cdf0e10cSrcweir {
393*cdf0e10cSrcweir }
394*cdf0e10cSrcweir 
395*cdf0e10cSrcweir FieldEntry::~FieldEntry()
396*cdf0e10cSrcweir {
397*cdf0e10cSrcweir     if (
398*cdf0e10cSrcweir         (m_constValueType == RT_TYPE_STRING) &&
399*cdf0e10cSrcweir         m_constValue.aString &&
400*cdf0e10cSrcweir         (m_constValue.aString != NULL_WSTRING)
401*cdf0e10cSrcweir        )
402*cdf0e10cSrcweir     {
403*cdf0e10cSrcweir         delete[] (sal_Unicode*)m_constValue.aString;
404*cdf0e10cSrcweir     }
405*cdf0e10cSrcweir }
406*cdf0e10cSrcweir 
407*cdf0e10cSrcweir void FieldEntry::setData(const OString&    name,
408*cdf0e10cSrcweir                          const OString&    typeName,
409*cdf0e10cSrcweir                          const OString&    doku,
410*cdf0e10cSrcweir                          const OString&    fileName,
411*cdf0e10cSrcweir                          RTFieldAccess      access,
412*cdf0e10cSrcweir                          RTValueType        constValueType,
413*cdf0e10cSrcweir                          RTConstValueUnion  constValue)
414*cdf0e10cSrcweir {
415*cdf0e10cSrcweir     sal_Unicode * newValue = 0;
416*cdf0e10cSrcweir     if (constValueType == RT_TYPE_STRING && constValue.aString != 0) {
417*cdf0e10cSrcweir         sal_Int32 n = rtl_ustr_getLength(constValue.aString) + 1;
418*cdf0e10cSrcweir         newValue = new sal_Unicode[n];
419*cdf0e10cSrcweir         rtl_copyMemory(newValue, constValue.aString, n * sizeof (sal_Unicode));
420*cdf0e10cSrcweir     }
421*cdf0e10cSrcweir 
422*cdf0e10cSrcweir 	m_name = name;
423*cdf0e10cSrcweir     m_typeName = typeName;
424*cdf0e10cSrcweir     m_doku = doku;
425*cdf0e10cSrcweir     m_fileName = fileName;
426*cdf0e10cSrcweir 
427*cdf0e10cSrcweir     if (
428*cdf0e10cSrcweir         (m_constValueType == RT_TYPE_STRING) &&
429*cdf0e10cSrcweir         m_constValue.aString &&
430*cdf0e10cSrcweir         (m_constValue.aString != NULL_WSTRING)
431*cdf0e10cSrcweir        )
432*cdf0e10cSrcweir     {
433*cdf0e10cSrcweir         delete[] (sal_Unicode*)m_constValue.aString;
434*cdf0e10cSrcweir     }
435*cdf0e10cSrcweir 
436*cdf0e10cSrcweir     m_access = access;
437*cdf0e10cSrcweir     m_constValueType = constValueType;
438*cdf0e10cSrcweir 
439*cdf0e10cSrcweir     if (m_constValueType == RT_TYPE_STRING)
440*cdf0e10cSrcweir     {
441*cdf0e10cSrcweir         if (constValue.aString == NULL)
442*cdf0e10cSrcweir             m_constValue.aString = NULL_WSTRING;
443*cdf0e10cSrcweir         else
444*cdf0e10cSrcweir         {
445*cdf0e10cSrcweir             m_constValue.aString = newValue;
446*cdf0e10cSrcweir         }
447*cdf0e10cSrcweir     }
448*cdf0e10cSrcweir     else
449*cdf0e10cSrcweir     {
450*cdf0e10cSrcweir         m_constValue = constValue;
451*cdf0e10cSrcweir     }
452*cdf0e10cSrcweir }
453*cdf0e10cSrcweir 
454*cdf0e10cSrcweir /**************************************************************************
455*cdf0e10cSrcweir 
456*cdf0e10cSrcweir     class ParamEntry
457*cdf0e10cSrcweir 
458*cdf0e10cSrcweir **************************************************************************/
459*cdf0e10cSrcweir 
460*cdf0e10cSrcweir class ParamEntry
461*cdf0e10cSrcweir {
462*cdf0e10cSrcweir public:
463*cdf0e10cSrcweir 
464*cdf0e10cSrcweir     OString    	m_typeName;
465*cdf0e10cSrcweir     OString     m_name;
466*cdf0e10cSrcweir     RTParamMode m_mode;
467*cdf0e10cSrcweir 
468*cdf0e10cSrcweir     ParamEntry();
469*cdf0e10cSrcweir     ~ParamEntry();
470*cdf0e10cSrcweir 
471*cdf0e10cSrcweir     void setData(const OString& typeName,
472*cdf0e10cSrcweir                  const OString&	name,
473*cdf0e10cSrcweir                  RTParamMode    mode);
474*cdf0e10cSrcweir };
475*cdf0e10cSrcweir 
476*cdf0e10cSrcweir ParamEntry::ParamEntry()
477*cdf0e10cSrcweir     : m_mode(RT_PARAM_INVALID)
478*cdf0e10cSrcweir {
479*cdf0e10cSrcweir }
480*cdf0e10cSrcweir 
481*cdf0e10cSrcweir ParamEntry::~ParamEntry()
482*cdf0e10cSrcweir {
483*cdf0e10cSrcweir }
484*cdf0e10cSrcweir 
485*cdf0e10cSrcweir void ParamEntry::setData(const OString& typeName,
486*cdf0e10cSrcweir                          const OString&	name,
487*cdf0e10cSrcweir                          RTParamMode   	mode)
488*cdf0e10cSrcweir {
489*cdf0e10cSrcweir     m_name = name;
490*cdf0e10cSrcweir     m_typeName = typeName;
491*cdf0e10cSrcweir     m_mode = mode;
492*cdf0e10cSrcweir }
493*cdf0e10cSrcweir 
494*cdf0e10cSrcweir /**************************************************************************
495*cdf0e10cSrcweir 
496*cdf0e10cSrcweir     class ReferenceEntry
497*cdf0e10cSrcweir 
498*cdf0e10cSrcweir **************************************************************************/
499*cdf0e10cSrcweir 
500*cdf0e10cSrcweir class ReferenceEntry
501*cdf0e10cSrcweir {
502*cdf0e10cSrcweir public:
503*cdf0e10cSrcweir 
504*cdf0e10cSrcweir     OString     	m_name;
505*cdf0e10cSrcweir     OString			m_doku;
506*cdf0e10cSrcweir     RTReferenceType m_type;
507*cdf0e10cSrcweir     RTFieldAccess   m_access;
508*cdf0e10cSrcweir 
509*cdf0e10cSrcweir     ReferenceEntry();
510*cdf0e10cSrcweir     ~ReferenceEntry();
511*cdf0e10cSrcweir 
512*cdf0e10cSrcweir     void setData(const OString&		name,
513*cdf0e10cSrcweir                  RTReferenceType    refType,
514*cdf0e10cSrcweir                  const OString&   	doku,
515*cdf0e10cSrcweir 				 RTFieldAccess     	access);
516*cdf0e10cSrcweir };
517*cdf0e10cSrcweir 
518*cdf0e10cSrcweir ReferenceEntry::ReferenceEntry()
519*cdf0e10cSrcweir     : m_type(RT_REF_INVALID)
520*cdf0e10cSrcweir 	, m_access(RT_ACCESS_INVALID)
521*cdf0e10cSrcweir {
522*cdf0e10cSrcweir }
523*cdf0e10cSrcweir 
524*cdf0e10cSrcweir ReferenceEntry::~ReferenceEntry()
525*cdf0e10cSrcweir {
526*cdf0e10cSrcweir }
527*cdf0e10cSrcweir 
528*cdf0e10cSrcweir void ReferenceEntry::setData(const OString&    name,
529*cdf0e10cSrcweir                              RTReferenceType   refType,
530*cdf0e10cSrcweir                              const OString&    doku,
531*cdf0e10cSrcweir 							 RTFieldAccess     access)
532*cdf0e10cSrcweir {
533*cdf0e10cSrcweir     m_name = name;
534*cdf0e10cSrcweir     m_doku = doku;
535*cdf0e10cSrcweir     m_type = refType;
536*cdf0e10cSrcweir 	m_access = access;
537*cdf0e10cSrcweir }
538*cdf0e10cSrcweir 
539*cdf0e10cSrcweir /**************************************************************************
540*cdf0e10cSrcweir 
541*cdf0e10cSrcweir     class MethodEntry
542*cdf0e10cSrcweir 
543*cdf0e10cSrcweir **************************************************************************/
544*cdf0e10cSrcweir 
545*cdf0e10cSrcweir class MethodEntry
546*cdf0e10cSrcweir {
547*cdf0e10cSrcweir public:
548*cdf0e10cSrcweir 
549*cdf0e10cSrcweir     OString       	m_name;
550*cdf0e10cSrcweir     OString       	m_returnTypeName;
551*cdf0e10cSrcweir     RTMethodMode    m_mode;
552*cdf0e10cSrcweir     sal_uInt16      m_paramCount;
553*cdf0e10cSrcweir     ParamEntry* 	m_params;
554*cdf0e10cSrcweir     sal_uInt16    	m_excCount;
555*cdf0e10cSrcweir     OString*      	m_excNames;
556*cdf0e10cSrcweir     OString      	m_doku;
557*cdf0e10cSrcweir 
558*cdf0e10cSrcweir     MethodEntry();
559*cdf0e10cSrcweir     ~MethodEntry();
560*cdf0e10cSrcweir 
561*cdf0e10cSrcweir     void setData(const OString&    name,
562*cdf0e10cSrcweir                  const OString&    returnTypeName,
563*cdf0e10cSrcweir                  RTMethodMode      mode,
564*cdf0e10cSrcweir                  sal_uInt16        paramCount,
565*cdf0e10cSrcweir                  sal_uInt16        excCount,
566*cdf0e10cSrcweir                  const OString&    doku);
567*cdf0e10cSrcweir 
568*cdf0e10cSrcweir     void setExcName(sal_uInt16 excIndex, const OString& name);
569*cdf0e10cSrcweir 
570*cdf0e10cSrcweir protected:
571*cdf0e10cSrcweir 
572*cdf0e10cSrcweir     void reallocParams(sal_uInt16 size);
573*cdf0e10cSrcweir     void reallocExcs(sal_uInt16 size);
574*cdf0e10cSrcweir };
575*cdf0e10cSrcweir 
576*cdf0e10cSrcweir MethodEntry::MethodEntry()
577*cdf0e10cSrcweir     : m_mode(RT_MODE_INVALID)
578*cdf0e10cSrcweir     , m_paramCount(0)
579*cdf0e10cSrcweir     , m_params(NULL)
580*cdf0e10cSrcweir     , m_excCount(0)
581*cdf0e10cSrcweir     , m_excNames(NULL)
582*cdf0e10cSrcweir {
583*cdf0e10cSrcweir }
584*cdf0e10cSrcweir 
585*cdf0e10cSrcweir MethodEntry::~MethodEntry()
586*cdf0e10cSrcweir {
587*cdf0e10cSrcweir     if (m_params)
588*cdf0e10cSrcweir         delete[] m_params;
589*cdf0e10cSrcweir 
590*cdf0e10cSrcweir     if (m_excNames)
591*cdf0e10cSrcweir         delete[] m_excNames;
592*cdf0e10cSrcweir }
593*cdf0e10cSrcweir 
594*cdf0e10cSrcweir void MethodEntry::setData(const OString&   	name,
595*cdf0e10cSrcweir                           const OString&   	returnTypeName,
596*cdf0e10cSrcweir                           RTMethodMode  	mode,
597*cdf0e10cSrcweir                           sal_uInt16        paramCount,
598*cdf0e10cSrcweir                           sal_uInt16        excCount,
599*cdf0e10cSrcweir                           const OString&   	doku)
600*cdf0e10cSrcweir {
601*cdf0e10cSrcweir 	m_name = name;
602*cdf0e10cSrcweir 	m_returnTypeName = returnTypeName;
603*cdf0e10cSrcweir 	m_doku = doku;
604*cdf0e10cSrcweir 
605*cdf0e10cSrcweir     m_mode = mode;
606*cdf0e10cSrcweir 
607*cdf0e10cSrcweir     reallocParams(paramCount);
608*cdf0e10cSrcweir     reallocExcs(excCount);
609*cdf0e10cSrcweir }
610*cdf0e10cSrcweir 
611*cdf0e10cSrcweir void MethodEntry::setExcName(sal_uInt16 excIndex, const OString& name)
612*cdf0e10cSrcweir {
613*cdf0e10cSrcweir     if (excIndex < m_excCount)
614*cdf0e10cSrcweir     {
615*cdf0e10cSrcweir 		m_excNames[excIndex] = name;
616*cdf0e10cSrcweir     }
617*cdf0e10cSrcweir }
618*cdf0e10cSrcweir 
619*cdf0e10cSrcweir void MethodEntry::reallocParams(sal_uInt16 size)
620*cdf0e10cSrcweir {
621*cdf0e10cSrcweir     ParamEntry* newParams;
622*cdf0e10cSrcweir 
623*cdf0e10cSrcweir     if (size)
624*cdf0e10cSrcweir         newParams = new ParamEntry[size];
625*cdf0e10cSrcweir     else
626*cdf0e10cSrcweir         newParams = NULL;
627*cdf0e10cSrcweir 
628*cdf0e10cSrcweir     if (m_paramCount)
629*cdf0e10cSrcweir     {
630*cdf0e10cSrcweir         sal_uInt16 i;
631*cdf0e10cSrcweir 
632*cdf0e10cSrcweir         for (i = 0; i < SAL_MIN(size, m_paramCount); i++)
633*cdf0e10cSrcweir         {
634*cdf0e10cSrcweir             newParams[i].setData(m_params[i].m_typeName, m_params[i].m_name, m_params[i].m_mode);
635*cdf0e10cSrcweir         }
636*cdf0e10cSrcweir 
637*cdf0e10cSrcweir         delete[] m_params;
638*cdf0e10cSrcweir     }
639*cdf0e10cSrcweir 
640*cdf0e10cSrcweir     m_paramCount = size;
641*cdf0e10cSrcweir     m_params = newParams;
642*cdf0e10cSrcweir }
643*cdf0e10cSrcweir 
644*cdf0e10cSrcweir void MethodEntry::reallocExcs(sal_uInt16 size)
645*cdf0e10cSrcweir {
646*cdf0e10cSrcweir     OString* newExcNames;
647*cdf0e10cSrcweir 
648*cdf0e10cSrcweir     if (size)
649*cdf0e10cSrcweir         newExcNames = new OString[size];
650*cdf0e10cSrcweir     else
651*cdf0e10cSrcweir         newExcNames = NULL;
652*cdf0e10cSrcweir 
653*cdf0e10cSrcweir     sal_uInt16 i;
654*cdf0e10cSrcweir 
655*cdf0e10cSrcweir     for (i = 0; i < SAL_MIN(size, m_excCount); i++)
656*cdf0e10cSrcweir     {
657*cdf0e10cSrcweir         newExcNames[i] = m_excNames[i];
658*cdf0e10cSrcweir     }
659*cdf0e10cSrcweir 
660*cdf0e10cSrcweir     delete[] m_excNames;
661*cdf0e10cSrcweir 
662*cdf0e10cSrcweir     m_excCount = size;
663*cdf0e10cSrcweir     m_excNames = newExcNames;
664*cdf0e10cSrcweir }
665*cdf0e10cSrcweir 
666*cdf0e10cSrcweir 
667*cdf0e10cSrcweir /**************************************************************************
668*cdf0e10cSrcweir 
669*cdf0e10cSrcweir     class TypeRegistryEntry
670*cdf0e10cSrcweir 
671*cdf0e10cSrcweir **************************************************************************/
672*cdf0e10cSrcweir 
673*cdf0e10cSrcweir class TypeWriter
674*cdf0e10cSrcweir {
675*cdf0e10cSrcweir 
676*cdf0e10cSrcweir public:
677*cdf0e10cSrcweir 
678*cdf0e10cSrcweir     sal_uInt32          m_refCount;
679*cdf0e10cSrcweir     typereg_Version     m_version;
680*cdf0e10cSrcweir     RTTypeClass         m_typeClass;
681*cdf0e10cSrcweir     OString		        m_typeName;
682*cdf0e10cSrcweir 	sal_uInt16			m_nSuperTypes;
683*cdf0e10cSrcweir     OString*            m_superTypeNames;
684*cdf0e10cSrcweir     RTUik*              m_pUik;
685*cdf0e10cSrcweir     OString		        m_doku;
686*cdf0e10cSrcweir     OString		        m_fileName;
687*cdf0e10cSrcweir     sal_uInt16          m_fieldCount;
688*cdf0e10cSrcweir     FieldEntry*         m_fields;
689*cdf0e10cSrcweir     sal_uInt16          m_methodCount;
690*cdf0e10cSrcweir     MethodEntry*        m_methods;
691*cdf0e10cSrcweir     sal_uInt16          m_referenceCount;
692*cdf0e10cSrcweir     ReferenceEntry*     m_references;
693*cdf0e10cSrcweir 
694*cdf0e10cSrcweir     sal_uInt8*          m_blop;
695*cdf0e10cSrcweir     sal_uInt32          m_blopSize;
696*cdf0e10cSrcweir 
697*cdf0e10cSrcweir     TypeWriter(typereg_Version version,
698*cdf0e10cSrcweir                rtl::OString const & documentation,
699*cdf0e10cSrcweir                rtl::OString const & fileName,
700*cdf0e10cSrcweir 			   RTTypeClass  	RTTypeClass,
701*cdf0e10cSrcweir                bool             published,
702*cdf0e10cSrcweir                const OString& 	typeName,
703*cdf0e10cSrcweir                sal_uInt16       superTypeCount,
704*cdf0e10cSrcweir                sal_uInt16  		FieldCount,
705*cdf0e10cSrcweir                sal_uInt16   	methodCount,
706*cdf0e10cSrcweir                sal_uInt16   	referenceCount);
707*cdf0e10cSrcweir 
708*cdf0e10cSrcweir     ~TypeWriter();
709*cdf0e10cSrcweir 
710*cdf0e10cSrcweir     void setSuperType(sal_uInt16 index, OString const & name);
711*cdf0e10cSrcweir 
712*cdf0e10cSrcweir     void createBlop(); // throws std::bad_alloc
713*cdf0e10cSrcweir };
714*cdf0e10cSrcweir 
715*cdf0e10cSrcweir TypeWriter::TypeWriter(typereg_Version version,
716*cdf0e10cSrcweir                        rtl::OString const & documentation,
717*cdf0e10cSrcweir                        rtl::OString const & fileName,
718*cdf0e10cSrcweir 					   RTTypeClass  	RTTypeClass,
719*cdf0e10cSrcweir                        bool             published,
720*cdf0e10cSrcweir                        const OString& 	typeName,
721*cdf0e10cSrcweir                        sal_uInt16       superTypeCount,
722*cdf0e10cSrcweir                        sal_uInt16   	fieldCount,
723*cdf0e10cSrcweir                        sal_uInt16   	methodCount,
724*cdf0e10cSrcweir                        sal_uInt16   	referenceCount)
725*cdf0e10cSrcweir     : m_refCount(1)
726*cdf0e10cSrcweir     , m_version(version)
727*cdf0e10cSrcweir     , m_typeClass(
728*cdf0e10cSrcweir         static_cast< enum RTTypeClass >(
729*cdf0e10cSrcweir             RTTypeClass | (published ? RT_TYPE_PUBLISHED : 0)))
730*cdf0e10cSrcweir  	, m_typeName(typeName)
731*cdf0e10cSrcweir 	, m_nSuperTypes(superTypeCount)
732*cdf0e10cSrcweir     , m_pUik(NULL)
733*cdf0e10cSrcweir     , m_doku(documentation)
734*cdf0e10cSrcweir     , m_fileName(fileName)
735*cdf0e10cSrcweir     , m_fieldCount(fieldCount)
736*cdf0e10cSrcweir     , m_methodCount(methodCount)
737*cdf0e10cSrcweir     , m_referenceCount(referenceCount)
738*cdf0e10cSrcweir     , m_blop(NULL)
739*cdf0e10cSrcweir     , m_blopSize(0)
740*cdf0e10cSrcweir {
741*cdf0e10cSrcweir 	if (m_nSuperTypes > 0)
742*cdf0e10cSrcweir 	{
743*cdf0e10cSrcweir 		m_superTypeNames = new OString[m_nSuperTypes];
744*cdf0e10cSrcweir 	} else
745*cdf0e10cSrcweir 	{
746*cdf0e10cSrcweir 		m_superTypeNames = NULL;
747*cdf0e10cSrcweir 	}
748*cdf0e10cSrcweir 
749*cdf0e10cSrcweir     if (m_fieldCount)
750*cdf0e10cSrcweir         m_fields = new FieldEntry[fieldCount];
751*cdf0e10cSrcweir 
752*cdf0e10cSrcweir     if (m_methodCount)
753*cdf0e10cSrcweir         m_methods = new MethodEntry[methodCount];
754*cdf0e10cSrcweir 
755*cdf0e10cSrcweir     if (m_referenceCount)
756*cdf0e10cSrcweir         m_references = new ReferenceEntry[referenceCount];
757*cdf0e10cSrcweir }
758*cdf0e10cSrcweir 
759*cdf0e10cSrcweir TypeWriter::~TypeWriter()
760*cdf0e10cSrcweir {
761*cdf0e10cSrcweir 	if (m_superTypeNames)
762*cdf0e10cSrcweir         delete[] m_superTypeNames;
763*cdf0e10cSrcweir 
764*cdf0e10cSrcweir     if (m_blop)
765*cdf0e10cSrcweir         delete[] m_blop;
766*cdf0e10cSrcweir 
767*cdf0e10cSrcweir     if (m_fieldCount)
768*cdf0e10cSrcweir         delete[] m_fields;
769*cdf0e10cSrcweir 
770*cdf0e10cSrcweir     if (m_methodCount)
771*cdf0e10cSrcweir         delete[] m_methods;
772*cdf0e10cSrcweir 
773*cdf0e10cSrcweir     if (m_referenceCount)
774*cdf0e10cSrcweir         delete[] m_references;
775*cdf0e10cSrcweir 
776*cdf0e10cSrcweir     if (m_pUik)
777*cdf0e10cSrcweir         delete m_pUik;
778*cdf0e10cSrcweir }
779*cdf0e10cSrcweir 
780*cdf0e10cSrcweir void TypeWriter::setSuperType(sal_uInt16 index, OString const & name)
781*cdf0e10cSrcweir {
782*cdf0e10cSrcweir     m_superTypeNames[index] = name;
783*cdf0e10cSrcweir }
784*cdf0e10cSrcweir 
785*cdf0e10cSrcweir void TypeWriter::createBlop()
786*cdf0e10cSrcweir {
787*cdf0e10cSrcweir     //TODO: Fix memory leaks that occur when std::bad_alloc is thrown
788*cdf0e10cSrcweir 
789*cdf0e10cSrcweir     sal_uInt8*  pBlopFields         = NULL;
790*cdf0e10cSrcweir     sal_uInt8*  pBlopMethods        = NULL;
791*cdf0e10cSrcweir     sal_uInt8*  pBlopReferences     = NULL;
792*cdf0e10cSrcweir     sal_uInt8*  pBuffer             = NULL;
793*cdf0e10cSrcweir     sal_uInt32  blopFieldsSize      = 0;
794*cdf0e10cSrcweir     sal_uInt32  blopMethodsSize     = 0;
795*cdf0e10cSrcweir     sal_uInt32  blopReferenceSize   = 0;
796*cdf0e10cSrcweir 
797*cdf0e10cSrcweir     CPInfo  root(CP_TAG_INVALID, NULL);
798*cdf0e10cSrcweir     sal_uInt16  cpIndexThisName = 0;
799*cdf0e10cSrcweir 	sal_uInt16* cpIndexSuperNames = NULL;
800*cdf0e10cSrcweir     sal_uInt16  cpIndexUik = 0;
801*cdf0e10cSrcweir     sal_uInt16  cpIndexDoku = 0;
802*cdf0e10cSrcweir     sal_uInt16  cpIndexFileName = 0;
803*cdf0e10cSrcweir     CPInfo* pInfo = NULL;
804*cdf0e10cSrcweir 
805*cdf0e10cSrcweir 	sal_uInt16  entrySize = sizeof(sal_uInt16);
806*cdf0e10cSrcweir 	sal_uInt32  blopHeaderEntrySize = BLOP_OFFSET_N_ENTRIES + entrySize + (BLOP_HEADER_N_ENTRIES * entrySize);
807*cdf0e10cSrcweir 	sal_uInt32  blopFieldEntrySize = BLOP_FIELD_N_ENTRIES * entrySize;
808*cdf0e10cSrcweir 	sal_uInt32  blopMethodEntrySize = BLOP_METHOD_N_ENTRIES * entrySize;
809*cdf0e10cSrcweir 	sal_uInt32  blopParamEntrySize = BLOP_PARAM_N_ENTRIES * entrySize;
810*cdf0e10cSrcweir 	sal_uInt32  blopReferenceEntrySize = BLOP_REFERENCE_N_ENTRIES * entrySize;
811*cdf0e10cSrcweir 
812*cdf0e10cSrcweir 	sal_uInt32 blopSize = blopHeaderEntrySize;
813*cdf0e10cSrcweir 
814*cdf0e10cSrcweir     // create CP entry for this name
815*cdf0e10cSrcweir     pInfo = new CPInfo(CP_TAG_UTF8_NAME, &root);
816*cdf0e10cSrcweir     pInfo->m_value.aUtf8 = m_typeName.getStr();
817*cdf0e10cSrcweir     cpIndexThisName = pInfo->m_index;
818*cdf0e10cSrcweir 
819*cdf0e10cSrcweir 	// nSuperTypes
820*cdf0e10cSrcweir 	blopSize += entrySize;
821*cdf0e10cSrcweir 
822*cdf0e10cSrcweir     // create CP entry for super names
823*cdf0e10cSrcweir     if (m_nSuperTypes)
824*cdf0e10cSrcweir     {
825*cdf0e10cSrcweir 		blopSize += m_nSuperTypes * entrySize;
826*cdf0e10cSrcweir 
827*cdf0e10cSrcweir 		cpIndexSuperNames = new sal_uInt16[m_nSuperTypes];
828*cdf0e10cSrcweir 
829*cdf0e10cSrcweir 		for (sal_uInt32 i=0; i < m_nSuperTypes; i++)
830*cdf0e10cSrcweir 		{
831*cdf0e10cSrcweir 	        pInfo = new CPInfo(CP_TAG_UTF8_NAME, pInfo);
832*cdf0e10cSrcweir     	    pInfo->m_value.aUtf8 = m_superTypeNames[i].getStr();
833*cdf0e10cSrcweir         	cpIndexSuperNames[i] = pInfo->m_index;
834*cdf0e10cSrcweir 		}
835*cdf0e10cSrcweir     }
836*cdf0e10cSrcweir 
837*cdf0e10cSrcweir     // create CP entry for uik
838*cdf0e10cSrcweir     if (m_pUik != NULL)
839*cdf0e10cSrcweir     {
840*cdf0e10cSrcweir         pInfo = new CPInfo(CP_TAG_UIK, pInfo);
841*cdf0e10cSrcweir         pInfo->m_value.aUik = m_pUik;
842*cdf0e10cSrcweir         cpIndexUik = pInfo->m_index;
843*cdf0e10cSrcweir     }
844*cdf0e10cSrcweir 
845*cdf0e10cSrcweir     // create CP entry for doku
846*cdf0e10cSrcweir     if (m_doku.getLength())
847*cdf0e10cSrcweir     {
848*cdf0e10cSrcweir         pInfo = new CPInfo(CP_TAG_UTF8_NAME, pInfo);
849*cdf0e10cSrcweir         pInfo->m_value.aUtf8 = m_doku.getStr();
850*cdf0e10cSrcweir         cpIndexDoku = pInfo->m_index;
851*cdf0e10cSrcweir     }
852*cdf0e10cSrcweir 
853*cdf0e10cSrcweir     // create CP entry for idl source filename
854*cdf0e10cSrcweir     if (m_fileName.getLength())
855*cdf0e10cSrcweir     {
856*cdf0e10cSrcweir         pInfo = new CPInfo(CP_TAG_UTF8_NAME, pInfo);
857*cdf0e10cSrcweir         pInfo->m_value.aUtf8 = m_fileName.getStr();
858*cdf0e10cSrcweir         cpIndexFileName = pInfo->m_index;
859*cdf0e10cSrcweir     }
860*cdf0e10cSrcweir 
861*cdf0e10cSrcweir     // fields blop
862*cdf0e10cSrcweir     blopSize += sizeof(sal_uInt16); // fieldCount + nFieldEntries
863*cdf0e10cSrcweir 
864*cdf0e10cSrcweir     if (m_fieldCount)
865*cdf0e10cSrcweir     {
866*cdf0e10cSrcweir         sal_uInt16 cpIndexName = 0;
867*cdf0e10cSrcweir         sal_uInt16 cpIndexTypeName = 0;
868*cdf0e10cSrcweir         sal_uInt16 cpIndexValue = 0;
869*cdf0e10cSrcweir         sal_uInt16 cpIndexDoku2 = 0;
870*cdf0e10cSrcweir         sal_uInt16 cpIndexFileName2 = 0;
871*cdf0e10cSrcweir 
872*cdf0e10cSrcweir 		// nFieldEntries + n fields
873*cdf0e10cSrcweir         blopFieldsSize = sizeof(sal_uInt16) + (m_fieldCount * blopFieldEntrySize);
874*cdf0e10cSrcweir 
875*cdf0e10cSrcweir         blopSize += blopFieldsSize;
876*cdf0e10cSrcweir 
877*cdf0e10cSrcweir         pBlopFields = new sal_uInt8[blopFieldsSize];
878*cdf0e10cSrcweir         pBuffer = pBlopFields;
879*cdf0e10cSrcweir 
880*cdf0e10cSrcweir 	    pBuffer += writeUINT16(pBuffer, BLOP_FIELD_N_ENTRIES);
881*cdf0e10cSrcweir 
882*cdf0e10cSrcweir         for (sal_uInt16 i = 0; i < m_fieldCount; i++)
883*cdf0e10cSrcweir         {
884*cdf0e10cSrcweir             cpIndexName = 0;
885*cdf0e10cSrcweir             cpIndexTypeName = 0;
886*cdf0e10cSrcweir             cpIndexValue = 0;
887*cdf0e10cSrcweir             cpIndexDoku2 = 0;
888*cdf0e10cSrcweir             cpIndexFileName2 = 0;
889*cdf0e10cSrcweir 
890*cdf0e10cSrcweir             pBuffer += writeUINT16(pBuffer, m_fields[i].m_access);
891*cdf0e10cSrcweir 
892*cdf0e10cSrcweir             if (m_fields[i].m_name.getLength())
893*cdf0e10cSrcweir             {
894*cdf0e10cSrcweir                 pInfo = new CPInfo(CP_TAG_UTF8_NAME, pInfo);
895*cdf0e10cSrcweir                 pInfo->m_value.aUtf8 = m_fields[i].m_name.getStr();
896*cdf0e10cSrcweir                 cpIndexName = pInfo->m_index;
897*cdf0e10cSrcweir             }
898*cdf0e10cSrcweir             pBuffer += writeUINT16(pBuffer, cpIndexName);
899*cdf0e10cSrcweir 
900*cdf0e10cSrcweir             if (m_fields[i].m_typeName.getLength())
901*cdf0e10cSrcweir             {
902*cdf0e10cSrcweir                 pInfo = new CPInfo(CP_TAG_UTF8_NAME, pInfo);
903*cdf0e10cSrcweir                 pInfo->m_value.aUtf8 = m_fields[i].m_typeName.getStr();
904*cdf0e10cSrcweir                 cpIndexTypeName = pInfo->m_index;
905*cdf0e10cSrcweir             }
906*cdf0e10cSrcweir             pBuffer += writeUINT16(pBuffer, cpIndexTypeName);
907*cdf0e10cSrcweir 
908*cdf0e10cSrcweir             if (m_fields[i].m_constValueType != RT_TYPE_NONE)
909*cdf0e10cSrcweir             {
910*cdf0e10cSrcweir                 pInfo = new CPInfo((CPInfoTag)m_fields[i].m_constValueType, pInfo);
911*cdf0e10cSrcweir                 pInfo->m_value.aConst = m_fields[i].m_constValue;
912*cdf0e10cSrcweir                 cpIndexValue = pInfo->m_index;
913*cdf0e10cSrcweir             }
914*cdf0e10cSrcweir             pBuffer += writeUINT16(pBuffer, cpIndexValue);
915*cdf0e10cSrcweir 
916*cdf0e10cSrcweir             if (m_fields[i].m_doku.getLength())
917*cdf0e10cSrcweir             {
918*cdf0e10cSrcweir                 pInfo = new CPInfo(CP_TAG_UTF8_NAME, pInfo);
919*cdf0e10cSrcweir                 pInfo->m_value.aUtf8 = m_fields[i].m_doku.getStr();
920*cdf0e10cSrcweir                 cpIndexDoku2 = pInfo->m_index;
921*cdf0e10cSrcweir             }
922*cdf0e10cSrcweir             pBuffer += writeUINT16(pBuffer, cpIndexDoku2);
923*cdf0e10cSrcweir 
924*cdf0e10cSrcweir             if (m_fields[i].m_fileName.getLength())
925*cdf0e10cSrcweir             {
926*cdf0e10cSrcweir                 pInfo = new CPInfo(CP_TAG_UTF8_NAME, pInfo);
927*cdf0e10cSrcweir                 pInfo->m_value.aUtf8 = m_fields[i].m_fileName.getStr();
928*cdf0e10cSrcweir                 cpIndexFileName2 = pInfo->m_index;
929*cdf0e10cSrcweir             }
930*cdf0e10cSrcweir             pBuffer += writeUINT16(pBuffer, cpIndexFileName2);
931*cdf0e10cSrcweir         }
932*cdf0e10cSrcweir     }
933*cdf0e10cSrcweir 
934*cdf0e10cSrcweir     // methods blop
935*cdf0e10cSrcweir     blopSize += sizeof(sal_uInt16); // methodCount
936*cdf0e10cSrcweir 
937*cdf0e10cSrcweir     if (m_methodCount)
938*cdf0e10cSrcweir     {
939*cdf0e10cSrcweir         sal_uInt16* pMethodEntrySize = new sal_uInt16[m_methodCount];
940*cdf0e10cSrcweir         sal_uInt16  cpIndexName = 0;
941*cdf0e10cSrcweir         sal_uInt16  cpIndexReturn = 0;
942*cdf0e10cSrcweir         sal_uInt16  cpIndexDoku2 = 0;
943*cdf0e10cSrcweir 
944*cdf0e10cSrcweir 		// nMethodEntries + nParamEntries
945*cdf0e10cSrcweir         blopMethodsSize = (2 * sizeof(sal_uInt16));
946*cdf0e10cSrcweir 
947*cdf0e10cSrcweir         for (sal_uInt16 i = 0; i < m_methodCount; i++)
948*cdf0e10cSrcweir         {
949*cdf0e10cSrcweir             pMethodEntrySize[i] = (sal_uInt16)
950*cdf0e10cSrcweir                 ( blopMethodEntrySize +                   				// header
951*cdf0e10cSrcweir                   sizeof(sal_uInt16) +                                 	// parameterCount
952*cdf0e10cSrcweir                   (m_methods[i].m_paramCount * blopParamEntrySize) + 	// exceptions
953*cdf0e10cSrcweir                   sizeof(sal_uInt16) +                                 	// exceptionCount
954*cdf0e10cSrcweir                   (m_methods[i].m_excCount * sizeof(sal_uInt16)) );   	// exceptions
955*cdf0e10cSrcweir 
956*cdf0e10cSrcweir             blopMethodsSize += pMethodEntrySize[i];
957*cdf0e10cSrcweir         }
958*cdf0e10cSrcweir 
959*cdf0e10cSrcweir         pBlopMethods = new sal_uInt8[blopMethodsSize];
960*cdf0e10cSrcweir 
961*cdf0e10cSrcweir         blopSize += blopMethodsSize;
962*cdf0e10cSrcweir 
963*cdf0e10cSrcweir         pBuffer = pBlopMethods;
964*cdf0e10cSrcweir 
965*cdf0e10cSrcweir 	    pBuffer += writeUINT16(pBuffer, BLOP_METHOD_N_ENTRIES);
966*cdf0e10cSrcweir     	pBuffer += writeUINT16(pBuffer, BLOP_PARAM_N_ENTRIES );
967*cdf0e10cSrcweir 
968*cdf0e10cSrcweir         for (sal_uInt16 i = 0; i < m_methodCount; i++)
969*cdf0e10cSrcweir         {
970*cdf0e10cSrcweir             cpIndexReturn = 0;
971*cdf0e10cSrcweir             cpIndexDoku2 = 0;
972*cdf0e10cSrcweir 
973*cdf0e10cSrcweir             pBuffer += writeUINT16(pBuffer, pMethodEntrySize[i]);
974*cdf0e10cSrcweir             pBuffer += writeUINT16(
975*cdf0e10cSrcweir                 pBuffer,
976*cdf0e10cSrcweir                 sal::static_int_cast< sal_uInt16 >(m_methods[i].m_mode));
977*cdf0e10cSrcweir 
978*cdf0e10cSrcweir             if (m_methods[i].m_name.getLength())
979*cdf0e10cSrcweir             {
980*cdf0e10cSrcweir                 pInfo = new CPInfo(CP_TAG_UTF8_NAME, pInfo);
981*cdf0e10cSrcweir                 pInfo->m_value.aUtf8 = m_methods[i].m_name.getStr();
982*cdf0e10cSrcweir                 cpIndexName = pInfo->m_index;
983*cdf0e10cSrcweir             }
984*cdf0e10cSrcweir             pBuffer += writeUINT16(pBuffer, cpIndexName);
985*cdf0e10cSrcweir             cpIndexName = 0;
986*cdf0e10cSrcweir 
987*cdf0e10cSrcweir             if (m_methods[i].m_returnTypeName.getLength())
988*cdf0e10cSrcweir             {
989*cdf0e10cSrcweir                 pInfo = new CPInfo(CP_TAG_UTF8_NAME, pInfo);
990*cdf0e10cSrcweir                 pInfo->m_value.aUtf8 = m_methods[i].m_returnTypeName.getStr();
991*cdf0e10cSrcweir                 cpIndexReturn = pInfo->m_index;
992*cdf0e10cSrcweir             }
993*cdf0e10cSrcweir             pBuffer += writeUINT16(pBuffer, cpIndexReturn);
994*cdf0e10cSrcweir 
995*cdf0e10cSrcweir             if (m_methods[i].m_doku.getLength())
996*cdf0e10cSrcweir             {
997*cdf0e10cSrcweir                 pInfo = new CPInfo(CP_TAG_UTF8_NAME, pInfo);
998*cdf0e10cSrcweir                 pInfo->m_value.aUtf8 = m_methods[i].m_doku.getStr();
999*cdf0e10cSrcweir                 cpIndexDoku2 = pInfo->m_index;
1000*cdf0e10cSrcweir             }
1001*cdf0e10cSrcweir             pBuffer += writeUINT16(pBuffer, cpIndexDoku2);
1002*cdf0e10cSrcweir 
1003*cdf0e10cSrcweir             sal_uInt16 j;
1004*cdf0e10cSrcweir 
1005*cdf0e10cSrcweir             pBuffer += writeUINT16(pBuffer, m_methods[i].m_paramCount);
1006*cdf0e10cSrcweir 
1007*cdf0e10cSrcweir             for (j = 0; j < m_methods[i].m_paramCount; j++)
1008*cdf0e10cSrcweir             {
1009*cdf0e10cSrcweir                 if (m_methods[i].m_params[j].m_typeName.getLength())
1010*cdf0e10cSrcweir                 {
1011*cdf0e10cSrcweir                     pInfo = new CPInfo(CP_TAG_UTF8_NAME, pInfo);
1012*cdf0e10cSrcweir                     pInfo->m_value.aUtf8 = m_methods[i].m_params[j].m_typeName.getStr();
1013*cdf0e10cSrcweir                     cpIndexName = pInfo->m_index;
1014*cdf0e10cSrcweir                 }
1015*cdf0e10cSrcweir                 pBuffer += writeUINT16(pBuffer, cpIndexName);
1016*cdf0e10cSrcweir                 cpIndexName = 0;
1017*cdf0e10cSrcweir 
1018*cdf0e10cSrcweir                 pBuffer += writeUINT16(
1019*cdf0e10cSrcweir                     pBuffer,
1020*cdf0e10cSrcweir                     sal::static_int_cast< sal_uInt16 >(
1021*cdf0e10cSrcweir                         m_methods[i].m_params[j].m_mode));
1022*cdf0e10cSrcweir 
1023*cdf0e10cSrcweir                 if (m_methods[i].m_params[j].m_name.getLength())
1024*cdf0e10cSrcweir                 {
1025*cdf0e10cSrcweir                     pInfo = new CPInfo(CP_TAG_UTF8_NAME, pInfo);
1026*cdf0e10cSrcweir                     pInfo->m_value.aUtf8 = m_methods[i].m_params[j].m_name.getStr();
1027*cdf0e10cSrcweir                     cpIndexName = pInfo->m_index;
1028*cdf0e10cSrcweir                 }
1029*cdf0e10cSrcweir                 pBuffer += writeUINT16(pBuffer, cpIndexName);
1030*cdf0e10cSrcweir                 cpIndexName = 0;
1031*cdf0e10cSrcweir             }
1032*cdf0e10cSrcweir 
1033*cdf0e10cSrcweir             pBuffer += writeUINT16(pBuffer, m_methods[i].m_excCount);
1034*cdf0e10cSrcweir 
1035*cdf0e10cSrcweir             for (j = 0; j < m_methods[i].m_excCount; j++)
1036*cdf0e10cSrcweir             {
1037*cdf0e10cSrcweir                 if (m_methods[i].m_excNames[j].getLength())
1038*cdf0e10cSrcweir                 {
1039*cdf0e10cSrcweir                     pInfo = new CPInfo(CP_TAG_UTF8_NAME, pInfo);
1040*cdf0e10cSrcweir                     pInfo->m_value.aUtf8 = m_methods[i].m_excNames[j].getStr();
1041*cdf0e10cSrcweir                     cpIndexName = pInfo->m_index;
1042*cdf0e10cSrcweir                 }
1043*cdf0e10cSrcweir                 pBuffer += writeUINT16(pBuffer, cpIndexName);
1044*cdf0e10cSrcweir                 cpIndexName = 0;
1045*cdf0e10cSrcweir             }
1046*cdf0e10cSrcweir         }
1047*cdf0e10cSrcweir 
1048*cdf0e10cSrcweir         delete[] pMethodEntrySize;
1049*cdf0e10cSrcweir     }
1050*cdf0e10cSrcweir 
1051*cdf0e10cSrcweir     // reference blop
1052*cdf0e10cSrcweir     blopSize += entrySize; // referenceCount
1053*cdf0e10cSrcweir 
1054*cdf0e10cSrcweir     if (m_referenceCount)
1055*cdf0e10cSrcweir     {
1056*cdf0e10cSrcweir         sal_uInt16 cpIndexName = 0;
1057*cdf0e10cSrcweir         sal_uInt16 cpIndexDoku2 = 0;
1058*cdf0e10cSrcweir 
1059*cdf0e10cSrcweir 		// nReferenceEntries + n references
1060*cdf0e10cSrcweir 		blopReferenceSize = entrySize + (m_referenceCount * blopReferenceEntrySize);
1061*cdf0e10cSrcweir 
1062*cdf0e10cSrcweir         blopSize += blopReferenceSize;
1063*cdf0e10cSrcweir 
1064*cdf0e10cSrcweir         pBlopReferences = new sal_uInt8[blopReferenceSize];
1065*cdf0e10cSrcweir         pBuffer = pBlopReferences;
1066*cdf0e10cSrcweir 
1067*cdf0e10cSrcweir 	    pBuffer += writeUINT16(pBuffer, BLOP_REFERENCE_N_ENTRIES);
1068*cdf0e10cSrcweir 
1069*cdf0e10cSrcweir         for (sal_uInt16 i = 0; i < m_referenceCount; i++)
1070*cdf0e10cSrcweir         {
1071*cdf0e10cSrcweir             pBuffer += writeUINT16(
1072*cdf0e10cSrcweir                 pBuffer,
1073*cdf0e10cSrcweir                 sal::static_int_cast< sal_uInt16 >(m_references[i].m_type));
1074*cdf0e10cSrcweir 
1075*cdf0e10cSrcweir             cpIndexName = 0;
1076*cdf0e10cSrcweir             cpIndexDoku2 = 0;
1077*cdf0e10cSrcweir 
1078*cdf0e10cSrcweir             if (m_references[i].m_name.getLength())
1079*cdf0e10cSrcweir             {
1080*cdf0e10cSrcweir                 pInfo = new CPInfo(CP_TAG_UTF8_NAME, pInfo);
1081*cdf0e10cSrcweir                 pInfo->m_value.aUtf8 = m_references[i].m_name.getStr();
1082*cdf0e10cSrcweir                 cpIndexName = pInfo->m_index;
1083*cdf0e10cSrcweir             }
1084*cdf0e10cSrcweir             pBuffer += writeUINT16(pBuffer, cpIndexName);
1085*cdf0e10cSrcweir 
1086*cdf0e10cSrcweir             if (m_references[i].m_doku.getLength())
1087*cdf0e10cSrcweir             {
1088*cdf0e10cSrcweir                 pInfo = new CPInfo(CP_TAG_UTF8_NAME, pInfo);
1089*cdf0e10cSrcweir                 pInfo->m_value.aUtf8 = m_references[i].m_doku.getStr();
1090*cdf0e10cSrcweir                 cpIndexDoku2 = pInfo->m_index;
1091*cdf0e10cSrcweir             }
1092*cdf0e10cSrcweir             pBuffer += writeUINT16(pBuffer, cpIndexDoku2);
1093*cdf0e10cSrcweir 
1094*cdf0e10cSrcweir             pBuffer += writeUINT16(pBuffer, m_references[i].m_access);
1095*cdf0e10cSrcweir         }
1096*cdf0e10cSrcweir     }
1097*cdf0e10cSrcweir 
1098*cdf0e10cSrcweir 
1099*cdf0e10cSrcweir     // get CP infos blop-length
1100*cdf0e10cSrcweir     pInfo = root.m_next;
1101*cdf0e10cSrcweir     sal_uInt32 cpBlopSize = 0;
1102*cdf0e10cSrcweir     sal_uInt16 cpCount = 0;
1103*cdf0e10cSrcweir 
1104*cdf0e10cSrcweir     while (pInfo)
1105*cdf0e10cSrcweir     {
1106*cdf0e10cSrcweir         cpBlopSize += pInfo->getBlopSize();
1107*cdf0e10cSrcweir         cpCount++;
1108*cdf0e10cSrcweir         pInfo = pInfo->m_next;
1109*cdf0e10cSrcweir     }
1110*cdf0e10cSrcweir 
1111*cdf0e10cSrcweir     blopSize += cpBlopSize;
1112*cdf0e10cSrcweir     blopSize += sizeof(sal_uInt16);   // constantPoolCount
1113*cdf0e10cSrcweir 
1114*cdf0e10cSrcweir     // write all in flat buffer
1115*cdf0e10cSrcweir 
1116*cdf0e10cSrcweir     sal_uInt8 * blop = new sal_uInt8[blopSize];
1117*cdf0e10cSrcweir 
1118*cdf0e10cSrcweir     pBuffer = blop;
1119*cdf0e10cSrcweir 
1120*cdf0e10cSrcweir     // Assumes two's complement arithmetic with modulo-semantics:
1121*cdf0e10cSrcweir     pBuffer += writeUINT32(pBuffer, magic + m_version);
1122*cdf0e10cSrcweir     pBuffer += writeUINT32(pBuffer, blopSize);
1123*cdf0e10cSrcweir     pBuffer += writeUINT16(pBuffer, minorVersion);
1124*cdf0e10cSrcweir     pBuffer += writeUINT16(pBuffer, majorVersion);
1125*cdf0e10cSrcweir     pBuffer += writeUINT16(pBuffer, BLOP_HEADER_N_ENTRIES);
1126*cdf0e10cSrcweir 
1127*cdf0e10cSrcweir     pBuffer += writeUINT16(pBuffer, (sal_uInt16)RT_UNO_IDL);
1128*cdf0e10cSrcweir     pBuffer += writeUINT16(pBuffer, (sal_uInt16)m_typeClass);
1129*cdf0e10cSrcweir     pBuffer += writeUINT16(pBuffer, cpIndexThisName);
1130*cdf0e10cSrcweir     pBuffer += writeUINT16(pBuffer, cpIndexUik);
1131*cdf0e10cSrcweir     pBuffer += writeUINT16(pBuffer, cpIndexDoku);
1132*cdf0e10cSrcweir     pBuffer += writeUINT16(pBuffer, cpIndexFileName);
1133*cdf0e10cSrcweir 
1134*cdf0e10cSrcweir 	// write supertypes
1135*cdf0e10cSrcweir     pBuffer += writeUINT16(pBuffer, m_nSuperTypes);
1136*cdf0e10cSrcweir 	if (m_nSuperTypes)
1137*cdf0e10cSrcweir 	{
1138*cdf0e10cSrcweir 		for (sal_uInt32 i=0; i < m_nSuperTypes; i++)
1139*cdf0e10cSrcweir 		{
1140*cdf0e10cSrcweir 		    pBuffer += writeUINT16(pBuffer, cpIndexSuperNames[i]);
1141*cdf0e10cSrcweir 		}
1142*cdf0e10cSrcweir 		delete[] cpIndexSuperNames;
1143*cdf0e10cSrcweir 	}
1144*cdf0e10cSrcweir 
1145*cdf0e10cSrcweir     pBuffer += writeUINT16(pBuffer, cpCount);
1146*cdf0e10cSrcweir 
1147*cdf0e10cSrcweir     // write and delete CP infos
1148*cdf0e10cSrcweir     pInfo = root.m_next;
1149*cdf0e10cSrcweir 
1150*cdf0e10cSrcweir     while (pInfo)
1151*cdf0e10cSrcweir     {
1152*cdf0e10cSrcweir         CPInfo* pNextInfo = pInfo->m_next;
1153*cdf0e10cSrcweir 
1154*cdf0e10cSrcweir         pBuffer += pInfo->toBlop(pBuffer);
1155*cdf0e10cSrcweir         delete pInfo;
1156*cdf0e10cSrcweir 
1157*cdf0e10cSrcweir         pInfo = pNextInfo;
1158*cdf0e10cSrcweir     }
1159*cdf0e10cSrcweir 
1160*cdf0e10cSrcweir     // write fields
1161*cdf0e10cSrcweir     pBuffer += writeUINT16(pBuffer, m_fieldCount);
1162*cdf0e10cSrcweir     if (blopFieldsSize)
1163*cdf0e10cSrcweir     {
1164*cdf0e10cSrcweir         memcpy(pBuffer, pBlopFields, blopFieldsSize);
1165*cdf0e10cSrcweir         pBuffer += blopFieldsSize;
1166*cdf0e10cSrcweir     }
1167*cdf0e10cSrcweir 
1168*cdf0e10cSrcweir     // write methods
1169*cdf0e10cSrcweir     pBuffer += writeUINT16(pBuffer, m_methodCount);
1170*cdf0e10cSrcweir     if (blopMethodsSize)
1171*cdf0e10cSrcweir     {
1172*cdf0e10cSrcweir         memcpy(pBuffer, pBlopMethods, blopMethodsSize);
1173*cdf0e10cSrcweir         pBuffer += blopMethodsSize;
1174*cdf0e10cSrcweir     }
1175*cdf0e10cSrcweir 
1176*cdf0e10cSrcweir     // write references
1177*cdf0e10cSrcweir     pBuffer += writeUINT16(pBuffer, m_referenceCount);
1178*cdf0e10cSrcweir     if (blopReferenceSize)
1179*cdf0e10cSrcweir     {
1180*cdf0e10cSrcweir         memcpy(pBuffer, pBlopReferences, blopReferenceSize);
1181*cdf0e10cSrcweir         pBuffer += blopReferenceSize;
1182*cdf0e10cSrcweir     }
1183*cdf0e10cSrcweir 
1184*cdf0e10cSrcweir     delete[] pBlopFields;
1185*cdf0e10cSrcweir     delete[] pBlopMethods;
1186*cdf0e10cSrcweir     delete[] pBlopReferences;
1187*cdf0e10cSrcweir 
1188*cdf0e10cSrcweir     delete[] m_blop;
1189*cdf0e10cSrcweir     m_blop = blop;
1190*cdf0e10cSrcweir     m_blopSize = blopSize;
1191*cdf0e10cSrcweir }
1192*cdf0e10cSrcweir 
1193*cdf0e10cSrcweir 
1194*cdf0e10cSrcweir /**************************************************************************
1195*cdf0e10cSrcweir 
1196*cdf0e10cSrcweir     C-API
1197*cdf0e10cSrcweir 
1198*cdf0e10cSrcweir **************************************************************************/
1199*cdf0e10cSrcweir 
1200*cdf0e10cSrcweir extern "C" {
1201*cdf0e10cSrcweir 
1202*cdf0e10cSrcweir static void TYPEREG_CALLTYPE acquire(TypeWriterImpl hEntry)
1203*cdf0e10cSrcweir {
1204*cdf0e10cSrcweir     TypeWriter* pEntry = (TypeWriter*) hEntry;
1205*cdf0e10cSrcweir 
1206*cdf0e10cSrcweir     if (pEntry != NULL)
1207*cdf0e10cSrcweir         pEntry->m_refCount++;
1208*cdf0e10cSrcweir }
1209*cdf0e10cSrcweir 
1210*cdf0e10cSrcweir static void TYPEREG_CALLTYPE release(TypeWriterImpl hEntry)
1211*cdf0e10cSrcweir {
1212*cdf0e10cSrcweir     TypeWriter* pEntry = (TypeWriter*) hEntry;
1213*cdf0e10cSrcweir 
1214*cdf0e10cSrcweir     if (pEntry != NULL)
1215*cdf0e10cSrcweir     {
1216*cdf0e10cSrcweir         if (--pEntry->m_refCount == 0)
1217*cdf0e10cSrcweir             delete pEntry;
1218*cdf0e10cSrcweir     }
1219*cdf0e10cSrcweir }
1220*cdf0e10cSrcweir 
1221*cdf0e10cSrcweir static void TYPEREG_CALLTYPE setUik(TypeWriterImpl  hEntry, const RTUik* uik)
1222*cdf0e10cSrcweir {
1223*cdf0e10cSrcweir     TypeWriter* pEntry = (TypeWriter*) hEntry;
1224*cdf0e10cSrcweir 
1225*cdf0e10cSrcweir     if (pEntry != NULL)
1226*cdf0e10cSrcweir     {
1227*cdf0e10cSrcweir         if (pEntry->m_pUik)
1228*cdf0e10cSrcweir         {
1229*cdf0e10cSrcweir             pEntry->m_pUik->m_Data1 = uik->m_Data1;
1230*cdf0e10cSrcweir             pEntry->m_pUik->m_Data2 = uik->m_Data2;
1231*cdf0e10cSrcweir             pEntry->m_pUik->m_Data3 = uik->m_Data3;
1232*cdf0e10cSrcweir             pEntry->m_pUik->m_Data4 = uik->m_Data4;
1233*cdf0e10cSrcweir             pEntry->m_pUik->m_Data5 = uik->m_Data5;
1234*cdf0e10cSrcweir         }
1235*cdf0e10cSrcweir         else
1236*cdf0e10cSrcweir             pEntry->m_pUik = new RTUik(*uik);
1237*cdf0e10cSrcweir     }
1238*cdf0e10cSrcweir }
1239*cdf0e10cSrcweir 
1240*cdf0e10cSrcweir static void TYPEREG_CALLTYPE setDoku(TypeWriterImpl hEntry, rtl_uString* doku)
1241*cdf0e10cSrcweir {
1242*cdf0e10cSrcweir     static_cast< TypeWriter * >(hEntry)->m_doku = toByteString(doku);
1243*cdf0e10cSrcweir }
1244*cdf0e10cSrcweir 
1245*cdf0e10cSrcweir static void TYPEREG_CALLTYPE setFileName(TypeWriterImpl hEntry, rtl_uString* fileName)
1246*cdf0e10cSrcweir {
1247*cdf0e10cSrcweir     static_cast< TypeWriter * >(hEntry)->m_fileName = toByteString(fileName);
1248*cdf0e10cSrcweir }
1249*cdf0e10cSrcweir 
1250*cdf0e10cSrcweir sal_Bool typereg_writer_setFieldData(
1251*cdf0e10cSrcweir     void * handle, sal_uInt16 index, rtl_uString const * documentation,
1252*cdf0e10cSrcweir     rtl_uString const * fileName, RTFieldAccess flags, rtl_uString const * name,
1253*cdf0e10cSrcweir     rtl_uString const * typeName, RTValueType valueType,
1254*cdf0e10cSrcweir     RTConstValueUnion valueValue)
1255*cdf0e10cSrcweir     SAL_THROW_EXTERN_C()
1256*cdf0e10cSrcweir {
1257*cdf0e10cSrcweir     try {
1258*cdf0e10cSrcweir         static_cast< TypeWriter * >(handle)->m_fields[index].setData(
1259*cdf0e10cSrcweir             toByteString(name), toByteString(typeName),
1260*cdf0e10cSrcweir             toByteString(documentation), toByteString(fileName), flags,
1261*cdf0e10cSrcweir             valueType, valueValue);
1262*cdf0e10cSrcweir     } catch (std::bad_alloc &) {
1263*cdf0e10cSrcweir         return false;
1264*cdf0e10cSrcweir     }
1265*cdf0e10cSrcweir     return true;
1266*cdf0e10cSrcweir }
1267*cdf0e10cSrcweir 
1268*cdf0e10cSrcweir static void TYPEREG_CALLTYPE setFieldData(TypeWriterImpl    hEntry,
1269*cdf0e10cSrcweir                                           sal_uInt16       	index,
1270*cdf0e10cSrcweir                                           rtl_uString*     	name,
1271*cdf0e10cSrcweir                                           rtl_uString*     	typeName,
1272*cdf0e10cSrcweir                                           rtl_uString*     	doku,
1273*cdf0e10cSrcweir                                           rtl_uString*     	fileName,
1274*cdf0e10cSrcweir                                           RTFieldAccess    	access,
1275*cdf0e10cSrcweir                                           RTValueType       valueType,
1276*cdf0e10cSrcweir                                           RTConstValueUnion	constValue)
1277*cdf0e10cSrcweir {
1278*cdf0e10cSrcweir     typereg_writer_setFieldData(
1279*cdf0e10cSrcweir         hEntry, index, doku, fileName, access, name, typeName, valueType,
1280*cdf0e10cSrcweir         constValue);
1281*cdf0e10cSrcweir }
1282*cdf0e10cSrcweir 
1283*cdf0e10cSrcweir sal_Bool typereg_writer_setMethodData(
1284*cdf0e10cSrcweir     void * handle, sal_uInt16 index, rtl_uString const * documentation,
1285*cdf0e10cSrcweir     RTMethodMode flags, rtl_uString const * name,
1286*cdf0e10cSrcweir     rtl_uString const * returnTypeName, sal_uInt16 parameterCount,
1287*cdf0e10cSrcweir     sal_uInt16 exceptionCount)
1288*cdf0e10cSrcweir     SAL_THROW_EXTERN_C()
1289*cdf0e10cSrcweir {
1290*cdf0e10cSrcweir     try {
1291*cdf0e10cSrcweir         static_cast< TypeWriter * >(handle)->m_methods[index].setData(
1292*cdf0e10cSrcweir             toByteString(name), toByteString(returnTypeName), flags,
1293*cdf0e10cSrcweir             parameterCount, exceptionCount, toByteString(documentation));
1294*cdf0e10cSrcweir     } catch (std::bad_alloc &) {
1295*cdf0e10cSrcweir         return false;
1296*cdf0e10cSrcweir     }
1297*cdf0e10cSrcweir     return true;
1298*cdf0e10cSrcweir }
1299*cdf0e10cSrcweir 
1300*cdf0e10cSrcweir static void TYPEREG_CALLTYPE setMethodData(TypeWriterImpl   hEntry,
1301*cdf0e10cSrcweir                                            sal_uInt16       index,
1302*cdf0e10cSrcweir                                            rtl_uString*  	name,
1303*cdf0e10cSrcweir                                            rtl_uString*  	returnTypeName,
1304*cdf0e10cSrcweir                                            RTMethodMode 	mode,
1305*cdf0e10cSrcweir                                            sal_uInt16       paramCount,
1306*cdf0e10cSrcweir                                            sal_uInt16       excCount,
1307*cdf0e10cSrcweir                                            rtl_uString*  	doku)
1308*cdf0e10cSrcweir {
1309*cdf0e10cSrcweir     typereg_writer_setMethodData(
1310*cdf0e10cSrcweir         hEntry, index, doku, mode, name, returnTypeName, paramCount, excCount);
1311*cdf0e10cSrcweir }
1312*cdf0e10cSrcweir 
1313*cdf0e10cSrcweir sal_Bool typereg_writer_setMethodParameterData(
1314*cdf0e10cSrcweir     void * handle, sal_uInt16 methodIndex, sal_uInt16 parameterIndex,
1315*cdf0e10cSrcweir     RTParamMode flags, rtl_uString const * name, rtl_uString const * typeName)
1316*cdf0e10cSrcweir     SAL_THROW_EXTERN_C()
1317*cdf0e10cSrcweir {
1318*cdf0e10cSrcweir     try {
1319*cdf0e10cSrcweir         static_cast< TypeWriter * >(handle)->
1320*cdf0e10cSrcweir             m_methods[methodIndex].m_params[parameterIndex].setData(
1321*cdf0e10cSrcweir                 toByteString(typeName), toByteString(name), flags);
1322*cdf0e10cSrcweir     } catch (std::bad_alloc &) {
1323*cdf0e10cSrcweir         return false;
1324*cdf0e10cSrcweir     }
1325*cdf0e10cSrcweir     return true;
1326*cdf0e10cSrcweir }
1327*cdf0e10cSrcweir 
1328*cdf0e10cSrcweir static void TYPEREG_CALLTYPE setParamData(TypeWriterImpl    hEntry,
1329*cdf0e10cSrcweir                                           sal_uInt16       	index,
1330*cdf0e10cSrcweir                                           sal_uInt16  		paramIndex,
1331*cdf0e10cSrcweir                                           rtl_uString*     	type,
1332*cdf0e10cSrcweir                                           rtl_uString*     	name,
1333*cdf0e10cSrcweir                                           RTParamMode      	mode)
1334*cdf0e10cSrcweir {
1335*cdf0e10cSrcweir     typereg_writer_setMethodParameterData(
1336*cdf0e10cSrcweir         hEntry, index, paramIndex, mode, name, type);
1337*cdf0e10cSrcweir }
1338*cdf0e10cSrcweir 
1339*cdf0e10cSrcweir sal_Bool typereg_writer_setMethodExceptionTypeName(
1340*cdf0e10cSrcweir     void * handle, sal_uInt16 methodIndex, sal_uInt16 exceptionIndex,
1341*cdf0e10cSrcweir     rtl_uString const * typeName)
1342*cdf0e10cSrcweir     SAL_THROW_EXTERN_C()
1343*cdf0e10cSrcweir {
1344*cdf0e10cSrcweir     try {
1345*cdf0e10cSrcweir         static_cast< TypeWriter * >(handle)->m_methods[methodIndex].setExcName(
1346*cdf0e10cSrcweir             exceptionIndex, toByteString(typeName));
1347*cdf0e10cSrcweir     } catch (std::bad_alloc &) {
1348*cdf0e10cSrcweir         return false;
1349*cdf0e10cSrcweir     }
1350*cdf0e10cSrcweir     return true;
1351*cdf0e10cSrcweir }
1352*cdf0e10cSrcweir 
1353*cdf0e10cSrcweir static void TYPEREG_CALLTYPE setExcData(TypeWriterImpl  hEntry,
1354*cdf0e10cSrcweir                                         sal_uInt16      index,
1355*cdf0e10cSrcweir                                         sal_uInt16      excIndex,
1356*cdf0e10cSrcweir                                         rtl_uString* 	type)
1357*cdf0e10cSrcweir {
1358*cdf0e10cSrcweir     typereg_writer_setMethodExceptionTypeName(hEntry, index, excIndex, type);
1359*cdf0e10cSrcweir }
1360*cdf0e10cSrcweir 
1361*cdf0e10cSrcweir void const * typereg_writer_getBlob(void * handle, sal_uInt32 * size)
1362*cdf0e10cSrcweir     SAL_THROW_EXTERN_C()
1363*cdf0e10cSrcweir {
1364*cdf0e10cSrcweir     TypeWriter * writer = static_cast< TypeWriter * >(handle);
1365*cdf0e10cSrcweir     if (writer->m_blop == 0) {
1366*cdf0e10cSrcweir         try {
1367*cdf0e10cSrcweir             writer->createBlop();
1368*cdf0e10cSrcweir         } catch (std::bad_alloc &) {
1369*cdf0e10cSrcweir             return 0;
1370*cdf0e10cSrcweir         }
1371*cdf0e10cSrcweir     }
1372*cdf0e10cSrcweir     *size = writer->m_blopSize;
1373*cdf0e10cSrcweir     return writer->m_blop;
1374*cdf0e10cSrcweir }
1375*cdf0e10cSrcweir 
1376*cdf0e10cSrcweir static const sal_uInt8* TYPEREG_CALLTYPE getBlop(TypeWriterImpl hEntry)
1377*cdf0e10cSrcweir {
1378*cdf0e10cSrcweir     sal_uInt32 size;
1379*cdf0e10cSrcweir     return static_cast< sal_uInt8 const * >(
1380*cdf0e10cSrcweir         typereg_writer_getBlob(hEntry, &size));
1381*cdf0e10cSrcweir }
1382*cdf0e10cSrcweir 
1383*cdf0e10cSrcweir static sal_uInt32 TYPEREG_CALLTYPE getBlopSize(TypeWriterImpl hEntry)
1384*cdf0e10cSrcweir {
1385*cdf0e10cSrcweir     sal_uInt32 size;
1386*cdf0e10cSrcweir     typereg_writer_getBlob(hEntry, &size);
1387*cdf0e10cSrcweir     return size;
1388*cdf0e10cSrcweir }
1389*cdf0e10cSrcweir 
1390*cdf0e10cSrcweir sal_Bool typereg_writer_setReferenceData(
1391*cdf0e10cSrcweir     void * handle, sal_uInt16 index, rtl_uString const * documentation,
1392*cdf0e10cSrcweir     RTReferenceType sort, RTFieldAccess flags, rtl_uString const * typeName)
1393*cdf0e10cSrcweir     SAL_THROW_EXTERN_C()
1394*cdf0e10cSrcweir {
1395*cdf0e10cSrcweir     try {
1396*cdf0e10cSrcweir         static_cast< TypeWriter * >(handle)->m_references[index].setData(
1397*cdf0e10cSrcweir             toByteString(typeName), sort, toByteString(documentation), flags);
1398*cdf0e10cSrcweir     } catch (std::bad_alloc &) {
1399*cdf0e10cSrcweir         return false;
1400*cdf0e10cSrcweir     }
1401*cdf0e10cSrcweir     return true;
1402*cdf0e10cSrcweir }
1403*cdf0e10cSrcweir 
1404*cdf0e10cSrcweir static void TYPEREG_CALLTYPE setReferenceData(TypeWriterImpl    hEntry,
1405*cdf0e10cSrcweir                                               sal_uInt16        index,
1406*cdf0e10cSrcweir                                               rtl_uString*   	name,
1407*cdf0e10cSrcweir                                               RTReferenceType   refType,
1408*cdf0e10cSrcweir                                               rtl_uString*   	doku,
1409*cdf0e10cSrcweir 											  RTFieldAccess 	access)
1410*cdf0e10cSrcweir {
1411*cdf0e10cSrcweir     typereg_writer_setReferenceData(hEntry, index, doku, refType, access, name);
1412*cdf0e10cSrcweir }
1413*cdf0e10cSrcweir 
1414*cdf0e10cSrcweir void * typereg_writer_create(
1415*cdf0e10cSrcweir     typereg_Version version, rtl_uString const * documentation,
1416*cdf0e10cSrcweir     rtl_uString const * fileName, RTTypeClass typeClass, sal_Bool published,
1417*cdf0e10cSrcweir     rtl_uString const * typeName, sal_uInt16 superTypeCount,
1418*cdf0e10cSrcweir     sal_uInt16 fieldCount, sal_uInt16 methodCount, sal_uInt16 referenceCount)
1419*cdf0e10cSrcweir     SAL_THROW_EXTERN_C()
1420*cdf0e10cSrcweir {
1421*cdf0e10cSrcweir     try {
1422*cdf0e10cSrcweir         return new TypeWriter(
1423*cdf0e10cSrcweir             version, toByteString(documentation), toByteString(fileName),
1424*cdf0e10cSrcweir             typeClass, published, toByteString(typeName), superTypeCount,
1425*cdf0e10cSrcweir             fieldCount, methodCount, referenceCount);
1426*cdf0e10cSrcweir     } catch (std::bad_alloc &) {
1427*cdf0e10cSrcweir         return 0;
1428*cdf0e10cSrcweir     }
1429*cdf0e10cSrcweir }
1430*cdf0e10cSrcweir 
1431*cdf0e10cSrcweir void typereg_writer_destroy(void * handle) SAL_THROW_EXTERN_C() {
1432*cdf0e10cSrcweir     delete static_cast< TypeWriter * >(handle);
1433*cdf0e10cSrcweir }
1434*cdf0e10cSrcweir 
1435*cdf0e10cSrcweir sal_Bool typereg_writer_setSuperTypeName(
1436*cdf0e10cSrcweir     void * handle, sal_uInt16 index, rtl_uString const * typeName)
1437*cdf0e10cSrcweir     SAL_THROW_EXTERN_C()
1438*cdf0e10cSrcweir {
1439*cdf0e10cSrcweir     try {
1440*cdf0e10cSrcweir         static_cast< TypeWriter * >(handle)->setSuperType(
1441*cdf0e10cSrcweir             index, toByteString(typeName));
1442*cdf0e10cSrcweir     } catch (std::bad_alloc &) {
1443*cdf0e10cSrcweir         return false;
1444*cdf0e10cSrcweir     }
1445*cdf0e10cSrcweir     return true;
1446*cdf0e10cSrcweir }
1447*cdf0e10cSrcweir 
1448*cdf0e10cSrcweir static TypeWriterImpl TYPEREG_CALLTYPE createEntry(
1449*cdf0e10cSrcweir     RTTypeClass typeClass, rtl_uString * typeName, rtl_uString * superTypeName,
1450*cdf0e10cSrcweir     sal_uInt16 fieldCount, sal_uInt16 methodCount, sal_uInt16 referenceCount)
1451*cdf0e10cSrcweir {
1452*cdf0e10cSrcweir     rtl::OUString empty;
1453*cdf0e10cSrcweir     sal_uInt16 superTypeCount = rtl_uString_getLength(superTypeName) == 0
1454*cdf0e10cSrcweir         ? 0 : 1;
1455*cdf0e10cSrcweir     TypeWriterImpl t = typereg_writer_create(
1456*cdf0e10cSrcweir         TYPEREG_VERSION_0, empty.pData, empty.pData, typeClass, false, typeName,
1457*cdf0e10cSrcweir         superTypeCount, fieldCount, methodCount, referenceCount);
1458*cdf0e10cSrcweir     if (superTypeCount > 0) {
1459*cdf0e10cSrcweir         typereg_writer_setSuperTypeName(t, 0, superTypeName);
1460*cdf0e10cSrcweir     }
1461*cdf0e10cSrcweir     return t;
1462*cdf0e10cSrcweir }
1463*cdf0e10cSrcweir 
1464*cdf0e10cSrcweir RegistryTypeWriter_Api* TYPEREG_CALLTYPE initRegistryTypeWriter_Api(void)
1465*cdf0e10cSrcweir {
1466*cdf0e10cSrcweir     static RegistryTypeWriter_Api aApi= {0,0,0,0,0,0,0,0,0,0,0,0,0};
1467*cdf0e10cSrcweir     if (!aApi.acquire)
1468*cdf0e10cSrcweir     {
1469*cdf0e10cSrcweir         aApi.createEntry        = &createEntry;
1470*cdf0e10cSrcweir         aApi.acquire            = &acquire;
1471*cdf0e10cSrcweir         aApi.release            = &release;
1472*cdf0e10cSrcweir         aApi.setUik             = &setUik;
1473*cdf0e10cSrcweir         aApi.setDoku            = &setDoku;
1474*cdf0e10cSrcweir         aApi.setFileName        = &setFileName;
1475*cdf0e10cSrcweir         aApi.setFieldData       = &setFieldData;
1476*cdf0e10cSrcweir         aApi.setMethodData      = &setMethodData;
1477*cdf0e10cSrcweir         aApi.setParamData       = &setParamData;
1478*cdf0e10cSrcweir         aApi.setExcData         = &setExcData;
1479*cdf0e10cSrcweir         aApi.getBlop            = &getBlop;
1480*cdf0e10cSrcweir         aApi.getBlopSize        = &getBlopSize;
1481*cdf0e10cSrcweir         aApi.setReferenceData   = &setReferenceData;
1482*cdf0e10cSrcweir 
1483*cdf0e10cSrcweir         return (&aApi);
1484*cdf0e10cSrcweir     }
1485*cdf0e10cSrcweir     else
1486*cdf0e10cSrcweir     {
1487*cdf0e10cSrcweir         return (&aApi);
1488*cdf0e10cSrcweir     }
1489*cdf0e10cSrcweir }
1490*cdf0e10cSrcweir 
1491*cdf0e10cSrcweir }
1492