changeset 155:e91dcbf77cc7

Fixes runtime problems with dmd and ldc. Changed a couple of floats to CGFloat
author Jacob Carlborg <doob@me.com>
date Mon, 06 Jul 2009 21:17:03 +0200
parents 535243e6d16a
children 969e7de37c3d
files dsss.conf dwt/graphics/LineAttributes.d dwt/graphics/Pattern.d dwt/graphics/TextLayout.d dwt/internal/cocoa/NSString.d dwt/internal/objc/runtime.d dwt/widgets/Control.d dwt/widgets/Tree.d
diffstat 8 files changed, 45 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/dsss.conf	Sat Jun 13 00:25:05 2009 +0200
+++ b/dsss.conf	Mon Jul 06 21:17:03 2009 +0200
@@ -1,14 +1,14 @@
 [dwt]
 
 version (GNU){
-    buildflags += -Jres -framework Cocoa -framework Carbon
+    buildflags += -Jres -framework Cocoa -framework Carbon -L-lxpcomglue -L-lstdc++
 }
 
 version (LDC){
-    buildflags += -Jres -L-framework=Cocoa -L-framework=Carbon
+    buildflags += -Jres -L=-framework=Cocoa -L=-framework=Carbon -L=-lxpcomglue -L=-lstdc++
 	exclude=dwt/browser
 }
 
