#include <node.h>
#include <v8.h>
+ Isolate* isolate = Isolate::GetCurrent();
+
using namespace v8;
Handle<Value> Method(const Arguments& args) {
- HandleScope scope;
+ HandleScope scope(isolate);
return scope.Close(String::New("world"));
}
#define BUILDING_NODE_EXTENSION
#include <node.h>
+ Isolate* isolate = Isolate::GetCurrent();
+
using namespace v8;
Handle<Value> Add(const Arguments& args) {
- HandleScope scope;
+ HandleScope scope(isolate);
if (args.Length() < 2) {
ThrowException(Exception::TypeError(String::New("Wrong number of arguments")));
- return scope.Close(Undefined());
+ return scope.Close(Undefined(isolate));
}
if (!args[0]->IsNumber() || !args[1]->IsNumber()) {
ThrowException(Exception::TypeError(String::New("Wrong arguments")));
- return scope.Close(Undefined());
+ return scope.Close(Undefined(isolate));
}
Local<Number> num = Number::New(args[0]->NumberValue() +
#define BUILDING_NODE_EXTENSION
#include <node.h>
+ Isolate* isolate = Isolate::GetCurrent();
+
using namespace v8;
Handle<Value> RunCallback(const Arguments& args) {
- HandleScope scope;
+ HandleScope scope(isolate);
Local<Function> cb = Local<Function>::Cast(args[0]);
const unsigned argc = 1;
Local<Value> argv[argc] = { Local<Value>::New(String::New("hello world")) };
cb->Call(Context::GetCurrent()->Global(), argc, argv);
- return scope.Close(Undefined());
+ return scope.Close(Undefined(isolate));
}
void Init(Handle<Object> exports, Handle<Object> module) {
#define BUILDING_NODE_EXTENSION
#include <node.h>
+ Isolate* isolate = Isolate::GetCurrent();
+
using namespace v8;
Handle<Value> CreateObject(const Arguments& args) {
- HandleScope scope;
+ HandleScope scope(isolate);
Local<Object> obj = Object::New();
obj->Set(String::NewSymbol("msg"), args[0]->ToString());
#define BUILDING_NODE_EXTENSION
#include <node.h>
+ Isolate* isolate = Isolate::GetCurrent();
+
using namespace v8;
Handle<Value> MyFunction(const Arguments& args) {
- HandleScope scope;
+ HandleScope scope(isolate);
return scope.Close(String::New("hello world"));
}
Handle<Value> CreateFunction(const Arguments& args) {
- HandleScope scope;
+ HandleScope scope(isolate);
Local<FunctionTemplate> tpl = FunctionTemplate::New(MyFunction);
Local<Function> fn = tpl->GetFunction();
#include <node.h>
#include "myobject.h"
+ Isolate* isolate = Isolate::GetCurrent();
+
using namespace v8;
MyObject::MyObject() {};
tpl->PrototypeTemplate()->Set(String::NewSymbol("plusOne"),
FunctionTemplate::New(PlusOne)->GetFunction());
- Persistent<Function> constructor = Persistent<Function>::New(tpl->GetFunction());
+ Persistent<Function> constructor = Persistent<Function>::New(isolate, tpl->GetFunction());
exports->Set(String::NewSymbol("MyObject"), constructor);
}
Handle<Value> MyObject::New(const Arguments& args) {
- HandleScope scope;
+ HandleScope scope(isolate);
MyObject* obj = new MyObject();
obj->counter_ = args[0]->IsUndefined() ? 0 : args[0]->NumberValue();
}
Handle<Value> MyObject::PlusOne(const Arguments& args) {
- HandleScope scope;
+ HandleScope scope(isolate);
MyObject* obj = ObjectWrap::Unwrap<MyObject>(args.This());
obj->counter_ += 1;
#include <node.h>
#include "myobject.h"
+ Isolate* isolate = Isolate::GetCurrent();
+
using namespace v8;
Handle<Value> CreateObject(const Arguments& args) {
- HandleScope scope;
+ HandleScope scope(isolate);
return scope.Close(MyObject::NewInstance(args));
}
#include <node.h>
#include "myobject.h"
+ Isolate* isolate = Isolate::GetCurrent();
+
using namespace v8;
MyObject::MyObject() {};
tpl->PrototypeTemplate()->Set(String::NewSymbol("plusOne"),
FunctionTemplate::New(PlusOne)->GetFunction());
- constructor = Persistent<Function>::New(tpl->GetFunction());
+ constructor = Persistent<Function>::New(isolate, tpl->GetFunction());
}
Handle<Value> MyObject::New(const Arguments& args) {
- HandleScope scope;
+ HandleScope scope(isolate);
MyObject* obj = new MyObject();
obj->counter_ = args[0]->IsUndefined() ? 0 : args[0]->NumberValue();
}
Handle<Value> MyObject::NewInstance(const Arguments& args) {
- HandleScope scope;
+ HandleScope scope(isolate);
const unsigned argc = 1;
Handle<Value> argv[argc] = { args[0] };
}
Handle<Value> MyObject::PlusOne(const Arguments& args) {
- HandleScope scope;
+ HandleScope scope(isolate);
MyObject* obj = ObjectWrap::Unwrap<MyObject>(args.This());
obj->counter_ += 1;
#include <node.h>
#include "myobject.h"
+ Isolate* isolate = Isolate::GetCurrent();
+
using namespace v8;
Handle<Value> CreateObject(const Arguments& args) {
- HandleScope scope;
+ HandleScope scope(isolate);
return scope.Close(MyObject::NewInstance(args));
}
Handle<Value> Add(const Arguments& args) {
- HandleScope scope;
+ HandleScope scope(isolate);
MyObject* obj1 = node::ObjectWrap::Unwrap<MyObject>(
args[0]->ToObject());
#include <node.h>
#include "myobject.h"
+ Isolate* isolate = Isolate::GetCurrent();
+
using namespace v8;
MyObject::MyObject() {};
}
Handle<Value> MyObject::New(const Arguments& args) {
- HandleScope scope;
+ HandleScope scope(isolate);
MyObject* obj = new MyObject();
obj->val_ = args[0]->IsUndefined() ? 0 : args[0]->NumberValue();
}
Handle<Value> MyObject::NewInstance(const Arguments& args) {
- HandleScope scope;
+ HandleScope scope(isolate);
const unsigned argc = 1;
Handle<Value> argv[argc] = { args[0] };