diff dwt/internal/cocoa/NSDictionary.d @ 45:d8635bb48c7c

Merge with SWT 3.5
author Jacob Carlborg <doob@me.com>
date Mon, 01 Dec 2008 17:07:00 +0100
parents f565d3a95c0a
children 62202ce0039f
line wrap: on
line diff
--- a/dwt/internal/cocoa/NSDictionary.d	Tue Oct 21 15:20:04 2008 +0200
+++ b/dwt/internal/cocoa/NSDictionary.d	Mon Dec 01 17:07:00 2008 +0100
@@ -1,330 +1,69 @@
 /*******************************************************************************
- * Copyright (c) 2007 IBM Corporation and others.
+ * Copyright (c) 2000, 2008 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
+ *    IBM Corporation - initial API and implementation
  *     
  * Port to the D programming language:
- *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *     Jacob Carlborg <doob@me.com>
  *******************************************************************************/
 module dwt.internal.cocoa.NSDictionary;
 
-
-import dwt.internal.c.carboncore.MacTypes : OSType;
-import dwt.internal.cocoa.id;
+import dwt.dwthelper.utils;
+import cocoa = dwt.internal.cocoa.id;
 import dwt.internal.cocoa.NSArray;
-import dwt.internal.cocoa.NSDate;
 import dwt.internal.cocoa.NSEnumerator;
-import dwt.internal.cocoa.NSInteger;
-import dwt.internal.cocoa.NSNumber;
 import dwt.internal.cocoa.NSObject;
 import dwt.internal.cocoa.NSString;
-import dwt.internal.cocoa.NSURL;
 import dwt.internal.cocoa.OS;
+import dwt.internal.objc.cocoa.Cocoa;
 import objc = dwt.internal.objc.runtime;
 
