From 4ea5ab63c1445ece928db723d8ee7f651d95ff7f Mon Sep 17 00:00:00 2001 From: Ryan Date: Wed, 4 Mar 2009 19:16:07 +0100 Subject: [PATCH] implement setInterval() --- Makefile | 3 ++- node_timer.cc | 21 ++++++++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index de5cfae..a11ea87 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,7 @@ EVDIR=$(HOME)/local/libev V8INC = $(HOME)/src/v8/include -V8LIB = $(HOME)/src/v8/libv8_g.a +#V8LIB = $(HOME)/src/v8/libv8_g.a +V8LIB = $(HOME)/src/v8/libv8.a CFLAGS = -g -I$(V8INC) -Ideps/oi -DHAVE_GNUTLS=0 -Ideps/ebb LDFLAGS = -lev -pthread # -lefence diff --git a/node_timer.cc b/node_timer.cc index f06542c..184dbf2 100644 --- a/node_timer.cc +++ b/node_timer.cc @@ -165,7 +165,26 @@ static Handle setInterval ( const Arguments& args ) { - assert(0 && "not implemented"); + if (args.Length() < 2) + return Undefined(); + + HandleScope scope; + + Local callback = Local::Cast(args[0]); + uint32_t delay = args[1]->Uint32Value(); + + ev_tstamp after = (double)delay / 1000.0; + + if (args.Length() > 2) + assert(0 && "extra params to setInterval not yet implemented."); + int argc = 0; + Handle argv[] = {}; + + Timer *timer = new Timer(callback, argc, argv, after, after); + + Local timeoutID = timer->CreateTimeoutID(); + + return scope.Close(timeoutID); } void -- 2.7.4