annotate dstep/foundation/NSFormatter.d @ 16:19885b43130e

Huge update, the bridge actually works now
author Jacob Carlborg <doob@me.com>
date Sun, 03 Jan 2010 22:06:11 +0100
parents 89f3c3ef1fd2
children b9de51448c6b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14
89f3c3ef1fd2 Added the Foundation framework
Jacob Carlborg <doob@me.com>
parents:
diff changeset
1 /**
89f3c3ef1fd2 Added the Foundation framework
Jacob Carlborg <doob@me.com>
parents:
diff changeset
2 * Copyright: Copyright (c) 2009 Jacob Carlborg.
89f3c3ef1fd2 Added the Foundation framework
Jacob Carlborg <doob@me.com>
parents:
diff changeset
3 * Authors: Jacob Carlborg
89f3c3ef1fd2 Added the Foundation framework
Jacob Carlborg <doob@me.com>
parents:
diff changeset
4 * Version: Initial created: Aug 3, 2009
89f3c3ef1fd2 Added the Foundation framework
Jacob Carlborg <doob@me.com>
parents:
diff changeset
5 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0)
89f3c3ef1fd2 Added the Foundation framework
Jacob Carlborg <doob@me.com>
parents:
diff changeset
6 */
89f3c3ef1fd2 Added the Foundation framework
Jacob Carlborg <doob@me.com>
parents:
diff changeset
7 module dstep.foundation.NSFormatter;
89f3c3ef1fd2 Added the Foundation framework
Jacob Carlborg <doob@me.com>
parents:
diff changeset
8
89f3c3ef1fd2 Added the Foundation framework
Jacob Carlborg <doob@me.com>
parents:
diff changeset
9 import dstep.foundation.NSAttributedString;
16
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 14
diff changeset
10 import dstep.foundation.NSCoder;
14
89f3c3ef1fd2 Added the Foundation framework
Jacob Carlborg <doob@me.com>
parents:
diff changeset
11 import dstep.foundation.NSDictionary;
89f3c3ef1fd2 Added the Foundation framework
Jacob Carlborg <doob@me.com>
parents:
diff changeset
12 import dstep.foundation.NSObject;
89f3c3ef1fd2 Added the Foundation framework
Jacob Carlborg <doob@me.com>
parents:
diff changeset
13 import dstep.foundation.NSRange;
89f3c3ef1fd2 Added the Foundation framework
Jacob Carlborg <doob@me.com>
parents:
diff changeset
14 import dstep.foundation.NSString;
16
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 14
diff changeset
15 import dstep.foundation.NSZone;
14
89f3c3ef1fd2 Added the Foundation framework
Jacob Carlborg <doob@me.com>
parents:
diff changeset
16 import dstep.objc.bridge.Bridge;
16
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 14
diff changeset
17 import dstep.objc.objc;
14
89f3c3ef1fd2 Added the Foundation framework
Jacob Carlborg <doob@me.com>
parents:
diff changeset
18
89f3c3ef1fd2 Added the Foundation framework
Jacob Carlborg <doob@me.com>
parents:
diff changeset
19 class NSFormatter : NSObject, INSCopying, INSCoding
89f3c3ef1fd2 Added the Foundation framework
Jacob Carlborg <doob@me.com>
parents:
diff changeset
20 {
16
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 14
diff changeset
21 mixin (ObjcWrap);
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 14
diff changeset
22
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 14
diff changeset
23 this ()
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 14
diff changeset
24 {
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 14
diff changeset
25 super(typeof(this).alloc.init.objcObject);
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 14
diff changeset
26 }
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 14
diff changeset
27
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 14
diff changeset
28 typeof(this) init ()
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 14
diff changeset
29 {
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 14
diff changeset
30 return invokeObjcSelf!(typeof(this), "init");
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 14
diff changeset
31 }
14
89f3c3ef1fd2 Added the Foundation framework
Jacob Carlborg <doob@me.com>
parents:
diff changeset
32
89f3c3ef1fd2 Added the Foundation framework
Jacob Carlborg <doob@me.com>
parents:
diff changeset
33 NSString stringForObjectValue (Object obj)
89f3c3ef1fd2 Added the Foundation framework
Jacob Carlborg <doob@me.com>
parents:
diff changeset
34 {
89f3c3ef1fd2 Added the Foundation framework
Jacob Carlborg <doob@me.com>
parents:
diff changeset
35 return invokeObjcSelf!(NSString, "stringForObjectValue:", Object)(obj);
89f3c3ef1fd2 Added the Foundation framework
Jacob Carlborg <doob@me.com>
parents:
diff changeset
36 }
89f3c3ef1fd2 Added the Foundation framework
Jacob Carlborg <doob@me.com>
parents:
diff changeset
37
89f3c3ef1fd2 Added the Foundation framework
Jacob Carlborg <doob@me.com>
parents:
diff changeset
38 NSAttributedString attributedStringForObjectValue (Object obj, NSDictionary attrs)
89f3c3ef1fd2 Added the Foundation framework
Jacob Carlborg <doob@me.com>
parents:
diff changeset
39 {
89f3c3ef1fd2 Added the Foundation framework
Jacob Carlborg <doob@me.com>
parents:
diff changeset
40 return invokeObjcSelf!(NSAttributedString, "attributedStringForObjectValue:withDefaultAttributes:", Object, NSDictionary)(obj, attrs);
89f3c3ef1fd2 Added the Foundation framework
Jacob Carlborg <doob@me.com>
parents:
diff changeset
41 }
89f3c3ef1fd2 Added the Foundation framework
Jacob Carlborg <doob@me.com>
parents:
diff changeset
42
89f3c3ef1fd2 Added the Foundation framework
Jacob Carlborg <doob@me.com>
parents:
diff changeset
43 NSString editingStringForObjectValue (Object obj)
89f3c3ef1fd2 Added the Foundation framework
Jacob Carlborg <doob@me.com>
parents:
diff changeset
44 {
89f3c3ef1fd2 Added the Foundation framework
Jacob Carlborg <doob@me.com>
parents:
diff changeset
45 return invokeObjcSelf!(NSString, "editingStringForObjectValue:", Object)(obj);
89f3c3ef1fd2 Added the Foundation framework
Jacob Carlborg <doob@me.com>
parents:
diff changeset
46 }
89f3c3ef1fd2 Added the Foundation framework
Jacob Carlborg <doob@me.com>
parents:
diff changeset
47
16
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 14
diff changeset
48 bool getObjectValue (out NSObject obj, NSString string, ref NSString error)
14
89f3c3ef1fd2 Added the Foundation framework
Jacob Carlborg <doob@me.com>
parents:
diff changeset
49 {
16
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 14
diff changeset
50 id err;
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 14
diff changeset
51 id object;
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 14
diff changeset
52
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 14
diff changeset
53 if (error)
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 14
diff changeset
54 err = new objc_object;
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 14
diff changeset
55
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 14
diff changeset
56 bool result = invokeObjcSelf!(bool, "getObjectValue:forString:errorDescription:", id*, NSString, id*)(&object, string, &err);
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 14
diff changeset
57
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 14
diff changeset
58 if (err)
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 14
diff changeset
59 error = new NSString(err);
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 14
diff changeset
60
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 14
diff changeset
61 if (object)
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 14
diff changeset
62 obj = new NSObject(object);
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 14
diff changeset
63
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 14
diff changeset
64 return result;
14
89f3c3ef1fd2 Added the Foundation framework
Jacob Carlborg <doob@me.com>
parents:
diff changeset
65 }
89f3c3ef1fd2 Added the Foundation framework
Jacob Carlborg <doob@me.com>
parents:
diff changeset
66
16
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 14
diff changeset
67 bool isPartialStringValid (NSString partialString, out NSString newString, ref NSString error)
14
89f3c3ef1fd2 Added the Foundation framework
Jacob Carlborg <doob@me.com>
parents:
diff changeset
68 {
16
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 14
diff changeset
69 id err;
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 14
diff changeset
70 id newStr = new objc_object;
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 14
diff changeset
71
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 14
diff changeset
72 if (error)
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 14
diff changeset
73 err = new objc_object;
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 14
diff changeset
74
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 14
diff changeset
75 bool result = invokeObjcSelf!(bool, "isPartialStringValid:newEditingString:errorDescription:", NSString, id*, id*)(partialString, &newStr, &err);
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 14
diff changeset
76
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 14
diff changeset
77 if (err)
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 14
diff changeset
78 error = new NSString(err);
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 14
diff changeset
79
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 14
diff changeset
80 if (newStr)
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 14
diff changeset
81 newString = new NSString(newStr);
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 14
diff changeset
82
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 14
diff changeset
83 return result;
14
89f3c3ef1fd2 Added the Foundation framework
Jacob Carlborg <doob@me.com>
parents:
diff changeset
84 }
89f3c3ef1fd2 Added the Foundation framework
Jacob Carlborg <doob@me.com>
parents:
diff changeset
85
16
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 14
diff changeset
86 bool isPartialStringValid (ref NSString partialStringPtr, NSRangePointer proposedSelRangePtr, NSString origString, NSRange origSelRange, ref NSString error)
14
89f3c3ef1fd2 Added the Foundation framework
Jacob Carlborg <doob@me.com>
parents:
diff changeset
87 {
16
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 14
diff changeset
88 id partialString = new objc_object;
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 14
diff changeset
89 id err;
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 14
diff changeset
90
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 14
diff changeset
91 if (error)
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 14
diff changeset
92 err = new objc_object;
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 14
diff changeset
93
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 14
diff changeset
94 bool result = invokeObjcSelf!(bool, "isPartialStringValid:proposedSelectedRange:originalString:originalSelectedRange:errorDescription:", id*, NSRangePointer, NSString, NSRange, id*)(&partialString, proposedSelRangePtr, origString, origSelRange, &err);
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 14
diff changeset
95
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 14
diff changeset
96 if (err)
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 14
diff changeset
97 error = new NSString(err);
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 14
diff changeset
98
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 14
diff changeset
99 if (partialString)
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 14
diff changeset
100 partialStringPtr = new NSString(partialString);
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 14
diff changeset
101
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 14
diff changeset
102 return result;
14
89f3c3ef1fd2 Added the Foundation framework
Jacob Carlborg <doob@me.com>
parents:
diff changeset
103 }
89f3c3ef1fd2 Added the Foundation framework
Jacob Carlborg <doob@me.com>
parents:
diff changeset
104
89f3c3ef1fd2 Added the Foundation framework
Jacob Carlborg <doob@me.com>
parents:
diff changeset
105 Object copyWithZone (NSZone* zone)
89f3c3ef1fd2 Added the Foundation framework
Jacob Carlborg <doob@me.com>
parents:
diff changeset
106 {
89f3c3ef1fd2 Added the Foundation framework
Jacob Carlborg <doob@me.com>
parents:
diff changeset
107 return invokeObjcSelf!(Object, "copyWithZone:", NSZone*)(zone);
89f3c3ef1fd2 Added the Foundation framework
Jacob Carlborg <doob@me.com>
parents:
diff changeset
108 }
89f3c3ef1fd2 Added the Foundation framework
Jacob Carlborg <doob@me.com>
parents:
diff changeset
109
89f3c3ef1fd2 Added the Foundation framework
Jacob Carlborg <doob@me.com>
parents:
diff changeset
110 void encodeWithCoder (NSCoder aCoder)
89f3c3ef1fd2 Added the Foundation framework
Jacob Carlborg <doob@me.com>
parents:
diff changeset
111 {
89f3c3ef1fd2 Added the Foundation framework
Jacob Carlborg <doob@me.com>
parents:
diff changeset
112 return invokeObjcSelf!(void, "encodeWithCoder:", NSCoder)(aCoder);
89f3c3ef1fd2 Added the Foundation framework
Jacob Carlborg <doob@me.com>
parents:
diff changeset
113 }
89f3c3ef1fd2 Added the Foundation framework
Jacob Carlborg <doob@me.com>
parents:
diff changeset
114
89f3c3ef1fd2 Added the Foundation framework
Jacob Carlborg <doob@me.com>
parents:
diff changeset
115 Object initWithCoder (NSCoder aDecoder)
89f3c3ef1fd2 Added the Foundation framework
Jacob Carlborg <doob@me.com>
parents:
diff changeset
116 {
89f3c3ef1fd2 Added the Foundation framework
Jacob Carlborg <doob@me.com>
parents:
diff changeset
117 return invokeObjcSelf!(Object, "initWithCoder:", NSCoder)(aDecoder);
89f3c3ef1fd2 Added the Foundation framework
Jacob Carlborg <doob@me.com>
parents:
diff changeset
118 }
89f3c3ef1fd2 Added the Foundation framework
Jacob Carlborg <doob@me.com>
parents:
diff changeset
119
89f3c3ef1fd2 Added the Foundation framework
Jacob Carlborg <doob@me.com>
parents:
diff changeset
120 this (NSCoder aDecoder)
89f3c3ef1fd2 Added the Foundation framework
Jacob Carlborg <doob@me.com>
parents:
diff changeset
121 {
16
19885b43130e Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents: 14
diff changeset
122 typeof(this).alloc.initWithCoder(aDecoder);
14
89f3c3ef1fd2 Added the Foundation framework
Jacob Carlborg <doob@me.com>
parents:
diff changeset
123 }
89f3c3ef1fd2 Added the Foundation framework
Jacob Carlborg <doob@me.com>
parents:
diff changeset
124 }
89f3c3ef1fd2 Added the Foundation framework
Jacob Carlborg <doob@me.com>
parents:
diff changeset
125