-
-public class NSDictionary : NSObject
-{
-
-    public this ()
-    {
-        super();
-    }
-
-    public this (objc.id id)
-    {
-        super(id);
-    }
-
-    public NSArray allKeys ()
-    {
-        objc.id result = OS.objc_msgSend(this.id_, OS.sel_allKeys);
-        return result !is null ? new NSArray(result) : null;
-    }
-
-    public NSArray allKeysForObject (id anObject)
-    {
-        objc.id result = OS.objc_msgSend(this.id_, OS.sel_allKeysForObject_1, anObject !is null ? anObject.id_ : null);
-        return result !is null ? new NSArray(result) : null;
-    }
-
-    public NSArray allValues ()
-    {
-        objc.id result = OS.objc_msgSend(this.id_, OS.sel_allValues);
-        return result !is null ? new NSArray(result) : null;
-    }
+public class NSDictionary : NSObject {
 
-    public NSUInteger count ()
-    {
-        return cast(NSUInteger) OS.objc_msgSend(this.id_, OS.sel_count);
-    }
-
-    public NSString description ()
-    {
-        objc.id result = OS.objc_msgSend(this.id_, OS.sel_description);
-        return result !is null ? new NSString(result) : null;
-    }
-
-    public NSString descriptionInStringsFileFormat ()
-    {
-        objc.id result = OS.objc_msgSend(this.id_, OS.sel_descriptionInStringsFileFormat);
-        return result !is null ? new NSString(result) : null;
-    }
-
-    public NSString descriptionWithLocale_ (id locale)
-    {
-        objc.id result = OS.objc_msgSend(this.id_, OS.sel_descriptionWithLocale_1, locale !is null ? locale.id_ : null);
-        return result !is null ? new NSString(result) : null;
-    }
-
-    public NSString descriptionWithLocale_indent_ (id locale, NSUInteger level)
-    {
-        objc.id result = OS.objc_msgSend(this.id_, OS.sel_descriptionWithLocale_1indent_1, locale !is null ? locale.id_ : null, level);
-        return result !is null ? new NSString(result) : null;
-    }
-
-    public static id dictionary ()
-    {
-        objc.id result = OS.objc_msgSend(OS.class_NSDictionary, OS.sel_dictionary);
-        return result !is null ? new id(result) : null;
-    }
-
-    public static id dictionaryWithContentsOfFile (NSString path)
-    {
-        objc.id result = OS.objc_msgSend(OS.class_NSDictionary, OS.sel_dictionaryWithContentsOfFile_1, path !is null ? path.id_ : null);
-        return result !is null ? new id(result) : null;
-    }
+public this() {
+    super();
+}
 
-    public static id dictionaryWithContentsOfURL (NSURL url)
-    {
-        objc.id result = OS.objc_msgSend(OS.class_NSDictionary, OS.sel_dictionaryWithContentsOfURL_1, url !is null ? url.id_ : null);
-        return result !is null ? new id(result) : null;
-    }
-
-    public static id dictionaryWithDictionary (NSDictionary dict)
-    {
-        objc.id result = OS.objc_msgSend(OS.class_NSDictionary, OS.sel_dictionaryWithDictionary_1, dict !is null ? dict.id_ : null);
-        return result !is null ? new id(result) : null;
-    }
-
-    public static id dictionaryWithObject (id object, id key)
-    {
-        objc.id result = OS.objc_msgSend(OS.class_NSDictionary, OS.sel_dictionaryWithObject_1forKey_1, object !is null ? object.id_ : null,
-                key !is null ? key.id_ : null);
-        return result !is null ? new id(result) : null;
-    }
-
-    public static id static_dictionaryWithObjects_forKeys_ (NSArray objects, NSArray keys)
-    {
-        objc.id result = OS.objc_msgSend(OS.class_NSDictionary, OS.sel_dictionaryWithObjects_1forKeys_1, objects !is null ? objects.id_ : null,
-                keys !is null ? keys.id_ : null);
-        return result !is null ? new id(result) : null;
-    }
-
-    public static id static_dictionaryWithObjects_forKeys_count_ (objc.id* objects, objc.id* keys, NSUInteger cnt)
-    {
-        objc.id result = OS.objc_msgSend(OS.class_NSDictionary, OS.sel_dictionaryWithObjects_1forKeys_1count_1, objects, keys, cnt);
-        return result !is null ? new id(result) : null;
-    }
+public this(objc.id id) {
+    super(id);
+}
 
-    public static id dictionaryWithObjectsAndKeys (id dictionaryWithObjectsAndKeys)
-    {
-        objc.id result = OS.objc_msgSend(OS.class_NSDictionary, OS.sel_dictionaryWithObjectsAndKeys_1,
-                dictionaryWithObjectsAndKeys !is null ? dictionaryWithObjectsAndKeys.id_ : null);
-        return result !is null ? new id(result) : null;
-    }
-
-    public NSDate fileCreationDate ()
-    {
-        objc.id result = OS.objc_msgSend(this.id_, OS.sel_fileCreationDate);
-        return result !is null ? new NSDate(result) : null;
-    }
-
-    public bool fileExtensionHidden ()
-    {
-        return OS.objc_msgSend(this.id_, OS.sel_fileExtensionHidden) !is null;
-    }
+public this(cocoa.id id) {
+    super(id);
+}
 
-    public NSNumber fileGroupOwnerAccountID ()
-    {
-        objc.id result = OS.objc_msgSend(this.id_, OS.sel_fileGroupOwnerAccountID);
-        return result !is null ? new NSNumber(result) : null;
-    }
-
-    public NSString fileGroupOwnerAccountName ()
-    {
-        objc.id result = OS.objc_msgSend(this.id_, OS.sel_fileGroupOwnerAccountName);
-        return result !is null ? new NSString(result) : null;
-    }
-
-    public OSType fileHFSCreatorCode ()
-    {
-        return cast(OSType) OS.objc_msgSend(this.id_, OS.sel_fileHFSCreatorCode);
-    }
-
-    public OSType fileHFSTypeCode ()
-    {
-        return cast(OSType) OS.objc_msgSend(this.id_, OS.sel_fileHFSTypeCode);
-    }
-
-    public bool fileIsAppendOnly ()
-    {
-        return OS.objc_msgSend(this.id_, OS.sel_fileIsAppendOnly) !is null;
-    }
+public NSArray allKeys() {
+    objc.id result = OS.objc_msgSend(this.id, OS.sel_allKeys);
+    return result !is null ? new NSArray(result) : null;
+}
 
-    public bool fileIsImmutable ()
-    {
-        return OS.objc_msgSend(this.id_, OS.sel_fileIsImmutable) !is null;
-    }
-
-    public NSDate fileModificationDate ()
-    {
-        objc.id result = OS.objc_msgSend(this.id_, OS.sel_fileModificationDate);
-        return result !is null ? new NSDate(result) : null;
-    }
-
-    public NSNumber fileOwnerAccountID ()
-    {
-        objc.id result = OS.objc_msgSend(this.id_, OS.sel_fileOwnerAccountID);
-        return result !is null ? new NSNumber(result) : null;
-    }
-
-    public NSString fileOwnerAccountName ()
-    {
-        objc.id result = OS.objc_msgSend(this.id_, OS.sel_fileOwnerAccountName);
-        return result !is null ? new NSString(result) : null;
-    }
-
-    public NSUInteger filePosixPermissions ()
-    {
-        return cast(NSUInteger) OS.objc_msgSend(this.id_, OS.sel_filePosixPermissions);
-    }
-
-    public ulong fileSize ()
-    {
-        return cast(ulong) OS.objc_msgSend(this.id_, OS.sel_fileSize);
-    }
+public NSUInteger count() {
+    return cast(NSUInteger) OS.objc_msgSend(this.id, OS.sel_count);
+}
 
-    public NSUInteger fileSystemFileNumber ()
-    {
-        return cast(NSUInteger) OS.objc_msgSend(this.id_, OS.sel_fileSystemFileNumber);
-    }
-
-    public NSInteger fileSystemNumber ()
-    {
-        return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_fileSystemNumber);
-    }
-
-    public NSString fileType ()
-    {
-        objc.id result = OS.objc_msgSend(this.id_, OS.sel_fileType);
-        return result !is null ? new NSString(result) : null;
-    }
-
-    public void getObjects (objc.id* objects, objc.id* keys)
-    {
-        OS.objc_msgSend(this.id_, OS.sel_getObjects_1andKeys_1, objects, keys);
-    }
-
-    public id initWithContentsOfFile (NSString path)
-    {
-        objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithContentsOfFile_1, path !is null ? path.id_ : null);
-        return result !is null ? new id(result) : null;
-    }
-
-    public id initWithContentsOfURL (NSURL url)
-    {
-        objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithContentsOfURL_1, url !is null ? url.id_ : null);
-        return result !is null ? new id(result) : null;
-    }
-
-    public id initWithDictionary_ (NSDictionary otherDictionary)
-    {
-        objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithDictionary_1, otherDictionary !is null ? otherDictionary.id_ : null);
-        return result !is null ? new id(result) : null;
-    }
+public static NSDictionary dictionaryWithObject(cocoa.id object, cocoa.id key) {
+    objc.id result = OS.objc_msgSend(OS.class_NSDictionary, OS.sel_dictionaryWithObject_forKey_, object !is null ? object.id : null, key !is null ? key.id : null);
+    return result !is null ? new NSDictionary(result) : null;
+}
 
