PageRenderTime 23ms CodeModel.GetById 13ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 1ms

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