Mercurial > projects > dwt-mac
comparison dwt/internal/cocoa/NSKeyedArchiver.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.NSKeyedArchiver; | 14 module dwt.internal.cocoa.NSKeyedArchiver; |
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.NSMutableData; | |
21 import dwt.internal.cocoa.NSPropertyListFormat; | |
22 import dwt.internal.cocoa.NSString; | |
23 import dwt.internal.cocoa.OS; | 20 import dwt.internal.cocoa.OS; |
24 import objc = dwt.internal.objc.runtime; | 21 import objc = dwt.internal.objc.runtime; |
25 | 22 |
26 public class NSKeyedArchiver : NSCoder | 23 public class NSKeyedArchiver : NSCoder { |
27 { | |
28 | 24 |
29 public this () | 25 public this() { |
30 { | 26 super(); |
31 super(); | 27 } |
32 } | |
33 | 28 |
34 public this (objc.id id) | 29 public this(objc.id id) { |
35 { | 30 super(id); |
36 super(id); | 31 } |
37 } | |
38 | 32 |
39 public static bool archiveRootObject (id rootObject, NSString path) | 33 public this(cocoa.id id) { |
40 { | 34 super(id); |
41 return OS.objc_msgSend(OS.class_NSKeyedArchiver, OS.sel_archiveRootObject_1toFile_1, rootObject !is null ? rootObject.id_ : null, | 35 } |
42 path !is null ? path.id_ : null) !is null; | |
43 } | |
44 | 36 |
45 public static NSData archivedDataWithRootObject (id rootObject) | 37 public static NSData archivedDataWithRootObject(cocoa.id rootObject) { |
46 { | 38 objc.id result = OS.objc_msgSend(OS.class_NSKeyedArchiver, OS.sel_archivedDataWithRootObject_, rootObject !is null ? rootObject.id : null); |
47 objc.id result = OS.objc_msgSend(OS.class_NSKeyedArchiver, OS.sel_archivedDataWithRootObject_1, rootObject !is null ? rootObject.id_ : null); | 39 return result !is null ? new NSData(result) : null; |
48 return result !is null ? new NSData(result) : null; | 40 } |
49 } | |
50 | |
51 public NSString classNameForClass_ (objc.Class cls) | |
52 { | |
53 objc.id result = OS.objc_msgSend(this.id_, OS.sel_classNameForClass_1, cls); | |
54 return result !is null ? new NSString(result) : null; | |
55 } | |
56 | |
57 public static NSString static_classNameForClass_ (objc.Class cls) | |
58 { | |
59 objc.id result = OS.objc_msgSend(OS.class_NSKeyedArchiver, OS.sel_classNameForClass_1, cls); | |
60 return result !is null ? new NSString(result) : null; | |
61 } | |
62 | |
63 public id delegatee () | |
64 { | |
65 objc.id result = OS.objc_msgSend(this.id_, OS.sel_delegate); | |
66 return result !is null ? new id(result) : null; | |
67 } | |
68 | |
69 public void encodeBool (bool boolv, NSString key) | |
70 { | |
71 OS.objc_msgSend(this.id_, OS.sel_encodeBool_1forKey_1, boolv, key !is null ? key.id_ : null); | |
72 } | |
73 | |
74 public void encodeBytes (/*const*/ubyte* bytesp, NSUInteger lenv, NSString key) | |
75 { | |
76 OS.objc_msgSend(this.id_, OS.sel_encodeBytes_1length_1forKey_1, bytesp, lenv, key !is null ? key.id_ : null); | |
77 } | |
78 | |
79 public void encodeConditionalObject (id objv, NSString key) | |
80 { | |
81 OS.objc_msgSend(this.id_, OS.sel_encodeConditionalObject_1forKey_1, objv !is null ? objv.id_ : null, key !is null ? key.id_ : null); | |
82 } | |
83 | |
84 public void encodeDouble (double realv, NSString key) | |
85 { | |
86 OS.objc_msgSend(this.id_, OS.sel_encodeDouble_1forKey_1, realv, key !is null ? key.id_ : null); | |
87 } | |
88 | |
89 public void encodeFloat (float realv, NSString key) | |
90 { | |
91 OS.objc_msgSend(this.id_, OS.sel_encodeFloat_1forKey_1, realv, key !is null ? key.id_ : null); | |
92 } | |
93 | |
94 public void encodeInt32 (int intv, NSString key) | |
95 { | |
96 OS.objc_msgSend(this.id_, OS.sel_encodeInt32_1forKey_1, intv, key !is null ? key.id_ : null); | |
97 } | |
98 | |
99 public void encodeInt64 (long intv, NSString key) | |
100 { | |
101 OS.objc_msgSend(this.id_, OS.sel_encodeInt64_1forKey_1, intv, key !is null ? key.id_ : null); | |
102 } | |
103 | |
104 public void encodeInt (int intv, NSString key) | |
105 { | |
106 OS.objc_msgSend(this.id_, OS.sel_encodeInt_1forKey_1, intv, key !is null ? key.id_ : null); | |
107 } | |
108 | |
109 public void encodeObject (id objv, NSString key) | |
110 { | |
111 OS.objc_msgSend(this.id_, OS.sel_encodeObject_1forKey_1, objv !is null ? objv.id_ : null, key !is null ? key.id_ : null); | |
112 } | |
113 | |
114 public void finishEncoding () | |
115 { | |
116 OS.objc_msgSend(this.id_, OS.sel_finishEncoding); | |
117 } | |
118 | |
119 public id initForWritingWithMutableData (NSMutableData data) | |
120 { | |
121 objc.id result = OS.objc_msgSend(this.id_, OS.sel_initForWritingWithMutableData_1, data !is null ? data.id_ : null); | |
122 return result !is null ? new id(result) : null; | |
123 } | |
124 | |
125 public NSPropertyListFormat outputFormat () | |
126 { | |
127 return cast(NSPropertyListFormat) OS.objc_msgSend(this.id_, OS.sel_outputFormat); | |
128 } | |
129 | |
130 public static void static_setClassName_forClass_ (NSString codedName, objc.Class cls) | |
131 { | |
132 OS.objc_msgSend(OS.class_NSKeyedArchiver, OS.sel_setClassName_1forClass_1, codedName !is null ? codedName.id_ : null, cls); | |
133 } | |
134 | |
135 public void setClassName_forClass_ (NSString codedName, objc.Class cls) | |
136 { | |
137 OS.objc_msgSend(this.id_, OS.sel_setClassName_1forClass_1, codedName !is null ? codedName.id_ : null, cls); | |
138 } | |
139 | |
140 public void setDelegate (id delegatee) | |
141 { | |
142 OS.objc_msgSend(this.id_, OS.sel_setDelegate_1, delegatee !is null ? delegatee.id_ : null); | |
143 } | |
144 | |
145 public void setOutputFormat (NSPropertyListFormat format) | |
146 { | |
147 OS.objc_msgSend(this.id_, OS.sel_setOutputFormat_1, format); | |
148 } | |
149 | 41 |
150 } | 42 } |