-    public id initWithDictionary_copyItems_ (NSDictionary otherDictionary, bool flag)
-    {
-        objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithDictionary_1copyItems_1, otherDictionary !is null ? otherDictionary.id_ : null, flag);
-        return result !is null ? new id(result) : null;
-    }
-
-    public id initWithObjects_forKeys_ (NSArray objects, NSArray keys)
-    {
-        objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithObjects_1forKeys_1, objects !is null ? objects.id_ : null,
-                keys !is null ? keys.id_ : null);
-        return result !is null ? new id(result) : null;
-    }
-
-    public id initWithObjects_forKeys_count_ (objc.id* objects, objc.id* keys, NSUInteger cnt)
-    {
-        objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithObjects_1forKeys_1count_1, objects, keys, cnt);
-        return result !is null ? new id(result) : null;
-    }
-
-    public id initWithObjectsAndKeys (id initWithObjectsAndKeys)
-    {
-        objc.id
-                result = OS.objc_msgSend(this.id_, OS.sel_initWithObjectsAndKeys_1, initWithObjectsAndKeys !is null ? initWithObjectsAndKeys.id_ : null);
-        return result !is null ? new id(result) : null;
-    }
-
-    public bool isEqualToDictionary (NSDictionary otherDictionary)
-    {
-        return OS.objc_msgSend(this.id_, OS.sel_isEqualToDictionary_1, otherDictionary !is null ? otherDictionary.id_ : null) !is null;
-    }
-
-    public NSEnumerator keyEnumerator ()
-    {
-        objc.id result = OS.objc_msgSend(this.id_, OS.sel_keyEnumerator);
-        return result !is null ? new NSEnumerator(result) : null;
-    }
+public NSEnumerator objectEnumerator() {
+    objc.id result = OS.objc_msgSend(this.id, OS.sel_objectEnumerator);
+    return result !is null ? new NSEnumerator(result) : null;
+}
 
