]>
git.saurik.com Git - apple/icu.git/blob - icuSources/tools/toolutil/ucmpwrit.c
1 /**********************************************************************
2 * Copyright (C) 1998-2000, International Business Machines Corporation
3 * and others. All Rights Reserved.
4 **********************************************************************/
12 ---------------------------------------------
15 8 512*2 = 1024 fIndex [uint16's] (UCMP8_kIndexCount*2)
16 1032 1*fCount fArray [int8_t's]
17 + padding (to extend fCount to the nearest multiple of 4)
21 #if (UCMP8_kIndexCount != 512)
22 # error UCMP8_kIndexCount - changed size. Check to see if different pading needed.
25 U_CAPI
uint32_t U_EXPORT2
udata_write_ucmp8 (UNewDataMemory
*pData
, const CompactByteArray
* array
)
29 udata_write32(pData
, ICU_UCMP8_VERSION
);
32 udata_write32(pData
, array
->fCount
);
35 udata_writeBlock(pData
, array
->fIndex
, sizeof(array
->fIndex
[0])*UCMP8_kIndexCount
);
36 size
+= sizeof(array
->fIndex
[0])*UCMP8_kIndexCount
;
38 udata_writeBlock(pData
, array
->fArray
, sizeof(array
->fArray
[0])*array
->fCount
);
39 size
+= sizeof(array
->fArray
[0])*array
->fCount
;
41 while(size%4
) /* end padding */
43 udata_writePadding(pData
, 1); /* Pad total so far to even size */
50 /* internal constants*/
53 static const int32_t UCMP16_kMaxUnicode
= UCMP16_kMaxUnicode_int
;
54 static const int32_t UCMP16_kUnicodeCount
= UCMP16_kUnicodeCount_int
;
55 static const int32_t UCMP16_kBlockShift
= UCMP16_kBlockShift_int
;
56 static const int32_t UCMP16_kBlockCount
= UCMP16_kBlockCount_int
;
57 static const int32_t UCMP16_kBlockBytes
= UCMP16_kBlockBytes_int
;
58 static const int32_t UCMP16_kIndexShift
= UCMP16_kIndexShift_int
;
59 static const int32_t UCMP16_kIndexCount
= UCMP16_kIndexCount_int
;
60 static const uint32_t UCMP16_kBlockMask
= UCMP16_kBlockMask_int
;
66 ---------------------------------------------
67 0 4 ICU_UCMP16_VERSION
71 16 512*2 = 1024 fIndex [uint16's] (UCMP16_kIndexCount*2)
72 1032 1*fCount fArray [int16's]
73 + padding (to extend fCount to the nearest multiple of 4)
77 #if (UCMP16_kIndexCount_int != 512)
78 # error UCMP16_kIndexCount - changed size. Check to see if different pading needed.
81 U_CAPI
uint32_t U_EXPORT2
udata_write_ucmp16 (UNewDataMemory
*pData
, const CompactShortArray
* array
)
85 udata_write32(pData
, ICU_UCMP16_VERSION
);
88 udata_write32(pData
, array
->fCount
);
91 udata_write32(pData
, array
->kBlockShift
);
94 udata_write32(pData
, array
->kBlockMask
);
97 udata_writeBlock(pData
, array
->fIndex
, sizeof(array
->fIndex
[0])*UCMP16_kIndexCount
);
98 size
+= sizeof(array
->fIndex
[0])*UCMP16_kIndexCount
;
100 udata_writeBlock(pData
, array
->fArray
, sizeof(array
->fArray
[0])*array
->fCount
);
101 size
+= sizeof(array
->fArray
[0])*array
->fCount
;
103 while(size%4
) /* end padding */
105 udata_writePadding(pData
, 1); /* Pad total so far to even size */
120 ---------------------------------------------
121 0 4 ICU_UCMP32_VERSION
123 16 512*2 = 1024 fIndex [uint16's] (UCMP16_kIndexCount*2)
124 1032 1*fCount fArray [int32's]
125 Padding is not needed for ucmp32, since the array consists of int32's
126 + padding (to extend fCount to the nearest multiple of 4)
130 #if (UCMP32_kIndexCount != 512)
131 # error UCMP32_kIndexCount - changed size. Check to see if different pading needed.
134 U_CAPI
uint32_t U_EXPORT2
udata_write_ucmp32 (UNewDataMemory
*pData
, const CompactIntArray
* array
)
138 udata_write32(pData
, ICU_UCMP32_VERSION
);
141 udata_write32(pData
, array
->fCount
);
144 udata_writeBlock(pData
, array
->fIndex
, sizeof(array
->fIndex
[0])*UCMP32_kIndexCount
);
145 size
+= sizeof(array
->fIndex
[0])*UCMP32_kIndexCount
;
147 udata_writeBlock(pData
, array
->fArray
, sizeof(array
->fArray
[0])*array
->fCount
);
148 size
+= sizeof(array
->fArray
[0])*array
->fCount
;
150 while(size%4
) /* end padding */
152 udata_writePadding(pData
, 1); /* Pad total so far to even size */