comparison dwt/internal/cocoa/NSKeyedUnarchiver.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.NSKeyedUnarchiver; 14 module dwt.internal.cocoa.NSKeyedUnarchiver;
15 15
16 import dwt.internal.cocoa.id; 16 import dwt.dwthelper.utils;
17 import cocoa = dwt.internal.cocoa.id;
17 import dwt.internal.cocoa.NSCoder; 18 import dwt.internal.cocoa.NSCoder;
18 import dwt.internal.cocoa.NSData; 19 import dwt.internal.cocoa.NSData;
19 import dwt.internal.cocoa.NSInteger;
20 import dwt.internal.cocoa.NSString;
21 import dwt.internal.cocoa.OS; 20 import dwt.internal.cocoa.OS;
22 import objc = dwt.internal.objc.runtime; 21 import objc = dwt.internal.objc.runtime;
23 22
24 public class NSKeyedUnarchiver : NSCoder 23 public class NSKeyedUnarchiver : NSCoder {
25 {
26 24
27 public this () 25 public this() {
28 { 26 super();
29 super(); 27 }
30 }
31 28
32 public this (objc.id id) 29 public this(objc.id id) {
33 { 30 super(id);
34 super(id); 31 }
35 }
36 32
37 public objc.Class classForClassName_ (NSString codedName) 33 public this(cocoa.id id) {
38 { 34 super(id);
39 return cast(objc.Class) OS.objc_msgSend(this.id_, OS.sel_classForClassName_1, codedName !is null ? codedName.id_ : null); 35 }
40 }
41 36
42 public static objc.Class static_classForClassName_ (NSString codedName) 37 public static cocoa.id unarchiveObjectWithData(NSData data) {
43 { 38 objc.id result = OS.objc_msgSend(OS.class_NSKeyedUnarchiver, OS.sel_unarchiveObjectWithData_, data !is null ? data.id : null);
44 return cast(objc.Class) OS.objc_msgSend(OS.class_NSKeyedUnarchiver, OS.sel_classForClassName_1, codedName !is null ? codedName.id_ : null); 39 return result !is null ? new cocoa.id(result) : null;
45 } 40 }
46
47 public bool containsValueForKey (NSString key)
48 {
49 return OS.objc_msgSend(this.id_, OS.sel_containsValueForKey_1, key !is null ? key.id_ : null) !is null;
50 }
51
52 public bool decodeBoolForKey (NSString key)
53 {
54 return OS.objc_msgSend(this.id_, OS.sel_decodeBoolForKey_1, key !is null ? key.id_ : null) !is null;
55 }
56
57 public /*const*/ubyte* decodeBytesForKey (NSString key, NSUInteger* lengthp)
58 {
59 return cast(/*const*/ubyte*) OS.objc_msgSend(this.id_, OS.sel_decodeBytesForKey_1returnedLength_1, key !is null ? key.id_ : null, lengthp);
60 }
61
62 public double decodeDoubleForKey (NSString key)
63 {
64 return cast(double) OS.objc_msgSend_fpret(this.id_, OS.sel_decodeDoubleForKey_1, key !is null ? key.id_ : null);
65 }
66
67 public float decodeFloatForKey (NSString key)
68 {
69 return cast(float) OS.objc_msgSend_fpret(this.id_, OS.sel_decodeFloatForKey_1, key !is null ? key.id_ : null);
70 }
71
72 public int decodeInt32ForKey (NSString key)
73 {
74 return cast(int) OS.objc_msgSend(this.id_, OS.sel_decodeInt32ForKey_1, key !is null ? key.id_ : null);
75 }
76
77 public long decodeInt64ForKey (NSString key)
78 {
79 return cast(long) OS.objc_msgSend(this.id_, OS.sel_decodeInt64ForKey_1, key !is null ? key.id_ : null);
80 }
81
82 public int decodeIntForKey (NSString key)
83 {
84 return cast(int) OS.objc_msgSend(this.id_, OS.sel_decodeIntForKey_1, key !is null ? key.id_ : null);
85 }
86
87 public id decodeObjectForKey (NSString key)
88 {
89 objc.id result = OS.objc_msgSend(this.id_, OS.sel_decodeObjectForKey_1, key !is null ? key.id_ : null);
90 return result !is null ? new id(result) : null;
91 }
92
93 public id delegatee ()
94 {
95 objc.id result = OS.objc_msgSend(this.id_, OS.sel_delegate);
96 return result !is null ? new id(result) : null;
97 }
98
99 public void finishDecoding ()
100 {
101 OS.objc_msgSend(this.id_, OS.sel_finishDecoding);
102 }
103
104 public id initForReadingWithData (NSData data)
105 {
106 objc.id result = OS.objc_msgSend(this.id_, OS.sel_initForReadingWithData_1, data !is null ? data.id_ : null);
107 return result !is null ? new id(result) : null;
108 }
109
110 public void setClass_forClassName_ (objc.Class cls, NSString codedName)
111 {
112 OS.objc_msgSend(this.id_, OS.sel_setClass_1forClassName_1, cls, codedName !is null ? codedName.id_ : null);
113 }
114
115 public static void static_setClass_forClassName_ (objc.Class cls, NSString codedName)
116 {
117 OS.objc_msgSend(OS.class_NSKeyedUnarchiver, OS.sel_setClass_1forClassName_1, cls, codedName !is null ? codedName.id_ : null);
118 }
119
120 public void setDelegate (id delegatee)
121 {
122 OS.objc_msgSend(this.id_, OS.sel_setDelegate_1, delegatee !is null ? delegatee.id_ : null);
123 }
124
125 public static id unarchiveObjectWithData (NSData data)
126 {
127 objc.id result = OS.objc_msgSend(OS.class_NSKeyedUnarchiver, OS.sel_unarchiveObjectWithData_1, data !is null ? data.id_ : null);
128 return result !is null ? new id(result) : null;
129 }
130
131 public static id unarchiveObjectWithFile (NSString path)
132 {
133 objc.id result = OS.objc_msgSend(OS.class_NSKeyedUnarchiver, OS.sel_unarchiveObjectWithFile_1, path !is null ? path.id_ : null);
134 return result !is null ? new id(result) : null;
135 }
136 41
137 } 42 }