/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

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