Commit cf7477c3 authored by legoc's avatar legoc
Browse files

Updated addons

parent 2f2ea51e
...@@ -16,6 +16,7 @@ namespace nomad { ...@@ -16,6 +16,7 @@ namespace nomad {
using v8::Function; using v8::Function;
using v8::FunctionCallbackInfo; using v8::FunctionCallbackInfo;
using v8::Isolate; using v8::Isolate;
using v8::Context;
using v8::Local; using v8::Local;
using v8::Object; using v8::Object;
using v8::String; using v8::String;
...@@ -28,6 +29,7 @@ using v8::Persistent; ...@@ -28,6 +29,7 @@ using v8::Persistent;
NomadAccessor accessor; NomadAccessor accessor;
Isolate * v8Isolate; Isolate * v8Isolate;
v8::Local<v8::Context> context;
/** /**
* Init function to initialise the Cameo Nomad addon. * Init function to initialise the Cameo Nomad addon.
...@@ -38,21 +40,21 @@ void Init(const FunctionCallbackInfo<Value>& args) { ...@@ -38,21 +40,21 @@ void Init(const FunctionCallbackInfo<Value>& args) {
v8Isolate = args.GetIsolate(); v8Isolate = args.GetIsolate();
// Local endpoint. // Local endpoint.
v8::String::Utf8Value param1(args[0]->ToString()); v8::String::Utf8Value param1(v8Isolate, args[0]);
string localEndpoint(*param1); string localEndpoint(*param1);
// Initialise the Nomad accessor. // Initialise the Nomad accessor.
accessor.init("vEXP", localEndpoint); accessor.init("vEXP", localEndpoint);
// Nomad endpoint. // Nomad endpoint.
v8::String::Utf8Value param2(args[1]->ToString()); v8::String::Utf8Value param2(v8Isolate, args[1]);
string nomadEndpoint(*param2); string nomadEndpoint(*param2);
// Connect to a nomad sim depending on the size of the args. // Connect to a nomad sim depending on the size of the args.
if (args.Length() > 2) { if (args.Length() > 2) {
// Interpret the arg 2 in string because it comes from the command line and is not a V8 integer. // Interpret the arg 2 in string because it comes from the command line and is not a V8 integer.
v8::String::Utf8Value param3(args[3]->ToString()); v8::String::Utf8Value param3(v8Isolate, args[3]);
string arg3(*param3); string arg3(*param3);
istringstream is(arg3); istringstream is(arg3);
...@@ -83,10 +85,10 @@ void Terminate(const FunctionCallbackInfo<Value>& args) { ...@@ -83,10 +85,10 @@ void Terminate(const FunctionCallbackInfo<Value>& args) {
*/ */
void GetPropertyId(const FunctionCallbackInfo<Value>& args) { void GetPropertyId(const FunctionCallbackInfo<Value>& args) {
v8::String::Utf8Value param0(args[0]->ToString()); v8::String::Utf8Value param0(v8Isolate, args[0]);
std::string servantName(*param0); std::string servantName(*param0);
v8::String::Utf8Value param1(args[1]->ToString()); v8::String::Utf8Value param1(v8Isolate, args[1]);
std::string propertyName(*param1); std::string propertyName(*param1);
args.GetReturnValue().Set(Number::New(args.GetIsolate(), accessor.getPropertyId(servantName, propertyName))); args.GetReturnValue().Set(Number::New(args.GetIsolate(), accessor.getPropertyId(servantName, propertyName)));
...@@ -119,7 +121,7 @@ void GetBooleanProperty(const FunctionCallbackInfo<Value>& args) { ...@@ -119,7 +121,7 @@ void GetBooleanProperty(const FunctionCallbackInfo<Value>& args) {
void GetStringProperty(const FunctionCallbackInfo<Value>& args) { void GetStringProperty(const FunctionCallbackInfo<Value>& args) {
string value = accessor.getStringValue(Local<Integer>::Cast(args[0])->Value()); string value = accessor.getStringValue(Local<Integer>::Cast(args[0])->Value());
args.GetReturnValue().Set(String::NewFromUtf8(args.GetIsolate(), value.c_str())); args.GetReturnValue().Set(String::NewFromUtf8(args.GetIsolate(), value.c_str()).ToLocalChecked());
} }
/** /**
...@@ -127,12 +129,13 @@ void GetStringProperty(const FunctionCallbackInfo<Value>& args) { ...@@ -127,12 +129,13 @@ void GetStringProperty(const FunctionCallbackInfo<Value>& args) {
*/ */
void GetInt32ArrayProperty(const FunctionCallbackInfo<Value>& args) { void GetInt32ArrayProperty(const FunctionCallbackInfo<Value>& args) {
Local<Context> context = args.GetIsolate()->GetCurrentContext();
Local<Array> array = Array::New(args.GetIsolate(), 0); Local<Array> array = Array::New(args.GetIsolate(), 0);
vector<int32_t> arrayValue = accessor.getInt32Array(Local<Integer>::Cast(args[0])->Value()); vector<int32_t> arrayValue = accessor.getInt32Array(Local<Integer>::Cast(args[0])->Value());
for (int i = 0; i < arrayValue.size(); ++i) { for (int i = 0; i < arrayValue.size(); ++i) {
array->Set(i, Integer::New(args.GetIsolate(), arrayValue[i])); array->Set(context, i, Integer::New(args.GetIsolate(), arrayValue[i]));
} }
args.GetReturnValue().Set(array); args.GetReturnValue().Set(array);
...@@ -143,12 +146,13 @@ void GetInt32ArrayProperty(const FunctionCallbackInfo<Value>& args) { ...@@ -143,12 +146,13 @@ void GetInt32ArrayProperty(const FunctionCallbackInfo<Value>& args) {
*/ */
void GetFloat64ArrayProperty(const FunctionCallbackInfo<Value>& args) { void GetFloat64ArrayProperty(const FunctionCallbackInfo<Value>& args) {
Local<Context> context = args.GetIsolate()->GetCurrentContext();
Local<Array> array = Array::New(args.GetIsolate(), 0); Local<Array> array = Array::New(args.GetIsolate(), 0);
vector<double> arrayValue = accessor.getFloat64Array(Local<Integer>::Cast(args[0])->Value()); vector<double> arrayValue = accessor.getFloat64Array(Local<Integer>::Cast(args[0])->Value());
for (int i = 0; i < arrayValue.size(); ++i) { for (int i = 0; i < arrayValue.size(); ++i) {
array->Set(i, Number::New(args.GetIsolate(), arrayValue[i])); array->Set(context, i, Number::New(args.GetIsolate(), arrayValue[i]));
} }
args.GetReturnValue().Set(array); args.GetReturnValue().Set(array);
...@@ -179,7 +183,7 @@ void SetBooleanProperty(const FunctionCallbackInfo<Value>& args) { ...@@ -179,7 +183,7 @@ void SetBooleanProperty(const FunctionCallbackInfo<Value>& args) {
* Sets the string property value. * Sets the string property value.
*/ */
void SetStringProperty(const FunctionCallbackInfo<Value>& args) { void SetStringProperty(const FunctionCallbackInfo<Value>& args) {
v8::String::Utf8Value param1(args[1]->ToString()); v8::String::Utf8Value param1(v8Isolate, args[1]);
std::string value(*param1); std::string value(*param1);
args.GetReturnValue().Set(Boolean::New(args.GetIsolate(), accessor.setStringValue(Local<Integer>::Cast(args[0])->Value(), value))); args.GetReturnValue().Set(Boolean::New(args.GetIsolate(), accessor.setStringValue(Local<Integer>::Cast(args[0])->Value(), value)));
} }
...@@ -205,7 +209,7 @@ static void WorkAsync(uv_work_t *req) { ...@@ -205,7 +209,7 @@ static void WorkAsync(uv_work_t *req) {
*/ */
template<typename Type, typename JSType> template<typename Type, typename JSType>
static void WorkAsyncComplete(uv_work_t *req, int status) { static void WorkAsyncComplete(uv_work_t *req, int status) {
/*
Isolate * isolate = Isolate::GetCurrent(); Isolate * isolate = Isolate::GetCurrent();
v8::HandleScope handleScope(isolate); v8::HandleScope handleScope(isolate);
...@@ -219,7 +223,7 @@ static void WorkAsyncComplete(uv_work_t *req, int status) { ...@@ -219,7 +223,7 @@ static void WorkAsyncComplete(uv_work_t *req, int status) {
Local<Function>::New(isolate, work->callback)->Call(isolate->GetCurrentContext()->Global(), 1, argv); Local<Function>::New(isolate, work->callback)->Call(isolate->GetCurrentContext()->Global(), 1, argv);
work->callback.Reset(); work->callback.Reset();
delete work; delete work;*/
} }
/** /**
...@@ -228,7 +232,7 @@ static void WorkAsyncComplete(uv_work_t *req, int status) { ...@@ -228,7 +232,7 @@ static void WorkAsyncComplete(uv_work_t *req, int status) {
*/ */
static void StringWorkAsyncComplete(uv_work_t *req, int status) { static void StringWorkAsyncComplete(uv_work_t *req, int status) {
Isolate * isolate = Isolate::GetCurrent(); /* Isolate * isolate = Isolate::GetCurrent();
v8::HandleScope handleScope(isolate); v8::HandleScope handleScope(isolate);
...@@ -241,7 +245,7 @@ static void StringWorkAsyncComplete(uv_work_t *req, int status) { ...@@ -241,7 +245,7 @@ static void StringWorkAsyncComplete(uv_work_t *req, int status) {
Local<Function>::New(isolate, work->callback)->Call(isolate->GetCurrentContext()->Global(), 1, argv); Local<Function>::New(isolate, work->callback)->Call(isolate->GetCurrentContext()->Global(), 1, argv);
work->callback.Reset(); work->callback.Reset();
delete work; delete work;*/
} }
/** /**
...@@ -249,7 +253,7 @@ static void StringWorkAsyncComplete(uv_work_t *req, int status) { ...@@ -249,7 +253,7 @@ static void StringWorkAsyncComplete(uv_work_t *req, int status) {
* function in JS. * function in JS.
*/ */
static void Float64ArrayWorkAsyncComplete(uv_work_t *req, int status) { static void Float64ArrayWorkAsyncComplete(uv_work_t *req, int status) {
/*
Isolate * isolate = Isolate::GetCurrent(); Isolate * isolate = Isolate::GetCurrent();
v8::HandleScope handleScope(isolate); v8::HandleScope handleScope(isolate);
...@@ -271,7 +275,7 @@ static void Float64ArrayWorkAsyncComplete(uv_work_t *req, int status) { ...@@ -271,7 +275,7 @@ static void Float64ArrayWorkAsyncComplete(uv_work_t *req, int status) {
Local<Function>::New(isolate, work->callback)->Call(isolate->GetCurrentContext()->Global(), 1, argv); Local<Function>::New(isolate, work->callback)->Call(isolate->GetCurrentContext()->Global(), 1, argv);
work->callback.Reset(); work->callback.Reset();
delete work; delete work;*/
} }
/** /**
...@@ -279,7 +283,7 @@ static void Float64ArrayWorkAsyncComplete(uv_work_t *req, int status) { ...@@ -279,7 +283,7 @@ static void Float64ArrayWorkAsyncComplete(uv_work_t *req, int status) {
* function in JS. * function in JS.
*/ */
static void Int32ArrayWorkAsyncComplete(uv_work_t *req, int status) { static void Int32ArrayWorkAsyncComplete(uv_work_t *req, int status) {
/*
Isolate * isolate = Isolate::GetCurrent(); Isolate * isolate = Isolate::GetCurrent();
v8::HandleScope handleScope(isolate); v8::HandleScope handleScope(isolate);
...@@ -301,56 +305,56 @@ static void Int32ArrayWorkAsyncComplete(uv_work_t *req, int status) { ...@@ -301,56 +305,56 @@ static void Int32ArrayWorkAsyncComplete(uv_work_t *req, int status) {
Local<Function>::New(isolate, work->callback)->Call(isolate->GetCurrentContext()->Global(), 1, argv); Local<Function>::New(isolate, work->callback)->Call(isolate->GetCurrentContext()->Global(), 1, argv);
work->callback.Reset(); work->callback.Reset();
delete work; delete work;*/
} }
template<typename Type, typename JSType> template<typename Type, typename JSType>
void PropertyChanged(Persistent<Function>* callback, Type value) { void PropertyChanged(Persistent<Function>* callback, Type value) {
/*
Work<Type> * work = new Work<Type>(); Work<Type> * work = new Work<Type>();
work->request.data = work; work->request.data = work;
work->callback.Reset(v8Isolate, *callback); work->callback.Reset(v8Isolate, *callback);
work->result = value; work->result = value;
uv_queue_work(uv_default_loop(), &work->request, WorkAsync, WorkAsyncComplete<Type, JSType>); uv_queue_work(uv_default_loop(), &work->request, WorkAsync, WorkAsyncComplete<Type, JSType>);*/
} }
void StringPropertyChanged(Persistent<Function>* callback, const std::string& value) { void StringPropertyChanged(Persistent<Function>* callback, const std::string& value) {
/*
Work<string> * work = new Work<string>(); Work<string> * work = new Work<string>();
work->request.data = work; work->request.data = work;
work->callback.Reset(v8Isolate, *callback); work->callback.Reset(v8Isolate, *callback);
work->result = value; work->result = value;
uv_queue_work(uv_default_loop(), &work->request, WorkAsync, StringWorkAsyncComplete); uv_queue_work(uv_default_loop(), &work->request, WorkAsync, StringWorkAsyncComplete);*/
} }
void Float64ArrayPropertyChanged(Persistent<Function>* callback, const std::vector<double>& value) { void Float64ArrayPropertyChanged(Persistent<Function>* callback, const std::vector<double>& value) {
/*
Work<std::vector<double> > * work = new Work<std::vector<double> >(); Work<std::vector<double> > * work = new Work<std::vector<double> >();
work->request.data = work; work->request.data = work;
work->callback.Reset(v8Isolate, *callback); work->callback.Reset(v8Isolate, *callback);
work->result = value; work->result = value;
uv_queue_work(uv_default_loop(), &work->request, WorkAsync, Float64ArrayWorkAsyncComplete); uv_queue_work(uv_default_loop(), &work->request, WorkAsync, Float64ArrayWorkAsyncComplete);*/
} }
void Int32ArrayPropertyChanged(Persistent<Function>* callback, const std::vector<int32_t>& value) { void Int32ArrayPropertyChanged(Persistent<Function>* callback, const std::vector<int32_t>& value) {
/*
Work<std::vector<int32_t> > * work = new Work<std::vector<int32_t> >(); Work<std::vector<int32_t> > * work = new Work<std::vector<int32_t> >();
work->request.data = work; work->request.data = work;
work->callback.Reset(v8Isolate, *callback); work->callback.Reset(v8Isolate, *callback);
work->result = value; work->result = value;
uv_queue_work(uv_default_loop(), &work->request, WorkAsync, Int32ArrayWorkAsyncComplete); uv_queue_work(uv_default_loop(), &work->request, WorkAsync, Int32ArrayWorkAsyncComplete);*/
} }
void RegisterFloat64PropertyChanged(const FunctionCallbackInfo<Value>& args) { void RegisterFloat64PropertyChanged(const FunctionCallbackInfo<Value>& args) {
/*
Isolate * isolate = args.GetIsolate(); Isolate * isolate = args.GetIsolate();
int propertyId = Local<Integer>::Cast(args[0])->Value(); int propertyId = Local<Integer>::Cast(args[0])->Value();
...@@ -362,11 +366,11 @@ void RegisterFloat64PropertyChanged(const FunctionCallbackInfo<Value>& args) { ...@@ -362,11 +366,11 @@ void RegisterFloat64PropertyChanged(const FunctionCallbackInfo<Value>& args) {
pCallback->Reset(isolate, callback); pCallback->Reset(isolate, callback);
accessor.registerFloat64PropertyChanged(propertyId, std::bind(&PropertyChanged<double, Number>, pCallback, _1)); accessor.registerFloat64PropertyChanged(propertyId, std::bind(&PropertyChanged<double, Number>, pCallback, _1));
args.GetReturnValue().Set(Undefined(isolate)); args.GetReturnValue().Set(Undefined(isolate));*/
} }
void RegisterInt32PropertyChanged(const FunctionCallbackInfo<Value>& args) { void RegisterInt32PropertyChanged(const FunctionCallbackInfo<Value>& args) {
/*
Isolate * isolate = args.GetIsolate(); Isolate * isolate = args.GetIsolate();
int propertyId = Local<Integer>::Cast(args[0])->Value(); int propertyId = Local<Integer>::Cast(args[0])->Value();
...@@ -378,11 +382,11 @@ void RegisterInt32PropertyChanged(const FunctionCallbackInfo<Value>& args) { ...@@ -378,11 +382,11 @@ void RegisterInt32PropertyChanged(const FunctionCallbackInfo<Value>& args) {
pCallback->Reset(isolate, callback); pCallback->Reset(isolate, callback);
accessor.registerInt32PropertyChanged(propertyId, std::bind(&PropertyChanged<int32_t, Integer>, pCallback, _1)); accessor.registerInt32PropertyChanged(propertyId, std::bind(&PropertyChanged<int32_t, Integer>, pCallback, _1));
args.GetReturnValue().Set(Undefined(isolate)); args.GetReturnValue().Set(Undefined(isolate));*/
} }
void RegisterBooleanPropertyChanged(const FunctionCallbackInfo<Value>& args) { void RegisterBooleanPropertyChanged(const FunctionCallbackInfo<Value>& args) {
/*
Isolate * isolate = args.GetIsolate(); Isolate * isolate = args.GetIsolate();
int propertyId = Local<Integer>::Cast(args[0])->Value(); int propertyId = Local<Integer>::Cast(args[0])->Value();
...@@ -394,11 +398,11 @@ void RegisterBooleanPropertyChanged(const FunctionCallbackInfo<Value>& args) { ...@@ -394,11 +398,11 @@ void RegisterBooleanPropertyChanged(const FunctionCallbackInfo<Value>& args) {
pCallback->Reset(isolate, callback); pCallback->Reset(isolate, callback);
accessor.registerBooleanPropertyChanged(propertyId, std::bind(&PropertyChanged<bool, Boolean>, pCallback, _1)); accessor.registerBooleanPropertyChanged(propertyId, std::bind(&PropertyChanged<bool, Boolean>, pCallback, _1));
args.GetReturnValue().Set(Undefined(isolate)); args.GetReturnValue().Set(Undefined(isolate));*/
} }
void RegisterStringPropertyChanged(const FunctionCallbackInfo<Value>& args) { void RegisterStringPropertyChanged(const FunctionCallbackInfo<Value>& args) {
/*
Isolate * isolate = args.GetIsolate(); Isolate * isolate = args.GetIsolate();
int propertyId = Local<Integer>::Cast(args[0])->Value(); int propertyId = Local<Integer>::Cast(args[0])->Value();
...@@ -410,11 +414,11 @@ void RegisterStringPropertyChanged(const FunctionCallbackInfo<Value>& args) { ...@@ -410,11 +414,11 @@ void RegisterStringPropertyChanged(const FunctionCallbackInfo<Value>& args) {
pCallback->Reset(isolate, callback); pCallback->Reset(isolate, callback);
accessor.registerStringPropertyChanged(propertyId, std::bind(&StringPropertyChanged, pCallback, _1)); accessor.registerStringPropertyChanged(propertyId, std::bind(&StringPropertyChanged, pCallback, _1));
args.GetReturnValue().Set(Undefined(isolate)); args.GetReturnValue().Set(Undefined(isolate));*/
} }
void RegisterFloat64ArrayPropertyChanged(const FunctionCallbackInfo<Value>& args) { void RegisterFloat64ArrayPropertyChanged(const FunctionCallbackInfo<Value>& args) {
/*
Isolate * isolate = args.GetIsolate(); Isolate * isolate = args.GetIsolate();
int propertyId = Local<Integer>::Cast(args[0])->Value(); int propertyId = Local<Integer>::Cast(args[0])->Value();
...@@ -426,11 +430,11 @@ void RegisterFloat64ArrayPropertyChanged(const FunctionCallbackInfo<Value>& args ...@@ -426,11 +430,11 @@ void RegisterFloat64ArrayPropertyChanged(const FunctionCallbackInfo<Value>& args
pCallback->Reset(isolate, callback); pCallback->Reset(isolate, callback);
accessor.registerFloat64ArrayPropertyChanged(propertyId, std::bind(&Float64ArrayPropertyChanged, pCallback, _1)); accessor.registerFloat64ArrayPropertyChanged(propertyId, std::bind(&Float64ArrayPropertyChanged, pCallback, _1));
args.GetReturnValue().Set(Undefined(isolate)); args.GetReturnValue().Set(Undefined(isolate));*/
} }
void RegisterInt32ArrayPropertyChanged(const FunctionCallbackInfo<Value>& args) { void RegisterInt32ArrayPropertyChanged(const FunctionCallbackInfo<Value>& args) {
/*
Isolate * isolate = args.GetIsolate(); Isolate * isolate = args.GetIsolate();
int propertyId = Local<Integer>::Cast(args[0])->Value(); int propertyId = Local<Integer>::Cast(args[0])->Value();
...@@ -442,7 +446,7 @@ void RegisterInt32ArrayPropertyChanged(const FunctionCallbackInfo<Value>& args) ...@@ -442,7 +446,7 @@ void RegisterInt32ArrayPropertyChanged(const FunctionCallbackInfo<Value>& args)
pCallback->Reset(isolate, callback); pCallback->Reset(isolate, callback);
accessor.registerInt32ArrayPropertyChanged(propertyId, std::bind(&Int32ArrayPropertyChanged, pCallback, _1)); accessor.registerInt32ArrayPropertyChanged(propertyId, std::bind(&Int32ArrayPropertyChanged, pCallback, _1));
args.GetReturnValue().Set(Undefined(isolate)); args.GetReturnValue().Set(Undefined(isolate));*/
} }
/** /**
......
...@@ -47,11 +47,11 @@ void Init(const FunctionCallbackInfo<Value>& args) { ...@@ -47,11 +47,11 @@ void Init(const FunctionCallbackInfo<Value>& args) {
v8Isolate = args.GetIsolate(); v8Isolate = args.GetIsolate();
// Local endpoint. // Local endpoint.
v8::String::Utf8Value param1(args[0]->ToString()); v8::String::Utf8Value param1(v8Isolate, args[0]);
string localEndpoint(*param1); string localEndpoint(*param1);
// Nomad endpoint. // Nomad endpoint.
v8::String::Utf8Value param2(args[1]->ToString()); v8::String::Utf8Value param2(v8Isolate, args[1]);
string nomadEndpoint(*param2); string nomadEndpoint(*param2);
// Init the app if it is not already done. // Init the app if it is not already done.
...@@ -112,7 +112,7 @@ void GetData(const FunctionCallbackInfo<Value>& args) { ...@@ -112,7 +112,7 @@ void GetData(const FunctionCallbackInfo<Value>& args) {
string response; string response;
requester->receive(response); requester->receive(response);
args.GetReturnValue().Set(String::NewFromUtf8(args.GetIsolate(), response.c_str())); args.GetReturnValue().Set(String::NewFromUtf8(args.GetIsolate(), response.c_str()).ToLocalChecked());
} }
/** /**
......
...@@ -18,6 +18,7 @@ using v8::Integer; ...@@ -18,6 +18,7 @@ using v8::Integer;
using v8::Boolean; using v8::Boolean;
using v8::Array; using v8::Array;
using v8::Persistent; using v8::Persistent;
using v8::Context;
// the native vexp library // the native vexp library
...@@ -36,7 +37,7 @@ void createSqwTree(const FunctionCallbackInfo<Value>& args) { ...@@ -36,7 +37,7 @@ void createSqwTree(const FunctionCallbackInfo<Value>& args) {
if(args.Length() != 0) { if(args.Length() != 0) {
auto str = String::NewFromUtf8(iso, "createSqwTree takes no arguments"); auto str = String::NewFromUtf8(iso, "createSqwTree takes no arguments");
iso->ThrowException(Exception::TypeError(str)); iso->ThrowException(Exception::TypeError(str.ToLocalChecked()));
return; return;
} }
...@@ -53,11 +54,11 @@ void removeSqwTree(const FunctionCallbackInfo<Value>& args) { ...@@ -53,11 +54,11 @@ void removeSqwTree(const FunctionCallbackInfo<Value>& args) {
if(args.Length() != 1 || !args[0]->IsInt32()) { if(args.Length() != 1 || !args[0]->IsInt32()) {
auto str = String::NewFromUtf8(iso, "removeSqwTree takes one argument: the tree handle"); auto str = String::NewFromUtf8(iso, "removeSqwTree takes one argument: the tree handle");
iso->ThrowException(Exception::TypeError(str)); iso->ThrowException(Exception::TypeError(str.ToLocalChecked()));
return; return;
} }
int handle = args[0]->Int32Value(); int handle = Local<Integer>::Cast(args[0])->Value();
accessor.removeSqwTree(handle); accessor.removeSqwTree(handle);
} }
...@@ -70,11 +71,11 @@ void clearSqwTree(const FunctionCallbackInfo<Value>& args) { ...@@ -70,11 +71,11 @@ void clearSqwTree(const FunctionCallbackInfo<Value>& args) {
if(args.Length() != 1 || !args[0]->IsInt32()) { if(args.Length() != 1 || !args[0]->IsInt32()) {
auto str = String::NewFromUtf8(iso, "clearSqwTree takes one argument: the tree handle"); auto str = String::NewFromUtf8(iso, "clearSqwTree takes one argument: the tree handle");
iso->ThrowException(Exception::TypeError(str)); iso->ThrowException(Exception::TypeError(str.ToLocalChecked()));
return; return;
} }
int handle = args[0]->Int32Value(); int handle = Local<Integer>::Cast(args[0])->Value();
accessor.clearSqwTree(handle); accessor.clearSqwTree(handle);
} }
...@@ -88,17 +89,17 @@ void addSqwValue(const FunctionCallbackInfo<Value>& args) { ...@@ -88,17 +89,17 @@ void addSqwValue(const FunctionCallbackInfo<Value>& args) {
if(args.Length() != 6 || !args[0]->IsInt32() || if(args.Length() != 6 || !args[0]->IsInt32() ||
!args[1]->IsNumber() || !args[2]->IsNumber() || !args[3]->IsNumber() || !args[4]->IsNumber() || !args[5]->IsNumber()) { !args[1]->IsNumber() || !args[2]->IsNumber() || !args[3]->IsNumber() || !args[4]->IsNumber() || !args[5]->IsNumber()) {
auto str = String::NewFromUtf8(iso, "addSqwValue takes six arguments: the tree handle and h, k, l, E, S"); auto str = String::NewFromUtf8(iso, "addSqwValue takes six arguments: the tree handle and h, k, l, E, S");
iso->ThrowException(Exception::TypeError(str)); iso->ThrowException(Exception::TypeError(str.ToLocalChecked()));
return; return;
} }
int handle = args[0]->Int32Value(); int handle = Local<Integer>::Cast(args[0])->Value();
double h = args[1]->NumberValue(); double h = Local<Number>::Cast(args[1])->Value();
double k = args[2]->NumberValue(); double k = Local<Number>::Cast(args[2])->Value();
double l = args[3]->NumberValue(); double l = Local<Number>::Cast(args[3])->Value();
double E = args[4]->NumberValue(); double E = Local<Number>::Cast(args[4])->Value();
double S = args[5]->NumberValue(); double S = Local<Number>::Cast(args[5])->Value();
accessor.addSqwValue(handle, h, k, l, E, S); accessor.addSqwValue(handle, h, k, l, E, S);
} }
...@@ -112,14 +113,15 @@ void loadSqwTable(const FunctionCallbackInfo<Value>& args) { ...@@ -112,14 +113,15 @@ void loadSqwTable(const FunctionCallbackInfo<Value>& args) {
if(args.Length() != 2 || !args[0]->IsInt32() || !args[1]->IsString()) { if(args.Length() != 2 || !args[0]->IsInt32() || !args[1]->IsString()) {
auto str = String::NewFromUtf8(iso, "loadSqwTable takes two arguments: the tree handle and the file name"); auto str = String::NewFromUtf8(iso, "loadSqwTable takes two arguments: the tree handle and the file name");
iso->ThrowException(Exception::TypeError(str)); iso->ThrowException(Exception::TypeError(str.ToLocalChecked()));
return; return;
} }
int handle = args[0]->Int32Value(); int handle = Local<Integer>::Cast(args[0])->Value();