/Frameworks/Foundation/objj.platform/CPKeyValueCoding.j

http://github.com/jfahrenkrug/MapKit-HelloWorld · Unknown · 172 lines · 172 code · 0 blank · 0 comment · 0 complexity · f51a84f83fd3a19644c2233c19726d31 MD5 · raw file

  1. i;9;CPArray.ji;10;CPObject.ji;14;CPDictionary.jc;5969;
  2. var _1=nil,_2=nil;
  3. CPUndefinedKeyException="CPUndefinedKeyException";
  4. CPTargetObjectUserInfoKey="CPTargetObjectUserInfoKey";
  5. CPUnknownUserInfoKey="CPUnknownUserInfoKey";
  6. var _3=objj_getClass("CPObject");
  7. if(!_3){
  8. objj_exception_throw(new objj_exception(OBJJClassNotFoundException,"*** Could not find definition for class \"CPObject\""));
  9. }
  10. var _4=_3.isa;
  11. class_addMethods(_3,[new objj_method(sel_getUid("_ivarForKey:"),function(_5,_6,_7){
  12. with(_5){
  13. var _8="_"+_7;
  14. if(typeof _5[_8]!="undefined"){
  15. return _8;
  16. }
  17. var _9="is"+_7.charAt(0).toUpperCase()+_7.substr(1);
  18. _8="_"+_9;
  19. if(typeof _5[_8]!="undefined"){
  20. return _8;
  21. }
  22. _8=_7;
  23. if(typeof _5[_8]!="undefined"){
  24. return _8;
  25. }
  26. _8=_9;
  27. if(typeof _5[_8]!="undefined"){
  28. return _8;
  29. }
  30. return nil;
  31. }
  32. }),new objj_method(sel_getUid("valueForKey:"),function(_a,_b,_c){
  33. with(_a){
  34. var _d=objj_msgSend(_a,"class"),_e=objj_msgSend(_d,"_accessorForKey:",_c);
  35. if(_e){
  36. return objj_msgSend(_a,_e);
  37. }
  38. if(objj_msgSend(_d,"accessInstanceVariablesDirectly")){
  39. var _f=objj_msgSend(_a,"_ivarForKey:",_c);
  40. if(_f){
  41. return _a[_f];
  42. }
  43. }
  44. return objj_msgSend(_a,"valueForUndefinedKey:",_c);
  45. }
  46. }),new objj_method(sel_getUid("valueForKeyPath:"),function(_10,_11,_12){
  47. with(_10){
  48. var _13=_12.split("."),_14=0,_15=_13.length,_16=_10;
  49. for(;_14<_15;++_14){
  50. _16=objj_msgSend(_16,"valueForKey:",_13[_14]);
  51. }
  52. return _16;
  53. }
  54. }),new objj_method(sel_getUid("dictionaryWithValuesForKeys:"),function(_17,_18,_19){
  55. with(_17){
  56. var _1a=0,_1b=_19.length,_1c=objj_msgSend(CPDictionary,"dictionary");
  57. for(;_1a<_1b;++_1a){
  58. var key=_19[_1a],_1e=objj_msgSend(_17,"valueForKey:",key);
  59. if(_1e===nil){
  60. objj_msgSend(_1c,"setObject:forKey:",objj_msgSend(CPNull,"null"),key);
  61. }else{
  62. objj_msgSend(_1c,"setObject:forKey:",_1e,key);
  63. }
  64. }
  65. return _1c;
  66. }
  67. }),new objj_method(sel_getUid("valueForUndefinedKey:"),function(_1f,_20,_21){
  68. with(_1f){
  69. objj_msgSend(objj_msgSend(CPException,"exceptionWithName:reason:userInfo:",CPUndefinedKeyException,objj_msgSend(_1f,"description")+" is not key value coding-compliant for the key "+_21,objj_msgSend(CPDictionary,"dictionaryWithObjects:forKeys:",[_1f,_21],[CPTargetObjectUserInfoKey,CPUnknownUserInfoKey])),"raise");
  70. }
  71. }),new objj_method(sel_getUid("setValue:forKeyPath:"),function(_22,_23,_24,_25){
  72. with(_22){
  73. if(!_25){
  74. _25="self";
  75. }
  76. var i=0,_27=_25.split("."),_28=_27.length-1,_29=_22;
  77. for(;i<_28;++i){
  78. _29=objj_msgSend(_29,"valueForKey:",_27[i]);
  79. }
  80. objj_msgSend(_29,"setValue:forKey:",_24,_27[i]);
  81. }
  82. }),new objj_method(sel_getUid("setValue:forKey:"),function(_2a,_2b,_2c,_2d){
  83. with(_2a){
  84. var _2e=objj_msgSend(_2a,"class"),_2f=objj_msgSend(_2e,"_modifierForKey:",_2d);
  85. if(_2f){
  86. return objj_msgSend(_2a,_2f,_2c);
  87. }
  88. if(objj_msgSend(_2e,"accessInstanceVariablesDirectly")){
  89. var _30=objj_msgSend(_2a,"_ivarForKey:",_2d);
  90. if(_30){
  91. objj_msgSend(_2a,"willChangeValueForKey:",_2d);
  92. _2a[_30]=_2c;
  93. objj_msgSend(_2a,"didChangeValueForKey:",_2d);
  94. }
  95. return;
  96. }
  97. objj_msgSend(_2a,"setValue:forUndefinedKey:",_2c,_2d);
  98. }
  99. }),new objj_method(sel_getUid("setValue:forUndefinedKey:"),function(_31,_32,_33,_34){
  100. with(_31){
  101. objj_msgSend(objj_msgSend(CPException,"exceptionWithName:reason:userInfo:",CPUndefinedKeyException,objj_msgSend(_31,"description")+" is not key value coding-compliant for the key "+_34,objj_msgSend(CPDictionary,"dictionaryWithObjects:forKeys:",[_31,_34],[CPTargetObjectUserInfoKey,CPUnknownUserInfoKey])),"raise");
  102. }
  103. })]);
  104. class_addMethods(_4,[new objj_method(sel_getUid("accessInstanceVariablesDirectly"),function(_35,_36){
  105. with(_35){
  106. return YES;
  107. }
  108. }),new objj_method(sel_getUid("_accessorForKey:"),function(_37,_38,_39){
  109. with(_37){
  110. if(!_1){
  111. _1=objj_msgSend(CPDictionary,"dictionary");
  112. }
  113. var _3a=objj_msgSend(isa,"hash"),_3b=nil,_3c=objj_msgSend(_1,"objectForKey:",_3a);
  114. if(_3c){
  115. _3b=objj_msgSend(_3c,"objectForKey:",_39);
  116. if(_3b){
  117. return _3b===objj_msgSend(CPNull,"null")?nil:_3b;
  118. }
  119. }else{
  120. _3c=objj_msgSend(CPDictionary,"dictionary");
  121. objj_msgSend(_1,"setObject:forKey:",_3c,_3a);
  122. }
  123. var _3d=_39.charAt(0).toUpperCase()+_39.substr(1);
  124. if(objj_msgSend(_37,"instancesRespondToSelector:",_3b=CPSelectorFromString("get"+_3d))||objj_msgSend(_37,"instancesRespondToSelector:",_3b=CPSelectorFromString(_39))||objj_msgSend(_37,"instancesRespondToSelector:",_3b=CPSelectorFromString("is"+_3d))||objj_msgSend(_37,"instancesRespondToSelector:",_3b=CPSelectorFromString("_get"+_3d))||objj_msgSend(_37,"instancesRespondToSelector:",_3b=CPSelectorFromString("_"+_39))||objj_msgSend(_37,"instancesRespondToSelector:",_3b=CPSelectorFromString("_is"+_3d))){
  125. objj_msgSend(_3c,"setObject:forKey:",_3b,_39);
  126. return _3b;
  127. }
  128. objj_msgSend(_3c,"setObject:forKey:",objj_msgSend(CPNull,"null"),_39);
  129. return nil;
  130. }
  131. }),new objj_method(sel_getUid("_modifierForKey:"),function(_3e,_3f,_40){
  132. with(_3e){
  133. if(!_2){
  134. _2=objj_msgSend(CPDictionary,"dictionary");
  135. }
  136. var _41=objj_msgSend(isa,"hash"),_42=nil,_43=objj_msgSend(_2,"objectForKey:",_41);
  137. if(_43){
  138. _42=objj_msgSend(_43,"objectForKey:",_40);
  139. if(_42){
  140. return _42===objj_msgSend(CPNull,"null")?nil:_42;
  141. }
  142. }else{
  143. _43=objj_msgSend(CPDictionary,"dictionary");
  144. objj_msgSend(_2,"setObject:forKey:",_43,_41);
  145. }
  146. if(_42){
  147. return _42===objj_msgSend(CPNull,"null")?nil:_42;
  148. }
  149. var _44=_40.charAt(0).toUpperCase()+_40.substr(1)+":";
  150. if(objj_msgSend(_3e,"instancesRespondToSelector:",_42=CPSelectorFromString("set"+_44))||objj_msgSend(_3e,"instancesRespondToSelector:",_42=CPSelectorFromString("_set"+_44))){
  151. objj_msgSend(_43,"setObject:forKey:",_42,_40);
  152. return _42;
  153. }
  154. objj_msgSend(_43,"setObject:forKey:",objj_msgSend(CPNull,"null"),_40);
  155. return nil;
  156. }
  157. })]);
  158. var _3=objj_getClass("CPDictionary");
  159. if(!_3){
  160. objj_exception_throw(new objj_exception(OBJJClassNotFoundException,"*** Could not find definition for class \"CPDictionary\""));
  161. }
  162. var _4=_3.isa;
  163. class_addMethods(_3,[new objj_method(sel_getUid("valueForKey:"),function(_45,_46,_47){
  164. with(_45){
  165. return objj_msgSend(_45,"objectForKey:",_47);
  166. }
  167. }),new objj_method(sel_getUid("setValue:forKey:"),function(_48,_49,_4a,_4b){
  168. with(_48){
  169. objj_msgSend(_48,"setObject:forKey:",_4a,_4b);
  170. }
  171. })]);
  172. i;13;CPArray+KVO.j