PageRenderTime 22ms CodeModel.GetById 16ms app.highlight 2ms RepoModel.GetById 2ms app.codeStats 0ms

/Frameworks/Foundation/objj.platform/CPTimer.j

http://github.com/jfahrenkrug/MapKit-HelloWorld
Unknown | 159 lines | 159 code | 0 blank | 0 comment | 0 complexity | 6667332d553f30935d5b07488d0cacf4 MD5 | raw file
  1i;10;CPObject.ji;14;CPInvocation.ji;8;CPDate.ji;11;CPRunLoop.jc;5195;
  2var _1=objj_allocateClassPair(CPObject,"CPTimer"),_2=_1.isa;
  3class_addIvars(_1,[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")]);
  4objj_registerClassPair(_1);
  5objj_addClassForBundle(_1,objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
  6class_addMethods(_1,[new objj_method(sel_getUid("initWithFireDate:interval:invocation:repeats:"),function(_3,_4,_5,_6,_7,_8){
  7with(_3){
  8_3=objj_msgSendSuper({receiver:_3,super_class:objj_getClass("CPObject")},"init");
  9if(_3){
 10_timeInterval=_6;
 11_invocation=_7;
 12_repeats=_8;
 13_isValid=YES;
 14_fireDate=_5;
 15}
 16return _3;
 17}
 18}),new objj_method(sel_getUid("initWithFireDate:interval:target:selector:userInfo:repeats:"),function(_9,_a,_b,_c,_d,_e,_f,_10){
 19with(_9){
 20var _11=objj_msgSend(CPInvocation,"invocationWithMethodSignature:",1);
 21objj_msgSend(_11,"setTarget:",_d);
 22objj_msgSend(_11,"setSelector:",_e);
 23objj_msgSend(_11,"setArgument:atIndex:",_9,2);
 24_9=objj_msgSend(_9,"initWithFireDate:interval:invocation:repeats:",_b,_c,_11,_10);
 25if(_9){
 26_userInfo=_f;
 27}
 28return _9;
 29}
 30}),new objj_method(sel_getUid("initWithFireDate:interval:callback:repeats:"),function(_12,_13,_14,_15,_16,_17){
 31with(_12){
 32_12=objj_msgSendSuper({receiver:_12,super_class:objj_getClass("CPObject")},"init");
 33if(_12){
 34_timeInterval=_15;
 35_callback=_16;
 36_repeats=_17;
 37_isValid=YES;
 38_fireDate=_14;
 39}
 40return _12;
 41}
 42}),new objj_method(sel_getUid("timeInterval"),function(_18,_19){
 43with(_18){
 44return _timeInterval;
 45}
 46}),new objj_method(sel_getUid("fireDate"),function(_1a,_1b){
 47with(_1a){
 48return _fireDate;
 49}
 50}),new objj_method(sel_getUid("setFireDate:"),function(_1c,_1d,_1e){
 51with(_1c){
 52_fireDate=_1e;
 53}
 54}),new objj_method(sel_getUid("fire"),function(_1f,_20){
 55with(_1f){
 56if(!_isValid){
 57return;
 58}
 59if(_callback){
 60_callback();
 61}else{
 62objj_msgSend(_invocation,"invoke");
 63}
 64if(!_isValid){
 65return;
 66}
 67if(_repeats){
 68_fireDate=objj_msgSend(CPDate,"dateWithTimeIntervalSinceNow:",_timeInterval);
 69}else{
 70objj_msgSend(_1f,"invalidate");
 71}
 72}
 73}),new objj_method(sel_getUid("isValid"),function(_21,_22){
 74with(_21){
 75return _isValid;
 76}
 77}),new objj_method(sel_getUid("invalidate"),function(_23,_24){
 78with(_23){
 79_isValid=NO;
 80_userInfo=nil;
 81_invocation=nil;
 82_callback=nil;
 83}
 84}),new objj_method(sel_getUid("userInfo"),function(_25,_26){
 85with(_25){
 86return _userInfo;
 87}
 88})]);
 89class_addMethods(_2,[new objj_method(sel_getUid("scheduledTimerWithTimeInterval:invocation:repeats:"),function(_27,_28,_29,_2a,_2b){
 90with(_27){
 91var _2c=objj_msgSend(objj_msgSend(_27,"alloc"),"initWithFireDate:interval:invocation:repeats:",objj_msgSend(CPDate,"dateWithTimeIntervalSinceNow:",_29),_29,_2a,_2b);
 92objj_msgSend(objj_msgSend(CPRunLoop,"currentRunLoop"),"addTimer:forMode:",_2c,CPDefaultRunLoopMode);
 93return _2c;
 94}
 95}),new objj_method(sel_getUid("scheduledTimerWithTimeInterval:target:selector:userInfo:repeats:"),function(_2d,_2e,_2f,_30,_31,_32,_33){
 96with(_2d){
 97var _34=objj_msgSend(objj_msgSend(_2d,"alloc"),"initWithFireDate:interval:target:selector:userInfo:repeats:",objj_msgSend(CPDate,"dateWithTimeIntervalSinceNow:",_2f),_2f,_30,_31,_32,_33);
 98objj_msgSend(objj_msgSend(CPRunLoop,"currentRunLoop"),"addTimer:forMode:",_34,CPDefaultRunLoopMode);
 99return _34;
100}
101}),new objj_method(sel_getUid("scheduledTimerWithTimeInterval:callback:repeats:"),function(_35,_36,_37,_38,_39){
102with(_35){
103var _3a=objj_msgSend(objj_msgSend(_35,"alloc"),"initWithFireDate:interval:callback:repeats:",objj_msgSend(CPDate,"dateWithTimeIntervalSinceNow:",_37),_37,_38,_39);
104objj_msgSend(objj_msgSend(CPRunLoop,"currentRunLoop"),"addTimer:forMode:",_3a,CPDefaultRunLoopMode);
105return _3a;
106}
107}),new objj_method(sel_getUid("timerWithTimeInterval:invocation:repeats:"),function(_3b,_3c,_3d,_3e,_3f){
108with(_3b){
109return objj_msgSend(objj_msgSend(_3b,"alloc"),"initWithFireDate:interval:invocation:repeats:",nil,_3d,_3e,_3f);
110}
111}),new objj_method(sel_getUid("timerWithTimeInterval:target:selector:userInfo:repeats:"),function(_40,_41,_42,_43,_44,_45,_46){
112with(_40){
113return objj_msgSend(objj_msgSend(_40,"alloc"),"initWithFireDate:interval:target:selector:userInfo:repeats:",nil,_42,_43,_44,_45,_46);
114}
115}),new objj_method(sel_getUid("timerWithTimeInterval:callback:repeats:"),function(_47,_48,_49,_4a,_4b){
116with(_47){
117return objj_msgSend(objj_msgSend(_47,"alloc"),"initWithFireDate:interval:callback:repeats:",nil,_49,_4a,_4b);
118}
119})]);
120var _4c=1000,_4d={};
121var _4e=function(_4f,_50,_51,_52){
122var _53=_4c++,_54=nil;
123if(typeof _4f==="string"){
124_54=function(){
125new Function(_4f)();
126if(!_51){
127_4d[_53]=nil;
128}
129};
130}else{
131if(!_52){
132_52=[];
133}
134_54=function(){
135_4f.apply(window,_52);
136if(!_51){
137_4d[_53]=nil;
138}
139};
140}
141_4d[_53]=objj_msgSend(CPTimer,"scheduledTimerWithTimeInterval:callback:repeats:",_50/1000,_54,_51);
142return _53;
143};
144window.setTimeout=function(_55,_56){
145return _4e(_55,_56,NO,Array.prototype.slice.apply(arguments,[2]));
146};
147window.clearTimeout=function(_57){
148var _58=_4d[_57];
149if(_58){
150objj_msgSend(_58,"invalidate");
151}
152_4d[_57]=nil;
153};
154window.setInterval=function(_59,_5a,_5b){
155return _4e(_59,_5a,YES,Array.prototype.slice.apply(arguments,[2]));
156};
157window.clearInterval=function(_5c){
158window.clearTimeout(_5c);
159};