add timers modules

This commit is contained in:
hyb1996
2017-07-21 11:24:02 +08:00
parent 85216477c4
commit 8f2a088111
26 changed files with 365 additions and 152 deletions

View File

@@ -2,23 +2,6 @@
module.exports = function(__runtime__, scope){
var events = Object.create(__runtime__.events);
var caller = function(func, args){
var arr = [];
var len = args.length;
for(var i = 0; i < len; i++){
arr.push(args[i]);
}
return func.apply(null, arr);
};
events.setFunctionCaller(caller);
events.emitter = function(){
var e = new com.stardust.autojs.runtime.api.EventEmitter();
e.setFunctionCaller(caller);
return e;
}
return events;
}

View File

@@ -19,10 +19,12 @@ module.exports = function(__runtime__, scope){
return !isStopped();
}
scope.stop = function(){
__runtime__.stop();
scope.exit = function(){
__runtime__.exit();
}
scope.stop = scope.exit;
scope.setClip = function(text){
__runtime__.setClip(text);
}

View File

@@ -0,0 +1,9 @@
module.exports = function(__runtime__, scope){
var timers = Object.create(__runtime__.timers);
scope.__asGlobal__(timers, ['loop', 'setTimeout', 'clearTimeout', 'setInterval', 'clearInterval', 'setImmediate', 'clearImmediate']);
return timers;
}