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