/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

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