The data contained in this repository can be downloaded to your computer using one of several clients.
Please see the documentation of your version control software client for more information.

Please select the desired protocol below to get the URL.

This URL has Read-Only access.

Statistics
| Branch: | Revision:

main_repo / src / process.cc @ 63a9cd38

History | View | Annotate | Download (894 Bytes)

1
#include "process.h"
2
#include "node.h"
3
#include <v8.h>
4
#include <stdlib.h>
5

    
6
using namespace v8;
7

    
8
static Handle<Value>
9
ExitCallback (const Arguments& args)
10
{
11
  int exit_code = 0;
12
  if (args.Length() > 0) exit_code = args[0]->IntegerValue();
13
  exit(exit_code);
14
  return Undefined(); 
15
}
16

    
17
static Handle<Value>
18
OnCallback (const Arguments& args)
19
{
20
  return Undefined(); 
21
}
22

    
23
void
24
NodeInit_process (Handle<Object> target)
25
{
26
  HandleScope scope;
27

    
28
  Local<Object> process = ObjectTemplate::New()->NewInstance();
29

    
30
  target->Set(String::NewSymbol("process"), process);
31

    
32
  // process.exit()
33
  Local<FunctionTemplate> process_exit = FunctionTemplate::New(ExitCallback);
34
  process->Set(String::NewSymbol("exit"), process_exit->GetFunction());
35

    
36
  // process.on()
37
  Local<FunctionTemplate> process_on = FunctionTemplate::New(OnCallback);
38
  process->Set(String::NewSymbol("on"), process_exit->GetFunction());
39
}