PageRenderTime 93ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 1ms

/Frameworks/Debug/Foundation/objj.platform/Foundation.sj

http://github.com/jfahrenkrug/MapKit-HelloWorld
Unknown | 7398 lines | 7348 code | 50 blank | 0 comment | 0 complexity | 7e7ccd4c4b044b8ba53940fea92d2cb5 MD5 | raw file
Possible License(s): LGPL-2.1, CC-BY-3.0
  1. @STATIC;1.0;p;13;CPArray+KVO.ji;9;CPArray.jc;15620;
  2. {
  3. var the_class = objj_getClass("CPObject")
  4. if(!the_class) objj_exception_throw(new objj_exception(OBJJClassNotFoundException, "*** Could not find definition for class \"CPObject\""));
  5. var meta_class = the_class.isa;class_addMethods(the_class, [new objj_method(sel_getUid("mutableArrayValueForKey:"), function $CPObject__mutableArrayValueForKey_(self, _cmd, aKey)
  6. { with(self)
  7. {
  8. return objj_msgSend(objj_msgSend(_CPKVCArray, "alloc"), "initWithKey:forProxyObject:", aKey, self);
  9. }
  10. }), new objj_method(sel_getUid("mutableArrayValueForKeyPath:"), function $CPObject__mutableArrayValueForKeyPath_(self, _cmd, aKeyPath)
  11. { with(self)
  12. {
  13. var dotIndex = aKeyPath.indexOf(".");
  14. if (dotIndex < 0)
  15. return objj_msgSend(self, "mutableArrayValueForKey:", aKeyPath);
  16. var firstPart = aKeyPath.substring(0, dotIndex),
  17. lastPart = aKeyPath.substring(dotIndex+1);
  18. return objj_msgSend(objj_msgSend(self, "valueForKeyPath:", firstPart), "valueForKeyPath:", lastPart);
  19. }
  20. })]);
  21. }
  22. {var the_class = objj_allocateClassPair(CPArray, "_CPKVCArray"),
  23. meta_class = the_class.isa;class_addIvars(the_class, [new objj_ivar("_proxyObject"), new objj_ivar("_key"), new objj_ivar("_insertSEL"), new objj_ivar("_insert"), new objj_ivar("_removeSEL"), new objj_ivar("_remove"), new objj_ivar("_replaceSEL"), new objj_ivar("_replace"), new objj_ivar("_insertManySEL"), new objj_ivar("_insertMany"), new objj_ivar("_removeManySEL"), new objj_ivar("_removeMany"), new objj_ivar("_replaceManySEL"), new objj_ivar("_replaceMany"), new objj_ivar("_objectAtIndexSEL"), new objj_ivar("_objectAtIndex"), new objj_ivar("_countSEL"), new objj_ivar("_count"), new objj_ivar("_accessSEL"), new objj_ivar("_access"), new objj_ivar("_setSEL"), new objj_ivar("_set")]);
  24. objj_registerClassPair(the_class);
  25. objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
  26. class_addMethods(the_class, [new objj_method(sel_getUid("initWithKey:forProxyObject:"), function $_CPKVCArray__initWithKey_forProxyObject_(self, _cmd, aKey, anObject)
  27. { with(self)
  28. {
  29. self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPArray") }, "init");
  30. _key = aKey;
  31. _proxyObject = anObject;
  32. var capitalizedKey = _key.charAt(0).toUpperCase() + _key.substring(1);
  33. _insertSEL = sel_getName("insertObject:in"+capitalizedKey+"AtIndex:");
  34. if (objj_msgSend(_proxyObject, "respondsToSelector:", _insertSEL))
  35. _insert = objj_msgSend(_proxyObject, "methodForSelector:", _insertSEL);
  36. _removeSEL = sel_getName("removeObjectFrom"+capitalizedKey+"AtIndex:");
  37. if (objj_msgSend(_proxyObject, "respondsToSelector:", _removeSEL))
  38. _remove = objj_msgSend(_proxyObject, "methodForSelector:", _removeSEL);
  39. _replaceSEL = sel_getName("replaceObjectFrom"+capitalizedKey+"AtIndex:withObject:");
  40. if (objj_msgSend(_proxyObject, "respondsToSelector:", _replaceSEL))
  41. _replace = objj_msgSend(_proxyObject, "methodForSelector:", _replaceSEL);
  42. _insertManySEL = sel_getName("insertObjects:in"+capitalizedKey+"AtIndexes:");
  43. if (objj_msgSend(_proxyObject, "respondsToSelector:", _insertManySEL))
  44. _insert = objj_msgSend(_proxyObject, "methodForSelector:", _insertManySEL);
  45. _removeManySEL = sel_getName("removeObjectsFrom"+capitalizedKey+"AtIndexes:");
  46. if (objj_msgSend(_proxyObject, "respondsToSelector:", _removeManySEL))
  47. _remove = objj_msgSend(_proxyObject, "methodForSelector:", _removeManySEL);
  48. _replaceManySEL = sel_getName("replaceObjectsFrom"+capitalizedKey+"AtIndexes:withObjects:");
  49. if (objj_msgSend(_proxyObject, "respondsToSelector:", _replaceManySEL))
  50. _replace = objj_msgSend(_proxyObject, "methodForSelector:", _replaceManySEL);
  51. _objectAtIndexSEL = sel_getName("objectIn"+capitalizedKey+"AtIndex:");
  52. if (objj_msgSend(_proxyObject, "respondsToSelector:", _objectAtIndexSEL))
  53. _objectAtIndex = objj_msgSend(_proxyObject, "methodForSelector:", _objectAtIndexSEL);
  54. _countSEL = sel_getName("countOf"+capitalizedKey);
  55. if (objj_msgSend(_proxyObject, "respondsToSelector:", _countSEL))
  56. _count = objj_msgSend(_proxyObject, "methodForSelector:", _countSEL);
  57. _accessSEL = sel_getName(_key);
  58. if (objj_msgSend(_proxyObject, "respondsToSelector:", _accessSEL))
  59. _access = objj_msgSend(_proxyObject, "methodForSelector:", _accessSEL);
  60. _setSEL = sel_getName("set"+capitalizedKey+":");
  61. if (objj_msgSend(_proxyObject, "respondsToSelector:", _setSEL))
  62. _set = objj_msgSend(_proxyObject, "methodForSelector:", _setSEL);
  63. return self;
  64. }
  65. }), new objj_method(sel_getUid("copy"), function $_CPKVCArray__copy(self, _cmd)
  66. { with(self)
  67. {
  68. var theCopy = [],
  69. count = objj_msgSend(self, "count");
  70. for (var i=0; i<count; i++)
  71. objj_msgSend(theCopy, "addObject:", objj_msgSend(self, "objectAtIndex:", i));
  72. return theCopy;
  73. }
  74. }), new objj_method(sel_getUid("_representedObject"), function $_CPKVCArray___representedObject(self, _cmd)
  75. { with(self)
  76. {
  77. if (_access)
  78. return _access(_proxyObject, _accessSEL);
  79. return objj_msgSend(_proxyObject, "valueForKey:", _key);
  80. }
  81. }), new objj_method(sel_getUid("_setRepresentedObject:"), function $_CPKVCArray___setRepresentedObject_(self, _cmd, anObject)
  82. { with(self)
  83. {
  84. if (_set)
  85. return _set(_proxyObject, _setSEL, anObject);
  86. objj_msgSend(_proxyObject, "setValue:forKey:", anObject, _key);
  87. }
  88. }), new objj_method(sel_getUid("count"), function $_CPKVCArray__count(self, _cmd)
  89. { with(self)
  90. {
  91. if (_count)
  92. return _count(_proxyObject, _countSEL);
  93. return objj_msgSend(objj_msgSend(self, "_representedObject"), "count");
  94. }
  95. }), new objj_method(sel_getUid("objectAtIndex:"), function $_CPKVCArray__objectAtIndex_(self, _cmd, anIndex)
  96. { with(self)
  97. {
  98. if(_objectAtIndex)
  99. return _objectAtIndex(_proxyObject, _objectAtIndexSEL, anIndex);
  100. return objj_msgSend(objj_msgSend(self, "_representedObject"), "objectAtIndex:", anIndex);
  101. }
  102. }), new objj_method(sel_getUid("addObject:"), function $_CPKVCArray__addObject_(self, _cmd, anObject)
  103. { with(self)
  104. {
  105. if (_insert)
  106. return _insert(_proxyObject, _insertSEL, anObject, objj_msgSend(self, "count"));
  107. var target = objj_msgSend(objj_msgSend(self, "_representedObject"), "copy");
  108. objj_msgSend(target, "addObject:", anObject);
  109. objj_msgSend(self, "_setRepresentedObject:", target);
  110. }
  111. }), new objj_method(sel_getUid("insertObject:atIndex:"), function $_CPKVCArray__insertObject_atIndex_(self, _cmd, anObject, anIndex)
  112. { with(self)
  113. {
  114. if (_insert)
  115. return _insert(_proxyObject, _insertSEL, anObject, anIndex);
  116. var target = objj_msgSend(objj_msgSend(self, "_representedObject"), "copy");
  117. objj_msgSend(target, "insertObject:atIndex:", anObject, anIndex);
  118. objj_msgSend(self, "_setRepresentedObject:", target);
  119. }
  120. }), new objj_method(sel_getUid("removeLastObject"), function $_CPKVCArray__removeLastObject(self, _cmd)
  121. { with(self)
  122. {
  123. if(_remove)
  124. return _remove(_proxyObject, _removeSEL, objj_msgSend(self, "count")-1);
  125. var target = objj_msgSend(objj_msgSend(self, "_representedObject"), "copy");
  126. objj_msgSend(target, "removeLastObject");
  127. objj_msgSend(self, "_setRepresentedObject:", target);
  128. }
  129. }), new objj_method(sel_getUid("removeObjectAtIndex:"), function $_CPKVCArray__removeObjectAtIndex_(self, _cmd, anIndex)
  130. { with(self)
  131. {
  132. if(_remove)
  133. return _remove(_proxyObject, _removeSEL, anIndex);
  134. var target = objj_msgSend(objj_msgSend(self, "_representedObject"), "copy");
  135. objj_msgSend(target, "removeObjectAtIndex:", anIndex);
  136. objj_msgSend(self, "_setRepresentedObject:", target);
  137. }
  138. }), new objj_method(sel_getUid("replaceObjectAtIndex:withObject:"), function $_CPKVCArray__replaceObjectAtIndex_withObject_(self, _cmd, anIndex, anObject)
  139. { with(self)
  140. {
  141. if(_replace)
  142. return _replace(_proxyObject, _replaceSEL, anIndex, anObject);
  143. var target = objj_msgSend(objj_msgSend(self, "_representedObject"), "copy");
  144. objj_msgSend(target, "replaceObjectAtIndex:withObject:", anIndex, anObject);
  145. objj_msgSend(self, "_setRepresentedObject:", target);
  146. }
  147. }), new objj_method(sel_getUid("objectsAtIndexes:"), function $_CPKVCArray__objectsAtIndexes_(self, _cmd, indexes)
  148. { with(self)
  149. {
  150. var index = objj_msgSend(indexes, "firstIndex"),
  151. objects = [];
  152. while(index != CPNotFound)
  153. {
  154. objj_msgSend(objects, "addObject:", objj_msgSend(self, "objectAtIndex:", index));
  155. index = objj_msgSend(indexes, "indexGreaterThanIndex:", index);
  156. }
  157. return objects;
  158. }
  159. })]);
  160. class_addMethods(meta_class, [new objj_method(sel_getUid("alloc"), function $_CPKVCArray__alloc(self, _cmd)
  161. { with(self)
  162. {
  163. var a = [];
  164. a.isa = self;
  165. var ivars = class_copyIvarList(self),
  166. count = ivars.length;
  167. while (count--)
  168. a[ivar_getName(ivars[count])] = nil;
  169. return a;
  170. }
  171. })]);
  172. }
  173. {
  174. var the_class = objj_getClass("CPArray")
  175. if(!the_class) objj_exception_throw(new objj_exception(OBJJClassNotFoundException, "*** Could not find definition for class \"CPArray\""));
  176. var meta_class = the_class.isa;class_addMethods(the_class, [new objj_method(sel_getUid("valueForKey:"), function $CPArray__valueForKey_(self, _cmd, aKey)
  177. { with(self)
  178. {
  179. if (aKey.indexOf("@") === 0)
  180. {
  181. if (aKey.indexOf(".") !== -1)
  182. objj_msgSend(CPException, "raise:reason:", CPInvalidArgumentException, "called valueForKey: on an array with a complex key ("+aKey+"). use valueForKeyPath:");
  183. if (aKey == "@count")
  184. return length;
  185. return nil;
  186. }
  187. else
  188. {
  189. var newArray = [],
  190. enumerator = objj_msgSend(self, "objectEnumerator"),
  191. object;
  192. while ((object = objj_msgSend(enumerator, "nextObject")) !== nil)
  193. {
  194. var value = objj_msgSend(object, "valueForKey:", aKey);
  195. if (value === nil || value === undefined)
  196. value = objj_msgSend(CPNull, "null");
  197. newArray.push(value);
  198. }
  199. return newArray;
  200. }
  201. }
  202. }), new objj_method(sel_getUid("valueForKeyPath:"), function $CPArray__valueForKeyPath_(self, _cmd, aKeyPath)
  203. { with(self)
  204. {
  205. if (aKeyPath.indexOf("@") === 0)
  206. {
  207. var dotIndex = aKeyPath.indexOf("."),
  208. operator = aKeyPath.substring(1, dotIndex),
  209. parameter = aKeyPath.substring(dotIndex+1);
  210. if (kvoOperators[operator])
  211. return kvoOperators[operator](self, _cmd, parameter);
  212. return nil;
  213. }
  214. else
  215. {
  216. var newArray = [],
  217. enumerator = objj_msgSend(self, "objectEnumerator"),
  218. object;
  219. while ((object = objj_msgSend(enumerator, "nextObject")) !== nil)
  220. {
  221. var value = objj_msgSend(object, "valueForKeyPath:", aKeyPath);
  222. if (value === nil || value === undefined)
  223. value = objj_msgSend(CPNull, "null");
  224. newArray.push(value);
  225. }
  226. return newArray;
  227. }
  228. }
  229. }), new objj_method(sel_getUid("setValue:forKey:"), function $CPArray__setValue_forKey_(self, _cmd, aValue, aKey)
  230. { with(self)
  231. {
  232. var enumerator = objj_msgSend(self, "objectEnumerator"),
  233. object;
  234. while (object = objj_msgSend(enumerator, "nextObject"))
  235. objj_msgSend(object, "setValue:forKey:", aValue, aKey);
  236. }
  237. }), new objj_method(sel_getUid("setValue:forKeyPath:"), function $CPArray__setValue_forKeyPath_(self, _cmd, aValue, aKeyPath)
  238. { with(self)
  239. {
  240. var enumerator = objj_msgSend(self, "objectEnumerator"),
  241. object;
  242. while (object = objj_msgSend(enumerator, "nextObject"))
  243. objj_msgSend(object, "setValue:forKeyPath:", aValue, aKeyPath);
  244. }
  245. })]);
  246. }
  247. var kvoOperators = [];
  248. kvoOperators["avg"] = avgOperator= function(self, _cmd, param)
  249. {
  250. var objects = objj_msgSend(self, "valueForKeyPath:", param),
  251. length = objj_msgSend(objects, "count"),
  252. index = length;
  253. average = 0.0;
  254. if (!length)
  255. return 0;
  256. while(index--)
  257. average += objj_msgSend(objects[index], "doubleValue");
  258. return average / length;
  259. }
  260. kvoOperators["max"] = maxOperator= function(self, _cmd, param)
  261. {
  262. var objects = objj_msgSend(self, "valueForKeyPath:", param),
  263. index = objj_msgSend(objects, "count") - 1,
  264. max = objj_msgSend(objects, "lastObject");
  265. while (index--)
  266. {
  267. var item = objects[index];
  268. if (objj_msgSend(max, "compare:", item) < 0)
  269. max = item;
  270. }
  271. return max;
  272. }
  273. kvoOperators["min"] = minOperator= function(self, _cmd, param)
  274. {
  275. var objects = objj_msgSend(self, "valueForKeyPath:", param),
  276. index = objj_msgSend(objects, "count") - 1,
  277. min = objj_msgSend(objects, "lastObject");
  278. while (index--)
  279. {
  280. var item = objects[index];
  281. if (objj_msgSend(min, "compare:", item) > 0)
  282. min = item;
  283. }
  284. return min;
  285. }
  286. kvoOperators["count"] = countOperator= function(self, _cmd, param)
  287. {
  288. return objj_msgSend(self, "count");
  289. }
  290. kvoOperators["sum"] = sumOperator= function(self, _cmd, param)
  291. {
  292. var objects = objj_msgSend(self, "valueForKeyPath:", param),
  293. index = objj_msgSend(objects, "count"),
  294. sum = 0.0;
  295. while(index--)
  296. sum += objj_msgSend(objects[index], "doubleValue");
  297. return sum;
  298. }
  299. {
  300. var the_class = objj_getClass("CPArray")
  301. if(!the_class) objj_exception_throw(new objj_exception(OBJJClassNotFoundException, "*** Could not find definition for class \"CPArray\""));
  302. var meta_class = the_class.isa;class_addMethods(the_class, [new objj_method(sel_getUid("addObserver:toObjectsAtIndexes:forKeyPath:options:context:"), function $CPArray__addObserver_toObjectsAtIndexes_forKeyPath_options_context_(self, _cmd, anObserver, indexes, aKeyPath, options, context)
  303. { with(self)
  304. {
  305. var index = objj_msgSend(indexes, "firstIndex");
  306. while (index >= 0)
  307. {
  308. objj_msgSend(self[index], "addObserver:forKeyPath:options:context:", anObserver, aKeyPath, options, context);
  309. index = objj_msgSend(indexes, "indexGreaterThanIndex:", index);
  310. }
  311. }
  312. }), new objj_method(sel_getUid("removeObserver:fromObjectsAtIndexes:forKeyPath:"), function $CPArray__removeObserver_fromObjectsAtIndexes_forKeyPath_(self, _cmd, anObserver, indexes, aKeyPath)
  313. { with(self)
  314. {
  315. var index = objj_msgSend(indexes, "firstIndex");
  316. while (index >= 0)
  317. {
  318. objj_msgSend(self[index], "removeObserver:forKeyPath:", anObserver, aKeyPath);
  319. index = objj_msgSend(indexes, "indexGreaterThanIndex:", index);
  320. }
  321. }
  322. }), new objj_method(sel_getUid("addObserver:forKeyPath:options:context:"), function $CPArray__addObserver_forKeyPath_options_context_(self, _cmd, observer, aKeyPath, options, context)
  323. { with(self)
  324. {
  325. if (objj_msgSend(isa, "instanceMethodForSelector:", _cmd) === objj_msgSend(CPArray, "instanceMethodForSelector:", _cmd))
  326. objj_msgSend(CPException, "raise:reason:", CPInvalidArgumentException, "Unsupported method on CPArray");
  327. else
  328. objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPArray").super_class }, "addObserver:forKeyPath:options:context:", observer, aKeyPath, options, context);
  329. }
  330. }), new objj_method(sel_getUid("removeObserver:forKeyPath:"), function $CPArray__removeObserver_forKeyPath_(self, _cmd, observer, aKeyPath)
  331. { with(self)
  332. {
  333. if (objj_msgSend(isa, "instanceMethodForSelector:", _cmd) === objj_msgSend(CPArray, "instanceMethodForSelector:", _cmd))
  334. objj_msgSend(CPException, "raise:reason:", CPInvalidArgumentException, "Unsupported method on CPArray");
  335. else
  336. objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPArray").super_class }, "removeObserver:forKeyPath:", observer, aKeyPath);
  337. }
  338. })]);
  339. }
  340. p;9;CPArray.ji;10;CPObject.ji;9;CPRange.ji;14;CPEnumerator.ji;18;CPSortDescriptor.ji;13;CPException.jc;25556;
  341. {var the_class = objj_allocateClassPair(CPEnumerator, "_CPArrayEnumerator"),
  342. meta_class = the_class.isa;class_addIvars(the_class, [new objj_ivar("_array"), new objj_ivar("_index")]);
  343. objj_registerClassPair(the_class);
  344. objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
  345. class_addMethods(the_class, [new objj_method(sel_getUid("initWithArray:"), function $_CPArrayEnumerator__initWithArray_(self, _cmd, anArray)
  346. { with(self)
  347. {
  348. self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPEnumerator") }, "init");
  349. if (self)
  350. {
  351. _array = anArray;
  352. _index = -1;
  353. }
  354. return self;
  355. }
  356. }), new objj_method(sel_getUid("nextObject"), function $_CPArrayEnumerator__nextObject(self, _cmd)
  357. { with(self)
  358. {
  359. if (++_index >= objj_msgSend(_array, "count"))
  360. return nil;
  361. return objj_msgSend(_array, "objectAtIndex:", _index);
  362. }
  363. })]);
  364. }
  365. {var the_class = objj_allocateClassPair(CPEnumerator, "_CPReverseArrayEnumerator"),
  366. meta_class = the_class.isa;class_addIvars(the_class, [new objj_ivar("_array"), new objj_ivar("_index")]);
  367. objj_registerClassPair(the_class);
  368. objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
  369. class_addMethods(the_class, [new objj_method(sel_getUid("initWithArray:"), function $_CPReverseArrayEnumerator__initWithArray_(self, _cmd, anArray)
  370. { with(self)
  371. {
  372. self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPEnumerator") }, "init");
  373. if (self)
  374. {
  375. _array = anArray;
  376. _index = objj_msgSend(_array, "count");
  377. }
  378. return self;
  379. }
  380. }), new objj_method(sel_getUid("nextObject"), function $_CPReverseArrayEnumerator__nextObject(self, _cmd)
  381. { with(self)
  382. {
  383. if (--_index < 0)
  384. return nil;
  385. return objj_msgSend(_array, "objectAtIndex:", _index);
  386. }
  387. })]);
  388. }
  389. {var the_class = objj_allocateClassPair(CPObject, "CPArray"),
  390. meta_class = the_class.isa;objj_registerClassPair(the_class);
  391. objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
  392. class_addMethods(the_class, [new objj_method(sel_getUid("init"), function $CPArray__init(self, _cmd)
  393. { with(self)
  394. {
  395. return self;
  396. }
  397. }), new objj_method(sel_getUid("initWithArray:"), function $CPArray__initWithArray_(self, _cmd, anArray)
  398. { with(self)
  399. {
  400. self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPObject") }, "init");
  401. if (self)
  402. objj_msgSend(self, "setArray:", anArray);
  403. return self;
  404. }
  405. }), new objj_method(sel_getUid("initWithArray:copyItems:"), function $CPArray__initWithArray_copyItems_(self, _cmd, anArray, copyItems)
  406. { with(self)
  407. {
  408. if (!copyItems)
  409. return objj_msgSend(self, "initWithArray:", anArray);
  410. self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPObject") }, "init");
  411. if (self)
  412. {
  413. var index = 0,
  414. count = objj_msgSend(anArray, "count");
  415. for(; index < count; ++i)
  416. {
  417. if (anArray[i].isa)
  418. self[i] = objj_msgSend(anArray, "copy");
  419. else
  420. self[i] = anArray;
  421. }
  422. }
  423. return self;
  424. }
  425. }), new objj_method(sel_getUid("initWithObjects:"), function $CPArray__initWithObjects_(self, _cmd, anArray)
  426. { with(self)
  427. {
  428. var i = 2,
  429. argument;
  430. for(; i < arguments.length && (argument = arguments[i]) != nil; ++i)
  431. push(argument);
  432. return self;
  433. }
  434. }), new objj_method(sel_getUid("initWithObjects:count:"), function $CPArray__initWithObjects_count_(self, _cmd, objects, aCount)
  435. { with(self)
  436. {
  437. self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPObject") }, "init");
  438. if (self)
  439. {
  440. var index = 0;
  441. for(; index < aCount; ++index)
  442. push(objects[index]);
  443. }
  444. return self;
  445. }
  446. }), new objj_method(sel_getUid("hash"), function $CPArray__hash(self, _cmd)
  447. { with(self)
  448. {
  449. if (self.__address == nil)
  450. self.__address = _objj_generateObjectHash();
  451. return self.__address;
  452. }
  453. }), new objj_method(sel_getUid("containsObject:"), function $CPArray__containsObject_(self, _cmd, anObject)
  454. { with(self)
  455. {
  456. return objj_msgSend(self, "indexOfObject:", anObject) != CPNotFound;
  457. }
  458. }), new objj_method(sel_getUid("count"), function $CPArray__count(self, _cmd)
  459. { with(self)
  460. {
  461. return length;
  462. }
  463. }), new objj_method(sel_getUid("indexOfObject:"), function $CPArray__indexOfObject_(self, _cmd, anObject)
  464. { with(self)
  465. {
  466. if (anObject === nil)
  467. return CPNotFound;
  468. var i = 0,
  469. count = length;
  470. if (anObject.isa)
  471. {
  472. for(; i < count; ++i)
  473. if(objj_msgSend(self[i], "isEqual:", anObject))
  474. return i;
  475. }
  476. else if (self.indexOf)
  477. return indexOf(anObject);
  478. else
  479. for(; i < count; ++i)
  480. if(self[i] == anObject)
  481. return i;
  482. return CPNotFound;
  483. }
  484. }), new objj_method(sel_getUid("indexOfObject:inRange:"), function $CPArray__indexOfObject_inRange_(self, _cmd, anObject, aRange)
  485. { with(self)
  486. {
  487. if (anObject === nil)
  488. return CPNotFound;
  489. var i = aRange.location,
  490. count = MIN(CPMaxRange(aRange), length);
  491. if (anObject.isa)
  492. {
  493. for(; i < count; ++i)
  494. if(objj_msgSend(self[i], "isEqual:", anObject))
  495. return i;
  496. }
  497. else
  498. for(; i < count; ++i)
  499. if(self[i] == anObject)
  500. return i;
  501. return CPNotFound;
  502. }
  503. }), new objj_method(sel_getUid("indexOfObjectIdenticalTo:"), function $CPArray__indexOfObjectIdenticalTo_(self, _cmd, anObject)
  504. { with(self)
  505. {
  506. if (anObject === nil)
  507. return CPNotFound;
  508. if (self.indexOf)
  509. return indexOf(anObject);
  510. else
  511. {
  512. var index = 0,
  513. count = length;
  514. for(; index < count; ++index)
  515. if(self[index] == anObject)
  516. return index;
  517. }
  518. return CPNotFound;
  519. }
  520. }), new objj_method(sel_getUid("indexOfObjectIdenticalTo:inRange:"), function $CPArray__indexOfObjectIdenticalTo_inRange_(self, _cmd, anObject, aRange)
  521. { with(self)
  522. {
  523. if (anObject === nil)
  524. return CPNotFound;
  525. if (self.indexOf)
  526. {
  527. var index = indexOf(anObject, aRange.location);
  528. if (CPLocationInRange(index, aRange))
  529. return index;
  530. }
  531. else
  532. {
  533. var index = aRange.location,
  534. count = MIN(CPMaxRange(aRange), length);
  535. for(; index < count; ++index)
  536. if(self[index] == anObject)
  537. return index;
  538. }
  539. return CPNotFound;
  540. }
  541. }), new objj_method(sel_getUid("indexOfObject:sortedBySelector:"), function $CPArray__indexOfObject_sortedBySelector_(self, _cmd, anObject, aSelector)
  542. { with(self)
  543. {
  544. return objj_msgSend(self, "indexOfObject:sortedByFunction:", anObject, function(lhs, rhs) { objj_msgSend(lhs, aSelector, rhs); });
  545. }
  546. }), new objj_method(sel_getUid("indexOfObject:sortedByFunction:"), function $CPArray__indexOfObject_sortedByFunction_(self, _cmd, anObject, aFunction)
  547. { with(self)
  548. {
  549. return objj_msgSend(self, "indexOfObject:sortedByFunction:context:", anObject, aFunction, nil);
  550. }
  551. }), new objj_method(sel_getUid("indexOfObject:sortedByFunction:context:"), function $CPArray__indexOfObject_sortedByFunction_context_(self, _cmd, anObject, aFunction, aContext)
  552. { with(self)
  553. {
  554. if (!aFunction || anObject === undefined)
  555. return CPNotFound;
  556. var mid, c, first = 0, last = length - 1;
  557. while (first <= last)
  558. {
  559. mid = FLOOR((first + last) / 2);
  560. c = aFunction(anObject, self[mid], aContext);
  561. if (c > 0)
  562. first = mid + 1;
  563. else if (c < 0)
  564. last = mid - 1;
  565. else
  566. {
  567. while (mid < length - 1 && aFunction(anObject, self[mid+1], aContext) == CPOrderedSame)
  568. mid++;
  569. return mid;
  570. }
  571. }
  572. return CPNotFound;
  573. }
  574. }), new objj_method(sel_getUid("indexOfObject:sortedByDescriptors:"), function $CPArray__indexOfObject_sortedByDescriptors_(self, _cmd, anObject, descriptors)
  575. { with(self)
  576. {
  577. objj_msgSend(self, "indexOfObject:sortedByFunction:", anObject, function(lhs, rhs)
  578. {
  579. var i = 0,
  580. count = objj_msgSend(descriptors, "count"),
  581. result = CPOrderedSame;
  582. while (i < count)
  583. if((result = objj_msgSend(descriptors[i++], "compareObject:withObject:", lhs, rhs)) != CPOrderedSame)
  584. return result;
  585. return result;
  586. });
  587. }
  588. }), new objj_method(sel_getUid("lastObject"), function $CPArray__lastObject(self, _cmd)
  589. { with(self)
  590. {
  591. var count = objj_msgSend(self, "count");
  592. if (!count) return nil;
  593. return self[count - 1];
  594. }
  595. }), new objj_method(sel_getUid("objectAtIndex:"), function $CPArray__objectAtIndex_(self, _cmd, anIndex)
  596. { with(self)
  597. {
  598. return self[anIndex];
  599. }
  600. }), new objj_method(sel_getUid("objectsAtIndexes:"), function $CPArray__objectsAtIndexes_(self, _cmd, indexes)
  601. { with(self)
  602. {
  603. var index = objj_msgSend(indexes, "firstIndex"),
  604. objects = [];
  605. while(index != CPNotFound)
  606. {
  607. objj_msgSend(objects, "addObject:", self[index]);
  608. index = objj_msgSend(indexes, "indexGreaterThanIndex:", index);
  609. }
  610. return objects;
  611. }
  612. }), new objj_method(sel_getUid("objectEnumerator"), function $CPArray__objectEnumerator(self, _cmd)
  613. { with(self)
  614. {
  615. return objj_msgSend(objj_msgSend(_CPArrayEnumerator, "alloc"), "initWithArray:", self);
  616. }
  617. }), new objj_method(sel_getUid("reverseObjectEnumerator"), function $CPArray__reverseObjectEnumerator(self, _cmd)
  618. { with(self)
  619. {
  620. return objj_msgSend(objj_msgSend(_CPReverseArrayEnumerator, "alloc"), "initWithArray:", self);
  621. }
  622. }), new objj_method(sel_getUid("makeObjectsPerformSelector:"), function $CPArray__makeObjectsPerformSelector_(self, _cmd, aSelector)
  623. { with(self)
  624. {
  625. if (!aSelector)
  626. objj_msgSend(CPException, "raise:reason:", CPInvalidArgumentException, "makeObjectsPerformSelector: 'aSelector' can't be nil");
  627. var index = 0,
  628. count = length;
  629. for(; index < count; ++index)
  630. objj_msgSend(self[index], aSelector);
  631. }
  632. }), new objj_method(sel_getUid("makeObjectsPerformSelector:withObject:"), function $CPArray__makeObjectsPerformSelector_withObject_(self, _cmd, aSelector, anObject)
  633. { with(self)
  634. {
  635. if (!aSelector)
  636. objj_msgSend(CPException, "raise:reason:", CPInvalidArgumentException, "makeObjectsPerformSelector:withObject 'aSelector' can't be nil");
  637. var index = 0,
  638. count = length;
  639. for(; index < count; ++index)
  640. objj_msgSend(self[index], aSelector, anObject);
  641. }
  642. }), new objj_method(sel_getUid("firstObjectCommonWithArray:"), function $CPArray__firstObjectCommonWithArray_(self, _cmd, anArray)
  643. { with(self)
  644. {
  645. if (!objj_msgSend(anArray, "count") || !objj_msgSend(self, "count"))
  646. return nil;
  647. var i = 0,
  648. count = objj_msgSend(self, "count");
  649. for(; i < count; ++i)
  650. if(objj_msgSend(anArray, "containsObject:", self[i]))
  651. return self[i];
  652. return nil;
  653. }
  654. }), new objj_method(sel_getUid("isEqualToArray:"), function $CPArray__isEqualToArray_(self, _cmd, anArray)
  655. { with(self)
  656. {
  657. if (self === anArray)
  658. return YES;
  659. if(length != anArray.length)
  660. return NO;
  661. var index = 0,
  662. count = objj_msgSend(self, "count");
  663. for(; index < count; ++index)
  664. {
  665. var lhs = self[index],
  666. rhs = anArray[index];
  667. if (lhs !== rhs && (!lhs.isa || !rhs.isa || !objj_msgSend(lhs, "isEqual:", rhs)))
  668. return NO;
  669. }
  670. return YES;
  671. }
  672. }), new objj_method(sel_getUid("isEqual:"), function $CPArray__isEqual_(self, _cmd, anObject)
  673. { with(self)
  674. {
  675. if (self === anObject)
  676. return YES;
  677. if(!objj_msgSend(anObject, "isKindOfClass:", objj_msgSend(CPArray, "class")))
  678. return NO;
  679. return objj_msgSend(self, "isEqualToArray:", anObject);
  680. }
  681. }), new objj_method(sel_getUid("arrayByAddingObject:"), function $CPArray__arrayByAddingObject_(self, _cmd, anObject)
  682. { with(self)
  683. {
  684. if (anObject === nil || anObject === undefined)
  685. objj_msgSend(CPException, "raise:reason:", CPInvalidArgumentException, "arrayByAddingObject: object can't be nil");
  686. var array = objj_msgSend(self, "copy");
  687. array.push(anObject);
  688. return array;
  689. }
  690. }), new objj_method(sel_getUid("arrayByAddingObjectsFromArray:"), function $CPArray__arrayByAddingObjectsFromArray_(self, _cmd, anArray)
  691. { with(self)
  692. {
  693. return slice(0).concat(anArray);
  694. }
  695. }), new objj_method(sel_getUid("subarrayWithRange:"), function $CPArray__subarrayWithRange_(self, _cmd, aRange)
  696. { with(self)
  697. {
  698. if (aRange.location < 0 || CPMaxRange(aRange) > length)
  699. objj_msgSend(CPException, "raise:reason:", CPRangeException, "subarrayWithRange: aRange out of bounds");
  700. return slice(aRange.location, CPMaxRange(aRange));
  701. }
  702. }), new objj_method(sel_getUid("sortedArrayUsingDescriptors:"), function $CPArray__sortedArrayUsingDescriptors_(self, _cmd, descriptors)
  703. { with(self)
  704. {
  705. var sorted = objj_msgSend(self, "copy");
  706. objj_msgSend(sorted, "sortUsingDescriptors:", descriptors);
  707. return sorted;
  708. }
  709. }), new objj_method(sel_getUid("sortedArrayUsingFunction:"), function $CPArray__sortedArrayUsingFunction_(self, _cmd, aFunction)
  710. { with(self)
  711. {
  712. return objj_msgSend(self, "sortedArrayUsingFunction:context:", aFunction, nil);
  713. }
  714. }), new objj_method(sel_getUid("sortedArrayUsingFunction:context:"), function $CPArray__sortedArrayUsingFunction_context_(self, _cmd, aFunction, aContext)
  715. { with(self)
  716. {
  717. var sorted = objj_msgSend(self, "copy");
  718. objj_msgSend(sorted, "sortUsingFunction:context:", aFunction, aContext);
  719. return sorted;
  720. }
  721. }), new objj_method(sel_getUid("sortedArrayUsingSelector:"), function $CPArray__sortedArrayUsingSelector_(self, _cmd, aSelector)
  722. { with(self)
  723. {
  724. var sorted = objj_msgSend(self, "copy")
  725. objj_msgSend(sorted, "sortUsingSelector:", aSelector);
  726. return sorted;
  727. }
  728. }), new objj_method(sel_getUid("componentsJoinedByString:"), function $CPArray__componentsJoinedByString_(self, _cmd, aString)
  729. { with(self)
  730. {
  731. return join(aString);
  732. }
  733. }), new objj_method(sel_getUid("description"), function $CPArray__description(self, _cmd)
  734. { with(self)
  735. {
  736. var i = 0,
  737. count = objj_msgSend(self, "count"),
  738. description = '(';
  739. for(; i < count; ++i)
  740. {
  741. if (self[i].isa) description += objj_msgSend(self[i], "description");
  742. else description += self[i];
  743. if (i != count - 1) description += ", ";
  744. }
  745. return description + ')';
  746. }
  747. }), new objj_method(sel_getUid("pathsMatchingExtensions:"), function $CPArray__pathsMatchingExtensions_(self, _cmd, filterTypes)
  748. { with(self)
  749. {
  750. var index = 0,
  751. count = objj_msgSend(self, "count"),
  752. array = [];
  753. for(; index < count; ++index)
  754. if (self[index].isa && objj_msgSend(self[index], "isKindOfClass:", objj_msgSend(CPString, "class")) && objj_msgSend(filterTypes, "containsObject:", objj_msgSend(self[index], "pathExtension")))
  755. array.push(self[index]);
  756. return array;
  757. }
  758. }), new objj_method(sel_getUid("setValue:forKey:"), function $CPArray__setValue_forKey_(self, _cmd, aValue, aKey)
  759. { with(self)
  760. {
  761. var i = 0,
  762. count = objj_msgSend(self, "count");
  763. for(; i < count; ++i)
  764. objj_msgSend(self[i], "setValue:forKey:", aValue, aKey);
  765. }
  766. }), new objj_method(sel_getUid("valueForKey:"), function $CPArray__valueForKey_(self, _cmd, aKey)
  767. { with(self)
  768. {
  769. var i = 0,
  770. count = objj_msgSend(self, "count"),
  771. array = [];
  772. for(; i < count; ++i)
  773. array.push(objj_msgSend(self[i], "valueForKey:", aKey));
  774. return array;
  775. }
  776. }), new objj_method(sel_getUid("copy"), function $CPArray__copy(self, _cmd)
  777. { with(self)
  778. {
  779. return slice(0);
  780. }
  781. })]);
  782. class_addMethods(meta_class, [new objj_method(sel_getUid("alloc"), function $CPArray__alloc(self, _cmd)
  783. { with(self)
  784. {
  785. return [];
  786. }
  787. }), new objj_method(sel_getUid("array"), function $CPArray__array(self, _cmd)
  788. { with(self)
  789. {
  790. return objj_msgSend(objj_msgSend(self, "alloc"), "init");
  791. }
  792. }), new objj_method(sel_getUid("arrayWithArray:"), function $CPArray__arrayWithArray_(self, _cmd, anArray)
  793. { with(self)
  794. {
  795. return objj_msgSend(objj_msgSend(self, "alloc"), "initWithArray:", anArray);
  796. }
  797. }), new objj_method(sel_getUid("arrayWithObject:"), function $CPArray__arrayWithObject_(self, _cmd, anObject)
  798. { with(self)
  799. {
  800. return objj_msgSend(objj_msgSend(self, "alloc"), "initWithObjects:", anObject);
  801. }
  802. }), new objj_method(sel_getUid("arrayWithObjects:"), function $CPArray__arrayWithObjects_(self, _cmd, anObject)
  803. { with(self)
  804. {
  805. var i = 2,
  806. array = objj_msgSend(objj_msgSend(self, "alloc"), "init"),
  807. argument;
  808. for(; i < arguments.length && (argument = arguments[i]) != nil; ++i)
  809. array.push(argument);
  810. return array;
  811. }
  812. }), new objj_method(sel_getUid("arrayWithObjects:count:"), function $CPArray__arrayWithObjects_count_(self, _cmd, objects, aCount)
  813. { with(self)
  814. {
  815. return objj_msgSend(objj_msgSend(self, "alloc"), "initWithObjects:count:", objects, aCount);
  816. }
  817. })]);
  818. }
  819. {
  820. var the_class = objj_getClass("CPArray")
  821. if(!the_class) objj_exception_throw(new objj_exception(OBJJClassNotFoundException, "*** Could not find definition for class \"CPArray\""));
  822. var meta_class = the_class.isa;class_addMethods(the_class, [new objj_method(sel_getUid("initWithCapacity:"), function $CPArray__initWithCapacity_(self, _cmd, aCapacity)
  823. { with(self)
  824. {
  825. return self;
  826. }
  827. }), new objj_method(sel_getUid("addObject:"), function $CPArray__addObject_(self, _cmd, anObject)
  828. { with(self)
  829. {
  830. push(anObject);
  831. }
  832. }), new objj_method(sel_getUid("addObjectsFromArray:"), function $CPArray__addObjectsFromArray_(self, _cmd, anArray)
  833. { with(self)
  834. {
  835. splice.apply(self, [length, 0].concat(anArray));
  836. }
  837. }), new objj_method(sel_getUid("insertObject:atIndex:"), function $CPArray__insertObject_atIndex_(self, _cmd, anObject, anIndex)
  838. { with(self)
  839. {
  840. splice(anIndex, 0, anObject);
  841. }
  842. }), new objj_method(sel_getUid("insertObjects:atIndexes:"), function $CPArray__insertObjects_atIndexes_(self, _cmd, objects, indexes)
  843. { with(self)
  844. {
  845. var indexesCount = objj_msgSend(indexes, "count"),
  846. objectsCount = objj_msgSend(objects, "count");
  847. if(indexesCount !== objectsCount)
  848. objj_msgSend(CPException, "raise:reason:", CPRangeException, "the counts of the passed-in array (" + objectsCount + ") and index set (" + indexesCount + ") must be identical.");
  849. var lastIndex = objj_msgSend(indexes, "lastIndex");
  850. if(lastIndex >= objj_msgSend(self, "count") + indexesCount)
  851. objj_msgSend(CPException, "raise:reason:", CPRangeException, "the last index (" + lastIndex + ") must be less than the sum of the original count (" + objj_msgSend(self, "count") + ") and the insertion count (" + indexesCount + ").");
  852. var index = 0,
  853. currentIndex = objj_msgSend(indexes, "firstIndex");
  854. for (; index < objectsCount; ++index, currentIndex = objj_msgSend(indexes, "indexGreaterThanIndex:", currentIndex))
  855. objj_msgSend(self, "insertObject:atIndex:", objects[index], currentIndex);
  856. }
  857. }), new objj_method(sel_getUid("replaceObjectAtIndex:withObject:"), function $CPArray__replaceObjectAtIndex_withObject_(self, _cmd, anIndex, anObject)
  858. { with(self)
  859. {
  860. self[anIndex] = anObject;
  861. }
  862. }), new objj_method(sel_getUid("replaceObjectsAtIndexes:withObjects:"), function $CPArray__replaceObjectsAtIndexes_withObjects_(self, _cmd, anIndexSet, objects)
  863. { with(self)
  864. {
  865. var i = 0,
  866. index = objj_msgSend(anIndexSet, "firstIndex");
  867. while(index != CPNotFound)
  868. {
  869. objj_msgSend(self, "replaceObjectAtIndex:withObject:", index, objects[i++]);
  870. index = objj_msgSend(anIndexSet, "indexGreaterThanIndex:", index);
  871. }
  872. }
  873. }), new objj_method(sel_getUid("replaceObjectsInRange:withObjectsFromArray:range:"), function $CPArray__replaceObjectsInRange_withObjectsFromArray_range_(self, _cmd, aRange, anArray, otherRange)
  874. { with(self)
  875. {
  876. if (!otherRange.location && otherRange.length == objj_msgSend(anArray, "count"))
  877. objj_msgSend(self, "replaceObjectsInRange:withObjectsFromArray:", aRange, anArray);
  878. else
  879. splice.apply(self, [aRange.location, aRange.length].concat(objj_msgSend(anArray, "subarrayWithRange:", otherRange)));
  880. }
  881. }), new objj_method(sel_getUid("replaceObjectsInRange:withObjectsFromArray:"), function $CPArray__replaceObjectsInRange_withObjectsFromArray_(self, _cmd, aRange, anArray)
  882. { with(self)
  883. {
  884. splice.apply(self, [aRange.location, aRange.length].concat(anArray));
  885. }
  886. }), new objj_method(sel_getUid("setArray:"), function $CPArray__setArray_(self, _cmd, anArray)
  887. { with(self)
  888. {
  889. if(self == anArray) return;
  890. splice.apply(self, [0, length].concat(anArray));
  891. }
  892. }), new objj_method(sel_getUid("removeAllObjects"), function $CPArray__removeAllObjects(self, _cmd)
  893. { with(self)
  894. {
  895. splice(0, length);
  896. }
  897. }), new objj_method(sel_getUid("removeLastObject"), function $CPArray__removeLastObject(self, _cmd)
  898. { with(self)
  899. {
  900. pop();
  901. }
  902. }), new objj_method(sel_getUid("removeObject:"), function $CPArray__removeObject_(self, _cmd, anObject)
  903. { with(self)
  904. {
  905. objj_msgSend(self, "removeObject:inRange:", anObject, CPMakeRange(0, length));
  906. }
  907. }), new objj_method(sel_getUid("removeObject:inRange:"), function $CPArray__removeObject_inRange_(self, _cmd, anObject, aRange)
  908. { with(self)
  909. {
  910. var index;
  911. while ((index = objj_msgSend(self, "indexOfObject:inRange:", anObject, aRange)) != CPNotFound)
  912. {
  913. objj_msgSend(self, "removeObjectAtIndex:", index);
  914. aRange = CPIntersectionRange(CPMakeRange(index, length - index), aRange);
  915. }
  916. }
  917. }), new objj_method(sel_getUid("removeObjectAtIndex:"), function $CPArray__removeObjectAtIndex_(self, _cmd, anIndex)
  918. { with(self)
  919. {
  920. splice(anIndex, 1);
  921. }
  922. }), new objj_method(sel_getUid("removeObjectsAtIndexes:"), function $CPArray__removeObjectsAtIndexes_(self, _cmd, anIndexSet)
  923. { with(self)
  924. {
  925. var index = objj_msgSend(anIndexSet, "lastIndex");
  926. while (index != CPNotFound)
  927. {
  928. objj_msgSend(self, "removeObjectAtIndex:", index);
  929. index = objj_msgSend(anIndexSet, "indexLessThanIndex:", index);
  930. }
  931. }
  932. }), new objj_method(sel_getUid("removeObjectIdenticalTo:"), function $CPArray__removeObjectIdenticalTo_(self, _cmd, anObject)
  933. { with(self)
  934. {
  935. objj_msgSend(self, "removeObjectIdenticalTo:inRange:", anObject, CPMakeRange(0, length));
  936. }
  937. }), new objj_method(sel_getUid("removeObjectIdenticalTo:inRange:"), function $CPArray__removeObjectIdenticalTo_inRange_(self, _cmd, anObject, aRange)
  938. { with(self)
  939. {
  940. var index;
  941. while ((index = objj_msgSend(self, "indexOfObjectIdenticalTo:inRange:", anObject, aRange)) != CPNotFound)
  942. {
  943. objj_msgSend(self, "removeObjectAtIndex:", index);
  944. aRange = CPIntersectionRange(CPMakeRange(index, length - index), aRange);
  945. }
  946. }
  947. }), new objj_method(sel_getUid("removeObjectsInArray:"), function $CPArray__removeObjectsInArray_(self, _cmd, anArray)
  948. { with(self)
  949. {
  950. var index = 0,
  951. count = objj_msgSend(anArray, "count");
  952. for (; index < count; ++index)
  953. objj_msgSend(self, "removeObject:", anArray[index]);
  954. }
  955. }), new objj_method(sel_getUid("removeObjectsInRange:"), function $CPArray__removeObjectsInRange_(self, _cmd, aRange)
  956. { with(self)
  957. {
  958. splice(aRange.location, aRange.length);
  959. }
  960. }), new objj_method(sel_getUid("exchangeObjectAtIndex:withObjectAtIndex:"), function $CPArray__exchangeObjectAtIndex_withObjectAtIndex_(self, _cmd, anIndex, otherIndex)
  961. { with(self)
  962. {
  963. var temporary = self[anIndex];
  964. self[anIndex] = self[otherIndex];
  965. self[otherIndex] = temporary;
  966. }
  967. }), new objj_method(sel_getUid("sortUsingDescriptors:"), function $CPArray__sortUsingDescriptors_(self, _cmd, descriptors)
  968. { with(self)
  969. {
  970. sort(function(lhs, rhs)
  971. {
  972. var i = 0,
  973. count = objj_msgSend(descriptors, "count"),
  974. result = CPOrderedSame;
  975. while(i < count)
  976. if((result = objj_msgSend(descriptors[i++], "compareObject:withObject:", lhs, rhs)) != CPOrderedSame)
  977. return result;
  978. return result;
  979. });
  980. }
  981. }), new objj_method(sel_getUid("sortUsingFunction:context:"), function $CPArray__sortUsingFunction_context_(self, _cmd, aFunction, aContext)
  982. { with(self)
  983. {
  984. sort(function(lhs, rhs) { return aFunction(lhs, rhs, aContext); });
  985. }
  986. }), new objj_method(sel_getUid("sortUsingSelector:"), function $CPArray__sortUsingSelector_(self, _cmd, aSelector)
  987. { with(self)
  988. {
  989. sort(function(lhs, rhs) { return objj_msgSend(lhs, aSelector, rhs); });
  990. }
  991. })]);
  992. class_addMethods(meta_class, [new objj_method(sel_getUid("arrayWithCapacity:"), function $CPArray__arrayWithCapacity_(self, _cmd, aCapacity)
  993. { with(self)
  994. {
  995. return objj_msgSend(objj_msgSend(self, "alloc"), "initWithCapacity:", aCapacity);
  996. }
  997. })]);
  998. }
  999. {
  1000. var the_class = objj_getClass("CPArray")
  1001. if(!the_class) objj_exception_throw(new objj_exception(OBJJClassNotFoundException, "*** Could not find definition for class \"CPArray\""));
  1002. var meta_class = the_class.isa;class_addMethods(the_class, [new objj_method(sel_getUid("initWithCoder:"), function $CPArray__initWithCoder_(self, _cmd, aCoder)
  1003. { with(self)
  1004. {
  1005. return objj_msgSend(aCoder, "decodeObjectForKey:", "CP.objects");
  1006. }
  1007. }), new objj_method(sel_getUid("encodeWithCoder:"), function $CPArray__encodeWithCoder_(self, _cmd, aCoder)
  1008. { with(self)
  1009. {
  1010. objj_msgSend(aCoder, "_encodeArrayOfObjects:forKey:", self, "CP.objects");
  1011. }
  1012. })]);
  1013. }
  1014. {var the_class = objj_allocateClassPair(CPArray, "CPMutableArray"),
  1015. meta_class = the_class.isa;objj_registerClassPair(the_class);
  1016. objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
  1017. }
  1018. Array.prototype.isa = CPArray;
  1019. objj_msgSend(CPArray, "initialize");
  1020. p;20;CPAttributedString.ji;10;CPObject.ji;10;CPString.ji;14;CPDictionary.ji;9;CPRange.jc;19869;
  1021. {var the_class = objj_allocateClassPair(CPObject, "CPAttributedString"),
  1022. meta_class = the_class.isa;class_addIvars(the_class, [new objj_ivar("_string"), new objj_ivar("_rangeEntries")]);
  1023. objj_registerClassPair(the_class);
  1024. objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
  1025. class_addMethods(the_class, [new objj_method(sel_getUid("initWithString:"), function $CPAttributedString__initWithString_(self, _cmd, aString)
  1026. { with(self)
  1027. {
  1028. return objj_msgSend(self, "initWithString:attributes:", aString, nil);
  1029. }
  1030. }), new objj_method(sel_getUid("initWithAttributedString:"), function $CPAttributedString__initWithAttributedString_(self, _cmd, aString)
  1031. { with(self)
  1032. {
  1033. var string = objj_msgSend(self, "initWithString:attributes:", "", nil);
  1034. objj_msgSend(string, "setAttributedString:", aString);
  1035. return string;
  1036. }
  1037. }), new objj_method(sel_getUid("initWithString:attributes:"), function $CPAttributedString__initWithString_attributes_(self, _cmd, aString, attributes)
  1038. { with(self)
  1039. {
  1040. self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPObject") }, "init");
  1041. if (!attributes)
  1042. attributes = objj_msgSend(CPDictionary, "dictionary");
  1043. _string = ""+aString;
  1044. _rangeEntries = [makeRangeEntry(CPMakeRange(0, _string.length), attributes)];
  1045. return self;
  1046. }
  1047. }), new objj_method(sel_getUid("string"), function $CPAttributedString__string(self, _cmd)
  1048. { with(self)
  1049. {
  1050. return _string;
  1051. }
  1052. }), new objj_method(sel_getUid("mutableString"), function $CPAttributedString__mutableString(self, _cmd)
  1053. { with(self)
  1054. {
  1055. return objj_msgSend(self, "string");
  1056. }
  1057. }), new objj_method(sel_getUid("length"), function $CPAttributedString__length(self, _cmd)
  1058. { with(self)
  1059. {
  1060. return _string.length;
  1061. }
  1062. }), new objj_method(sel_getUid("_indexOfEntryWithIndex:"), function $CPAttributedString___indexOfEntryWithIndex_(self, _cmd, anIndex)
  1063. { with(self)
  1064. {
  1065. if (anIndex < 0 || anIndex > _string.length || anIndex === undefined)
  1066. return CPNotFound;
  1067. var sortFunction = function(index, entry)
  1068. {
  1069. if (CPLocationInRange(index, entry.range))
  1070. return CPOrderedSame;
  1071. else if (CPMaxRange(entry.range) <= index)
  1072. return CPOrderedDescending;
  1073. else
  1074. return CPOrderedAscending;
  1075. }
  1076. return objj_msgSend(_rangeEntries, "indexOfObject:sortedByFunction:", anIndex, sortFunction);
  1077. }
  1078. }), new objj_method(sel_getUid("attributesAtIndex:effectiveRange:"), function $CPAttributedString__attributesAtIndex_effectiveRange_(self, _cmd, anIndex, aRange)
  1079. { with(self)
  1080. {
  1081. var entryIndex = objj_msgSend(self, "_indexOfEntryWithIndex:", anIndex);
  1082. if (entryIndex == CPNotFound)
  1083. return nil;
  1084. var matchingRange = _rangeEntries[entryIndex];
  1085. if (aRange)
  1086. {
  1087. aRange.location = matchingRange.range.location;
  1088. aRange.length = matchingRange.range.length;
  1089. }
  1090. return matchingRange.attributes;
  1091. }
  1092. }), new objj_method(sel_getUid("attributesAtIndex:longestEffectiveRange:inRange:"), function $CPAttributedString__attributesAtIndex_longestEffectiveRange_inRange_(self, _cmd, anIndex, aRange, rangeLimit)
  1093. { with(self)
  1094. {
  1095. var startingEntryIndex = objj_msgSend(self, "_indexOfEntryWithIndex:", anIndex);
  1096. if (startingEntryIndex == CPNotFound)
  1097. return nil;
  1098. if (!aRange)
  1099. return _rangeEntries[startingEntryIndex].attributes;
  1100. if (CPRangeInRange(_rangeEntries[startingEntryIndex].range, rangeLimit))
  1101. {
  1102. aRange.location = rangeLimit.location;
  1103. aRange.length = rangeLimit.length;
  1104. return _rangeEntries[startingEntryIndex].attributes;
  1105. }
  1106. var nextRangeIndex = startingEntryIndex - 1,
  1107. currentEntry = _rangeEntries[startingEntryIndex],
  1108. comparisonDict = currentEntry.attributes;
  1109. while (nextRangeIndex >= 0)
  1110. {
  1111. var nextEntry = _rangeEntries[nextRangeIndex];
  1112. if (CPMaxRange(nextEntry.range) > rangeLimit.location && objj_msgSend(nextEntry.attributes, "isEqualToDictionary:", comparisonDict))
  1113. {
  1114. currentEntry = nextEntry;
  1115. nextRangeIndex--;
  1116. }
  1117. else
  1118. break;
  1119. }
  1120. aRange.location = MAX(currentEntry.range.location, rangeLimit.location);
  1121. currentEntry = _rangeEntries[startingEntryIndex];
  1122. nextRangeIndex = startingEntryIndex + 1;
  1123. while (nextRangeIndex < _rangeEntries.length)
  1124. {
  1125. var nextEntry = _rangeEntries[nextRangeIndex];
  1126. if (nextEntry.range.location < CPMaxRange(rangeLimit) && objj_msgSend(nextEntry.attributes, "isEqualToDictionary:", comparisonDict))
  1127. {
  1128. currentEntry = nextEntry;
  1129. nextRangeIndex++;
  1130. }
  1131. else
  1132. break;
  1133. }
  1134. aRange.length = MIN(CPMaxRange(currentEntry.range), CPMaxRange(rangeLimit)) - aRange.location;
  1135. return comparisonDict;
  1136. }
  1137. }), new objj_method(sel_getUid("attribute:atIndex:effectiveRange:"), function $CPAttributedString__attribute_atIndex_effectiveRange_(self, _cmd, attribute, index, aRange)
  1138. { with(self)
  1139. {
  1140. if (!attribute)
  1141. {
  1142. if (aRange)
  1143. {
  1144. aRange.location = 0;
  1145. aRange.length = _string.length;
  1146. }
  1147. return nil;
  1148. }
  1149. return objj_msgSend(objj_msgSend(self, "attributesAtIndex:effectiveRange:", index, aRange), "valueForKey:", attribute);
  1150. }
  1151. }), new objj_method(sel_getUid("attribute:atIndex:longestEffectiveRange:inRange:"), function $CPAttributedString__attribute_atIndex_longestEffectiveRange_inRange_(self, _cmd, attribute, anIndex, aRange, rangeLimit)
  1152. { with(self)
  1153. {
  1154. var startingEntryIndex = objj_msgSend(self, "_indexOfEntryWithIndex:", anIndex);
  1155. if (startingEntryIndex == CPNotFound || !attribute)
  1156. return nil;
  1157. if (!aRange)
  1158. return objj_msgSend(_rangeEntries[startingEntryIndex].attributes, "objectForKey:", attribute);
  1159. if (CPRangeInRange(_rangeEntries[startingEntryIndex].range, rangeLimit))
  1160. {
  1161. aRange.location = rangeLimit.location;
  1162. aRange.length = rangeLimit.length;
  1163. return objj_msgSend(_rangeEntries[startingEntryIndex].attributes, "objectForKey:", attribute);
  1164. }
  1165. var nextRangeIndex = startingEntryIndex - 1,
  1166. currentEntry = _rangeEntries[startingEntryIndex],
  1167. comparisonAttribute = objj_msgSend(currentEntry.attributes, "objectForKey:", attribute);
  1168. while (nextRangeIndex >= 0)
  1169. {
  1170. var nextEntry = _rangeEntries[nextRangeIndex];
  1171. if (CPMaxRange(nextEntry.range) > rangeLimit.location && isEqual(comparisonAttribute, objj_msgSend(nextEntry.attributes, "objectForKey:", attribute)))
  1172. {
  1173. currentEntry = nextEntry;
  1174. nextRangeIndex--;
  1175. }
  1176. else
  1177. break;
  1178. }
  1179. aRange.location = MAX(currentEntry.range.location, rangeLimit.location);
  1180. currentEntry = _rangeEntries[startingEntryIndex];
  1181. nextRangeIndex = startingEntryIndex + 1;
  1182. while (nextRangeIndex < _rangeEntries.length)
  1183. {
  1184. var nextEntry = _rangeEntries[nextRangeIndex];
  1185. if (nextEntry.range.location < CPMaxRange(rangeLimit) && isEqual(comparisonAttribute, objj_msgSend(nextEntry.attributes, "objectForKey:", attribute)))
  1186. {
  1187. currentEntry = nextEntry;
  1188. nextRangeIndex++;
  1189. }
  1190. else
  1191. break;
  1192. }
  1193. aRange.length = MIN(CPMaxRange(currentEntry.range), CPMaxRange(rangeLimit)) - aRange.location;
  1194. return comparisonAttribute;
  1195. }
  1196. }), new objj_method(sel_getUid("isEqualToAttributedString:"), function $CPAttributedString__isEqualToAttributedString_(self, _cmd, aString)
  1197. { with(self)
  1198. {
  1199. if(!aString)
  1200. return NO;
  1201. if(_string != objj_msgSend(aString, "string"))
  1202. return NO;
  1203. var myRange = CPMakeRange(),
  1204. comparisonRange = CPMakeRange(),
  1205. myAttributes = objj_msgSend(self, "attributesAtIndex:effectiveRange:", 0, myRange),
  1206. comparisonAttributes = objj_msgSend(aString, "attributesAtIndex:effectiveRange:", 0, comparisonRange),
  1207. length = _string.length;
  1208. while (CPMaxRange(CPUnionRange(myRange, comparisonRange)) < length)
  1209. {
  1210. if (CPIntersectionRange(myRange, comparisonRange).length > 0 && !objj_msgSend(myAttributes, "isEqualToDictionary:", comparisonAttributes))
  1211. return NO;
  1212. if (CPMaxRange(myRange) < CPMaxRange(comparisonRange))
  1213. myAttributes = objj_msgSend(self, "attributesAtIndex:effectiveRange:", CPMaxRange(myRange), myRange);
  1214. else
  1215. comparisonAttributes = objj_msgSend(aString, "attributesAtIndex:effectiveRange:", CPMaxRange(comparisonRange), comparisonRange);
  1216. }
  1217. return YES;
  1218. }
  1219. }), new objj_method(sel_getUid("isEqual:"), function $CPAttributedString__isEqual_(self, _cmd, anObject)
  1220. { with(self)
  1221. {
  1222. if (anObject == self)
  1223. return YES;
  1224. if (objj_msgSend(anObject, "isKindOfClass:", objj_msgSend(self, "class")))
  1225. return objj_msgSend(self, "isEqualToAttributedString:", anObject);
  1226. return NO;
  1227. }
  1228. }), new objj_method(sel_getUid("attributedSubstringFromRange:"), function $CPAttributedString__attributedSubstringFromRange_(self, _cmd, aRange)
  1229. { with(self)
  1230. {
  1231. if (!aRange || CPMaxRange(aRange) > _string.length || aRange.location < 0)
  1232. objj_msgSend(CPException, "raise:reason:", CPRangeException, "tried to get attributedSubstring for an invalid range: "+(aRange?CPStringFromRange(aRange):"nil"));
  1233. var newString = objj_msgSend(objj_msgSend(CPAttributedString, "alloc"), "initWithString:", _string.substring(aRange.location, CPMaxRange(aRange))),
  1234. entryIndex = objj_msgSend(self, "_indexOfEntryWithIndex:", aRange.location),
  1235. currentRangeEntry = _rangeEntries[entryIndex],
  1236. lastIndex = CPMaxRange(aRange);
  1237. newString._rangeEntries = [];
  1238. while (currentRangeEntry && CPMaxRange(currentRangeEntry.range) < lastIndex)
  1239. {
  1240. var newEntry = copyRangeEntry(currentRangeEntry);
  1241. newEntry.range.location -= aRange.location;
  1242. if (newEntry.range.location < 0)
  1243. {
  1244. newEntry.range.length += newEntry.range.location;
  1245. newEntry.range.location = 0;
  1246. }
  1247. newString._rangeEntries.push(newEntry);
  1248. currentRangeEntry = _rangeEntries[++entryIndex];
  1249. }
  1250. if (currentRangeEntry)
  1251. {
  1252. var newRangeEntry = copyRangeEntry(currentRangeEntry);
  1253. newRangeEntry.range.length = CPMaxRange(aRange) - newRangeEntry.range.location;
  1254. newRangeEntry.range.location -= aRange.location;
  1255. if (newRangeEntry.range.location < 0)
  1256. {
  1257. newRangeEntry.range.length += newRangeEntry.range.location;
  1258. newRangeEntry.range.location = 0;
  1259. }
  1260. newString._rangeEntries.push(newRangeEntry);
  1261. }
  1262. return newString;
  1263. }
  1264. }), new objj_method(sel_getUid("replaceCharactersInRange:withString:"), function $CPAttributedString__replaceCharactersInRange_withString_(self, _cmd, aRange, aString)
  1265. { with(self)
  1266. {
  1267. objj_msgSend(self, "beginEditing");
  1268. if (!aString)
  1269. aString = "";
  1270. var startingIndex = objj_msgSend(self, "_indexOfEntryWithIndex:", aRange.location),
  1271. startingRangeEntry = _rangeEntries[startingIndex],
  1272. endingIndex = objj_msgSend(self, "_indexOfEntryWithIndex:", MAX(CPMaxRange(aRange)-1, 0)),
  1273. endingRangeEntry = _rangeEntries[endingIndex],
  1274. additionalLength = aString.length - aRange.length;
  1275. _string = _string.substring(0, aRange.location) + aString + _string.substring(CPMaxRange(aRange));
  1276. if (startingIndex == endingIndex)
  1277. startingRangeEntry.range.length += additionalLength;
  1278. else
  1279. {
  1280. endingRangeEntry.range.length = CPMaxRange(endingRangeEntry.range) - CPMaxRange(aRange);
  1281. endingRangeEntry.range.location = CPMaxRange(aRange);
  1282. startingRangeEntry.range.length = CPMaxRange(aRange) - startingRangeEntry.range.location;
  1283. _rangeEntries.splice(startingIndex, endingIndex - startingIndex);
  1284. }
  1285. endingIndex = startingIndex + 1;
  1286. while(endingIndex < _rangeEntries.length)
  1287. _rangeEntries[endingIndex++].range.location+=additionalLength;
  1288. objj_msgSend(self, "endEditing");
  1289. }
  1290. }), new objj_method(sel_getUid("deleteCharactersInRange:"), function $CPAttributedString__deleteCharactersInRange_(self, _cmd, aRange)
  1291. { with(self)
  1292. {
  1293. objj_msgSend(self, "replaceCharactersInRange:withString:", aRange, nil);
  1294. }
  1295. }), new objj_method(sel_getUid("setAttributes:range:"), function $CPAttributedString__setAttributes_range_(self, _cmd, aDictionary, aRange)
  1296. { with(self)
  1297. {
  1298. objj_msgSend(self, "beginEditing");
  1299. var startingEntryIndex = objj_msgSend(self, "_indexOfRangeEntryForIndex:splitOnMaxIndex:", aRange.location, YES),
  1300. endingEntryIndex = objj_msgSend(self, "_indexOfRangeEntryForIndex:splitOnMaxIndex:", CPMaxRange(aRange), YES),
  1301. current = startingEntryIndex;
  1302. if (endingEntryIndex == CPNotFound)
  1303. endingEntryIndex = _rangeEntries.length;
  1304. while (current < endingEntryIndex)
  1305. _rangeEntries[current++].attributes = objj_msgSend(aDictionary, "copy");
  1306. objj_msgSend(self, "_coalesceRangeEntriesFromIndex:toIndex:", startingEntryIndex, endingEntryIndex);
  1307. objj_msgSend(self, "endEditing");
  1308. }
  1309. }), new objj_method(sel_getUid("addAttributes:range:"), function $CPAttributedString__addAttributes_range_(self, _cmd, aDictionary, aRange)
  1310. { with(self)
  1311. {
  1312. objj_msgSend(self, "beginEditing");
  1313. var startingEntryIndex = objj_msgSend(self, "_indexOfRangeEntryForIndex:splitOnMaxIndex:", aRange.location, YES),
  1314. endingEntryIndex = objj_msgSend(self, "_indexOfRangeEntryForIndex:splitOnMaxIndex:", CPMaxRange(aRange), YES),
  1315. current = startingEntryIndex;
  1316. if (endingEntryIndex == CPNotFound)
  1317. endingEntryIndex = _rangeEntries.length;
  1318. while (current < endingEntryIndex)
  1319. {
  1320. var keys = objj_msgSend(aDictionary, "allKeys"),
  1321. count = objj_msgSend(keys, "count");
  1322. while (count--)
  1323. objj_msgSend(_rangeEntries[current].attributes, "setObject:forKey:", objj_msgSend(aDictionary, "objectForKey:", keys[count]), keys[count]);
  1324. current++;
  1325. }
  1326. objj_msgSend(self, "_coalesceRangeEntriesFromIndex:toIndex:", startingEntryIndex, endingEntryIndex);
  1327. objj_msgSend(self, "endEditing");
  1328. }
  1329. }), new objj_method(sel_getUid("addAttribute:value:range:"), function $CPAttributedString__addAttribute_value_range_(self, _cmd, anAttribute, aValue, aRange)
  1330. { with(self)
  1331. {
  1332. objj_msgSend(self, "addAttributes:range:", objj_msgSend(CPDictionary, "dictionaryWithObject:forKey:", aValue, anAttribute), aRange);
  1333. }
  1334. }), new objj_method(sel_getUid("removeAttribute:range:"), function $CPAttributedString__removeAttribute_range_(self, _cmd, anAttribute, aRange)
  1335. { with(self)
  1336. {
  1337. objj_msgSend(self, "addAttribute:value:range:", anAttribute, nil, aRange);
  1338. }
  1339. }), new objj_method(sel_getUid("appendAttributedString:"), function $CPAttributedString__appendAttributedString_(self, _cmd, aString)
  1340. { with(self)
  1341. {
  1342. objj_msgSend(self, "insertAttributedString:atIndex:", aString, _string.length);
  1343. }
  1344. }), new objj_method(sel_getUid("insertAttributedString:atIndex:"), function $CPAttributedString__insertAttributedString_atIndex_(self, _cmd, aString, anIndex)
  1345. { with(self)
  1346. {
  1347. objj_msgSend(self, "beginEditing");
  1348. if (anIndex < 0 || anIndex > objj_msgSend(self, "length"))
  1349. objj_msgSend(CPException, "raise:reason:", CPRangeException, "tried to insert attributed string at an invalid index: "+anIndex);
  1350. var entryIndexOfNextEntry = objj_msgSend(self, "_indexOfRangeEntryForIndex:splitOnMaxIndex:", anIndex, YES),
  1351. otherRangeEntries = aString._rangeEntries,
  1352. length = objj_msgSend(aString, "length");
  1353. if (entryIndexOfNextEntry == CPNotFound)
  1354. entryIndexOfNextEntry = _rangeEntries.length;
  1355. _string = _string.substring(0, anIndex) + aString._string + _string.substring(anIndex);
  1356. var current = entryIndexOfNextEntry;
  1357. while (current < _rangeEntries.length)
  1358. _rangeEntries[current++].range.location += length;
  1359. var newRangeEntryCount = otherRangeEntries.length,
  1360. index = 0;
  1361. while (index < newRangeEntryCount)
  1362. {
  1363. var entryCopy = copyRangeEntry(otherRangeEntries[index++]);
  1364. entryCopy.range.location += anIndex;
  1365. _rangeEntries.splice(entryIndexOfNextEntry-1+index, 0, entryCopy);
  1366. }
  1367. objj_msgSend(self, "endEditing");
  1368. }
  1369. }), new objj_method(sel_getUid("replaceCharactersInRange:withAttributedString:"), function $CPAttributedString__replaceCharactersInRange_withAttributedString_(self, _cmd, aRange, aString)
  1370. { with(self)
  1371. {
  1372. objj_msgSend(self, "beginEditing");
  1373. objj_msgSend(self, "deleteCharactersInRange:", aRange);
  1374. objj_msgSend(self, "insertAttributedString:atIndex:", aString, aRange.location);
  1375. objj_msgSend(self, "endEditing");
  1376. }
  1377. }), new objj_method(sel_getUid("setAttributedString:"), function $CPAttributedString__setAttributedString_(self, _cmd, aString)
  1378. { with(self)
  1379. {
  1380. objj_msgSend(self, "beginEditing");
  1381. _string = aString._string;
  1382. _rangeEntries = [];
  1383. for (var i=0, count = aString._rangeEntries.length; i<count; i++)
  1384. _rangeEntries.push(copyRangeEntry(aString._rangeEntries[i]));
  1385. objj_msgSend(self, "endEditing");
  1386. }
  1387. }), new objj_method(sel_getUid("_indexOfRangeEntryForIndex:splitOnMaxIndex:"), function $CPAttributedString___indexOfRangeEntryForIndex_splitOnMaxIndex_(self, _cmd, characterIndex, split)
  1388. { with(self)
  1389. {
  1390. var index = objj_msgSend(self, "_indexOfEntryWithIndex:", characterIndex);
  1391. if (index < 0)
  1392. return index;
  1393. var rangeEntry = _rangeEntries[index];
  1394. if (rangeEntry.range.location == characterIndex || (CPMaxRange(rangeEntry.range) - 1 == characterIndex && !split))
  1395. return index;
  1396. var newEntries = splitRangeEntryAtIndex(rangeEntry, characterIndex);
  1397. _rangeEntries.splice(index, 1, newEntries[0], newEntries[1]);
  1398. index++;
  1399. return index;
  1400. }
  1401. }), new objj_method(sel_getUid("_coalesceRangeEntriesFromIndex:toIndex:"), function $CPAttributedString___coalesceRangeEntriesFromIndex_toIndex_(self, _cmd, start, end)
  1402. { with(self)
  1403. {
  1404. var current = start;
  1405. if (end >= _rangeEntries.length)
  1406. end = _rangeEntries.length -1;
  1407. while (current < end)
  1408. {
  1409. var a = _rangeEntries[current],
  1410. b = _rangeEntries[current+1];
  1411. if (objj_msgSend(a.attributes, "isEqualToDictionary:", b.attributes))
  1412. {
  1413. a.range.length = CPMaxRange(b.range) - a.range.location;
  1414. _rangeEntries.splice(current+1, 1);
  1415. end--;
  1416. }
  1417. else
  1418. current++;
  1419. }
  1420. }
  1421. }), new objj_method(sel_getUid("beginEditing"), function $CPAttributedString__beginEditing(self, _cmd)
  1422. { with(self)
  1423. {
  1424. }
  1425. }), new objj_method(sel_getUid("endEditing"), function $CPAttributedString__endEditing(self, _cmd)
  1426. { with(self)
  1427. {
  1428. }
  1429. })]);
  1430. }
  1431. {var the_class = objj_allocateClassPair(CPAttributedString, "CPMutableAttributedString"),
  1432. meta_class = the_class.isa;objj_registerClassPair(the_class);
  1433. objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
  1434. }
  1435. var isEqual = isEqual= function(a, b)
  1436. {
  1437. if (a == b)
  1438. return YES;
  1439. if (objj_msgSend(a, "respondsToSelector:", sel_getUid("isEqual:")) && objj_msgSend(a, "isEqual:", b))
  1440. return YES;
  1441. return NO;
  1442. }
  1443. var makeRangeEntry = makeRangeEntry= function( aRange, attributes)
  1444. {
  1445. return {range:aRange, attributes:objj_msgSend(attributes, "copy")};
  1446. }
  1447. var copyRangeEntry = copyRangeEntry= function( aRangeEntry)
  1448. {
  1449. return makeRangeEntry(CPCopyRange(aRangeEntry.range), objj_msgSend(aRangeEntry.attributes, "copy"));
  1450. }
  1451. var splitRangeEntry = splitRangeEntryAtIndex= function( aRangeEntry, anIndex)
  1452. {
  1453. var newRangeEntry = copyRangeEntry(aRangeEntry),
  1454. cachedIndex = CPMaxRange(aRangeEntry.range);
  1455. aRangeEntry.range.length = anIndex - aRangeEntry.range.location;
  1456. newRangeEntry.range.location = anIndex;
  1457. newRangeEntry.range.length = cachedIndex - anIndex;
  1458. newRangeEntry.attributes = objj_msgSend(newRangeEntry.attributes, "copy");
  1459. return [aRangeEntry, newRangeEntry];
  1460. }
  1461. p;10;CPBundle.ji;10;CPObject.ji;14;CPDictionary.ji;14;CPURLRequest.jc;5166;
  1462. {var the_class = objj_allocateClassPair(CPObject, "CPBundle"),
  1463. meta_class = the_class.isa;objj_registerClassPair(the_class);
  1464. objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
  1465. class_addMethods(the_class, [new objj_method(sel_getUid("initWithPath:"), function $CPBundle__initWithPath_(self, _cmd, aPath)
  1466. { with(self)
  1467. {
  1468. self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPObject") }, "init");
  1469. if (self)
  1470. {
  1471. path = aPath;
  1472. objj_setBundleForPath(path, self);
  1473. }
  1474. return self;
  1475. }
  1476. }), new objj_method(sel_getUid("classNamed:"), function $CPBundle__classNamed_(self, _cmd, aString)
  1477. { with(self)
  1478. {
  1479. }
  1480. }), new objj_method(sel_getUid("bundlePath"), function $CPBundle__bundlePath(self, _cmd)
  1481. { with(self)
  1482. {
  1483. return objj_msgSend(path, "stringByDeletingLastPathComponent");
  1484. }
  1485. }), new objj_method(sel_getUid("resourcePath"), function $CPBundle__resourcePath(self, _cmd)
  1486. { with(self)
  1487. {
  1488. var resourcePath = objj_msgSend(self, "bundlePath");
  1489. if (resourcePath.length)
  1490. resourcePath += '/';
  1491. return resourcePath + "Resources";
  1492. }
  1493. }), new objj_method(sel_getUid("principalClass"), function $CPBundle__principalClass(self, _cmd)
  1494. { with(self)
  1495. {
  1496. var className = objj_msgSend(self, "objectForInfoDictionaryKey:", "CPPrincipalClass");
  1497. return className ? CPClassFromString(className) : Nil;
  1498. }
  1499. }), new objj_method(sel_getUid("pathForResource:"), function $CPBundle__pathForResource_(self, _cmd, aFilename)
  1500. { with(self)
  1501. {
  1502. return objj_msgSend(self, "resourcePath") + '/' + aFilename;
  1503. }
  1504. }), new objj_method(sel_getUid("infoDictionary"), function $CPBundle__infoDictionary(self, _cmd)
  1505. { with(self)
  1506. {
  1507. return info;
  1508. }
  1509. }), new objj_method(sel_getUid("objectForInfoDictionaryKey:"), function $CPBundle__objectForInfoDictionaryKey_(self, _cmd, aKey)
  1510. { with(self)
  1511. {
  1512. return objj_msgSend(info, "objectForKey:", aKey);
  1513. }
  1514. }), new objj_method(sel_getUid("loadWithDelegate:"), function $CPBundle__loadWithDelegate_(self, _cmd, aDelegate)
  1515. { with(self)
  1516. {
  1517. self._delegate = aDelegate;
  1518. self._infoConnection = objj_msgSend(CPURLConnection, "connectionWithRequest:delegate:", objj_msgSend(CPURLRequest, "requestWithURL:", objj_msgSend(self, "bundlePath") + "/Info.plist"), self);
  1519. }
  1520. }), new objj_method(sel_getUid("connection:didReceiveData:"), function $CPBundle__connection_didReceiveData_(self, _cmd, aConnection, data)
  1521. { with(self)
  1522. {
  1523. if (aConnection === self._infoConnection)
  1524. {
  1525. info = CPPropertyListCreateFromData(objj_msgSend(CPData, "dataWithString:", data));
  1526. var platform = '/',
  1527. platforms = objj_msgSend(self, "objectForInfoDictionaryKey:", "CPBundlePlatforms");
  1528. if (platforms)
  1529. {
  1530. platform = objj_msgSend(platforms, "firstObjectCommonWithArray:", OBJJ_PLATFORMS);
  1531. platform = platform ? '/' + platform + ".platform/" : '/';
  1532. }
  1533. objj_msgSend(CPURLConnection, "connectionWithRequest:delegate:", objj_msgSend(CPURLRequest, "requestWithURL:", objj_msgSend(self, "bundlePath") + platform + objj_msgSend(self, "objectForInfoDictionaryKey:", "CPBundleExecutable")), self);
  1534. }
  1535. else
  1536. {
  1537. objj_decompile(objj_msgSend(data, "string"), self);
  1538. var context = new objj_context();
  1539. if (objj_msgSend(_delegate, "respondsToSelector:", sel_getUid("bundleDidFinishLoading:")))
  1540. context.didCompleteCallback = function() { objj_msgSend(_delegate, "bundleDidFinishLoading:", self); };
  1541. var files = objj_msgSend(self, "objectForInfoDictionaryKey:", "CPBundleReplacedFiles"),
  1542. count = files.length,
  1543. bundlePath = objj_msgSend(self, "bundlePath");
  1544. while (count--)
  1545. {
  1546. var fileName = files[count];
  1547. if (fileName.indexOf(".j") === fileName.length - 2)
  1548. context.pushFragment(fragment_create_file(bundlePath + '/' + fileName, new objj_bundle(""), YES, NULL));
  1549. }
  1550. if (context.fragments.length)
  1551. context.evaluate();
  1552. else
  1553. objj_msgSend(_delegate, "bundleDidFinishLoading:", self);
  1554. }
  1555. }
  1556. }), new objj_method(sel_getUid("connection:didFailWithError:"), function $CPBundle__connection_didFailWithError_(self, _cmd, aConnection, anError)
  1557. { with(self)
  1558. {
  1559. alert("Couldnot find bundle:" + anError)
  1560. }
  1561. }), new objj_method(sel_getUid("connectionDidFinishLoading:"), function $CPBundle__connectionDidFinishLoading_(self, _cmd, aConnection)
  1562. { with(self)
  1563. {
  1564. }
  1565. })]);
  1566. class_addMethods(meta_class, [new objj_method(sel_getUid("alloc"), function $CPBundle__alloc(self, _cmd)
  1567. { with(self)
  1568. {
  1569. return new objj_bundle;
  1570. }
  1571. }), new objj_method(sel_getUid("bundleWithPath:"), function $CPBundle__bundleWithPath_(self, _cmd, aPath)
  1572. { with(self)
  1573. {
  1574. return objj_getBundleWithPath(aPath);
  1575. }
  1576. }), new objj_method(sel_getUid("bundleForClass:"), function $CPBundle__bundleForClass_(self, _cmd, aClass)
  1577. { with(self)
  1578. {
  1579. return objj_bundleForClass(aClass);
  1580. }
  1581. }), new objj_method(sel_getUid("mainBundle"), function $CPBundle__mainBundle(self, _cmd)
  1582. { with(self)
  1583. {
  1584. return objj_msgSend(CPBundle, "bundleWithPath:", "Info.plist");
  1585. }
  1586. })]);
  1587. }
  1588. objj_bundle.prototype.isa = CPBundle;
  1589. p;9;CPCoder.ji;10;CPObject.ji;13;CPException.jc;2598;
  1590. {var the_class = objj_allocateClassPair(CPObject, "CPCoder"),
  1591. meta_class = the_class.isa;objj_registerClassPair(the_class);
  1592. objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
  1593. class_addMethods(the_class, [new objj_method(sel_getUid("allowsKeyedCoding"), function $CPCoder__allowsKeyedCoding(self, _cmd)
  1594. { with(self)
  1595. {
  1596. return NO;
  1597. }
  1598. }), new objj_method(sel_getUid("encodeValueOfObjCType:at:"), function $CPCoder__encodeValueOfObjCType_at_(self, _cmd, aType, anObject)
  1599. { with(self)
  1600. {
  1601. CPInvalidAbstractInvocation();
  1602. }
  1603. }), new objj_method(sel_getUid("encodeDataObject:"), function $CPCoder__encodeDataObject_(self, _cmd, aData)
  1604. { with(self)
  1605. {
  1606. CPInvalidAbstractInvocation();
  1607. }
  1608. }), new objj_method(sel_getUid("encodeObject:"), function $CPCoder__encodeObject_(self, _cmd, anObject)
  1609. { with(self)
  1610. {
  1611. }
  1612. }), new objj_method(sel_getUid("encodePoint:"), function $CPCoder__encodePoint_(self, _cmd, aPoint)
  1613. { with(self)
  1614. {
  1615. objj_msgSend(self, "encodeNumber:", aPoint.x);
  1616. objj_msgSend(self, "encodeNumber:", aPoint.y);
  1617. }
  1618. }), new objj_method(sel_getUid("encodeRect:"), function $CPCoder__encodeRect_(self, _cmd, aRect)
  1619. { with(self)
  1620. {
  1621. objj_msgSend(self, "encodePoint:", aRect.origin);
  1622. objj_msgSend(self, "encodeSize:", aRect.size);
  1623. }
  1624. }), new objj_method(sel_getUid("encodeSize:"), function $CPCoder__encodeSize_(self, _cmd, aSize)
  1625. { with(self)
  1626. {
  1627. objj_msgSend(self, "encodeNumber:", aSize.width);
  1628. objj_msgSend(self, "encodeNumber:", aSize.height);
  1629. }
  1630. }), new objj_method(sel_getUid("encodePropertyList:"), function $CPCoder__encodePropertyList_(self, _cmd, aPropertyList)
  1631. { with(self)
  1632. {
  1633. }
  1634. }), new objj_method(sel_getUid("encodeRootObject:"), function $CPCoder__encodeRootObject_(self, _cmd, anObject)
  1635. { with(self)
  1636. {
  1637. objj_msgSend(self, "encodeObject:", anObject);
  1638. }
  1639. }), new objj_method(sel_getUid("encodeBycopyObject:"), function $CPCoder__encodeBycopyObject_(self, _cmd, anObject)
  1640. { with(self)
  1641. {
  1642. objj_msgSend(self, "encodeObject:", object);
  1643. }
  1644. }), new objj_method(sel_getUid("encodeConditionalObject:"), function $CPCoder__encodeConditionalObject_(self, _cmd, anObject)
  1645. { with(self)
  1646. {
  1647. objj_msgSend(self, "encodeObject:", object);
  1648. }
  1649. })]);
  1650. }
  1651. {
  1652. var the_class = objj_getClass("CPObject")
  1653. if(!the_class) objj_exception_throw(new objj_exception(OBJJClassNotFoundException, "*** Could not find definition for class \"CPObject\""));
  1654. var meta_class = the_class.isa;class_addMethods(the_class, [new objj_method(sel_getUid("awakeAfterUsingCoder:"), function $CPObject__awakeAfterUsingCoder_(self, _cmd, aDecoder)
  1655. { with(self)
  1656. {
  1657. return self;
  1658. }
  1659. })]);
  1660. }
  1661. p;14;CPCountedSet.ji;7;CPSet.jc;1792;
  1662. {var the_class = objj_allocateClassPair(CPMutableSet, "CPCountedSet"),
  1663. meta_class = the_class.isa;class_addIvars(the_class, [new objj_ivar("_counts")]);
  1664. objj_registerClassPair(the_class);
  1665. objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
  1666. class_addMethods(the_class, [new objj_method(sel_getUid("addObject:"), function $CPCountedSet__addObject_(self, _cmd, anObject)
  1667. { with(self)
  1668. {
  1669. if (!_counts)
  1670. _counts = {};
  1671. objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPMutableSet") }, "addObject:", anObject);
  1672. var hash = objj_msgSend(anObject, "hash");
  1673. if (_counts[hash] === undefined)
  1674. _counts[hash] = 1;
  1675. else
  1676. ++_counts[hash];
  1677. }
  1678. }), new objj_method(sel_getUid("removeObject:"), function $CPCountedSet__removeObject_(self, _cmd, anObject)
  1679. { with(self)
  1680. {
  1681. if (!_counts)
  1682. return;
  1683. var hash = objj_msgSend(anObject, "hash");
  1684. if (_counts[hash] === undefined)
  1685. return;
  1686. else
  1687. {
  1688. --_counts[hash];
  1689. if (_counts[hash] === 0)
  1690. {
  1691. delete _counts[hash];
  1692. objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPMutableSet") }, "removeObject:", anObject);
  1693. }
  1694. }
  1695. }
  1696. }), new objj_method(sel_getUid("removeAllObjects"), function $CPCountedSet__removeAllObjects(self, _cmd)
  1697. { with(self)
  1698. {
  1699. objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPMutableSet") }, "removeAllObjects");
  1700. _counts = {};
  1701. }
  1702. }), new objj_method(sel_getUid("countForObject:"), function $CPCountedSet__countForObject_(self, _cmd, anObject)
  1703. { with(self)
  1704. {
  1705. if (!_counts)
  1706. _counts = {};
  1707. var hash = objj_msgSend(anObject, "hash");
  1708. if (_counts[hash] === undefined)
  1709. return 0;
  1710. return _counts[hash];
  1711. }
  1712. })]);
  1713. }
  1714. p;8;CPData.ji;10;CPObject.ji;10;CPString.jc;2933;
  1715. {var the_class = objj_allocateClassPair(CPObject, "CPData"),
  1716. meta_class = the_class.isa;class_addIvars(the_class, [new objj_ivar("_plistObject")]);
  1717. objj_registerClassPair(the_class);
  1718. objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
  1719. class_addMethods(the_class, [new objj_method(sel_getUid("initWithString:"), function $CPData__initWithString_(self, _cmd, aString)
  1720. { with(self)
  1721. {
  1722. self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPObject") }, "init");
  1723. if (self)
  1724. string = aString;
  1725. return self;
  1726. }
  1727. }), new objj_method(sel_getUid("initWithPlistObject:"), function $CPData__initWithPlistObject_(self, _cmd, aPlistObject)
  1728. { with(self)
  1729. {
  1730. self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPObject") }, "init");
  1731. if (self)
  1732. _plistObject = aPlistObject;
  1733. return self;
  1734. }
  1735. }), new objj_method(sel_getUid("length"), function $CPData__length(self, _cmd)
  1736. { with(self)
  1737. {
  1738. return objj_msgSend(objj_msgSend(self, "string"), "length");
  1739. }
  1740. }), new objj_method(sel_getUid("description"), function $CPData__description(self, _cmd)
  1741. { with(self)
  1742. {
  1743. return string;
  1744. }
  1745. }), new objj_method(sel_getUid("string"), function $CPData__string(self, _cmd)
  1746. { with(self)
  1747. {
  1748. if (!string && _plistObject)
  1749. string = objj_msgSend(objj_msgSend(CPPropertyListSerialization, "dataFromPropertyList:format:errorDescription:", _plistObject, CPPropertyList280NorthFormat_v1_0, NULL), "string");
  1750. return string;
  1751. }
  1752. }), new objj_method(sel_getUid("setString:"), function $CPData__setString_(self, _cmd, aString)
  1753. { with(self)
  1754. {
  1755. string = aString;
  1756. _plistObject = nil;
  1757. }
  1758. }), new objj_method(sel_getUid("plistObject"), function $CPData__plistObject(self, _cmd)
  1759. { with(self)
  1760. {
  1761. if (string && !_plistObject)
  1762. _plistObject = objj_msgSend(CPPropertyListSerialization, "propertyListFromData:format:errorDescription:", self, 0, NULL);
  1763. return _plistObject;
  1764. }
  1765. }), new objj_method(sel_getUid("setPlistObject:"), function $CPData__setPlistObject_(self, _cmd, aPlistObject)
  1766. { with(self)
  1767. {
  1768. string = nil;
  1769. _plistObject = aPlistObject;
  1770. }
  1771. })]);
  1772. class_addMethods(meta_class, [new objj_method(sel_getUid("alloc"), function $CPData__alloc(self, _cmd)
  1773. { with(self)
  1774. {
  1775. return new objj_data();
  1776. }
  1777. }), new objj_method(sel_getUid("data"), function $CPData__data(self, _cmd)
  1778. { with(self)
  1779. {
  1780. return objj_msgSend(objj_msgSend(self, "alloc"), "initWithPlistObject:", nil);
  1781. }
  1782. }), new objj_method(sel_getUid("dataWithString:"), function $CPData__dataWithString_(self, _cmd, aString)
  1783. { with(self)
  1784. {
  1785. return objj_msgSend(objj_msgSend(self, "alloc"), "initWithString:", aString);
  1786. }
  1787. }), new objj_method(sel_getUid("dataWithPlistObject:"), function $CPData__dataWithPlistObject_(self, _cmd, aPlistObject)
  1788. { with(self)
  1789. {
  1790. return objj_msgSend(objj_msgSend(self, "alloc"), "initWithPlistObject:", aPlistObject);
  1791. }
  1792. })]);
  1793. }
  1794. objj_data.prototype.isa = CPData;
  1795. p;8;CPDate.ji;10;CPObject.ji;10;CPString.jc;4765;
  1796. var CPDateReferenceDate = new Date(Date.UTC(2001,1,1,0,0,0,0));
  1797. {var the_class = objj_allocateClassPair(CPObject, "CPDate"),
  1798. meta_class = the_class.isa;objj_registerClassPair(the_class);
  1799. objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
  1800. class_addMethods(the_class, [new objj_method(sel_getUid("initWithTimeIntervalSinceNow:"), function $CPDate__initWithTimeIntervalSinceNow_(self, _cmd, seconds)
  1801. { with(self)
  1802. {
  1803. self = new Date((new Date()).getTime() + seconds * 1000);
  1804. return self;
  1805. }
  1806. }), new objj_method(sel_getUid("initWithTimeIntervalSince1970:"), function $CPDate__initWithTimeIntervalSince1970_(self, _cmd, seconds)
  1807. { with(self)
  1808. {
  1809. self = new Date(seconds * 1000);
  1810. return self;
  1811. }
  1812. }), new objj_method(sel_getUid("initWithTimeIntervalSinceReferenceDate:"), function $CPDate__initWithTimeIntervalSinceReferenceDate_(self, _cmd, seconds)
  1813. { with(self)
  1814. {
  1815. self = objj_msgSend(self, "initWithTimeInterval:sinceDate:", seconds, CPDateReferenceDate);
  1816. return self;
  1817. }
  1818. }), new objj_method(sel_getUid("initWithTimeInterval:sinceDate:"), function $CPDate__initWithTimeInterval_sinceDate_(self, _cmd, seconds, refDate)
  1819. { with(self)
  1820. {
  1821. self = new Date(refDate.getTime() + seconds * 1000);
  1822. return self;
  1823. }
  1824. }), new objj_method(sel_getUid("initWithString:"), function $CPDate__initWithString_(self, _cmd, description)
  1825. { with(self)
  1826. {
  1827. self = new Date(description);
  1828. return self;
  1829. }
  1830. }), new objj_method(sel_getUid("timeIntervalSinceDate:"), function $CPDate__timeIntervalSinceDate_(self, _cmd, anotherDate)
  1831. { with(self)
  1832. {
  1833. return (self.getTime() - anotherDate.getTime()) / 1000.0;
  1834. }
  1835. }), new objj_method(sel_getUid("timeIntervalSinceNow"), function $CPDate__timeIntervalSinceNow(self, _cmd)
  1836. { with(self)
  1837. {
  1838. return objj_msgSend(self, "timeIntervalSinceDate:", objj_msgSend(CPDate, "date"));
  1839. }
  1840. }), new objj_method(sel_getUid("timeIntervalSince1970"), function $CPDate__timeIntervalSince1970(self, _cmd)
  1841. { with(self)
  1842. {
  1843. return self.getTime() / 1000.0;
  1844. }
  1845. }), new objj_method(sel_getUid("timeIntervalSinceReferenceDate"), function $CPDate__timeIntervalSinceReferenceDate(self, _cmd)
  1846. { with(self)
  1847. {
  1848. return (self.getTime() - CPDateReferenceDate.getTime()) / 1000.0;
  1849. }
  1850. }), new objj_method(sel_getUid("isEqualToDate:"), function $CPDate__isEqualToDate_(self, _cmd, anotherDate)
  1851. { with(self)
  1852. {
  1853. return !(self < anotherDate || self > anotherDate);
  1854. }
  1855. }), new objj_method(sel_getUid("compare:"), function $CPDate__compare_(self, _cmd, anotherDate)
  1856. { with(self)
  1857. {
  1858. return (self > anotherDate) ? CPOrderedDescending : ((self < anotherDate) ? CPOrderedAscending : CPOrderedSame);
  1859. }
  1860. }), new objj_method(sel_getUid("earlierDate:"), function $CPDate__earlierDate_(self, _cmd, anotherDate)
  1861. { with(self)
  1862. {
  1863. return (self < anotherDate) ? self : anotherDate;
  1864. }
  1865. }), new objj_method(sel_getUid("laterDate:"), function $CPDate__laterDate_(self, _cmd, anotherDate)
  1866. { with(self)
  1867. {
  1868. return (self > anotherDate) ? self : anotherDate;
  1869. }
  1870. }), new objj_method(sel_getUid("description"), function $CPDate__description(self, _cmd)
  1871. { with(self)
  1872. {
  1873. return self.toString();
  1874. }
  1875. })]);
  1876. class_addMethods(meta_class, [new objj_method(sel_getUid("alloc"), function $CPDate__alloc(self, _cmd)
  1877. { with(self)
  1878. {
  1879. return new Date;
  1880. }
  1881. }), new objj_method(sel_getUid("date"), function $CPDate__date(self, _cmd)
  1882. { with(self)
  1883. {
  1884. return objj_msgSend(objj_msgSend(self, "alloc"), "init");
  1885. }
  1886. }), new objj_method(sel_getUid("dateWithTimeIntervalSinceNow:"), function $CPDate__dateWithTimeIntervalSinceNow_(self, _cmd, seconds)
  1887. { with(self)
  1888. {
  1889. return objj_msgSend(objj_msgSend(CPDate, "alloc"), "initWithTimeIntervalSinceNow:", seconds);
  1890. }
  1891. }), new objj_method(sel_getUid("dateWithTimeIntervalSince1970:"), function $CPDate__dateWithTimeIntervalSince1970_(self, _cmd, seconds)
  1892. { with(self)
  1893. {
  1894. return objj_msgSend(objj_msgSend(CPDate, "alloc"), "initWithTimeIntervalSince1970:", seconds);
  1895. }
  1896. }), new objj_method(sel_getUid("dateWithTimeIntervalSinceReferenceDate:"), function $CPDate__dateWithTimeIntervalSinceReferenceDate_(self, _cmd, seconds)
  1897. { with(self)
  1898. {
  1899. return objj_msgSend(objj_msgSend(CPDate, "alloc"), "initWithTimeIntervalSinceReferenceDate:", seconds);
  1900. }
  1901. }), new objj_method(sel_getUid("distantPast"), function $CPDate__distantPast(self, _cmd)
  1902. { with(self)
  1903. {
  1904. return new Date(-10000,1,1,0,0,0,0);
  1905. }
  1906. }), new objj_method(sel_getUid("distantFuture"), function $CPDate__distantFuture(self, _cmd)
  1907. { with(self)
  1908. {
  1909. return new Date(10000,1,1,0,0,0,0);
  1910. }
  1911. }), new objj_method(sel_getUid("timeIntervalSinceReferenceDate"), function $CPDate__timeIntervalSinceReferenceDate(self, _cmd)
  1912. { with(self)
  1913. {
  1914. return objj_msgSend(objj_msgSend(CPDate, "date"), "timeIntervalSinceReferenceDate");
  1915. }
  1916. })]);
  1917. }
  1918. Date.prototype.isa = CPDate;
  1919. p;14;CPDictionary.ji;10;CPObject.ji;14;CPEnumerator.ji;13;CPException.jc;10057;
  1920. {var the_class = objj_allocateClassPair(CPEnumerator, "_CPDictionaryValueEnumerator"),
  1921. meta_class = the_class.isa;class_addIvars(the_class, [new objj_ivar("_keyEnumerator"), new objj_ivar("_dictionary")]);
  1922. objj_registerClassPair(the_class);
  1923. objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
  1924. class_addMethods(the_class, [new objj_method(sel_getUid("initWithDictionary:"), function $_CPDictionaryValueEnumerator__initWithDictionary_(self, _cmd, aDictionary)
  1925. { with(self)
  1926. {
  1927. self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPEnumerator") }, "init");
  1928. if (self)
  1929. {
  1930. _keyEnumerator = objj_msgSend(aDictionary, "keyEnumerator");
  1931. _dictionary = aDictionary;
  1932. }
  1933. return self;
  1934. }
  1935. }), new objj_method(sel_getUid("nextObject"), function $_CPDictionaryValueEnumerator__nextObject(self, _cmd)
  1936. { with(self)
  1937. {
  1938. var key = objj_msgSend(_keyEnumerator, "nextObject");
  1939. if (!key)
  1940. return nil;
  1941. return objj_msgSend(_dictionary, "objectForKey:", key);
  1942. }
  1943. })]);
  1944. }
  1945. {var the_class = objj_allocateClassPair(CPObject, "CPDictionary"),
  1946. meta_class = the_class.isa;objj_registerClassPair(the_class);
  1947. objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
  1948. class_addMethods(the_class, [new objj_method(sel_getUid("initWithDictionary:"), function $CPDictionary__initWithDictionary_(self, _cmd, aDictionary)
  1949. { with(self)
  1950. {
  1951. var key = "",
  1952. dictionary = objj_msgSend(objj_msgSend(CPDictionary, "alloc"), "init");
  1953. for (key in aDictionary._buckets)
  1954. objj_msgSend(dictionary, "setObject:forKey:", objj_msgSend(aDictionary, "objectForKey:", key), key);
  1955. return dictionary;
  1956. }
  1957. }), new objj_method(sel_getUid("initWithObjects:forKeys:"), function $CPDictionary__initWithObjects_forKeys_(self, _cmd, objects, keyArray)
  1958. { with(self)
  1959. {
  1960. self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPObject") }, "init");
  1961. if (objj_msgSend(objects, "count") != objj_msgSend(keyArray, "count"))
  1962. objj_msgSend(CPException, "raise:reason:", CPInvalidArgumentException, "Counts are different.("+objj_msgSend(objects, "count")+"!="+objj_msgSend(keyArray, "count")+")");
  1963. if (self)
  1964. {
  1965. var i = objj_msgSend(keyArray, "count");
  1966. while (i--)
  1967. objj_msgSend(self, "setObject:forKey:", objects[i], keyArray[i]);
  1968. }
  1969. return self;
  1970. }
  1971. }), new objj_method(sel_getUid("initWithObjectsAndKeys:"), function $CPDictionary__initWithObjectsAndKeys_(self, _cmd, firstObject)
  1972. { with(self)
  1973. {
  1974. var argCount = arguments.length;
  1975. if (argCount % 2 !== 0)
  1976. objj_msgSend(CPException, "raise:reason:", CPInvalidArgumentException, "Key-value count is mismatched. (" + argCount + " arguments passed)");
  1977. self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPObject") }, "init");
  1978. if (self)
  1979. {
  1980. var index = 2;
  1981. for(; index < argCount; index += 2)
  1982. {
  1983. var value = arguments[index];
  1984. if (value === nil)
  1985. break;
  1986. objj_msgSend(self, "setObject:forKey:", value, arguments[index + 1]);
  1987. }
  1988. }
  1989. return self;
  1990. }
  1991. }), new objj_method(sel_getUid("copy"), function $CPDictionary__copy(self, _cmd)
  1992. { with(self)
  1993. {
  1994. return objj_msgSend(CPDictionary, "dictionaryWithDictionary:", self);
  1995. }
  1996. }), new objj_method(sel_getUid("count"), function $CPDictionary__count(self, _cmd)
  1997. { with(self)
  1998. {
  1999. return count;
  2000. }
  2001. }), new objj_method(sel_getUid("allKeys"), function $CPDictionary__allKeys(self, _cmd)
  2002. { with(self)
  2003. {
  2004. return _keys;
  2005. }
  2006. }), new objj_method(sel_getUid("allValues"), function $CPDictionary__allValues(self, _cmd)
  2007. { with(self)
  2008. {
  2009. var index = _keys.length,
  2010. values = [];
  2011. while (index--)
  2012. values.push(dictionary_getValue(self, [_keys[index]]));
  2013. return values;
  2014. }
  2015. }), new objj_method(sel_getUid("keyEnumerator"), function $CPDictionary__keyEnumerator(self, _cmd)
  2016. { with(self)
  2017. {
  2018. return objj_msgSend(_keys, "objectEnumerator");
  2019. }
  2020. }), new objj_method(sel_getUid("objectEnumerator"), function $CPDictionary__objectEnumerator(self, _cmd)
  2021. { with(self)
  2022. {
  2023. return objj_msgSend(objj_msgSend(_CPDictionaryValueEnumerator, "alloc"), "initWithDictionary:", self);
  2024. }
  2025. }), new objj_method(sel_getUid("isEqualToDictionary:"), function $CPDictionary__isEqualToDictionary_(self, _cmd, aDictionary)
  2026. { with(self)
  2027. {
  2028. if (count !== objj_msgSend(aDictionary, "count"))
  2029. return NO;
  2030. var index = count;
  2031. while (index--)
  2032. {
  2033. var currentKey = _keys[index],
  2034. lhsObject = _buckets[currentKey],
  2035. rhsObject = aDictionary._buckets[currentKey];
  2036. if (lhsObject === rhsObject)
  2037. continue;
  2038. if (lhsObject.isa && rhsObject.isa && objj_msgSend(lhsObject, "respondsToSelector:", sel_getUid("isEqual:")) && objj_msgSend(lhsObject, "isEqual:", rhsObject))
  2039. continue;
  2040. return NO;
  2041. }
  2042. return YES;
  2043. }
  2044. }), new objj_method(sel_getUid("objectForKey:"), function $CPDictionary__objectForKey_(self, _cmd, aKey)
  2045. { with(self)
  2046. {
  2047. var object = _buckets[aKey];
  2048. return (object === undefined) ? nil : object;
  2049. }
  2050. }), new objj_method(sel_getUid("removeAllObjects"), function $CPDictionary__removeAllObjects(self, _cmd)
  2051. { with(self)
  2052. {
  2053. _keys = [];
  2054. count = 0;
  2055. _buckets = {};
  2056. }
  2057. }), new objj_method(sel_getUid("removeObjectForKey:"), function $CPDictionary__removeObjectForKey_(self, _cmd, aKey)
  2058. { with(self)
  2059. {
  2060. dictionary_removeValue(self, aKey);
  2061. }
  2062. }), new objj_method(sel_getUid("removeObjectsForKeys:"), function $CPDictionary__removeObjectsForKeys_(self, _cmd, allKeys)
  2063. { with(self)
  2064. {
  2065. var index = allKeys.length;
  2066. while (index--)
  2067. dictionary_removeValue(self, allKeys[index]);
  2068. }
  2069. }), new objj_method(sel_getUid("setObject:forKey:"), function $CPDictionary__setObject_forKey_(self, _cmd, anObject, aKey)
  2070. { with(self)
  2071. {
  2072. dictionary_setValue(self, aKey, anObject);
  2073. }
  2074. }), new objj_method(sel_getUid("addEntriesFromDictionary:"), function $CPDictionary__addEntriesFromDictionary_(self, _cmd, aDictionary)
  2075. { with(self)
  2076. {
  2077. if (!aDictionary)
  2078. return;
  2079. var keys = objj_msgSend(aDictionary, "allKeys"),
  2080. index = objj_msgSend(keys, "count");
  2081. while (index--)
  2082. {
  2083. var key = keys[index];
  2084. objj_msgSend(self, "setObject:forKey:", objj_msgSend(aDictionary, "objectForKey:", key), key);
  2085. }
  2086. }
  2087. }), new objj_method(sel_getUid("description"), function $CPDictionary__description(self, _cmd)
  2088. { with(self)
  2089. {
  2090. var description = "CPDictionary {\n";
  2091. var i = _keys.length;
  2092. while (i--)
  2093. {
  2094. description += _keys[i] + ":";
  2095. var object = _buckets[_keys[i]];
  2096. if (object && object.isa)
  2097. description += objj_msgSend(object, "description");
  2098. else
  2099. description += object;
  2100. description += "\n";
  2101. }
  2102. description += "}";
  2103. return description;
  2104. }
  2105. })]);
  2106. class_addMethods(meta_class, [new objj_method(sel_getUid("alloc"), function $CPDictionary__alloc(self, _cmd)
  2107. { with(self)
  2108. {
  2109. return new objj_dictionary();
  2110. }
  2111. }), new objj_method(sel_getUid("dictionary"), function $CPDictionary__dictionary(self, _cmd)
  2112. { with(self)
  2113. {
  2114. return objj_msgSend(objj_msgSend(self, "alloc"), "init");
  2115. }
  2116. }), new objj_method(sel_getUid("dictionaryWithDictionary:"), function $CPDictionary__dictionaryWithDictionary_(self, _cmd, aDictionary)
  2117. { with(self)
  2118. {
  2119. return objj_msgSend(objj_msgSend(self, "alloc"), "initWithDictionary:", aDictionary);
  2120. }
  2121. }), new objj_method(sel_getUid("dictionaryWithObject:forKey:"), function $CPDictionary__dictionaryWithObject_forKey_(self, _cmd, anObject, aKey)
  2122. { with(self)
  2123. {
  2124. return objj_msgSend(objj_msgSend(self, "alloc"), "initWithObjects:forKeys:", [anObject], [aKey]);
  2125. }
  2126. }), new objj_method(sel_getUid("dictionaryWithObjects:forKeys:"), function $CPDictionary__dictionaryWithObjects_forKeys_(self, _cmd, objects, keys)
  2127. { with(self)
  2128. {
  2129. return objj_msgSend(objj_msgSend(self, "alloc"), "initWithObjects:forKeys:", objects, keys);
  2130. }
  2131. }), new objj_method(sel_getUid("dictionaryWithJSObject:"), function $CPDictionary__dictionaryWithJSObject_(self, _cmd, object)
  2132. { with(self)
  2133. {
  2134. return objj_msgSend(self, "dictionaryWithJSObject:recursively:", object, NO);
  2135. }
  2136. }), new objj_method(sel_getUid("dictionaryWithJSObject:recursively:"), function $CPDictionary__dictionaryWithJSObject_recursively_(self, _cmd, object, recursively)
  2137. { with(self)
  2138. {
  2139. var dictionary = objj_msgSend(objj_msgSend(self, "alloc"), "init");
  2140. for (var key in object)
  2141. {
  2142. var value = object[key];
  2143. if (recursively && value.constructor === Object)
  2144. value = objj_msgSend(CPDictionary, "dictionaryWithJSObject:recursively:", value, YES);
  2145. objj_msgSend(dictionary, "setObject:forKey:", value, key);
  2146. }
  2147. return dictionary;
  2148. }
  2149. }), new objj_method(sel_getUid("dictionaryWithObjectsAndKeys:"), function $CPDictionary__dictionaryWithObjectsAndKeys_(self, _cmd, firstObject)
  2150. { with(self)
  2151. {
  2152. arguments[0] = objj_msgSend(self, "alloc");
  2153. arguments[1] = sel_getUid("initWithObjectsAndKeys:");
  2154. return objj_msgSend.apply(this, arguments);
  2155. }
  2156. })]);
  2157. }
  2158. {
  2159. var the_class = objj_getClass("CPDictionary")
  2160. if(!the_class) objj_exception_throw(new objj_exception(OBJJClassNotFoundException, "*** Could not find definition for class \"CPDictionary\""));
  2161. var meta_class = the_class.isa;class_addMethods(the_class, [new objj_method(sel_getUid("initWithCoder:"), function $CPDictionary__initWithCoder_(self, _cmd, aCoder)
  2162. { with(self)
  2163. {
  2164. return objj_msgSend(aCoder, "_decodeDictionaryOfObjectsForKey:", "CP.objects");
  2165. }
  2166. }), new objj_method(sel_getUid("encodeWithCoder:"), function $CPDictionary__encodeWithCoder_(self, _cmd, aCoder)
  2167. { with(self)
  2168. {
  2169. objj_msgSend(aCoder, "_encodeDictionaryOfObjects:forKey:", self, "CP.objects");
  2170. }
  2171. })]);
  2172. }
  2173. {var the_class = objj_allocateClassPair(CPDictionary, "CPMutableDictionary"),
  2174. meta_class = the_class.isa;objj_registerClassPair(the_class);
  2175. objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
  2176. }
  2177. objj_dictionary.prototype.isa = CPDictionary;
  2178. p;14;CPEnumerator.ji;10;CPObject.jc;500;
  2179. {var the_class = objj_allocateClassPair(CPObject, "CPEnumerator"),
  2180. meta_class = the_class.isa;objj_registerClassPair(the_class);
  2181. objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
  2182. class_addMethods(the_class, [new objj_method(sel_getUid("nextObject"), function $CPEnumerator__nextObject(self, _cmd)
  2183. { with(self)
  2184. {
  2185. return nil;
  2186. }
  2187. }), new objj_method(sel_getUid("allObjects"), function $CPEnumerator__allObjects(self, _cmd)
  2188. { with(self)
  2189. {
  2190. return [];
  2191. }
  2192. })]);
  2193. }
  2194. p;13;CPException.ji;9;CPCoder.ji;10;CPObject.ji;10;CPString.jc;4340;
  2195. CPInvalidArgumentException = "CPInvalidArgumentException";
  2196. CPUnsupportedMethodException = "CPUnsupportedMethodException";
  2197. CPRangeException = "CPRangeException";
  2198. CPInternalInconsistencyException = "CPInternalInconsistencyException";
  2199. {var the_class = objj_allocateClassPair(CPObject, "CPException"),
  2200. meta_class = the_class.isa;objj_registerClassPair(the_class);
  2201. objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
  2202. class_addMethods(the_class, [new objj_method(sel_getUid("initWithName:reason:userInfo:"), function $CPException__initWithName_reason_userInfo_(self, _cmd, aName, aReason, aUserInfo)
  2203. { with(self)
  2204. {
  2205. self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPObject") }, "init");
  2206. if (self)
  2207. {
  2208. name = aName;
  2209. reason = aReason;
  2210. userInfo = aUserInfo;
  2211. }
  2212. return self;
  2213. }
  2214. }), new objj_method(sel_getUid("name"), function $CPException__name(self, _cmd)
  2215. { with(self)
  2216. {
  2217. return name;
  2218. }
  2219. }), new objj_method(sel_getUid("reason"), function $CPException__reason(self, _cmd)
  2220. { with(self)
  2221. {
  2222. return reason;
  2223. }
  2224. }), new objj_method(sel_getUid("userInfo"), function $CPException__userInfo(self, _cmd)
  2225. { with(self)
  2226. {
  2227. return userInfo;
  2228. }
  2229. }), new objj_method(sel_getUid("description"), function $CPException__description(self, _cmd)
  2230. { with(self)
  2231. {
  2232. return reason;
  2233. }
  2234. }), new objj_method(sel_getUid("raise"), function $CPException__raise(self, _cmd)
  2235. { with(self)
  2236. {
  2237. objj_exception_throw(self);
  2238. }
  2239. })]);
  2240. class_addMethods(meta_class, [new objj_method(sel_getUid("alloc"), function $CPException__alloc(self, _cmd)
  2241. { with(self)
  2242. {
  2243. return new objj_exception();
  2244. }
  2245. }), new objj_method(sel_getUid("raise:reason:"), function $CPException__raise_reason_(self, _cmd, aName, aReason)
  2246. { with(self)
  2247. {
  2248. objj_msgSend(objj_msgSend(self, "exceptionWithName:reason:userInfo:", aName, aReason, nil), "raise");
  2249. }
  2250. }), new objj_method(sel_getUid("exceptionWithName:reason:userInfo:"), function $CPException__exceptionWithName_reason_userInfo_(self, _cmd, aName, aReason, aUserInfo)
  2251. { with(self)
  2252. {
  2253. return objj_msgSend(objj_msgSend(self, "alloc"), "initWithName:reason:userInfo:", aName, aReason, aUserInfo);
  2254. }
  2255. })]);
  2256. }
  2257. {
  2258. var the_class = objj_getClass("CPException")
  2259. if(!the_class) objj_exception_throw(new objj_exception(OBJJClassNotFoundException, "*** Could not find definition for class \"CPException\""));
  2260. var meta_class = the_class.isa;class_addMethods(the_class, [new objj_method(sel_getUid("copy"), function $CPException__copy(self, _cmd)
  2261. { with(self)
  2262. {
  2263. return objj_msgSend(objj_msgSend(self, "class"), "exceptionWithName:reason:userInfo:", name, reason, userInfo);
  2264. }
  2265. })]);
  2266. }
  2267. var CPExceptionNameKey = "CPExceptionNameKey",
  2268. CPExceptionReasonKey = "CPExceptionReasonKey",
  2269. CPExceptionUserInfoKey = "CPExceptionUserInfoKey";
  2270. {
  2271. var the_class = objj_getClass("CPException")
  2272. if(!the_class) objj_exception_throw(new objj_exception(OBJJClassNotFoundException, "*** Could not find definition for class \"CPException\""));
  2273. var meta_class = the_class.isa;class_addMethods(the_class, [new objj_method(sel_getUid("initWithCoder:"), function $CPException__initWithCoder_(self, _cmd, aCoder)
  2274. { with(self)
  2275. {
  2276. self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPObject") }, "init");
  2277. if (self)
  2278. {
  2279. name = objj_msgSend(aCoder, "decodeObjectForKey:", CPExceptionNameKey);
  2280. reason = objj_msgSend(aCoder, "decodeObjectForKey:", CPExceptionReasonKey);
  2281. userInfo = objj_msgSend(aCoder, "decodeObjectForKey:", CPExceptionUserInfoKey);
  2282. }
  2283. return self;
  2284. }
  2285. }), new objj_method(sel_getUid("encodeWithCoder:"), function $CPException__encodeWithCoder_(self, _cmd, aCoder)
  2286. { with(self)
  2287. {
  2288. objj_msgSend(aCoder, "encodeObject:forKey:", name, CPExceptionNameKey);
  2289. objj_msgSend(aCoder, "encodeObject:forKey:", reason, CPExceptionReasonKey);
  2290. objj_msgSend(aCoder, "encodeObject:forKey:", userInfo, CPExceptionUserInfoKey);
  2291. }
  2292. })]);
  2293. }
  2294. objj_exception.prototype.isa = CPException;
  2295. objj_msgSend(CPException, "initialize");
  2296. _CPRaiseInvalidAbstractInvocation= function(anObject, aSelector)
  2297. {
  2298. objj_msgSend(CPException, "raise:reason:", CPInvalidArgumentException, "*** -" + sel_getName(aSelector) + " cannot be sent to an abstract object of class " + objj_msgSend(anObject, "className") + ": Create a concrete instance!");
  2299. }
  2300. p;12;CPIndexSet.ji;9;CPRange.ji;10;CPObject.jc;18435;
  2301. {var the_class = objj_allocateClassPair(CPObject, "CPIndexSet"),
  2302. meta_class = the_class.isa;class_addIvars(the_class, [new objj_ivar("_count"), new objj_ivar("_cachedRangeIndex"), new objj_ivar("_ranges")]);
  2303. objj_registerClassPair(the_class);
  2304. objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
  2305. class_addMethods(the_class, [new objj_method(sel_getUid("init"), function $CPIndexSet__init(self, _cmd)
  2306. { with(self)
  2307. {
  2308. self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPObject") }, "init");
  2309. if (self)
  2310. {
  2311. _count = 0;
  2312. _ranges = [];
  2313. _cachedRangeIndex = 0;
  2314. }
  2315. return self;
  2316. }
  2317. }), new objj_method(sel_getUid("initWithIndex:"), function $CPIndexSet__initWithIndex_(self, _cmd, anIndex)
  2318. { with(self)
  2319. {
  2320. self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPObject") }, "init");
  2321. if (self)
  2322. {
  2323. _count = 1;
  2324. _ranges = objj_msgSend(CPArray, "arrayWithObject:", CPMakeRange(anIndex, 1));
  2325. _cachedRangeIndex = 0;
  2326. }
  2327. return self;
  2328. }
  2329. }), new objj_method(sel_getUid("initWithIndexesInRange:"), function $CPIndexSet__initWithIndexesInRange_(self, _cmd, aRange)
  2330. { with(self)
  2331. {
  2332. self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPObject") }, "init");
  2333. if (self)
  2334. {
  2335. _count = aRange.length;
  2336. _ranges = objj_msgSend(CPArray, "arrayWithObject:", aRange);
  2337. _cachedRangeIndex = 0;
  2338. }
  2339. return self;
  2340. }
  2341. }), new objj_method(sel_getUid("initWithIndexSet:"), function $CPIndexSet__initWithIndexSet_(self, _cmd, anIndexSet)
  2342. { with(self)
  2343. {
  2344. self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPObject") }, "init");
  2345. if (self)
  2346. {
  2347. _count = objj_msgSend(anIndexSet, "count");
  2348. _ranges = [];
  2349. _cachedRangeIndex = 0;
  2350. var index = 0,
  2351. count = anIndexSet._ranges.length;
  2352. for (; index < count; ++index)
  2353. _ranges.push(CPCopyRange(anIndexSet._ranges[index]));
  2354. }
  2355. return self;
  2356. }
  2357. }), new objj_method(sel_getUid("isEqualToIndexSet:"), function $CPIndexSet__isEqualToIndexSet_(self, _cmd, anIndexSet)
  2358. { with(self)
  2359. {
  2360. if (self == anIndexSet)
  2361. return YES;
  2362. var i = 0,
  2363. count = _ranges.length;
  2364. otherRanges = anIndexSet._ranges;
  2365. if (count != otherRanges.length || _count != objj_msgSend(anIndexSet, "count"))
  2366. return NO;
  2367. for (; i < count; ++i)
  2368. if (!CPEqualRanges(_ranges[i], otherRanges[i]))
  2369. return NO;
  2370. return YES;
  2371. }
  2372. }), new objj_method(sel_getUid("containsIndex:"), function $CPIndexSet__containsIndex_(self, _cmd, anIndex)
  2373. { with(self)
  2374. {
  2375. return objj_msgSend(self, "containsIndexesInRange:", CPMakeRange(anIndex, 1));
  2376. }
  2377. }), new objj_method(sel_getUid("containsIndexesInRange:"), function $CPIndexSet__containsIndexesInRange_(self, _cmd, aRange)
  2378. { with(self)
  2379. {
  2380. if(!_count)
  2381. return NO;
  2382. var i = SOERangeIndex(self, aRange.location),
  2383. lower = aRange.location,
  2384. upper = CPMaxRange(aRange),
  2385. count = _ranges.length;
  2386. for(;i < count && _ranges[i].location < upper; ++i)
  2387. if (_ranges[i].location <= lower && CPMaxRange(_ranges[i]) >= upper)
  2388. {
  2389. _cachedRangeIndex = i;
  2390. return YES;
  2391. }
  2392. _cachedRangeIndex = i;
  2393. return NO;
  2394. }
  2395. }), new objj_method(sel_getUid("containsIndexes:"), function $CPIndexSet__containsIndexes_(self, _cmd, anIndexSet)
  2396. { with(self)
  2397. {
  2398. if(!objj_msgSend(anIndexSet, "count"))
  2399. return YES;
  2400. if(!_count)
  2401. return NO;
  2402. var i = 0,
  2403. count = _ranges.length;
  2404. for(; i < count; ++i)
  2405. if (!objj_msgSend(anIndexSet, "containsIndexesInRange:", _ranges[i]))
  2406. return NO;
  2407. return YES;
  2408. }
  2409. }), new objj_method(sel_getUid("intersectsIndexesInRange:"), function $CPIndexSet__intersectsIndexesInRange_(self, _cmd, aRange)
  2410. { with(self)
  2411. {
  2412. if(!_count)
  2413. return NO;
  2414. var i = SOERangeIndex(self, aRange.location),
  2415. count = _ranges.length,
  2416. upper = CPMaxRange(aRange);
  2417. for (; i < count && _ranges[i].location < upper; ++i)
  2418. if(CPIntersectionRange(aRange, _ranges[i]).length)
  2419. return YES;
  2420. return NO;
  2421. }
  2422. }), new objj_method(sel_getUid("count"), function $CPIndexSet__count(self, _cmd)
  2423. { with(self)
  2424. {
  2425. return _count;
  2426. }
  2427. }), new objj_method(sel_getUid("firstIndex"), function $CPIndexSet__firstIndex(self, _cmd)
  2428. { with(self)
  2429. {
  2430. return _count ? _ranges[0].location : CPNotFound;
  2431. }
  2432. }), new objj_method(sel_getUid("lastIndex"), function $CPIndexSet__lastIndex(self, _cmd)
  2433. { with(self)
  2434. {
  2435. return _count ? CPMaxRange(_ranges[_ranges.length - 1]) - 1 : CPNotFound;
  2436. }
  2437. }), new objj_method(sel_getUid("indexGreaterThanIndex:"), function $CPIndexSet__indexGreaterThanIndex_(self, _cmd, anIndex)
  2438. { with(self)
  2439. {
  2440. if(!_count)
  2441. return CPNotFound;
  2442. var i = SOERangeIndex(self, anIndex++),
  2443. count = _ranges.length;
  2444. for(; i < count && anIndex >= CPMaxRange(_ranges[i]); ++i) ;
  2445. if (i == count)
  2446. return CPNotFound;
  2447. _cachedRangeIndex = i;
  2448. if (anIndex < _ranges[i].location)
  2449. return _ranges[i].location;
  2450. return anIndex;
  2451. }
  2452. }), new objj_method(sel_getUid("indexLessThanIndex:"), function $CPIndexSet__indexLessThanIndex_(self, _cmd, anIndex)
  2453. { with(self)
  2454. {
  2455. if (!_count)
  2456. return CPNotFound;
  2457. var i = GOERangeIndex(self, anIndex--);
  2458. for (; i >= 0 && anIndex < _ranges[i].location; --i) ;
  2459. if(i < 0)
  2460. return CPNotFound;
  2461. _cachedRangeIndex = i;
  2462. if (CPLocationInRange(anIndex, _ranges[i]))
  2463. return anIndex;
  2464. if (CPMaxRange(_ranges[i]) - 1 < anIndex)
  2465. return CPMaxRange(_ranges[i]) - 1;
  2466. return CPNotFound;
  2467. }
  2468. }), new objj_method(sel_getUid("indexGreaterThanOrEqualToIndex:"), function $CPIndexSet__indexGreaterThanOrEqualToIndex_(self, _cmd, anIndex)
  2469. { with(self)
  2470. {
  2471. return objj_msgSend(self, "indexGreaterThanIndex:", anIndex - 1);
  2472. }
  2473. }), new objj_method(sel_getUid("indexLessThanOrEqualToIndex:"), function $CPIndexSet__indexLessThanOrEqualToIndex_(self, _cmd, anIndex)
  2474. { with(self)
  2475. {
  2476. return objj_msgSend(self, "indexLessThanIndex:", anIndex + 1);
  2477. }
  2478. }), new objj_method(sel_getUid("getIndexes:maxCount:inIndexRange:"), function $CPIndexSet__getIndexes_maxCount_inIndexRange_(self, _cmd, anArray, aMaxCount, aRangePointer)
  2479. { with(self)
  2480. {
  2481. if (!_count || aMaxCount <= 0 || aRangePointer && !aRangePointer.length)
  2482. return 0;
  2483. var i = SOERangeIndex(self, aRangePointer? aRangePointer.location : 0),
  2484. total = 0,
  2485. count = _ranges.length;
  2486. for (; i < count; ++i)
  2487. {
  2488. var intersection = aRangePointer ? CPIntersectionRange(_ranges[i], aRangePointer) : _ranges[i],
  2489. index = intersection.location,
  2490. maximum = CPMaxRange(intersection);
  2491. for (; index < maximum; ++index)
  2492. {
  2493. anArray[total++] = index;
  2494. if (total == aMaxCount)
  2495. {
  2496. if (aRangePointer)
  2497. {
  2498. var upper = CPMaxRange(aRangePointer);
  2499. aRangePointer.location = index + 1;
  2500. aRangePointer.length = upper - index - 1;
  2501. }
  2502. return aMaxCount;
  2503. }
  2504. }
  2505. }
  2506. if (aRangePointer)
  2507. {
  2508. aRangePointer.location = CPNotFound;
  2509. aRangePointer.length = 0;
  2510. }
  2511. return total;
  2512. }
  2513. }), new objj_method(sel_getUid("description"), function $CPIndexSet__description(self, _cmd)
  2514. { with(self)
  2515. {
  2516. var desc = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPObject") }, "description") + " ";
  2517. if (_count)
  2518. {
  2519. desc += "[number of indexes: " + _count + " (in " + _ranges.length + " ranges), indexes: (";
  2520. for (i = 0; i < _ranges.length; i++)
  2521. {
  2522. desc += _ranges[i].location;
  2523. if (_ranges[i].length > 1) desc += "-" + (CPMaxRange(_ranges[i])-1) + ":"+_ranges[i].length+":";
  2524. if (i+1 < _ranges.length) desc += " ";
  2525. }
  2526. desc += ")]";
  2527. }
  2528. else
  2529. desc += "(no indexes)";
  2530. return desc;
  2531. }
  2532. })]);
  2533. class_addMethods(meta_class, [new objj_method(sel_getUid("indexSet"), function $CPIndexSet__indexSet(self, _cmd)
  2534. { with(self)
  2535. {
  2536. return objj_msgSend(objj_msgSend(self, "alloc"), "init");
  2537. }
  2538. }), new objj_method(sel_getUid("indexSetWithIndex:"), function $CPIndexSet__indexSetWithIndex_(self, _cmd, anIndex)
  2539. { with(self)
  2540. {
  2541. return objj_msgSend(objj_msgSend(self, "alloc"), "initWithIndex:", anIndex);
  2542. }
  2543. }), new objj_method(sel_getUid("indexSetWithIndexesInRange:"), function $CPIndexSet__indexSetWithIndexesInRange_(self, _cmd, aRange)
  2544. { with(self)
  2545. {
  2546. return objj_msgSend(objj_msgSend(self, "alloc"), "initWithIndexesInRange:", aRange);
  2547. }
  2548. })]);
  2549. }
  2550. {
  2551. var the_class = objj_getClass("CPIndexSet")
  2552. if(!the_class) objj_exception_throw(new objj_exception(OBJJClassNotFoundException, "*** Could not find definition for class \"CPIndexSet\""));
  2553. var meta_class = the_class.isa;class_addMethods(the_class, [new objj_method(sel_getUid("addIndex:"), function $CPIndexSet__addIndex_(self, _cmd, anIndex)
  2554. { with(self)
  2555. {
  2556. objj_msgSend(self, "addIndexesInRange:", CPMakeRange(anIndex, 1));
  2557. }
  2558. }), new objj_method(sel_getUid("addIndexes:"), function $CPIndexSet__addIndexes_(self, _cmd, anIndexSet)
  2559. { with(self)
  2560. {
  2561. var i = 0,
  2562. ranges = anIndexSet._ranges,
  2563. count = ranges.length;
  2564. for(; i < count; ++i)
  2565. objj_msgSend(self, "addIndexesInRange:", ranges[i]);
  2566. }
  2567. }), new objj_method(sel_getUid("addIndexesInRange:"), function $CPIndexSet__addIndexesInRange_(self, _cmd, aRange)
  2568. { with(self)
  2569. {
  2570. if (_ranges.length == 0)
  2571. {
  2572. _count = aRange.length;
  2573. return objj_msgSend(_ranges, "addObject:", CPCopyRange(aRange));
  2574. }
  2575. var i = SOERangeIndex(self, aRange.location),
  2576. count = _ranges.length,
  2577. padded = CPMakeRange(aRange.location - 1, aRange.length + 2),
  2578. maximum = CPMaxRange(aRange);
  2579. if (count && CPMaxRange(_ranges[count - 1]) < aRange.location)
  2580. objj_msgSend(_ranges, "addObject:", CPCopyRange(aRange));
  2581. else
  2582. for (; i < count; ++i)
  2583. {
  2584. if (maximum < _ranges[i].location)
  2585. {
  2586. _count += aRange.length;
  2587. if (i < _cachedRangeIndex) ++_cachedRangeIndex;
  2588. return objj_msgSend(_ranges, "insertObject:atIndex:", CPCopyRange(aRange), i);
  2589. }
  2590. if (CPIntersectionRange(_ranges[i], padded).length)
  2591. {
  2592. var union = CPUnionRange(_ranges[i], aRange);
  2593. if (union.length == _ranges[i].length)
  2594. return;
  2595. ++union.length;
  2596. var j = i;
  2597. for(; j < count; ++j)
  2598. if(CPIntersectionRange(union, _ranges[j]).length)
  2599. _count -= _ranges[j].length;
  2600. else
  2601. break;
  2602. --union.length;
  2603. _ranges[i] = union;
  2604. if (j - i - 1 > 0)
  2605. {
  2606. var remove = CPMakeRange(i + 1, j - i - 1);
  2607. _ranges[i] = CPUnionRange(_ranges[i], _ranges[j - 1]);
  2608. objj_msgSend(_ranges, "removeObjectsInRange:", remove);
  2609. if (_cachedRangeIndex >= CPMaxRange(remove)) _cachedRangedIndex -= remove.length;
  2610. else if (CPLocationInRange(_cachedRangeIndex, remove)) _cachedRangeIndex = i;
  2611. }
  2612. _count += _ranges[i].length;
  2613. return;
  2614. }
  2615. }
  2616. _count += aRange.length;
  2617. }
  2618. }), new objj_method(sel_getUid("removeIndex:"), function $CPIndexSet__removeIndex_(self, _cmd, anIndex)
  2619. { with(self)
  2620. {
  2621. objj_msgSend(self, "removeIndexesInRange:", CPMakeRange(anIndex, 1));
  2622. }
  2623. }), new objj_method(sel_getUid("removeIndexes:"), function $CPIndexSet__removeIndexes_(self, _cmd, anIndexSet)
  2624. { with(self)
  2625. {
  2626. var i = 0,
  2627. ranges = anIndexSet._ranges,
  2628. count = ranges.length;
  2629. for(; i < count; ++i)
  2630. objj_msgSend(self, "removeIndexesInRange:", ranges[i]);
  2631. }
  2632. }), new objj_method(sel_getUid("removeAllIndexes"), function $CPIndexSet__removeAllIndexes(self, _cmd)
  2633. { with(self)
  2634. {
  2635. _ranges = [];
  2636. _count = 0;
  2637. _cachedRangeIndex = 0;
  2638. }
  2639. }), new objj_method(sel_getUid("removeIndexesInRange:"), function $CPIndexSet__removeIndexesInRange_(self, _cmd, aRange)
  2640. { with(self)
  2641. {
  2642. var i = SOERangeIndex(self, aRange.location),
  2643. count = _ranges.length,
  2644. maximum = CPMaxRange(aRange),
  2645. removal = CPMakeRange(CPNotFound, 0);
  2646. for (; i < count; ++i)
  2647. {
  2648. var range = _ranges[i];
  2649. if (maximum < range.location)
  2650. break;
  2651. var intersection = CPIntersectionRange(range, aRange);
  2652. if (!intersection.length)
  2653. continue;
  2654. else if (intersection.length == range.length)
  2655. {
  2656. if (removal.location == CPNotFound)
  2657. removal = CPMakeRange(i, 1);
  2658. else
  2659. ++removal.length;
  2660. }
  2661. else if (intersection.location > range.location && CPMaxRange(intersection) < CPMaxRange(range))
  2662. {
  2663. var insert = CPMakeRange(CPMaxRange(intersection), CPMaxRange(range) - CPMaxRange(intersection));
  2664. range.length = intersection.location - range.location;
  2665. _count -= intersection.length;
  2666. return objj_msgSend(_ranges, "insertObject:atIndex:", insert, i + 1);
  2667. }
  2668. else
  2669. {
  2670. range.length -= intersection.length;
  2671. if (intersection.location <= range.location)
  2672. range.location += intersection.length;
  2673. }
  2674. _count -= intersection.length;
  2675. }
  2676. if (removal.length)
  2677. objj_msgSend(_ranges, "removeObjectsInRange:", removal);
  2678. }
  2679. }), new objj_method(sel_getUid("shiftIndexesStartingAtIndex:by:"), function $CPIndexSet__shiftIndexesStartingAtIndex_by_(self, _cmd, anIndex, aDelta)
  2680. { with(self)
  2681. {
  2682. if (!_count || aDelta == 0)
  2683. return;
  2684. var i = _ranges.length - 1,
  2685. shifted = CPMakeRange(CPNotFound, 0);
  2686. for(; i >= 0; --i)
  2687. {
  2688. var range = _ranges[i],
  2689. maximum = CPMaxRange(range);
  2690. if (anIndex > maximum)
  2691. break;
  2692. if (anIndex > range.location && anIndex < maximum)
  2693. {
  2694. shifted = CPMakeRange(anIndex + aDelta, maximum - anIndex);
  2695. range.length = anIndex - range.location;
  2696. if (aDelta > 0)
  2697. objj_msgSend(_ranges, "insertObject:atIndex:", shifted, i + 1);
  2698. else if (shifted.location < 0)
  2699. {
  2700. shifted.length = CPMaxRange(shifted);
  2701. shifted.location = 0;
  2702. }
  2703. break;
  2704. }
  2705. if ((range.location += aDelta) < 0)
  2706. {
  2707. range.length = CPMaxRange(range);
  2708. range.location = 0;
  2709. }
  2710. }
  2711. if (aDelta < 0)
  2712. {
  2713. var j = i + 1,
  2714. count = _ranges.length,
  2715. shifts = [];
  2716. for (; j < count; ++j)
  2717. objj_msgSend(shifts, "addObject:", _ranges[j]);
  2718. if ((j = i + 1) < count)
  2719. {
  2720. objj_msgSend(_ranges, "removeObjectsInRange:", CPMakeRange(j, count - j));
  2721. for (j = 0, count = shifts.length; j < count; ++j)
  2722. objj_msgSend(self, "addIndexesInRange:", shifts[j]);
  2723. }
  2724. if (shifted.location != CPNotFound)
  2725. objj_msgSend(self, "addIndexesInRange:", shifted);
  2726. }
  2727. }
  2728. })]);
  2729. }
  2730. var CPIndexSetCountKey = "CPIndexSetCountKey",
  2731. CPIndexSetCachedRangeIndexKey = "CPIndexSetCachedRangeIndexKey",
  2732. CPIndexSetRangeStringsKey = "CPIndexSetRangeStringsKey";
  2733. {
  2734. var the_class = objj_getClass("CPIndexSet")
  2735. if(!the_class) objj_exception_throw(new objj_exception(OBJJClassNotFoundException, "*** Could not find definition for class \"CPIndexSet\""));
  2736. var meta_class = the_class.isa;class_addMethods(the_class, [new objj_method(sel_getUid("initWithCoder:"), function $CPIndexSet__initWithCoder_(self, _cmd, aCoder)
  2737. { with(self)
  2738. {
  2739. self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPObject") }, "init");
  2740. if (self)
  2741. {
  2742. _count = objj_msgSend(aCoder, "decodeIntForKey:", CPIndexSetCountKey);
  2743. _cachedRangeIndex = objj_msgSend(aCoder, "decodeIntForKey:", CPIndexSetCachedRangeIndexKey);
  2744. _ranges = [];
  2745. var rangeStrings = objj_msgSend(aCoder, "decodeObjectForKey:", CPIndexSetRangeStringsKey),
  2746. index = 0,
  2747. count = rangeStrings.length;
  2748. for (; index < count; ++index)
  2749. _ranges.push(CPRangeFromString(rangeStrings[index]));
  2750. }
  2751. return self;
  2752. }
  2753. }), new objj_method(sel_getUid("encodeWithCoder:"), function $CPIndexSet__encodeWithCoder_(self, _cmd, aCoder)
  2754. { with(self)
  2755. {
  2756. objj_msgSend(aCoder, "encodeInt:forKey:", _count, CPIndexSetCountKey);
  2757. objj_msgSend(aCoder, "encodeInt:forKey:", _cachedRangeIndex, CPIndexSetCachedRangeIndexKey);
  2758. var index = 0,
  2759. count = _ranges.length,
  2760. rangeStrings = [];
  2761. for (; index < count; ++index)
  2762. rangeStrings[index] = CPStringFromRange(_ranges[index]);
  2763. objj_msgSend(aCoder, "encodeObject:forKey:", rangeStrings, CPIndexSetRangeStringsKey);
  2764. }
  2765. })]);
  2766. }
  2767. {
  2768. var the_class = objj_getClass("CPIndexSet")
  2769. if(!the_class) objj_exception_throw(new objj_exception(OBJJClassNotFoundException, "*** Could not find definition for class \"CPIndexSet\""));
  2770. var meta_class = the_class.isa;class_addMethods(the_class, [new objj_method(sel_getUid("copy"), function $CPIndexSet__copy(self, _cmd)
  2771. { with(self)
  2772. {
  2773. return objj_msgSend(objj_msgSend(objj_msgSend(self, "class"), "alloc"), "initWithIndexSet:", self);
  2774. }
  2775. }), new objj_method(sel_getUid("mutableCopy"), function $CPIndexSet__mutableCopy(self, _cmd)
  2776. { with(self)
  2777. {
  2778. return objj_msgSend(objj_msgSend(objj_msgSend(self, "class"), "alloc"), "initWithIndexSet:", self);
  2779. }
  2780. })]);
  2781. }
  2782. {var the_class = objj_allocateClassPair(CPIndexSet, "CPMutableIndexSet"),
  2783. meta_class = the_class.isa;objj_registerClassPair(the_class);
  2784. objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
  2785. }
  2786. var SOERangeIndex = function(anIndexSet, anIndex)
  2787. {
  2788. var ranges = anIndexSet._ranges,
  2789. cachedRangeIndex = 0;
  2790. if(cachedRangeIndex < ranges.length && anIndex >= ranges[cachedRangeIndex].location)
  2791. return cachedRangeIndex;
  2792. return 0;
  2793. }
  2794. var GOERangeIndex = function(anIndexSet, anIndex)
  2795. {
  2796. var ranges = anIndexSet._ranges,
  2797. cachedRangeIndex = anIndexSet._ranges.length;
  2798. if(cachedRangeIndex < ranges.length && anIndex <= ranges[cachedRangeIndex].location)
  2799. return cachedRangeIndex;
  2800. return ranges.length - 1;
  2801. }
  2802. p;14;CPInvocation.ji;10;CPObject.ji;13;CPException.jc;3770;
  2803. {var the_class = objj_allocateClassPair(CPObject, "CPInvocation"),
  2804. meta_class = the_class.isa;class_addIvars(the_class, [new objj_ivar("_returnValue"), new objj_ivar("_arguments"), new objj_ivar("_methodSignature")]);
  2805. objj_registerClassPair(the_class);
  2806. objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
  2807. class_addMethods(the_class, [new objj_method(sel_getUid("initWithMethodSignature:"), function $CPInvocation__initWithMethodSignature_(self, _cmd, aMethodSignature)
  2808. { with(self)
  2809. {
  2810. self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPObject") }, "init");
  2811. if (self)
  2812. {
  2813. _arguments = [];
  2814. _methodSignature = aMethodSignature;
  2815. }
  2816. return self;
  2817. }
  2818. }), new objj_method(sel_getUid("setSelector:"), function $CPInvocation__setSelector_(self, _cmd, aSelector)
  2819. { with(self)
  2820. {
  2821. _arguments[1] = aSelector;
  2822. }
  2823. }), new objj_method(sel_getUid("selector"), function $CPInvocation__selector(self, _cmd)
  2824. { with(self)
  2825. {
  2826. return _arguments[1];
  2827. }
  2828. }), new objj_method(sel_getUid("setTarget:"), function $CPInvocation__setTarget_(self, _cmd, aTarget)
  2829. { with(self)
  2830. {
  2831. _arguments[0] = aTarget;
  2832. }
  2833. }), new objj_method(sel_getUid("target"), function $CPInvocation__target(self, _cmd)
  2834. { with(self)
  2835. {
  2836. return _arguments[0];
  2837. }
  2838. }), new objj_method(sel_getUid("setArgument:atIndex:"), function $CPInvocation__setArgument_atIndex_(self, _cmd, anArgument, anIndex)
  2839. { with(self)
  2840. {
  2841. _arguments[anIndex] = anArgument;
  2842. }
  2843. }), new objj_method(sel_getUid("argumentAtIndex:"), function $CPInvocation__argumentAtIndex_(self, _cmd, anIndex)
  2844. { with(self)
  2845. {
  2846. return _arguments[anIndex];
  2847. }
  2848. }), new objj_method(sel_getUid("setReturnValue:"), function $CPInvocation__setReturnValue_(self, _cmd, aReturnValue)
  2849. { with(self)
  2850. {
  2851. _returnValue = aReturnValue;
  2852. }
  2853. }), new objj_method(sel_getUid("returnValue"), function $CPInvocation__returnValue(self, _cmd)
  2854. { with(self)
  2855. {
  2856. return _returnValue;
  2857. }
  2858. }), new objj_method(sel_getUid("invoke"), function $CPInvocation__invoke(self, _cmd)
  2859. { with(self)
  2860. {
  2861. _returnValue = objj_msgSend.apply(objj_msgSend, _arguments);
  2862. }
  2863. }), new objj_method(sel_getUid("invokeWithTarget:"), function $CPInvocation__invokeWithTarget_(self, _cmd, aTarget)
  2864. { with(self)
  2865. {
  2866. _arguments[0] = aTarget;
  2867. _returnValue = objj_msgSend.apply(objj_msgSend, _arguments);
  2868. }
  2869. })]);
  2870. class_addMethods(meta_class, [new objj_method(sel_getUid("invocationWithMethodSignature:"), function $CPInvocation__invocationWithMethodSignature_(self, _cmd, aMethodSignature)
  2871. { with(self)
  2872. {
  2873. return objj_msgSend(objj_msgSend(self, "alloc"), "initWithMethodSignature:", aMethodSignature);
  2874. }
  2875. })]);
  2876. }
  2877. var CPInvocationArguments = "CPInvocationArguments",
  2878. CPInvocationReturnValue = "CPInvocationReturnValue";
  2879. {
  2880. var the_class = objj_getClass("CPInvocation")
  2881. if(!the_class) objj_exception_throw(new objj_exception(OBJJClassNotFoundException, "*** Could not find definition for class \"CPInvocation\""));
  2882. var meta_class = the_class.isa;class_addMethods(the_class, [new objj_method(sel_getUid("initWithCoder:"), function $CPInvocation__initWithCoder_(self, _cmd, aCoder)
  2883. { with(self)
  2884. {
  2885. self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPObject") }, "init");
  2886. if (self)
  2887. {
  2888. _returnValue = objj_msgSend(aCoder, "decodeObjectForKey:", CPInvocationReturnValue);
  2889. _arguments = objj_msgSend(aCoder, "decodeObjectForKey:", CPInvocationArguments);
  2890. }
  2891. return self;
  2892. }
  2893. }), new objj_method(sel_getUid("encodeWithCoder:"), function $CPInvocation__encodeWithCoder_(self, _cmd, aCoder)
  2894. { with(self)
  2895. {
  2896. objj_msgSend(aCoder, "encodeObject:forKey:", _returnValue, CPInvocationReturnValue);
  2897. objj_msgSend(aCoder, "encodeObject:forKey:", _arguments, CPInvocationArguments);
  2898. }
  2899. })]);
  2900. }
  2901. p;19;CPJSONPConnection.jI;21;Foundation/CPObject.jc;3725;
  2902. CPJSONPConnectionCallbacks = {};
  2903. {var the_class = objj_allocateClassPair(CPObject, "CPJSONPConnection"),
  2904. meta_class = the_class.isa;class_addIvars(the_class, [new objj_ivar("_request"), new objj_ivar("_delegate"), new objj_ivar("_callbackParameter"), new objj_ivar("_scriptTag")]);
  2905. objj_registerClassPair(the_class);
  2906. objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
  2907. class_addMethods(the_class, [new objj_method(sel_getUid("initWithRequest:callback:delegate:"), function $CPJSONPConnection__initWithRequest_callback_delegate_(self, _cmd, aRequest, aString, aDelegate)
  2908. { with(self)
  2909. {
  2910. return objj_msgSend(self, "initWithRequest:callback:delegate:startImmediately:", aRequest, aString, aDelegate, NO);
  2911. }
  2912. }), new objj_method(sel_getUid("initWithRequest:callback:delegate:startImmediately:"), function $CPJSONPConnection__initWithRequest_callback_delegate_startImmediately_(self, _cmd, aRequest, aString, aDelegate, shouldStartImmediately)
  2913. { with(self)
  2914. {
  2915. self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPObject") }, "init");
  2916. _request = aRequest;
  2917. _delegate = aDelegate;
  2918. _callbackParameter = aString;
  2919. CPJSONPConnectionCallbacks["callback"+objj_msgSend(self, "hash")] = function(data)
  2920. {
  2921. objj_msgSend(_delegate, "connection:didReceiveData:", self, data);
  2922. objj_msgSend(self, "removeScriptTag");
  2923. objj_msgSend(objj_msgSend(CPRunLoop, "currentRunLoop"), "limitDateForMode:", CPDefaultRunLoopMode);
  2924. };
  2925. if(shouldStartImmediately)
  2926. objj_msgSend(self, "start");
  2927. return self;
  2928. }
  2929. }), new objj_method(sel_getUid("start"), function $CPJSONPConnection__start(self, _cmd)
  2930. { with(self)
  2931. {
  2932. try
  2933. {
  2934. var head = document.getElementsByTagName("head").item(0);
  2935. var source = objj_msgSend(_request, "URL");
  2936. source += (source.indexOf('?') < 0) ? "?" : "&";
  2937. source += _callbackParameter+"=CPJSONPConnectionCallbacks.callback"+objj_msgSend(self, "hash");
  2938. _scriptTag = document.createElement("script");
  2939. _scriptTag.setAttribute("type", "text/javascript");
  2940. _scriptTag.setAttribute("charset", "utf-8");
  2941. _scriptTag.setAttribute("src", source);
  2942. head.appendChild(_scriptTag);
  2943. }
  2944. catch (exception)
  2945. {
  2946. objj_msgSend(_delegate, "connection:didFailWithError:", self, exception);
  2947. objj_msgSend(self, "removeScriptTag");
  2948. }
  2949. }
  2950. }), new objj_method(sel_getUid("removeScriptTag"), function $CPJSONPConnection__removeScriptTag(self, _cmd)
  2951. { with(self)
  2952. {
  2953. var head = document.getElementsByTagName("head").item(0);
  2954. if(_scriptTag.parentNode == head)
  2955. head.removeChild(_scriptTag);
  2956. CPJSONPConnectionCallbacks["callback"+objj_msgSend(self, "hash")] = nil;
  2957. delete CPJSONPConnectionCallbacks["callback"+objj_msgSend(self, "hash")];
  2958. }
  2959. }), new objj_method(sel_getUid("cancel"), function $CPJSONPConnection__cancel(self, _cmd)
  2960. { with(self)
  2961. {
  2962. objj_msgSend(self, "removeScriptTag");
  2963. }
  2964. })]);
  2965. class_addMethods(meta_class, [new objj_method(sel_getUid("sendRequest:callback:delegate:"), function $CPJSONPConnection__sendRequest_callback_delegate_(self, _cmd, aRequest, callbackParameter, aDelegate)
  2966. { with(self)
  2967. {
  2968. return objj_msgSend(self, "connectionWithRequest:callback:delegate:", aRequest, callbackParameter, aDelegate);
  2969. }
  2970. }), new objj_method(sel_getUid("connectionWithRequest:callback:delegate:"), function $CPJSONPConnection__connectionWithRequest_callback_delegate_(self, _cmd, aRequest, callbackParameter, aDelegate)
  2971. { with(self)
  2972. {
  2973. return objj_msgSend(objj_msgSend(objj_msgSend(self, "class"), "alloc"), "initWithRequest:callback:delegate:startImmediately:", aRequest, callbackParameter, aDelegate, YES);;
  2974. }
  2975. })]);
  2976. }
  2977. p;17;CPKeyedArchiver.ji;8;CPData.ji;9;CPCoder.ji;9;CPArray.ji;10;CPString.ji;10;CPNumber.ji;14;CPDictionary.ji;9;CPValue.jc;16071;
  2978. var CPArchiverReplacementClassNames = nil;
  2979. var _CPKeyedArchiverDidEncodeObjectSelector = 1,
  2980. _CPKeyedArchiverWillEncodeObjectSelector = 2,
  2981. _CPKeyedArchiverWillReplaceObjectWithObjectSelector = 4,
  2982. _CPKeyedArchiverDidFinishSelector = 8,
  2983. _CPKeyedArchiverWillFinishSelector = 16;
  2984. var _CPKeyedArchiverNullString = "$null",
  2985. _CPKeyedArchiverNullReference = nil,
  2986. _CPKeyedArchiverUIDKey = "CP$UID",
  2987. _CPKeyedArchiverTopKey = "$top",
  2988. _CPKeyedArchiverObjectsKey = "$objects",
  2989. _CPKeyedArchiverArchiverKey = "$archiver",
  2990. _CPKeyedArchiverVersionKey = "$version",
  2991. _CPKeyedArchiverClassNameKey = "$classname",
  2992. _CPKeyedArchiverClassesKey = "$classes",
  2993. _CPKeyedArchiverClassKey = "$class";
  2994. var _CPKeyedArchiverStringClass = Nil,
  2995. _CPKeyedArchiverNumberClass = Nil;
  2996. {var the_class = objj_allocateClassPair(CPValue, "_CPKeyedArchiverValue"),
  2997. meta_class = the_class.isa;objj_registerClassPair(the_class);
  2998. objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
  2999. }
  3000. {var the_class = objj_allocateClassPair(CPCoder, "CPKeyedArchiver"),
  3001. meta_class = the_class.isa;class_addIvars(the_class, [new objj_ivar("_delegate"), new objj_ivar("_delegateSelectors"), new objj_ivar("_data"), new objj_ivar("_objects"), new objj_ivar("_UIDs"), new objj_ivar("_conditionalUIDs"), new objj_ivar("_replacementObjects"), new objj_ivar("_replacementClassNames"), new objj_ivar("_plistObject"), new objj_ivar("_plistObjects"), new objj_ivar("_outputFormat")]);
  3002. objj_registerClassPair(the_class);
  3003. objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
  3004. class_addMethods(the_class, [new objj_method(sel_getUid("initForWritingWithMutableData:"), function $CPKeyedArchiver__initForWritingWithMutableData_(self, _cmd, data)
  3005. { with(self)
  3006. {
  3007. self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPCoder") }, "init");
  3008. if (self)
  3009. {
  3010. _data = data;
  3011. _objects = [];
  3012. _UIDs = objj_msgSend(CPDictionary, "dictionary");
  3013. _conditionalUIDs = objj_msgSend(CPDictionary, "dictionary");
  3014. _replacementObjects = objj_msgSend(CPDictionary, "dictionary");
  3015. _data = data;
  3016. _plistObject = objj_msgSend(CPDictionary, "dictionary");
  3017. _plistObjects = objj_msgSend(CPArray, "arrayWithObject:", _CPKeyedArchiverNullString);
  3018. }
  3019. return self;
  3020. }
  3021. }), new objj_method(sel_getUid("finishEncoding"), function $CPKeyedArchiver__finishEncoding(self, _cmd)
  3022. { with(self)
  3023. {
  3024. if (_delegate && _delegateSelectors & _CPKeyedArchiverWillFinishSelector)
  3025. objj_msgSend(_delegate, "archiverWillFinish:", self);
  3026. var i = 0,
  3027. topObject = _plistObject,
  3028. classes = [];
  3029. for (; i < _objects.length; ++i)
  3030. {
  3031. var object = _objects[i],
  3032. theClass = objj_msgSend(object, "classForKeyedArchiver");
  3033. _plistObject = _plistObjects[objj_msgSend(_UIDs, "objectForKey:", objj_msgSend(object, "hash"))];
  3034. objj_msgSend(object, "encodeWithCoder:", self);
  3035. if (_delegate && _delegateSelectors & _CPKeyedArchiverDidEncodeObjectSelector)
  3036. objj_msgSend(_delegate, "archiver:didEncodeObject:", self, object);
  3037. }
  3038. _plistObject = objj_msgSend(CPDictionary, "dictionary");
  3039. objj_msgSend(_plistObject, "setObject:forKey:", topObject, _CPKeyedArchiverTopKey);
  3040. objj_msgSend(_plistObject, "setObject:forKey:", _plistObjects, _CPKeyedArchiverObjectsKey);
  3041. objj_msgSend(_plistObject, "setObject:forKey:", objj_msgSend(self, "className"), _CPKeyedArchiverArchiverKey);
  3042. objj_msgSend(_plistObject, "setObject:forKey:", "100000", _CPKeyedArchiverVersionKey);
  3043. objj_msgSend(_data, "setPlistObject:", _plistObject);
  3044. if (_delegate && _delegateSelectors & _CPKeyedArchiverDidFinishSelector)
  3045. objj_msgSend(_delegate, "archiverDidFinish:", self);
  3046. }
  3047. }), new objj_method(sel_getUid("outputFormat"), function $CPKeyedArchiver__outputFormat(self, _cmd)
  3048. { with(self)
  3049. {
  3050. return _outputFormat;
  3051. }
  3052. }), new objj_method(sel_getUid("setOutputFormat:"), function $CPKeyedArchiver__setOutputFormat_(self, _cmd, aPropertyListFormat)
  3053. { with(self)
  3054. {
  3055. _outputFormat = aPropertyListFormat;
  3056. }
  3057. }), new objj_method(sel_getUid("encodeBool:forKey:"), function $CPKeyedArchiver__encodeBool_forKey_(self, _cmd, aBOOL, aKey)
  3058. { with(self)
  3059. {
  3060. objj_msgSend(_plistObject, "setObject:forKey:", _CPKeyedArchiverEncodeObject(self, aBOOL, NO), aKey);
  3061. }
  3062. }), new objj_method(sel_getUid("encodeDouble:forKey:"), function $CPKeyedArchiver__encodeDouble_forKey_(self, _cmd, aDouble, aKey)
  3063. { with(self)
  3064. {
  3065. objj_msgSend(_plistObject, "setObject:forKey:", _CPKeyedArchiverEncodeObject(self, aDouble, NO), aKey);
  3066. }
  3067. }), new objj_method(sel_getUid("encodeFloat:forKey:"), function $CPKeyedArchiver__encodeFloat_forKey_(self, _cmd, aFloat, aKey)
  3068. { with(self)
  3069. {
  3070. objj_msgSend(_plistObject, "setObject:forKey:", _CPKeyedArchiverEncodeObject(self, aFloat, NO), aKey);
  3071. }
  3072. }), new objj_method(sel_getUid("encodeInt:forKey:"), function $CPKeyedArchiver__encodeInt_forKey_(self, _cmd, anInt, aKey)
  3073. { with(self)
  3074. {
  3075. objj_msgSend(_plistObject, "setObject:forKey:", _CPKeyedArchiverEncodeObject(self, anInt, NO), aKey);
  3076. }
  3077. }), new objj_method(sel_getUid("setDelegate:"), function $CPKeyedArchiver__setDelegate_(self, _cmd, aDelegate)
  3078. { with(self)
  3079. {
  3080. _delegate = aDelegate;
  3081. if (objj_msgSend(_delegate, "respondsToSelector:", sel_getUid("archiver:didEncodeObject:")))
  3082. _delegateSelectors |= _CPKeyedArchiverDidEncodeObjectSelector;
  3083. if (objj_msgSend(_delegate, "respondsToSelector:", sel_getUid("archiver:willEncodeObject:")))
  3084. _delegateSelectors |= _CPKeyedArchiverWillEncodeObjectSelector;
  3085. if (objj_msgSend(_delegate, "respondsToSelector:", sel_getUid("archiver:willReplaceObject:withObject:")))
  3086. _delegateSelectors |= _CPKeyedArchiverWillReplaceObjectWithObjectSelector;
  3087. if (objj_msgSend(_delegate, "respondsToSelector:", sel_getUid("archiver:didFinishEncoding:")))
  3088. _delegateSelectors |= _CPKeyedArchiverDidFinishEncodingSelector;
  3089. if (objj_msgSend(_delegate, "respondsToSelector:", sel_getUid("archiver:willFinishEncoding:")))
  3090. _delegateSelectors |= _CPKeyedArchiverWillFinishEncodingSelector;
  3091. }
  3092. }), new objj_method(sel_getUid("delegate"), function $CPKeyedArchiver__delegate(self, _cmd)
  3093. { with(self)
  3094. {
  3095. return _delegate;
  3096. }
  3097. }), new objj_method(sel_getUid("encodePoint:forKey:"), function $CPKeyedArchiver__encodePoint_forKey_(self, _cmd, aPoint, aKey)
  3098. { with(self)
  3099. {
  3100. objj_msgSend(_plistObject, "setObject:forKey:", _CPKeyedArchiverEncodeObject(self, CPStringFromPoint(aPoint), NO), aKey);
  3101. }
  3102. }), new objj_method(sel_getUid("encodeRect:forKey:"), function $CPKeyedArchiver__encodeRect_forKey_(self, _cmd, aRect, aKey)
  3103. { with(self)
  3104. {
  3105. objj_msgSend(_plistObject, "setObject:forKey:", _CPKeyedArchiverEncodeObject(self, CPStringFromRect(aRect), NO), aKey);
  3106. }
  3107. }), new objj_method(sel_getUid("encodeSize:forKey:"), function $CPKeyedArchiver__encodeSize_forKey_(self, _cmd, aSize, aKey)
  3108. { with(self)
  3109. {
  3110. objj_msgSend(_plistObject, "setObject:forKey:", _CPKeyedArchiverEncodeObject(self, CPStringFromSize(aSize), NO), aKey);
  3111. }
  3112. }), new objj_method(sel_getUid("encodeConditionalObject:forKey:"), function $CPKeyedArchiver__encodeConditionalObject_forKey_(self, _cmd, anObject, aKey)
  3113. { with(self)
  3114. {
  3115. objj_msgSend(_plistObject, "setObject:forKey:", _CPKeyedArchiverEncodeObject(self, anObject, YES), aKey);
  3116. }
  3117. }), new objj_method(sel_getUid("encodeNumber:forKey:"), function $CPKeyedArchiver__encodeNumber_forKey_(self, _cmd, aNumber, aKey)
  3118. { with(self)
  3119. {
  3120. objj_msgSend(_plistObject, "setObject:forKey:", _CPKeyedArchiverEncodeObject(self, aNumber, NO), aKey);
  3121. }
  3122. }), new objj_method(sel_getUid("encodeObject:forKey:"), function $CPKeyedArchiver__encodeObject_forKey_(self, _cmd, anObject, aKey)
  3123. { with(self)
  3124. {
  3125. objj_msgSend(_plistObject, "setObject:forKey:", _CPKeyedArchiverEncodeObject(self, anObject, NO), aKey);
  3126. }
  3127. }), new objj_method(sel_getUid("_encodeArrayOfObjects:forKey:"), function $CPKeyedArchiver___encodeArrayOfObjects_forKey_(self, _cmd, objects, aKey)
  3128. { with(self)
  3129. {
  3130. var i = 0,
  3131. count = objects.length,
  3132. references = objj_msgSend(CPArray, "arrayWithCapacity:", count);
  3133. for (; i < count; ++i)
  3134. objj_msgSend(references, "addObject:", _CPKeyedArchiverEncodeObject(self, objects[i], NO));
  3135. objj_msgSend(_plistObject, "setObject:forKey:", references, aKey);
  3136. }
  3137. }), new objj_method(sel_getUid("_encodeDictionaryOfObjects:forKey:"), function $CPKeyedArchiver___encodeDictionaryOfObjects_forKey_(self, _cmd, aDictionary, aKey)
  3138. { with(self)
  3139. {
  3140. var key,
  3141. keys = objj_msgSend(aDictionary, "keyEnumerator"),
  3142. references = objj_msgSend(CPDictionary, "dictionary");
  3143. while (key = objj_msgSend(keys, "nextObject"))
  3144. objj_msgSend(references, "setObject:forKey:", _CPKeyedArchiverEncodeObject(self, objj_msgSend(aDictionary, "objectForKey:", key), NO), key);
  3145. objj_msgSend(_plistObject, "setObject:forKey:", references, aKey);
  3146. }
  3147. }), new objj_method(sel_getUid("setClassName:forClass:"), function $CPKeyedArchiver__setClassName_forClass_(self, _cmd, aClassName, aClass)
  3148. { with(self)
  3149. {
  3150. if (!_replacementClassNames)
  3151. _replacementClassNames = objj_msgSend(CPDictionary, "dictionary");
  3152. objj_msgSend(_replacementClassNames, "setObject:forKey:", aClassName, CPStringFromClass(aClass));
  3153. }
  3154. }), new objj_method(sel_getUid("classNameForClass:"), function $CPKeyedArchiver__classNameForClass_(self, _cmd, aClass)
  3155. { with(self)
  3156. {
  3157. if (!_replacementClassNames)
  3158. return aClass.name;
  3159. var className = objj_msgSend(_replacementClassNames, "objectForKey:", CPStringFromClass(aClassName));
  3160. return className ? className : aClass.name;
  3161. }
  3162. })]);
  3163. class_addMethods(meta_class, [new objj_method(sel_getUid("initialize"), function $CPKeyedArchiver__initialize(self, _cmd)
  3164. { with(self)
  3165. {
  3166. if (self != objj_msgSend(CPKeyedArchiver, "class"))
  3167. return;
  3168. _CPKeyedArchiverStringClass = objj_msgSend(CPString, "class");
  3169. _CPKeyedArchiverNumberClass = objj_msgSend(CPNumber, "class");
  3170. _CPKeyedArchiverNullReference = objj_msgSend(CPDictionary, "dictionaryWithObject:forKey:", 0, _CPKeyedArchiverUIDKey);
  3171. }
  3172. }), new objj_method(sel_getUid("allowsKeyedCoding"), function $CPKeyedArchiver__allowsKeyedCoding(self, _cmd)
  3173. { with(self)
  3174. {
  3175. return YES;
  3176. }
  3177. }), new objj_method(sel_getUid("archivedDataWithRootObject:"), function $CPKeyedArchiver__archivedDataWithRootObject_(self, _cmd, anObject)
  3178. { with(self)
  3179. {
  3180. var data = objj_msgSend(CPData, "dataWithPlistObject:", nil),
  3181. archiver = objj_msgSend(objj_msgSend(self, "alloc"), "initForWritingWithMutableData:", data);
  3182. objj_msgSend(archiver, "encodeObject:forKey:", anObject, "root");
  3183. objj_msgSend(archiver, "finishEncoding");
  3184. return data;
  3185. }
  3186. }), new objj_method(sel_getUid("setClassName:forClass:"), function $CPKeyedArchiver__setClassName_forClass_(self, _cmd, aClassName, aClass)
  3187. { with(self)
  3188. {
  3189. if (!CPArchiverReplacementClassNames)
  3190. CPArchiverReplacementClassNames = objj_msgSend(CPDictionary, "dictionary");
  3191. objj_msgSend(CPArchiverReplacementClassNames, "setObject:forKey:", aClassName, CPStringFromClass(aClass));
  3192. }
  3193. }), new objj_method(sel_getUid("classNameForClass:"), function $CPKeyedArchiver__classNameForClass_(self, _cmd, aClass)
  3194. { with(self)
  3195. {
  3196. if (!CPArchiverReplacementClassNames)
  3197. return aClass.name;
  3198. var className = objj_msgSend(CPArchiverReplacementClassNames, "objectForKey:", CPStringFromClass(aClassName));
  3199. return className ? className : aClass.name;
  3200. }
  3201. })]);
  3202. }
  3203. var _CPKeyedArchiverEncodeObject = function(self, anObject, isConditional)
  3204. {
  3205. if (anObject !== nil && !anObject.isa)
  3206. anObject = objj_msgSend(_CPKeyedArchiverValue, "valueWithJSObject:", anObject);
  3207. var hash = objj_msgSend(anObject, "hash"),
  3208. object = objj_msgSend(self._replacementObjects, "objectForKey:", hash);
  3209. if (object === nil)
  3210. {
  3211. object = objj_msgSend(anObject, "replacementObjectForKeyedArchiver:", self);
  3212. if (self._delegate)
  3213. {
  3214. if (object !== anObject && self._delegateSelectors & _CPKeyedArchiverWillReplaceObjectWithObjectSelector)
  3215. objj_msgSend(self._delegate, "archiver:willReplaceObject:withObject:", self, anObject, object);
  3216. if (self._delegateSelectors & _CPKeyedArchiverWillEncodeObjectSelector)
  3217. {
  3218. anObject = objj_msgSend(self._delegate, "archiver:willEncodeObject:", self, object);
  3219. if (anObject !== object && self._delegateSelectors & _CPKeyedArchiverWillReplaceObjectWithObjectSelector)
  3220. objj_msgSend(self._delegate, "archiver:willReplaceObject:withObject:", self, object, anObject);
  3221. object = anObject;
  3222. }
  3223. }
  3224. objj_msgSend(self._replacementObjects, "setObject:forKey:", object, hash);
  3225. }
  3226. if (object === nil)
  3227. return _CPKeyedArchiverNullReference;
  3228. var UID = objj_msgSend(self._UIDs, "objectForKey:", hash = objj_msgSend(object, "hash"));
  3229. if (UID === nil)
  3230. {
  3231. if (isConditional)
  3232. {
  3233. if ((UID = objj_msgSend(self._conditionalUIDs, "objectForKey:", hash)) === nil)
  3234. {
  3235. objj_msgSend(self._conditionalUIDs, "setObject:forKey:", UID = objj_msgSend(self._plistObjects, "count"), hash);
  3236. objj_msgSend(self._plistObjects, "addObject:", _CPKeyedArchiverNullString);
  3237. }
  3238. }
  3239. else
  3240. {
  3241. var theClass = objj_msgSend(object, "classForKeyedArchiver"),
  3242. plistObject = nil;
  3243. if ((theClass === _CPKeyedArchiverStringClass) || (theClass === _CPKeyedArchiverNumberClass))
  3244. plistObject = object;
  3245. else
  3246. {
  3247. plistObject = objj_msgSend(CPDictionary, "dictionary");
  3248. objj_msgSend(self._objects, "addObject:", object);
  3249. var className = objj_msgSend(self, "classNameForClass:", theClass);
  3250. if (!className)
  3251. className = objj_msgSend(objj_msgSend(self, "class"), "classNameForClass:", theClass);
  3252. if (!className)
  3253. className = theClass.name;
  3254. else
  3255. theClass = window[className];
  3256. var classUID = objj_msgSend(self._UIDs, "objectForKey:", className);
  3257. if (!classUID)
  3258. {
  3259. var plistClass = objj_msgSend(CPDictionary, "dictionary"),
  3260. hierarchy = [];
  3261. objj_msgSend(plistClass, "setObject:forKey:", className, _CPKeyedArchiverClassNameKey);
  3262. do
  3263. {
  3264. objj_msgSend(hierarchy, "addObject:", CPStringFromClass(theClass));
  3265. } while (theClass = objj_msgSend(theClass, "superclass"));
  3266. objj_msgSend(plistClass, "setObject:forKey:", hierarchy, _CPKeyedArchiverClassesKey);
  3267. classUID = objj_msgSend(self._plistObjects, "count");
  3268. objj_msgSend(self._plistObjects, "addObject:", plistClass);
  3269. objj_msgSend(self._UIDs, "setObject:forKey:", classUID, className);
  3270. }
  3271. objj_msgSend(plistObject, "setObject:forKey:", objj_msgSend(CPDictionary, "dictionaryWithObject:forKey:", classUID, _CPKeyedArchiverUIDKey), _CPKeyedArchiverClassKey);
  3272. }
  3273. UID = objj_msgSend(self._conditionalUIDs, "objectForKey:", hash);
  3274. if (UID !== nil)
  3275. {
  3276. objj_msgSend(self._UIDs, "setObject:forKey:", UID, hash);
  3277. objj_msgSend(self._plistObjects, "replaceObjectAtIndex:withObject:", UID, plistObject);
  3278. }
  3279. else
  3280. {
  3281. objj_msgSend(self._UIDs, "setObject:forKey:", UID = objj_msgSend(self._plistObjects, "count"), hash);
  3282. objj_msgSend(self._plistObjects, "addObject:", plistObject);
  3283. }
  3284. }
  3285. }
  3286. return objj_msgSend(CPDictionary, "dictionaryWithObject:forKey:", UID, _CPKeyedArchiverUIDKey);
  3287. }
  3288. p;19;CPKeyedUnarchiver.ji;8;CPNull.ji;9;CPCoder.jc;13014;
  3289. var _CPKeyedUnarchiverCannotDecodeObjectOfClassNameOriginalClassesSelector = 1,
  3290. _CPKeyedUnarchiverDidDecodeObjectSelector = 1 << 1,
  3291. _CPKeyedUnarchiverWillReplaceObjectWithObjectSelector = 1 << 2,
  3292. _CPKeyedUnarchiverWillFinishSelector = 1 << 3,
  3293. _CPKeyedUnarchiverDidFinishSelector = 1 << 4;
  3294. var _CPKeyedArchiverNullString = "$null"
  3295. _CPKeyedArchiverUIDKey = "CP$UID",
  3296. _CPKeyedArchiverTopKey = "$top",
  3297. _CPKeyedArchiverObjectsKey = "$objects",
  3298. _CPKeyedArchiverArchiverKey = "$archiver",
  3299. _CPKeyedArchiverVersionKey = "$version",
  3300. _CPKeyedArchiverClassNameKey = "$classname",
  3301. _CPKeyedArchiverClassesKey = "$classes",
  3302. _CPKeyedArchiverClassKey = "$class";
  3303. var _CPKeyedUnarchiverArrayClass = Nil,
  3304. _CPKeyedUnarchiverStringClass = Nil,
  3305. _CPKeyedUnarchiverDictionaryClass = Nil,
  3306. _CPKeyedUnarchiverNumberClass = Nil,
  3307. _CPKeyedUnarchiverDataClass = Nil,
  3308. _CPKeyedUnarchiverArchiverValueClass = Nil;
  3309. {var the_class = objj_allocateClassPair(CPCoder, "CPKeyedUnarchiver"),
  3310. meta_class = the_class.isa;class_addIvars(the_class, [new objj_ivar("_delegate"), new objj_ivar("_delegateSelectors"), new objj_ivar("_data"), new objj_ivar("_replacementClasses"), new objj_ivar("_objects"), new objj_ivar("_archive"), new objj_ivar("_plistObject"), new objj_ivar("_plistObjects")]);
  3311. objj_registerClassPair(the_class);
  3312. objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
  3313. class_addMethods(the_class, [new objj_method(sel_getUid("initForReadingWithData:"), function $CPKeyedUnarchiver__initForReadingWithData_(self, _cmd, data)
  3314. { with(self)
  3315. {
  3316. self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPCoder") }, "init");
  3317. if (self)
  3318. {
  3319. _archive = objj_msgSend(data, "plistObject");
  3320. _objects = objj_msgSend(CPArray, "arrayWithObject:", objj_msgSend(CPNull, "null"));
  3321. _plistObject = objj_msgSend(_archive, "objectForKey:", _CPKeyedArchiverTopKey);
  3322. _plistObjects = objj_msgSend(_archive, "objectForKey:", _CPKeyedArchiverObjectsKey);
  3323. _replacementClasses = objj_msgSend(CPDictionary, "dictionary");
  3324. }
  3325. return self;
  3326. }
  3327. }), new objj_method(sel_getUid("containsValueForKey:"), function $CPKeyedUnarchiver__containsValueForKey_(self, _cmd, aKey)
  3328. { with(self)
  3329. {
  3330. return objj_msgSend(_plistObject, "objectForKey:", aKey) != nil;
  3331. }
  3332. }), new objj_method(sel_getUid("_decodeDictionaryOfObjectsForKey:"), function $CPKeyedUnarchiver___decodeDictionaryOfObjectsForKey_(self, _cmd, aKey)
  3333. { with(self)
  3334. {
  3335. var object = objj_msgSend(_plistObject, "objectForKey:", aKey);
  3336. if (objj_msgSend(object, "isKindOfClass:", _CPKeyedUnarchiverDictionaryClass))
  3337. {
  3338. var key,
  3339. keys = objj_msgSend(object, "keyEnumerator"),
  3340. dictionary = objj_msgSend(CPDictionary, "dictionary");
  3341. while (key = objj_msgSend(keys, "nextObject"))
  3342. objj_msgSend(dictionary, "setObject:forKey:", _CPKeyedUnarchiverDecodeObjectAtIndex(self, objj_msgSend(objj_msgSend(object, "objectForKey:", key), "objectForKey:", _CPKeyedArchiverUIDKey)), key);
  3343. return dictionary;
  3344. }
  3345. return nil;
  3346. }
  3347. }), new objj_method(sel_getUid("decodeBoolForKey:"), function $CPKeyedUnarchiver__decodeBoolForKey_(self, _cmd, aKey)
  3348. { with(self)
  3349. {
  3350. return objj_msgSend(self, "decodeObjectForKey:", aKey);
  3351. }
  3352. }), new objj_method(sel_getUid("decodeFloatForKey:"), function $CPKeyedUnarchiver__decodeFloatForKey_(self, _cmd, aKey)
  3353. { with(self)
  3354. {
  3355. return objj_msgSend(self, "decodeObjectForKey:", aKey);
  3356. }
  3357. }), new objj_method(sel_getUid("decodeDoubleForKey:"), function $CPKeyedUnarchiver__decodeDoubleForKey_(self, _cmd, aKey)
  3358. { with(self)
  3359. {
  3360. return objj_msgSend(self, "decodeObjectForKey:", aKey);
  3361. }
  3362. }), new objj_method(sel_getUid("decodeIntForKey:"), function $CPKeyedUnarchiver__decodeIntForKey_(self, _cmd, aKey)
  3363. { with(self)
  3364. {
  3365. return objj_msgSend(self, "decodeObjectForKey:", aKey);
  3366. }
  3367. }), new objj_method(sel_getUid("decodePointForKey:"), function $CPKeyedUnarchiver__decodePointForKey_(self, _cmd, aKey)
  3368. { with(self)
  3369. {
  3370. var object = objj_msgSend(self, "decodeObjectForKey:", aKey);
  3371. if(object)
  3372. return CPPointFromString(object);
  3373. else
  3374. return CPPointMake(0.0, 0.0);
  3375. }
  3376. }), new objj_method(sel_getUid("decodeRectForKey:"), function $CPKeyedUnarchiver__decodeRectForKey_(self, _cmd, aKey)
  3377. { with(self)
  3378. {
  3379. var object = objj_msgSend(self, "decodeObjectForKey:", aKey);
  3380. if(object)
  3381. return CPRectFromString(object);
  3382. else
  3383. return CPRectMakeZero();
  3384. }
  3385. }), new objj_method(sel_getUid("decodeSizeForKey:"), function $CPKeyedUnarchiver__decodeSizeForKey_(self, _cmd, aKey)
  3386. { with(self)
  3387. {
  3388. var object = objj_msgSend(self, "decodeObjectForKey:", aKey);
  3389. if(object)
  3390. return CPSizeFromString(object);
  3391. else
  3392. return CPSizeMake(0.0, 0.0);
  3393. }
  3394. }), new objj_method(sel_getUid("decodeObjectForKey:"), function $CPKeyedUnarchiver__decodeObjectForKey_(self, _cmd, aKey)
  3395. { with(self)
  3396. {
  3397. var object = objj_msgSend(_plistObject, "objectForKey:", aKey);
  3398. if (objj_msgSend(object, "isKindOfClass:", _CPKeyedUnarchiverDictionaryClass))
  3399. return _CPKeyedUnarchiverDecodeObjectAtIndex(self, objj_msgSend(object, "objectForKey:", _CPKeyedArchiverUIDKey));
  3400. else if (objj_msgSend(object, "isKindOfClass:", _CPKeyedUnarchiverNumberClass) || objj_msgSend(object, "isKindOfClass:", _CPKeyedUnarchiverDataClass))
  3401. return object;
  3402. else if (objj_msgSend(object, "isKindOfClass:", _CPKeyedUnarchiverArrayClass))
  3403. {
  3404. var index = 0,
  3405. count = object.length,
  3406. array = [];
  3407. for (; index < count; ++index)
  3408. array[index] = _CPKeyedUnarchiverDecodeObjectAtIndex(self, objj_msgSend(object[index], "objectForKey:", _CPKeyedArchiverUIDKey));
  3409. return array;
  3410. }
  3411. return nil;
  3412. }
  3413. }), new objj_method(sel_getUid("decodeBytesForKey:"), function $CPKeyedUnarchiver__decodeBytesForKey_(self, _cmd, aKey)
  3414. { with(self)
  3415. {
  3416. var data = objj_msgSend(self, "decodeObjectForKey:", aKey);
  3417. if (objj_msgSend(data, "isKindOfClass:", objj_msgSend(CPData, "class")))
  3418. return data.bytes;
  3419. return nil;
  3420. }
  3421. }), new objj_method(sel_getUid("finishDecoding"), function $CPKeyedUnarchiver__finishDecoding(self, _cmd)
  3422. { with(self)
  3423. {
  3424. if (_delegateSelectors & _CPKeyedUnarchiverWillFinishSelector)
  3425. objj_msgSend(_delegate, "unarchiverWillFinish:", self);
  3426. if (_delegateSelectors & _CPKeyedUnarchiverDidFinishSelector)
  3427. objj_msgSend(_delegate, "unarchiverDidFinish:", self);
  3428. }
  3429. }), new objj_method(sel_getUid("delegate"), function $CPKeyedUnarchiver__delegate(self, _cmd)
  3430. { with(self)
  3431. {
  3432. return _delegate;
  3433. }
  3434. }), new objj_method(sel_getUid("setDelegate:"), function $CPKeyedUnarchiver__setDelegate_(self, _cmd, aDelegate)
  3435. { with(self)
  3436. {
  3437. _delegate = aDelegate;
  3438. if (objj_msgSend(_delegate, "respondsToSelector:", sel_getUid("unarchiver:cannotDecodeObjectOfClassName:originalClasses:")))
  3439. _delegateSelectors |= _CPKeyedUnarchiverCannotDecodeObjectOfClassNameOriginalClassesSelector;
  3440. if (objj_msgSend(_delegate, "respondsToSelector:", sel_getUid("unarchiver:didDecodeObject:")))
  3441. _delegateSelectors |= _CPKeyedUnarchiverDidDecodeObjectSelector;
  3442. if (objj_msgSend(_delegate, "respondsToSelector:", sel_getUid("unarchiver:willReplaceObject:withObject:")))
  3443. _delegateSelectors |= _CPKeyedUnarchiverWillReplaceObjectWithObjectSelector;
  3444. if (objj_msgSend(_delegate, "respondsToSelector:", sel_getUid("unarchiverWillFinish:")))
  3445. _delegateSelectors |= _CPKeyedUnarchiverWilFinishSelector;
  3446. if (objj_msgSend(_delegate, "respondsToSelector:", sel_getUid("unarchiverDidFinish:")))
  3447. _delegateSelectors |= _CPKeyedUnarchiverDidFinishSelector;
  3448. }
  3449. }), new objj_method(sel_getUid("setClass:forClassName:"), function $CPKeyedUnarchiver__setClass_forClassName_(self, _cmd, aClass, aClassName)
  3450. { with(self)
  3451. {
  3452. objj_msgSend(_replacementClasses, "setObject:forKey:", aClass, aClassName);
  3453. }
  3454. }), new objj_method(sel_getUid("classForClassName:"), function $CPKeyedUnarchiver__classForClassName_(self, _cmd, aClassName)
  3455. { with(self)
  3456. {
  3457. return objj_msgSend(_replacementClasses, "objectForKey:", aClassName);
  3458. }
  3459. }), new objj_method(sel_getUid("allowsKeyedCoding"), function $CPKeyedUnarchiver__allowsKeyedCoding(self, _cmd)
  3460. { with(self)
  3461. {
  3462. return YES;
  3463. }
  3464. })]);
  3465. class_addMethods(meta_class, [new objj_method(sel_getUid("initialize"), function $CPKeyedUnarchiver__initialize(self, _cmd)
  3466. { with(self)
  3467. {
  3468. if (self !== objj_msgSend(CPKeyedUnarchiver, "class"))
  3469. return;
  3470. _CPKeyedUnarchiverArrayClass = objj_msgSend(CPArray, "class");
  3471. _CPKeyedUnarchiverStringClass = objj_msgSend(CPString, "class");
  3472. _CPKeyedUnarchiverDictionaryClass = objj_msgSend(CPDictionary, "class");
  3473. _CPKeyedUnarchiverNumberClass = objj_msgSend(CPNumber, "class");
  3474. _CPKeyedUnarchiverDataClass = objj_msgSend(CPData, "class");
  3475. _CPKeyedUnarchiverArchiverValueClass = objj_msgSend(_CPKeyedArchiverValue, "class");
  3476. }
  3477. }), new objj_method(sel_getUid("unarchiveObjectWithData:"), function $CPKeyedUnarchiver__unarchiveObjectWithData_(self, _cmd, data)
  3478. { with(self)
  3479. {
  3480. var unarchiver = objj_msgSend(objj_msgSend(self, "alloc"), "initForReadingWithData:", data),
  3481. object = objj_msgSend(unarchiver, "decodeObjectForKey:", "root");
  3482. objj_msgSend(unarchiver, "finishDecoding");
  3483. return object;
  3484. }
  3485. }), new objj_method(sel_getUid("unarchiveObjectWithFile:"), function $CPKeyedUnarchiver__unarchiveObjectWithFile_(self, _cmd, aFilePath)
  3486. { with(self)
  3487. {
  3488. }
  3489. }), new objj_method(sel_getUid("unarchiveObjectWithFile:asynchronously:"), function $CPKeyedUnarchiver__unarchiveObjectWithFile_asynchronously_(self, _cmd, aFilePath, aFlag)
  3490. { with(self)
  3491. {
  3492. }
  3493. })]);
  3494. }
  3495. var _CPKeyedUnarchiverDecodeObjectAtIndex = function(self, anIndex)
  3496. {
  3497. var object = self._objects[anIndex];
  3498. if (object)
  3499. if (object == self._objects[0])
  3500. return nil;
  3501. else
  3502. return object;
  3503. var object,
  3504. plistObject = self._plistObjects[anIndex];
  3505. if (objj_msgSend(plistObject, "isKindOfClass:", _CPKeyedUnarchiverDictionaryClass))
  3506. {
  3507. var plistClass = self._plistObjects[objj_msgSend(objj_msgSend(plistObject, "objectForKey:", _CPKeyedArchiverClassKey), "objectForKey:", _CPKeyedArchiverUIDKey)],
  3508. className = objj_msgSend(plistClass, "objectForKey:", _CPKeyedArchiverClassNameKey),
  3509. classes = objj_msgSend(plistClass, "objectForKey:", _CPKeyedArchiverClassesKey),
  3510. theClass = objj_msgSend(self, "classForClassName:", className);
  3511. if (!theClass)
  3512. theClass = CPClassFromString(className);
  3513. object = objj_msgSend(theClass, "alloc");
  3514. self._objects[anIndex] = object;
  3515. var savedPlistObject = self._plistObject;
  3516. self._plistObject = plistObject;
  3517. var string = className;
  3518. var processedObject = objj_msgSend(object, "initWithCoder:", self);
  3519. self._plistObject = savedPlistObject;
  3520. if (processedObject != object)
  3521. {
  3522. if (self._delegateSelectors & _CPKeyedUnarchiverWillReplaceObjectWithObjectSelector)
  3523. objj_msgSend(self._delegate, "unarchiver:willReplaceObject:withObject:", self, object, processedObject);
  3524. object = processedObject;
  3525. self._objects[anIndex] = processedObject;
  3526. }
  3527. processedObject = objj_msgSend(object, "awakeAfterUsingCoder:", self);
  3528. if (processedObject != object)
  3529. {
  3530. if (self._delegateSelectors & _CPKeyedUnarchiverWillReplaceObjectWithObjectSelector)
  3531. objj_msgSend(self._delegate, "unarchiver:willReplaceObject:withObject:", self, object, processedObject);
  3532. object = processedObject;
  3533. self._objects[anIndex] = processedObject;
  3534. }
  3535. if (self._delegate)
  3536. {
  3537. if (self._delegateSelectors & _CPKeyedUnarchiverDidDecodeObjectSelector)
  3538. processedObject = objj_msgSend(self._delegate, "unarchiver:didDecodeObject:", self, object);
  3539. if (processedObject != object)
  3540. {
  3541. if (self._delegateSelectors & _CPKeyedUnarchiverWillReplaceObjectWithObjectSelector)
  3542. objj_msgSend(self._delegate, "unarchiver:willReplaceObject:withObject:", self, object, processedObject);
  3543. object = processedObject;
  3544. self._objects[anIndex] = processedObject;
  3545. }
  3546. }
  3547. }
  3548. else
  3549. {
  3550. self._objects[anIndex] = object = plistObject;
  3551. if (objj_msgSend(object, "class") == _CPKeyedUnarchiverStringClass)
  3552. {
  3553. if (object == _CPKeyedArchiverNullString)
  3554. {
  3555. self._objects[anIndex] = self._objects[0];
  3556. return nil;
  3557. }
  3558. else
  3559. self._objects[anIndex] = object = plistObject;
  3560. }
  3561. }
  3562. if (objj_msgSend(object, "isMemberOfClass:", _CPKeyedUnarchiverArchiverValueClass))
  3563. object = objj_msgSend(object, "JSObject");
  3564. return object;
  3565. }
  3566. p;18;CPKeyValueCoding.ji;9;CPArray.ji;10;CPObject.ji;14;CPDictionary.jc;8588;
  3567. var CPObjectAccessorsForClass = nil,
  3568. CPObjectModifiersForClass = nil;
  3569. CPUndefinedKeyException = "CPUndefinedKeyException";
  3570. CPTargetObjectUserInfoKey = "CPTargetObjectUserInfoKey";
  3571. CPUnknownUserInfoKey = "CPUnknownUserInfoKey";
  3572. {
  3573. var the_class = objj_getClass("CPObject")
  3574. if(!the_class) objj_exception_throw(new objj_exception(OBJJClassNotFoundException, "*** Could not find definition for class \"CPObject\""));
  3575. var meta_class = the_class.isa;class_addMethods(the_class, [new objj_method(sel_getUid("_ivarForKey:"), function $CPObject___ivarForKey_(self, _cmd, aKey)
  3576. { with(self)
  3577. {
  3578. var ivar = '_' + aKey;
  3579. if (typeof self[ivar] != "undefined")
  3580. return ivar;
  3581. var isKey = "is" + aKey.charAt(0).toUpperCase() + aKey.substr(1);
  3582. ivar = '_' + isKey;
  3583. if (typeof self[ivar] != "undefined")
  3584. return ivar;
  3585. ivar = aKey;
  3586. if (typeof self[ivar] != "undefined")
  3587. return ivar;
  3588. ivar = isKey;
  3589. if (typeof self[ivar] != "undefined")
  3590. return ivar;
  3591. return nil;
  3592. }
  3593. }), new objj_method(sel_getUid("valueForKey:"), function $CPObject__valueForKey_(self, _cmd, aKey)
  3594. { with(self)
  3595. {
  3596. var theClass = objj_msgSend(self, "class"),
  3597. selector = objj_msgSend(theClass, "_accessorForKey:", aKey);
  3598. if (selector)
  3599. return objj_msgSend(self, selector);
  3600. if(objj_msgSend(theClass, "accessInstanceVariablesDirectly"))
  3601. {
  3602. var ivar = objj_msgSend(self, "_ivarForKey:", aKey);
  3603. if (ivar)
  3604. return self[ivar];
  3605. }
  3606. return objj_msgSend(self, "valueForUndefinedKey:", aKey);
  3607. }
  3608. }), new objj_method(sel_getUid("valueForKeyPath:"), function $CPObject__valueForKeyPath_(self, _cmd, aKeyPath)
  3609. { with(self)
  3610. {
  3611. var keys = aKeyPath.split("."),
  3612. index = 0,
  3613. count = keys.length,
  3614. value = self;
  3615. for(; index < count; ++index)
  3616. value = objj_msgSend(value, "valueForKey:", keys[index]);
  3617. return value;
  3618. }
  3619. }), new objj_method(sel_getUid("dictionaryWithValuesForKeys:"), function $CPObject__dictionaryWithValuesForKeys_(self, _cmd, keys)
  3620. { with(self)
  3621. {
  3622. var index = 0,
  3623. count = keys.length,
  3624. dictionary = objj_msgSend(CPDictionary, "dictionary");
  3625. for (; index < count; ++index)
  3626. {
  3627. var key = keys[index],
  3628. value = objj_msgSend(self, "valueForKey:", key);
  3629. if (value === nil)
  3630. objj_msgSend(dictionary, "setObject:forKey:", objj_msgSend(CPNull, "null"), key);
  3631. else
  3632. objj_msgSend(dictionary, "setObject:forKey:", value, key);
  3633. }
  3634. return dictionary;
  3635. }
  3636. }), new objj_method(sel_getUid("valueForUndefinedKey:"), function $CPObject__valueForUndefinedKey_(self, _cmd, aKey)
  3637. { with(self)
  3638. {
  3639. objj_msgSend(objj_msgSend(CPException, "exceptionWithName:reason:userInfo:", CPUndefinedKeyException, objj_msgSend(self, "description") + " is not key value coding-compliant for the key " + aKey, objj_msgSend(CPDictionary, "dictionaryWithObjects:forKeys:", [self, aKey], [CPTargetObjectUserInfoKey, CPUnknownUserInfoKey])), "raise");
  3640. }
  3641. }), new objj_method(sel_getUid("setValue:forKeyPath:"), function $CPObject__setValue_forKeyPath_(self, _cmd, aValue, aKeyPath)
  3642. { with(self)
  3643. {
  3644. if (!aKeyPath) aKeyPath = "self";
  3645. var i = 0,
  3646. keys = aKeyPath.split("."),
  3647. count = keys.length - 1,
  3648. owner = self;
  3649. for(; i < count; ++i)
  3650. owner = objj_msgSend(owner, "valueForKey:", keys[i]);
  3651. objj_msgSend(owner, "setValue:forKey:", aValue, keys[i]);
  3652. }
  3653. }), new objj_method(sel_getUid("setValue:forKey:"), function $CPObject__setValue_forKey_(self, _cmd, aValue, aKey)
  3654. { with(self)
  3655. {
  3656. var theClass = objj_msgSend(self, "class"),
  3657. selector = objj_msgSend(theClass, "_modifierForKey:", aKey);
  3658. if (selector)
  3659. return objj_msgSend(self, selector, aValue);
  3660. if(objj_msgSend(theClass, "accessInstanceVariablesDirectly"))
  3661. {
  3662. var ivar = objj_msgSend(self, "_ivarForKey:", aKey);
  3663. if (ivar)
  3664. {
  3665. objj_msgSend(self, "willChangeValueForKey:", aKey);
  3666. self[ivar] = aValue;
  3667. objj_msgSend(self, "didChangeValueForKey:", aKey);
  3668. }
  3669. return;
  3670. }
  3671. objj_msgSend(self, "setValue:forUndefinedKey:", aValue, aKey);
  3672. }
  3673. }), new objj_method(sel_getUid("setValue:forUndefinedKey:"), function $CPObject__setValue_forUndefinedKey_(self, _cmd, aValue, aKey)
  3674. { with(self)
  3675. {
  3676. objj_msgSend(objj_msgSend(CPException, "exceptionWithName:reason:userInfo:", CPUndefinedKeyException, objj_msgSend(self, "description") + " is not key value coding-compliant for the key " + aKey, objj_msgSend(CPDictionary, "dictionaryWithObjects:forKeys:", [self, aKey], [CPTargetObjectUserInfoKey, CPUnknownUserInfoKey])), "raise");
  3677. }
  3678. })]);
  3679. class_addMethods(meta_class, [new objj_method(sel_getUid("accessInstanceVariablesDirectly"), function $CPObject__accessInstanceVariablesDirectly(self, _cmd)
  3680. { with(self)
  3681. {
  3682. return YES;
  3683. }
  3684. }), new objj_method(sel_getUid("_accessorForKey:"), function $CPObject___accessorForKey_(self, _cmd, aKey)
  3685. { with(self)
  3686. {
  3687. if (!CPObjectAccessorsForClass)
  3688. CPObjectAccessorsForClass = objj_msgSend(CPDictionary, "dictionary");
  3689. var hash = objj_msgSend(isa, "hash"),
  3690. selector = nil,
  3691. accessors = objj_msgSend(CPObjectAccessorsForClass, "objectForKey:", hash);
  3692. if (accessors)
  3693. {
  3694. selector = objj_msgSend(accessors, "objectForKey:", aKey);
  3695. if (selector)
  3696. return selector === objj_msgSend(CPNull, "null") ? nil : selector;
  3697. }
  3698. else
  3699. {
  3700. accessors = objj_msgSend(CPDictionary, "dictionary");
  3701. objj_msgSend(CPObjectAccessorsForClass, "setObject:forKey:", accessors, hash);
  3702. }
  3703. var capitalizedKey = aKey.charAt(0).toUpperCase() + aKey.substr(1);
  3704. if (objj_msgSend(self, "instancesRespondToSelector:", selector = CPSelectorFromString("get" + capitalizedKey)) ||
  3705. objj_msgSend(self, "instancesRespondToSelector:", selector = CPSelectorFromString(aKey)) ||
  3706. objj_msgSend(self, "instancesRespondToSelector:", selector = CPSelectorFromString("is" + capitalizedKey)) ||
  3707. objj_msgSend(self, "instancesRespondToSelector:", selector = CPSelectorFromString("_get" + capitalizedKey)) ||
  3708. objj_msgSend(self, "instancesRespondToSelector:", selector = CPSelectorFromString("_" + aKey)) ||
  3709. objj_msgSend(self, "instancesRespondToSelector:", selector = CPSelectorFromString("_is" + capitalizedKey)))
  3710. {
  3711. objj_msgSend(accessors, "setObject:forKey:", selector, aKey);
  3712. return selector;
  3713. }
  3714. objj_msgSend(accessors, "setObject:forKey:", objj_msgSend(CPNull, "null"), aKey);
  3715. return nil;
  3716. }
  3717. }), new objj_method(sel_getUid("_modifierForKey:"), function $CPObject___modifierForKey_(self, _cmd, aKey)
  3718. { with(self)
  3719. {
  3720. if (!CPObjectModifiersForClass)
  3721. CPObjectModifiersForClass = objj_msgSend(CPDictionary, "dictionary");
  3722. var hash = objj_msgSend(isa, "hash"),
  3723. selector = nil,
  3724. modifiers = objj_msgSend(CPObjectModifiersForClass, "objectForKey:", hash);
  3725. if (modifiers)
  3726. {
  3727. selector = objj_msgSend(modifiers, "objectForKey:", aKey);
  3728. if (selector)
  3729. return selector === objj_msgSend(CPNull, "null") ? nil : selector;
  3730. }
  3731. else
  3732. {
  3733. modifiers = objj_msgSend(CPDictionary, "dictionary");
  3734. objj_msgSend(CPObjectModifiersForClass, "setObject:forKey:", modifiers, hash);
  3735. }
  3736. if (selector)
  3737. return selector === objj_msgSend(CPNull, "null") ? nil : selector;
  3738. var capitalizedKey = aKey.charAt(0).toUpperCase() + aKey.substr(1) + ':';
  3739. if (objj_msgSend(self, "instancesRespondToSelector:", selector = CPSelectorFromString("set" + capitalizedKey)) ||
  3740. objj_msgSend(self, "instancesRespondToSelector:", selector = CPSelectorFromString("_set" + capitalizedKey)))
  3741. {
  3742. objj_msgSend(modifiers, "setObject:forKey:", selector, aKey);
  3743. return selector;
  3744. }
  3745. objj_msgSend(modifiers, "setObject:forKey:", objj_msgSend(CPNull, "null"), aKey);
  3746. return nil;
  3747. }
  3748. })]);
  3749. }
  3750. {
  3751. var the_class = objj_getClass("CPDictionary")
  3752. if(!the_class) objj_exception_throw(new objj_exception(OBJJClassNotFoundException, "*** Could not find definition for class \"CPDictionary\""));
  3753. var meta_class = the_class.isa;class_addMethods(the_class, [new objj_method(sel_getUid("valueForKey:"), function $CPDictionary__valueForKey_(self, _cmd, aKey)
  3754. { with(self)
  3755. {
  3756. return objj_msgSend(self, "objectForKey:", aKey);
  3757. }
  3758. }), new objj_method(sel_getUid("setValue:forKey:"), function $CPDictionary__setValue_forKey_(self, _cmd, aValue, aKey)
  3759. { with(self)
  3760. {
  3761. objj_msgSend(self, "setObject:forKey:", aValue, aKey);
  3762. }
  3763. })]);
  3764. }
  3765. i;13;CPArray+KVO.jp;21;CPKeyValueObserving.ji;9;CPArray.ji;14;CPDictionary.ji;13;CPException.ji;10;CPObject.ji;7;CPSet.jc;21303;
  3766. {
  3767. var the_class = objj_getClass("CPObject")
  3768. if(!the_class) objj_exception_throw(new objj_exception(OBJJClassNotFoundException, "*** Could not find definition for class \"CPObject\""));
  3769. var meta_class = the_class.isa;class_addMethods(the_class, [new objj_method(sel_getUid("willChangeValueForKey:"), function $CPObject__willChangeValueForKey_(self, _cmd, aKey)
  3770. { with(self)
  3771. {
  3772. }
  3773. }), new objj_method(sel_getUid("didChangeValueForKey:"), function $CPObject__didChangeValueForKey_(self, _cmd, aKey)
  3774. { with(self)
  3775. {
  3776. }
  3777. }), new objj_method(sel_getUid("willChange:valuesAtIndexes:forKey:"), function $CPObject__willChange_valuesAtIndexes_forKey_(self, _cmd, change, indexes, key)
  3778. { with(self)
  3779. {
  3780. }
  3781. }), new objj_method(sel_getUid("didChange:valuesAtIndexes:forKey:"), function $CPObject__didChange_valuesAtIndexes_forKey_(self, _cmd, change, indexes, key)
  3782. { with(self)
  3783. {
  3784. }
  3785. }), new objj_method(sel_getUid("addObserver:forKeyPath:options:context:"), function $CPObject__addObserver_forKeyPath_options_context_(self, _cmd, anObserver, aPath, options, aContext)
  3786. { with(self)
  3787. {
  3788. if (!anObserver || !aPath)
  3789. return;
  3790. objj_msgSend(objj_msgSend(_CPKVOProxy, "proxyForObject:", self), "_addObserver:forKeyPath:options:context:", anObserver, aPath, options, aContext);
  3791. }
  3792. }), new objj_method(sel_getUid("removeObserver:forKeyPath:"), function $CPObject__removeObserver_forKeyPath_(self, _cmd, anObserver, aPath)
  3793. { with(self)
  3794. {
  3795. if (!anObserver || !aPath)
  3796. return;
  3797. objj_msgSend(objj_msgSend(KVOProxyMap, "objectForKey:", objj_msgSend(self, "hash")), "_removeObserver:forKeyPath:", anObserver, aPath);
  3798. }
  3799. })]);
  3800. class_addMethods(meta_class, [new objj_method(sel_getUid("automaticallyNotifiesObserversForKey:"), function $CPObject__automaticallyNotifiesObserversForKey_(self, _cmd, aKey)
  3801. { with(self)
  3802. {
  3803. return YES;
  3804. }
  3805. }), new objj_method(sel_getUid("keyPathsForValuesAffectingValueForKey:"), function $CPObject__keyPathsForValuesAffectingValueForKey_(self, _cmd, aKey)
  3806. { with(self)
  3807. {
  3808. var capitalizedKey = aKey.charAt(0).toUpperCase()+aKey.substring(1);
  3809. selector = "keyPathsForValuesAffectingValueFor"+capitalizedKey;
  3810. if (objj_msgSend(objj_msgSend(self, "class"), "respondsToSelector:", selector))
  3811. return objj_msgSend(objj_msgSend(self, "class"), selector);
  3812. return objj_msgSend(CPSet, "set");
  3813. }
  3814. })]);
  3815. }
  3816. CPKeyValueObservingOptionNew = 1 << 0;
  3817. CPKeyValueObservingOptionOld = 1 << 1;
  3818. CPKeyValueObservingOptionInitial = 1 << 2;
  3819. CPKeyValueObservingOptionPrior = 1 << 3;
  3820. CPKeyValueChangeKindKey = "CPKeyValueChangeKindKey";
  3821. CPKeyValueChangeNewKey = "CPKeyValueChangeNewKey";
  3822. CPKeyValueChangeOldKey = "CPKeyValueChangeOldKey";
  3823. CPKeyValueChangeIndexesKey = "CPKeyValueChangeIndexesKey";
  3824. CPKeyValueChangeNotificationIsPriorKey = "CPKeyValueChangeNotificationIsPriorKey";
  3825. CPKeyValueChangeSetting = 1;
  3826. CPKeyValueChangeInsertion = 2;
  3827. CPKeyValueChangeRemoval = 3;
  3828. CPKeyValueChangeReplacement = 4;
  3829. var kvoNewAndOld = CPKeyValueObservingOptionNew|CPKeyValueObservingOptionOld;
  3830. var KVOProxyMap = objj_msgSend(CPDictionary, "dictionary"),
  3831. DependentKeysMap = objj_msgSend(CPDictionary, "dictionary");
  3832. {var the_class = objj_allocateClassPair(CPObject, "_CPKVOProxy"),
  3833. meta_class = the_class.isa;class_addIvars(the_class, [new objj_ivar("_targetObject"), new objj_ivar("_nativeClass"), new objj_ivar("_changesForKey"), new objj_ivar("_observersForKey"), new objj_ivar("_replacedKeys")]);
  3834. objj_registerClassPair(the_class);
  3835. objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
  3836. class_addMethods(the_class, [new objj_method(sel_getUid("initWithTarget:"), function $_CPKVOProxy__initWithTarget_(self, _cmd, aTarget)
  3837. { with(self)
  3838. {
  3839. self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPObject") }, "init");
  3840. _targetObject = aTarget;
  3841. _nativeClass = objj_msgSend(aTarget, "class");
  3842. _observersForKey = objj_msgSend(CPDictionary, "dictionary");
  3843. _changesForKey = objj_msgSend(CPDictionary, "dictionary");
  3844. _replacedKeys = objj_msgSend(CPSet, "set");
  3845. return self;
  3846. }
  3847. }), new objj_method(sel_getUid("_replaceClass"), function $_CPKVOProxy___replaceClass(self, _cmd)
  3848. { with(self)
  3849. {
  3850. var currentClass = _nativeClass,
  3851. kvoClassName = "$KVO_"+class_getName(_nativeClass),
  3852. existingKVOClass = objj_lookUpClass(kvoClassName);
  3853. if (existingKVOClass)
  3854. {
  3855. _targetObject.isa = existingKVOClass;
  3856. return;
  3857. }
  3858. var kvoClass = objj_allocateClassPair(currentClass, kvoClassName);
  3859. objj_registerClassPair(kvoClass);
  3860. _class_initialize(kvoClass);
  3861. var methodList = _CPKVOModelSubclass.method_list,
  3862. count = methodList.length;
  3863. for (var i=0; i<count; i++)
  3864. {
  3865. var method = methodList[i];
  3866. class_addMethod(kvoClass, method_getName(method), method_getImplementation(method), "");
  3867. }
  3868. _targetObject.isa = kvoClass;
  3869. }
  3870. }), new objj_method(sel_getUid("_replaceSetterForKey:"), function $_CPKVOProxy___replaceSetterForKey_(self, _cmd, aKey)
  3871. { with(self)
  3872. {
  3873. if (objj_msgSend(_replacedKeys, "containsObject:", aKey) || !objj_msgSend(_nativeClass, "automaticallyNotifiesObserversForKey:", aKey))
  3874. return;
  3875. var currentClass = _nativeClass,
  3876. capitalizedKey = aKey.charAt(0).toUpperCase() + aKey.substring(1),
  3877. found = false,
  3878. replacementMethods = [
  3879. "set"+capitalizedKey+":", _kvoMethodForMethod,
  3880. "_set"+capitalizedKey+":", _kvoMethodForMethod,
  3881. "insertObject:in"+capitalizedKey+"AtIndex:", _kvoInsertMethodForMethod,
  3882. "replaceObjectIn"+capitalizedKey+"AtIndex:withObject:", _kvoReplaceMethodForMethod,
  3883. "removeObjectFrom"+capitalizedKey+"AtIndex:", _kvoRemoveMethodForMethod
  3884. ];
  3885. for (var i=0, count=replacementMethods.length; i<count; i+=2)
  3886. {
  3887. var theSelector = sel_getName(replacementMethods[i]),
  3888. theReplacementMethod = replacementMethods[i+1];
  3889. if (objj_msgSend(_nativeClass, "instancesRespondToSelector:", theSelector))
  3890. {
  3891. var theMethod = class_getInstanceMethod(_nativeClass, theSelector);
  3892. class_addMethod(_targetObject.isa, theSelector, theReplacementMethod(aKey, theMethod), "");
  3893. found = true;
  3894. }
  3895. }
  3896. if (found)
  3897. return;
  3898. var composedOfKeys = objj_msgSend(objj_msgSend(_nativeClass, "keyPathsForValuesAffectingValueForKey:", aKey), "allObjects");
  3899. if (!composedOfKeys)
  3900. return;
  3901. var dependentKeysForClass = objj_msgSend(DependentKeysMap, "objectForKey:", objj_msgSend(_nativeClass, "hash"));
  3902. if (!dependentKeysForClass)
  3903. {
  3904. dependentKeysForClass = objj_msgSend(CPDictionary, "new");
  3905. objj_msgSend(DependentKeysMap, "setObject:forKey:", dependentKeysForClass, objj_msgSend(_nativeClass, "hash"));
  3906. }
  3907. for (var i=0, count=composedOfKeys.length; i<count; i++)
  3908. {
  3909. var componentKey = composedOfKeys[i],
  3910. keysComposedOfKey = objj_msgSend(dependentKeysForClass, "objectForKey:", componentKey);
  3911. if (!keysComposedOfKey)
  3912. {
  3913. keysComposedOfKey = objj_msgSend(CPSet, "new");
  3914. objj_msgSend(dependentKeysForClass, "setObject:forKey:", keysComposedOfKey, componentKey);
  3915. }
  3916. objj_msgSend(keysComposedOfKey, "addObject:", aKey);
  3917. objj_msgSend(self, "_replaceSetterForKey:", componentKey);
  3918. }
  3919. }
  3920. }), new objj_method(sel_getUid("_addObserver:forKeyPath:options:context:"), function $_CPKVOProxy___addObserver_forKeyPath_options_context_(self, _cmd, anObserver, aPath, options, aContext)
  3921. { with(self)
  3922. {
  3923. if (!anObserver)
  3924. return;
  3925. var forwarder = nil;
  3926. if (aPath.indexOf('.') != CPNotFound)
  3927. forwarder = objj_msgSend(objj_msgSend(_CPKVOForwardingObserver, "alloc"), "initWithKeyPath:object:observer:options:context:", aPath, _targetObject, anObserver, options, aContext);
  3928. else
  3929. objj_msgSend(self, "_replaceSetterForKey:", aPath);
  3930. var observers = objj_msgSend(_observersForKey, "objectForKey:", aPath);
  3931. if (!observers)
  3932. {
  3933. observers = objj_msgSend(CPDictionary, "dictionary");
  3934. objj_msgSend(_observersForKey, "setObject:forKey:", observers, aPath);
  3935. }
  3936. objj_msgSend(observers, "setObject:forKey:", _CPKVOInfoMake(anObserver, options, aContext, forwarder), objj_msgSend(anObserver, "hash"));
  3937. if (options & CPKeyValueObservingOptionInitial)
  3938. {
  3939. var newValue = objj_msgSend(_targetObject, "valueForKeyPath:", aPath);
  3940. if (newValue === nil || newValue === undefined)
  3941. newValue = objj_msgSend(CPNull, "null");
  3942. var changes = objj_msgSend(CPDictionary, "dictionaryWithObject:forKey:", newValue, CPKeyValueChangeNewKey);
  3943. objj_msgSend(anObserver, "observeValueForKeyPath:ofObject:change:context:", aPath, self, changes, aContext);
  3944. }
  3945. }
  3946. }), new objj_method(sel_getUid("_removeObserver:forKeyPath:"), function $_CPKVOProxy___removeObserver_forKeyPath_(self, _cmd, anObserver, aPath)
  3947. { with(self)
  3948. {
  3949. var observers = objj_msgSend(_observersForKey, "objectForKey:", aPath);
  3950. if (aPath.indexOf('.') != CPNotFound)
  3951. {
  3952. var forwarder = objj_msgSend(observers, "objectForKey:", objj_msgSend(anObserver, "hash")).forwarder;
  3953. objj_msgSend(forwarder, "finalize");
  3954. }
  3955. objj_msgSend(observers, "removeObjectForKey:", objj_msgSend(anObserver, "hash"));
  3956. if (!objj_msgSend(observers, "count"))
  3957. objj_msgSend(_observersForKey, "removeObjectForKey:", aPath);
  3958. if (!objj_msgSend(_observersForKey, "count"))
  3959. {
  3960. _targetObject.isa = _nativeClass;
  3961. objj_msgSend(KVOProxyMap, "removeObjectForKey:", objj_msgSend(_targetObject, "hash"));
  3962. }
  3963. }
  3964. }), new objj_method(sel_getUid("_sendNotificationsForKey:changeOptions:isBefore:"), function $_CPKVOProxy___sendNotificationsForKey_changeOptions_isBefore_(self, _cmd, aKey, changeOptions, isBefore)
  3965. { with(self)
  3966. {
  3967. var changes = objj_msgSend(_changesForKey, "objectForKey:", aKey);
  3968. if (isBefore)
  3969. {
  3970. changes = changeOptions;
  3971. var indexes = objj_msgSend(changes, "objectForKey:", CPKeyValueChangeIndexesKey);
  3972. if (indexes)
  3973. {
  3974. var type = objj_msgSend(changes, "objectForKey:", CPKeyValueChangeKindKey);
  3975. if (type == CPKeyValueChangeReplacement || type == CPKeyValueChangeRemoval)
  3976. {
  3977. var oldValues = objj_msgSend(objj_msgSend(_targetObject, "mutableArrayValueForKeyPath:", aKey), "objectsAtIndexes:", indexes);
  3978. objj_msgSend(changes, "setValue:forKey:", oldValues, CPKeyValueChangeOldKey);
  3979. }
  3980. }
  3981. else
  3982. {
  3983. var oldValue = objj_msgSend(_targetObject, "valueForKey:", aKey);
  3984. if (oldValue === nil || oldValue === undefined)
  3985. oldValue = objj_msgSend(CPNull, "null");
  3986. objj_msgSend(changes, "setObject:forKey:", oldValue, CPKeyValueChangeOldKey);
  3987. }
  3988. objj_msgSend(changes, "setObject:forKey:", 1, CPKeyValueChangeNotificationIsPriorKey);
  3989. objj_msgSend(_changesForKey, "setObject:forKey:", changes, aKey);
  3990. }
  3991. else
  3992. {
  3993. objj_msgSend(changes, "removeObjectForKey:", CPKeyValueChangeNotificationIsPriorKey);
  3994. var indexes = objj_msgSend(changes, "objectForKey:", CPKeyValueChangeIndexesKey);
  3995. if (indexes)
  3996. {
  3997. var type = objj_msgSend(changes, "objectForKey:", CPKeyValueChangeKindKey);
  3998. if (type == CPKeyValueChangeReplacement || type == CPKeyValueChangeInsertion)
  3999. {
  4000. var oldValues = objj_msgSend(objj_msgSend(_targetObject, "mutableArrayValueForKeyPath:", aKey), "objectsAtIndexes:", indexes);
  4001. objj_msgSend(changes, "setValue:forKey:", oldValues, CPKeyValueChangeNewKey);
  4002. }
  4003. }
  4004. else
  4005. {
  4006. var newValue = objj_msgSend(_targetObject, "valueForKey:", aKey);
  4007. if (newValue === nil || newValue === undefined)
  4008. newValue = objj_msgSend(CPNull, "null");
  4009. objj_msgSend(changes, "setObject:forKey:", newValue, CPKeyValueChangeNewKey);
  4010. }
  4011. }
  4012. var observers = objj_msgSend(objj_msgSend(_observersForKey, "objectForKey:", aKey), "allValues"),
  4013. count = objj_msgSend(observers, "count");
  4014. while (count--)
  4015. {
  4016. var observerInfo = observers[count];
  4017. if (isBefore && (observerInfo.options & CPKeyValueObservingOptionPrior))
  4018. objj_msgSend(observerInfo.observer, "observeValueForKeyPath:ofObject:change:context:", aKey, _targetObject, changes, observerInfo.context);
  4019. else if (!isBefore)
  4020. objj_msgSend(observerInfo.observer, "observeValueForKeyPath:ofObject:change:context:", aKey, _targetObject, changes, observerInfo.context);
  4021. }
  4022. var keysComposedOfKey = objj_msgSend(objj_msgSend(objj_msgSend(DependentKeysMap, "objectForKey:", objj_msgSend(_nativeClass, "hash")), "objectForKey:", aKey), "allObjects");
  4023. if (!keysComposedOfKey)
  4024. return;
  4025. for (var i=0, count=keysComposedOfKey.length; i<count; i++)
  4026. objj_msgSend(self, "_sendNotificationsForKey:changeOptions:isBefore:", keysComposedOfKey[i], changeOptions, isBefore);
  4027. }
  4028. })]);
  4029. class_addMethods(meta_class, [new objj_method(sel_getUid("proxyForObject:"), function $_CPKVOProxy__proxyForObject_(self, _cmd, anObject)
  4030. { with(self)
  4031. {
  4032. var proxy = objj_msgSend(KVOProxyMap, "objectForKey:", objj_msgSend(anObject, "hash"));
  4033. if (proxy)
  4034. return proxy;
  4035. proxy = objj_msgSend(objj_msgSend(self, "alloc"), "initWithTarget:", anObject);
  4036. objj_msgSend(proxy, "_replaceClass");
  4037. objj_msgSend(KVOProxyMap, "setObject:forKey:", proxy, objj_msgSend(anObject, "hash"));
  4038. return proxy;
  4039. }
  4040. })]);
  4041. }
  4042. {var the_class = objj_allocateClassPair(Nil, "_CPKVOModelSubclass"),
  4043. meta_class = the_class.isa;objj_registerClassPair(the_class);
  4044. objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
  4045. class_addMethods(the_class, [new objj_method(sel_getUid("willChangeValueForKey:"), function $_CPKVOModelSubclass__willChangeValueForKey_(self, _cmd, aKey)
  4046. { with(self)
  4047. {
  4048. if (!aKey)
  4049. return;
  4050. var changeOptions = objj_msgSend(CPDictionary, "dictionaryWithObject:forKey:", CPKeyValueChangeSetting, CPKeyValueChangeKindKey);
  4051. objj_msgSend(objj_msgSend(_CPKVOProxy, "proxyForObject:", self), "_sendNotificationsForKey:changeOptions:isBefore:", aKey, changeOptions, YES);
  4052. }
  4053. }), new objj_method(sel_getUid("didChangeValueForKey:"), function $_CPKVOModelSubclass__didChangeValueForKey_(self, _cmd, aKey)
  4054. { with(self)
  4055. {
  4056. if (!aKey)
  4057. return;
  4058. objj_msgSend(objj_msgSend(_CPKVOProxy, "proxyForObject:", self), "_sendNotificationsForKey:changeOptions:isBefore:", aKey, nil, NO);
  4059. }
  4060. }), new objj_method(sel_getUid("willChange:valuesAtIndexes:forKey:"), function $_CPKVOModelSubclass__willChange_valuesAtIndexes_forKey_(self, _cmd, change, indexes, aKey)
  4061. { with(self)
  4062. {
  4063. if (!aKey)
  4064. return;
  4065. var changeOptions = objj_msgSend(CPDictionary, "dictionaryWithObjects:forKeys:", [change, indexes], [CPKeyValueChangeKindKey, CPKeyValueChangeIndexesKey]);
  4066. objj_msgSend(objj_msgSend(_CPKVOProxy, "proxyForObject:", self), "_sendNotificationsForKey:changeOptions:isBefore:", aKey, changeOptions, YES);
  4067. }
  4068. }), new objj_method(sel_getUid("didChange:valuesAtIndexes:forKey:"), function $_CPKVOModelSubclass__didChange_valuesAtIndexes_forKey_(self, _cmd, change, indexes, aKey)
  4069. { with(self)
  4070. {
  4071. if (!aKey)
  4072. return;
  4073. objj_msgSend(objj_msgSend(_CPKVOProxy, "proxyForObject:", self), "_sendNotificationsForKey:changeOptions:isBefore:", aKey, nil, NO);
  4074. }
  4075. }), new objj_method(sel_getUid("class"), function $_CPKVOModelSubclass__class(self, _cmd)
  4076. { with(self)
  4077. {
  4078. return objj_msgSend(KVOProxyMap, "objectForKey:", objj_msgSend(self, "hash"))._nativeClass;
  4079. }
  4080. }), new objj_method(sel_getUid("superclass"), function $_CPKVOModelSubclass__superclass(self, _cmd)
  4081. { with(self)
  4082. {
  4083. return objj_msgSend(objj_msgSend(self, "class"), "superclass");
  4084. }
  4085. }), new objj_method(sel_getUid("isKindOfClass:"), function $_CPKVOModelSubclass__isKindOfClass_(self, _cmd, aClass)
  4086. { with(self)
  4087. {
  4088. return objj_msgSend(objj_msgSend(self, "class"), "isSubclassOfClass:", aClass);
  4089. }
  4090. }), new objj_method(sel_getUid("isMemberOfClass:"), function $_CPKVOModelSubclass__isMemberOfClass_(self, _cmd, aClass)
  4091. { with(self)
  4092. {
  4093. return objj_msgSend(self, "class") == aClass;
  4094. }
  4095. }), new objj_method(sel_getUid("className"), function $_CPKVOModelSubclass__className(self, _cmd)
  4096. { with(self)
  4097. {
  4098. return objj_msgSend(self, "class").name;
  4099. }
  4100. })]);
  4101. }
  4102. {var the_class = objj_allocateClassPair(CPObject, "_CPKVOForwardingObserver"),
  4103. meta_class = the_class.isa;class_addIvars(the_class, [new objj_ivar("_object"), new objj_ivar("_observer"), new objj_ivar("_context"), new objj_ivar("_firstPart"), new objj_ivar("_secondPart"), new objj_ivar("_value")]);
  4104. objj_registerClassPair(the_class);
  4105. objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
  4106. class_addMethods(the_class, [new objj_method(sel_getUid("initWithKeyPath:object:observer:options:context:"), function $_CPKVOForwardingObserver__initWithKeyPath_object_observer_options_context_(self, _cmd, aKeyPath, anObject, anObserver, options, aContext)
  4107. { with(self)
  4108. {
  4109. self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPObject") }, "init");
  4110. _context = aContext;
  4111. _observer = anObserver;
  4112. _object = anObject;
  4113. var dotIndex = aKeyPath.indexOf('.');
  4114. if (dotIndex == CPNotFound)
  4115. objj_msgSend(CPException, "raise:reason:", CPInvalidArgumentException, "Created _CPKVOForwardingObserver without compound key path: "+aKeyPath);
  4116. _firstPart = aKeyPath.substring(0, dotIndex);
  4117. _secondPart = aKeyPath.substring(dotIndex+1);
  4118. objj_msgSend(_object, "addObserver:forKeyPath:options:context:", self, _firstPart, kvoNewAndOld, nil);
  4119. _value = objj_msgSend(_object, "valueForKey:", _firstPart);
  4120. if (_value)
  4121. objj_msgSend(_value, "addObserver:forKeyPath:options:context:", self, _secondPart, kvoNewAndOld, nil);
  4122. return self;
  4123. }
  4124. }), new objj_method(sel_getUid("observeValueForKeyPath:ofObject:change:context:"), function $_CPKVOForwardingObserver__observeValueForKeyPath_ofObject_change_context_(self, _cmd, aKeyPath, anObject, changes, aContext)
  4125. { with(self)
  4126. {
  4127. if (anObject == _object)
  4128. {
  4129. objj_msgSend(_observer, "observeValueForKeyPath:ofObject:change:context:", _firstPart, _object, changes, _context);
  4130. if (_value)
  4131. objj_msgSend(_value, "removeObserver:forKeyPath:", self, _secondPart);
  4132. _value = objj_msgSend(_object, "valueForKey:", _firstPart);
  4133. if (_value)
  4134. objj_msgSend(_value, "addObserver:forKeyPath:options:context:", self, _secondPart, kvoNewAndOld, nil);
  4135. }
  4136. else
  4137. {
  4138. objj_msgSend(_observer, "observeValueForKeyPath:ofObject:change:context:", _firstPart+"."+aKeyPath, _object, changes, _context);
  4139. }
  4140. }
  4141. }), new objj_method(sel_getUid("finalize"), function $_CPKVOForwardingObserver__finalize(self, _cmd)
  4142. { with(self)
  4143. {
  4144. if (_value)
  4145. objj_msgSend(_value, "removeObserver:forKeyPath:", self, _secondPart);
  4146. objj_msgSend(_object, "removeObserver:forKeyPath:", self, _firstPart);
  4147. _object = nil;
  4148. _observer = nil;
  4149. _context = nil;
  4150. _value = nil;
  4151. }
  4152. })]);
  4153. }
  4154. var _CPKVOInfoMake = _CPKVOInfoMake= function(anObserver, theOptions, aContext, aForwarder)
  4155. {
  4156. return {
  4157. observer: anObserver,
  4158. options: theOptions,
  4159. context: aContext,
  4160. forwarder: aForwarder
  4161. };
  4162. }
  4163. var _kvoMethodForMethod = _kvoMethodForMethod= function(theKey, theMethod)
  4164. {
  4165. return function(self, _cmd, object)
  4166. {
  4167. objj_msgSend(self, "willChangeValueForKey:", theKey);
  4168. theMethod.method_imp(self, _cmd, object);
  4169. objj_msgSend(self, "didChangeValueForKey:", theKey);
  4170. }
  4171. }
  4172. var _kvoInsertMethodForMethod = _kvoInsertMethodForMethod= function(theKey, theMethod)
  4173. {
  4174. return function(self, _cmd, object, index)
  4175. {
  4176. objj_msgSend(self, "willChange:valuesAtIndexes:forKey:", CPKeyValueChangeInsertion, objj_msgSend(CPIndexSet, "indexSetWithIndex:", index), theKey);
  4177. theMethod.method_imp(self, _cmd, object, index);
  4178. objj_msgSend(self, "didChange:valuesAtIndexes:forKey:", CPKeyValueChangeInsertion, objj_msgSend(CPIndexSet, "indexSetWithIndex:", index), theKey)
  4179. }
  4180. }
  4181. var _kvoReplaceMethodForMethod = _kvoReplaceMethodForMethod= function(theKey, theMethod)
  4182. {
  4183. return function(self, _cmd, index, object)
  4184. {
  4185. objj_msgSend(self, "willChange:valuesAtIndexes:forKey:", CPKeyValueChangeReplacement, objj_msgSend(CPIndexSet, "indexSetWithIndex:", index), theKey);
  4186. theMethod.method_imp(self, _cmd, index, object);
  4187. objj_msgSend(self, "didChange:valuesAtIndexes:forKey:", CPKeyValueChangeReplacement, objj_msgSend(CPIndexSet, "indexSetWithIndex:", index), theKey)
  4188. }
  4189. }
  4190. var _kvoRemoveMethodForMethod = _kvoRemoveMethodForMethod= function(theKey, theMethod)
  4191. {
  4192. return function(self, _cmd, index)
  4193. {
  4194. objj_msgSend(self, "willChange:valuesAtIndexes:forKey:", CPKeyValueChangeRemoval, objj_msgSend(CPIndexSet, "indexSetWithIndex:", index), theKey);
  4195. theMethod.method_imp(self, _cmd, index);
  4196. objj_msgSend(self, "didChange:valuesAtIndexes:forKey:", CPKeyValueChangeRemoval, objj_msgSend(CPIndexSet, "indexSetWithIndex:", index), theKey)
  4197. }
  4198. }
  4199. i;13;CPArray+KVO.jp;7;CPLog.jc;10117;window.CPLogDisable = false;
  4200. var CPLogDefaultTitle = "Cappuccino";
  4201. var CPLogLevels = ["fatal", "error", "warn", "info", "debug", "trace"];
  4202. var CPLogDefaultLevel = CPLogLevels[0];
  4203. var _CPLogLevelsInverted = {};
  4204. for (var i = 0; i < CPLogLevels.length; i++)
  4205. _CPLogLevelsInverted[CPLogLevels[i]] = i;
  4206. var _CPLogRegistrations = {};
  4207. var _CPFormatLogMessage = function(aString, aLevel, aTitle)
  4208. {
  4209. var now = new Date();
  4210. aLevel = ( aLevel == null ? '' : ' [' + aLevel + ']' );
  4211. if (typeof sprintf == "function")
  4212. return sprintf("%4d-%02d-%02d %02d:%02d:%02d.%03d %s%s: %s",
  4213. now.getFullYear(), now.getMonth(), now.getDate(),
  4214. now.getHours(), now.getMinutes(), now.getSeconds(), now.getMilliseconds(),
  4215. aTitle, aLevel, aString);
  4216. else
  4217. return now + " " + aTitle + aLevel + ": " + aString;
  4218. }
  4219. CPLogRegister= function(aProvider, aMaxLevel)
  4220. {
  4221. CPLogRegisterRange(aProvider, CPLogLevels[0], aMaxLevel || CPLogLevels[CPLogLevels.length-1]);
  4222. }
  4223. CPLogRegisterRange= function(aProvider, aMinLevel, aMaxLevel)
  4224. {
  4225. var min = _CPLogLevelsInverted[aMinLevel];
  4226. var max = _CPLogLevelsInverted[aMaxLevel];
  4227. if (min != undefined && max != undefined)
  4228. for (var i = 0; i <= max; i++)
  4229. CPLogRegisterSingle(aProvider, CPLogLevels[i]);
  4230. }
  4231. CPLogRegisterSingle= function(aProvider, aLevel)
  4232. {
  4233. if (_CPLogRegistrations[aLevel] == undefined)
  4234. _CPLogRegistrations[aLevel] = [aProvider];
  4235. else
  4236. _CPLogRegistrations[aLevel].push(aProvider);
  4237. }
  4238. _CPLogDispatch= function(parameters, aLevel, aTitle)
  4239. {
  4240. if (aTitle == undefined)
  4241. aTitle = CPLogDefaultTitle;
  4242. if (aLevel == undefined)
  4243. aLevel = CPLogDefaultLevel;
  4244. var message = (typeof parameters[0] == "string" && parameters.length > 1) ? sprintf.apply(null, parameters) : String(parameters[0]);
  4245. if (_CPLogRegistrations[aLevel])
  4246. for (var i = 0; i < _CPLogRegistrations[aLevel].length; i++)
  4247. _CPLogRegistrations[aLevel][i](message, aLevel, aTitle);
  4248. }
  4249. CPLog= function() { _CPLogDispatch(arguments); }
  4250. for (var i = 0; i < CPLogLevels.length; i++)
  4251. CPLog[CPLogLevels[i]] = (function(level) { return function() { _CPLogDispatch(arguments, level); }; })(CPLogLevels[i]);
  4252. ANSI_ESC = String.fromCharCode(0x1B);
  4253. ANSI_CSI = ANSI_ESC + '[';
  4254. ANSI_TEXT_PROP = 'm';
  4255. ANSI_RESET = '0';
  4256. ANSI_BOLD = '1';
  4257. ANSI_FAINT = '2';
  4258. ANSI_NORMAL = '22';
  4259. ANSI_ITALIC = '3';
  4260. ANSI_UNDER = '4';
  4261. ANSI_UNDER_DBL = '21';
  4262. ANSI_UNDER_OFF = '24';
  4263. ANSI_BLINK = '5';
  4264. ANSI_BLINK_FAST = '6';
  4265. ANSI_BLINK_OFF = '25';
  4266. ANSI_REVERSE = '7';
  4267. ANSI_POSITIVE = '27';
  4268. ANSI_CONCEAL = '8';
  4269. ANSI_REVEAL = '28';
  4270. ANSI_FG = '3';
  4271. ANSI_BG = '4';
  4272. ANSI_FG_INTENSE = '9';
  4273. ANSI_BG_INTENSE = '10';
  4274. ANSI_BLACK = '0';
  4275. ANSI_RED = '1';
  4276. ANSI_GREEN = '2';
  4277. ANSI_YELLOW = '3';
  4278. ANSI_BLUE = '4';
  4279. ANSI_MAGENTA = '5';
  4280. ANSI_CYAN = '6';
  4281. ANSI_WHITE = '7';
  4282. var colorCodeMap = {
  4283. "black" : ANSI_BLACK,
  4284. "red" : ANSI_RED,
  4285. "green" : ANSI_GREEN,
  4286. "yellow" : ANSI_YELLOW,
  4287. "blue" : ANSI_BLUE,
  4288. "magenta" : ANSI_MAGENTA,
  4289. "cyan" : ANSI_CYAN,
  4290. "white" : ANSI_WHITE
  4291. }
  4292. ANSIControlCode = function(code, parameters)
  4293. {
  4294. if (parameters == undefined)
  4295. parameters = "";
  4296. else if (typeof(parameters) == 'object' && (parameters instanceof Array))
  4297. parameters = parameters.join(';');
  4298. return ANSI_CSI + String(parameters) + String(code);
  4299. }
  4300. ANSITextApplyProperties = function(string, properties)
  4301. {
  4302. return ANSIControlCode(ANSI_TEXT_PROP, properties) + String(string) + ANSIControlCode(ANSI_TEXT_PROP);
  4303. }
  4304. ANSITextColorize = function(string, color)
  4305. {
  4306. if (colorCodeMap[color] == undefined)
  4307. return string;
  4308. return ANSITextApplyProperties(string, ANSI_FG + colorCodeMap[color]);
  4309. }
  4310. var levelColorMap = {
  4311. "fatal": "red",
  4312. "error": "red",
  4313. "warn" : "yellow",
  4314. "info" : "green",
  4315. "debug": "cyan",
  4316. "trace": "blue"
  4317. }
  4318. CPLogPrint= function(aString, aLevel, aTitle)
  4319. {
  4320. if (typeof print != "undefined")
  4321. {
  4322. if (aLevel == "fatal" || aLevel == "error" || aLevel == "warn")
  4323. var message = ANSITextColorize(_CPFormatLogMessage(aString, aLevel, aTitle), levelColorMap[aLevel]);
  4324. else
  4325. var message = _CPFormatLogMessage(aString, ANSITextColorize(aLevel, levelColorMap[aLevel]), aTitle);
  4326. print(message);
  4327. }
  4328. }
  4329. CPLogAlert= function(aString, aLevel, aTitle)
  4330. {
  4331. if (typeof alert != "undefined" && !window.CPLogDisable)
  4332. {
  4333. var message = _CPFormatLogMessage(aString, aLevel, aTitle);
  4334. window.CPLogDisable = !confirm(message + "\n\n(Click cancel to stop log alerts)");
  4335. }
  4336. }
  4337. CPLogConsole= function(aString, aLevel, aTitle)
  4338. {
  4339. if (typeof console != "undefined")
  4340. {
  4341. var message = _CPFormatLogMessage(aString, aLevel, aTitle);
  4342. var logger = {
  4343. "fatal": "error",
  4344. "error": "error",
  4345. "warn": "warn",
  4346. "info": "info",
  4347. "debug": "debug",
  4348. "trace": "debug"
  4349. }[aLevel];
  4350. if (logger && console[logger])
  4351. console[logger](message);
  4352. else if (console.log)
  4353. console.log(message);
  4354. }
  4355. }
  4356. var CPLogWindow = null;
  4357. CPLogPopup = function(aString, aLevel, aTitle)
  4358. {
  4359. try {
  4360. if (window.CPLogDisable || window.open == undefined)
  4361. return;
  4362. if (!CPLogWindow || !CPLogWindow.document)
  4363. {
  4364. CPLogWindow = window.open("", "_blank", "width=600,height=400,status=no,resizable=yes,scrollbars=yes");
  4365. if (!CPLogWindow) {
  4366. window.CPLogDisable = !confirm(aString + "\n\n(Disable pop-up blocking for CPLog window; Click cancel to stop log alerts)");
  4367. return;
  4368. }
  4369. _CPLogInitPopup(CPLogWindow);
  4370. }
  4371. var logDiv = CPLogWindow.document.createElement("div");
  4372. logDiv.setAttribute("class", aLevel || "fatal");
  4373. var message = _CPFormatLogMessage(aString, null, aTitle);
  4374. logDiv.appendChild(CPLogWindow.document.createTextNode(message));
  4375. CPLogWindow.log.appendChild(logDiv);
  4376. if (CPLogWindow.focusEnabled.checked)
  4377. CPLogWindow.focus();
  4378. if (CPLogWindow.blockEnabled.checked)
  4379. CPLogWindow.blockEnabled.checked = CPLogWindow.confirm(message+"\nContinue blocking?");
  4380. if (CPLogWindow.scrollEnabled.checked)
  4381. CPLogWindow.scrollToBottom();
  4382. } catch(e) {
  4383. }
  4384. }
  4385. var _CPLogInitPopup = function(logWindow)
  4386. {
  4387. var doc = logWindow.document;
  4388. doc.writeln("<html><head><title></title></head><body></body></html>");
  4389. doc.title = CPLogDefaultTitle + " Run Log";
  4390. var head = doc.getElementsByTagName("head")[0];
  4391. var body = doc.getElementsByTagName("body")[0];
  4392. var base = window.location.protocol + "//" + window.location.host + window.location.pathname;
  4393. base = base.substring(0,base.lastIndexOf("/")+1);
  4394. var link = doc.createElement("link");
  4395. link.setAttribute("type", "text/css");
  4396. link.setAttribute("rel", "stylesheet");
  4397. link.setAttribute("href", base+"Frameworks/Foundation/Resources/log.css");
  4398. link.setAttribute("media", "screen");
  4399. head.appendChild(link);
  4400. var div = doc.createElement("div");
  4401. div.setAttribute("id", "header");
  4402. body.appendChild(div);
  4403. var ul = doc.createElement("ul");
  4404. ul.setAttribute("id", "enablers");
  4405. div.appendChild(ul);
  4406. for (var i = 0; i < CPLogLevels.length; i++) {
  4407. var li = doc.createElement("li");
  4408. li.setAttribute("id", "en"+CPLogLevels[i]);
  4409. li.setAttribute("class", CPLogLevels[i]);
  4410. li.setAttribute("onclick", "toggle(this);");
  4411. li.setAttribute("enabled", "yes");
  4412. li.appendChild(doc.createTextNode(CPLogLevels[i]));
  4413. ul.appendChild(li);
  4414. }
  4415. var ul = doc.createElement("ul");
  4416. ul.setAttribute("id", "options");
  4417. div.appendChild(ul);
  4418. var options = {"focus":["Focus",false], "block":["Block",false], "wrap":["Wrap",false], "scroll":["Scroll",true], "close":["Close",true]};
  4419. for (o in options) {
  4420. var li = doc.createElement("li");
  4421. ul.appendChild(li);
  4422. logWindow[o+"Enabled"] = doc.createElement("input");
  4423. logWindow[o+"Enabled"].setAttribute("id", o);
  4424. logWindow[o+"Enabled"].setAttribute("type", "checkbox");
  4425. if (options[o][1])
  4426. logWindow[o+"Enabled"].setAttribute("checked", "checked");
  4427. li.appendChild(logWindow[o+"Enabled"]);
  4428. var label = doc.createElement("label");
  4429. label.setAttribute("for", o);
  4430. label.appendChild(doc.createTextNode(options[o][0]));
  4431. li.appendChild(label);
  4432. }
  4433. logWindow.log = doc.createElement("div");
  4434. logWindow.log.setAttribute("class", "enerror endebug enwarn eninfo enfatal entrace");
  4435. body.appendChild(logWindow.log);
  4436. logWindow.toggle = function(elem) {
  4437. var enabled = (elem.getAttribute("enabled") == "yes") ? "no" : "yes";
  4438. elem.setAttribute("enabled", enabled);
  4439. if (enabled == "yes")
  4440. logWindow.log.className += " " + elem.id
  4441. else
  4442. logWindow.log.className = logWindow.log.className.replace(new RegExp("[\\s]*"+elem.id, "g"), "");
  4443. }
  4444. logWindow.scrollToBottom = function() {
  4445. logWindow.scrollTo(0, body.offsetHeight);
  4446. }
  4447. logWindow.wrapEnabled.addEventListener("click", function() {
  4448. logWindow.log.setAttribute("wrap", logWindow.wrapEnabled.checked ? "yes" : "no");
  4449. }, false);
  4450. logWindow.addEventListener("keydown", function(e) {
  4451. var e = e || logWindow.event;
  4452. if (e.keyCode == 75 && (e.ctrlKey || e.metaKey)) {
  4453. while (logWindow.log.firstChild) {
  4454. logWindow.log.removeChild(logWindow.log.firstChild);
  4455. }
  4456. e.preventDefault();
  4457. }
  4458. }, "false");
  4459. window.addEventListener("unload", function() {
  4460. if (logWindow && logWindow.closeEnabled && logWindow.closeEnabled.checked) {
  4461. window.CPLogDisable = true;
  4462. logWindow.close();
  4463. }
  4464. }, false);
  4465. logWindow.addEventListener("unload", function() {
  4466. if (!window.CPLogDisable) {
  4467. window.CPLogDisable = !confirm("Click cancel to stop logging");
  4468. }
  4469. }, false);
  4470. }
  4471. p;16;CPNotification.ji;10;CPObject.ji;13;CPException.jc;2045;
  4472. {var the_class = objj_allocateClassPair(CPObject, "CPNotification"),
  4473. meta_class = the_class.isa;class_addIvars(the_class, [new objj_ivar("_name"), new objj_ivar("_object"), new objj_ivar("_userInfo")]);
  4474. objj_registerClassPair(the_class);
  4475. objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
  4476. class_addMethods(the_class, [new objj_method(sel_getUid("init"), function $CPNotification__init(self, _cmd)
  4477. { with(self)
  4478. {
  4479. objj_msgSend(CPException, "raise:reason:", CPUnsupportedMethodException, "CPNotification's init method should not be used");
  4480. }
  4481. }), new objj_method(sel_getUid("initWithName:object:userInfo:"), function $CPNotification__initWithName_object_userInfo_(self, _cmd, aNotificationName, anObject, aUserInfo)
  4482. { with(self)
  4483. {
  4484. self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPObject") }, "init");
  4485. if (self)
  4486. {
  4487. _name = aNotificationName;
  4488. _object = anObject;
  4489. _userInfo = aUserInfo;
  4490. }
  4491. return self;
  4492. }
  4493. }), new objj_method(sel_getUid("name"), function $CPNotification__name(self, _cmd)
  4494. { with(self)
  4495. {
  4496. return _name;
  4497. }
  4498. }), new objj_method(sel_getUid("object"), function $CPNotification__object(self, _cmd)
  4499. { with(self)
  4500. {
  4501. return _object;
  4502. }
  4503. }), new objj_method(sel_getUid("userInfo"), function $CPNotification__userInfo(self, _cmd)
  4504. { with(self)
  4505. {
  4506. return _userInfo;
  4507. }
  4508. })]);
  4509. class_addMethods(meta_class, [new objj_method(sel_getUid("notificationWithName:object:userInfo:"), function $CPNotification__notificationWithName_object_userInfo_(self, _cmd, aNotificationName, anObject, aUserInfo)
  4510. { with(self)
  4511. {
  4512. return objj_msgSend(objj_msgSend(self, "alloc"), "initWithName:object:userInfo:", aNotificationName, anObject, aUserInfo);
  4513. }
  4514. }), new objj_method(sel_getUid("notificationWithName:object:"), function $CPNotification__notificationWithName_object_(self, _cmd, aNotificationName, anObject)
  4515. { with(self)
  4516. {
  4517. return objj_msgSend(objj_msgSend(self, "alloc"), "initWithName:object:userInfo:", aNotificationName, anObject, nil);
  4518. }
  4519. })]);
  4520. }
  4521. p;22;CPNotificationCenter.ji;9;CPArray.ji;14;CPDictionary.ji;16;CPNotification.ji;13;CPException.jc;10027;
  4522. var CPNotificationDefaultCenter = nil;
  4523. {var the_class = objj_allocateClassPair(CPObject, "CPNotificationCenter"),
  4524. meta_class = the_class.isa;class_addIvars(the_class, [new objj_ivar("_namedRegistries"), new objj_ivar("_unnamedRegistry")]);
  4525. objj_registerClassPair(the_class);
  4526. objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
  4527. class_addMethods(the_class, [new objj_method(sel_getUid("init"), function $CPNotificationCenter__init(self, _cmd)
  4528. { with(self)
  4529. {
  4530. self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPObject") }, "init");
  4531. if (self)
  4532. {
  4533. _namedRegistries = objj_msgSend(CPDictionary, "dictionary");
  4534. _unnamedRegistry = objj_msgSend(objj_msgSend(_CPNotificationRegistry, "alloc"), "init");
  4535. }
  4536. return self;
  4537. }
  4538. }), new objj_method(sel_getUid("addObserver:selector:name:object:"), function $CPNotificationCenter__addObserver_selector_name_object_(self, _cmd, anObserver, aSelector, aNotificationName, anObject)
  4539. { with(self)
  4540. {
  4541. var registry,
  4542. observer = objj_msgSend(objj_msgSend(_CPNotificationObserver, "alloc"), "initWithObserver:selector:", anObserver, aSelector);
  4543. if (aNotificationName == nil)
  4544. registry = _unnamedRegistry;
  4545. else if (!(registry = objj_msgSend(_namedRegistries, "objectForKey:", aNotificationName)))
  4546. {
  4547. registry = objj_msgSend(objj_msgSend(_CPNotificationRegistry, "alloc"), "init");
  4548. objj_msgSend(_namedRegistries, "setObject:forKey:", registry, aNotificationName);
  4549. }
  4550. objj_msgSend(registry, "addObserver:object:", observer, anObject);
  4551. }
  4552. }), new objj_method(sel_getUid("removeObserver:"), function $CPNotificationCenter__removeObserver_(self, _cmd, anObserver)
  4553. { with(self)
  4554. {
  4555. var name = nil,
  4556. names = objj_msgSend(_namedRegistries, "keyEnumerator");
  4557. while (name = objj_msgSend(names, "nextObject"))
  4558. objj_msgSend(objj_msgSend(_namedRegistries, "objectForKey:", name), "removeObserver:object:", anObserver, nil);
  4559. objj_msgSend(_unnamedRegistry, "removeObserver:object:", anObserver, nil);
  4560. }
  4561. }), new objj_method(sel_getUid("removeObserver:name:object:"), function $CPNotificationCenter__removeObserver_name_object_(self, _cmd, anObserver, aNotificationName, anObject)
  4562. { with(self)
  4563. {
  4564. if (aNotificationName == nil)
  4565. {
  4566. var name = nil,
  4567. names = objj_msgSend(_namedRegistries, "keyEnumerator");
  4568. while (name = objj_msgSend(names, "nextObject"))
  4569. objj_msgSend(objj_msgSend(_namedRegistries, "objectForKey:", name), "removeObserver:object:", anObserver, anObject);
  4570. objj_msgSend(_unnamedRegistry, "removeObserver:object:", anObserver, anObject);
  4571. }
  4572. else
  4573. objj_msgSend(objj_msgSend(_namedRegistries, "objectForKey:", aNotificationName), "removeObserver:object:", anObserver, anObject);
  4574. }
  4575. }), new objj_method(sel_getUid("postNotification:"), function $CPNotificationCenter__postNotification_(self, _cmd, aNotification)
  4576. { with(self)
  4577. {
  4578. if (!aNotification)
  4579. objj_msgSend(CPException, "raise:reason:", CPInvalidArgumentException, "postNotification: does not except 'nil' notifications");
  4580. _CPNotificationCenterPostNotification(self, aNotification);
  4581. }
  4582. }), new objj_method(sel_getUid("postNotificationName:object:userInfo:"), function $CPNotificationCenter__postNotificationName_object_userInfo_(self, _cmd, aNotificationName, anObject, aUserInfo)
  4583. { with(self)
  4584. {
  4585. _CPNotificationCenterPostNotification(self, objj_msgSend(objj_msgSend(CPNotification, "alloc"), "initWithName:object:userInfo:", aNotificationName, anObject, aUserInfo));
  4586. }
  4587. }), new objj_method(sel_getUid("postNotificationName:object:"), function $CPNotificationCenter__postNotificationName_object_(self, _cmd, aNotificationName, anObject)
  4588. { with(self)
  4589. {
  4590. _CPNotificationCenterPostNotification(self, objj_msgSend(objj_msgSend(CPNotification, "alloc"), "initWithName:object:userInfo:", aNotificationName, anObject, nil));
  4591. }
  4592. })]);
  4593. class_addMethods(meta_class, [new objj_method(sel_getUid("defaultCenter"), function $CPNotificationCenter__defaultCenter(self, _cmd)
  4594. { with(self)
  4595. {
  4596. if (!CPNotificationDefaultCenter)
  4597. CPNotificationDefaultCenter = objj_msgSend(objj_msgSend(CPNotificationCenter, "alloc"), "init");
  4598. return CPNotificationDefaultCenter;
  4599. }
  4600. })]);
  4601. }
  4602. var _CPNotificationCenterPostNotification = function( self, aNotification)
  4603. {
  4604. objj_msgSend(self._unnamedRegistry, "postNotification:", aNotification);
  4605. objj_msgSend(objj_msgSend(self._namedRegistries, "objectForKey:", objj_msgSend(aNotification, "name")), "postNotification:", aNotification);
  4606. }
  4607. {var the_class = objj_allocateClassPair(CPObject, "_CPNotificationRegistry"),
  4608. meta_class = the_class.isa;class_addIvars(the_class, [new objj_ivar("_objectObservers"), new objj_ivar("_observerRemoval"), new objj_ivar("_postingObservers")]);
  4609. objj_registerClassPair(the_class);
  4610. objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
  4611. class_addMethods(the_class, [new objj_method(sel_getUid("init"), function $_CPNotificationRegistry__init(self, _cmd)
  4612. { with(self)
  4613. {
  4614. if (self)
  4615. _objectObservers = objj_msgSend(CPDictionary, "dictionary");
  4616. return self;
  4617. }
  4618. }), new objj_method(sel_getUid("addObserver:object:"), function $_CPNotificationRegistry__addObserver_object_(self, _cmd, anObserver, anObject)
  4619. { with(self)
  4620. {
  4621. if (!anObject)
  4622. anObject = objj_msgSend(CPNull, "null");
  4623. var observers = objj_msgSend(_objectObservers, "objectForKey:", objj_msgSend(anObject, "hash"));
  4624. if (!observers)
  4625. {
  4626. observers = [];
  4627. objj_msgSend(_objectObservers, "setObject:forKey:", observers, objj_msgSend(anObject, "hash"));
  4628. }
  4629. if (observers == _postingObservers)
  4630. _postingObservers = objj_msgSend(observers, "copy");
  4631. observers.push(anObserver);
  4632. }
  4633. }), new objj_method(sel_getUid("removeObserver:object:"), function $_CPNotificationRegistry__removeObserver_object_(self, _cmd, anObserver, anObject)
  4634. { with(self)
  4635. {
  4636. var removedKeys = [];
  4637. if (anObject == nil)
  4638. {
  4639. var key = nil,
  4640. keys = objj_msgSend(_objectObservers, "keyEnumerator");
  4641. while (key = objj_msgSend(keys, "nextObject"))
  4642. {
  4643. var observers = objj_msgSend(_objectObservers, "objectForKey:", key),
  4644. count = observers ? observers.length : 0;
  4645. while (count--)
  4646. if (objj_msgSend(observers[count], "observer") == anObserver)
  4647. {
  4648. _observerRemoval = YES;
  4649. if (observers == _postingObservers)
  4650. _postingObservers = objj_msgSend(observers, "copy");
  4651. observers.splice(count, 1);
  4652. }
  4653. if (!observers || observers.length == 0)
  4654. removedKeys.push(key);
  4655. }
  4656. }
  4657. else
  4658. {
  4659. var key = objj_msgSend(anObject, "hash"),
  4660. observers = objj_msgSend(_objectObservers, "objectForKey:", key);
  4661. count = observers ? observers.length : 0;
  4662. while (count--)
  4663. if (objj_msgSend(observers[count], "observer") == anObserver)
  4664. {
  4665. _observerRemoval = YES;
  4666. if (observers == _postingObservers)
  4667. _postingObservers = objj_msgSend(observers, "copy");
  4668. observers.splice(count, 1)
  4669. }
  4670. if (!observers || observers.length == 0)
  4671. removedKeys.push(key);
  4672. }
  4673. var count = removedKeys.length;
  4674. while (count--)
  4675. objj_msgSend(_objectObservers, "removeObjectForKey:", removedKeys[count]);
  4676. }
  4677. }), new objj_method(sel_getUid("postNotification:"), function $_CPNotificationRegistry__postNotification_(self, _cmd, aNotification)
  4678. { with(self)
  4679. {
  4680. var object = objj_msgSend(aNotification, "object");
  4681. if (object != nil && (_postingObservers = objj_msgSend(_objectObservers, "objectForKey:", objj_msgSend(object, "hash"))))
  4682. {
  4683. var observers = _postingObservers,
  4684. count = observers.length;
  4685. _observerRemoval = NO;
  4686. while (count--)
  4687. {
  4688. var observer = _postingObservers[count];
  4689. if (!_observerRemoval || objj_msgSend(observers, "indexOfObjectIdenticalTo:", observer) != CPNotFound)
  4690. objj_msgSend(observer, "postNotification:", aNotification);
  4691. }
  4692. }
  4693. _postingObservers = objj_msgSend(_objectObservers, "objectForKey:", objj_msgSend(objj_msgSend(CPNull, "null"), "hash"));
  4694. if (!_postingObservers)
  4695. return;
  4696. var observers = _postingObservers,
  4697. count = observers.length;
  4698. _observerRemoval = NO;
  4699. while (count--)
  4700. {
  4701. var observer = _postingObservers[count];
  4702. if (!_observerRemoval || objj_msgSend(observers, "indexOfObjectIdenticalTo:", observer) != CPNotFound)
  4703. objj_msgSend(observer, "postNotification:", aNotification);
  4704. }
  4705. _postingObservers = nil;
  4706. }
  4707. }), new objj_method(sel_getUid("count"), function $_CPNotificationRegistry__count(self, _cmd)
  4708. { with(self)
  4709. {
  4710. return objj_msgSend(_objectObservers, "count");
  4711. }
  4712. })]);
  4713. }
  4714. {var the_class = objj_allocateClassPair(CPObject, "_CPNotificationObserver"),
  4715. meta_class = the_class.isa;class_addIvars(the_class, [new objj_ivar("_observer"), new objj_ivar("_selector")]);
  4716. objj_registerClassPair(the_class);
  4717. objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
  4718. class_addMethods(the_class, [new objj_method(sel_getUid("initWithObserver:selector:"), function $_CPNotificationObserver__initWithObserver_selector_(self, _cmd, anObserver, aSelector)
  4719. { with(self)
  4720. {
  4721. if (self)
  4722. {
  4723. _observer = anObserver;
  4724. _selector = aSelector;
  4725. }
  4726. return self;
  4727. }
  4728. }), new objj_method(sel_getUid("observer"), function $_CPNotificationObserver__observer(self, _cmd)
  4729. { with(self)
  4730. {
  4731. return _observer;
  4732. }
  4733. }), new objj_method(sel_getUid("postNotification:"), function $_CPNotificationObserver__postNotification_(self, _cmd, aNotification)
  4734. { with(self)
  4735. {
  4736. objj_msgSend(_observer, "performSelector:withObject:", _selector, aNotification);
  4737. }
  4738. })]);
  4739. }
  4740. p;8;CPNull.ji;10;CPObject.jc;500;
  4741. var CPNullSharedNull = nil;
  4742. {var the_class = objj_allocateClassPair(CPObject, "CPNull"),
  4743. meta_class = the_class.isa;objj_registerClassPair(the_class);
  4744. objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
  4745. class_addMethods(meta_class, [new objj_method(sel_getUid("null"), function $CPNull__null(self, _cmd)
  4746. { with(self)
  4747. {
  4748. if (!CPNullSharedNull)
  4749. CPNullSharedNull = objj_msgSend(objj_msgSend(CPNull, "alloc"), "init");
  4750. return CPNullSharedNull;
  4751. }
  4752. })]);
  4753. }
  4754. p;10;CPNumber.ji;10;CPObject.ji;15;CPObjJRuntime.jc;8499;
  4755. var __placeholder = new Number(),
  4756. _CPNumberHashes = { };
  4757. {var the_class = objj_allocateClassPair(CPObject, "CPNumber"),
  4758. meta_class = the_class.isa;objj_registerClassPair(the_class);
  4759. objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
  4760. class_addMethods(the_class, [new objj_method(sel_getUid("initWithBool:"), function $CPNumber__initWithBool_(self, _cmd, aBoolean)
  4761. { with(self)
  4762. {
  4763. return aBoolean;
  4764. }
  4765. }), new objj_method(sel_getUid("initWithChar:"), function $CPNumber__initWithChar_(self, _cmd, aChar)
  4766. { with(self)
  4767. {
  4768. if (aChar.charCodeAt)
  4769. return aChar.charCodeAt(0);
  4770. return aChar;
  4771. }
  4772. }), new objj_method(sel_getUid("initWithDouble:"), function $CPNumber__initWithDouble_(self, _cmd, aDouble)
  4773. { with(self)
  4774. {
  4775. return aDouble;
  4776. }
  4777. }), new objj_method(sel_getUid("initWithFloat:"), function $CPNumber__initWithFloat_(self, _cmd, aFloat)
  4778. { with(self)
  4779. {
  4780. return aFloat;
  4781. }
  4782. }), new objj_method(sel_getUid("initWithInt:"), function $CPNumber__initWithInt_(self, _cmd, anInt)
  4783. { with(self)
  4784. {
  4785. return anInt;
  4786. }
  4787. }), new objj_method(sel_getUid("initWithLong:"), function $CPNumber__initWithLong_(self, _cmd, aLong)
  4788. { with(self)
  4789. {
  4790. return aLong;
  4791. }
  4792. }), new objj_method(sel_getUid("initWithLongLong:"), function $CPNumber__initWithLongLong_(self, _cmd, aLongLong)
  4793. { with(self)
  4794. {
  4795. return aLongLong;
  4796. }
  4797. }), new objj_method(sel_getUid("initWithShort:"), function $CPNumber__initWithShort_(self, _cmd, aShort)
  4798. { with(self)
  4799. {
  4800. return aShort;
  4801. }
  4802. }), new objj_method(sel_getUid("initWithUnsignedChar:"), function $CPNumber__initWithUnsignedChar_(self, _cmd, aChar)
  4803. { with(self)
  4804. {
  4805. if (aChar.charCodeAt)
  4806. return aChar.charCodeAt(0);
  4807. return aChar;
  4808. }
  4809. }), new objj_method(sel_getUid("initWithUnsignedInt:"), function $CPNumber__initWithUnsignedInt_(self, _cmd, anUnsignedInt)
  4810. { with(self)
  4811. {
  4812. return anUnsignedInt;
  4813. }
  4814. }), new objj_method(sel_getUid("initWithUnsignedLong:"), function $CPNumber__initWithUnsignedLong_(self, _cmd, anUnsignedLong)
  4815. { with(self)
  4816. {
  4817. return anUnsignedLong;
  4818. }
  4819. }), new objj_method(sel_getUid("initWithUnsignedShort:"), function $CPNumber__initWithUnsignedShort_(self, _cmd, anUnsignedShort)
  4820. { with(self)
  4821. {
  4822. return anUnsignedShort;
  4823. }
  4824. }), new objj_method(sel_getUid("hash"), function $CPNumber__hash(self, _cmd)
  4825. { with(self)
  4826. {
  4827. if (!_CPNumberHashes[self])
  4828. _CPNumberHashes[self] = _objj_generateObjectHash();
  4829. return _CPNumberHashes[self];
  4830. }
  4831. }), new objj_method(sel_getUid("boolValue"), function $CPNumber__boolValue(self, _cmd)
  4832. { with(self)
  4833. {
  4834. return self ? true : false;
  4835. }
  4836. }), new objj_method(sel_getUid("charValue"), function $CPNumber__charValue(self, _cmd)
  4837. { with(self)
  4838. {
  4839. return String.fromCharCode(self);
  4840. }
  4841. }), new objj_method(sel_getUid("decimalValue"), function $CPNumber__decimalValue(self, _cmd)
  4842. { with(self)
  4843. {
  4844. objj_throw_exception("decimalValue: NOT YET IMPLEMENTED");
  4845. }
  4846. }), new objj_method(sel_getUid("descriptionWithLocale:"), function $CPNumber__descriptionWithLocale_(self, _cmd, aDictionary)
  4847. { with(self)
  4848. {
  4849. if (!aDictionary) return toString();
  4850. objj_throw_exception("descriptionWithLocale: NOT YET IMPLEMENTED");
  4851. }
  4852. }), new objj_method(sel_getUid("description"), function $CPNumber__description(self, _cmd)
  4853. { with(self)
  4854. {
  4855. return objj_msgSend(self, "descriptionWithLocale:", nil);
  4856. }
  4857. }), new objj_method(sel_getUid("doubleValue"), function $CPNumber__doubleValue(self, _cmd)
  4858. { with(self)
  4859. {
  4860. if (typeof self == "boolean") return self ? 1 : 0;
  4861. return self;
  4862. }
  4863. }), new objj_method(sel_getUid("floatValue"), function $CPNumber__floatValue(self, _cmd)
  4864. { with(self)
  4865. {
  4866. if (typeof self == "boolean") return self ? 1 : 0;
  4867. return self;
  4868. }
  4869. }), new objj_method(sel_getUid("intValue"), function $CPNumber__intValue(self, _cmd)
  4870. { with(self)
  4871. {
  4872. if (typeof self == "boolean") return self ? 1 : 0;
  4873. return self;
  4874. }
  4875. }), new objj_method(sel_getUid("longLongValue"), function $CPNumber__longLongValue(self, _cmd)
  4876. { with(self)
  4877. {
  4878. if (typeof self == "boolean") return self ? 1 : 0;
  4879. return self;
  4880. }
  4881. }), new objj_method(sel_getUid("longValue"), function $CPNumber__longValue(self, _cmd)
  4882. { with(self)
  4883. {
  4884. if (typeof self == "boolean") return self ? 1 : 0;
  4885. return self;
  4886. }
  4887. }), new objj_method(sel_getUid("shortValue"), function $CPNumber__shortValue(self, _cmd)
  4888. { with(self)
  4889. {
  4890. if (typeof self == "boolean") return self ? 1 : 0;
  4891. return self;
  4892. }
  4893. }), new objj_method(sel_getUid("stringValue"), function $CPNumber__stringValue(self, _cmd)
  4894. { with(self)
  4895. {
  4896. return toString();
  4897. }
  4898. }), new objj_method(sel_getUid("unsignedCharValue"), function $CPNumber__unsignedCharValue(self, _cmd)
  4899. { with(self)
  4900. {
  4901. return String.fromCharCode(self);
  4902. }
  4903. }), new objj_method(sel_getUid("unsignedIntValue"), function $CPNumber__unsignedIntValue(self, _cmd)
  4904. { with(self)
  4905. {
  4906. if (typeof self == "boolean") return self ? 1 : 0;
  4907. return self;
  4908. }
  4909. }), new objj_method(sel_getUid("unsignedLongValue"), function $CPNumber__unsignedLongValue(self, _cmd)
  4910. { with(self)
  4911. {
  4912. if (typeof self == "boolean") return self ? 1 : 0;
  4913. return self;
  4914. }
  4915. }), new objj_method(sel_getUid("unsignedShortValue"), function $CPNumber__unsignedShortValue(self, _cmd)
  4916. { with(self)
  4917. {
  4918. if (typeof self == "boolean") return self ? 1 : 0;
  4919. return self;
  4920. }
  4921. }), new objj_method(sel_getUid("compare:"), function $CPNumber__compare_(self, _cmd, aNumber)
  4922. { with(self)
  4923. {
  4924. if (self > aNumber) return CPOrderedDescending;
  4925. else if (self < aNumber) return CPOrderedAscending;
  4926. return CPOrderedSame;
  4927. }
  4928. }), new objj_method(sel_getUid("isEqualToNumber:"), function $CPNumber__isEqualToNumber_(self, _cmd, aNumber)
  4929. { with(self)
  4930. {
  4931. return self == aNumber;
  4932. }
  4933. })]);
  4934. class_addMethods(meta_class, [new objj_method(sel_getUid("alloc"), function $CPNumber__alloc(self, _cmd)
  4935. { with(self)
  4936. {
  4937. return __placeholder;
  4938. }
  4939. }), new objj_method(sel_getUid("numberWithBool:"), function $CPNumber__numberWithBool_(self, _cmd, aBoolean)
  4940. { with(self)
  4941. {
  4942. return aBoolean;
  4943. }
  4944. }), new objj_method(sel_getUid("numberWithChar:"), function $CPNumber__numberWithChar_(self, _cmd, aChar)
  4945. { with(self)
  4946. {
  4947. if (aChar.charCodeAt)
  4948. return aChar.charCodeAt(0);
  4949. return aChar;
  4950. }
  4951. }), new objj_method(sel_getUid("numberWithDouble:"), function $CPNumber__numberWithDouble_(self, _cmd, aDouble)
  4952. { with(self)
  4953. {
  4954. return aDouble;
  4955. }
  4956. }), new objj_method(sel_getUid("numberWithFloat:"), function $CPNumber__numberWithFloat_(self, _cmd, aFloat)
  4957. { with(self)
  4958. {
  4959. return aFloat;
  4960. }
  4961. }), new objj_method(sel_getUid("numberWithInt:"), function $CPNumber__numberWithInt_(self, _cmd, anInt)
  4962. { with(self)
  4963. {
  4964. return anInt;
  4965. }
  4966. }), new objj_method(sel_getUid("numberWithLong:"), function $CPNumber__numberWithLong_(self, _cmd, aLong)
  4967. { with(self)
  4968. {
  4969. return aLong;
  4970. }
  4971. }), new objj_method(sel_getUid("numberWithLongLong:"), function $CPNumber__numberWithLongLong_(self, _cmd, aLongLong)
  4972. { with(self)
  4973. {
  4974. return aLongLong;
  4975. }
  4976. }), new objj_method(sel_getUid("numberWithShort:"), function $CPNumber__numberWithShort_(self, _cmd, aShort)
  4977. { with(self)
  4978. {
  4979. return aShort;
  4980. }
  4981. }), new objj_method(sel_getUid("numberWithUnsignedChar:"), function $CPNumber__numberWithUnsignedChar_(self, _cmd, aChar)
  4982. { with(self)
  4983. {
  4984. if (aChar.charCodeAt)
  4985. return aChar.charCodeAt(0);
  4986. return aChar;
  4987. }
  4988. }), new objj_method(sel_getUid("numberWithUnsignedInt:"), function $CPNumber__numberWithUnsignedInt_(self, _cmd, anUnsignedInt)
  4989. { with(self)
  4990. {
  4991. return anUnsignedInt;
  4992. }
  4993. }), new objj_method(sel_getUid("numberWithUnsignedLong:"), function $CPNumber__numberWithUnsignedLong_(self, _cmd, anUnsignedLong)
  4994. { with(self)
  4995. {
  4996. return anUnsignedLong;
  4997. }
  4998. }), new objj_method(sel_getUid("numberWithUnsignedShort:"), function $CPNumber__numberWithUnsignedShort_(self, _cmd, anUnsignedShort)
  4999. { with(self)
  5000. {
  5001. return anUnsignedShort;
  5002. }
  5003. })]);
  5004. }
  5005. {
  5006. var the_class = objj_getClass("CPNumber")
  5007. if(!the_class) objj_exception_throw(new objj_exception(OBJJClassNotFoundException, "*** Could not find definition for class \"CPNumber\""));
  5008. var meta_class = the_class.isa;class_addMethods(the_class, [new objj_method(sel_getUid("initWithCoder:"), function $CPNumber__initWithCoder_(self, _cmd, aCoder)
  5009. { with(self)
  5010. {
  5011. return objj_msgSend(aCoder, "decodeNumber");
  5012. }
  5013. }), new objj_method(sel_getUid("encodeWithCoder:"), function $CPNumber__encodeWithCoder_(self, _cmd, aCoder)
  5014. { with(self)
  5015. {
  5016. objj_msgSend(aCoder, "encodeNumber:forKey:", self, "self");
  5017. }
  5018. })]);
  5019. }
  5020. Number.prototype.isa = CPNumber;
  5021. Boolean.prototype.isa = CPNumber;
  5022. objj_msgSend(CPNumber, "initialize");
  5023. p;10;CPObject.jc;8745;{var the_class = objj_allocateClassPair(Nil, "CPObject"),
  5024. meta_class = the_class.isa;class_addIvars(the_class, [new objj_ivar("isa")]);
  5025. objj_registerClassPair(the_class);
  5026. objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
  5027. class_addMethods(the_class, [new objj_method(sel_getUid("init"), function $CPObject__init(self, _cmd)
  5028. { with(self)
  5029. {
  5030. return self;
  5031. }
  5032. }), new objj_method(sel_getUid("copy"), function $CPObject__copy(self, _cmd)
  5033. { with(self)
  5034. {
  5035. return self;
  5036. }
  5037. }), new objj_method(sel_getUid("mutableCopy"), function $CPObject__mutableCopy(self, _cmd)
  5038. { with(self)
  5039. {
  5040. return objj_msgSend(self, "copy");
  5041. }
  5042. }), new objj_method(sel_getUid("dealloc"), function $CPObject__dealloc(self, _cmd)
  5043. { with(self)
  5044. {
  5045. }
  5046. }), new objj_method(sel_getUid("class"), function $CPObject__class(self, _cmd)
  5047. { with(self)
  5048. {
  5049. return isa;
  5050. }
  5051. }), new objj_method(sel_getUid("isKindOfClass:"), function $CPObject__isKindOfClass_(self, _cmd, aClass)
  5052. { with(self)
  5053. {
  5054. return objj_msgSend(isa, "isSubclassOfClass:", aClass);
  5055. }
  5056. }), new objj_method(sel_getUid("isMemberOfClass:"), function $CPObject__isMemberOfClass_(self, _cmd, aClass)
  5057. { with(self)
  5058. {
  5059. return self.isa === aClass;
  5060. }
  5061. }), new objj_method(sel_getUid("isProxy"), function $CPObject__isProxy(self, _cmd)
  5062. { with(self)
  5063. {
  5064. return NO;
  5065. }
  5066. }), new objj_method(sel_getUid("respondsToSelector:"), function $CPObject__respondsToSelector_(self, _cmd, aSelector)
  5067. { with(self)
  5068. {
  5069. return !!class_getInstanceMethod(isa, aSelector);
  5070. }
  5071. }), new objj_method(sel_getUid("methodForSelector:"), function $CPObject__methodForSelector_(self, _cmd, aSelector)
  5072. { with(self)
  5073. {
  5074. return class_getMethodImplementation(isa, aSelector);
  5075. }
  5076. }), new objj_method(sel_getUid("methodSignatureForSelector:"), function $CPObject__methodSignatureForSelector_(self, _cmd, aSelector)
  5077. { with(self)
  5078. {
  5079. return nil;
  5080. }
  5081. }), new objj_method(sel_getUid("description"), function $CPObject__description(self, _cmd)
  5082. { with(self)
  5083. {
  5084. return "<" + isa.name + " 0x" + objj_msgSend(CPString, "stringWithHash:", objj_msgSend(self, "hash")) + ">";
  5085. }
  5086. }), new objj_method(sel_getUid("performSelector:"), function $CPObject__performSelector_(self, _cmd, aSelector)
  5087. { with(self)
  5088. {
  5089. return objj_msgSend(self, aSelector);
  5090. }
  5091. }), new objj_method(sel_getUid("performSelector:withObject:"), function $CPObject__performSelector_withObject_(self, _cmd, aSelector, anObject)
  5092. { with(self)
  5093. {
  5094. return objj_msgSend(self, aSelector, anObject);
  5095. }
  5096. }), new objj_method(sel_getUid("performSelector:withObject:withObject:"), function $CPObject__performSelector_withObject_withObject_(self, _cmd, aSelector, anObject, anotherObject)
  5097. { with(self)
  5098. {
  5099. return objj_msgSend(self, aSelector, anObject, anotherObject);
  5100. }
  5101. }), new objj_method(sel_getUid("forwardInvocation:"), function $CPObject__forwardInvocation_(self, _cmd, anInvocation)
  5102. { with(self)
  5103. {
  5104. objj_msgSend(self, "doesNotRecognizeSelector:", objj_msgSend(anInvocation, "selector"));
  5105. }
  5106. }), new objj_method(sel_getUid("forward::"), function $CPObject__forward__(self, _cmd, aSelector, args)
  5107. { with(self)
  5108. {
  5109. var signature = objj_msgSend(self, "methodSignatureForSelector:", aSelector);
  5110. if (signature)
  5111. {
  5112. invocation = objj_msgSend(CPInvocation, "invocationWithMethodSignature:", signature);
  5113. objj_msgSend(invocation, "setTarget:", self);
  5114. objj_msgSend(invocation, "setSelector:", aSelector);
  5115. var index = 2,
  5116. count = args.length;
  5117. for (; index < count; ++index)
  5118. objj_msgSend(invocation, "setArgument:atIndex:", args[index], index);
  5119. objj_msgSend(self, "forwardInvocation:", invocation);
  5120. return objj_msgSend(invocation, "returnValue");
  5121. }
  5122. objj_msgSend(self, "doesNotRecognizeSelector:", aSelector);
  5123. }
  5124. }), new objj_method(sel_getUid("doesNotRecognizeSelector:"), function $CPObject__doesNotRecognizeSelector_(self, _cmd, aSelector)
  5125. { with(self)
  5126. {
  5127. objj_msgSend(CPException, "raise:reason:", CPInvalidArgumentException,
  5128. (class_isMetaClass(isa) ? "+" : "-") + " [" + objj_msgSend(self, "className") + " " + aSelector + "] unrecognized selector sent to " +
  5129. (class_isMetaClass(isa) ? "class" : "instance") + " 0x" + objj_msgSend(CPString, "stringWithHash:", objj_msgSend(self, "hash")));
  5130. }
  5131. }), new objj_method(sel_getUid("awakeAfterUsingCoder:"), function $CPObject__awakeAfterUsingCoder_(self, _cmd, aCoder)
  5132. { with(self)
  5133. {
  5134. return self;
  5135. }
  5136. }), new objj_method(sel_getUid("classForKeyedArchiver"), function $CPObject__classForKeyedArchiver(self, _cmd)
  5137. { with(self)
  5138. {
  5139. return objj_msgSend(self, "classForCoder");
  5140. }
  5141. }), new objj_method(sel_getUid("classForCoder"), function $CPObject__classForCoder(self, _cmd)
  5142. { with(self)
  5143. {
  5144. return objj_msgSend(self, "class");
  5145. }
  5146. }), new objj_method(sel_getUid("replacementObjectForArchiver:"), function $CPObject__replacementObjectForArchiver_(self, _cmd, anArchiver)
  5147. { with(self)
  5148. {
  5149. return objj_msgSend(self, "replacementObjectForCoder:", anArchiver);
  5150. }
  5151. }), new objj_method(sel_getUid("replacementObjectForKeyedArchiver:"), function $CPObject__replacementObjectForKeyedArchiver_(self, _cmd, anArchiver)
  5152. { with(self)
  5153. {
  5154. return objj_msgSend(self, "replacementObjectForCoder:", anArchiver);
  5155. }
  5156. }), new objj_method(sel_getUid("replacementObjectForCoder:"), function $CPObject__replacementObjectForCoder_(self, _cmd, aCoder)
  5157. { with(self)
  5158. {
  5159. return self;
  5160. }
  5161. }), new objj_method(sel_getUid("className"), function $CPObject__className(self, _cmd)
  5162. { with(self)
  5163. {
  5164. return isa.name;
  5165. }
  5166. }), new objj_method(sel_getUid("autorelease"), function $CPObject__autorelease(self, _cmd)
  5167. { with(self)
  5168. {
  5169. return self;
  5170. }
  5171. }), new objj_method(sel_getUid("hash"), function $CPObject__hash(self, _cmd)
  5172. { with(self)
  5173. {
  5174. return __address;
  5175. }
  5176. }), new objj_method(sel_getUid("isEqual:"), function $CPObject__isEqual_(self, _cmd, anObject)
  5177. { with(self)
  5178. {
  5179. return self === anObject || objj_msgSend(self, "hash") === objj_msgSend(anObject, "hash");
  5180. }
  5181. }), new objj_method(sel_getUid("retain"), function $CPObject__retain(self, _cmd)
  5182. { with(self)
  5183. {
  5184. return self;
  5185. }
  5186. }), new objj_method(sel_getUid("release"), function $CPObject__release(self, _cmd)
  5187. { with(self)
  5188. {
  5189. }
  5190. }), new objj_method(sel_getUid("self"), function $CPObject__self(self, _cmd)
  5191. { with(self)
  5192. {
  5193. return self;
  5194. }
  5195. }), new objj_method(sel_getUid("superclass"), function $CPObject__superclass(self, _cmd)
  5196. { with(self)
  5197. {
  5198. return isa.super_class;
  5199. }
  5200. })]);
  5201. class_addMethods(meta_class, [new objj_method(sel_getUid("load"), function $CPObject__load(self, _cmd)
  5202. { with(self)
  5203. {
  5204. }
  5205. }), new objj_method(sel_getUid("initialize"), function $CPObject__initialize(self, _cmd)
  5206. { with(self)
  5207. {
  5208. }
  5209. }), new objj_method(sel_getUid("new"), function $CPObject__new(self, _cmd)
  5210. { with(self)
  5211. {
  5212. return objj_msgSend(objj_msgSend(self, "alloc"), "init");
  5213. }
  5214. }), new objj_method(sel_getUid("alloc"), function $CPObject__alloc(self, _cmd)
  5215. { with(self)
  5216. {
  5217. return class_createInstance(self);
  5218. }
  5219. }), new objj_method(sel_getUid("class"), function $CPObject__class(self, _cmd)
  5220. { with(self)
  5221. {
  5222. return self;
  5223. }
  5224. }), new objj_method(sel_getUid("superclass"), function $CPObject__superclass(self, _cmd)
  5225. { with(self)
  5226. {
  5227. return super_class;
  5228. }
  5229. }), new objj_method(sel_getUid("isSubclassOfClass:"), function $CPObject__isSubclassOfClass_(self, _cmd, aClass)
  5230. { with(self)
  5231. {
  5232. var theClass = self;
  5233. for(; theClass; theClass = theClass.super_class)
  5234. if(theClass === aClass)
  5235. return YES;
  5236. return NO;
  5237. }
  5238. }), new objj_method(sel_getUid("isKindOfClass:"), function $CPObject__isKindOfClass_(self, _cmd, aClass)
  5239. { with(self)
  5240. {
  5241. return objj_msgSend(self, "isSubclassOfClass:", aClass);
  5242. }
  5243. }), new objj_method(sel_getUid("isMemberOfClass:"), function $CPObject__isMemberOfClass_(self, _cmd, aClass)
  5244. { with(self)
  5245. {
  5246. return self === aClass;
  5247. }
  5248. }), new objj_method(sel_getUid("instancesRespondToSelector:"), function $CPObject__instancesRespondToSelector_(self, _cmd, aSelector)
  5249. { with(self)
  5250. {
  5251. return !!class_getInstanceMethod(self, aSelector);
  5252. }
  5253. }), new objj_method(sel_getUid("instanceMethodForSelector:"), function $CPObject__instanceMethodForSelector_(self, _cmd, aSelector)
  5254. { with(self)
  5255. {
  5256. return class_getMethodImplementation(self, aSelector);
  5257. }
  5258. }), new objj_method(sel_getUid("setVersion:"), function $CPObject__setVersion_(self, _cmd, aVersion)
  5259. { with(self)
  5260. {
  5261. version = aVersion;
  5262. return self;
  5263. }
  5264. }), new objj_method(sel_getUid("version"), function $CPObject__version(self, _cmd)
  5265. { with(self)
  5266. {
  5267. return version;
  5268. }
  5269. })]);
  5270. }
  5271. objj_object.prototype.toString = function()
  5272. {
  5273. if (this.isa && class_getInstanceMethod(this.isa, "description") != NULL)
  5274. return objj_msgSend(this, "description")
  5275. else
  5276. return String(this) + " (-description not implemented)";
  5277. }
  5278. p;15;CPObjJRuntime.ji;7;CPLog.jc;467;
  5279. CPStringFromSelector= function(aSelector)
  5280. {
  5281. return sel_getName(aSelector);
  5282. }
  5283. CPSelectorFromString= function(aSelectorName)
  5284. {
  5285. return sel_registerName(aSelectorName);
  5286. }
  5287. CPClassFromString= function(aClassName)
  5288. {
  5289. return objj_getClass(aClassName);
  5290. }
  5291. CPStringFromClass= function(aClass)
  5292. {
  5293. return class_getName(aClass);
  5294. }
  5295. CPOrderedAscending = -1;
  5296. CPOrderedSame = 0;
  5297. CPOrderedDescending = 1;
  5298. CPNotFound = -1;
  5299. MIN = Math.min;
  5300. MAX = Math.max;
  5301. ABS = Math.abs;
  5302. p;29;CPPropertyListSerialization.ji;10;CPObject.jc;1089;
  5303. CPPropertyListOpenStepFormat = kCFPropertyListOpenStepFormat;
  5304. CPPropertyListXMLFormat_v1_0 = kCFPropertyListXMLFormat_v1_0;
  5305. CPPropertyListBinaryFormat_v1_0 = kCFPropertyListBinaryFormat_v1_0;
  5306. CPPropertyList280NorthFormat_v1_0 = kCFPropertyList280NorthFormat_v1_0;
  5307. {var the_class = objj_allocateClassPair(CPObject, "CPPropertyListSerialization"),
  5308. meta_class = the_class.isa;objj_registerClassPair(the_class);
  5309. objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
  5310. class_addMethods(meta_class, [new objj_method(sel_getUid("dataFromPropertyList:format:errorDescription:"), function $CPPropertyListSerialization__dataFromPropertyList_format_errorDescription_(self, _cmd, aPlist, aFormat, anErrorString)
  5311. { with(self)
  5312. {
  5313. return CPPropertyListCreateData(aPlist, aFormat);
  5314. }
  5315. }), new objj_method(sel_getUid("propertyListFromData:format:errorDescription:"), function $CPPropertyListSerialization__propertyListFromData_format_errorDescription_(self, _cmd, data, aFormat, errorString)
  5316. { with(self)
  5317. {
  5318. return CPPropertyListCreateFromData(data, aFormat);
  5319. }
  5320. })]);
  5321. }
  5322. p;9;CPRange.jc;1714;CPMakeRange= function(location, length)
  5323. {
  5324. return { location: location, length: length };
  5325. }
  5326. CPCopyRange= function(aRange)
  5327. {
  5328. return { location: aRange.location, length: aRange.length };
  5329. }
  5330. CPMakeRangeCopy= function(aRange)
  5331. {
  5332. return { location:aRange.location, length:aRange.length };
  5333. }
  5334. CPEmptyRange= function(aRange)
  5335. {
  5336. return aRange.length === 0;
  5337. }
  5338. CPMaxRange= function(aRange)
  5339. {
  5340. return aRange.location + aRange.length;
  5341. }
  5342. CPEqualRanges= function(lhsRange, rhsRange)
  5343. {
  5344. return ((lhsRange.location === rhsRange.location) && (lhsRange.length === rhsRange.length));
  5345. }
  5346. CPLocationInRange= function(aLocation, aRange)
  5347. {
  5348. return (aLocation >= aRange.location) && (aLocation < CPMaxRange(aRange));
  5349. }
  5350. CPUnionRange= function(lhsRange, rhsRange)
  5351. {
  5352. var location = MIN(lhsRange.location, rhsRange.location);
  5353. return CPMakeRange(location, MAX(CPMaxRange(lhsRange), CPMaxRange(rhsRange)) - location);
  5354. }
  5355. CPIntersectionRange= function(lhsRange, rhsRange)
  5356. {
  5357. if(CPMaxRange(lhsRange) < rhsRange.location || CPMaxRange(rhsRange) < lhsRange.location)
  5358. return CPMakeRange(0, 0);
  5359. var location = MAX(lhsRange.location, rhsRange.location);
  5360. return CPMakeRange(location, MIN(CPMaxRange(lhsRange), CPMaxRange(rhsRange)) - location);
  5361. }
  5362. CPRangeInRange= function(lhsRange, rhsRange)
  5363. {
  5364. return (lhsRange.location <= rhsRange.location && CPMaxRange(lhsRange) >= CPMaxRange(rhsRange));
  5365. }
  5366. CPStringFromRange= function(aRange)
  5367. {
  5368. return "{" + aRange.location + ", " + aRange.length + "}";
  5369. }
  5370. CPRangeFromString= function(aString)
  5371. {
  5372. var comma = aString.indexOf(',');
  5373. return { location:parseInt(aString.substr(1, comma - 1)), length:parseInt(aString.substring(comma + 1, aString.length)) };
  5374. }
  5375. p;11;CPRunLoop.ji;10;CPObject.ji;9;CPArray.ji;10;CPString.jc;9636;
  5376. CPDefaultRunLoopMode = "CPDefaultRunLoopMode";
  5377. _CPRunLoopPerformCompare= function(lhs, rhs)
  5378. {
  5379. return objj_msgSend(rhs, "order") - objj_msgSend(lhs, "order");
  5380. }
  5381. var _CPRunLoopPerformPool = [],
  5382. _CPRunLoopPerformPoolCapacity = 5;
  5383. {var the_class = objj_allocateClassPair(CPObject, "_CPRunLoopPerform"),
  5384. meta_class = the_class.isa;class_addIvars(the_class, [new objj_ivar("_target"), new objj_ivar("_selector"), new objj_ivar("_argument"), new objj_ivar("_order"), new objj_ivar("_runLoopModes"), new objj_ivar("_isValid")]);
  5385. objj_registerClassPair(the_class);
  5386. objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
  5387. class_addMethods(the_class, [new objj_method(sel_getUid("initWithSelector:target:argument:order:modes:"), function $_CPRunLoopPerform__initWithSelector_target_argument_order_modes_(self, _cmd, aSelector, aTarget, anArgument, anOrder, modes)
  5388. { with(self)
  5389. {
  5390. self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPObject") }, "init");
  5391. if (self)
  5392. {
  5393. _selector = aSelector;
  5394. _target = aTarget;
  5395. _argument = anArgument;
  5396. _order = anOrder;
  5397. _runLoopModes = modes;
  5398. _isValid = YES;
  5399. }
  5400. return self;
  5401. }
  5402. }), new objj_method(sel_getUid("selector"), function $_CPRunLoopPerform__selector(self, _cmd)
  5403. { with(self)
  5404. {
  5405. return _selector;
  5406. }
  5407. }), new objj_method(sel_getUid("target"), function $_CPRunLoopPerform__target(self, _cmd)
  5408. { with(self)
  5409. {
  5410. return _target;
  5411. }
  5412. }), new objj_method(sel_getUid("argument"), function $_CPRunLoopPerform__argument(self, _cmd)
  5413. { with(self)
  5414. {
  5415. return _argument;
  5416. }
  5417. }), new objj_method(sel_getUid("order"), function $_CPRunLoopPerform__order(self, _cmd)
  5418. { with(self)
  5419. {
  5420. return _order;
  5421. }
  5422. }), new objj_method(sel_getUid("fireInMode:"), function $_CPRunLoopPerform__fireInMode_(self, _cmd, aRunLoopMode)
  5423. { with(self)
  5424. {
  5425. if (!_isValid)
  5426. return YES;
  5427. if (objj_msgSend(_runLoopModes, "containsObject:", aRunLoopMode))
  5428. {
  5429. objj_msgSend(_target, "performSelector:withObject:", _selector, _argument);
  5430. return YES;
  5431. }
  5432. return NO;
  5433. }
  5434. }), new objj_method(sel_getUid("invalidate"), function $_CPRunLoopPerform__invalidate(self, _cmd)
  5435. { with(self)
  5436. {
  5437. _isValid = NO;
  5438. }
  5439. })]);
  5440. class_addMethods(meta_class, [new objj_method(sel_getUid("_poolPerform:"), function $_CPRunLoopPerform___poolPerform_(self, _cmd, aPerform)
  5441. { with(self)
  5442. {
  5443. if (!aPerform || _CPRunLoopPerformPool.length >= _CPRunLoopPerformPoolCapacity)
  5444. return;
  5445. _CPRunLoopPerformPool.push(aPerform);
  5446. }
  5447. }), new objj_method(sel_getUid("performWithSelector:target:argument:order:modes:"), function $_CPRunLoopPerform__performWithSelector_target_argument_order_modes_(self, _cmd, aSelector, aTarget, anArgument, anOrder, modes)
  5448. { with(self)
  5449. {
  5450. if (_CPRunLoopPerformPool.length)
  5451. {
  5452. var perform = _CPRunLoopPerformPool.pop();
  5453. perform._target = aTarget;
  5454. perform._selector = aSelector;
  5455. perform._argument = anArgument;
  5456. perform._order = anOrder;
  5457. perform._runLoopModes = modes;
  5458. perform._isValid = YES;
  5459. return perform;
  5460. }
  5461. return objj_msgSend(objj_msgSend(self, "alloc"), "initWithSelector:target:argument:order:modes:", aSelector, aTarget, anArgument, anOrder, modes);
  5462. }
  5463. })]);
  5464. }
  5465. var CPRunLoopLastNativeRunLoop = 0;
  5466. {var the_class = objj_allocateClassPair(CPObject, "CPRunLoop"),
  5467. meta_class = the_class.isa;class_addIvars(the_class, [new objj_ivar("_runLoopLock"), new objj_ivar("_timersForModes"), new objj_ivar("_nativeTimersForModes"), new objj_ivar("_nextTimerFireDatesForModes"), new objj_ivar("_didAddTimer"), new objj_ivar("_effectiveDate"), new objj_ivar("_orderedPerforms")]);
  5468. objj_registerClassPair(the_class);
  5469. objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
  5470. class_addMethods(the_class, [new objj_method(sel_getUid("init"), function $CPRunLoop__init(self, _cmd)
  5471. { with(self)
  5472. {
  5473. self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPObject") }, "init");
  5474. if (self)
  5475. {
  5476. _orderedPerforms = [];
  5477. _timersForModes = {};
  5478. _nativeTimersForModes = {};
  5479. _nextTimerFireDatesForModes = {};
  5480. }
  5481. return self;
  5482. }
  5483. }), new objj_method(sel_getUid("performSelector:target:argument:order:modes:"), function $CPRunLoop__performSelector_target_argument_order_modes_(self, _cmd, aSelector, aTarget, anArgument, anOrder, modes)
  5484. { with(self)
  5485. {
  5486. var perform = objj_msgSend(_CPRunLoopPerform, "performWithSelector:target:argument:order:modes:", aSelector, aTarget, anArgument, anOrder, modes),
  5487. count = _orderedPerforms.length;
  5488. while (count--)
  5489. if (anOrder < objj_msgSend(_orderedPerforms[count], "order"))
  5490. break;
  5491. _orderedPerforms.splice(count + 1, 0, perform);
  5492. }
  5493. }), new objj_method(sel_getUid("cancelPerformSelector:target:argument:"), function $CPRunLoop__cancelPerformSelector_target_argument_(self, _cmd, aSelector, aTarget, anArgument)
  5494. { with(self)
  5495. {
  5496. var count = _orderedPerforms.length;
  5497. while (count--)
  5498. {
  5499. var perform = _orderedPerforms[count];
  5500. if (objj_msgSend(perform, "selector") === aSelector && objj_msgSend(perform, "target") == aTarget && objj_msgSend(perform, "argument") == anArgument)
  5501. objj_msgSend(_orderedPerforms[count], "invalidate");
  5502. }
  5503. }
  5504. }), new objj_method(sel_getUid("performSelectors"), function $CPRunLoop__performSelectors(self, _cmd)
  5505. { with(self)
  5506. {
  5507. objj_msgSend(self, "limitDateForMode:", CPDefaultRunLoopMode);
  5508. }
  5509. }), new objj_method(sel_getUid("addTimer:forMode:"), function $CPRunLoop__addTimer_forMode_(self, _cmd, aTimer, aMode)
  5510. { with(self)
  5511. {
  5512. if (_timersForModes[aMode])
  5513. _timersForModes[aMode].push(aTimer);
  5514. else
  5515. _timersForModes[aMode] = [aTimer];
  5516. _didAddTimer = YES;
  5517. if (!aTimer._lastNativeRunLoopsForModes)
  5518. aTimer._lastNativeRunLoopsForModes = {};
  5519. aTimer._lastNativeRunLoopsForModes[aMode] = CPRunLoopLastNativeRunLoop;
  5520. }
  5521. }), new objj_method(sel_getUid("limitDateForMode:"), function $CPRunLoop__limitDateForMode_(self, _cmd, aMode)
  5522. { with(self)
  5523. {
  5524. if (_runLoopLock)
  5525. return;
  5526. _runLoopLock = YES;
  5527. var now = _effectiveDate ? objj_msgSend(_effectiveDate, "laterDate:", objj_msgSend(CPDate, "date")) : objj_msgSend(CPDate, "date"),
  5528. nextFireDate = nil,
  5529. nextTimerFireDate = _nextTimerFireDatesForModes[aMode];
  5530. if (_didAddTimer || nextTimerFireDate && nextTimerFireDate <= now)
  5531. {
  5532. _didAddTimer = NO;
  5533. if (_nativeTimersForModes[aMode] !== nil)
  5534. {
  5535. window.clearNativeTimeout(_nativeTimersForModes[aMode]);
  5536. _nativeTimersForModes[aMode] = nil;
  5537. }
  5538. var timers = _timersForModes[aMode],
  5539. index = timers.length;
  5540. _timersForModes[aMode] = nil;
  5541. while (index--)
  5542. {
  5543. var timer = timers[index];
  5544. if (timer._lastNativeRunLoopsForModes[aMode] < CPRunLoopLastNativeRunLoop && timer._isValid && timer._fireDate <= now)
  5545. objj_msgSend(timer, "fire");
  5546. if (timer._isValid)
  5547. nextFireDate = (nextFireDate === nil) ? timer._fireDate : objj_msgSend(nextFireDate, "earlierDate:", timer._fireDate);
  5548. else
  5549. {
  5550. timer._lastNativeRunLoopsForModes[aMode] = 0;
  5551. timers.splice(index, 1);
  5552. }
  5553. }
  5554. var newTimers = _timersForModes[aMode];
  5555. if (newTimers && newTimers.length)
  5556. {
  5557. index = newTimers.length;
  5558. while (index--)
  5559. {
  5560. var timer = newTimers[index];
  5561. if (objj_msgSend(timer, "isValid"))
  5562. nextFireDate = (nextFireDate === nil) ? timer._fireDate : objj_msgSend(nextFireDate, "earlierDate:", timer._fireDate);
  5563. else
  5564. newTimers.splice(index, 1);
  5565. }
  5566. _timersForModes[aMode] = newTimers.concat(timers);
  5567. }
  5568. else
  5569. _timersForModes[aMode] = timers;
  5570. _nextTimerFireDatesForModes[aMode] = nextFireDate;
  5571. if (_nextTimerFireDatesForModes[aMode] !== nil)
  5572. _nativeTimersForModes[aMode] = window.setNativeTimeout(function() { _effectiveDate = nextFireDate; _nativeTimersForModes[aMode] = nil; ++CPRunLoopLastNativeRunLoop; objj_msgSend(self, "limitDateForMode:", aMode); _effectiveDate = nil; }, MAX(0, objj_msgSend(nextFireDate, "timeIntervalSinceNow") * 1000));
  5573. }
  5574. var performs = _orderedPerforms,
  5575. index = performs.length;
  5576. _orderedPerforms = [];
  5577. while (index--)
  5578. {
  5579. var perform = performs[index];
  5580. if (objj_msgSend(perform, "fireInMode:", CPDefaultRunLoopMode))
  5581. {
  5582. objj_msgSend(_CPRunLoopPerform, "_poolPerform:", perform);
  5583. performs.splice(index, 1);
  5584. }
  5585. }
  5586. if (_orderedPerforms.length)
  5587. {
  5588. _orderedPerforms = _orderedPerforms.concat(performs);
  5589. _orderedPerforms.sort(_CPRunLoopPerformCompare);
  5590. }
  5591. else
  5592. _orderedPerforms = performs;
  5593. _runLoopLock = NO;
  5594. return nextFireDate;
  5595. }
  5596. })]);
  5597. class_addMethods(meta_class, [new objj_method(sel_getUid("initialize"), function $CPRunLoop__initialize(self, _cmd)
  5598. { with(self)
  5599. {
  5600. if (self != objj_msgSend(CPRunLoop, "class"))
  5601. return;
  5602. CPMainRunLoop = objj_msgSend(objj_msgSend(CPRunLoop, "alloc"), "init");
  5603. }
  5604. }), new objj_method(sel_getUid("currentRunLoop"), function $CPRunLoop__currentRunLoop(self, _cmd)
  5605. { with(self)
  5606. {
  5607. return CPMainRunLoop;
  5608. }
  5609. }), new objj_method(sel_getUid("mainRunLoop"), function $CPRunLoop__mainRunLoop(self, _cmd)
  5610. { with(self)
  5611. {
  5612. return CPMainRunLoop;
  5613. }
  5614. })]);
  5615. }
  5616. p;7;CPSet.ji;10;CPObject.ji;9;CPArray.ji;10;CPNumber.ji;14;CPEnumerator.jc;10411;
  5617. {var the_class = objj_allocateClassPair(CPObject, "CPSet"),
  5618. meta_class = the_class.isa;class_addIvars(the_class, [new objj_ivar("_contents"), new objj_ivar("_count")]);
  5619. objj_registerClassPair(the_class);
  5620. objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
  5621. class_addMethods(the_class, [new objj_method(sel_getUid("init"), function $CPSet__init(self, _cmd)
  5622. { with(self)
  5623. {
  5624. if (self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPObject") }, "init"))
  5625. {
  5626. _count = 0;
  5627. _contents = {};
  5628. }
  5629. return self;
  5630. }
  5631. }), new objj_method(sel_getUid("initWithArray:"), function $CPSet__initWithArray_(self, _cmd, anArray)
  5632. { with(self)
  5633. {
  5634. if (self = objj_msgSend(self, "init"))
  5635. {
  5636. var count = anArray.length;
  5637. while (count--)
  5638. objj_msgSend(self, "addObject:", anArray[count]);
  5639. }
  5640. return self;
  5641. }
  5642. }), new objj_method(sel_getUid("initWithObjects:count:"), function $CPSet__initWithObjects_count_(self, _cmd, objects, count)
  5643. { with(self)
  5644. {
  5645. return objj_msgSend(self, "initWithArray:", objects.splice(0, count));
  5646. }
  5647. }), new objj_method(sel_getUid("initWithObjects:"), function $CPSet__initWithObjects_(self, _cmd, anObject)
  5648. { with(self)
  5649. {
  5650. if (self = objj_msgSend(self, "init"))
  5651. {
  5652. var argLength = arguments.length,
  5653. i = 2;
  5654. for(; i < argLength && (argument = arguments[i]) != nil; ++i)
  5655. objj_msgSend(self, "addObject:", argument);
  5656. }
  5657. return self;
  5658. }
  5659. }), new objj_method(sel_getUid("initWithSet:"), function $CPSet__initWithSet_(self, _cmd, aSet)
  5660. { with(self)
  5661. {
  5662. return objj_msgSend(self, "initWithSet:copyItems:", aSet, NO);
  5663. }
  5664. }), new objj_method(sel_getUid("initWithSet:copyItems:"), function $CPSet__initWithSet_copyItems_(self, _cmd, aSet, shouldCopyItems)
  5665. { with(self)
  5666. {
  5667. self = objj_msgSend(self, "init");
  5668. if (!aSet)
  5669. return self;
  5670. var contents = aSet._contents;
  5671. for (var property in contents)
  5672. {
  5673. if (contents.hasOwnProperty(property))
  5674. {
  5675. if (shouldCopyItems)
  5676. objj_msgSend(self, "addObject:", objj_msgSend(contents[property], "copy"));
  5677. else
  5678. objj_msgSend(self, "addObject:", contents[property]);
  5679. }
  5680. }
  5681. return self;
  5682. }
  5683. }), new objj_method(sel_getUid("allObjects"), function $CPSet__allObjects(self, _cmd)
  5684. { with(self)
  5685. {
  5686. var array = [];
  5687. for (var property in _contents)
  5688. {
  5689. if (_contents.hasOwnProperty(property))
  5690. array.push(_contents[property]);
  5691. }
  5692. return array;
  5693. }
  5694. }), new objj_method(sel_getUid("anyObject"), function $CPSet__anyObject(self, _cmd)
  5695. { with(self)
  5696. {
  5697. for (var property in _contents)
  5698. {
  5699. if (_contents.hasOwnProperty(property))
  5700. return _contents[property];
  5701. }
  5702. return nil;
  5703. }
  5704. }), new objj_method(sel_getUid("containsObject:"), function $CPSet__containsObject_(self, _cmd, anObject)
  5705. { with(self)
  5706. {
  5707. if (_contents[objj_msgSend(anObject, "hash")] && objj_msgSend(_contents[objj_msgSend(anObject, "hash")], "isEqual:", anObject))
  5708. return YES;
  5709. return NO;
  5710. }
  5711. }), new objj_method(sel_getUid("count"), function $CPSet__count(self, _cmd)
  5712. { with(self)
  5713. {
  5714. return _count;
  5715. }
  5716. }), new objj_method(sel_getUid("intersectsSet:"), function $CPSet__intersectsSet_(self, _cmd, set)
  5717. { with(self)
  5718. {
  5719. var items = objj_msgSend(set, "allObjects");
  5720. for (var i = items.length; i > 0; i--)
  5721. {
  5722. if (objj_msgSend(self, "containsObject:", items[i]))
  5723. return YES;
  5724. }
  5725. return NO;
  5726. }
  5727. }), new objj_method(sel_getUid("isEqualToSet:"), function $CPSet__isEqualToSet_(self, _cmd, set)
  5728. { with(self)
  5729. {
  5730. return self === set || (objj_msgSend(self, "count") === objj_msgSend(set, "count") && objj_msgSend(set, "isSubsetOfSet:", self));
  5731. }
  5732. }), new objj_method(sel_getUid("isSubsetOfSet:"), function $CPSet__isSubsetOfSet_(self, _cmd, set)
  5733. { with(self)
  5734. {
  5735. var items = objj_msgSend(self, "allObjects");
  5736. for (var i = 0; i < items.length; i++)
  5737. {
  5738. if (!objj_msgSend(set, "containsObject:", items[i]))
  5739. return NO;
  5740. }
  5741. return YES;
  5742. }
  5743. }), new objj_method(sel_getUid("makeObjectsPerformSelector:"), function $CPSet__makeObjectsPerformSelector_(self, _cmd, aSelector)
  5744. { with(self)
  5745. {
  5746. objj_msgSend(self, "makeObjectsPerformSelector:withObject:", aSelector, nil);
  5747. }
  5748. }), new objj_method(sel_getUid("makeObjectsPerformSelector:withObject:"), function $CPSet__makeObjectsPerformSelector_withObject_(self, _cmd, aSelector, argument)
  5749. { with(self)
  5750. {
  5751. var items = objj_msgSend(self, "allObjects");
  5752. for (var i = 0; i < items.length; i++)
  5753. {
  5754. objj_msgSend(items[i], "performSelector:withObject:", aSelector, argument);
  5755. }
  5756. }
  5757. }), new objj_method(sel_getUid("member:"), function $CPSet__member_(self, _cmd, object)
  5758. { with(self)
  5759. {
  5760. if (objj_msgSend(self, "containsObject:", object))
  5761. return object;
  5762. return nil;
  5763. }
  5764. }), new objj_method(sel_getUid("objectEnumerator"), function $CPSet__objectEnumerator(self, _cmd)
  5765. { with(self)
  5766. {
  5767. return objj_msgSend(objj_msgSend(self, "allObjects"), "objectEnumerator");
  5768. }
  5769. }), new objj_method(sel_getUid("initWithCapacity:"), function $CPSet__initWithCapacity_(self, _cmd, numItems)
  5770. { with(self)
  5771. {
  5772. self = objj_msgSend(self, "init");
  5773. return self;
  5774. }
  5775. }), new objj_method(sel_getUid("setSet:"), function $CPSet__setSet_(self, _cmd, set)
  5776. { with(self)
  5777. {
  5778. objj_msgSend(self, "removeAllObjects");
  5779. objj_msgSend(self, "addObjectsFromArray:", objj_msgSend(set, "allObjects"));
  5780. }
  5781. }), new objj_method(sel_getUid("addObject:"), function $CPSet__addObject_(self, _cmd, anObject)
  5782. { with(self)
  5783. {
  5784. _contents[objj_msgSend(anObject, "hash")] = anObject;
  5785. _count++;
  5786. }
  5787. }), new objj_method(sel_getUid("addObjectsFromArray:"), function $CPSet__addObjectsFromArray_(self, _cmd, array)
  5788. { with(self)
  5789. {
  5790. for (var i = 0, count = array.length; i < count; i++)
  5791. {
  5792. objj_msgSend(self, "addObject:", array[i]);
  5793. }
  5794. }
  5795. }), new objj_method(sel_getUid("removeObject:"), function $CPSet__removeObject_(self, _cmd, anObject)
  5796. { with(self)
  5797. {
  5798. if (objj_msgSend(self, "containsObject:", anObject))
  5799. {
  5800. delete _contents[objj_msgSend(anObject, "hash")];
  5801. _count--;
  5802. }
  5803. }
  5804. }), new objj_method(sel_getUid("removeAllObjects"), function $CPSet__removeAllObjects(self, _cmd)
  5805. { with(self)
  5806. {
  5807. _contents = {};
  5808. _count = 0;
  5809. }
  5810. }), new objj_method(sel_getUid("intersectSet:"), function $CPSet__intersectSet_(self, _cmd, set)
  5811. { with(self)
  5812. {
  5813. var items = objj_msgSend(self, "allObjects");
  5814. for (var i = 0, count = items.length; i < count; i++)
  5815. {
  5816. if (!objj_msgSend(set, "containsObject:", items[i]))
  5817. objj_msgSend(self, "removeObject:", items[i]);
  5818. }
  5819. }
  5820. }), new objj_method(sel_getUid("minusSet:"), function $CPSet__minusSet_(self, _cmd, set)
  5821. { with(self)
  5822. {
  5823. var items = objj_msgSend(set, "allObjects");
  5824. for (var i = 0; i < items.length; i++)
  5825. {
  5826. if (objj_msgSend(self, "containsObject:", items[i]))
  5827. objj_msgSend(self, "removeObject:", items[i]);
  5828. }
  5829. }
  5830. }), new objj_method(sel_getUid("unionSet:"), function $CPSet__unionSet_(self, _cmd, set)
  5831. { with(self)
  5832. {
  5833. var items = objj_msgSend(set, "allObjects");
  5834. for (var i = 0, count = items.length; i < count; i++)
  5835. {
  5836. objj_msgSend(self, "addObject:", items[i]);
  5837. }
  5838. }
  5839. })]);
  5840. class_addMethods(meta_class, [new objj_method(sel_getUid("set"), function $CPSet__set(self, _cmd)
  5841. { with(self)
  5842. {
  5843. return objj_msgSend(objj_msgSend(self, "alloc"), "init");
  5844. }
  5845. }), new objj_method(sel_getUid("setWithArray:"), function $CPSet__setWithArray_(self, _cmd, array)
  5846. { with(self)
  5847. {
  5848. return objj_msgSend(objj_msgSend(self, "alloc"), "initWithArray:", array);
  5849. }
  5850. }), new objj_method(sel_getUid("setWithObject:"), function $CPSet__setWithObject_(self, _cmd, anObject)
  5851. { with(self)
  5852. {
  5853. return objj_msgSend(objj_msgSend(self, "alloc"), "initWithArray:", [anObject]);
  5854. }
  5855. }), new objj_method(sel_getUid("setWithObjects:count:"), function $CPSet__setWithObjects_count_(self, _cmd, objects, count)
  5856. { with(self)
  5857. {
  5858. return objj_msgSend(objj_msgSend(self, "alloc"), "initWithObjects:count:", objects, count);
  5859. }
  5860. }), new objj_method(sel_getUid("setWithObjects:"), function $CPSet__setWithObjects_(self, _cmd, anObject)
  5861. { with(self)
  5862. {
  5863. var set = objj_msgSend(objj_msgSend(self, "alloc"), "init"),
  5864. argLength = arguments.length,
  5865. i = 2;
  5866. for(; i < argLength && ((argument = arguments[i]) !== nil); ++i)
  5867. objj_msgSend(set, "addObject:", argument);
  5868. return set;
  5869. }
  5870. }), new objj_method(sel_getUid("setWithSet:"), function $CPSet__setWithSet_(self, _cmd, set)
  5871. { with(self)
  5872. {
  5873. return objj_msgSend(objj_msgSend(self, "alloc"), "initWithSet:", set);
  5874. }
  5875. }), new objj_method(sel_getUid("setWithCapacity:"), function $CPSet__setWithCapacity_(self, _cmd, numItems)
  5876. { with(self)
  5877. {
  5878. return objj_msgSend(objj_msgSend(self, "alloc"), "initWithCapacity:", numItems);
  5879. }
  5880. })]);
  5881. }
  5882. {
  5883. var the_class = objj_getClass("CPSet")
  5884. if(!the_class) objj_exception_throw(new objj_exception(OBJJClassNotFoundException, "*** Could not find definition for class \"CPSet\""));
  5885. var meta_class = the_class.isa;class_addMethods(the_class, [new objj_method(sel_getUid("copy"), function $CPSet__copy(self, _cmd)
  5886. { with(self)
  5887. {
  5888. return objj_msgSend(objj_msgSend(CPSet, "alloc"), "initWithSet:", self);
  5889. }
  5890. }), new objj_method(sel_getUid("mutableCopy"), function $CPSet__mutableCopy(self, _cmd)
  5891. { with(self)
  5892. {
  5893. return objj_msgSend(self, "copy");
  5894. }
  5895. })]);
  5896. }
  5897. var CPSetObjectsKey = "CPSetObjectsKey";
  5898. {
  5899. var the_class = objj_getClass("CPSet")
  5900. if(!the_class) objj_exception_throw(new objj_exception(OBJJClassNotFoundException, "*** Could not find definition for class \"CPSet\""));
  5901. var meta_class = the_class.isa;class_addMethods(the_class, [new objj_method(sel_getUid("initWithCoder:"), function $CPSet__initWithCoder_(self, _cmd, aCoder)
  5902. { with(self)
  5903. {
  5904. return objj_msgSend(self, "initWithArray:", objj_msgSend(aCoder, "decodeObjectForKey:", CPSetObjectsKey));
  5905. }
  5906. }), new objj_method(sel_getUid("encodeWithCoder:"), function $CPSet__encodeWithCoder_(self, _cmd, aCoder)
  5907. { with(self)
  5908. {
  5909. objj_msgSend(aCoder, "encodeObject:forKey:", objj_msgSend(self, "allObjects"), CPSetObjectsKey);
  5910. }
  5911. })]);
  5912. }
  5913. {var the_class = objj_allocateClassPair(CPSet, "CPMutableSet"),
  5914. meta_class = the_class.isa;objj_registerClassPair(the_class);
  5915. objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
  5916. }
  5917. p;18;CPSortDescriptor.ji;10;CPObject.ji;15;CPObjJRuntime.jc;2123;
  5918. CPOrderedAscending = -1;
  5919. CPOrderedSame = 0;
  5920. CPOrderedDescending = 1;
  5921. {var the_class = objj_allocateClassPair(CPObject, "CPSortDescriptor"),
  5922. meta_class = the_class.isa;class_addIvars(the_class, [new objj_ivar("_key"), new objj_ivar("_selector"), new objj_ivar("_ascending")]);
  5923. objj_registerClassPair(the_class);
  5924. objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
  5925. class_addMethods(the_class, [new objj_method(sel_getUid("initWithKey:ascending:"), function $CPSortDescriptor__initWithKey_ascending_(self, _cmd, aKey, isAscending)
  5926. { with(self)
  5927. {
  5928. return objj_msgSend(self, "initWithKey:ascending:selector:", aKey, isAscending, sel_getUid("compare:"));
  5929. }
  5930. }), new objj_method(sel_getUid("initWithKey:ascending:selector:"), function $CPSortDescriptor__initWithKey_ascending_selector_(self, _cmd, aKey, isAscending, aSelector)
  5931. { with(self)
  5932. {
  5933. self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPObject") }, "init");
  5934. if (self)
  5935. {
  5936. _key = aKey;
  5937. _ascending = isAscending;
  5938. _selector = aSelector;
  5939. }
  5940. return self;
  5941. }
  5942. }), new objj_method(sel_getUid("ascending"), function $CPSortDescriptor__ascending(self, _cmd)
  5943. { with(self)
  5944. {
  5945. return _ascending;
  5946. }
  5947. }), new objj_method(sel_getUid("key"), function $CPSortDescriptor__key(self, _cmd)
  5948. { with(self)
  5949. {
  5950. return _key;
  5951. }
  5952. }), new objj_method(sel_getUid("selector"), function $CPSortDescriptor__selector(self, _cmd)
  5953. { with(self)
  5954. {
  5955. return _selector;
  5956. }
  5957. }), new objj_method(sel_getUid("compareObject:withObject:"), function $CPSortDescriptor__compareObject_withObject_(self, _cmd, lhsObject, rhsObject)
  5958. { with(self)
  5959. {
  5960. return (_ascending ? 1 : -1) * objj_msgSend(objj_msgSend(lhsObject, "valueForKey:", _key), "performSelector:withObject:", _selector, objj_msgSend(rhsObject, "valueForKey:", _key));
  5961. }
  5962. }), new objj_method(sel_getUid("reversedSortDescriptor"), function $CPSortDescriptor__reversedSortDescriptor(self, _cmd)
  5963. { with(self)
  5964. {
  5965. return objj_msgSend(objj_msgSend(objj_msgSend(self, "class"), "alloc"), "initWithKey:ascending:selector:", _key, !_ascending, _selector);
  5966. }
  5967. })]);
  5968. }
  5969. p;10;CPString.ji;10;CPObject.ji;13;CPException.ji;18;CPSortDescriptor.ji;9;CPValue.jc;12759;
  5970. CPCaseInsensitiveSearch = 1;
  5971. CPLiteralSearch = 2;
  5972. CPBackwardsSearch = 4;
  5973. CPAnchoredSearch = 8;
  5974. CPNumericSearch = 64;
  5975. var CPStringHashes = new objj_dictionary();
  5976. {var the_class = objj_allocateClassPair(CPObject, "CPString"),
  5977. meta_class = the_class.isa;objj_registerClassPair(the_class);
  5978. objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
  5979. class_addMethods(the_class, [new objj_method(sel_getUid("initWithString:"), function $CPString__initWithString_(self, _cmd, aString)
  5980. { with(self)
  5981. {
  5982. return String(aString);
  5983. }
  5984. }), new objj_method(sel_getUid("initWithFormat:"), function $CPString__initWithFormat_(self, _cmd, format)
  5985. { with(self)
  5986. {
  5987. if (!format)
  5988. objj_msgSend(CPException, "raise:reason:", CPInvalidArgumentException, "initWithFormat: the format can't be 'nil'");
  5989. self = sprintf.apply(this, Array.prototype.slice.call(arguments, 2));
  5990. return self;
  5991. }
  5992. }), new objj_method(sel_getUid("description"), function $CPString__description(self, _cmd)
  5993. { with(self)
  5994. {
  5995. return self;
  5996. }
  5997. }), new objj_method(sel_getUid("length"), function $CPString__length(self, _cmd)
  5998. { with(self)
  5999. {
  6000. return length;
  6001. }
  6002. }), new objj_method(sel_getUid("characterAtIndex:"), function $CPString__characterAtIndex_(self, _cmd, anIndex)
  6003. { with(self)
  6004. {
  6005. return charAt(anIndex);
  6006. }
  6007. }), new objj_method(sel_getUid("stringByAppendingFormat:"), function $CPString__stringByAppendingFormat_(self, _cmd, format)
  6008. { with(self)
  6009. {
  6010. if (!format)
  6011. objj_msgSend(CPException, "raise:reason:", CPInvalidArgumentException, "initWithFormat: the format can't be 'nil'");
  6012. return self + sprintf.apply(this, Array.prototype.slice.call(arguments, 2));
  6013. }
  6014. }), new objj_method(sel_getUid("stringByAppendingString:"), function $CPString__stringByAppendingString_(self, _cmd, aString)
  6015. { with(self)
  6016. {
  6017. return self + aString;
  6018. }
  6019. }), new objj_method(sel_getUid("stringByPaddingToLength:withString:startingAtIndex:"), function $CPString__stringByPaddingToLength_withString_startingAtIndex_(self, _cmd, aLength, aString, anIndex)
  6020. { with(self)
  6021. {
  6022. if (length == aLength)
  6023. return self;
  6024. if (aLength < length)
  6025. return substr(0, aLength);
  6026. var string = self,
  6027. substring = aString.substring(anIndex),
  6028. difference = aLength - length;
  6029. while ((difference -= substring.length) >= 0)
  6030. string += substring;
  6031. if (-difference < substring.length)
  6032. string += substring.substring(0, -difference);
  6033. return string;
  6034. }
  6035. }), new objj_method(sel_getUid("componentsSeparatedByString:"), function $CPString__componentsSeparatedByString_(self, _cmd, aString)
  6036. { with(self)
  6037. {
  6038. return split(aString);
  6039. }
  6040. }), new objj_method(sel_getUid("substringFromIndex:"), function $CPString__substringFromIndex_(self, _cmd, anIndex)
  6041. { with(self)
  6042. {
  6043. return substr(anIndex);
  6044. }
  6045. }), new objj_method(sel_getUid("substringWithRange:"), function $CPString__substringWithRange_(self, _cmd, aRange)
  6046. { with(self)
  6047. {
  6048. return substr(aRange.location, aRange.length);
  6049. }
  6050. }), new objj_method(sel_getUid("substringToIndex:"), function $CPString__substringToIndex_(self, _cmd, anIndex)
  6051. { with(self)
  6052. {
  6053. return substring(0, anIndex);
  6054. }
  6055. }), new objj_method(sel_getUid("rangeOfString:"), function $CPString__rangeOfString_(self, _cmd, aString)
  6056. { with(self)
  6057. {
  6058. return objj_msgSend(self, "rangeOfString:options:", aString, 0);
  6059. }
  6060. }), new objj_method(sel_getUid("rangeOfString:options:"), function $CPString__rangeOfString_options_(self, _cmd, aString, aMask)
  6061. { with(self)
  6062. {
  6063. return objj_msgSend(self, "rangeOfString:options:range:", aString, aMask, nil);
  6064. }
  6065. }), new objj_method(sel_getUid("rangeOfString:options:range:"), function $CPString__rangeOfString_options_range_(self, _cmd, aString, aMask, aRange)
  6066. { with(self)
  6067. {
  6068. var string = (aRange == nil) ? self : objj_msgSend(self, "substringWithRange:", aRange),
  6069. location = CPNotFound;
  6070. if (aMask & CPCaseInsensitiveSearch)
  6071. {
  6072. string = string.toLowerCase();
  6073. aString = aString.toLowerCase();
  6074. }
  6075. if (aMask & CPBackwardsSearch)
  6076. location = string.lastIndexOf(aString, aMask & CPAnchoredSearch ? length - aString.length : 0);
  6077. else if (aMask & CPAnchoredSearch)
  6078. location = string.substr(0, aString.length).indexOf(aString) != CPNotFound ? 0 : CPNotFound;
  6079. else
  6080. location = string.indexOf(aString);
  6081. return CPMakeRange(location, location == CPNotFound ? 0 : aString.length);
  6082. }
  6083. }), new objj_method(sel_getUid("stringByReplacingOccurrencesOfString:withString:"), function $CPString__stringByReplacingOccurrencesOfString_withString_(self, _cmd, target, replacement)
  6084. { with(self)
  6085. {
  6086. return self.replace(new RegExp(target, "g"), replacement);
  6087. }
  6088. }), new objj_method(sel_getUid("stringByReplacingOccurrencesOfString:withString:options:range:"), function $CPString__stringByReplacingOccurrencesOfString_withString_options_range_(self, _cmd, target, replacement, options, searchRange)
  6089. { with(self)
  6090. {
  6091. var start = substring(0, searchRange.location),
  6092. stringSegmentToSearch = substr(searchRange.location, searchRange.length),
  6093. end = substring(searchRange.location + searchRange.length, self.length),
  6094. regExp;
  6095. if (options & CPCaseInsensitiveSearch)
  6096. regExp = new RegExp(target, "gi");
  6097. else
  6098. regExp = new RegExp(target, "g");
  6099. return start + '' + stringSegmentToSearch.replace(regExp, replacement) + '' + end;
  6100. }
  6101. }), new objj_method(sel_getUid("stringByReplacingCharactersInRange:withString:"), function $CPString__stringByReplacingCharactersInRange_withString_(self, _cmd, range, replacement)
  6102. { with(self)
  6103. {
  6104. return '' + substring(0, range.location) + replacement + substring(range.location + range.length, self.length);
  6105. }
  6106. }), new objj_method(sel_getUid("compare:"), function $CPString__compare_(self, _cmd, aString)
  6107. { with(self)
  6108. {
  6109. return objj_msgSend(self, "compare:options:", aString, nil);
  6110. }
  6111. }), new objj_method(sel_getUid("caseInsensitiveCompare:"), function $CPString__caseInsensitiveCompare_(self, _cmd, aString)
  6112. { with(self)
  6113. {
  6114. return objj_msgSend(self, "compare:options:", aString, CPCaseInsensitiveSearch);
  6115. }
  6116. }), new objj_method(sel_getUid("compare:options:"), function $CPString__compare_options_(self, _cmd, aString, aMask)
  6117. { with(self)
  6118. {
  6119. var lhs = self,
  6120. rhs = aString;
  6121. if (aMask & CPCaseInsensitiveSearch)
  6122. {
  6123. lhs = lhs.toLowerCase();
  6124. rhs = rhs.toLowerCase();
  6125. }
  6126. if (lhs < rhs)
  6127. return CPOrderedAscending;
  6128. else if (lhs > rhs)
  6129. return CPOrderedDescending;
  6130. return CPOrderedSame;
  6131. }
  6132. }), new objj_method(sel_getUid("compare:options:range:"), function $CPString__compare_options_range_(self, _cmd, aString, aMask, range)
  6133. { with(self)
  6134. {
  6135. var lhs = objj_msgSend(self, "substringWithRange:", range),
  6136. rhs = aString;
  6137. return objj_msgSend(lhs, "compare:options:", rhs, aMask);
  6138. }
  6139. }), new objj_method(sel_getUid("hasPrefix:"), function $CPString__hasPrefix_(self, _cmd, aString)
  6140. { with(self)
  6141. {
  6142. return aString && aString != "" && indexOf(aString) == 0;
  6143. }
  6144. }), new objj_method(sel_getUid("hasSuffix:"), function $CPString__hasSuffix_(self, _cmd, aString)
  6145. { with(self)
  6146. {
  6147. return aString && aString != "" && lastIndexOf(aString) == (length - aString.length);
  6148. }
  6149. }), new objj_method(sel_getUid("isEqualToString:"), function $CPString__isEqualToString_(self, _cmd, aString)
  6150. { with(self)
  6151. {
  6152. return self == aString;
  6153. }
  6154. }), new objj_method(sel_getUid("hash"), function $CPString__hash(self, _cmd)
  6155. { with(self)
  6156. {
  6157. var hash = dictionary_getValue(CPStringHashes, self);
  6158. if (!hash)
  6159. {
  6160. hash = _objj_generateObjectHash();
  6161. dictionary_setValue(CPStringHashes, self, hash);
  6162. }
  6163. return hash;
  6164. }
  6165. }), new objj_method(sel_getUid("capitalizedString"), function $CPString__capitalizedString(self, _cmd)
  6166. { with(self)
  6167. {
  6168. var parts = self.split(/\b/g);
  6169. for (var i = 0; i < parts.length; i++)
  6170. {
  6171. if (i == 0 || (/\s$/).test(parts[i-1]))
  6172. parts[i] = parts[i].substring(0, 1).toUpperCase() + parts[i].substring(1).toLowerCase();
  6173. else
  6174. parts[i] = parts[i].toLowerCase();
  6175. }
  6176. return parts.join("");
  6177. }
  6178. }), new objj_method(sel_getUid("lowercaseString"), function $CPString__lowercaseString(self, _cmd)
  6179. { with(self)
  6180. {
  6181. return toLowerCase();
  6182. }
  6183. }), new objj_method(sel_getUid("uppercaseString"), function $CPString__uppercaseString(self, _cmd)
  6184. { with(self)
  6185. {
  6186. return toUpperCase();
  6187. }
  6188. }), new objj_method(sel_getUid("doubleValue"), function $CPString__doubleValue(self, _cmd)
  6189. { with(self)
  6190. {
  6191. return parseFloat(self, 10);
  6192. }
  6193. }), new objj_method(sel_getUid("boolValue"), function $CPString__boolValue(self, _cmd)
  6194. { with(self)
  6195. {
  6196. var replaceRegExp = new RegExp("^\\s*[\\+,\\-]*0*");
  6197. return RegExp("^[Y,y,t,T,1-9]").test(self.replace(replaceRegExp, ''));
  6198. }
  6199. }), new objj_method(sel_getUid("floatValue"), function $CPString__floatValue(self, _cmd)
  6200. { with(self)
  6201. {
  6202. return parseFloat(self, 10);
  6203. }
  6204. }), new objj_method(sel_getUid("intValue"), function $CPString__intValue(self, _cmd)
  6205. { with(self)
  6206. {
  6207. return parseInt(self, 10);
  6208. }
  6209. }), new objj_method(sel_getUid("pathComponents"), function $CPString__pathComponents(self, _cmd)
  6210. { with(self)
  6211. {
  6212. var result = split('/');
  6213. if (result[0] === "")
  6214. result[0] = "/";
  6215. if (result[result.length - 1] === "")
  6216. result.pop();
  6217. return result;
  6218. }
  6219. }), new objj_method(sel_getUid("pathExtension"), function $CPString__pathExtension(self, _cmd)
  6220. { with(self)
  6221. {
  6222. return substr(lastIndexOf('.') + 1);
  6223. }
  6224. }), new objj_method(sel_getUid("lastPathComponent"), function $CPString__lastPathComponent(self, _cmd)
  6225. { with(self)
  6226. {
  6227. var components = objj_msgSend(self, "pathComponents");
  6228. return components[components.length -1];
  6229. }
  6230. }), new objj_method(sel_getUid("stringByDeletingLastPathComponent"), function $CPString__stringByDeletingLastPathComponent(self, _cmd)
  6231. { with(self)
  6232. {
  6233. var path = self,
  6234. start = length - 1;
  6235. while (path.charAt(start) === '/')
  6236. start--;
  6237. path = path.substr(0, path.lastIndexOf('/', start));
  6238. if (path === "" && charAt(0) === '/')
  6239. return '/';
  6240. return path;
  6241. }
  6242. }), new objj_method(sel_getUid("stringByStandardizingPath"), function $CPString__stringByStandardizingPath(self, _cmd)
  6243. { with(self)
  6244. {
  6245. return objj_standardize_path(self);
  6246. }
  6247. }), new objj_method(sel_getUid("copy"), function $CPString__copy(self, _cmd)
  6248. { with(self)
  6249. {
  6250. return new String(self);
  6251. }
  6252. })]);
  6253. class_addMethods(meta_class, [new objj_method(sel_getUid("alloc"), function $CPString__alloc(self, _cmd)
  6254. { with(self)
  6255. {
  6256. return new String;
  6257. }
  6258. }), new objj_method(sel_getUid("string"), function $CPString__string(self, _cmd)
  6259. { with(self)
  6260. {
  6261. return objj_msgSend(objj_msgSend(self, "alloc"), "init");
  6262. }
  6263. }), new objj_method(sel_getUid("stringWithHash:"), function $CPString__stringWithHash_(self, _cmd, aHash)
  6264. { with(self)
  6265. {
  6266. var hashString = parseInt(aHash, 10).toString(16);
  6267. return "000000".substring(0, MAX(6-hashString.length, 0)) + hashString;
  6268. }
  6269. }), new objj_method(sel_getUid("stringWithString:"), function $CPString__stringWithString_(self, _cmd, aString)
  6270. { with(self)
  6271. {
  6272. if (!aString)
  6273. objj_msgSend(CPException, "raise:reason:", CPInvalidArgumentException, "stringWithString: the string can't be 'nil'");
  6274. return objj_msgSend(objj_msgSend(self, "alloc"), "initWithString:", aString);
  6275. }
  6276. }), new objj_method(sel_getUid("stringWithFormat:"), function $CPString__stringWithFormat_(self, _cmd, format)
  6277. { with(self)
  6278. {
  6279. if (!format)
  6280. objj_msgSend(CPException, "raise:reason:", CPInvalidArgumentException, "initWithFormat: the format can't be 'nil'");
  6281. return sprintf.apply(this, Array.prototype.slice.call(arguments, 2));
  6282. }
  6283. })]);
  6284. }
  6285. {
  6286. var the_class = objj_getClass("CPString")
  6287. if(!the_class) objj_exception_throw(new objj_exception(OBJJClassNotFoundException, "*** Could not find definition for class \"CPString\""));
  6288. var meta_class = the_class.isa;class_addMethods(the_class, [new objj_method(sel_getUid("objectFromJSON"), function $CPString__objectFromJSON(self, _cmd)
  6289. { with(self)
  6290. {
  6291. return CPJSObjectCreateWithJSON(self);
  6292. }
  6293. })]);
  6294. class_addMethods(meta_class, [new objj_method(sel_getUid("JSONFromObject:"), function $CPString__JSONFromObject_(self, _cmd, anObject)
  6295. { with(self)
  6296. {
  6297. return CPJSObjectCreateJSON(anObject);
  6298. }
  6299. })]);
  6300. }
  6301. {
  6302. var the_class = objj_getClass("CPString")
  6303. if(!the_class) objj_exception_throw(new objj_exception(OBJJClassNotFoundException, "*** Could not find definition for class \"CPString\""));
  6304. var meta_class = the_class.isa;class_addMethods(meta_class, [new objj_method(sel_getUid("UUID"), function $CPString__UUID(self, _cmd)
  6305. { with(self)
  6306. {
  6307. var g = "";
  6308. for(var i = 0; i < 32; i++)
  6309. g += FLOOR(RAND() * 0xF).toString(0xF);
  6310. return g;
  6311. }
  6312. })]);
  6313. }
  6314. String.prototype.isa = CPString;
  6315. p;9;CPTimer.ji;10;CPObject.ji;14;CPInvocation.ji;8;CPDate.ji;11;CPRunLoop.jc;7723;
  6316. {var the_class = objj_allocateClassPair(CPObject, "CPTimer"),
  6317. meta_class = the_class.isa;class_addIvars(the_class, [new objj_ivar("_timeInterval"), new objj_ivar("_invocation"), new objj_ivar("_callback"), new objj_ivar("_repeats"), new objj_ivar("_isValid"), new objj_ivar("_fireDate"), new objj_ivar("_userInfo")]);
  6318. objj_registerClassPair(the_class);
  6319. objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
  6320. class_addMethods(the_class, [new objj_method(sel_getUid("initWithFireDate:interval:invocation:repeats:"), function $CPTimer__initWithFireDate_interval_invocation_repeats_(self, _cmd, aDate, seconds, anInvocation, shouldRepeat)
  6321. { with(self)
  6322. {
  6323. self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPObject") }, "init");
  6324. if (self)
  6325. {
  6326. _timeInterval = seconds;
  6327. _invocation = anInvocation;
  6328. _repeats = shouldRepeat;
  6329. _isValid = YES;
  6330. _fireDate = aDate;
  6331. }
  6332. return self;
  6333. }
  6334. }), new objj_method(sel_getUid("initWithFireDate:interval:target:selector:userInfo:repeats:"), function $CPTimer__initWithFireDate_interval_target_selector_userInfo_repeats_(self, _cmd, aDate, seconds, aTarget, aSelector, userInfo, shouldRepeat)
  6335. { with(self)
  6336. {
  6337. var invocation = objj_msgSend(CPInvocation, "invocationWithMethodSignature:", 1);
  6338. objj_msgSend(invocation, "setTarget:", aTarget);
  6339. objj_msgSend(invocation, "setSelector:", aSelector);
  6340. objj_msgSend(invocation, "setArgument:atIndex:", self, 2);
  6341. self = objj_msgSend(self, "initWithFireDate:interval:invocation:repeats:", aDate, seconds, invocation, shouldRepeat);
  6342. if (self)
  6343. _userInfo = userInfo;
  6344. return self;
  6345. }
  6346. }), new objj_method(sel_getUid("initWithFireDate:interval:callback:repeats:"), function $CPTimer__initWithFireDate_interval_callback_repeats_(self, _cmd, aDate, seconds, aFunction, shouldRepeat)
  6347. { with(self)
  6348. {
  6349. self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPObject") }, "init");
  6350. if (self)
  6351. {
  6352. _timeInterval = seconds;
  6353. _callback = aFunction;
  6354. _repeats = shouldRepeat;
  6355. _isValid = YES;
  6356. _fireDate = aDate;
  6357. }
  6358. return self;
  6359. }
  6360. }), new objj_method(sel_getUid("timeInterval"), function $CPTimer__timeInterval(self, _cmd)
  6361. { with(self)
  6362. {
  6363. return _timeInterval;
  6364. }
  6365. }), new objj_method(sel_getUid("fireDate"), function $CPTimer__fireDate(self, _cmd)
  6366. { with(self)
  6367. {
  6368. return _fireDate;
  6369. }
  6370. }), new objj_method(sel_getUid("setFireDate:"), function $CPTimer__setFireDate_(self, _cmd, aDate)
  6371. { with(self)
  6372. {
  6373. _fireDate = aDate;
  6374. }
  6375. }), new objj_method(sel_getUid("fire"), function $CPTimer__fire(self, _cmd)
  6376. { with(self)
  6377. {
  6378. if (!_isValid)
  6379. return;
  6380. if (_callback)
  6381. _callback();
  6382. else
  6383. objj_msgSend(_invocation, "invoke");
  6384. if (!_isValid)
  6385. return;
  6386. if (_repeats)
  6387. _fireDate = objj_msgSend(CPDate, "dateWithTimeIntervalSinceNow:", _timeInterval);
  6388. else
  6389. objj_msgSend(self, "invalidate");
  6390. }
  6391. }), new objj_method(sel_getUid("isValid"), function $CPTimer__isValid(self, _cmd)
  6392. { with(self)
  6393. {
  6394. return _isValid;
  6395. }
  6396. }), new objj_method(sel_getUid("invalidate"), function $CPTimer__invalidate(self, _cmd)
  6397. { with(self)
  6398. {
  6399. _isValid = NO;
  6400. _userInfo = nil;
  6401. _invocation = nil;
  6402. _callback = nil;
  6403. }
  6404. }), new objj_method(sel_getUid("userInfo"), function $CPTimer__userInfo(self, _cmd)
  6405. { with(self)
  6406. {
  6407. return _userInfo;
  6408. }
  6409. })]);
  6410. class_addMethods(meta_class, [new objj_method(sel_getUid("scheduledTimerWithTimeInterval:invocation:repeats:"), function $CPTimer__scheduledTimerWithTimeInterval_invocation_repeats_(self, _cmd, seconds, anInvocation, shouldRepeat)
  6411. { with(self)
  6412. {
  6413. var timer = objj_msgSend(objj_msgSend(self, "alloc"), "initWithFireDate:interval:invocation:repeats:", objj_msgSend(CPDate, "dateWithTimeIntervalSinceNow:", seconds), seconds, anInvocation, shouldRepeat);
  6414. objj_msgSend(objj_msgSend(CPRunLoop, "currentRunLoop"), "addTimer:forMode:", timer, CPDefaultRunLoopMode);
  6415. return timer;
  6416. }
  6417. }), new objj_method(sel_getUid("scheduledTimerWithTimeInterval:target:selector:userInfo:repeats:"), function $CPTimer__scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_(self, _cmd, seconds, aTarget, aSelector, userInfo, shouldRepeat)
  6418. { with(self)
  6419. {
  6420. var timer = objj_msgSend(objj_msgSend(self, "alloc"), "initWithFireDate:interval:target:selector:userInfo:repeats:", objj_msgSend(CPDate, "dateWithTimeIntervalSinceNow:", seconds), seconds, aTarget, aSelector, userInfo, shouldRepeat)
  6421. objj_msgSend(objj_msgSend(CPRunLoop, "currentRunLoop"), "addTimer:forMode:", timer, CPDefaultRunLoopMode);
  6422. return timer;
  6423. }
  6424. }), new objj_method(sel_getUid("scheduledTimerWithTimeInterval:callback:repeats:"), function $CPTimer__scheduledTimerWithTimeInterval_callback_repeats_(self, _cmd, seconds, aFunction, shouldRepeat)
  6425. { with(self)
  6426. {
  6427. var timer = objj_msgSend(objj_msgSend(self, "alloc"), "initWithFireDate:interval:callback:repeats:", objj_msgSend(CPDate, "dateWithTimeIntervalSinceNow:", seconds), seconds, aFunction, shouldRepeat);
  6428. objj_msgSend(objj_msgSend(CPRunLoop, "currentRunLoop"), "addTimer:forMode:", timer, CPDefaultRunLoopMode);
  6429. return timer;
  6430. }
  6431. }), new objj_method(sel_getUid("timerWithTimeInterval:invocation:repeats:"), function $CPTimer__timerWithTimeInterval_invocation_repeats_(self, _cmd, seconds, anInvocation, shouldRepeat)
  6432. { with(self)
  6433. {
  6434. return objj_msgSend(objj_msgSend(self, "alloc"), "initWithFireDate:interval:invocation:repeats:", nil, seconds, anInvocation, shouldRepeat);
  6435. }
  6436. }), new objj_method(sel_getUid("timerWithTimeInterval:target:selector:userInfo:repeats:"), function $CPTimer__timerWithTimeInterval_target_selector_userInfo_repeats_(self, _cmd, seconds, aTarget, aSelector, userInfo, shouldRepeat)
  6437. { with(self)
  6438. {
  6439. return objj_msgSend(objj_msgSend(self, "alloc"), "initWithFireDate:interval:target:selector:userInfo:repeats:", nil, seconds, aTarget, aSelector, userInfo, shouldRepeat);
  6440. }
  6441. }), new objj_method(sel_getUid("timerWithTimeInterval:callback:repeats:"), function $CPTimer__timerWithTimeInterval_callback_repeats_(self, _cmd, seconds, aFunction, shouldRepeat)
  6442. { with(self)
  6443. {
  6444. return objj_msgSend(objj_msgSend(self, "alloc"), "initWithFireDate:interval:callback:repeats:", nil, seconds, aFunction, shouldRepeat);
  6445. }
  6446. })]);
  6447. }
  6448. var CPTimersTimeoutID = 1000,
  6449. CPTimersForTimeoutIDs = {};
  6450. var _CPTimerBridgeTimer = function(codeOrFunction, aDelay, shouldRepeat, functionArgs)
  6451. {
  6452. var timeoutID = CPTimersTimeoutID++,
  6453. theFunction = nil;
  6454. if (typeof codeOrFunction === "string")
  6455. theFunction = function() { new Function(codeOrFunction)(); if (!shouldRepeat) CPTimersForTimeoutIDs[timeoutID] = nil; }
  6456. else
  6457. {
  6458. if (!functionArgs)
  6459. functionArgs = [];
  6460. theFunction = function() { codeOrFunction.apply(window, functionArgs); if (!shouldRepeat) CPTimersForTimeoutIDs[timeoutID] = nil; }
  6461. }
  6462. CPTimersForTimeoutIDs[timeoutID] = objj_msgSend(CPTimer, "scheduledTimerWithTimeInterval:callback:repeats:", aDelay / 1000, theFunction, shouldRepeat);
  6463. return timeoutID;
  6464. }
  6465. window.setTimeout = function(codeOrFunction, aDelay)
  6466. {
  6467. return _CPTimerBridgeTimer(codeOrFunction, aDelay, NO, Array.prototype.slice.apply(arguments, [2]));
  6468. }
  6469. window.clearTimeout = function(aTimeoutID)
  6470. {
  6471. var timer = CPTimersForTimeoutIDs[aTimeoutID];
  6472. if (timer)
  6473. objj_msgSend(timer, "invalidate");
  6474. CPTimersForTimeoutIDs[aTimeoutID] = nil;
  6475. }
  6476. window.setInterval = function(codeOrFunction, aDelay, functionArgs)
  6477. {
  6478. return _CPTimerBridgeTimer(codeOrFunction, aDelay, YES, Array.prototype.slice.apply(arguments, [2]));
  6479. }
  6480. window.clearInterval = function(aTimeoutID)
  6481. {
  6482. window.clearTimeout(aTimeoutID);
  6483. }
  6484. p;15;CPUndoManager.ji;10;CPObject.ji;14;CPInvocation.jc;18634;
  6485. var CPUndoManagerNormal = 0,
  6486. CPUndoManagerUndoing = 1,
  6487. CPUndoManagerRedoing = 2;
  6488. CPUndoManagerCheckpointNotification = "CPUndoManagerCheckpointNotification";
  6489. CPUndoManagerDidOpenUndoGroupNotification = "CPUndoManagerDidOpenUndoGroupNotification";
  6490. CPUndoManagerDidRedoChangeNotification = "CPUndoManagerDidRedoChangeNotification";
  6491. CPUndoManagerDidUndoChangeNotification = "CPUndoManagerDidUndoChangeNotification";
  6492. CPUndoManagerWillCloseUndoGroupNotification = "CPUndoManagerWillCloseUndoGroupNotification";
  6493. CPUndoManagerWillRedoChangeNotification = "CPUndoManagerWillRedoChangeNotification";
  6494. CPUndoManagerWillUndoChangeNotification = "CPUndoManagerWillUndoChangeNotification";
  6495. CPUndoCloseGroupingRunLoopOrdering = 350000;
  6496. var _CPUndoGroupingPool = [],
  6497. _CPUndoGroupingPoolCapacity = 5;
  6498. {var the_class = objj_allocateClassPair(CPObject, "_CPUndoGrouping"),
  6499. meta_class = the_class.isa;class_addIvars(the_class, [new objj_ivar("_parent"), new objj_ivar("_invocations")]);
  6500. objj_registerClassPair(the_class);
  6501. objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
  6502. class_addMethods(the_class, [new objj_method(sel_getUid("initWithParent:"), function $_CPUndoGrouping__initWithParent_(self, _cmd, anUndoGrouping)
  6503. { with(self)
  6504. {
  6505. self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPObject") }, "init");
  6506. if (self)
  6507. {
  6508. _parent = anUndoGrouping;
  6509. _invocations = [];
  6510. }
  6511. return self;
  6512. }
  6513. }), new objj_method(sel_getUid("parent"), function $_CPUndoGrouping__parent(self, _cmd)
  6514. { with(self)
  6515. {
  6516. return _parent;
  6517. }
  6518. }), new objj_method(sel_getUid("addInvocation:"), function $_CPUndoGrouping__addInvocation_(self, _cmd, anInvocation)
  6519. { with(self)
  6520. {
  6521. _invocations.push(anInvocation);
  6522. }
  6523. }), new objj_method(sel_getUid("addInvocationsFromArray:"), function $_CPUndoGrouping__addInvocationsFromArray_(self, _cmd, invocations)
  6524. { with(self)
  6525. {
  6526. objj_msgSend(_invocations, "addObjectsFromArray:", invocations);
  6527. }
  6528. }), new objj_method(sel_getUid("removeInvocationsWithTarget:"), function $_CPUndoGrouping__removeInvocationsWithTarget_(self, _cmd, aTarget)
  6529. { with(self)
  6530. {
  6531. var index = _invocations.length;
  6532. while (index--)
  6533. if (objj_msgSend(_invocations[index], "target") == aTarget)
  6534. _invocations.splice(index, 1);
  6535. }
  6536. }), new objj_method(sel_getUid("invocations"), function $_CPUndoGrouping__invocations(self, _cmd)
  6537. { with(self)
  6538. {
  6539. return _invocations;
  6540. }
  6541. }), new objj_method(sel_getUid("invoke"), function $_CPUndoGrouping__invoke(self, _cmd)
  6542. { with(self)
  6543. {
  6544. var index = _invocations.length;
  6545. while (index--)
  6546. objj_msgSend(_invocations[index], "invoke");
  6547. }
  6548. })]);
  6549. class_addMethods(meta_class, [new objj_method(sel_getUid("_poolUndoGrouping:"), function $_CPUndoGrouping___poolUndoGrouping_(self, _cmd, anUndoGrouping)
  6550. { with(self)
  6551. {
  6552. if (!anUndoGrouping || _CPUndoGroupingPool.length >= _CPUndoGroupingPoolCapacity)
  6553. return;
  6554. _CPUndoGroupingPool.push(anUndoGrouping);
  6555. }
  6556. }), new objj_method(sel_getUid("undoGroupingWithParent:"), function $_CPUndoGrouping__undoGroupingWithParent_(self, _cmd, anUndoGrouping)
  6557. { with(self)
  6558. {
  6559. if (_CPUndoGroupingPool.length)
  6560. {
  6561. var grouping = _CPUndoGroupingPool.pop();
  6562. grouping._parent = anUndoGrouping;
  6563. if (grouping._invocations.length)
  6564. grouping._invocations = [];
  6565. return grouping;
  6566. }
  6567. return objj_msgSend(objj_msgSend(self, "alloc"), "initWithParent:", anUndoGrouping);
  6568. }
  6569. })]);
  6570. }
  6571. var _CPUndoGroupingParentKey = "_CPUndoGroupingParentKey",
  6572. _CPUndoGroupingInvocationsKey = "_CPUndoGroupingInvocationsKey";
  6573. {
  6574. var the_class = objj_getClass("_CPUndoGrouping")
  6575. if(!the_class) objj_exception_throw(new objj_exception(OBJJClassNotFoundException, "*** Could not find definition for class \"_CPUndoGrouping\""));
  6576. var meta_class = the_class.isa;class_addMethods(the_class, [new objj_method(sel_getUid("initWithCoder:"), function $_CPUndoGrouping__initWithCoder_(self, _cmd, aCoder)
  6577. { with(self)
  6578. {
  6579. self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPObject") }, "init");
  6580. if (self)
  6581. {
  6582. _parent = objj_msgSend(aCoder, "decodeObjectForKey:", _CPUndoGroupingParentKey);
  6583. _invocations = objj_msgSend(aCoder, "decodeObjectForKey:", _CPUndoGroupingInvocationsKey);
  6584. }
  6585. return self;
  6586. }
  6587. }), new objj_method(sel_getUid("encodeWithCoder:"), function $_CPUndoGrouping__encodeWithCoder_(self, _cmd, aCoder)
  6588. { with(self)
  6589. {
  6590. objj_msgSend(aCoder, "encodeObject:forKey:", _parent, _CPUndoGroupingParentKey);
  6591. objj_msgSend(aCoder, "encodeObject:forKey:", _invocations, _CPUndoGroupingInvocationsKey);
  6592. }
  6593. })]);
  6594. }
  6595. {var the_class = objj_allocateClassPair(CPObject, "CPUndoManager"),
  6596. meta_class = the_class.isa;class_addIvars(the_class, [new objj_ivar("_redoStack"), new objj_ivar("_undoStack"), new objj_ivar("_groupsByEvent"), new objj_ivar("_disableCount"), new objj_ivar("_levelsOfUndo"), new objj_ivar("_currentGrouping"), new objj_ivar("_state"), new objj_ivar("_actionName"), new objj_ivar("_preparedTarget"), new objj_ivar("_runLoopModes"), new objj_ivar("_registeredWithRunLoop")]);
  6597. objj_registerClassPair(the_class);
  6598. objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
  6599. class_addMethods(the_class, [new objj_method(sel_getUid("init"), function $CPUndoManager__init(self, _cmd)
  6600. { with(self)
  6601. {
  6602. self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPObject") }, "init");
  6603. if (self)
  6604. {
  6605. _redoStack = [];
  6606. _undoStack = [];
  6607. _state = CPUndoManagerNormal;
  6608. objj_msgSend(self, "setRunLoopModes:", [CPDefaultRunLoopMode]);
  6609. objj_msgSend(self, "setGroupsByEvent:", YES);
  6610. _performRegistered = NO;
  6611. }
  6612. return self;
  6613. }
  6614. }), new objj_method(sel_getUid("registerUndoWithTarget:selector:object:"), function $CPUndoManager__registerUndoWithTarget_selector_object_(self, _cmd, aTarget, aSelector, anObject)
  6615. { with(self)
  6616. {
  6617. if (!_currentGrouping)
  6618. objj_msgSend(CPException, "raise:reason:", CPInternalInconsistencyException, "No undo group is currently open");
  6619. if (_disableCount > 0)
  6620. return;
  6621. var invocation = objj_msgSend(CPInvocation, "invocationWithMethodSignature:", nil);
  6622. objj_msgSend(invocation, "setTarget:", aTarget);
  6623. objj_msgSend(invocation, "setSelector:", aSelector);
  6624. objj_msgSend(invocation, "setArgument:atIndex:", anObject, 2);
  6625. objj_msgSend(_currentGrouping, "addInvocation:", invocation);
  6626. if (_state == CPUndoManagerNormal)
  6627. objj_msgSend(_redoStack, "removeAllObjects");
  6628. }
  6629. }), new objj_method(sel_getUid("prepareWithInvocationTarget:"), function $CPUndoManager__prepareWithInvocationTarget_(self, _cmd, aTarget)
  6630. { with(self)
  6631. {
  6632. _preparedTarget = aTarget;
  6633. return self;
  6634. }
  6635. }), new objj_method(sel_getUid("methodSignatureForSelector:"), function $CPUndoManager__methodSignatureForSelector_(self, _cmd, aSelector)
  6636. { with(self)
  6637. {
  6638. if (objj_msgSend(_preparedTarget, "respondsToSelector:", aSelector))
  6639. return 1;
  6640. return nil;
  6641. }
  6642. }), new objj_method(sel_getUid("forwardInvocation:"), function $CPUndoManager__forwardInvocation_(self, _cmd, anInvocation)
  6643. { with(self)
  6644. {
  6645. if (_disableCount > 0)
  6646. return;
  6647. objj_msgSend(anInvocation, "setTarget:", _preparedTarget);
  6648. objj_msgSend(_currentGrouping, "addInvocation:", anInvocation);
  6649. if (_state == CPUndoManagerNormal)
  6650. objj_msgSend(_redoStack, "removeAllObjects");
  6651. _preparedTarget = nil;
  6652. }
  6653. }), new objj_method(sel_getUid("canRedo"), function $CPUndoManager__canRedo(self, _cmd)
  6654. { with(self)
  6655. {
  6656. return _redoStack.length > 0;
  6657. }
  6658. }), new objj_method(sel_getUid("canUndo"), function $CPUndoManager__canUndo(self, _cmd)
  6659. { with(self)
  6660. {
  6661. if (_undoStack.length > 0)
  6662. return YES;
  6663. return objj_msgSend(_currentGrouping, "actions").length > 0;
  6664. }
  6665. }), new objj_method(sel_getUid("undo"), function $CPUndoManager__undo(self, _cmd)
  6666. { with(self)
  6667. {
  6668. if (objj_msgSend(self, "groupingLevel") == 1)
  6669. objj_msgSend(self, "endUndoGrouping");
  6670. objj_msgSend(self, "undoNestedGroup");
  6671. }
  6672. }), new objj_method(sel_getUid("undoNestedGroup"), function $CPUndoManager__undoNestedGroup(self, _cmd)
  6673. { with(self)
  6674. {
  6675. if (_undoStack.length == 0)
  6676. return;
  6677. var defaultCenter = objj_msgSend(CPNotificationCenter, "defaultCenter");
  6678. objj_msgSend(defaultCenter, "postNotificationName:object:", CPUndoManagerWillUndoChangeNotification, self);
  6679. var undoGrouping = _undoStack.pop();
  6680. _state = CPUndoManagerUndoing;
  6681. objj_msgSend(self, "beginUndoGrouping");
  6682. objj_msgSend(undoGrouping, "invoke");
  6683. objj_msgSend(self, "endUndoGrouping");
  6684. objj_msgSend(_CPUndoGrouping, "_poolUndoGrouping:", undoGrouping);
  6685. _state = CPUndoManagerNormal;
  6686. objj_msgSend(defaultCenter, "postNotificationName:object:", CPUndoManagerDidUndoChangeNotification, self);
  6687. }
  6688. }), new objj_method(sel_getUid("redo"), function $CPUndoManager__redo(self, _cmd)
  6689. { with(self)
  6690. {
  6691. if (_redoStack.length == 0)
  6692. return;
  6693. var defaultCenter = objj_msgSend(CPNotificationCenter, "defaultCenter");
  6694. objj_msgSend(defaultCenter, "postNotificationName:object:", CPUndoManagerWillRedoChangeNotification, self);
  6695. var oldUndoGrouping = _currentGrouping,
  6696. undoGrouping = _redoStack.pop();
  6697. _currentGrouping = nil;
  6698. _state = CPUndoManagerRedoing;
  6699. objj_msgSend(self, "beginUndoGrouping");
  6700. objj_msgSend(undoGrouping, "invoke");
  6701. objj_msgSend(self, "endUndoGrouping");
  6702. objj_msgSend(_CPUndoGrouping, "_poolUndoGrouping:", undoGrouping);
  6703. _currentGrouping = oldUndoGrouping;
  6704. _state = CPUndoManagerNormal;
  6705. objj_msgSend(defaultCenter, "postNotificationName:object:", CPUndoManagerDidRedoChangeNotification, self);
  6706. }
  6707. }), new objj_method(sel_getUid("beginUndoGrouping"), function $CPUndoManager__beginUndoGrouping(self, _cmd)
  6708. { with(self)
  6709. {
  6710. _currentGrouping = objj_msgSend(_CPUndoGrouping, "undoGroupingWithParent:", _currentGrouping);
  6711. }
  6712. }), new objj_method(sel_getUid("endUndoGrouping"), function $CPUndoManager__endUndoGrouping(self, _cmd)
  6713. { with(self)
  6714. {
  6715. if (!_currentGrouping)
  6716. objj_msgSend(CPException, "raise:reason:", CPInternalInconsistencyException, "endUndoGrouping. No undo group is currently open.");
  6717. var parent = objj_msgSend(_currentGrouping, "parent");
  6718. if (!parent && objj_msgSend(_currentGrouping, "invocations").length > 0)
  6719. {
  6720. objj_msgSend(objj_msgSend(CPNotificationCenter, "defaultCenter"), "postNotificationName:object:", CPUndoManagerWillCloseUndoGroupNotification, self);
  6721. var stack = _state == CPUndoManagerUndoing ? _redoStack : _undoStack;
  6722. stack.push(_currentGrouping);
  6723. if (_levelsOfUndo > 0 && stack.length > _levelsOfUndo)
  6724. stack.splice(0, 1);
  6725. }
  6726. else
  6727. {
  6728. objj_msgSend(parent, "addInvocationsFromArray:", objj_msgSend(_currentGrouping, "invocations"));
  6729. objj_msgSend(_CPUndoGrouping, "_poolUndoGrouping:", _currentGrouping);
  6730. }
  6731. _currentGrouping = parent;
  6732. }
  6733. }), new objj_method(sel_getUid("enableUndoRegistration"), function $CPUndoManager__enableUndoRegistration(self, _cmd)
  6734. { with(self)
  6735. {
  6736. if (_disableCount <= 0)
  6737. objj_msgSend(CPException, "raise:reason:", CPInternalInconsistencyException, "enableUndoRegistration. There are no disable messages in effect right now.");
  6738. _disableCount--;
  6739. }
  6740. }), new objj_method(sel_getUid("groupsByEvent"), function $CPUndoManager__groupsByEvent(self, _cmd)
  6741. { with(self)
  6742. {
  6743. return _groupsByEvent;
  6744. }
  6745. }), new objj_method(sel_getUid("setGroupsByEvent:"), function $CPUndoManager__setGroupsByEvent_(self, _cmd, aFlag)
  6746. { with(self)
  6747. {
  6748. if (_groupsByEvent == aFlag)
  6749. return;
  6750. _groupsByEvent = aFlag;
  6751. if (_groupsByEvent)
  6752. {
  6753. objj_msgSend(self, "_registerWithRunLoop");
  6754. if (!_currentGrouping)
  6755. objj_msgSend(self, "beginUndoGrouping");
  6756. }
  6757. else
  6758. objj_msgSend(self, "_unregisterWithRunLoop");
  6759. }
  6760. }), new objj_method(sel_getUid("groupingLevel"), function $CPUndoManager__groupingLevel(self, _cmd)
  6761. { with(self)
  6762. {
  6763. var grouping = _currentGrouping,
  6764. level = _currentGrouping != nil;
  6765. while (grouping = objj_msgSend(grouping, "parent"))
  6766. ++level;
  6767. return level;
  6768. }
  6769. }), new objj_method(sel_getUid("disableUndoRegistration"), function $CPUndoManager__disableUndoRegistration(self, _cmd)
  6770. { with(self)
  6771. {
  6772. ++_disableCount;
  6773. }
  6774. }), new objj_method(sel_getUid("isUndoRegistrationEnabled"), function $CPUndoManager__isUndoRegistrationEnabled(self, _cmd)
  6775. { with(self)
  6776. {
  6777. return _disableCount == 0;
  6778. }
  6779. }), new objj_method(sel_getUid("isUndoing"), function $CPUndoManager__isUndoing(self, _cmd)
  6780. { with(self)
  6781. {
  6782. return _state == CPUndoManagerUndoing;
  6783. }
  6784. }), new objj_method(sel_getUid("isRedoing"), function $CPUndoManager__isRedoing(self, _cmd)
  6785. { with(self)
  6786. {
  6787. return _state == CPUndoManagerRedoing;
  6788. }
  6789. }), new objj_method(sel_getUid("removeAllActions"), function $CPUndoManager__removeAllActions(self, _cmd)
  6790. { with(self)
  6791. {
  6792. _redoStack = [];
  6793. _undoStack = [];
  6794. _disableCount = 0;
  6795. }
  6796. }), new objj_method(sel_getUid("removeAllActionsWithTarget:"), function $CPUndoManager__removeAllActionsWithTarget_(self, _cmd, aTarget)
  6797. { with(self)
  6798. {
  6799. objj_msgSend(_currentGrouping, "removeInvocationsWithTarget:", aTarget);
  6800. var index = _redoStack.length;
  6801. while (index--)
  6802. {
  6803. var grouping = _redoStack[index];
  6804. objj_msgSend(grouping, "removeInvocationsWithTarget:", aTarget);
  6805. if (!objj_msgSend(grouping, "invocations").length)
  6806. _redoStack.splice(index, 1);
  6807. }
  6808. index = _undoStack.length;
  6809. while (index--)
  6810. {
  6811. var grouping = _undoStack[index];
  6812. objj_msgSend(grouping, "removeInvocationsWithTarget:", aTarget);
  6813. if (!objj_msgSend(grouping, "invocations").length)
  6814. _undoStack.splice(index, 1);
  6815. }
  6816. }
  6817. }), new objj_method(sel_getUid("setActionName:"), function $CPUndoManager__setActionName_(self, _cmd, anActionName)
  6818. { with(self)
  6819. {
  6820. _actionName = anActionName;
  6821. }
  6822. }), new objj_method(sel_getUid("redoActionName"), function $CPUndoManager__redoActionName(self, _cmd)
  6823. { with(self)
  6824. {
  6825. return objj_msgSend(self, "canRedo") ? _actionName : nil;
  6826. }
  6827. }), new objj_method(sel_getUid("undoActionName"), function $CPUndoManager__undoActionName(self, _cmd)
  6828. { with(self)
  6829. {
  6830. return objj_msgSend(self, "canUndo") ? _actionName : nil;
  6831. }
  6832. }), new objj_method(sel_getUid("runLoopModes"), function $CPUndoManager__runLoopModes(self, _cmd)
  6833. { with(self)
  6834. {
  6835. return _runLoopModes;
  6836. }
  6837. }), new objj_method(sel_getUid("setRunLoopModes:"), function $CPUndoManager__setRunLoopModes_(self, _cmd, modes)
  6838. { with(self)
  6839. {
  6840. _runLoopModes = modes;
  6841. objj_msgSend(self, "_unregisterWithRunLoop");
  6842. if (_groupsByEvent)
  6843. objj_msgSend(self, "_registerWithRunLoop");
  6844. }
  6845. }), new objj_method(sel_getUid("beginUndoGroupingForEvent"), function $CPUndoManager__beginUndoGroupingForEvent(self, _cmd)
  6846. { with(self)
  6847. {
  6848. if (!_groupsByEvent)
  6849. return;
  6850. if (_currentGrouping != nil)
  6851. objj_msgSend(self, "endUndoGrouping");
  6852. objj_msgSend(self, "beginUndoGrouping");
  6853. objj_msgSend(objj_msgSend(CPRunLoop, "currentRunLoop"), "performSelector:target:argument:order:modes:", sel_getUid("beginUndoGroupingForEvent"), self, nil, CPUndoCloseGroupingRunLoopOrdering, _runLoopModes);
  6854. }
  6855. }), new objj_method(sel_getUid("_registerWithRunLoop"), function $CPUndoManager___registerWithRunLoop(self, _cmd)
  6856. { with(self)
  6857. {
  6858. if (_registeredWithRunLoop)
  6859. return;
  6860. _registeredWithRunLoop = YES;
  6861. objj_msgSend(objj_msgSend(CPRunLoop, "currentRunLoop"), "performSelector:target:argument:order:modes:", sel_getUid("beginUndoGroupingForEvent"), self, nil, CPUndoCloseGroupingRunLoopOrdering, _runLoopModes);
  6862. }
  6863. }), new objj_method(sel_getUid("_unregisterWithRunLoop"), function $CPUndoManager___unregisterWithRunLoop(self, _cmd)
  6864. { with(self)
  6865. {
  6866. if (!_registeredWithRunLoop)
  6867. return;
  6868. _registeredWithRunLoop = NO;
  6869. objj_msgSend(objj_msgSend(CPRunLoop, "currentRunLoop"), "cancelPerformSelector:target:argument:", sel_getUid("beginUndoGroupingForEvent"), self, nil);
  6870. }
  6871. })]);
  6872. }
  6873. var CPUndoManagerRedoStackKey = "CPUndoManagerRedoStackKey",
  6874. CPUndoManagerUndoStackKey = "CPUndoManagerUndoStackKey";
  6875. CPUndoManagerLevelsOfUndoKey = "CPUndoManagerLevelsOfUndoKey";
  6876. CPUndoManagerActionNameKey = "CPUndoManagerActionNameKey";
  6877. CPUndoManagerCurrentGroupingKey = "CPUndoManagerCurrentGroupingKey";
  6878. CPUndoManagerRunLoopModesKey = "CPUndoManagerRunLoopModesKey";
  6879. CPUndoManagerGroupsByEventKey = "CPUndoManagerGroupsByEventKey";
  6880. {
  6881. var the_class = objj_getClass("CPUndoManager")
  6882. if(!the_class) objj_exception_throw(new objj_exception(OBJJClassNotFoundException, "*** Could not find definition for class \"CPUndoManager\""));
  6883. var meta_class = the_class.isa;class_addMethods(the_class, [new objj_method(sel_getUid("initWithCoder:"), function $CPUndoManager__initWithCoder_(self, _cmd, aCoder)
  6884. { with(self)
  6885. {
  6886. self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPObject") }, "init");
  6887. if (self)
  6888. {
  6889. _redoStack = objj_msgSend(aCoder, "decodeObjectForKey:", CPUndoManagerRedoStackKey);
  6890. _undoStack = objj_msgSend(aCoder, "decodeObjectForKey:", CPUndoManagerUndoStackKey);
  6891. _levelsOfUndo = objj_msgSend(aCoder, "decodeObjectForKey:", CPUndoManagerLevelsOfUndoKey);
  6892. _actionName = objj_msgSend(aCoder, "decodeObjectForKey:", CPUndoManagerActionNameKey);
  6893. _currentGrouping = objj_msgSend(aCoder, "decodeObjectForKey:", CPUndoManagerCurrentGroupingKey);
  6894. _state = CPUndoManagerNormal;
  6895. objj_msgSend(self, "setRunLoopModes:", objj_msgSend(aCoder, "decodeObjectForKey:", CPUndoManagerRunLoopModesKey));
  6896. objj_msgSend(self, "setGroupsByEvent:", objj_msgSend(aCoder, "decodeBoolForKey:", CPUndoManagerGroupsByEventKey));
  6897. }
  6898. return self;
  6899. }
  6900. }), new objj_method(sel_getUid("encodeWithCoder:"), function $CPUndoManager__encodeWithCoder_(self, _cmd, aCoder)
  6901. { with(self)
  6902. {
  6903. objj_msgSend(aCoder, "encodeObject:forKey:", _redoStack, CPUndoManagerRedoStackKey);
  6904. objj_msgSend(aCoder, "encodeObject:forKey:", _undoStack, CPUndoManagerUndoStackKey);
  6905. objj_msgSend(aCoder, "encodeInt:forKey:", _levelsOfUndo, CPUndoManagerLevelsOfUndoKey);
  6906. objj_msgSend(aCoder, "encodeObject:forKey:", _actionName, CPUndoManagerActionNameKey);
  6907. objj_msgSend(aCoder, "encodeObject:forKey:", _currentGrouping, CPUndoManagerCurrentGroupingKey);
  6908. objj_msgSend(aCoder, "encodeObject:forKey:", _runLoopModes, CPUndoManagerRunLoopModesKey);
  6909. objj_msgSend(aCoder, "encodeBool:forKey:", _groupsByEvent, CPUndoManagerGroupsByEventKey);
  6910. }
  6911. })]);
  6912. }
  6913. p;17;CPURLConnection.ji;10;CPObject.ji;11;CPRunLoop.ji;14;CPURLRequest.ji;15;CPURLResponse.jc;6650;
  6914. var XMLHTTPRequestUninitialized = 0,
  6915. XMLHTTPRequestLoading = 1,
  6916. XMLHTTPRequestLoaded = 2,
  6917. XMLHTTPRequestInteractive = 3,
  6918. XMLHTTPRequestComplete = 4;
  6919. var CPURLConnectionDelegate = nil;
  6920. {var the_class = objj_allocateClassPair(CPObject, "CPURLConnection"),
  6921. meta_class = the_class.isa;class_addIvars(the_class, [new objj_ivar("_request"), new objj_ivar("_delegate"), new objj_ivar("_isCanceled"), new objj_ivar("_isLocalFileConnection"), new objj_ivar("_XMLHTTPRequest")]);
  6922. objj_registerClassPair(the_class);
  6923. objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
  6924. class_addMethods(the_class, [new objj_method(sel_getUid("initWithRequest:delegate:startImmediately:"), function $CPURLConnection__initWithRequest_delegate_startImmediately_(self, _cmd, aRequest, aDelegate, shouldStartImmediately)
  6925. { with(self)
  6926. {
  6927. self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPObject") }, "init");
  6928. if (self)
  6929. {
  6930. _request = aRequest;
  6931. _delegate = aDelegate;
  6932. _isCanceled = NO;
  6933. var path = objj_msgSend(_request, "URL");
  6934. _isLocalFileConnection = path.indexOf("file:") === 0 ||
  6935. ((path.indexOf("http:") !== 0 || path.indexOf("https:") !== 0) &&
  6936. window.location &&
  6937. (window.location.protocol === "file:" || window.location.protocol === "app:"));
  6938. _XMLHTTPRequest = objj_request_xmlhttp();
  6939. if (shouldStartImmediately)
  6940. objj_msgSend(self, "start");
  6941. }
  6942. return self;
  6943. }
  6944. }), new objj_method(sel_getUid("initWithRequest:delegate:"), function $CPURLConnection__initWithRequest_delegate_(self, _cmd, aRequest, aDelegate)
  6945. { with(self)
  6946. {
  6947. return objj_msgSend(self, "initWithRequest:delegate:startImmediately:", aRequest, aDelegate, YES);
  6948. }
  6949. }), new objj_method(sel_getUid("delegate"), function $CPURLConnection__delegate(self, _cmd)
  6950. { with(self)
  6951. {
  6952. return _delegate;
  6953. }
  6954. }), new objj_method(sel_getUid("start"), function $CPURLConnection__start(self, _cmd)
  6955. { with(self)
  6956. {
  6957. _isCanceled = NO;
  6958. try
  6959. {
  6960. _XMLHTTPRequest.open(objj_msgSend(_request, "HTTPMethod"), objj_msgSend(_request, "URL"), YES);
  6961. _XMLHTTPRequest.onreadystatechange = function() { objj_msgSend(self, "_readyStateDidChange"); }
  6962. var fields = objj_msgSend(_request, "allHTTPHeaderFields"),
  6963. key = nil,
  6964. keys = objj_msgSend(fields, "keyEnumerator");
  6965. while (key = objj_msgSend(keys, "nextObject"))
  6966. _XMLHTTPRequest.setRequestHeader(key, objj_msgSend(fields, "objectForKey:", key));
  6967. _XMLHTTPRequest.send(objj_msgSend(_request, "HTTPBody"));
  6968. }
  6969. catch (anException)
  6970. {
  6971. if (objj_msgSend(_delegate, "respondsToSelector:", sel_getUid("connection:didFailWithError:")))
  6972. objj_msgSend(_delegate, "connection:didFailWithError:", self, anException);
  6973. }
  6974. }
  6975. }), new objj_method(sel_getUid("cancel"), function $CPURLConnection__cancel(self, _cmd)
  6976. { with(self)
  6977. {
  6978. _isCanceled = YES;
  6979. try
  6980. {
  6981. _XMLHTTPRequest.abort();
  6982. }
  6983. catch (anException)
  6984. {
  6985. }
  6986. }
  6987. }), new objj_method(sel_getUid("isLocalFileConnection"), function $CPURLConnection__isLocalFileConnection(self, _cmd)
  6988. { with(self)
  6989. {
  6990. return _isLocalFileConnection;
  6991. }
  6992. }), new objj_method(sel_getUid("_readyStateDidChange"), function $CPURLConnection___readyStateDidChange(self, _cmd)
  6993. { with(self)
  6994. {
  6995. if (_XMLHTTPRequest.readyState == XMLHTTPRequestComplete)
  6996. {
  6997. var statusCode = _XMLHTTPRequest.status,
  6998. URL = objj_msgSend(_request, "URL");
  6999. if (objj_msgSend(_delegate, "respondsToSelector:", sel_getUid("connection:didReceiveResponse:")))
  7000. {
  7001. if (_isLocalFileConnection)
  7002. objj_msgSend(_delegate, "connection:didReceiveResponse:", self, objj_msgSend(objj_msgSend(CPURLResponse, "alloc"), "initWithURL:", URL));
  7003. else
  7004. {
  7005. var response = objj_msgSend(objj_msgSend(CPHTTPURLResponse, "alloc"), "initWithURL:", URL);
  7006. objj_msgSend(response, "_setStatusCode:", statusCode);
  7007. objj_msgSend(_delegate, "connection:didReceiveResponse:", self, response);
  7008. }
  7009. }
  7010. if (!_isCanceled)
  7011. {
  7012. if (statusCode == 401 && objj_msgSend(CPURLConnectionDelegate, "respondsToSelector:", sel_getUid("connectionDidReceiveAuthenticationChallenge:")))
  7013. objj_msgSend(CPURLConnectionDelegate, "connectionDidReceiveAuthenticationChallenge:", self);
  7014. else
  7015. {
  7016. if (objj_msgSend(_delegate, "respondsToSelector:", sel_getUid("connection:didReceiveData:")))
  7017. objj_msgSend(_delegate, "connection:didReceiveData:", self, _XMLHTTPRequest.responseText);
  7018. if (objj_msgSend(_delegate, "respondsToSelector:", sel_getUid("connectionDidFinishLoading:")))
  7019. objj_msgSend(_delegate, "connectionDidFinishLoading:", self);
  7020. }
  7021. }
  7022. }
  7023. objj_msgSend(objj_msgSend(CPRunLoop, "currentRunLoop"), "limitDateForMode:", CPDefaultRunLoopMode);
  7024. }
  7025. }), new objj_method(sel_getUid("_XMLHTTPRequest"), function $CPURLConnection___XMLHTTPRequest(self, _cmd)
  7026. { with(self)
  7027. {
  7028. return _XMLHTTPRequest;
  7029. }
  7030. })]);
  7031. class_addMethods(meta_class, [new objj_method(sel_getUid("setClassDelegate:"), function $CPURLConnection__setClassDelegate_(self, _cmd, delegate)
  7032. { with(self)
  7033. {
  7034. CPURLConnectionDelegate = delegate;
  7035. }
  7036. }), new objj_method(sel_getUid("sendSynchronousRequest:returningResponse:error:"), function $CPURLConnection__sendSynchronousRequest_returningResponse_error_(self, _cmd, aRequest, aURLResponse, anError)
  7037. { with(self)
  7038. {
  7039. try
  7040. {
  7041. var request = objj_request_xmlhttp();
  7042. request.open(objj_msgSend(aRequest, "HTTPMethod"), objj_msgSend(aRequest, "URL"), NO);
  7043. var fields = objj_msgSend(aRequest, "allHTTPHeaderFields"),
  7044. key = nil,
  7045. keys = objj_msgSend(fields, "keyEnumerator");
  7046. while (key = objj_msgSend(keys, "nextObject"))
  7047. request.setRequestHeader(key, objj_msgSend(fields, "objectForKey:", key));
  7048. request.send(objj_msgSend(aRequest, "HTTPBody"));
  7049. return objj_msgSend(CPData, "dataWithString:", request.responseText);
  7050. }
  7051. catch (anException)
  7052. {
  7053. }
  7054. return nil;
  7055. }
  7056. }), new objj_method(sel_getUid("connectionWithRequest:delegate:"), function $CPURLConnection__connectionWithRequest_delegate_(self, _cmd, aRequest, aDelegate)
  7057. { with(self)
  7058. {
  7059. return objj_msgSend(objj_msgSend(self, "alloc"), "initWithRequest:delegate:", aRequest, aDelegate);
  7060. }
  7061. })]);
  7062. }
  7063. p;14;CPURLRequest.ji;10;CPObject.jc;2769;
  7064. {var the_class = objj_allocateClassPair(CPObject, "CPURLRequest"),
  7065. meta_class = the_class.isa;class_addIvars(the_class, [new objj_ivar("_URL"), new objj_ivar("_HTTPBody"), new objj_ivar("_HTTPMethod"), new objj_ivar("_HTTPHeaderFields")]);
  7066. objj_registerClassPair(the_class);
  7067. objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
  7068. class_addMethods(the_class, [new objj_method(sel_getUid("initWithURL:"), function $CPURLRequest__initWithURL_(self, _cmd, aURL)
  7069. { with(self)
  7070. {
  7071. self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPObject") }, "init");
  7072. if (self)
  7073. {
  7074. _URL = aURL;
  7075. _HTTPBody = "";
  7076. _HTTPMethod = "GET";
  7077. _HTTPHeaderFields = objj_msgSend(CPDictionary, "dictionary");
  7078. objj_msgSend(self, "setValue:forHTTPHeaderField:", "Thu, 1 Jan 1970 00:00:00 GMT", "If-Modified-Since");
  7079. objj_msgSend(self, "setValue:forHTTPHeaderField:", "no-cache", "Cache-Control");
  7080. objj_msgSend(self, "setValue:forHTTPHeaderField:", "XMLHttpRequest", "X-Requested-With");
  7081. }
  7082. return self;
  7083. }
  7084. }), new objj_method(sel_getUid("URL"), function $CPURLRequest__URL(self, _cmd)
  7085. { with(self)
  7086. {
  7087. return _URL;
  7088. }
  7089. }), new objj_method(sel_getUid("setURL:"), function $CPURLRequest__setURL_(self, _cmd, aURL)
  7090. { with(self)
  7091. {
  7092. _URL = aURL;
  7093. }
  7094. }), new objj_method(sel_getUid("setHTTPBody:"), function $CPURLRequest__setHTTPBody_(self, _cmd, anHTTPBody)
  7095. { with(self)
  7096. {
  7097. _HTTPBody = anHTTPBody;
  7098. }
  7099. }), new objj_method(sel_getUid("HTTPBody"), function $CPURLRequest__HTTPBody(self, _cmd)
  7100. { with(self)
  7101. {
  7102. return _HTTPBody;
  7103. }
  7104. }), new objj_method(sel_getUid("setHTTPMethod:"), function $CPURLRequest__setHTTPMethod_(self, _cmd, anHTTPMethod)
  7105. { with(self)
  7106. {
  7107. _HTTPMethod = anHTTPMethod;
  7108. }
  7109. }), new objj_method(sel_getUid("HTTPMethod"), function $CPURLRequest__HTTPMethod(self, _cmd)
  7110. { with(self)
  7111. {
  7112. return _HTTPMethod;
  7113. }
  7114. }), new objj_method(sel_getUid("allHTTPHeaderFields"), function $CPURLRequest__allHTTPHeaderFields(self, _cmd)
  7115. { with(self)
  7116. {
  7117. return _HTTPHeaderFields;
  7118. }
  7119. }), new objj_method(sel_getUid("valueForHTTPHeaderField:"), function $CPURLRequest__valueForHTTPHeaderField_(self, _cmd, aField)
  7120. { with(self)
  7121. {
  7122. return objj_msgSend(_HTTPHeaderFields, "objectForKey:", aField);
  7123. }
  7124. }), new objj_method(sel_getUid("setValue:forHTTPHeaderField:"), function $CPURLRequest__setValue_forHTTPHeaderField_(self, _cmd, aValue, aField)
  7125. { with(self)
  7126. {
  7127. objj_msgSend(_HTTPHeaderFields, "setObject:forKey:", aValue, aField);
  7128. }
  7129. })]);
  7130. class_addMethods(meta_class, [new objj_method(sel_getUid("requestWithURL:"), function $CPURLRequest__requestWithURL_(self, _cmd, aURL)
  7131. { with(self)
  7132. {
  7133. return objj_msgSend(objj_msgSend(CPURLRequest, "alloc"), "initWithURL:", aURL);
  7134. }
  7135. })]);
  7136. }
  7137. p;15;CPURLResponse.ji;10;CPObject.jc;1309;
  7138. {var the_class = objj_allocateClassPair(CPObject, "CPURLResponse"),
  7139. meta_class = the_class.isa;class_addIvars(the_class, [new objj_ivar("_URL")]);
  7140. objj_registerClassPair(the_class);
  7141. objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
  7142. class_addMethods(the_class, [new objj_method(sel_getUid("initWithURL:"), function $CPURLResponse__initWithURL_(self, _cmd, aURL)
  7143. { with(self)
  7144. {
  7145. self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPObject") }, "init");
  7146. if (self)
  7147. _URL = aURL;
  7148. return self;
  7149. }
  7150. }), new objj_method(sel_getUid("URL"), function $CPURLResponse__URL(self, _cmd)
  7151. { with(self)
  7152. {
  7153. return _URL;
  7154. }
  7155. })]);
  7156. }
  7157. {var the_class = objj_allocateClassPair(CPURLResponse, "CPHTTPURLResponse"),
  7158. meta_class = the_class.isa;class_addIvars(the_class, [new objj_ivar("_statusCode")]);
  7159. objj_registerClassPair(the_class);
  7160. objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
  7161. class_addMethods(the_class, [new objj_method(sel_getUid("_setStatusCode:"), function $CPHTTPURLResponse___setStatusCode_(self, _cmd, aStatusCode)
  7162. { with(self)
  7163. {
  7164. _statusCode = aStatusCode;
  7165. }
  7166. }), new objj_method(sel_getUid("statusCode"), function $CPHTTPURLResponse__statusCode(self, _cmd)
  7167. { with(self)
  7168. {
  7169. return _statusCode;
  7170. }
  7171. })]);
  7172. }
  7173. p;22;CPUserSessionManager.jI;21;Foundation/CPObject.jI;21;Foundation/CPString.jc;2478;
  7174. CPUserSessionUndeterminedStatus = 0;
  7175. CPUserSessionLoggedInStatus = 1;
  7176. CPUserSessionLoggedOutStatus = 2;
  7177. CPUserSessionManagerStatusDidChangeNotification = "CPUserSessionManagerStatusDidChangeNotification";
  7178. CPUserSessionManagerUserIdentifierDidChangeNotification = "CPUserSessionManagerUserIdentifierDidChangeNotification";
  7179. var CPDefaultUserSessionManager = nil;
  7180. {var the_class = objj_allocateClassPair(CPObject, "CPUserSessionManager"),
  7181. meta_class = the_class.isa;class_addIvars(the_class, [new objj_ivar("_status"), new objj_ivar("_userIdentifier")]);
  7182. objj_registerClassPair(the_class);
  7183. objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
  7184. class_addMethods(the_class, [new objj_method(sel_getUid("init"), function $CPUserSessionManager__init(self, _cmd)
  7185. { with(self)
  7186. {
  7187. self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPObject") }, "init");
  7188. if (self)
  7189. _status = CPUserSessionUndeterminedStatus;
  7190. return self;
  7191. }
  7192. }), new objj_method(sel_getUid("status"), function $CPUserSessionManager__status(self, _cmd)
  7193. { with(self)
  7194. {
  7195. return _status;
  7196. }
  7197. }), new objj_method(sel_getUid("setStatus:"), function $CPUserSessionManager__setStatus_(self, _cmd, aStatus)
  7198. { with(self)
  7199. {
  7200. if (_status == aStatus)
  7201. return;
  7202. _status = aStatus;
  7203. objj_msgSend(objj_msgSend(CPNotificationCenter, "defaultCenter"), "postNotificationName:object:", CPUserSessionManagerStatusDidChangeNotification, self);
  7204. if (_status != CPUserSessionLoggedInStatus)
  7205. objj_msgSend(self, "setUserIdentifier:", nil);
  7206. }
  7207. }), new objj_method(sel_getUid("userIdentifier"), function $CPUserSessionManager__userIdentifier(self, _cmd)
  7208. { with(self)
  7209. {
  7210. return _userIdentifier;
  7211. }
  7212. }), new objj_method(sel_getUid("setUserIdentifier:"), function $CPUserSessionManager__setUserIdentifier_(self, _cmd, anIdentifier)
  7213. { with(self)
  7214. {
  7215. if (_userIdentifier == anIdentifier)
  7216. return;
  7217. _userIdentifier = anIdentifier;
  7218. objj_msgSend(objj_msgSend(CPNotificationCenter, "defaultCenter"), "postNotificationName:object:", CPUserSessionManagerUserIdentifierDidChangeNotification, self);
  7219. }
  7220. })]);
  7221. class_addMethods(meta_class, [new objj_method(sel_getUid("defaultManager"), function $CPUserSessionManager__defaultManager(self, _cmd)
  7222. { with(self)
  7223. {
  7224. if (!CPDefaultUserSessionManager)
  7225. CPDefaultUserSessionManager = objj_msgSend(objj_msgSend(CPUserSessionManager, "alloc"), "init");
  7226. return CPDefaultUserSessionManager;
  7227. }
  7228. })]);
  7229. }
  7230. p;9;CPValue.ji;10;CPObject.ji;9;CPCoder.jc;5030;
  7231. {var the_class = objj_allocateClassPair(CPObject, "CPValue"),
  7232. meta_class = the_class.isa;class_addIvars(the_class, [new objj_ivar("_JSObject")]);
  7233. objj_registerClassPair(the_class);
  7234. objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
  7235. class_addMethods(the_class, [new objj_method(sel_getUid("initWithJSObject:"), function $CPValue__initWithJSObject_(self, _cmd, aJSObject)
  7236. { with(self)
  7237. {
  7238. self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPObject") }, "init");
  7239. if (self)
  7240. _JSObject = aJSObject;
  7241. return self;
  7242. }
  7243. }), new objj_method(sel_getUid("JSObject"), function $CPValue__JSObject(self, _cmd)
  7244. { with(self)
  7245. {
  7246. return _JSObject;
  7247. }
  7248. })]);
  7249. class_addMethods(meta_class, [new objj_method(sel_getUid("valueWithJSObject:"), function $CPValue__valueWithJSObject_(self, _cmd, aJSObject)
  7250. { with(self)
  7251. {
  7252. return objj_msgSend(objj_msgSend(self, "alloc"), "initWithJSObject:", aJSObject);
  7253. }
  7254. })]);
  7255. }
  7256. var CPValueValueKey = "CPValueValueKey";
  7257. {
  7258. var the_class = objj_getClass("CPValue")
  7259. if(!the_class) objj_exception_throw(new objj_exception(OBJJClassNotFoundException, "*** Could not find definition for class \"CPValue\""));
  7260. var meta_class = the_class.isa;class_addMethods(the_class, [new objj_method(sel_getUid("initWithCoder:"), function $CPValue__initWithCoder_(self, _cmd, aCoder)
  7261. { with(self)
  7262. {
  7263. self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPObject") }, "init");
  7264. if (self)
  7265. _JSObject = CPJSObjectCreateWithJSON(objj_msgSend(aCoder, "decodeObjectForKey:", CPValueValueKey));
  7266. return self;
  7267. }
  7268. }), new objj_method(sel_getUid("encodeWithCoder:"), function $CPValue__encodeWithCoder_(self, _cmd, aCoder)
  7269. { with(self)
  7270. {
  7271. objj_msgSend(aCoder, "encodeObject:forKey:", CPJSObjectCreateJSON(_JSObject), CPValueValueKey);
  7272. }
  7273. })]);
  7274. }
  7275. var _JSONCharacterEncodings = {};
  7276. _JSONCharacterEncodings['\b'] = "\\b";
  7277. _JSONCharacterEncodings['\t'] = "\\t";
  7278. _JSONCharacterEncodings['\n'] = "\\n";
  7279. _JSONCharacterEncodings['\f'] = "\\f";
  7280. _JSONCharacterEncodings['\r'] = "\\r";
  7281. _JSONCharacterEncodings['"'] = "\\\"";
  7282. _JSONCharacterEncodings['\\'] = "\\\\";
  7283. var _JSONEncodedCharacters = new RegExp("[\\\"\\\\\\x00-\\x1f\\x7f-\\x9f]", 'g');
  7284. CPJSObjectCreateJSON= function(aJSObject)
  7285. {
  7286. var type = typeof aJSObject,
  7287. valueOf = aJSObject ? aJSObject.valueOf() : null,
  7288. typeValueOf = typeof valueOf;
  7289. if (type != typeValueOf)
  7290. {
  7291. type = typeValueOf;
  7292. aJSObject = valueOf;
  7293. }
  7294. switch (type)
  7295. {
  7296. case "string":
  7297. if (!_JSONEncodedCharacters.test(aJSObject))
  7298. return '"' + aJSObject + '"';
  7299. return '"' + aJSObject.replace(_JSONEncodedCharacters, _CPJSObjectEncodeCharacter) + '"';
  7300. case "number":
  7301. return isFinite(aJSObject) ? String(aJSObject) : "null";
  7302. case "boolean":
  7303. case "null": return String(aJSObject);
  7304. case "object":
  7305. if (!aJSObject)
  7306. return "null";
  7307. if (typeof aJSObject.toJSON === "function")
  7308. return CPJSObjectCreateJSON(aJSObject.toJSON());
  7309. var array = [];
  7310. if (aJSObject.slice)
  7311. {
  7312. var index = 0,
  7313. count = aJSObject.length;
  7314. for (; index < count; ++index)
  7315. array.push(CPJSObjectCreateJSON(aJSObject[index]) || "null");
  7316. return '[' + array.join(',') + ']';
  7317. }
  7318. var key = NULL;
  7319. for (key in aJSObject)
  7320. {
  7321. if (!(typeof key === "string"))
  7322. continue;
  7323. var value = CPJSObjectCreateJSON(aJSObject[key]);
  7324. if (value)
  7325. array.push(CPJSObjectCreateJSON(key) + ':' + value);
  7326. }
  7327. return '{' + array.join(',') + '}';
  7328. }
  7329. }
  7330. var _CPJSObjectEncodeCharacter = function(aCharacter)
  7331. {
  7332. var encoding = _JSONCharacterEncodings[aCharacter];
  7333. if (encoding)
  7334. return encoding;
  7335. encoding = aCharacter.charCodeAt(0);
  7336. return '\\u00' + FLOOR(encoding / 16).toString(16) + (encoding % 16).toString(16);
  7337. }
  7338. var _JSONBackslashCharacters = new RegExp("\\\\.", 'g'),
  7339. _JSONSimpleValueTokens = new RegExp("\"[^\"\\\\\\n\\r]*\"|true|false|null|-?\\d+(?:\\.\\d*)?(?:[eE][+\\-]?\\d+)?", 'g'),
  7340. _JSONValidOpenBrackets = new RegExp("(?:^|:|,)(?:\\s*\\[)+", 'g'),
  7341. _JSONValidExpression = new RegExp("^[\\],:{}\\s]*$");
  7342. CPJSObjectCreateWithJSON= function(aString)
  7343. {
  7344. if (_JSONValidExpression.test(aString.replace(_JSONBackslashCharacters, '@').replace(_JSONSimpleValueTokens, ']').replace(_JSONValidOpenBrackets, '')))
  7345. return eval('(' + aString + ')');
  7346. return nil;
  7347. }
  7348. p;12;Foundation.ji;9;CPArray.ji;10;CPBundle.ji;9;CPCoder.ji;8;CPData.ji;8;CPDate.ji;14;CPDictionary.ji;14;CPEnumerator.ji;13;CPException.ji;12;CPIndexSet.ji;14;CPInvocation.ji;19;CPJSONPConnection.ji;17;CPKeyedArchiver.ji;19;CPKeyedUnarchiver.ji;18;CPKeyValueCoding.ji;21;CPKeyValueObserving.ji;7;CPLog.ji;16;CPNotification.ji;22;CPNotificationCenter.ji;8;CPNull.ji;10;CPNumber.ji;10;CPObject.ji;15;CPObjJRuntime.ji;29;CPPropertyListSerialization.ji;9;CPRange.ji;11;CPRunLoop.ji;7;CPSet.ji;18;CPSortDescriptor.ji;10;CPString.ji;9;CPTimer.ji;15;CPUndoManager.ji;17;CPURLConnection.ji;14;CPURLRequest.ji;15;CPURLResponse.ji;22;CPUserSessionManager.ji;9;CPValue.j