diff 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
line wrap: on
line diff
--- a/dwt/internal/cocoa/OS.d	Tue Oct 07 12:56:18 2008 +0200
+++ b/dwt/internal/cocoa/OS.d	Fri Oct 10 12:29:48 2008 +0200
@@ -29,13 +29,14 @@
 static import dwt.internal.objc.appkit.NSAccessibility;
 static import dwt.internal.objc.appkit.NSAttributedString;
 static import dwt.internal.objc.appkit.NSGraphics;
-static import dwt.internal.objc.appkit.NSScreen;
 static import dwt.internal.objc.coregraphics.CGRemoteOperation;
 static import dwt.internal.objc.foundation.NSGeometry;
 static import dwt.internal.objc.foundation.NSHFSFileTypes;
 static import dwt.internal.objc.foundation.NSRunLoop;
 static import dwt.internal.objc.runtime;
 
+import mambo.io;
+
 private alias dwt.internal.objc.runtime.objc_object objc_object;
 
 struct ClassData
@@ -63,7 +64,7 @@
     static this ()
     {
         int[1] response;
-        OS.Gestalt(OS.gestaltSystemVersion, response);
+        OS.Gestalt(OS.gestaltSystemVersion, response.ptr);
         VERSION = response[0] & 0xffff;
         
         OS.sel_sendSelection = OS.sel_registerName("sendSelection");
@@ -79,6 +80,9 @@
             
         foreach (data ; selectorData)
             *data.var = sel_registerName(data.arg);
+        
+        OS.NSDefaultRunLoopMode = new NSString(OS.FuncNSDefaultRunLoopMode());
+        OS.NSBackgroundColorAttributeName = new NSString(OS.FuncNSBackgroundColorAttributeName());
     }
     
     //TODO - don't hard code
@@ -99,9 +103,49 @@
     public static const String sel_drawAtPoint_;
     public static const String sel_timerProc_1;
     
-    Object JNIGetObject(NSInteger globalRef)
+    private static Object[] globalRefs;
+    
+    static Object JNIGetObject (NSInteger globalRef)
+    {
+        println("OS->JNIGetObject->globalRef=", globalRef);
+        auto o = new Object;
+        o = cast(Object) globalRef;
+        return o;
+        //return globalRefs[globalRef - 1];
+    }
+    
+    static NSInteger NewGlobalRef (Object object)
+    {
+        globalRefs ~= object;
+        return globalRefs.length;
+    }
+    
+    static void DeleteGlobalRef (NSInteger globalRef)
     {
-        return cast(Object) globalRef;
+        globalRefs = globalRefs[0 .. remove!(Object)(globalRefs, globalRef - 1)];
+    }
+    
+    static size_t remove (T) (T[] arr, size_t index)
+    {
+        void exch (size_t p1, size_t p2)
+        {
+            T t = arr[p1];
+            arr[p1] = arr[p2];
+            arr[p2] = t;
+        }
+        
+        size_t cnt = 0;
+        
+        for (size_t pos = 0, len = arr.length; pos < len; ++pos)
+        {
+            if (pos == index)
+                ++cnt;
+            
+            else
+                exch(pos, pos - cnt);
+        }
+        
+        return arr.length - cnt;
     }
     
     alias dwt.internal.c.carboncore.Gestalt.Gestalt Gestalt;
@@ -142,6 +186,7 @@
     
     /** objc runtime */
     static alias dwt.internal.objc.runtime.objc_registerClassPair objc_registerClassPair;
+    alias dwt.internal.objc.runtime.class_addIvar class_addIvar;
     alias dwt.internal.objc.runtime.class_addMethod class_addMethod;
     alias dwt.internal.objc.runtime.objc_allocateClassPair objc_allocateClassPair;
     alias dwt.internal.objc.runtime.objc_getClass objc_getClass;
@@ -157,8 +202,8 @@
     
     version (X86)
         alias dwt.internal.objc.runtime.objc_msgSend_fpret objc_msgSend_fpret;
-        
-    alias dwt.internal.objc.runtime.drawRect_1CALLBACK drawRect_1CALLBACK;
+    
+    alias dwt.internal.objc.runtime.drawRect_CALLBACK drawRect_CALLBACK;
 
     /** Classes */
     public static /*const*/ id class_NSScanner;
@@ -14646,12 +14691,12 @@
     public static const int NSScrollerArrowsMinEnd = 1;
     public static const int NSScrollerArrowsNone = 2;
     public static const int NSScrollerDecrementArrow = 1;
-    public static const int NSScrollerDecrementLine = 4;
-    public static const int NSScrollerDecrementPage = 1;
+//    public static const int NSScrollerDecrementLine = 4;
+//    public static const int NSScrollerDecrementPage = 1;
     public static const int NSScrollerIncrementArrow = 0;
-    public static const int NSScrollerIncrementLine = 5;
-    public static const int NSScrollerIncrementPage = 3;
-    public static const int NSScrollerKnob = 2;
+//    public static const int NSScrollerIncrementLine = 5;
+//    public static const int NSScrollerIncrementPage = 3;
+//    public static const int NSScrollerKnob = 2;
     public static const int NSScrollerKnobSlot = 6;
     public static const int NSScrollerNoPart = 0;
     public static const int NSSearchFieldClearRecentsMenuItemTag = 1002;
@@ -15988,7 +16033,8 @@
 //  public static const native int NSAttachmentAttributeName();
 //  public static const native int NSAttributedStringBinding();
 //  public static const native int NSAuthorDocumentAttribute();
-    alias dwt.internal.objc.appkit.NSAttributedString.NSBackgroundColorAttributeName NSBackgroundColorAttributeName;
+    public static const NSString NSBackgroundColorAttributeName;
+    alias dwt.internal.objc.appkit.NSAttributedString.NSBackgroundColorAttributeName FuncNSBackgroundColorAttributeName;
 //  public static const native int NSBackgroundColorDocumentAttribute();
 //  public static const native int NSBadBitmapParametersException();
 //  public static const native int NSBadComparisonException();
@@ -16060,7 +16106,7 @@
 //  public static const native int NSDeviceIsPrinter();
 //  public static const native int NSDeviceIsScreen();
     alias dwt.internal.objc.appkit.NSGraphics.NSDeviceRGBColorSpace NSDeviceRGBColorSpace;
-    alias dwt.internal.objc.appkit.NSScreen.NSDeviceResolution NSDeviceResolution;
+    alias dwt.internal.objc.appkit.NSGraphics.NSDeviceResolution NSDeviceResolution;
 //  public static const native int NSDeviceSize();
 //  public static const native int NSDeviceWhiteColorSpace();
 //  public static const native int NSDirectoryFileType();
@@ -16590,7 +16636,8 @@
 //  public static const native int NSDecimalNumberExactnessException();
 //  public static const native int NSDecimalNumberOverflowException();
 //  public static const native int NSDecimalNumberUnderflowException();
-    alias dwt.internal.objc.foundation.NSRunLoop.NSDefaultRunLoopMode NSDefaultRunLoopMode;
+    public static const NSString NSDefaultRunLoopMode;
+    alias dwt.internal.objc.foundation.NSRunLoop.NSDefaultRunLoopMode FuncNSDefaultRunLoopMode;
 //  public static const native int NSDestinationInvalidException();
 //  public static const native int NSDidBecomeSingleThreadedNotification();
 //  public static const native int NSDistinctUnionOfArraysKeyValueOperator();