Browse Source

remove process.{cc,h} process.exit() now exit()

the process object might return in the future but for now it is going away.
v0.7.4-release
Ryan 16 years ago
parent
commit
0f5170339c
  1. 4
      src/main.js
  2. 24
      src/node.cc
  3. 1
      src/node.h
  4. 39
      src/process.cc
  5. 11
      src/process.h
  6. 2
      test/test-pingpong.js
  7. 1
      wscript

4
src/main.js

@ -79,7 +79,7 @@ clearInterval = clearTimeout;
findScript(base_directory, name, function (filename) {
if (filename === null) {
stderr.puts("Cannot find a script matching: " + name);
process.exit(1);
exit(1);
}
loadScript(filename, target, callback);
});
@ -137,7 +137,7 @@ clearInterval = clearTimeout;
File.cat(filename, function (status, content) {
if (status != 0) {
stderr.puts("Error reading " + filename + ": " + File.strerror(status));
process.exit(1);
exit(1);
}
var scaffold = new Scaffold(content, filename, target);

24
src/node.cc

@ -2,7 +2,6 @@
#include "net.h"
#include "file.h"
#include "process.h"
#include "http.h"
#include "timer.h"
@ -124,6 +123,15 @@ ExecuteString(v8::Handle<v8::String> source,
return scope.Close(result);
}
NODE_METHOD(node_exit)
{
int r = 0;
if (args.Length() > 0)
r = args[0]->IntegerValue();
::exit(r);
return Undefined();
}
NODE_METHOD(compile)
{
if (args.Length() < 2)
@ -166,18 +174,9 @@ void
node::fatal_exception (TryCatch &try_catch)
{
ReportException(&try_catch);
ev_unloop(EV_DEFAULT_UC_ EVUNLOOP_ALL);
exit_code = 1;
}
void
node::exit (int code)
{
exit_code = code;
ev_unloop(EV_DEFAULT_UC_ EVUNLOOP_ALL);
::exit(1);
}
static ev_async thread_pool_watcher;
static void
@ -236,6 +235,7 @@ main (int argc, char *argv[])
NODE_SET_METHOD(node, "compile", compile);
NODE_SET_METHOD(node, "debug", debug);
NODE_SET_METHOD(g, "exit", node_exit);
Local<Array> arguments = Array::New(argc);
for (int i = 0; i < argc; i++) {
@ -244,10 +244,10 @@ main (int argc, char *argv[])
}
g->Set(String::New("ARGV"), arguments);
// BUILT-IN MODULES
node::Init_net(g);
node::Init_timer(g);
node::Init_process(g);
node::Init_file(g);
node::Init_http(g);

1
src/node.h

@ -15,7 +15,6 @@ namespace node {
enum encoding {UTF8, RAW};
void fatal_exception (v8::TryCatch &try_catch);
void exit (int code);
void eio_warmup (void); // call this before creating a new eio event.
class ObjectWrap {

39
src/process.cc

@ -1,39 +0,0 @@
#include "process.h"
#include "node.h"
#include <v8.h>
#include <stdlib.h>
using namespace v8;
static Handle<Value>
ExitCallback (const Arguments& args)
{
int exit_code = 0;
if (args.Length() > 0) exit_code = args[0]->IntegerValue();
exit(exit_code);
return Undefined();
}
static Handle<Value>
OnCallback (const Arguments& args)
{
return Undefined();
}
void
node::Init_process (Handle<Object> target)
{
HandleScope scope;
Local<Object> process = ObjectTemplate::New()->NewInstance();
target->Set(String::NewSymbol("process"), process);
// process.exit()
Local<FunctionTemplate> process_exit = FunctionTemplate::New(ExitCallback);
process->Set(String::NewSymbol("exit"), process_exit->GetFunction());
// process.on()
Local<FunctionTemplate> process_on = FunctionTemplate::New(OnCallback);
process->Set(String::NewSymbol("on"), process_exit->GetFunction());
}

11
src/process.h

@ -1,11 +0,0 @@
#ifndef node_process_h
#define node_process_h
#include <v8.h>
namespace node {
void Init_process (v8::Handle<v8::Object> target);
} // namespace node
#endif

2
test/test-pingpong.js

@ -45,7 +45,7 @@ function onLoad() {
socket.connectTCP(12123, "127.0.0.1", function (status) {
if(status != 0)
process.exit(1);
exit(1);
socket.write("PING");
});

1
wscript

@ -158,7 +158,6 @@ def build(bld):
src/node.cc
src/http.cc
src/net.cc
src/process.cc
src/file.cc
src/timer.cc
"""

Loading…
Cancel
Save