PageRenderTime 24ms CodeModel.GetById 14ms app.highlight 4ms RepoModel.GetById 2ms app.codeStats 0ms

/Frameworks/Foundation/objj.platform/CPDictionary.j

http://github.com/polymar/polish
Unknown | 229 lines | 229 code | 0 blank | 0 comment | 0 complexity | 62747268e47e4030f830fd99e7a22e72 MD5 | raw file
  1i;10;CPObject.ji;14;CPEnumerator.ji;13;CPException.jc;7057;
  2var _1=objj_allocateClassPair(CPEnumerator,"_CPDictionaryValueEnumerator"),_2=_1.isa;
  3class_addIvars(_1,[new objj_ivar("_keyEnumerator"),new objj_ivar("_dictionary")]);
  4objj_registerClassPair(_1);
  5objj_addClassForBundle(_1,objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
  6class_addMethods(_1,[new objj_method(sel_getUid("initWithDictionary:"),function(_3,_4,_5){
  7with(_3){
  8_3=objj_msgSendSuper({receiver:_3,super_class:objj_getClass("CPEnumerator")},"init");
  9if(_3){
 10_keyEnumerator=objj_msgSend(_5,"keyEnumerator");
 11_dictionary=_5;
 12}
 13return _3;
 14}
 15}),new objj_method(sel_getUid("nextObject"),function(_6,_7){
 16with(_6){
 17var _8=objj_msgSend(_keyEnumerator,"nextObject");
 18if(!_8){
 19return nil;
 20}
 21return objj_msgSend(_dictionary,"objectForKey:",_8);
 22}
 23})]);
 24var _1=objj_allocateClassPair(CPObject,"CPDictionary"),_2=_1.isa;
 25objj_registerClassPair(_1);
 26objj_addClassForBundle(_1,objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
 27class_addMethods(_1,[new objj_method(sel_getUid("initWithDictionary:"),function(_9,_a,_b){
 28with(_9){
 29var _c="",_d=objj_msgSend(objj_msgSend(CPDictionary,"alloc"),"init");
 30for(_c in _b._buckets){
 31objj_msgSend(_d,"setObject:forKey:",objj_msgSend(_b,"objectForKey:",_c),_c);
 32}
 33return _d;
 34}
 35}),new objj_method(sel_getUid("initWithObjects:forKeys:"),function(_e,_f,_10,_11){
 36with(_e){
 37_e=objj_msgSendSuper({receiver:_e,super_class:objj_getClass("CPObject")},"init");
 38if(objj_msgSend(_10,"count")!=objj_msgSend(_11,"count")){
 39objj_msgSend(CPException,"raise:reason:",CPInvalidArgumentException,"Counts are different.("+objj_msgSend(_10,"count")+"!="+objj_msgSend(_11,"count")+")");
 40}
 41if(_e){
 42var i=objj_msgSend(_11,"count");
 43while(i--){
 44objj_msgSend(_e,"setObject:forKey:",_10[i],_11[i]);
 45}
 46}
 47return _e;
 48}
 49}),new objj_method(sel_getUid("initWithObjectsAndKeys:"),function(_13,_14,_15){
 50with(_13){
 51var _16=arguments.length;
 52if(_16%2!==0){
 53objj_msgSend(CPException,"raise:reason:",CPInvalidArgumentException,"Key-value count is mismatched. ("+_16+" arguments passed)");
 54}
 55_13=objj_msgSendSuper({receiver:_13,super_class:objj_getClass("CPObject")},"init");
 56if(_13){
 57var _17=2;
 58for(;_17<_16;_17+=2){
 59var _18=arguments[_17];
 60if(_18===nil){
 61break;
 62}
 63objj_msgSend(_13,"setObject:forKey:",_18,arguments[_17+1]);
 64}
 65}
 66return _13;
 67}
 68}),new objj_method(sel_getUid("copy"),function(_19,_1a){
 69with(_19){
 70return objj_msgSend(CPDictionary,"dictionaryWithDictionary:",_19);
 71}
 72}),new objj_method(sel_getUid("count"),function(_1b,_1c){
 73with(_1b){
 74return count;
 75}
 76}),new objj_method(sel_getUid("allKeys"),function(_1d,_1e){
 77with(_1d){
 78return _keys;
 79}
 80}),new objj_method(sel_getUid("allValues"),function(_1f,_20){
 81with(_1f){
 82var _21=_keys.length,_22=[];
 83while(_21--){
 84_22.push(dictionary_getValue(_1f,[_keys[_21]]));
 85}
 86return _22;
 87}
 88}),new objj_method(sel_getUid("keyEnumerator"),function(_23,_24){
 89with(_23){
 90return objj_msgSend(_keys,"objectEnumerator");
 91}
 92}),new objj_method(sel_getUid("objectEnumerator"),function(_25,_26){
 93with(_25){
 94return objj_msgSend(objj_msgSend(_CPDictionaryValueEnumerator,"alloc"),"initWithDictionary:",_25);
 95}
 96}),new objj_method(sel_getUid("isEqualToDictionary:"),function(_27,_28,_29){
 97with(_27){
 98if(count!==objj_msgSend(_29,"count")){
 99return NO;
100}
101var _2a=count;
102while(_2a--){
103var _2b=_keys[_2a],_2c=_buckets[_2b],_2d=_29._buckets[_2b];
104if(_2c===_2d){
105continue;
106}
107if(_2c.isa&&_2d.isa&&objj_msgSend(_2c,"respondsToSelector:",sel_getUid("isEqual:"))&&objj_msgSend(_2c,"isEqual:",_2d)){
108continue;
109}
110return NO;
111}
112return YES;
113}
114}),new objj_method(sel_getUid("objectForKey:"),function(_2e,_2f,_30){
115with(_2e){
116var _31=_buckets[_30];
117return (_31===undefined)?nil:_31;
118}
119}),new objj_method(sel_getUid("removeAllObjects"),function(_32,_33){
120with(_32){
121_keys=[];
122count=0;
123_buckets={};
124}
125}),new objj_method(sel_getUid("removeObjectForKey:"),function(_34,_35,_36){
126with(_34){
127dictionary_removeValue(_34,_36);
128}
129}),new objj_method(sel_getUid("removeObjectsForKeys:"),function(_37,_38,_39){
130with(_37){
131var _3a=_39.length;
132while(_3a--){
133dictionary_removeValue(_37,_39[_3a]);
134}
135}
136}),new objj_method(sel_getUid("setObject:forKey:"),function(_3b,_3c,_3d,_3e){
137with(_3b){
138dictionary_setValue(_3b,_3e,_3d);
139}
140}),new objj_method(sel_getUid("addEntriesFromDictionary:"),function(_3f,_40,_41){
141with(_3f){
142if(!_41){
143return;
144}
145var _42=objj_msgSend(_41,"allKeys"),_43=objj_msgSend(_42,"count");
146while(_43--){
147var key=_42[_43];
148objj_msgSend(_3f,"setObject:forKey:",objj_msgSend(_41,"objectForKey:",key),key);
149}
150}
151}),new objj_method(sel_getUid("description"),function(_45,_46){
152with(_45){
153var _47="CPDictionary {\n";
154var i=_keys.length;
155while(i--){
156_47+=_keys[i]+":";
157var _49=_buckets[_keys[i]];
158if(_49&&_49.isa){
159_47+=objj_msgSend(_49,"description");
160}else{
161_47+=_49;
162}
163_47+="\n";
164}
165_47+="}";
166return _47;
167}
168})]);
169class_addMethods(_2,[new objj_method(sel_getUid("alloc"),function(_4a,_4b){
170with(_4a){
171return new objj_dictionary();
172}
173}),new objj_method(sel_getUid("dictionary"),function(_4c,_4d){
174with(_4c){
175return objj_msgSend(objj_msgSend(_4c,"alloc"),"init");
176}
177}),new objj_method(sel_getUid("dictionaryWithDictionary:"),function(_4e,_4f,_50){
178with(_4e){
179return objj_msgSend(objj_msgSend(_4e,"alloc"),"initWithDictionary:",_50);
180}
181}),new objj_method(sel_getUid("dictionaryWithObject:forKey:"),function(_51,_52,_53,_54){
182with(_51){
183return objj_msgSend(objj_msgSend(_51,"alloc"),"initWithObjects:forKeys:",[_53],[_54]);
184}
185}),new objj_method(sel_getUid("dictionaryWithObjects:forKeys:"),function(_55,_56,_57,_58){
186with(_55){
187return objj_msgSend(objj_msgSend(_55,"alloc"),"initWithObjects:forKeys:",_57,_58);
188}
189}),new objj_method(sel_getUid("dictionaryWithJSObject:"),function(_59,_5a,_5b){
190with(_59){
191return objj_msgSend(_59,"dictionaryWithJSObject:recursively:",_5b,NO);
192}
193}),new objj_method(sel_getUid("dictionaryWithJSObject:recursively:"),function(_5c,_5d,_5e,_5f){
194with(_5c){
195var _60=objj_msgSend(objj_msgSend(_5c,"alloc"),"init");
196for(var key in _5e){
197var _62=_5e[key];
198if(_5f&&_62.constructor===Object){
199_62=objj_msgSend(CPDictionary,"dictionaryWithJSObject:recursively:",_62,YES);
200}
201objj_msgSend(_60,"setObject:forKey:",_62,key);
202}
203return _60;
204}
205}),new objj_method(sel_getUid("dictionaryWithObjectsAndKeys:"),function(_63,_64,_65){
206with(_63){
207arguments[0]=objj_msgSend(_63,"alloc");
208arguments[1]=sel_getUid("initWithObjectsAndKeys:");
209return objj_msgSend.apply(this,arguments);
210}
211})]);
212var _1=objj_getClass("CPDictionary");
213if(!_1){
214objj_exception_throw(new objj_exception(OBJJClassNotFoundException,"*** Could not find definition for class \"CPDictionary\""));
215}
216var _2=_1.isa;
217class_addMethods(_1,[new objj_method(sel_getUid("initWithCoder:"),function(_66,_67,_68){
218with(_66){
219return objj_msgSend(_68,"_decodeDictionaryOfObjectsForKey:","CP.objects");
220}
221}),new objj_method(sel_getUid("encodeWithCoder:"),function(_69,_6a,_6b){
222with(_69){
223objj_msgSend(_6b,"_encodeDictionaryOfObjects:forKey:",_69,"CP.objects");
224}
225})]);
226var _1=objj_allocateClassPair(CPDictionary,"CPMutableDictionary"),_2=_1.isa;
227objj_registerClassPair(_1);
228objj_addClassForBundle(_1,objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
229objj_dictionary.prototype.isa=CPDictionary;