comparison dwt/internal/cocoa/NSMutableDictionary.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
comparison
equal deleted inserted replaced
44:ca5e494f2bbf 45:d8635bb48c7c
1 /******************************************************************************* 1 /*******************************************************************************
2 * Copyright (c) 2007 IBM Corporation and others. 2 * Copyright (c) 2000, 2008 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials 3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0 4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at 5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html 6 * http://www.eclipse.org/legal/epl-v10.html
7 * 7 *
8 * Contributors: 8 * Contributors:
9 * IBM Corporation - initial API and implementation 9 * IBM Corporation - initial API and implementation
10 * 10 *
11 * Port to the D programming language: 11 * Port to the D programming language:
12 * Jacob Carlborg <jacob.carlborg@gmail.com> 12 * Jacob Carlborg <doob@me.com>
13 *******************************************************************************/ 13 *******************************************************************************/
14 module dwt.internal.cocoa.NSMutableDictionary; 14 module dwt.internal.cocoa.NSMutableDictionary;
15 15
16 import dwt.internal.cocoa.id; 16 import dwt.dwthelper.utils;
17 import dwt.internal.cocoa.NSArray; 17 import cocoa = dwt.internal.cocoa.id;
18 import dwt.internal.cocoa.NSDictionary; 18 import dwt.internal.cocoa.NSDictionary;
19 import dwt.internal.cocoa.NSInteger;
20 import dwt.internal.cocoa.NSString; 19 import dwt.internal.cocoa.NSString;
21 import dwt.internal.cocoa.OS; 20 import dwt.internal.cocoa.OS;
21 import dwt.internal.objc.cocoa.Cocoa;
22 import objc = dwt.internal.objc.runtime; 22 import objc = dwt.internal.objc.runtime;
23 23
24 public class NSMutableDictionary : NSDictionary 24 public class NSMutableDictionary : NSDictionary {
25 {
26 25
27 public this () 26 public this() {
28 { 27 super();
29 super(); 28 }
30 }
31 29
32 public this (objc.id id) 30 public this(objc.id id) {
33 { 31 super(id);
34 super(id); 32 }
35 }
36 33
37 public void addEntriesFromDictionary (NSDictionary otherDictionary) 34 public this(cocoa.id id) {
38 { 35 super(id);
39 OS.objc_msgSend(this.id_, OS.sel_addEntriesFromDictionary_1, otherDictionary !is null ? otherDictionary.id_ : null); 36 }
40 }
41 37
42 public static NSMutableDictionary dictionaryWithCapacity (NSUInteger numItems) 38 public static NSMutableDictionary dictionaryWithCapacity(NSUInteger numItems) {
43 { 39 objc.id result = OS.objc_msgSend(OS.class_NSMutableDictionary, OS.sel_dictionaryWithCapacity_, numItems);
44 objc.id result = OS.objc_msgSend(OS.class_NSMutableDictionary, OS.sel_dictionaryWithCapacity_1, numItems); 40 return result !is null ? new NSMutableDictionary(result) : null;
45 return result !is null ? new NSMutableDictionary(result) : null; 41 }
46 }
47 42
48 public NSMutableDictionary initWithCapacity (NSUInteger numItems) 43 public void setObject(cocoa.id anObject, cocoa.id aKey) {
49 { 44 OS.objc_msgSend(this.id, OS.sel_setObject_forKey_, anObject !is null ? anObject.id : null, aKey !is null ? aKey.id : null);
50 objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithCapacity_1, numItems); 45 }
51 return result !is null ? this : null;
52 }
53 46
54 public void removeAllObjects () 47 public void setValue(cocoa.id value, NSString key) {
55 { 48 OS.objc_msgSend(this.id, OS.sel_setValue_forKey_, value !is null ? value.id : null, key !is null ? key.id : null);
56 OS.objc_msgSend(this.id_, OS.sel_removeAllObjects); 49 }
57 }
58 50
59 public void removeObjectForKey (id aKey) 51 public static NSDictionary dictionaryWithObject(cocoa.id object, cocoa.id key) {
60 { 52 objc.id result = OS.objc_msgSend(OS.class_NSMutableDictionary, OS.sel_dictionaryWithObject_forKey_, object !is null ? object.id : null, key !is null ? key.id : null);
61 OS.objc_msgSend(this.id_, OS.sel_removeObjectForKey_1, aKey !is null ? aKey.id_ : null); 53 return result !is null ? new NSMutableDictionary(result) : null;
62 } 54 }
63
64 public void removeObjectsForKeys (NSArray keyArray)
65 {
66 OS.objc_msgSend(this.id_, OS.sel_removeObjectsForKeys_1, keyArray !is null ? keyArray.id_ : null);
67 }
68
69 public void setDictionary (NSDictionary otherDictionary)
70 {
71 OS.objc_msgSend(this.id_, OS.sel_setDictionary_1, otherDictionary !is null ? otherDictionary.id_ : null);
72 }
73
74 public void setObject (id anObject, id aKey)
75 {
76 OS.objc_msgSend(this.id_, OS.sel_setObject_1forKey_1, anObject !is null ? anObject.id_ : null, aKey !is null ? aKey.id_ : null);
77 }
78
79 public void setObject (id anObject, objc.id aKey)
80 {
81 OS.objc_msgSend(this.id_, OS.sel_setObject_1forKey_1, anObject !is null ? anObject.id_ : null, aKey);
82 }
83
84 public void setValue (id value, NSString key)
85 {
86 OS.objc_msgSend(this.id_, OS.sel_setValue_1forKey_1, value !is null ? value.id_ : null, key !is null ? key.id_ : null);
87 }
88 55
89 } 56 }