-    public NSArray keysSortedByValueUsingSelector (objc.SEL comparator)
-    {
-        objc.id result = OS.objc_msgSend(this.id_, OS.sel_keysSortedByValueUsingSelector_1, comparator);
-        return result !is null ? new NSArray(result) : null;
-    }
-
-    public NSEnumerator objectEnumerator ()
-    {
-        objc.id result = OS.objc_msgSend(this.id_, OS.sel_objectEnumerator);
-        return result !is null ? new NSEnumerator(result) : null;
-    }
-
-    public id objectForKey (id aKey)
-    {
-        objc.id result = OS.objc_msgSend(this.id_, OS.sel_objectForKey_1, aKey !is null ? aKey.id_ : null);
-        return result !is null ? new id(result) : null;
-    }
+public cocoa.id objectForKey(cocoa.id aKey) {
+    objc.id result = OS.objc_msgSend(this.id, OS.sel_objectForKey_, aKey !is null ? aKey.id : null);
+    return result !is null ? new cocoa.id(result) : null;
+}
 
-    public NSArray objectsForKeys (NSArray keys, id marker)
-    {
-        objc.id result = OS.objc_msgSend(this.id_, OS.sel_objectsForKeys_1notFoundMarker_1, keys !is null ? keys.id_ : null,
-                marker !is null ? marker.id_ : null);
-        return result !is null ? new NSArray(result) : null;
-    }
-
-    public id valueForKey (NSString key)
-    {
-        objc.id result = OS.objc_msgSend(this.id_, OS.sel_valueForKey_1, key !is null ? key.id_ : null);
-        return result !is null ? new id(result) : null;
-    }
-
-    public bool writeToFile (NSString path, bool useAuxiliaryFile)
-    {
-        return OS.objc_msgSend(this.id_, OS.sel_writeToFile_1atomically_1, path !is null ? path.id_ : null, useAuxiliaryFile) !is null;
-    }
-
-    public bool writeToURL (NSURL url, bool atomically)
-    {
-        return OS.objc_msgSend(this.id_, OS.sel_writeToURL_1atomically_1, url !is null ? url.id_ : null, atomically) !is null;
-    }
+public cocoa.id valueForKey(NSString key) {
+    objc.id result = OS.objc_msgSend(this.id, OS.sel_valueForKey_, key !is null ? key.id : null);
+    return result !is null ? new id(result) : null;
+}
 
 }