PageRenderTime 26ms CodeModel.GetById 15ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/Frameworks/Foundation/objj.platform/CPNotificationCenter.j

http://github.com/jfahrenkrug/MapKit-HelloWorld
Unknown | 196 lines | 196 code | 0 blank | 0 comment | 0 complexity | d6d8b585c4b68b7f43348784e2baf41d MD5 | raw file
  1i;9;CPArray.ji;14;CPDictionary.ji;16;CPNotification.ji;13;CPException.jc;6582;
  2var _1=nil;
  3var _2=objj_allocateClassPair(CPObject,"CPNotificationCenter"),_3=_2.isa;
  4class_addIvars(_2,[new objj_ivar("_namedRegistries"),new objj_ivar("_unnamedRegistry")]);
  5objj_registerClassPair(_2);
  6objj_addClassForBundle(_2,objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
  7class_addMethods(_2,[new objj_method(sel_getUid("init"),function(_4,_5){
  8with(_4){
  9_4=objj_msgSendSuper({receiver:_4,super_class:objj_getClass("CPObject")},"init");
 10if(_4){
 11_namedRegistries=objj_msgSend(CPDictionary,"dictionary");
 12_unnamedRegistry=objj_msgSend(objj_msgSend(_CPNotificationRegistry,"alloc"),"init");
 13}
 14return _4;
 15}
 16}),new objj_method(sel_getUid("addObserver:selector:name:object:"),function(_6,_7,_8,_9,_a,_b){
 17with(_6){
 18var _c,_d=objj_msgSend(objj_msgSend(_CPNotificationObserver,"alloc"),"initWithObserver:selector:",_8,_9);
 19if(_a==nil){
 20_c=_unnamedRegistry;
 21}else{
 22if(!(_c=objj_msgSend(_namedRegistries,"objectForKey:",_a))){
 23_c=objj_msgSend(objj_msgSend(_CPNotificationRegistry,"alloc"),"init");
 24objj_msgSend(_namedRegistries,"setObject:forKey:",_c,_a);
 25}
 26}
 27objj_msgSend(_c,"addObserver:object:",_d,_b);
 28}
 29}),new objj_method(sel_getUid("removeObserver:"),function(_e,_f,_10){
 30with(_e){
 31var _11=nil,_12=objj_msgSend(_namedRegistries,"keyEnumerator");
 32while(_11=objj_msgSend(_12,"nextObject")){
 33objj_msgSend(objj_msgSend(_namedRegistries,"objectForKey:",_11),"removeObserver:object:",_10,nil);
 34}
 35objj_msgSend(_unnamedRegistry,"removeObserver:object:",_10,nil);
 36}
 37}),new objj_method(sel_getUid("removeObserver:name:object:"),function(_13,_14,_15,_16,_17){
 38with(_13){
 39if(_16==nil){
 40var _18=nil,_19=objj_msgSend(_namedRegistries,"keyEnumerator");
 41while(_18=objj_msgSend(_19,"nextObject")){
 42objj_msgSend(objj_msgSend(_namedRegistries,"objectForKey:",_18),"removeObserver:object:",_15,_17);
 43}
 44objj_msgSend(_unnamedRegistry,"removeObserver:object:",_15,_17);
 45}else{
 46objj_msgSend(objj_msgSend(_namedRegistries,"objectForKey:",_16),"removeObserver:object:",_15,_17);
 47}
 48}
 49}),new objj_method(sel_getUid("postNotification:"),function(_1a,_1b,_1c){
 50with(_1a){
 51if(!_1c){
 52objj_msgSend(CPException,"raise:reason:",CPInvalidArgumentException,"postNotification: does not except 'nil' notifications");
 53}
 54_1d(_1a,_1c);
 55}
 56}),new objj_method(sel_getUid("postNotificationName:object:userInfo:"),function(_1e,_1f,_20,_21,_22){
 57with(_1e){
 58_1d(_1e,objj_msgSend(objj_msgSend(CPNotification,"alloc"),"initWithName:object:userInfo:",_20,_21,_22));
 59}
 60}),new objj_method(sel_getUid("postNotificationName:object:"),function(_23,_24,_25,_26){
 61with(_23){
 62_1d(_23,objj_msgSend(objj_msgSend(CPNotification,"alloc"),"initWithName:object:userInfo:",_25,_26,nil));
 63}
 64})]);
 65class_addMethods(_3,[new objj_method(sel_getUid("defaultCenter"),function(_27,_28){
 66with(_27){
 67if(!_1){
 68_1=objj_msgSend(objj_msgSend(CPNotificationCenter,"alloc"),"init");
 69}
 70return _1;
 71}
 72})]);
 73var _1d=function(_29,_2a){
 74objj_msgSend(_29._unnamedRegistry,"postNotification:",_2a);
 75objj_msgSend(objj_msgSend(_29._namedRegistries,"objectForKey:",objj_msgSend(_2a,"name")),"postNotification:",_2a);
 76};
 77var _2=objj_allocateClassPair(CPObject,"_CPNotificationRegistry"),_3=_2.isa;
 78class_addIvars(_2,[new objj_ivar("_objectObservers"),new objj_ivar("_observerRemoval"),new objj_ivar("_postingObservers")]);
 79objj_registerClassPair(_2);
 80objj_addClassForBundle(_2,objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
 81class_addMethods(_2,[new objj_method(sel_getUid("init"),function(_2b,_2c){
 82with(_2b){
 83if(_2b){
 84_objectObservers=objj_msgSend(CPDictionary,"dictionary");
 85}
 86return _2b;
 87}
 88}),new objj_method(sel_getUid("addObserver:object:"),function(_2d,_2e,_2f,_30){
 89with(_2d){
 90if(!_30){
 91_30=objj_msgSend(CPNull,"null");
 92}
 93var _31=objj_msgSend(_objectObservers,"objectForKey:",objj_msgSend(_30,"hash"));
 94if(!_31){
 95_31=[];
 96objj_msgSend(_objectObservers,"setObject:forKey:",_31,objj_msgSend(_30,"hash"));
 97}
 98if(_31==_postingObservers){
 99_postingObservers=objj_msgSend(_31,"copy");
100}
101_31.push(_2f);
102}
103}),new objj_method(sel_getUid("removeObserver:object:"),function(_32,_33,_34,_35){
104with(_32){
105var _36=[];
106if(_35==nil){
107var key=nil,_38=objj_msgSend(_objectObservers,"keyEnumerator");
108while(key=objj_msgSend(_38,"nextObject")){
109var _39=objj_msgSend(_objectObservers,"objectForKey:",key),_3a=_39?_39.length:0;
110while(_3a--){
111if(objj_msgSend(_39[_3a],"observer")==_34){
112_observerRemoval=YES;
113if(_39==_postingObservers){
114_postingObservers=objj_msgSend(_39,"copy");
115}
116_39.splice(_3a,1);
117}
118}
119if(!_39||_39.length==0){
120_36.push(key);
121}
122}
123}else{
124var key=objj_msgSend(_35,"hash"),_39=objj_msgSend(_objectObservers,"objectForKey:",key);
125_3a=_39?_39.length:0;
126while(_3a--){
127if(objj_msgSend(_39[_3a],"observer")==_34){
128_observerRemoval=YES;
129if(_39==_postingObservers){
130_postingObservers=objj_msgSend(_39,"copy");
131}
132_39.splice(_3a,1);
133}
134}
135if(!_39||_39.length==0){
136_36.push(key);
137}
138}
139var _3a=_36.length;
140while(_3a--){
141objj_msgSend(_objectObservers,"removeObjectForKey:",_36[_3a]);
142}
143}
144}),new objj_method(sel_getUid("postNotification:"),function(_3b,_3c,_3d){
145with(_3b){
146var _3e=objj_msgSend(_3d,"object");
147if(_3e!=nil&&(_postingObservers=objj_msgSend(_objectObservers,"objectForKey:",objj_msgSend(_3e,"hash")))){
148var _3f=_postingObservers,_40=_3f.length;
149_observerRemoval=NO;
150while(_40--){
151var _41=_postingObservers[_40];
152if(!_observerRemoval||objj_msgSend(_3f,"indexOfObjectIdenticalTo:",_41)!=CPNotFound){
153objj_msgSend(_41,"postNotification:",_3d);
154}
155}
156}
157_postingObservers=objj_msgSend(_objectObservers,"objectForKey:",objj_msgSend(objj_msgSend(CPNull,"null"),"hash"));
158if(!_postingObservers){
159return;
160}
161var _3f=_postingObservers,_40=_3f.length;
162_observerRemoval=NO;
163while(_40--){
164var _41=_postingObservers[_40];
165if(!_observerRemoval||objj_msgSend(_3f,"indexOfObjectIdenticalTo:",_41)!=CPNotFound){
166objj_msgSend(_41,"postNotification:",_3d);
167}
168}
169_postingObservers=nil;
170}
171}),new objj_method(sel_getUid("count"),function(_42,_43){
172with(_42){
173return objj_msgSend(_objectObservers,"count");
174}
175})]);
176var _2=objj_allocateClassPair(CPObject,"_CPNotificationObserver"),_3=_2.isa;
177class_addIvars(_2,[new objj_ivar("_observer"),new objj_ivar("_selector")]);
178objj_registerClassPair(_2);
179objj_addClassForBundle(_2,objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
180class_addMethods(_2,[new objj_method(sel_getUid("initWithObserver:selector:"),function(_44,_45,_46,_47){
181with(_44){
182if(_44){
183_observer=_46;
184_selector=_47;
185}
186return _44;
187}
188}),new objj_method(sel_getUid("observer"),function(_48,_49){
189with(_48){
190return _observer;
191}
192}),new objj_method(sel_getUid("postNotification:"),function(_4a,_4b,_4c){
193with(_4a){
194objj_msgSend(_observer,"performSelector:withObject:",_selector,_4c);
195}
196})]);