Mercurial > projects > dstep
comparison dstep/coreservices/carboncore/UnicodeUtilities.d @ 11:07194b026fa4
Added bindings to a couple of frameworks, new license + some other things
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Sat, 01 Aug 2009 15:03:28 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
10:27e00625790b | 11:07194b026fa4 |
---|---|
1 /** | |
2 * Copyright: Copyright (c) 2009 Jacob Carlborg. | |
3 * Authors: Jacob Carlborg | |
4 * Version: Initial created: Jul 21, 2009 | |
5 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0) | |
6 */ | |
7 module dstep.coreservices.carboncore.UnicodeUtilities; | |
8 | |
9 //import dstep.AvailabilityMacros; | |
10 import dstep.corefoundation.CFBase; | |
11 import dstep.coreservices.carboncore.MacLocales; | |
12 import dstep.coreservices.carboncore.MacTypes; | |
13 import dstep.coreservices.carboncore.MixedMode; | |
14 import dstep.coreservices.carboncore.TextCommon; | |
15 import dstep.corefoundation.CFCharacterSet; | |
16 import dstep.objc.bridge.TypeEncoding; | |
17 | |
18 struct OpaqueCollatorRef; | |
19 struct OpaqueUCTypeSelectRef; | |
20 struct OpaqueTextBreakLocatorRef; | |
21 | |
22 alias ushort UCKeyOutput; | |
23 alias ushort UCKeyCharSeq; | |
24 alias OpaqueCollatorRef* CollatorRef; | |
25 alias uint UCCollateOptions; | |
26 alias uint UCCollationValue; | |
27 alias OpaqueUCTypeSelectRef* UCTypeSelectRef; | |
28 alias int UCTypeSelectCompareResult; | |
29 alias ushort UCTSWalkDirection; | |
30 alias ushort UCTypeSelectOptions; | |
31 alias IndexToUCStringProcPtr IndexToUCStringUPP; | |
32 alias OpaqueTextBreakLocatorRef* TextBreakLocatorRef; | |
33 alias uint UCTextBreakType; | |
34 alias uint UCTextBreakOptions; | |
35 | |
36 extern (C) | |
37 { | |
38 alias ubyte function (uint, void*, void*, CFStringRef*, UCTypeSelectOptions*) IndexToUCStringProcPtr; | |
39 } | |
40 | |
41 // This is needed otherwise the enums will fail compiling with gdc | |
42 version (GNU) | |
43 { | |
44 private | |
45 { | |
46 const __kUnicodeCollationClass = getOSType!("ucol"); | |
47 | |
48 } | |
49 } | |
50 | |
51 // This is needed otherwise the enums will fail compiling with gdc | |
52 version (GNU) | |
53 { | |
54 private | |
55 { | |
56 const __kUnicodeTextBreakClass = getOSType!("ubrk"); | |
57 | |
58 } | |
59 } | |
60 | |
61 enum | |
62 { | |
63 kUCKeyOutputStateIndexMask = 0x4000, | |
64 kUCKeyOutputSequenceIndexMask = 0x8000, | |
65 kUCKeyOutputTestForIndexMask = 0xC000, | |
66 kUCKeyOutputGetIndexMask = 0x3FFF | |
67 } | |
68 | |
69 enum | |
70 { | |
71 kUCKeyStateEntryTerminalFormat = 0x0001, | |
72 kUCKeyStateEntryRangeFormat = 0x0002 | |
73 } | |
74 | |
75 enum | |
76 { | |
77 kUCKeyLayoutHeaderFormat = 0x1002, | |
78 kUCKeyLayoutFeatureInfoFormat = 0x2001, | |
79 kUCKeyModifiersToTableNumFormat = 0x3001, | |
80 kUCKeyToCharTableIndexFormat = 0x4001, | |
81 kUCKeyStateRecordsIndexFormat = 0x5001, | |
82 kUCKeyStateTerminatorsFormat = 0x6001, | |
83 kUCKeySequenceDataIndexFormat = 0x7001 | |
84 } | |
85 | |
86 enum | |
87 { | |
88 kUCKeyActionDown = 0, | |
89 kUCKeyActionUp = 1, | |
90 kUCKeyActionAutoKey = 2, | |
91 kUCKeyActionDisplay = 3 | |
92 } | |
93 | |
94 enum | |
95 { | |
96 kUCKeyTranslateNoDeadKeysBit = 0 | |
97 } | |
98 | |
99 enum | |
100 { | |
101 kUCKeyTranslateNoDeadKeysMask = 1L << kUCKeyTranslateNoDeadKeysBit | |
102 } | |
103 | |
104 enum | |
105 { | |
106 kUnicodeCollationClass = getOSType!("ucol") | |
107 } | |
108 | |
109 enum | |
110 { | |
111 kUCCollateComposeInsensitiveMask = 1L << 1, | |
112 kUCCollateWidthInsensitiveMask = 1L << 2, | |
113 kUCCollateCaseInsensitiveMask = 1L << 3, | |
114 kUCCollateDiacritInsensitiveMask = 1L << 4, | |
115 kUCCollatePunctuationSignificantMask = 1L << 15, | |
116 kUCCollateDigitsOverrideMask = 1L << 16, | |
117 kUCCollateDigitsAsNumberMask = 1L << 17 | |
118 } | |
119 | |
120 enum | |
121 { | |
122 kUCCollateStandardOptions = kUCCollateComposeInsensitiveMask | kUCCollateWidthInsensitiveMask | |
123 } | |
124 | |
125 enum | |
126 { | |
127 kUCCollateTypeHFSExtended = 1 | |
128 } | |
129 | |
130 enum | |
131 { | |
132 kUCCollateTypeSourceMask = 0x000000FF, | |
133 kUCCollateTypeShiftBits = 24 | |
134 } | |
135 | |
136 enum | |
137 { | |
138 kUCCollateTypeMask = kUCCollateTypeSourceMask << kUCCollateTypeShiftBits | |
139 } | |
140 | |
141 enum | |
142 { | |
143 kUCTSDirectionNext = 0, | |
144 kUCTSDirectionPrevious = 1 | |
145 } | |
146 | |
147 enum | |
148 { | |
149 kUCTSOptionsNoneMask = 0, | |
150 kUCTSOptionsReleaseStringMask = 1, | |
151 kUCTSOptionsDataIsOrderedMask = 2 | |
152 } | |
153 | |
154 enum | |
155 { | |
156 kUCTypeSelectMaxListSize = cast(uint)0xFFFFFFFF | |
157 } | |
158 | |
159 enum | |
160 { | |
161 kUnicodeTextBreakClass = getOSType!("ubrk") | |
162 } | |
163 | |
164 enum | |
165 { | |
166 kUCTextBreakCharMask = 1L << 0, | |
167 kUCTextBreakClusterMask = 1L << 2, | |
168 kUCTextBreakWordMask = 1L << 4, | |
169 kUCTextBreakLineMask = 1L << 6, | |
170 kUCTextBreakParagraphMask = 1L << 8 | |
171 } | |
172 | |
173 enum | |
174 { | |
175 kUCTextBreakLeadingEdgeMask = 1L << 0, | |
176 kUCTextBreakGoBackwardsMask = 1L << 1, | |
177 kUCTextBreakIterateMask = 1L << 2 | |
178 } | |
179 | |
180 struct UCKeyStateRecord | |
181 { | |
182 ushort stateZeroCharData; | |
183 ushort stateZeroNextState; | |
184 ushort stateEntryCount; | |
185 ushort stateEntryFormat; | |
186 UInt32* stateEntryData; | |
187 } | |
188 | |
189 | |
190 struct UCKeyStateEntryTerminal | |
191 { | |
192 ushort curState; | |
193 ushort charData; | |
194 } | |
195 | |
196 | |
197 struct UCKeyStateEntryRange | |
198 { | |
199 ushort curStateStart; | |
200 ubyte curStateRange; | |
201 ubyte deltaMultiplier; | |
202 ushort charData; | |
203 ushort nextState; | |
204 } | |
205 | |
206 | |
207 struct UCKeyboardTypeHeader | |
208 { | |
209 uint keyboardTypeFirst; | |
210 uint keyboardTypeLast; | |
211 uint keyModifiersToTableNumOffset; | |
212 uint keyToCharTableIndexOffset; | |
213 uint keyStateRecordsIndexOffset; | |
214 uint keyStateTerminatorsOffset; | |
215 uint keySequenceDataIndexOffset; | |
216 } | |
217 | |
218 | |
219 struct UCKeyboardLayout | |
220 { | |
221 ushort keyLayoutHeaderFormat; | |
222 ushort keyLayoutDataVersion; | |
223 uint keyLayoutFeatureInfoOffset; | |
224 uint keyboardTypeCount; | |
225 UCKeyboardTypeHeader* keyboardTypeList; | |
226 } | |
227 | |
228 | |
229 struct UCKeyLayoutFeatureInfo | |
230 { | |
231 ushort keyLayoutFeatureInfoFormat; | |
232 ushort reserved; | |
233 uint maxOutputStringLength; | |
234 } | |
235 | |
236 | |
237 struct UCKeyModifiersToTableNum | |
238 { | |
239 ushort keyModifiersToTableNumFormat; | |
240 ushort defaultTableNum; | |
241 uint modifiersCount; | |
242 char* tableNum; | |
243 } | |
244 | |
245 | |
246 struct UCKeyToCharTableIndex | |
247 { | |
248 ushort keyToCharTableIndexFormat; | |
249 ushort keyToCharTableSize; | |
250 uint keyToCharTableCount; | |
251 UInt32* keyToCharTableOffsets; | |
252 } | |
253 | |
254 | |
255 struct UCKeyStateRecordsIndex | |
256 { | |
257 ushort keyStateRecordsIndexFormat; | |
258 ushort keyStateRecordCount; | |
259 UInt32* keyStateRecordOffsets; | |
260 } | |
261 | |
262 | |
263 struct UCKeyStateTerminators | |
264 { | |
265 ushort keyStateTerminatorsFormat; | |
266 ushort keyStateTerminatorCount; | |
267 UCKeyCharSeq* keyStateTerminators; | |
268 } | |
269 | |
270 | |
271 struct UCKeySequenceDataIndex | |
272 { | |
273 ushort keySequenceDataIndexFormat; | |
274 ushort charSequenceCount; | |
275 UInt16* charSequenceOffsets; | |
276 } | |
277 | |
278 extern (C) | |
279 { | |
280 IndexToUCStringUPP NewIndexToUCStringUPP (IndexToUCStringProcPtr userRoutine); | |
281 void DisposeIndexToUCStringUPP (IndexToUCStringUPP userUPP); | |
282 ubyte InvokeIndexToUCStringUPP (uint index, void* listDataPtr, void* refcon, CFStringRef* outString, UCTypeSelectOptions* tsOptions, IndexToUCStringUPP userUPP); | |
283 int UCKeyTranslate (UCKeyboardLayout* keyLayoutPtr, ushort virtualKeyCode, ushort keyAction, uint modifierKeyState, uint keyboardType, uint keyTranslateOptions, UInt32* deadKeyState, uint maxStringLength, UniCharCount* actualStringLength, wchar* unicodeString); | |
284 int UCCreateCollator (LocaleRef locale, uint opVariant, uint options, CollatorRef* collatorRef); | |
285 int UCGetCollationKey (CollatorRef collatorRef, wchar* textPtr, uint textLength, uint maxKeySize, ItemCount* actualKeySize, UCCollationValue* collationKey); | |
286 int UCCompareCollationKeys (UCCollationValue* key1Ptr, uint key1Length, UCCollationValue* key2Ptr, uint key2Length, char* equivalent, SInt32* order); | |
287 int UCCompareText (CollatorRef collatorRef, wchar* text1Ptr, uint text1Length, wchar* text2Ptr, uint text2Length, char* equivalent, SInt32* order); | |
288 int UCDisposeCollator (CollatorRef* collatorRef); | |
289 int UCCompareTextDefault (uint options, wchar* text1Ptr, uint text1Length, wchar* text2Ptr, uint text2Length, char* equivalent, SInt32* order); | |
290 int UCCompareTextNoLocale (uint options, wchar* text1Ptr, uint text1Length, wchar* text2Ptr, uint text2Length, char* equivalent, SInt32* order); | |
291 int UCCreateTextBreakLocator (LocaleRef locale, uint opVariant, uint breakTypes, TextBreakLocatorRef* breakRef); | |
292 int UCFindTextBreak (TextBreakLocatorRef breakRef, uint breakType, uint options, wchar* textPtr, uint textLength, uint startOffset, UniCharArrayOffset* breakOffset); | |
293 int UCDisposeTextBreakLocator (TextBreakLocatorRef* breakRef); | |
294 int UCTypeSelectCreateSelector (LocaleRef locale, uint opVariant, uint options, UCTypeSelectRef* newSelector); | |
295 int UCTypeSelectFlushSelectorData (UCTypeSelectRef ref_); | |
296 int UCTypeSelectReleaseSelector (UCTypeSelectRef* ref_); | |
297 ubyte UCTypeSelectWouldResetBuffer (UCTypeSelectRef inRef, CFStringRef inText, double inEventTime); | |
298 int UCTypeSelectAddKeyToSelector (UCTypeSelectRef inRef, CFStringRef inText, double inEventTime, char* updateFlag); | |
299 int UCTypeSelectCompare (UCTypeSelectRef ref_, CFStringRef inText, UCTypeSelectCompareResult* result); | |
300 int UCTypeSelectFindItem (UCTypeSelectRef ref_, uint listSize, void* listDataPtr, void* refcon, IndexToUCStringUPP userUPP, UInt32* closestItem); | |
301 int UCTypeSelectWalkList (UCTypeSelectRef ref_, CFStringRef currSelect, ushort direction, uint listSize, void* listDataPtr, void* refcon, IndexToUCStringUPP userUPP, UInt32* closestItem); | |
302 } |