diff dwt/internal/cocoa/NSArray.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/NSArray.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,342 @@
+/*******************************************************************************
+ * 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.NSArray;
+
+import dwt.internal.cocoa.id;
+import dwt.internal.cocoa.NSData;
+import dwt.internal.cocoa.NSEnumerator;
+import dwt.internal.cocoa.NSIndexSet;
+import dwt.internal.cocoa.NSInteger;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSPredicate;
+import dwt.internal.cocoa.NSRange;
+import dwt.internal.cocoa.NSString;
+import dwt.internal.cocoa.NSURL;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+public class NSArray : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public void addObserver_forKeyPath_options_context_ (NSObject observer, NSString keyPath, objc.id options, objc.id context)
+    {
+        OS.objc_msgSend(this.id, OS.sel_addObserver_1forKeyPath_1options_1context_1, observer !is null ? observer.id : null,
+                keyPath !is null ? keyPath.id : null, options, context);
+    }
+
+    public void addObserver_toObjectsAtIndexes_forKeyPath_options_context_ (NSObject observer, NSIndexSet indexes, NSString keyPath, objc.id options,
+            objc.id context)
+    {
+        OS.objc_msgSend(this.id, OS.sel_addObserver_1toObjectsAtIndexes_1forKeyPath_1options_1context_1, observer !is null ? observer.id : null,
+                indexes !is null ? indexes.id : null, keyPath !is null ? keyPath.id : null, options, context);
+    }
+
+    public static id array ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSArray, OS.sel_array);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSArray arrayByAddingObject (id anObject)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_arrayByAddingObject_1, anObject !is null ? anObject.id : null);
+        return result is this.id ? this : (result !is null ? new NSArray(result) : null);
+    }
+
+    public NSArray arrayByAddingObjectsFromArray (NSArray otherArray)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_arrayByAddingObjectsFromArray_1, otherArray !is null ? otherArray.id : null);
+        return result is this.id ? this : (result !is null ? new NSArray(result) : null);
+    }
+
+    public static id arrayWithArray (NSArray array)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSArray, OS.sel_arrayWithArray_1, array !is null ? array.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id arrayWithContentsOfFile (NSString path)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSArray, OS.sel_arrayWithContentsOfFile_1, path !is null ? path.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id arrayWithContentsOfURL (NSURL url)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSArray, OS.sel_arrayWithContentsOfURL_1, url !is null ? url.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id arrayWithObject (id anObject)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSArray, OS.sel_arrayWithObject_1, anObject !is null ? anObject.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id static_arrayWithObjects_ (id arrayWithObjects)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSArray, OS.sel_arrayWithObjects_1, arrayWithObjects !is null ? arrayWithObjects.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public static id static_arrayWithObjects_count_ (/*const*/objc.id* objects, NSUInteger cnt)
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSArray, OS.sel_arrayWithObjects_1count_1, objects, cnt);
+        return result !is null ? new id(result) : null;
+    }
+
+    public NSString componentsJoinedByString (NSString separator)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_componentsJoinedByString_1, separator !is null ? separator.id : null);
+        return result !is null ? new NSString(result) : null;
+    }
+
+    public bool containsObject (id anObject)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_containsObject_1, anObject !is null ? anObject.id : null) !is null;
+    }
+
+    public NSUInteger count ()
+    {
+        return 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 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, objc.id 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 NSArray filteredArrayUsingPredicate (NSPredicate predicate)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_filteredArrayUsingPredicate_1, predicate !is null ? predicate.id : null);
+        return result is this.id ? this : (result !is null ? new NSArray(result) : null);
+    }
+
+    public id firstObjectCommonWithArray (NSArray otherArray)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_firstObjectCommonWithArray_1, otherArray !is null ? otherArray.id : null);
+        return result !is null ? new id(result) : null;
+    }
+
+    public void getObjects_ (objc.id objects)
+    {
+        OS.objc_msgSend(this.id, OS.sel_getObjects_1, objects);
+    }
+
+    public void getObjects_range_ (objc.id objects, NSRange range)
+    {
+        OS.objc_msgSend(this.id, OS.sel_getObjects_1range_1, objects, range);
+    }
+
+    public NSUInteger indexOfObject_ (id anObject)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_indexOfObject_1, anObject !is null ? anObject.id : null);
+    }
+
+    public NSUInteger indexOfObject_inRange_ (id anObject, NSRange range)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_indexOfObject_1inRange_1, anObject !is null ? anObject.id : null, range);
+    }
+
+    public NSUInteger indexOfObjectIdenticalTo_ (id anObject)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_indexOfObjectIdenticalTo_1, anObject !is null ? anObject.id : null);
+    }
+
+    public NSUInteger indexOfObjectIdenticalTo_inRange_ (id anObject, NSRange range)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_indexOfObjectIdenticalTo_1inRange_1, anObject !is null ? anObject.id : null, range);
+    }
+
+    public NSArray initWithArray_ (NSArray array)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithArray_1, array !is null ? array.id : null);
+        return result !is null ? this : null;
+    }
+
+    public NSArray initWithArray_copyItems_ (NSArray array, bool flag)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithArray_1copyItems_1, array !is null ? array.id : null, flag);
+        return result !is null ? this : null;
+    }
+
+    public NSArray 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 ? this : null;
+    }
+
+    public NSArray 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 ? this : null;
+    }
+
+    public NSArray initWithObjects_ (id initWithObjects)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithObjects_1, initWithObjects !is null ? initWithObjects.id : null);
+        return result !is null ? this : null;
+    }
+
+    public NSArray initWithObjects_count_ (/*const*/objc.id* objects, NSUInteger cnt)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithObjects_1count_1, objects, cnt);
+        return result !is null ? this : null;
+    }
+
+    public bool isEqualToArray (NSArray otherArray)
+    {
+        return OS.objc_msgSend(this.id, OS.sel_isEqualToArray_1, otherArray !is null ? otherArray.id : null) !is null;
+    }
+
+    public id lastObject ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_lastObject);
+        return result !is null ? new id(result) : null;
+    }
+
+    public void makeObjectsPerformSelector_ (objc.SEL aSelector)
+    {
+        OS.objc_msgSend(this.id, OS.sel_makeObjectsPerformSelector_1, aSelector);
+    }
+
+    public void makeObjectsPerformSelector_withObject_ (objc.SEL aSelector, id argument)
+    {
+        OS.objc_msgSend(this.id, OS.sel_makeObjectsPerformSelector_1withObject_1, aSelector, argument !is null ? argument.id : null);
+    }
+
+    public objc.id objectAtIndex (NSUInteger index)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_objectAtIndex_1, index);
+        return result;
+    //  return result !is null ? new id(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 objectsAtIndexes (NSIndexSet indexes)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_objectsAtIndexes_1, indexes !is null ? indexes.id : null);
+        return result is this.id ? this : (result !is null ? new NSArray(result) : null);
+    }
+
+    public NSArray pathsMatchingExtensions (NSArray filterTypes)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_pathsMatchingExtensions_1, filterTypes !is null ? filterTypes.id : null);
+        return result is this.id ? this : (result !is null ? new NSArray(result) : null);
+    }
+
+    public void removeObserver_forKeyPath_ (NSObject observer, NSString keyPath)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeObserver_1forKeyPath_1, observer !is null ? observer.id : null, keyPath !is null ? keyPath.id : null);
+    }
+
+    public void removeObserver_fromObjectsAtIndexes_forKeyPath_ (NSObject observer, NSIndexSet indexes, NSString keyPath)
+    {
+        OS.objc_msgSend(this.id, OS.sel_removeObserver_1fromObjectsAtIndexes_1forKeyPath_1, observer !is null ? observer.id : null,
+                indexes !is null ? indexes.id : null, keyPath !is null ? keyPath.id : null);
+    }
+
+    public NSEnumerator reverseObjectEnumerator ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_reverseObjectEnumerator);
+        return result !is null ? new NSEnumerator(result) : null;
+    }
+
+    public void setValue (id value, NSString key)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setValue_1forKey_1, value !is null ? value.id : null, key !is null ? key.id : null);
+    }
+
+    public NSData sortedArrayHint ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_sortedArrayHint);
+        return result !is null ? new NSData(result) : null;
+    }
+
+    public NSArray sortedArrayUsingDescriptors (NSArray sortDescriptors)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_sortedArrayUsingDescriptors_1, sortDescriptors !is null ? sortDescriptors.id : null);
+        return result is this.id ? this : (result !is null ? new NSArray(result) : null);
+    }
+
+    public NSArray sortedArrayUsingFunction_context_ (objc.id comparator, objc.id context)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_sortedArrayUsingFunction_1context_1, comparator, context);
+        return result is this.id ? this : (result !is null ? new NSArray(result) : null);
+    }
+
+    public NSArray sortedArrayUsingFunction_context_hint_ (objc.id comparator, objc.id context, NSData hint)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_sortedArrayUsingFunction_1context_1hint_1, comparator, context,
+                hint !is null ? hint.id : null);
+        return result is this.id ? this : (result !is null ? new NSArray(result) : null);
+    }
+
+    public NSArray sortedArrayUsingSelector (objc.id comparator)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_sortedArrayUsingSelector_1, comparator);
+        return result is this.id ? this : (result !is null ? new NSArray(result) : null);
+    }
+
+    public NSArray subarrayWithRange (NSRange range)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_subarrayWithRange_1, range);
+        return result is this.id ? this : (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;
+    }
+
+}