Mercurial > projects > dwt-mac
comparison dwt/internal/cocoa/OS.d @ 37:642f460a0908
Fixed a lot of compile errors, a "hello world" app compiles now
author | Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com> |
---|---|
date | Fri, 10 Oct 2008 12:29:48 +0200 |
parents | db5a898b2119 |
children | 198549365851 |
comparison
equal
deleted
inserted
replaced
36:db5a898b2119 | 37:642f460a0908 |
---|---|
27 import dwt.internal.cocoa.NSInteger; | 27 import dwt.internal.cocoa.NSInteger; |
28 import dwt.internal.cocoa.NSString; | 28 import dwt.internal.cocoa.NSString; |
29 static import dwt.internal.objc.appkit.NSAccessibility; | 29 static import dwt.internal.objc.appkit.NSAccessibility; |
30 static import dwt.internal.objc.appkit.NSAttributedString; | 30 static import dwt.internal.objc.appkit.NSAttributedString; |
31 static import dwt.internal.objc.appkit.NSGraphics; | 31 static import dwt.internal.objc.appkit.NSGraphics; |
32 static import dwt.internal.objc.appkit.NSScreen; | |
33 static import dwt.internal.objc.coregraphics.CGRemoteOperation; | 32 static import dwt.internal.objc.coregraphics.CGRemoteOperation; |
34 static import dwt.internal.objc.foundation.NSGeometry; | 33 static import dwt.internal.objc.foundation.NSGeometry; |
35 static import dwt.internal.objc.foundation.NSHFSFileTypes; | 34 static import dwt.internal.objc.foundation.NSHFSFileTypes; |
36 static import dwt.internal.objc.foundation.NSRunLoop; | 35 static import dwt.internal.objc.foundation.NSRunLoop; |
37 static import dwt.internal.objc.runtime; | 36 static import dwt.internal.objc.runtime; |
37 | |
38 import mambo.io; | |
38 | 39 |
39 private alias dwt.internal.objc.runtime.objc_object objc_object; | 40 private alias dwt.internal.objc.runtime.objc_object objc_object; |
40 | 41 |
41 struct ClassData | 42 struct ClassData |
42 { | 43 { |
61 public static const int VERSION; | 62 public static const int VERSION; |
62 | 63 |
63 static this () | 64 static this () |
64 { | 65 { |
65 int[1] response; | 66 int[1] response; |
66 OS.Gestalt(OS.gestaltSystemVersion, response); | 67 OS.Gestalt(OS.gestaltSystemVersion, response.ptr); |
67 VERSION = response[0] & 0xffff; | 68 VERSION = response[0] & 0xffff; |
68 | 69 |
69 OS.sel_sendSelection = OS.sel_registerName("sendSelection"); | 70 OS.sel_sendSelection = OS.sel_registerName("sendSelection"); |
70 OS.sel_sendDoubleSelection = OS.sel_registerName("sendDoubleSelection"); | 71 OS.sel_sendDoubleSelection = OS.sel_registerName("sendDoubleSelection"); |
71 OS.sel_sendArrowSelection = OS.sel_registerName("sendArrowSelection"); | 72 OS.sel_sendArrowSelection = OS.sel_registerName("sendArrowSelection"); |
77 foreach (data ; classesData) | 78 foreach (data ; classesData) |
78 *data.var = objc_getClass(data.arg); | 79 *data.var = objc_getClass(data.arg); |
79 | 80 |
80 foreach (data ; selectorData) | 81 foreach (data ; selectorData) |
81 *data.var = sel_registerName(data.arg); | 82 *data.var = sel_registerName(data.arg); |
83 | |
84 OS.NSDefaultRunLoopMode = new NSString(OS.FuncNSDefaultRunLoopMode()); | |
85 OS.NSBackgroundColorAttributeName = new NSString(OS.FuncNSBackgroundColorAttributeName()); | |
82 } | 86 } |
83 | 87 |
84 //TODO - don't hard code | 88 //TODO - don't hard code |
85 public static const size_t PTR_SIZEOF = (void*).sizeof; | 89 public static const size_t PTR_SIZEOF = (void*).sizeof; |
86 | 90 |
97 public static const String sel_sendVerticalSelection; | 101 public static const String sel_sendVerticalSelection; |
98 public static const String sel_sendHorizontalSelection; | 102 public static const String sel_sendHorizontalSelection; |
99 public static const String sel_drawAtPoint_; | 103 public static const String sel_drawAtPoint_; |
100 public static const String sel_timerProc_1; | 104 public static const String sel_timerProc_1; |
101 | 105 |
102 Object JNIGetObject(NSInteger globalRef) | 106 private static Object[] globalRefs; |
107 | |
108 static Object JNIGetObject (NSInteger globalRef) | |
103 { | 109 { |
104 return cast(Object) globalRef; | 110 println("OS->JNIGetObject->globalRef=", globalRef); |
111 auto o = new Object; | |
112 o = cast(Object) globalRef; | |
113 return o; | |
114 //return globalRefs[globalRef - 1]; | |
115 } | |
116 | |
117 static NSInteger NewGlobalRef (Object object) | |
118 { | |
119 globalRefs ~= object; | |
120 return globalRefs.length; | |
121 } | |
122 | |
123 static void DeleteGlobalRef (NSInteger globalRef) | |
124 { | |
125 globalRefs = globalRefs[0 .. remove!(Object)(globalRefs, globalRef - 1)]; | |
126 } | |
127 | |
128 static size_t remove (T) (T[] arr, size_t index) | |
129 { | |
130 void exch (size_t p1, size_t p2) | |
131 { | |
132 T t = arr[p1]; | |
133 arr[p1] = arr[p2]; | |
134 arr[p2] = t; | |
135 } | |
136 | |
137 size_t cnt = 0; | |
138 | |
139 for (size_t pos = 0, len = arr.length; pos < len; ++pos) | |
140 { | |
141 if (pos == index) | |
142 ++cnt; | |
143 | |
144 else | |
145 exch(pos, pos - cnt); | |
146 } | |
147 | |
148 return arr.length - cnt; | |
105 } | 149 } |
106 | 150 |
107 alias dwt.internal.c.carboncore.Gestalt.Gestalt Gestalt; | 151 alias dwt.internal.c.carboncore.Gestalt.Gestalt Gestalt; |
108 alias dwt.internal.c.hiservices.Processes.GetCurrentProcess GetCurrentProcess; | 152 alias dwt.internal.c.hiservices.Processes.GetCurrentProcess GetCurrentProcess; |
109 alias dwt.internal.c.hiservices.Processes.SetFrontProcess SetFrontProcess; | 153 alias dwt.internal.c.hiservices.Processes.SetFrontProcess SetFrontProcess; |
140 public static const int kQDParseRegionFromTopLeft = kQDParseRegionFromTop | kQDParseRegionFromLeft; | 184 public static const int kQDParseRegionFromTopLeft = kQDParseRegionFromTop | kQDParseRegionFromLeft; |
141 public static const int kQDRegionToRectsMsgParse = 2; | 185 public static const int kQDRegionToRectsMsgParse = 2; |
142 | 186 |
143 /** objc runtime */ | 187 /** objc runtime */ |
144 static alias dwt.internal.objc.runtime.objc_registerClassPair objc_registerClassPair; | 188 static alias dwt.internal.objc.runtime.objc_registerClassPair objc_registerClassPair; |
189 alias dwt.internal.objc.runtime.class_addIvar class_addIvar; | |
145 alias dwt.internal.objc.runtime.class_addMethod class_addMethod; | 190 alias dwt.internal.objc.runtime.class_addMethod class_addMethod; |
146 alias dwt.internal.objc.runtime.objc_allocateClassPair objc_allocateClassPair; | 191 alias dwt.internal.objc.runtime.objc_allocateClassPair objc_allocateClassPair; |
147 alias dwt.internal.objc.runtime.objc_getClass objc_getClass; | 192 alias dwt.internal.objc.runtime.objc_getClass objc_getClass; |
148 alias dwt.internal.objc.runtime.objc_lookUpClass objc_lookUpClass; | 193 alias dwt.internal.objc.runtime.objc_lookUpClass objc_lookUpClass; |
149 alias dwt.internal.objc.runtime.object_getClassName object_getClassName; | 194 alias dwt.internal.objc.runtime.object_getClassName object_getClassName; |
155 alias dwt.internal.objc.runtime.objc_msgSend_stret objc_msgSend_stret; | 200 alias dwt.internal.objc.runtime.objc_msgSend_stret objc_msgSend_stret; |
156 alias dwt.internal.objc.runtime.objc_msgSendSuper objc_msgSendSuper; | 201 alias dwt.internal.objc.runtime.objc_msgSendSuper objc_msgSendSuper; |
157 | 202 |
158 version (X86) | 203 version (X86) |
159 alias dwt.internal.objc.runtime.objc_msgSend_fpret objc_msgSend_fpret; | 204 alias dwt.internal.objc.runtime.objc_msgSend_fpret objc_msgSend_fpret; |
160 | 205 |
161 alias dwt.internal.objc.runtime.drawRect_1CALLBACK drawRect_1CALLBACK; | 206 alias dwt.internal.objc.runtime.drawRect_CALLBACK drawRect_CALLBACK; |
162 | 207 |
163 /** Classes */ | 208 /** Classes */ |
164 public static /*const*/ id class_NSScanner; | 209 public static /*const*/ id class_NSScanner; |
165 public static /*const*/ id class_NSCIImageRep; | 210 public static /*const*/ id class_NSCIImageRep; |
166 public static /*const*/ id class_NSPathControl; | 211 public static /*const*/ id class_NSPathControl; |
14644 public static const int NSScrollerArrowsDefaultSetting = 0; | 14689 public static const int NSScrollerArrowsDefaultSetting = 0; |
14645 public static const int NSScrollerArrowsMaxEnd = 0; | 14690 public static const int NSScrollerArrowsMaxEnd = 0; |
14646 public static const int NSScrollerArrowsMinEnd = 1; | 14691 public static const int NSScrollerArrowsMinEnd = 1; |
14647 public static const int NSScrollerArrowsNone = 2; | 14692 public static const int NSScrollerArrowsNone = 2; |
14648 public static const int NSScrollerDecrementArrow = 1; | 14693 public static const int NSScrollerDecrementArrow = 1; |
14649 public static const int NSScrollerDecrementLine = 4; | 14694 // public static const int NSScrollerDecrementLine = 4; |
14650 public static const int NSScrollerDecrementPage = 1; | 14695 // public static const int NSScrollerDecrementPage = 1; |
14651 public static const int NSScrollerIncrementArrow = 0; | 14696 public static const int NSScrollerIncrementArrow = 0; |
14652 public static const int NSScrollerIncrementLine = 5; | 14697 // public static const int NSScrollerIncrementLine = 5; |
14653 public static const int NSScrollerIncrementPage = 3; | 14698 // public static const int NSScrollerIncrementPage = 3; |
14654 public static const int NSScrollerKnob = 2; | 14699 // public static const int NSScrollerKnob = 2; |
14655 public static const int NSScrollerKnobSlot = 6; | 14700 public static const int NSScrollerKnobSlot = 6; |
14656 public static const int NSScrollerNoPart = 0; | 14701 public static const int NSScrollerNoPart = 0; |
14657 public static const int NSSearchFieldClearRecentsMenuItemTag = 1002; | 14702 public static const int NSSearchFieldClearRecentsMenuItemTag = 1002; |
14658 public static const int NSSearchFieldNoRecentsMenuItemTag = 1003; | 14703 public static const int NSSearchFieldNoRecentsMenuItemTag = 1003; |
14659 public static const int NSSearchFieldRecentsMenuItemTag = 1001; | 14704 public static const int NSSearchFieldRecentsMenuItemTag = 1001; |
15986 // public static const native int NSApplicationWillUpdateNotification(); | 16031 // public static const native int NSApplicationWillUpdateNotification(); |
15987 // public static const native int NSArgumentBinding(); | 16032 // public static const native int NSArgumentBinding(); |
15988 // public static const native int NSAttachmentAttributeName(); | 16033 // public static const native int NSAttachmentAttributeName(); |
15989 // public static const native int NSAttributedStringBinding(); | 16034 // public static const native int NSAttributedStringBinding(); |
15990 // public static const native int NSAuthorDocumentAttribute(); | 16035 // public static const native int NSAuthorDocumentAttribute(); |
15991 alias dwt.internal.objc.appkit.NSAttributedString.NSBackgroundColorAttributeName NSBackgroundColorAttributeName; | 16036 public static const NSString NSBackgroundColorAttributeName; |
16037 alias dwt.internal.objc.appkit.NSAttributedString.NSBackgroundColorAttributeName FuncNSBackgroundColorAttributeName; | |
15992 // public static const native int NSBackgroundColorDocumentAttribute(); | 16038 // public static const native int NSBackgroundColorDocumentAttribute(); |
15993 // public static const native int NSBadBitmapParametersException(); | 16039 // public static const native int NSBadBitmapParametersException(); |
15994 // public static const native int NSBadComparisonException(); | 16040 // public static const native int NSBadComparisonException(); |
15995 // public static const native int NSBadRTFColorTableException(); | 16041 // public static const native int NSBadRTFColorTableException(); |
15996 // public static const native int NSBadRTFDirectiveException(); | 16042 // public static const native int NSBadRTFDirectiveException(); |
16058 // public static const native int NSDeviceCMYKColorSpace(); | 16104 // public static const native int NSDeviceCMYKColorSpace(); |
16059 // public static const native int NSDeviceColorSpaceName(); | 16105 // public static const native int NSDeviceColorSpaceName(); |
16060 // public static const native int NSDeviceIsPrinter(); | 16106 // public static const native int NSDeviceIsPrinter(); |
16061 // public static const native int NSDeviceIsScreen(); | 16107 // public static const native int NSDeviceIsScreen(); |
16062 alias dwt.internal.objc.appkit.NSGraphics.NSDeviceRGBColorSpace NSDeviceRGBColorSpace; | 16108 alias dwt.internal.objc.appkit.NSGraphics.NSDeviceRGBColorSpace NSDeviceRGBColorSpace; |
16063 alias dwt.internal.objc.appkit.NSScreen.NSDeviceResolution NSDeviceResolution; | 16109 alias dwt.internal.objc.appkit.NSGraphics.NSDeviceResolution NSDeviceResolution; |
16064 // public static const native int NSDeviceSize(); | 16110 // public static const native int NSDeviceSize(); |
16065 // public static const native int NSDeviceWhiteColorSpace(); | 16111 // public static const native int NSDeviceWhiteColorSpace(); |
16066 // public static const native int NSDirectoryFileType(); | 16112 // public static const native int NSDirectoryFileType(); |
16067 // public static const native int NSDisplayNameBindingOption(); | 16113 // public static const native int NSDisplayNameBindingOption(); |
16068 // public static const native int NSDisplayPatternBindingOption(); | 16114 // public static const native int NSDisplayPatternBindingOption(); |
16588 // public static const native int NSDebugEnabled(); | 16634 // public static const native int NSDebugEnabled(); |
16589 // public static const native int NSDecimalNumberDivideByZeroException(); | 16635 // public static const native int NSDecimalNumberDivideByZeroException(); |
16590 // public static const native int NSDecimalNumberExactnessException(); | 16636 // public static const native int NSDecimalNumberExactnessException(); |
16591 // public static const native int NSDecimalNumberOverflowException(); | 16637 // public static const native int NSDecimalNumberOverflowException(); |
16592 // public static const native int NSDecimalNumberUnderflowException(); | 16638 // public static const native int NSDecimalNumberUnderflowException(); |
16593 alias dwt.internal.objc.foundation.NSRunLoop.NSDefaultRunLoopMode NSDefaultRunLoopMode; | 16639 public static const NSString NSDefaultRunLoopMode; |
16640 alias dwt.internal.objc.foundation.NSRunLoop.NSDefaultRunLoopMode FuncNSDefaultRunLoopMode; | |
16594 // public static const native int NSDestinationInvalidException(); | 16641 // public static const native int NSDestinationInvalidException(); |
16595 // public static const native int NSDidBecomeSingleThreadedNotification(); | 16642 // public static const native int NSDidBecomeSingleThreadedNotification(); |
16596 // public static const native int NSDistinctUnionOfArraysKeyValueOperator(); | 16643 // public static const native int NSDistinctUnionOfArraysKeyValueOperator(); |
16597 // public static const native int NSDistinctUnionOfObjectsKeyValueOperator(); | 16644 // public static const native int NSDistinctUnionOfObjectsKeyValueOperator(); |
16598 // public static const native int NSDistinctUnionOfSetsKeyValueOperator(); | 16645 // public static const native int NSDistinctUnionOfSetsKeyValueOperator(); |