/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
- i;10;CPObject.ji;14;CPInvocation.ji;8;CPDate.ji;11;CPRunLoop.jc;5195;
- var _1=objj_allocateClassPair(CPObject,"CPTimer"),_2=_1.isa;
- class_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")]);
- objj_registerClassPair(_1);
- objj_addClassForBundle(_1,objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
- class_addMethods(_1,[new objj_method(sel_getUid("initWithFireDate:interval:invocation:repeats:"),function(_3,_4,_5,_6,_7,_8){
- with(_3){
- _3=objj_msgSendSuper({receiver:_3,super_class:objj_getClass("CPObject")},"init");
- if(_3){
- _timeInterval=_6;
- _invocation=_7;
- _repeats=_8;
- _isValid=YES;
- _fireDate=_5;
- }
- return _3;
- }
- }),new objj_method(sel_getUid("initWithFireDate:interval:target:selector:userInfo:repeats:"),function(_9,_a,_b,_c,_d,_e,_f,_10){
- with(_9){
- var _11=objj_msgSend(CPInvocation,"invocationWithMethodSignature:",1);
- objj_msgSend(_11,"setTarget:",_d);
- objj_msgSend(_11,"setSelector:",_e);
- objj_msgSend(_11,"setArgument:atIndex:",_9,2);
- _9=objj_msgSend(_9,"initWithFireDate:interval:invocation:repeats:",_b,_c,_11,_10);
- if(_9){
- _userInfo=_f;
- }
- return _9;
- }
- }),new objj_method(sel_getUid("initWithFireDate:interval:callback:repeats:"),function(_12,_13,_14,_15,_16,_17){
- with(_12){
- _12=objj_msgSendSuper({receiver:_12,super_class:objj_getClass("CPObject")},"init");
- if(_12){
- _timeInterval=_15;
- _callback=_16;
- _repeats=_17;
- _isValid=YES;
- _fireDate=_14;
- }
- return _12;
- }
- }),new objj_method(sel_getUid("timeInterval"),function(_18,_19){
- with(_18){
- return _timeInterval;
- }
- }),new objj_method(sel_getUid("fireDate"),function(_1a,_1b){
- with(_1a){
- return _fireDate;
- }
- }),new objj_method(sel_getUid("setFireDate:"),function(_1c,_1d,_1e){
- with(_1c){
- _fireDate=_1e;
- }
- }),new objj_method(sel_getUid("fire"),function(_1f,_20){
- with(_1f){
- if(!_isValid){
- return;
- }
- if(_callback){
- _callback();
- }else{
- objj_msgSend(_invocation,"invoke");
- }
- if(!_isValid){
- return;
- }
- if(_repeats){
- _fireDate=objj_msgSend(CPDate,"dateWithTimeIntervalSinceNow:",_timeInterval);
- }else{
- objj_msgSend(_1f,"invalidate");
- }
- }
- }),new objj_method(sel_getUid("isValid"),function(_21,_22){
- with(_21){
- return _isValid;
- }
- }),new objj_method(sel_getUid("invalidate"),function(_23,_24){
- with(_23){
- _isValid=NO;
- _userInfo=nil;
- _invocation=nil;
- _callback=nil;
- }
- }),new objj_method(sel_getUid("userInfo"),function(_25,_26){
- with(_25){
- return _userInfo;
- }
- })]);
- class_addMethods(_2,[new objj_method(sel_getUid("scheduledTimerWithTimeInterval:invocation:repeats:"),function(_27,_28,_29,_2a,_2b){
- with(_27){
- var _2c=objj_msgSend(objj_msgSend(_27,"alloc"),"initWithFireDate:interval:invocation:repeats:",objj_msgSend(CPDate,"dateWithTimeIntervalSinceNow:",_29),_29,_2a,_2b);
- objj_msgSend(objj_msgSend(CPRunLoop,"currentRunLoop"),"addTimer:forMode:",_2c,CPDefaultRunLoopMode);
- return _2c;
- }
- }),new objj_method(sel_getUid("scheduledTimerWithTimeInterval:target:selector:userInfo:repeats:"),function(_2d,_2e,_2f,_30,_31,_32,_33){
- with(_2d){
- var _34=objj_msgSend(objj_msgSend(_2d,"alloc"),"initWithFireDate:interval:target:selector:userInfo:repeats:",objj_msgSend(CPDate,"dateWithTimeIntervalSinceNow:",_2f),_2f,_30,_31,_32,_33);
- objj_msgSend(objj_msgSend(CPRunLoop,"currentRunLoop"),"addTimer:forMode:",_34,CPDefaultRunLoopMode);
- return _34;
- }
- }),new objj_method(sel_getUid("scheduledTimerWithTimeInterval:callback:repeats:"),function(_35,_36,_37,_38,_39){
- with(_35){
- var _3a=objj_msgSend(objj_msgSend(_35,"alloc"),"initWithFireDate:interval:callback:repeats:",objj_msgSend(CPDate,"dateWithTimeIntervalSinceNow:",_37),_37,_38,_39);
- objj_msgSend(objj_msgSend(CPRunLoop,"currentRunLoop"),"addTimer:forMode:",_3a,CPDefaultRunLoopMode);
- return _3a;
- }
- }),new objj_method(sel_getUid("timerWithTimeInterval:invocation:repeats:"),function(_3b,_3c,_3d,_3e,_3f){
- with(_3b){
- return objj_msgSend(objj_msgSend(_3b,"alloc"),"initWithFireDate:interval:invocation:repeats:",nil,_3d,_3e,_3f);
- }
- }),new objj_method(sel_getUid("timerWithTimeInterval:target:selector:userInfo:repeats:"),function(_40,_41,_42,_43,_44,_45,_46){
- with(_40){
- return objj_msgSend(objj_msgSend(_40,"alloc"),"initWithFireDate:interval:target:selector:userInfo:repeats:",nil,_42,_43,_44,_45,_46);
- }
- }),new objj_method(sel_getUid("timerWithTimeInterval:callback:repeats:"),function(_47,_48,_49,_4a,_4b){
- with(_47){
- return objj_msgSend(objj_msgSend(_47,"alloc"),"initWithFireDate:interval:callback:repeats:",nil,_49,_4a,_4b);
- }
- })]);
- var _4c=1000,_4d={};
- var _4e=function(_4f,_50,_51,_52){
- var _53=_4c++,_54=nil;
- if(typeof _4f==="string"){
- _54=function(){
- new Function(_4f)();
- if(!_51){
- _4d[_53]=nil;
- }
- };
- }else{
- if(!_52){
- _52=[];
- }
- _54=function(){
- _4f.apply(window,_52);
- if(!_51){
- _4d[_53]=nil;
- }
- };
- }
- _4d[_53]=objj_msgSend(CPTimer,"scheduledTimerWithTimeInterval:callback:repeats:",_50/1000,_54,_51);
- return _53;
- };
- window.setTimeout=function(_55,_56){
- return _4e(_55,_56,NO,Array.prototype.slice.apply(arguments,[2]));
- };
- window.clearTimeout=function(_57){
- var _58=_4d[_57];
- if(_58){
- objj_msgSend(_58,"invalidate");
- }
- _4d[_57]=nil;
- };
- window.setInterval=function(_59,_5a,_5b){
- return _4e(_59,_5a,YES,Array.prototype.slice.apply(arguments,[2]));
- };
- window.clearInterval=function(_5c){
- window.clearTimeout(_5c);
- };