diff dwt/internal/cocoa/NSValue.d @ 0:380af2bdd8e5

Upload of whole dwt tree
author Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
date Sat, 09 Aug 2008 17:00:02 +0200
parents
children 8b48be5454ce
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSValue.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,146 @@
+/*******************************************************************************
+ * Copyright (c) 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     
+ * Port to the D Programming language:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSValue;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSPoint;
+import dwt.internal.cocoa.NSRange;
+import dwt.internal.cocoa.NSRect;
+import dwt.internal.cocoa.NSSize;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSValue : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public void getValue (void* value)
+    {
+        OS.objc_msgSend(this.id, OS.sel_getValue_1, value);
+    }
+
+    public id initWithBytes (/*const*/void* value, /*const char* */byte* type)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithBytes_1objCType_1, value, type);
+        return result !is null ? new id(result) : null;
+    }
+
+    public bool isEqualToValue (NSValue value)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isEqualToValue_1, value !is null ? value.id : null) !is null;
+    }
+
+    public id nonretainedObjectValue ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_nonretainedObjectValue);
+        return result !is null ? new id(result) : null;
+    }
+
+    public /*const char* */byte* objCType ()
+    {
+        return cast(/*const char* */byte*) OS.objc_msgSend(this.id, OS.sel_objCType);
+    }
+
+    public NSPoint pointValue ()
+    {
+        NSPoint result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_pointValue);
+        return result;
+    }
+
+    public void* pointerValue ()
+    {
+        return cast(void*) OS.objc_msgSend(this.id, OS.sel_pointerValue);
+    }
+
+    public NSRange rangeValue ()
+    {
+        NSRange result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_rangeValue);
+        return result;
+    }
+
+    public NSRect rectValue ()
+    {
+        NSRect result;
+        OS.objc_msgSend_stret(result, this.id, OS.sel_rectValue);
+        return result;
+    }
+
+    public NSSize sizeValue ()
+    {
+        NSSize result;
+        OS.objc_msgSend_struct(result, this.id, OS.sel_sizeValue);
+        return result;
+    }
+
+    public static NSValue value (/*const*/void* value, /*const char* */byte* type)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSValue, OS.sel_value_1withObjCType_1, value, type);
+        return result !is null ? new NSValue(result) : null;
+    }
+
+    public static NSValue valueWithBytes (/*const*/void* value, /*const char* */byte* type)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSValue, OS.sel_valueWithBytes_1objCType_1, value, type);
+        return result !is null ? new NSValue(result) : null;
+    }
+
+    public static NSValue valueWithNonretainedObject (id anObject)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSValue, OS.sel_valueWithNonretainedObject_1, anObject !is null ? anObject.id : null);
+        return result !is null ? new NSValue(result) : null;
+    }
+
+    public static NSValue valueWithPoint (NSPoint point)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSValue, OS.sel_valueWithPoint_1, point);
+        return result !is null ? new NSValue(result) : null;
+    }
+
+    public static NSValue valueWithPointer (/*const*/void* pointer)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSValue, OS.sel_valueWithPointer_1, pointer);
+        return result !is null ? new NSValue(result) : null;
+    }
+
+    public static NSValue valueWithRange (NSRange range)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSValue, OS.sel_valueWithRange_1, range);
+        return result !is null ? new NSValue(result) : null;
+    }
+
+    public static NSValue valueWithRect (NSRect rect)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSValue, OS.sel_valueWithRect_1, rect);
+        return result !is null ? new NSValue(result) : null;
+    }
+
+    public static NSValue valueWithSize (NSSize size)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSValue, OS.sel_valueWithSize_1, size);
+        return result !is null ? new NSValue(result) : null;
+    }
+
+}