-version (DMD){
-    buildflags += -Jres -L-framework -LCocoa -L-framework -LCarbon -version=darwin
+version (DigitalMars){
+	buildflags += -Jres -L-framework -LCocoa -L-framework -LCarbon -L-lxpcomglue -L-lstdc++
 }
\ No newline at end of file
--- a/dwt/graphics/LineAttributes.d	Sat Jun 13 00:25:05 2009 +0200
+++ b/dwt/graphics/LineAttributes.d	Mon Jul 06 21:17:03 2009 +0200
@@ -16,6 +16,7 @@
 import dwt.DWT;
 
 import dwt.dwthelper.utils;
+import dwt.internal.c.Carbon;
 
 /**
  * <code>LineAttributes</code> defines a set of line attributes that
@@ -37,7 +38,7 @@
     /**
      * The line width.
      */
-    public float width;
+    public CGFloat width;
 
     /**
      * The line style.
@@ -72,24 +73,24 @@
     /**
      * The line dash style for DWT.LINE_CUSTOM.
      */
-    public float[] dash;
+    public CGFloat[] dash;
 
     /**
      * The line dash style offset for DWT.LINE_CUSTOM.
      */
-    public float dashOffset;
+    public CGFloat dashOffset;
 
     /**
      * The line miter limit.
      */
-    public float miterLimit;
+    public CGFloat miterLimit;
 
 /** 
  * Create a new line attributes with the specified line width.
  *
  * @param width the line width
  */
-public this(float width) {
+public this(CGFloat width) {
     this(width, DWT.CAP_FLAT, DWT.JOIN_MITER, DWT.LINE_SOLID, null, 0, 10);
 }
     
@@ -100,7 +101,7 @@
  * @param cap the line cap style
  * @param join the line join style
  */
-public this(float width, int cap, int join) {
+public this(CGFloat width, int cap, int join) {
     this(width, cap, join, DWT.LINE_SOLID, null, 0, 10);
 }
 
@@ -115,7 +116,7 @@
  * @param dashOffset the line dash style offset
  * @param miterLimit the line miter limit
  */
-public this(float width, int cap, int join, int style, float[] dash, float dashOffset, float miterLimit) {
+public this(CGFloat width, int cap, int join, int style, CGFloat[] dash, CGFloat dashOffset, CGFloat miterLimit) {
     this.width = width;
     this.cap = cap;
     this.join = join;
--- a/dwt/graphics/Pattern.d	Sat Jun 13 00:25:05 2009 +0200
+++ b/dwt/graphics/Pattern.d	Mon Jul 06 21:17:03 2009 +0200
@@ -59,7 +59,7 @@
     NSGradient gradient;
     NSPoint pt1, pt2;
     Image image;
-    float[] color1, color2;
+    CGFloat[] color1, color2;
     int alpha1, alpha2;
 
 /**
--- a/dwt/graphics/TextLayout.d	Sat Jun 13 00:25:05 2009 +0200
+++ b/dwt/graphics/TextLayout.d	Mon Jul 06 21:17:03 2009 +0200
@@ -405,7 +405,7 @@
     NSAutoreleasePool pool = gc.checkGC(GC.CLIPPING | GC.TRANSFORM | GC.FOREGROUND);
     try {
         gc.handle.saveGraphicsState();
-        float[] fg = gc.data.foreground;
+        Carbon.CGFloat[] fg = gc.data.foreground;
         NSColor foreground = NSColor.colorWithDeviceRed(fg[0], fg[1], fg[2], fg[3]);
         NSPoint pt = NSPoint();
         pt.x = x;
@@ -470,7 +470,7 @@
                                 float baseline = layoutManager.typesetter().baselineOffsetInLayoutManager(layoutManager, lineStart);
                                 float underlineX = pt.x + rect.x;
                                 float underlineY = pt.y + rect.y + rect.height - baseline;
-                                float[] color = null;
+                                Carbon.CGFloat[] color = null;
                                 if (style.underlineColor !is null) color = style.underlineColor.handle;
                                 if (color is null && style.foreground !is null) color = style.foreground.handle;
                                 if (color !is null) {
@@ -482,7 +482,7 @@
                                     path.setLineWidth(2f);
                                     path.setLineCapStyle(OS.NSRoundLineCapStyle);
                                     path.setLineJoinStyle(OS.NSRoundLineJoinStyle);
-                                    path.setLineDash([1f, 3f].ptr, 2, cast(Carbon.CGFloat) 0);
+                                    path.setLineDash([1.0, 3.0].ptr, 2, cast(Carbon.CGFloat) 0);
                                     point.x = underlineX;
                                     point.y = underlineY + 0.5f;
                                     path.moveToPoint(point);
--- a/dwt/internal/cocoa/NSString.d	Sat Jun 13 00:25:05 2009 +0200
+++ b/dwt/internal/cocoa/NSString.d	Mon Jul 06 21:17:03 2009 +0200
@@ -36,13 +36,13 @@
 }
 
 public String getString() {
-    wchar[] buffer = new wchar[lengthOfCharacters];
+    wchar[] buffer = new wchar[length()];
     getCharacters(buffer.ptr);
     return dwt.dwthelper.utils.toString(buffer);
 }
 
 public wchar[] getString16() {
-    wchar[] buffer = new wchar[lengthOfCharacters];
+    wchar[] buffer = new wchar[length()];
     getCharacters(buffer.ptr);
     return buffer;
 }
--- a/dwt/internal/objc/runtime.d	Sat Jun 13 00:25:05 2009 +0200
+++ b/dwt/internal/objc/runtime.d	Mon Jul 06 21:17:03 2009 +0200
@@ -34,6 +34,9 @@
 else version (X86_64)
     const int STRUCT_SIZE_LIMIT = 16;
 
+else version (PPC64)
+    const int STRUCT_SIZE_LIMIT = 16;
+
 struct objc_object
 {
     Class isa;
@@ -189,38 +192,50 @@
 
 id objc_msgSend (ARGS...) (id theReceiver, SEL theSelector, ARGS args)
 {
-    return (cast(id (*)(id, SEL, ARGS...))&dwt.internal.objc.bindings.objc_msgSend)(theReceiver, theSelector, args);
+    alias extern (C) id function (id, SEL, ARGS) fp;
+    return (cast(fp)&dwt.internal.objc.bindings.objc_msgSend)(theReceiver, theSelector, args);
 }
 
 void objc_msgSend_struct (T, ARGS...) (T* result, id theReceiver, SEL theSelector, ARGS args)
 {
-    result = cast(T*) dwt.internal.objc.bindings.objc_msgSend(theReceiver, theSelector, args);
+    alias extern (C) T* function (id, SEL, ARGS) fp;
+    result = (cast(fp)&dwt.internal.objc.bindings.objc_msgSend)(theReceiver, theSelector, args);
+    //result = cast(T*) dwt.internal.objc.bindings.objc_msgSend(theReceiver, theSelector, args);
 }
 
 void objc_msgSend_stret (T, ARGS...) (T* stretAddr, id theReceiver, SEL theSelector, ARGS args)
 {    
     if (T.sizeof > STRUCT_SIZE_LIMIT)
-		(cast(void (*)(T *, id, SEL, ARGS...))&dwt.internal.objc.bindings.objc_msgSend_stret)(stretAddr, theReceiver, theSelector, args);
+    {
+        alias extern (C) void function (T *, id, SEL, ARGS) fp;
+        (cast(fp)&dwt.internal.objc.bindings.objc_msgSend_stret)(stretAddr, theReceiver, theSelector, args);
+    }
     
     else
-        *stretAddr = (*cast(T (*)(id, SEL, ARGS...))&dwt.internal.objc.bindings.objc_msgSend)(theReceiver, theSelector, args);
+    {
+        alias extern (C) T function (id, SEL, ARGS) fp;
+        *stretAddr = (*cast(fp)&dwt.internal.objc.bindings.objc_msgSend)(theReceiver, theSelector, args);
+    }
 }
 
 id objc_msgSendSuper (ARGS...) (objc_super* superr, SEL op, ARGS args)
 {
-    return (cast(id (*)(objc_super*, SEL, ARGS...))&dwt.internal.objc.bindings.objc_msgSendSuper)(superr, op, args);
+    alias extern (C) id function (objc_super*, SEL, ARGS) fp;
+    return (cast(fp)&dwt.internal.objc.bindings.objc_msgSendSuper)(superr, op, args);
 }
 
 bool objc_msgSend_bool (ARGS...) (id theReceiver, SEL theSelector, ARGS args)
 {
-    return (cast(bool (*)(id, SEL, ARGS...))&dwt.internal.objc.bindings.objc_msgSend)(theReceiver, theSelector, args);
+    alias extern (C) bool function (id, SEL, ARGS) fp;
+    return (cast(fp)&dwt.internal.objc.bindings.objc_msgSend)(theReceiver, theSelector, args);
 }
 
 version (X86)
 {
     double objc_msgSend_fpret(ARGS...) (id self, SEL op, ARGS args)
     {
-        return (cast(double (*)(id, SEL, ARGS...))&dwt.internal.objc.bindings.objc_msgSend_fpret)(self, op, args);
+        alias extern (C) double function (id, SEL, ARGS) fp;
+        return (cast(fp)&dwt.internal.objc.bindings.objc_msgSend_fpret)(self, op, args);
     }
 }
 
@@ -228,6 +243,7 @@
 {
     double objc_msgSend_fpret(ARGS...) (id self, SEL op, ARGS args)
     {
-        return (cast(double (*)(id, SEL, ARGS...))&dwt.internal.objc.bindings.objc_msgSend)(self, op, args);
+        alias extern (C) double function (id, SEL, ARGS) fp;
+        return (cast(fp)&dwt.internal.objc.bindings.objc_msgSend)(self, op, args);
     }
 }
\ No newline at end of file
--- a/dwt/widgets/Control.d	Sat Jun 13 00:25:05 2009 +0200
+++ b/dwt/widgets/Control.d	Mon Jul 06 21:17:03 2009 +0200
@@ -2837,10 +2837,10 @@
     view.setNeedsDisplay(true);
 }
 
-void setForeground (float [] color) {
+void setForeground (Carbon.CGFloat [] color) {
 }
 
-void setForeground (int control, float [] color) {
+void setForeground (int control, Carbon.CGFloat [] color) {
 //  ControlFontStyleRec fontStyle = new ControlFontStyleRec ();
 //  OS.GetControlData (control, cast(short) OS.kControlEntireControl, OS.kControlFontStyleTag, ControlFontStyleRec.sizeof, fontStyle, null);
 //  if (color !is null) {
--- a/dwt/widgets/Tree.d	Sat Jun 13 00:25:05 2009 +0200
+++ b/dwt/widgets/Tree.d	Mon Jul 06 21:17:03 2009 +0200
@@ -1681,7 +1681,7 @@
     return (cast(TreeItem) display.getWidget (item)).itemCount !is 0;
 }
 
-int outlineView_numberOfChildrenOfItem (objc.id id, objc.SEL sel, objc.id outlineView, objc.id item) {
+NSInteger outlineView_numberOfChildrenOfItem (objc.id id, objc.SEL sel, objc.id outlineView, objc.id item) {
     if (item is null) return itemCount;
     return (cast(TreeItem) display.getWidget (item)).itemCount;
 }