summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorasanoaozora <fifitaneki@hotmail.com>2016-06-07 18:00:24 +0200
committerasanoaozora <fifitaneki@hotmail.com>2016-06-07 18:00:24 +0200
commit3e757d93f5f525e7278834397112c7028231c3ff (patch)
tree8ef707679f02f419b2257280933650a050e2fc15
parent5c53c08a85ac2f953f986cf21023a938fb77c385 (diff)
downloadnavigation-3e757d93f5f525e7278834397112c7028231c3ff.tar.gz
update the HTML panel to align with nodejs 4.2.6 (in progress)
-rw-r--r--test/html-based-panel/node-cpp-lbs-modules/FuelStopAdvisorWrapper.cpp241
-rw-r--r--test/html-based-panel/node-cpp-lbs-modules/FuelStopAdvisorWrapper.hpp26
-rw-r--r--test/html-based-panel/node-cpp-lbs-modules/Makefile2
-rw-r--r--test/html-based-panel/node-cpp-lbs-modules/NavigationCoreWrapper.cpp182
-rw-r--r--test/html-based-panel/node-cpp-lbs-modules/NavigationCoreWrapper.hpp18
-rw-r--r--test/html-based-panel/node-cpp-lbs-modules/PositioningEnhancedPositionWrapper.cpp151
-rw-r--r--test/html-based-panel/node-cpp-lbs-modules/PositioningEnhancedPositionWrapper.hpp14
-rw-r--r--test/html-based-panel/node-cpp-lbs-modules/package.json3
-rw-r--r--test/html-based-panel/server.js2
-rw-r--r--test/html-based-panel/simulation-panel.html2
-rw-r--r--test/html-based-panel/viewer-panel.html2
11 files changed, 354 insertions, 289 deletions
diff --git a/test/html-based-panel/node-cpp-lbs-modules/FuelStopAdvisorWrapper.cpp b/test/html-based-panel/node-cpp-lbs-modules/FuelStopAdvisorWrapper.cpp
index 640bc42..3a8fa80 100644
--- a/test/html-based-panel/node-cpp-lbs-modules/FuelStopAdvisorWrapper.cpp
+++ b/test/html-based-panel/node-cpp-lbs-modules/FuelStopAdvisorWrapper.cpp
@@ -31,132 +31,135 @@
using namespace std;
-v8::Persistent<v8::FunctionTemplate> FuelStopAdvisorWrapper::constructor;
+v8::Persistent<v8::Function> FuelStopAdvisorWrapper::constructor;
v8::Persistent<v8::Function> FuelStopAdvisorWrapper::signalTripDataUpdated;
void FuelStopAdvisorWrapper::TripDataUpdated(const uint8_t& number)
{
- v8::HandleScope scope();
-
+ v8::Isolate* isolate = v8::Isolate::GetCurrent();
+ v8::HandleScope handleScope(isolate);
const unsigned argc = 1;
v8::Local<v8::Value> argv[argc];
- argv[0]=v8::Local<v8::Value>::New(v8::Integer::New(number));
+ argv[0]=v8::Local<v8::Value>::New(isolate,v8::Integer::New(isolate,number));
- v8::Persistent<v8::Function> fct = static_cast<v8::Function*>(*signalTripDataUpdated);
- fct->Call(v8::Context::GetCurrent()->Global(), argc, argv);
+ v8::Local<v8::Function> fct = v8::Local<v8::Function>::New(isolate,signalTripDataUpdated);
+ fct->Call(isolate->GetCurrentContext()->Global(), argc, argv);
}
-v8::Handle<v8::Value> FuelStopAdvisorWrapper::SetTripDataUpdatedListener(const v8::Arguments& args)
+void FuelStopAdvisorWrapper::SetTripDataUpdatedListener(const v8::FunctionCallbackInfo<v8::Value> &args)
{
- v8::HandleScope scope; //to properly clean up v8 handles
+ v8::Isolate* isolate = args.GetIsolate();
if (!args[0]->IsFunction()) {
- return v8::ThrowException(
- v8::Exception::TypeError(v8::String::New("Requires a function as parameter"))
+ isolate->ThrowException(
+ v8::Exception::TypeError(v8::String::NewFromUtf8(isolate,"Requires a function as parameter"))
);
}
+ v8::Local<v8::Function> fct = v8::Local<v8::Function>::Cast(args[0]);
+ v8::Persistent<v8::Function> persfct(isolate,fct);
+ signalTripDataUpdated.Reset(isolate,persfct);;
- signalTripDataUpdated = v8::Persistent<v8::Function>::New(v8::Handle<v8::Function>::Cast(args[0]));
-
- v8::Local<v8::Object> ret = v8::Object::New();
- ret->Set( 0, v8::Boolean::New(signalTripDataUpdated->IsFunction()) );
+ v8::Local<v8::Object> ret = v8::Object::New(isolate);
+ ret->Set( 0, v8::Boolean::New(isolate, v8::True) );
- return scope.Close(ret);
+ args.GetReturnValue().Set(ret);
}
v8::Persistent<v8::Function> FuelStopAdvisorWrapper::signalFuelStopAdvisorWarning;
void FuelStopAdvisorWrapper::FuelStopAdvisorWarning(const bool &destinationCantBeReached)
{
- v8::HandleScope scope;
-
+ v8::Isolate* isolate = v8::Isolate::GetCurrent();
+ v8::HandleScope handleScope(isolate);
const unsigned argc = 1;
v8::Local<v8::Value> argv[argc];
- argv[0]=v8::Local<v8::Value>::New(v8::Boolean::New(destinationCantBeReached));
+ argv[0]=v8::Local<v8::Value>::New(isolate,v8::Boolean::New(isolate,destinationCantBeReached));
- v8::Persistent<v8::Function> fct = static_cast<v8::Function*>(*signalFuelStopAdvisorWarning);
- fct->Call(v8::Context::GetCurrent()->Global(), argc, argv);
+ v8::Local<v8::Function> fct= v8::Local<v8::Function>::New(isolate,signalFuelStopAdvisorWarning);
+ fct->Call(isolate->GetCurrentContext()->Global(), argc, argv);
}
-v8::Handle<v8::Value> FuelStopAdvisorWrapper::SetFuelStopAdvisorWarningListener(const v8::Arguments& args)
+void FuelStopAdvisorWrapper::SetFuelStopAdvisorWarningListener(const v8::FunctionCallbackInfo<v8::Value> &args)
{
- v8::HandleScope scope; //to properly clean up v8 handles
+ v8::Isolate* isolate = args.GetIsolate();
if (!args[0]->IsFunction()) {
- return v8::ThrowException(
- v8::Exception::TypeError(v8::String::New("Requires a function as parameter"))
+ isolate->ThrowException(
+ v8::Exception::TypeError(v8::String::NewFromUtf8(isolate,"Requires a function as parameter"))
);
}
+ v8::Local<v8::Function> fct = v8::Local<v8::Function>::Cast(args[0]);
+ v8::Persistent<v8::Function> persfct(isolate,fct);
+ signalFuelStopAdvisorWarning.Reset(isolate,persfct);;
- signalFuelStopAdvisorWarning = v8::Persistent<v8::Function>::New(v8::Handle<v8::Function>::Cast(args[0]));
+ v8::Local<v8::Object> ret = v8::Object::New(isolate);
+ ret->Set( 0, v8::Boolean::New(isolate, v8::True) );
- v8::Local<v8::Object> ret = v8::Object::New();
- ret->Set( 0, v8::Boolean::New(signalFuelStopAdvisorWarning->IsFunction()) );
-
- return scope.Close(ret);
+ args.GetReturnValue().Set(ret);
}
v8::Persistent<v8::Function> FuelStopAdvisorWrapper::signalTripDataResetted;
void FuelStopAdvisorWrapper::TripDataResetted(const uint8_t& number)
{
- v8::HandleScope scope;
-
+ v8::Isolate* isolate = v8::Isolate::GetCurrent();
+ v8::HandleScope handleScope(isolate);
const unsigned argc = 1;
v8::Local<v8::Value> argv[argc];
- argv[0]=v8::Local<v8::Value>::New(v8::Integer::New(number));
+ argv[0]=v8::Local<v8::Value>::New(isolate,v8::Integer::New(isolate,number));
- v8::Persistent<v8::Function> fct = static_cast<v8::Function*>(*signalTripDataResetted);
- fct->Call(v8::Context::GetCurrent()->Global(), argc, argv);
+ v8::Local<v8::Function> fct= v8::Local<v8::Function>::New(isolate,signalTripDataResetted);
+ fct->Call(isolate->GetCurrentContext()->Global(), argc, argv);
}
-v8::Handle<v8::Value> FuelStopAdvisorWrapper::SetTripDataResettedListener(const v8::Arguments& args)
+void FuelStopAdvisorWrapper::SetTripDataResettedListener(const v8::FunctionCallbackInfo<v8::Value> &args)
{
- v8::HandleScope scope; //to properly clean up v8 handles
+ v8::Isolate* isolate = args.GetIsolate();
if (!args[0]->IsFunction()) {
- return v8::ThrowException(
- v8::Exception::TypeError(v8::String::New("Requires a function as parameter"))
+ isolate->ThrowException(
+ v8::Exception::TypeError(v8::String::NewFromUtf8(isolate,"Requires a function as parameter"))
);
}
- signalTripDataResetted = v8::Persistent<v8::Function>::New(v8::Handle<v8::Function>::Cast(args[0]));
+ v8::Local<v8::Function> fct = v8::Local<v8::Function>::Cast(args[0]);
+ v8::Persistent<v8::Function> persfct(isolate,fct);
+ signalTripDataResetted.Reset(isolate,persfct);;
- v8::Local<v8::Object> ret = v8::Object::New();
- ret->Set( 0, v8::Boolean::New(signalTripDataResetted->IsFunction()) );
+ v8::Local<v8::Object> ret = v8::Object::New(isolate);
+ ret->Set( 0, v8::Boolean::New(isolate, v8::True) );
- return scope.Close(ret);
+ args.GetReturnValue().Set(ret);
}
-void FuelStopAdvisorWrapper::Init(v8::Handle<v8::Object> target) {
- v8::HandleScope scope;
+void FuelStopAdvisorWrapper::Init(v8::Local<v8::Object> target) {
+ v8::Isolate* isolate = target->GetIsolate();
- v8::Local<v8::FunctionTemplate> tpl = v8::FunctionTemplate::New(New);
- v8::Local<v8::String> name = v8::String::NewSymbol("FuelStopAdvisorWrapper");
-
- constructor = v8::Persistent<v8::FunctionTemplate>::New(tpl);
- // ObjectWrap uses the first internal field to store the wrapped pointer.
- constructor->InstanceTemplate()->SetInternalFieldCount(1);
- constructor->SetClassName(name);
+ // Prepare constructor template
+ v8::Local<v8::FunctionTemplate> tpl = v8::FunctionTemplate::New(isolate, New);
+ tpl->SetClassName(v8::String::NewFromUtf8(isolate, "FuelStopAdvisorWrapper"));
+ tpl->InstanceTemplate()->SetInternalFieldCount(1);
// Add all prototype methods, getters and setters here.
- NODE_SET_PROTOTYPE_METHOD(constructor, "getVersion", GetVersion);
- NODE_SET_PROTOTYPE_METHOD(constructor, "getInstantData", GetInstantData);
- NODE_SET_PROTOTYPE_METHOD(constructor, "setTripDataUpdatedListener", SetTripDataUpdatedListener);
- NODE_SET_PROTOTYPE_METHOD(constructor, "setFuelStopAdvisorWarningListener", SetFuelStopAdvisorWarningListener);
- NODE_SET_PROTOTYPE_METHOD(constructor, "setTripDataResettedListener", SetTripDataResettedListener);
- NODE_SET_PROTOTYPE_METHOD(constructor, "getSpeed", GetSpeed);
- NODE_SET_PROTOTYPE_METHOD(constructor, "getLevel", GetLevel);
- NODE_SET_PROTOTYPE_METHOD(constructor, "getInstantConsumption", GetInstantConsumption);
- NODE_SET_PROTOTYPE_METHOD(constructor, "getOdometer", GetOdometer);
+ NODE_SET_PROTOTYPE_METHOD(tpl, "getVersion", GetVersion);
+ NODE_SET_PROTOTYPE_METHOD(tpl, "getInstantData", GetInstantData);
+ NODE_SET_PROTOTYPE_METHOD(tpl, "setTripDataUpdatedListener", SetTripDataUpdatedListener);
+ NODE_SET_PROTOTYPE_METHOD(tpl, "setFuelStopAdvisorWarningListener", SetFuelStopAdvisorWarningListener);
+ NODE_SET_PROTOTYPE_METHOD(tpl, "setTripDataResettedListener", SetTripDataResettedListener);
+ NODE_SET_PROTOTYPE_METHOD(tpl, "getSpeed", GetSpeed);
+ NODE_SET_PROTOTYPE_METHOD(tpl, "getLevel", GetLevel);
+ NODE_SET_PROTOTYPE_METHOD(tpl, "getInstantConsumption", GetInstantConsumption);
+ NODE_SET_PROTOTYPE_METHOD(tpl, "getOdometer", GetOdometer);
// This has to be last, otherwise the properties won't show up on the
// object in JavaScript.
- target->Set(name, constructor->GetFunction());
+ constructor.Reset(isolate, tpl->GetFunction());
+ target->Set(v8::String::NewFromUtf8(isolate, "FuelStopAdvisorWrapper"),
+ tpl->GetFunction());
}
FuelStopAdvisorWrapper::FuelStopAdvisorWrapper() {
@@ -165,44 +168,60 @@ FuelStopAdvisorWrapper::FuelStopAdvisorWrapper() {
FuelStopAdvisorWrapper::~FuelStopAdvisorWrapper() {
}
-v8::Handle<v8::Value> FuelStopAdvisorWrapper::New(const v8::Arguments& args) {
- v8::HandleScope scope;
-
- if (!args.IsConstructCall()) {
- return v8::ThrowException(v8::Exception::TypeError(
- v8::String::New("Use the new operator to create instances of this object."))
- );
+void FuelStopAdvisorWrapper::New(const v8::FunctionCallbackInfo<v8::Value> &args) {
+ v8::Isolate* isolate = args.GetIsolate();
+
+ if (args.IsConstructCall()) {
+ // Invoked as constructor: `new MyObject(...)`
+// double value = args[0]->IsUndefined() ? 0 : args[0]->NumberValue(); //no parameters
+ FuelStopAdvisorWrapper* obj = new FuelStopAdvisorWrapper();
+ obj->Wrap(args.This());
+ args.GetReturnValue().Set(args.This());
+ DemonstratorProxy* proxy = new DemonstratorProxy(obj);
+ obj->mp_demonstratorProxy = proxy;
+ } else { // not tested yet
+ // Invoked as plain function `MyObject(...)`, turn into construct call.
+ const int argc = 1;
+ v8::Local<v8::Value> argv[argc] = { args[0] };
+ v8::Local<v8::Context> context = isolate->GetCurrentContext();
+ v8::Local<v8::Function> cons = v8::Local<v8::Function>::New(isolate, constructor);
+ v8::Local<v8::Object> result = cons->NewInstance(context, argc, argv).ToLocalChecked();
+ args.GetReturnValue().Set(result);
}
+}
- // Creates a new instance object of this type and wraps it.
- FuelStopAdvisorWrapper* obj = new FuelStopAdvisorWrapper();
+void FuelStopAdvisorWrapper::NewInstance(const v8::FunctionCallbackInfo<v8::Value>& args) {
+ v8::Isolate* isolate = args.GetIsolate();
- DemonstratorProxy* proxy = new DemonstratorProxy(obj);
- obj->mp_demonstratorProxy = proxy;
- obj->Wrap(args.This());
+ const unsigned argc = 1;
+ v8::Local<v8::Value> argv[argc] = { args[0] };
+ v8::Local<v8::Function> cons = v8::Local<v8::Function>::New(isolate, constructor);
+ v8::Local<v8::Context> context = isolate->GetCurrentContext();
+ v8::Local<v8::Object> instance =
+ cons->NewInstance(context, argc, argv).ToLocalChecked();
- return args.This();
+ args.GetReturnValue().Set(instance);
}
-v8::Handle<v8::Value> FuelStopAdvisorWrapper::GetVersion(const v8::Arguments& args) {
- v8::HandleScope scope; //to properly clean up v8 handles
+void FuelStopAdvisorWrapper::GetVersion(const v8::FunctionCallbackInfo<v8::Value> &args) {
+ v8::Isolate* isolate = args.GetIsolate();
// Retrieves the pointer to the wrapped object instance.
FuelStopAdvisorWrapper* obj = ObjectWrap::Unwrap<FuelStopAdvisorWrapper>(args.This());
::DBus::Struct< uint16_t, uint16_t, uint16_t, std::string > DBus_version = obj->mp_demonstratorProxy->mp_fuelStopAdvisorProxy->GetVersion();
- v8::Local<v8::Object> ret = v8::Object::New();
- ret->Set( 0, v8::Int32::New(DBus_version._1) );
- ret->Set( 1, v8::Int32::New(DBus_version._2) );
- ret->Set( 2, v8::Int32::New(DBus_version._3) );
- ret->Set( 3, v8::String::New(DBus_version._4.c_str()) );
+ v8::Local<v8::Object> ret = v8::Object::New(isolate);
+ ret->Set( 0, v8::Int32::New(isolate,DBus_version._1) );
+ ret->Set( 1, v8::Int32::New(isolate,DBus_version._2) );
+ ret->Set( 2, v8::Int32::New(isolate,DBus_version._3) );
+ ret->Set( 3, v8::String::NewFromUtf8(isolate,DBus_version._4.c_str()) );
- return scope.Close(ret);
+ args.GetReturnValue().Set(ret);
}
-v8::Handle<v8::Value> FuelStopAdvisorWrapper::GetInstantData(const v8::Arguments& args) {
- v8::HandleScope scope; //to properly clean up v8 handles
+void FuelStopAdvisorWrapper::GetInstantData(const v8::FunctionCallbackInfo<v8::Value> &args) {
+ v8::Isolate* isolate = args.GetIsolate();
// Retrieves the pointer to the wrapped object instance.
FuelStopAdvisorWrapper* obj = ObjectWrap::Unwrap<FuelStopAdvisorWrapper>(args.This());
@@ -210,26 +229,26 @@ v8::Handle<v8::Value> FuelStopAdvisorWrapper::GetInstantData(const v8::Arguments
std::map< uint16_t, ::DBus::Variant > instant_data = obj->mp_demonstratorProxy->mp_fuelStopAdvisorProxy->GetInstantData();
- v8::Local<v8::Array> ret = v8::Array::New();
+ v8::Local<v8::Array> ret = v8::Array::New(isolate);
for (std::map< uint16_t, ::DBus::Variant >::iterator iter = instant_data.begin(); iter != instant_data.end(); iter++) {
- v8::Local<v8::Object> data = v8::Object::New();
+ v8::Local<v8::Object> data = v8::Object::New(isolate);
::DBus::Variant value = iter->second;
printf("GetInstantData%d\n",iter->first);
printf("GetInstantData%s\n",value.signature().c_str());
- data->Set(v8::String::New("key"), v8::Uint32::New(iter->first));
+ data->Set(v8::String::NewFromUtf8(isolate,"key"), v8::Uint32::New(isolate,iter->first));
switch (iter->first) {
case GENIVI_FUELSTOPADVISOR_FUEL_LEVEL:
- data->Set(v8::String::New("value"), v8::Int32::New(15));
+ data->Set(v8::String::NewFromUtf8(isolate,"value"), v8::Int32::New(isolate,15));
break;
case GENIVI_FUELSTOPADVISOR_INSTANT_FUEL_CONSUMPTION_PER_DISTANCE:
- data->Set(v8::String::New("value"), v8::Int32::New(55));
+ data->Set(v8::String::NewFromUtf8(isolate,"value"), v8::Int32::New(isolate,55));
break;
case GENIVI_FUELSTOPADVISOR_TANK_DISTANCE:
- data->Set(v8::String::New("value"), v8::Int32::New(300));
+ data->Set(v8::String::NewFromUtf8(isolate,"value"), v8::Int32::New(isolate,300));
break;
case GENIVI_FUELSTOPADVISOR_ENHANCED_TANK_DISTANCE:
- data->Set(v8::String::New("value"), v8::Int32::New(400));
+ data->Set(v8::String::NewFromUtf8(isolate,"value"), v8::Int32::New(isolate,400));
break;
default:
break;
@@ -237,22 +256,22 @@ v8::Handle<v8::Value> FuelStopAdvisorWrapper::GetInstantData(const v8::Arguments
ret->Set(ret->Length(), data);
}
- return scope.Close(ret);
+ args.GetReturnValue().Set(ret);
}
-v8::Handle<v8::Value> FuelStopAdvisorWrapper::GetSpeed(const v8::Arguments& args) {
- v8::HandleScope scope; //to properly clean up v8 handles
+void FuelStopAdvisorWrapper::GetSpeed(const v8::FunctionCallbackInfo<v8::Value> &args) {
+ v8::Isolate* isolate = args.GetIsolate();
// Retrieves the pointer to the wrapped object instance.
FuelStopAdvisorWrapper* obj = ObjectWrap::Unwrap<FuelStopAdvisorWrapper>(args.This());
- v8::Local<v8::Object> ret = v8::Object::New();
+ v8::Local<v8::Object> ret = v8::Object::New(isolate);
- return scope.Close(ret);
+ args.GetReturnValue().Set(ret);
}
-v8::Handle<v8::Value> FuelStopAdvisorWrapper::GetLevel(const v8::Arguments& args) {
- v8::HandleScope scope; //to properly clean up v8 handles
+void FuelStopAdvisorWrapper::GetLevel(const v8::FunctionCallbackInfo<v8::Value> &args) {
+ v8::Isolate* isolate = args.GetIsolate();
// Retrieves the pointer to the wrapped object instance.
FuelStopAdvisorWrapper* obj = ObjectWrap::Unwrap<FuelStopAdvisorWrapper>(args.This());
@@ -262,14 +281,14 @@ v8::Handle<v8::Value> FuelStopAdvisorWrapper::GetLevel(const v8::Arguments& args
uint16_t level;
it >> level;
- v8::Local<v8::Object> ret = v8::Object::New();
- ret->Set( 0, v8::Uint32::New(level) );
+ v8::Local<v8::Object> ret = v8::Object::New(isolate);
+ ret->Set( 0, v8::Uint32::New(isolate, level) );
- return scope.Close(ret);
+ args.GetReturnValue().Set(ret);
}
-v8::Handle<v8::Value> FuelStopAdvisorWrapper::GetInstantConsumption(const v8::Arguments& args) {
- v8::HandleScope scope; //to properly clean up v8 handles
+void FuelStopAdvisorWrapper::GetInstantConsumption(const v8::FunctionCallbackInfo<v8::Value> &args) {
+ v8::Isolate* isolate = args.GetIsolate();
// Retrieves the pointer to the wrapped object instance.
FuelStopAdvisorWrapper* obj = ObjectWrap::Unwrap<FuelStopAdvisorWrapper>(args.This());
@@ -279,21 +298,21 @@ v8::Handle<v8::Value> FuelStopAdvisorWrapper::GetInstantConsumption(const v8::Ar
uint32_t consumption;
it >> consumption;
- v8::Local<v8::Object> ret = v8::Object::New();
- ret->Set( 0, v8::Uint32::New(consumption) );
+ v8::Local<v8::Object> ret = v8::Object::New(isolate);
+ ret->Set( 0, v8::Uint32::New(isolate,consumption) );
- return scope.Close(ret);
+ args.GetReturnValue().Set(ret);
}
-v8::Handle<v8::Value> FuelStopAdvisorWrapper::GetOdometer(const v8::Arguments& args) {
- v8::HandleScope scope; //to properly clean up v8 handles
+void FuelStopAdvisorWrapper::GetOdometer(const v8::FunctionCallbackInfo<v8::Value> &args) {
+ v8::Isolate* isolate = args.GetIsolate();
// Retrieves the pointer to the wrapped object instance.
FuelStopAdvisorWrapper* obj = ObjectWrap::Unwrap<FuelStopAdvisorWrapper>(args.This());
- v8::Local<v8::Object> ret = v8::Object::New();
+ v8::Local<v8::Object> ret = v8::Object::New(isolate);
- return scope.Close(ret);
+ args.GetReturnValue().Set(ret);
}
@@ -302,4 +321,4 @@ void RegisterModule(v8::Handle<v8::Object> target) {
FuelStopAdvisorWrapper::Init(target);
}
-NODE_MODULE(FuelStopAdvisorWrapper, RegisterModule);
+NODE_MODULE(FuelStopAdvisorWrapper, RegisterModule)
diff --git a/test/html-based-panel/node-cpp-lbs-modules/FuelStopAdvisorWrapper.hpp b/test/html-based-panel/node-cpp-lbs-modules/FuelStopAdvisorWrapper.hpp
index c01d1cf..23da191 100644
--- a/test/html-based-panel/node-cpp-lbs-modules/FuelStopAdvisorWrapper.hpp
+++ b/test/html-based-panel/node-cpp-lbs-modules/FuelStopAdvisorWrapper.hpp
@@ -31,6 +31,7 @@
#include <node.h>
#include <node_buffer.h>
+#include <node_object_wrap.h>
#include "./dbus-proxies/DemonstratorProxy.hpp"
@@ -49,8 +50,9 @@ class FuelStopAdvisorWrapper : public node::ObjectWrap {
friend void DemonstratorProxy::FuelStopAdvisorWarning(const bool &destinationCantBeReached);
public:
- static v8::Persistent<v8::FunctionTemplate> constructor;
- static void Init(v8::Handle<v8::Object> target);
+ static v8::Persistent<v8::Function> constructor;
+ static void Init(v8::Local<v8::Object> target);
+ static void NewInstance(const v8::FunctionCallbackInfo<v8::Value>& args);
static v8::Persistent<v8::Function> signalTripDataUpdated;
static v8::Persistent<v8::Function> signalFuelStopAdvisorWarning;
static v8::Persistent<v8::Function> signalTripDataResetted;
@@ -59,21 +61,21 @@ protected:
FuelStopAdvisorWrapper();
~FuelStopAdvisorWrapper();
- static v8::Handle<v8::Value> New(const v8::Arguments& args);
- static v8::Handle<v8::Value> GetVersion(const v8::Arguments& args);
- static v8::Handle<v8::Value> GetInstantData(const v8::Arguments& args);
+ static void New(const v8::FunctionCallbackInfo<v8::Value> &args);
+ static void GetVersion(const v8::FunctionCallbackInfo<v8::Value> &args);
+ static void GetInstantData(const v8::FunctionCallbackInfo<v8::Value> &args);
- static v8::Handle<v8::Value> SetTripDataResettedListener(const v8::Arguments& args);
+ static void SetTripDataResettedListener(const v8::FunctionCallbackInfo<v8::Value> &args);
void TripDataResetted(const uint8_t& number);
- static v8::Handle<v8::Value> SetTripDataUpdatedListener(const v8::Arguments& args);
+ static void SetTripDataUpdatedListener(const v8::FunctionCallbackInfo<v8::Value> &args);
void TripDataUpdated(const uint8_t& number);
- static v8::Handle<v8::Value> SetFuelStopAdvisorWarningListener(const v8::Arguments& args);
+ static void SetFuelStopAdvisorWarningListener(const v8::FunctionCallbackInfo<v8::Value> &args);
void FuelStopAdvisorWarning(const bool& destinationCantBeReached);
- static v8::Handle<v8::Value> GetSpeed(const v8::Arguments& args);
- static v8::Handle<v8::Value> GetLevel(const v8::Arguments& args);
- static v8::Handle<v8::Value> GetInstantConsumption(const v8::Arguments& args);
- static v8::Handle<v8::Value> GetOdometer(const v8::Arguments& args);
+ static void GetSpeed(const v8::FunctionCallbackInfo<v8::Value> &args);
+ static void GetLevel(const v8::FunctionCallbackInfo<v8::Value> &args);
+ static void GetInstantConsumption(const v8::FunctionCallbackInfo<v8::Value> &args);
+ static void GetOdometer(const v8::FunctionCallbackInfo<v8::Value> &args);
private:
DemonstratorProxy* mp_demonstratorProxy;
diff --git a/test/html-based-panel/node-cpp-lbs-modules/Makefile b/test/html-based-panel/node-cpp-lbs-modules/Makefile
index 9916ec3..4423713 100644
--- a/test/html-based-panel/node-cpp-lbs-modules/Makefile
+++ b/test/html-based-panel/node-cpp-lbs-modules/Makefile
@@ -1,4 +1,4 @@
-all: clean configure.release build pack install
+all: clean configure.release build pack
release: configure.release build pack install
diff --git a/test/html-based-panel/node-cpp-lbs-modules/NavigationCoreWrapper.cpp b/test/html-based-panel/node-cpp-lbs-modules/NavigationCoreWrapper.cpp
index d06a7d6..90fc7d0 100644
--- a/test/html-based-panel/node-cpp-lbs-modules/NavigationCoreWrapper.cpp
+++ b/test/html-based-panel/node-cpp-lbs-modules/NavigationCoreWrapper.cpp
@@ -29,95 +29,98 @@
#include "NavigationCoreWrapper.hpp"
-v8::Persistent<v8::FunctionTemplate> NavigationCoreWrapper::constructor;
+v8::Persistent<v8::Function> NavigationCoreWrapper::constructor;
v8::Persistent<v8::Function> NavigationCoreWrapper::signalGuidanceStatusChanged;
v8::Persistent<v8::Function> NavigationCoreWrapper::signalSimulationStatusChanged;
void NavigationCoreWrapper::GuidanceStatusChanged(const int32_t& guidanceStatus, const uint32_t& routeHandle)
{
- v8::HandleScope scope();
+ v8::Isolate* isolate = v8::Isolate::GetCurrent();
const unsigned argc = 2;
v8::Local<v8::Value> argv[argc];
- argv[0]=v8::Local<v8::Value>::New(v8::Int32::New(guidanceStatus));
- argv[1]=v8::Local<v8::Value>::New(v8::Uint32::New(routeHandle));
+ argv[0]=v8::Local<v8::Value>::New(isolate,v8::Int32::New(isolate,guidanceStatus));
+ argv[1]=v8::Local<v8::Value>::New(isolate,v8::Uint32::New(isolate,routeHandle));
- v8::Persistent<v8::Function> fct = static_cast<v8::Function*>(*signalGuidanceStatusChanged);
- fct->Call(v8::Context::GetCurrent()->Global(), argc, argv);
+ v8::Local<v8::Function> fct;
+ fct.New(isolate,signalGuidanceStatusChanged);
+ fct->Call(isolate->GetCurrentContext()->Global(), argc, argv);
}
-v8::Handle<v8::Value> NavigationCoreWrapper::SetGuidanceStatusChangedListener(const v8::Arguments& args)
+void NavigationCoreWrapper::SetGuidanceStatusChangedListener(const v8::FunctionCallbackInfo<v8::Value> &args)
{
- v8::HandleScope scope; //to properly clean up v8 handles
+ v8::Isolate* isolate = args.GetIsolate();
if (!args[0]->IsFunction()) {
- return v8::ThrowException(
- v8::Exception::TypeError(v8::String::New("Requires a function as parameter"))
+ isolate->ThrowException(
+ v8::Exception::TypeError(v8::String::NewFromUtf8(isolate,"Requires a function as parameter"))
);
}
+ v8::Local<v8::Function> fct = v8::Local<v8::Function>::Cast(args[0]);
+ v8::Persistent<v8::Function> persfct(isolate,fct);
+ signalGuidanceStatusChanged.Reset(isolate,persfct);;
- signalGuidanceStatusChanged = v8::Persistent<v8::Function>::New(v8::Handle<v8::Function>::Cast(args[0]));
+ v8::Local<v8::Object> ret = v8::Object::New(isolate);
+ ret->Set( 0, v8::Boolean::New(isolate, v8::True) );
- v8::Local<v8::Object> ret = v8::Object::New();
- ret->Set( 0, v8::Boolean::New(signalGuidanceStatusChanged->IsFunction()) );
-
- return scope.Close(ret);
+ args.GetReturnValue().Set(ret);
}
void NavigationCoreWrapper::SimulationStatusChanged(const int32_t& simulationStatus)
{
- v8::HandleScope scope();
+ v8::Isolate* isolate = v8::Isolate::GetCurrent();
const unsigned argc = 1;
v8::Local<v8::Value> argv[argc];
- argv[0]=v8::Local<v8::Value>::New(v8::Int32::New(simulationStatus));
+ argv[0]=v8::Local<v8::Value>::New(isolate,v8::Int32::New(isolate,simulationStatus));
- v8::Persistent<v8::Function> fct = static_cast<v8::Function*>(*signalSimulationStatusChanged);
- fct->Call(v8::Context::GetCurrent()->Global(), argc, argv);
+ v8::Local<v8::Function> fct;
+ fct.New(isolate,signalSimulationStatusChanged);
+ fct->Call(isolate->GetCurrentContext()->Global(), argc, argv);
}
-v8::Handle<v8::Value> NavigationCoreWrapper::SetSimulationStatusChangedListener(const v8::Arguments& args)
+void NavigationCoreWrapper::SetSimulationStatusChangedListener(const v8::FunctionCallbackInfo<v8::Value> &args)
{
- v8::HandleScope scope; //to properly clean up v8 handles
+ v8::Isolate* isolate = args.GetIsolate();
if (!args[0]->IsFunction()) {
- return v8::ThrowException(
- v8::Exception::TypeError(v8::String::New("Requires a function as parameter"))
+ isolate->ThrowException(
+ v8::Exception::TypeError(v8::String::NewFromUtf8(isolate,"Requires a function as parameter"))
);
}
+ v8::Local<v8::Function> fct = v8::Local<v8::Function>::Cast(args[0]);
+ v8::Persistent<v8::Function> persfct(isolate,fct);
+ signalSimulationStatusChanged.Reset(isolate,persfct);;
- signalSimulationStatusChanged = v8::Persistent<v8::Function>::New(v8::Handle<v8::Function>::Cast(args[0]));
-
- v8::Local<v8::Object> ret = v8::Object::New();
- ret->Set( 0, v8::Boolean::New(signalSimulationStatusChanged->IsFunction()) );
+ v8::Local<v8::Object> ret = v8::Object::New(isolate);
+ ret->Set( 0, v8::Boolean::New(isolate, v8::True) );
- return scope.Close(ret);
+ args.GetReturnValue().Set(ret);
}
-void NavigationCoreWrapper::Init(v8::Handle<v8::Object> target) {
- v8::HandleScope scope;
-
- v8::Local<v8::FunctionTemplate> tpl = v8::FunctionTemplate::New(New);
- v8::Local<v8::String> name = v8::String::NewSymbol("NavigationCoreWrapper");
+void NavigationCoreWrapper::Init(v8::Local<v8::Object> target) {
+ v8::Isolate* isolate = target->GetIsolate();
- constructor = v8::Persistent<v8::FunctionTemplate>::New(tpl);
- // ObjectWrap uses the first internal field to store the wrapped pointer.
- constructor->InstanceTemplate()->SetInternalFieldCount(1);
- constructor->SetClassName(name);
+ // Prepare constructor template
+ v8::Local<v8::FunctionTemplate> tpl = v8::FunctionTemplate::New(isolate, New);
+ tpl->SetClassName(v8::String::NewFromUtf8(isolate, "NavigationCoreWrapper"));
+ tpl->InstanceTemplate()->SetInternalFieldCount(1);
// Add all prototype methods, getters and setters here.
- NODE_SET_PROTOTYPE_METHOD(constructor, "setGuidanceStatusChangedListener", SetGuidanceStatusChangedListener);
- NODE_SET_PROTOTYPE_METHOD(constructor, "getGuidanceStatus", GetGuidanceStatus);
- NODE_SET_PROTOTYPE_METHOD(constructor, "setSimulationStatusChangedListener", SetSimulationStatusChangedListener);
- NODE_SET_PROTOTYPE_METHOD(constructor, "getSimulationStatus", GetSimulationStatus);
- NODE_SET_PROTOTYPE_METHOD(constructor, "getPosition", GetPosition);
+ NODE_SET_PROTOTYPE_METHOD(tpl, "setGuidanceStatusChangedListener", SetGuidanceStatusChangedListener);
+ NODE_SET_PROTOTYPE_METHOD(tpl, "getGuidanceStatus", GetGuidanceStatus);
+ NODE_SET_PROTOTYPE_METHOD(tpl, "setSimulationStatusChangedListener", SetSimulationStatusChangedListener);
+ NODE_SET_PROTOTYPE_METHOD(tpl, "getSimulationStatus", GetSimulationStatus);
+ NODE_SET_PROTOTYPE_METHOD(tpl, "getPosition", GetPosition);
// This has to be last, otherwise the properties won't show up on the
// object in JavaScript.
- target->Set(name, constructor->GetFunction());
+ constructor.Reset(isolate, tpl->GetFunction());
+ target->Set(v8::String::NewFromUtf8(isolate, "NavigationCoreWrapper"),
+ tpl->GetFunction());
}
NavigationCoreWrapper::NavigationCoreWrapper() {
@@ -126,32 +129,49 @@ NavigationCoreWrapper::NavigationCoreWrapper() {
NavigationCoreWrapper::~NavigationCoreWrapper() {
}
-v8::Handle<v8::Value> NavigationCoreWrapper::New(const v8::Arguments& args) {
- v8::HandleScope scope;
-
- if (!args.IsConstructCall()) {
- return v8::ThrowException(v8::Exception::TypeError(
- v8::String::New("Use the new operator to create instances of this object."))
- );
+void NavigationCoreWrapper::New(const v8::FunctionCallbackInfo<v8::Value> &args) {
+ v8::Isolate* isolate = args.GetIsolate();
+
+ if (args.IsConstructCall()) {
+ // Invoked as constructor: `new MyObject(...)`
+// double value = args[0]->IsUndefined() ? 0 : args[0]->NumberValue(); //no parameters
+ NavigationCoreWrapper* obj = new NavigationCoreWrapper();
+ obj->Wrap(args.This());
+ args.GetReturnValue().Set(args.This());
+
+ NavigationCoreProxy* proxy = new NavigationCoreProxy(obj);
+ obj->mp_navigationCoreProxy = proxy;
+ } else { // not tested yet
+ // Invoked as plain function `MyObject(...)`, turn into construct call.
+ const int argc = 1;
+ v8::Local<v8::Value> argv[argc] = { args[0] };
+ v8::Local<v8::Context> context = isolate->GetCurrentContext();
+ v8::Local<v8::Function> cons = v8::Local<v8::Function>::New(isolate, constructor);
+ v8::Local<v8::Object> result = cons->NewInstance(context, argc, argv).ToLocalChecked();
+ args.GetReturnValue().Set(result);
}
- // Creates a new instance object of this type and wraps it.
- NavigationCoreWrapper* obj = new NavigationCoreWrapper();
+}
- NavigationCoreProxy* proxy = new NavigationCoreProxy(obj);
+void NavigationCoreWrapper::NewInstance(const v8::FunctionCallbackInfo<v8::Value>& args) {
+ v8::Isolate* isolate = args.GetIsolate();
- obj->mp_navigationCoreProxy = proxy;
- obj->Wrap(args.This());
+ const unsigned argc = 1;
+ v8::Local<v8::Value> argv[argc] = { args[0] };
+ v8::Local<v8::Function> cons = v8::Local<v8::Function>::New(isolate, constructor);
+ v8::Local<v8::Context> context = isolate->GetCurrentContext();
+ v8::Local<v8::Object> instance =
+ cons->NewInstance(context, argc, argv).ToLocalChecked();
- return args.This();
+ args.GetReturnValue().Set(instance);
}
void RegisterModule(v8::Handle<v8::Object> target) {
NavigationCoreWrapper::Init(target);
}
-v8::Handle<v8::Value> NavigationCoreWrapper::GetGuidanceStatus(const v8::Arguments& args)
+void NavigationCoreWrapper::GetGuidanceStatus(const v8::FunctionCallbackInfo<v8::Value> &args)
{
- v8::HandleScope scope; //to properly clean up v8 handles
+ v8::Isolate* isolate = args.GetIsolate();
// Retrieves the pointer to the wrapped object instance.
NavigationCoreWrapper* obj = ObjectWrap::Unwrap<NavigationCoreWrapper>(args.This());
@@ -159,52 +179,52 @@ v8::Handle<v8::Value> NavigationCoreWrapper::GetGuidanceStatus(const v8::Argumen
uint32_t routeHandle;
obj->mp_navigationCoreProxy->mp_navigationCoreGuidanceProxy->GetGuidanceStatus(guidanceStatus,routeHandle);
- v8::Local<v8::Object> ret = v8::Object::New();
- ret->Set( 0, v8::Int32::New(guidanceStatus) );
- ret->Set( 1, v8::Uint32::New(routeHandle) );
+ v8::Local<v8::Object> ret = v8::Object::New(isolate);
+ ret->Set( 0, v8::Int32::New(isolate,guidanceStatus) );
+ ret->Set( 1, v8::Uint32::New(isolate,routeHandle) );
- return scope.Close(ret);
+ args.GetReturnValue().Set(ret);
}
-v8::Handle<v8::Value> NavigationCoreWrapper::GetSimulationStatus(const v8::Arguments& args)
+void NavigationCoreWrapper::GetSimulationStatus(const v8::FunctionCallbackInfo<v8::Value> &args)
{
- v8::HandleScope scope; //to properly clean up v8 handles
+ v8::Isolate* isolate = args.GetIsolate();
// Retrieves the pointer to the wrapped object instance.
NavigationCoreWrapper* obj = ObjectWrap::Unwrap<NavigationCoreWrapper>(args.This());
int32_t simulationStatus;
simulationStatus = obj->mp_navigationCoreProxy->mp_navigationCoreMapMatchedPositionProxy->GetSimulationStatus();
- v8::Local<v8::Object> ret = v8::Object::New();
- ret->Set( 0, v8::Int32::New(simulationStatus) );
+ v8::Local<v8::Object> ret = v8::Object::New(isolate);
+ ret->Set( 0, v8::Int32::New(isolate,simulationStatus) );
- return scope.Close(ret);
+ args.GetReturnValue().Set(ret);
}
-v8::Handle<v8::Value> NavigationCoreWrapper::GetPosition(const v8::Arguments& args)
+void NavigationCoreWrapper::GetPosition(const v8::FunctionCallbackInfo<v8::Value> &args)
{
- v8::HandleScope scope; //to properly clean up v8 handles
+ v8::Isolate* isolate = args.GetIsolate();
std::vector< int32_t > valuesToReturn;
std::map< int32_t, ::DBus::Struct< uint8_t, ::DBus::Variant > > position;
if (args.Length() < 1) {
- return v8::ThrowException(
- v8::Exception::TypeError(v8::String::New("getPosition requires at least 1 argument"))
+ isolate->ThrowException(
+ v8::Exception::TypeError(v8::String::NewFromUtf8(isolate,"getPosition requires at least 1 argument"))
);
}
if (args[0]->IsArray()) {
- v8::Handle<v8::Array> array = v8::Handle<v8::Array>::Cast(args[0]);
+ v8::Local<v8::Array> array = v8::Local<v8::Array>::Cast(args[0]);
for(uint32_t i=0;i<array->Length();i++)
{
- v8::Handle<v8::Value> value = v8::Handle<v8::Object>::Cast(array->Get(i));
+ v8::Local<v8::Value> value = v8::Local<v8::Object>::Cast(array->Get(i));
valuesToReturn.push_back(value->ToInt32()->Int32Value());
}
} else {
- return v8::ThrowException(
- v8::Exception::TypeError(v8::String::New("getPosition requires an array as argument"))
+ isolate->ThrowException(
+ v8::Exception::TypeError(v8::String::NewFromUtf8(isolate,"getPosition requires an array as argument"))
);
}
@@ -212,12 +232,12 @@ v8::Handle<v8::Value> NavigationCoreWrapper::GetPosition(const v8::Arguments& ar
NavigationCoreWrapper* obj = ObjectWrap::Unwrap<NavigationCoreWrapper>(args.This());
position = obj->mp_navigationCoreProxy->mp_navigationCoreMapMatchedPositionProxy->GetPosition(valuesToReturn);
- v8::Local<v8::Array> ret = v8::Array::New();
+ v8::Local<v8::Array> ret = v8::Array::New(isolate);
for (std::map< int32_t, ::DBus::Struct< uint8_t, ::DBus::Variant > >::iterator iter = position.begin(); iter != position.end(); iter++) {
- v8::Local<v8::Object> data = v8::Object::New();
+ v8::Local<v8::Object> data = v8::Object::New(isolate);
::DBus::Struct< uint8_t, ::DBus::Variant > value;
- data->Set(v8::String::New("key"), v8::Int32::New(iter->first));
+ data->Set(v8::String::NewFromUtf8(isolate,"key"), v8::Int32::New(isolate,iter->first));
value = iter->second;
switch (iter->first) {
case GENIVI_NAVIGATIONCORE_LATITUDE:
@@ -226,13 +246,13 @@ v8::Handle<v8::Value> NavigationCoreWrapper::GetPosition(const v8::Arguments& ar
case GENIVI_NAVIGATIONCORE_SPEED:
case GENIVI_NAVIGATIONCORE_HEADING:
default:
- data->Set(v8::String::New("value"), v8::Number::New(value._2));
+ data->Set(v8::String::NewFromUtf8(isolate,"value"), v8::Number::New(isolate,value._2));
break;
}
ret->Set(ret->Length(), data);
}
- return scope.Close(ret);
+ args.GetReturnValue().Set(ret);
}
-NODE_MODULE(NavigationCoreWrapper, RegisterModule);
+NODE_MODULE(NavigationCoreWrapper, RegisterModule)
diff --git a/test/html-based-panel/node-cpp-lbs-modules/NavigationCoreWrapper.hpp b/test/html-based-panel/node-cpp-lbs-modules/NavigationCoreWrapper.hpp
index 99cc9f7..bb6be67 100644
--- a/test/html-based-panel/node-cpp-lbs-modules/NavigationCoreWrapper.hpp
+++ b/test/html-based-panel/node-cpp-lbs-modules/NavigationCoreWrapper.hpp
@@ -31,6 +31,7 @@
#include <node.h>
#include <node_buffer.h>
+#include <node_object_wrap.h>
#include "./dbus-proxies/NavigationCoreProxy.hpp"
@@ -48,8 +49,9 @@ class NavigationCoreWrapper : public node::ObjectWrap {
friend void NavigationCoreProxy::SimulationStatusChanged(const int32_t &simulationStatus);
public:
- static v8::Persistent<v8::FunctionTemplate> constructor;
- static void Init(v8::Handle<v8::Object> target);
+ static v8::Persistent<v8::Function> constructor;
+ static void Init(v8::Local<v8::Object> target);
+ static void NewInstance(const v8::FunctionCallbackInfo<v8::Value>& args);
static v8::Persistent<v8::Function> signalGuidanceStatusChanged;
static v8::Persistent<v8::Function> signalSimulationStatusChanged;
@@ -57,14 +59,14 @@ protected:
NavigationCoreWrapper();
~NavigationCoreWrapper();
- static v8::Handle<v8::Value> New(const v8::Arguments& args);
- static v8::Handle<v8::Value> GetGuidanceStatus(const v8::Arguments& args);
- static v8::Handle<v8::Value> GetSimulationStatus(const v8::Arguments& args);
- static v8::Handle<v8::Value> GetPosition(const v8::Arguments& args);
+ static void New(const v8::FunctionCallbackInfo<v8::Value> &args);
+ static void GetGuidanceStatus(const v8::FunctionCallbackInfo<v8::Value> &args);
+ static void GetSimulationStatus(const v8::FunctionCallbackInfo<v8::Value> &args);
+ static void GetPosition(const v8::FunctionCallbackInfo<v8::Value> &args);
- static v8::Handle<v8::Value> SetGuidanceStatusChangedListener(const v8::Arguments& args);
+ static void SetGuidanceStatusChangedListener(const v8::FunctionCallbackInfo<v8::Value> &args);
void GuidanceStatusChanged(const int32_t& guidanceStatus, const uint32_t& routeHandle);
- static v8::Handle<v8::Value> SetSimulationStatusChangedListener(const v8::Arguments& args);
+ static void SetSimulationStatusChangedListener(const v8::FunctionCallbackInfo<v8::Value> &args);
void SimulationStatusChanged(const int32_t& simulationStatus);
private:
diff --git a/test/html-based-panel/node-cpp-lbs-modules/PositioningEnhancedPositionWrapper.cpp b/test/html-based-panel/node-cpp-lbs-modules/PositioningEnhancedPositionWrapper.cpp
index ff77d5a..8c58df8 100644
--- a/test/html-based-panel/node-cpp-lbs-modules/PositioningEnhancedPositionWrapper.cpp
+++ b/test/html-based-panel/node-cpp-lbs-modules/PositioningEnhancedPositionWrapper.cpp
@@ -31,59 +31,59 @@
using namespace std;
-v8::Persistent<v8::FunctionTemplate> PositioningEnhancedPositionWrapper::constructor;
+v8::Persistent<v8::Function> PositioningEnhancedPositionWrapper::constructor;
v8::Persistent<v8::Function> PositioningEnhancedPositionWrapper::signalPositionUpdate;
void PositioningEnhancedPositionWrapper::PositionUpdate(const uint64_t& changedValues) {
- v8::HandleScope scope;
+ v8::Isolate* isolate = v8::Isolate::GetCurrent();
const unsigned argc = 2;
uint64to32 data;
data.full = changedValues;
v8::Local<v8::Value> argv[argc];
- argv[0] = v8::Local<v8::Value>::New(v8::Uint32::New(data.p.high));
- argv[1] = v8::Local<v8::Value>::New(v8::Uint32::New(data.p.low));
-
- v8::Persistent<v8::Function> fct = static_cast<v8::Function*>(*signalPositionUpdate);
- fct->Call(v8::Context::GetCurrent()->Global(), argc, argv);
+ argv[0] = v8::Local<v8::Value>::New(isolate,v8::Uint32::New(isolate,data.p.high));
+ argv[1] = v8::Local<v8::Value>::New(isolate,v8::Uint32::New(isolate,data.p.low));
+ v8::Local<v8::Function> fct;
+ fct.New(isolate,signalPositionUpdate);
+ fct->Call(isolate->GetCurrentContext()->Global(), argc, argv);
}
-v8::Handle<v8::Value> PositioningEnhancedPositionWrapper::SetPositionUpdateListener(const v8::Arguments& args)
+void PositioningEnhancedPositionWrapper::SetPositionUpdateListener(const v8::FunctionCallbackInfo<v8::Value> &args)
{
- v8::HandleScope scope; //to properly clean up v8 handles
+ v8::Isolate* isolate = args.GetIsolate();
if (!args[0]->IsFunction()) {
- return v8::ThrowException(
- v8::Exception::TypeError(v8::String::New("Requires a function as parameter"))
+ isolate->ThrowException(
+ v8::Exception::TypeError(v8::String::NewFromUtf8(isolate,"Requires a function as parameter"))
);
}
+ v8::Local<v8::Function> fct = v8::Local<v8::Function>::Cast(args[0]);
+ v8::Persistent<v8::Function> persfct(isolate,fct);
+ signalPositionUpdate.Reset(isolate,persfct);;
- signalPositionUpdate = v8::Persistent<v8::Function>::New(v8::Handle<v8::Function>::Cast(args[0]));
-
- v8::Local<v8::Object> ret = v8::Object::New();
- ret->Set( 0, v8::Boolean::New(signalPositionUpdate->IsFunction()) );
+ v8::Local<v8::Object> ret = v8::Object::New(isolate);
+ ret->Set( 0, v8::Boolean::New(isolate, v8::True) );
- return scope.Close(ret);
+ args.GetReturnValue().Set(ret);
}
-void PositioningEnhancedPositionWrapper::Init(v8::Handle<v8::Object> target) {
- v8::HandleScope scope;
-
- v8::Local<v8::FunctionTemplate> tpl = v8::FunctionTemplate::New(New);
- v8::Local<v8::String> name = v8::String::NewSymbol("PositioningEnhancedPositionWrapper");
+void PositioningEnhancedPositionWrapper::Init(v8::Local<v8::Object> target) {
+ v8::Isolate* isolate = target->GetIsolate();
- constructor = v8::Persistent<v8::FunctionTemplate>::New(tpl);
- // ObjectWrap uses the first internal field to store the wrapped pointer.
- constructor->InstanceTemplate()->SetInternalFieldCount(1);
- constructor->SetClassName(name);
+ // Prepare constructor template
+ v8::Local<v8::FunctionTemplate> tpl = v8::FunctionTemplate::New(isolate, New);
+ tpl->SetClassName(v8::String::NewFromUtf8(isolate, "PositioningEnhancedPositionWrapper"));
+ tpl->InstanceTemplate()->SetInternalFieldCount(1);
// Add all prototype methods, getters and setters here.
- NODE_SET_PROTOTYPE_METHOD(constructor, "getVersion", GetVersion);
- NODE_SET_PROTOTYPE_METHOD(constructor, "getPositionInfo", GetPositionInfo);
- NODE_SET_PROTOTYPE_METHOD(constructor, "setPositionUpdateListener", SetPositionUpdateListener);
+ NODE_SET_PROTOTYPE_METHOD(tpl, "getVersion", GetVersion);
+ NODE_SET_PROTOTYPE_METHOD(tpl, "getPositionInfo", GetPositionInfo);
+ NODE_SET_PROTOTYPE_METHOD(tpl, "setPositionUpdateListener", SetPositionUpdateListener);
// This has to be last, otherwise the properties won't show up on the
// object in JavaScript.
- target->Set(name, constructor->GetFunction());
+ constructor.Reset(isolate, tpl->GetFunction());
+ target->Set(v8::String::NewFromUtf8(isolate, "PositioningEnhancedPositionWrapper"),
+ tpl->GetFunction());
}
PositioningEnhancedPositionWrapper::PositioningEnhancedPositionWrapper() {
@@ -92,62 +92,79 @@ PositioningEnhancedPositionWrapper::PositioningEnhancedPositionWrapper() {
PositioningEnhancedPositionWrapper::~PositioningEnhancedPositionWrapper() {
}
-v8::Handle<v8::Value> PositioningEnhancedPositionWrapper::New(const v8::Arguments& args) {
- v8::HandleScope scope;
-
- if (!args.IsConstructCall()) {
- return v8::ThrowException(v8::Exception::TypeError(
- v8::String::New("Use the new operator to create instances of this object."))
- );
- }
+void PositioningEnhancedPositionWrapper::New(const v8::FunctionCallbackInfo<v8::Value> &args) {
+ v8::Isolate* isolate = args.GetIsolate();
- // Creates a new instance object of this type and wraps it.
+ if (args.IsConstructCall()) {
+ // Invoked as constructor: `new MyObject(...)`
+// double value = args[0]->IsUndefined() ? 0 : args[0]->NumberValue(); //no parameters
PositioningEnhancedPositionWrapper* obj = new PositioningEnhancedPositionWrapper();
+ obj->Wrap(args.This());
+ args.GetReturnValue().Set(args.This());
PositioningProxy* proxy = new PositioningProxy(obj);
obj->mp_positioningProxy = proxy;
- obj->Wrap(args.This());
+ } else { // not tested yet
+ // Invoked as plain function `MyObject(...)`, turn into construct call.
+ const int argc = 1;
+ v8::Local<v8::Value> argv[argc] = { args[0] };
+ v8::Local<v8::Context> context = isolate->GetCurrentContext();
+ v8::Local<v8::Function> cons = v8::Local<v8::Function>::New(isolate, constructor);
+ v8::Local<v8::Object> result = cons->NewInstance(context, argc, argv).ToLocalChecked();
+ args.GetReturnValue().Set(result);
+ }
+}
+
+void PositioningEnhancedPositionWrapper::NewInstance(const v8::FunctionCallbackInfo<v8::Value>& args) {
+ v8::Isolate* isolate = args.GetIsolate();
+
+ const unsigned argc = 1;
+ v8::Local<v8::Value> argv[argc] = { args[0] };
+ v8::Local<v8::Function> cons = v8::Local<v8::Function>::New(isolate, constructor);
+ v8::Local<v8::Context> context = isolate->GetCurrentContext();
+ v8::Local<v8::Object> instance =
+ cons->NewInstance(context, argc, argv).ToLocalChecked();
- return args.This();
+ args.GetReturnValue().Set(instance);
}
-v8::Handle<v8::Value> PositioningEnhancedPositionWrapper::GetVersion(const v8::Arguments& args) {
- v8::HandleScope scope; //to properly clean up v8 handles
+void PositioningEnhancedPositionWrapper::GetVersion(const v8::FunctionCallbackInfo<v8::Value> &args) {
+ v8::Isolate* isolate = args.GetIsolate();
// Retrieves the pointer to the wrapped object instance.
PositioningEnhancedPositionWrapper* obj = ObjectWrap::Unwrap<PositioningEnhancedPositionWrapper>(args.This());
::DBus::Struct< uint16_t, uint16_t, uint16_t, std::string > DBus_version = obj->mp_positioningProxy->mp_enhancedPositionProxy->GetVersion();
- v8::Local<v8::Object> ret = v8::Object::New();
- ret->Set( 0, v8::Int32::New(DBus_version._1) );
- ret->Set( 1, v8::Int32::New(DBus_version._2) );
- ret->Set( 2, v8::Int32::New(DBus_version._3) );
- ret->Set( 3, v8::String::New(DBus_version._4.c_str()) );
+ v8::Local<v8::Object> ret = v8::Object::New(isolate);
+ ret->Set( 0, v8::Int32::New(isolate,DBus_version._1) );
+ ret->Set( 1, v8::Int32::New(isolate,DBus_version._2) );
+ ret->Set( 2, v8::Int32::New(isolate,DBus_version._3) );
+ ret->Set( 3, v8::String::NewFromUtf8(isolate,DBus_version._4.c_str()) );
- return scope.Close(ret);
+ args.GetReturnValue().Set(ret);
}
-v8::Handle<v8::Value> PositioningEnhancedPositionWrapper::GetPositionInfo(const v8::Arguments& args) {
- v8::HandleScope scope; //to properly clean up v8 handles
+void PositioningEnhancedPositionWrapper::GetPositionInfo(const v8::FunctionCallbackInfo<v8::Value> &args) {
+ v8::Isolate* isolate = args.GetIsolate();
uint64to32 valuesToReturn;
if (args.Length() < 1) {
- return v8::ThrowException(
- v8::Exception::TypeError(v8::String::New("getPositionInfo requires at least 1 argument"))
+ isolate->ThrowException(
+ v8::Exception::TypeError(v8::String::NewFromUtf8(isolate,"getPositionInfo requires at least 1 argument"))
);
}
if (args[0]->IsArray()) {
- v8::Handle<v8::Array> array = v8::Handle<v8::Array>::Cast(args[0]);
- v8::Handle<v8::Value> msb = v8::Handle<v8::Object>::Cast(array->Get(0));
- v8::Handle<v8::Value> lsb = v8::Handle<v8::Object>::Cast(array->Get(1));
+ v8::Local<v8::Array> array = v8::Local<v8::Array>::Cast(args[0]);
+ v8::Local<v8::Value> msb = v8::Local<v8::Object>::Cast(array->Get(0));
+ v8::Local<v8::Value> lsb = v8::Local<v8::Object>::Cast(array->Get(1));
valuesToReturn.p.high = msb->ToInt32()->Int32Value();
valuesToReturn.p.low = lsb->ToInt32()->Int32Value();
} else {
- return v8::ThrowException(
- v8::Exception::TypeError(v8::String::New("getPositionInfo requires an array as argument"))
+ isolate->ThrowException(
+ v8::Exception::TypeError(v8::String::NewFromUtf8(isolate,"getPositionInfo requires an array as argument"))
);
}
@@ -158,35 +175,35 @@ v8::Handle<v8::Value> PositioningEnhancedPositionWrapper::GetPositionInfo(const
obj->mp_positioningProxy->mp_enhancedPositionProxy->GetPositionInfo(valuesToReturn.full, timestamp, position);
- v8::Local<v8::Array> ret = v8::Array::New();
+ v8::Local<v8::Array> ret = v8::Array::New(isolate);
- v8::Local<v8::Object> tst = v8::Object::New();
+ v8::Local<v8::Object> tst = v8::Object::New(isolate);
uint64to32 t;
t.full = timestamp;
- tst->Set(v8::String::New("timestamp_msb"), v8::Uint32::New(t.p.high));
- tst->Set(v8::String::New("timestamp_lsb"), v8::Uint32::New(t.p.low));
+ tst->Set(v8::String::NewFromUtf8(isolate,"timestamp_msb"), v8::Uint32::New(isolate,t.p.high));
+ tst->Set(v8::String::NewFromUtf8(isolate,"timestamp_lsb"), v8::Uint32::New(isolate,t.p.low));
ret->Set(ret->Length(), tst);
for (std::map< uint64_t, ::DBus::Variant >::iterator iter = position.begin(); iter != position.end(); iter++) {
- v8::Local<v8::Object> data = v8::Object::New();
+ v8::Local<v8::Object> data = v8::Object::New(isolate);
::DBus::Variant value;
uint64to32 key;
value = iter->second;
key.full = iter->first;
- data->Set(v8::String::New("key_msb"), v8::Uint32::New(key.p.high));
- data->Set(v8::String::New("key_lsb"), v8::Uint32::New(key.p.low));
+ data->Set(v8::String::NewFromUtf8(isolate,"key_msb"), v8::Uint32::New(isolate,key.p.high));
+ data->Set(v8::String::NewFromUtf8(isolate,"key_lsb"), v8::Uint32::New(isolate,key.p.low));
switch (iter->first) {
case GENIVI_ENHANCEDPOSITIONSERVICE_LATITUDE:
case GENIVI_ENHANCEDPOSITIONSERVICE_LONGITUDE:
case GENIVI_ENHANCEDPOSITIONSERVICE_ALTITUDE:
default:
- data->Set(v8::String::New("value"), v8::Number::New(value));
+ data->Set(v8::String::NewFromUtf8(isolate,"value"), v8::Number::New(isolate,value));
break;
}
ret->Set(ret->Length(), data);
}
- return scope.Close(ret);
+ args.GetReturnValue().Set(v8::DEFAULT);
}
@@ -194,4 +211,4 @@ void RegisterModule(v8::Handle<v8::Object> target) {
PositioningEnhancedPositionWrapper::Init(target);
}
-NODE_MODULE(PositioningEnhancedPositionWrapper, RegisterModule);
+NODE_MODULE(PositioningEnhancedPositionWrapper, RegisterModule)
diff --git a/test/html-based-panel/node-cpp-lbs-modules/PositioningEnhancedPositionWrapper.hpp b/test/html-based-panel/node-cpp-lbs-modules/PositioningEnhancedPositionWrapper.hpp
index c9f37ad..e688a5d 100644
--- a/test/html-based-panel/node-cpp-lbs-modules/PositioningEnhancedPositionWrapper.hpp
+++ b/test/html-based-panel/node-cpp-lbs-modules/PositioningEnhancedPositionWrapper.hpp
@@ -31,6 +31,7 @@
#include <node.h>
#include <node_buffer.h>
+#include <node_object_wrap.h>
#include "./dbus-proxies/PositioningProxy.hpp"
@@ -47,8 +48,9 @@ class PositioningEnhancedPositionWrapper : public node::ObjectWrap {
friend void PositioningProxy::PositionUpdate(const uint64_t &changedValues);
public:
- static v8::Persistent<v8::FunctionTemplate> constructor;
- static void Init(v8::Handle<v8::Object> target);
+ static v8::Persistent<v8::Function> constructor;
+ static void Init(v8::Local<v8::Object> target);
+ static void NewInstance(const v8::FunctionCallbackInfo<v8::Value>& args);
static v8::Persistent<v8::Function> signalPositionUpdate;
protected:
@@ -63,11 +65,11 @@ protected:
} p;
} uint64to32;
- static v8::Handle<v8::Value> New(const v8::Arguments& args);
- static v8::Handle<v8::Value> GetVersion(const v8::Arguments& args);
- static v8::Handle<v8::Value> GetPositionInfo(const v8::Arguments& args);
+ static void New(const v8::FunctionCallbackInfo<v8::Value> &args);
+ static void GetVersion(const v8::FunctionCallbackInfo<v8::Value> &args);
+ static void GetPositionInfo(const v8::FunctionCallbackInfo<v8::Value> &args);
- static v8::Handle<v8::Value> SetPositionUpdateListener(const v8::Arguments& args);
+ static void SetPositionUpdateListener(const v8::FunctionCallbackInfo<v8::Value> &args);
static void PositionUpdate(const uint64_t& changedValues);
private:
diff --git a/test/html-based-panel/node-cpp-lbs-modules/package.json b/test/html-based-panel/node-cpp-lbs-modules/package.json
index 2ae0a08..af66f57 100644
--- a/test/html-based-panel/node-cpp-lbs-modules/package.json
+++ b/test/html-based-panel/node-cpp-lbs-modules/package.json
@@ -18,7 +18,8 @@
"fs": "0.0.2",
"path": "",
"socket.io": "1.4.5",
- "gcontext": "0.0.2",
+ "gcontext": "0.0.3",
+ "nan": "^2.3.5",
"python-shell": "0.4.0",
"enum": "2.3.0"
},
diff --git a/test/html-based-panel/server.js b/test/html-based-panel/server.js
index 6ad2a06..70646f2 100644
--- a/test/html-based-panel/server.js
+++ b/test/html-based-panel/server.js
@@ -35,6 +35,8 @@ var path = require('path');
var gcontext = require('gcontext');
var python_shell = require('python-shell');
var Enum = require('enum');
+var segfault_handler = require('segfault-handler');
+segfault_handler.registerHandler('crash.log');
// Configuration of the python script for simulating log replayer data
var python_script_enum = new Enum({'START': 1, 'INITIALIZATION': 2, 'HIGH_TANK_LEVEL': 3, 'LOW_TANK_LEVEL': 4});
diff --git a/test/html-based-panel/simulation-panel.html b/test/html-based-panel/simulation-panel.html
index 7367662..f2c6aa2 100644
--- a/test/html-based-panel/simulation-panel.html
+++ b/test/html-based-panel/simulation-panel.html
@@ -5,7 +5,7 @@
<title>Simulation panel for the FSA (draft)</title>
<link rel="stylesheet" href="style-sheets/stylesheet.css">
<!-- to be fixed, use relative paths -->
-<script type="text/javascript" src="./node_modules/socket.io/node_modules/socket.io-client/socket.io.js"></script>
+<script type="text/javascript" src="./node_modules/socket.io-client/socket.io.js"></script>
<script type="text/javascript" src="./node_modules/webidl2/lib/webidl2.js"></script>
<script type="text/javascript" src="./node_modules/enum/enum-2.3.0.js"></script>
</head>
diff --git a/test/html-based-panel/viewer-panel.html b/test/html-based-panel/viewer-panel.html
index e038e6d..c1e0acc 100644
--- a/test/html-based-panel/viewer-panel.html
+++ b/test/html-based-panel/viewer-panel.html
@@ -5,7 +5,7 @@
<title>Viewer panel for the FSA (draft)</title>
<link rel="stylesheet" href="style-sheets/stylesheet.css">
<!-- to be fixed, use relative paths -->
-<script type="text/javascript" src="./node_modules/socket.io/node_modules/socket.io-client/socket.io.js"></script>
+<script type="text/javascript" src="./node_modules/socket.io-client/socket.io.js"></script>
<script type="text/javascript" src="./node_modules/enum/enum-2.3.0.js"></script>
</head>
<body>