Mercurial > projects > dstep
view 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 |
line wrap: on
line source
/** * Copyright: Copyright (c) 2009 Jacob Carlborg. * Authors: Jacob Carlborg * Version: Initial created: Jul 21, 2009 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0) */ module dstep.coreservices.carboncore.UnicodeUtilities; //import dstep.AvailabilityMacros; import dstep.corefoundation.CFBase; import dstep.coreservices.carboncore.MacLocales; import dstep.coreservices.carboncore.MacTypes; import dstep.coreservices.carboncore.MixedMode; import dstep.coreservices.carboncore.TextCommon; import dstep.corefoundation.CFCharacterSet; import dstep.objc.bridge.TypeEncoding; struct OpaqueCollatorRef; struct OpaqueUCTypeSelectRef; struct OpaqueTextBreakLocatorRef; alias ushort UCKeyOutput; alias ushort UCKeyCharSeq; alias OpaqueCollatorRef* CollatorRef; alias uint UCCollateOptions; alias uint UCCollationValue; alias OpaqueUCTypeSelectRef* UCTypeSelectRef; alias int UCTypeSelectCompareResult; alias ushort UCTSWalkDirection; alias ushort UCTypeSelectOptions; alias IndexToUCStringProcPtr IndexToUCStringUPP; alias OpaqueTextBreakLocatorRef* TextBreakLocatorRef; alias uint UCTextBreakType; alias uint UCTextBreakOptions; extern (C) { alias ubyte function (uint, void*, void*, CFStringRef*, UCTypeSelectOptions*) IndexToUCStringProcPtr; } // This is needed otherwise the enums will fail compiling with gdc version (GNU) { private { const __kUnicodeCollationClass = getOSType!("ucol"); } } // This is needed otherwise the enums will fail compiling with gdc version (GNU) { private { const __kUnicodeTextBreakClass = getOSType!("ubrk"); } } enum { kUCKeyOutputStateIndexMask = 0x4000, kUCKeyOutputSequenceIndexMask = 0x8000, kUCKeyOutputTestForIndexMask = 0xC000, kUCKeyOutputGetIndexMask = 0x3FFF } enum { kUCKeyStateEntryTerminalFormat = 0x0001, kUCKeyStateEntryRangeFormat = 0x0002 } enum { kUCKeyLayoutHeaderFormat = 0x1002, kUCKeyLayoutFeatureInfoFormat = 0x2001, kUCKeyModifiersToTableNumFormat = 0x3001, kUCKeyToCharTableIndexFormat = 0x4001, kUCKeyStateRecordsIndexFormat = 0x5001, kUCKeyStateTerminatorsFormat = 0x6001, kUCKeySequenceDataIndexFormat = 0x7001 } enum { kUCKeyActionDown = 0, kUCKeyActionUp = 1, kUCKeyActionAutoKey = 2, kUCKeyActionDisplay = 3 } enum { kUCKeyTranslateNoDeadKeysBit = 0 } enum { kUCKeyTranslateNoDeadKeysMask = 1L << kUCKeyTranslateNoDeadKeysBit } enum { kUnicodeCollationClass = getOSType!("ucol") } enum { kUCCollateComposeInsensitiveMask = 1L << 1, kUCCollateWidthInsensitiveMask = 1L << 2, kUCCollateCaseInsensitiveMask = 1L << 3, kUCCollateDiacritInsensitiveMask = 1L << 4, kUCCollatePunctuationSignificantMask = 1L << 15, kUCCollateDigitsOverrideMask = 1L << 16, kUCCollateDigitsAsNumberMask = 1L << 17 } enum { kUCCollateStandardOptions = kUCCollateComposeInsensitiveMask | kUCCollateWidthInsensitiveMask } enum { kUCCollateTypeHFSExtended = 1 } enum { kUCCollateTypeSourceMask = 0x000000FF, kUCCollateTypeShiftBits = 24 } enum { kUCCollateTypeMask = kUCCollateTypeSourceMask << kUCCollateTypeShiftBits } enum { kUCTSDirectionNext = 0, kUCTSDirectionPrevious = 1 } enum { kUCTSOptionsNoneMask = 0, kUCTSOptionsReleaseStringMask = 1, kUCTSOptionsDataIsOrderedMask = 2 } enum { kUCTypeSelectMaxListSize = cast(uint)0xFFFFFFFF } enum { kUnicodeTextBreakClass = getOSType!("ubrk") } enum { kUCTextBreakCharMask = 1L << 0, kUCTextBreakClusterMask = 1L << 2, kUCTextBreakWordMask = 1L << 4, kUCTextBreakLineMask = 1L << 6, kUCTextBreakParagraphMask = 1L << 8 } enum { kUCTextBreakLeadingEdgeMask = 1L << 0, kUCTextBreakGoBackwardsMask = 1L << 1, kUCTextBreakIterateMask = 1L << 2 } struct UCKeyStateRecord { ushort stateZeroCharData; ushort stateZeroNextState; ushort stateEntryCount; ushort stateEntryFormat; UInt32* stateEntryData; } struct UCKeyStateEntryTerminal { ushort curState; ushort charData; } struct UCKeyStateEntryRange { ushort curStateStart; ubyte curStateRange; ubyte deltaMultiplier; ushort charData; ushort nextState; } struct UCKeyboardTypeHeader { uint keyboardTypeFirst; uint keyboardTypeLast; uint keyModifiersToTableNumOffset; uint keyToCharTableIndexOffset; uint keyStateRecordsIndexOffset; uint keyStateTerminatorsOffset; uint keySequenceDataIndexOffset; } struct UCKeyboardLayout { ushort keyLayoutHeaderFormat; ushort keyLayoutDataVersion; uint keyLayoutFeatureInfoOffset; uint keyboardTypeCount; UCKeyboardTypeHeader* keyboardTypeList; } struct UCKeyLayoutFeatureInfo { ushort keyLayoutFeatureInfoFormat; ushort reserved; uint maxOutputStringLength; } struct UCKeyModifiersToTableNum { ushort keyModifiersToTableNumFormat; ushort defaultTableNum; uint modifiersCount; char* tableNum; } struct UCKeyToCharTableIndex { ushort keyToCharTableIndexFormat; ushort keyToCharTableSize; uint keyToCharTableCount; UInt32* keyToCharTableOffsets; } struct UCKeyStateRecordsIndex { ushort keyStateRecordsIndexFormat; ushort keyStateRecordCount; UInt32* keyStateRecordOffsets; } struct UCKeyStateTerminators { ushort keyStateTerminatorsFormat; ushort keyStateTerminatorCount; UCKeyCharSeq* keyStateTerminators; } struct UCKeySequenceDataIndex { ushort keySequenceDataIndexFormat; ushort charSequenceCount; UInt16* charSequenceOffsets; } extern (C) { IndexToUCStringUPP NewIndexToUCStringUPP (IndexToUCStringProcPtr userRoutine); void DisposeIndexToUCStringUPP (IndexToUCStringUPP userUPP); ubyte InvokeIndexToUCStringUPP (uint index, void* listDataPtr, void* refcon, CFStringRef* outString, UCTypeSelectOptions* tsOptions, IndexToUCStringUPP userUPP); int UCKeyTranslate (UCKeyboardLayout* keyLayoutPtr, ushort virtualKeyCode, ushort keyAction, uint modifierKeyState, uint keyboardType, uint keyTranslateOptions, UInt32* deadKeyState, uint maxStringLength, UniCharCount* actualStringLength, wchar* unicodeString); int UCCreateCollator (LocaleRef locale, uint opVariant, uint options, CollatorRef* collatorRef); int UCGetCollationKey (CollatorRef collatorRef, wchar* textPtr, uint textLength, uint maxKeySize, ItemCount* actualKeySize, UCCollationValue* collationKey); int UCCompareCollationKeys (UCCollationValue* key1Ptr, uint key1Length, UCCollationValue* key2Ptr, uint key2Length, char* equivalent, SInt32* order); int UCCompareText (CollatorRef collatorRef, wchar* text1Ptr, uint text1Length, wchar* text2Ptr, uint text2Length, char* equivalent, SInt32* order); int UCDisposeCollator (CollatorRef* collatorRef); int UCCompareTextDefault (uint options, wchar* text1Ptr, uint text1Length, wchar* text2Ptr, uint text2Length, char* equivalent, SInt32* order); int UCCompareTextNoLocale (uint options, wchar* text1Ptr, uint text1Length, wchar* text2Ptr, uint text2Length, char* equivalent, SInt32* order); int UCCreateTextBreakLocator (LocaleRef locale, uint opVariant, uint breakTypes, TextBreakLocatorRef* breakRef); int UCFindTextBreak (TextBreakLocatorRef breakRef, uint breakType, uint options, wchar* textPtr, uint textLength, uint startOffset, UniCharArrayOffset* breakOffset); int UCDisposeTextBreakLocator (TextBreakLocatorRef* breakRef); int UCTypeSelectCreateSelector (LocaleRef locale, uint opVariant, uint options, UCTypeSelectRef* newSelector); int UCTypeSelectFlushSelectorData (UCTypeSelectRef ref_); int UCTypeSelectReleaseSelector (UCTypeSelectRef* ref_); ubyte UCTypeSelectWouldResetBuffer (UCTypeSelectRef inRef, CFStringRef inText, double inEventTime); int UCTypeSelectAddKeyToSelector (UCTypeSelectRef inRef, CFStringRef inText, double inEventTime, char* updateFlag); int UCTypeSelectCompare (UCTypeSelectRef ref_, CFStringRef inText, UCTypeSelectCompareResult* result); int UCTypeSelectFindItem (UCTypeSelectRef ref_, uint listSize, void* listDataPtr, void* refcon, IndexToUCStringUPP userUPP, UInt32* closestItem); int UCTypeSelectWalkList (UCTypeSelectRef ref_, CFStringRef currSelect, ushort direction, uint listSize, void* listDataPtr, void* refcon, IndexToUCStringUPP userUPP, UInt32* closestItem); }