template <class T> class JSHandle {
static Nan::Persistent<v8::FunctionTemplate> &theTemplate() {
static Nan::Persistent<v8::FunctionTemplate> returnValue;
if (returnValue.IsEmpty()) {
v8::Local<v8::FunctionTemplate> theTemplate =
Nan::New<v8::FunctionTemplate>();
theTemplate
->SetClassName(Nan::New(T::jsClassName()).ToLocalChecked());
theTemplate->InstanceTemplate()->SetInternalFieldCount(1);
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/node_api.cc b/src/node_api.cc | |
index ccf8738..95037a1 100644 | |
--- a/src/node_api.cc | |
+++ b/src/node_api.cc | |
@@ -334,6 +334,8 @@ class CallbackWrapperBase : public CallbackWrapper { | |
_cbdata->GetInternalField(kEnvIndex))->Value()); | |
// Make sure any errors encountered last time we were in N-API are gone. | |
+ fprintf(stderr, "env->last_error.error_code: %d\n", | |
+ env->last_error.error_code); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/node.cc b/src/node.cc | |
index 90eee0f..c2ef453 100644 | |
--- a/src/node.cc | |
+++ b/src/node.cc | |
@@ -29,6 +29,10 @@ | |
#include "node_lttng.h" | |
#endif | |
+#if defined ENABLE_NAPI | |
+#include "node_jsvmapi_internal.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void doInstanceOf(napi_env env, napi_func_cb_info info) { | |
napi_value arguments[2]; | |
napi_valuetype originalType, currentType, constructorPrototypeType; | |
bool returnValue = false; | |
napi_propertyname underunderProto; | |
napi_get_cb_args(env, info, arguments, 2); | |
if (napi_get_type_of_value(env, arguments[1]) != napi_function) { | |
napi_throw_type_error(env, (char *)"constructor must be a function"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bool napi_instanceof(napi_env e, napi_value o, napi_value c) { | |
v8::Isolate *isolate = v8impl::V8IsolateFromJsEnv(e); | |
v8::Local<v8::Value> obj = v8impl::V8LocalValueFromJsValue(o); | |
v8::Local<v8::Value> consProto = v8impl::V8LocalValueFromJsValue(c) | |
->ToObject()->Get(v8::String::NewFromUtf8(isolate, "prototype")); | |
v8::Local<v8::String> protoString = | |
v8::String::NewFromUtf8(isolate, "__proto__"); | |
while (!obj->IsNull()) { | |
if (obj->StrictEquals(consProto)) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const char *napi_type_name_from_value(napi_valuetype theType) { | |
return theType == napi_undefined ? "napi_undefined" : | |
theType == napi_null ? "napi_null" : | |
theType == napi_boolean ? "napi_boolean" : | |
theType == napi_number ? "napi_number" : | |
theType == napi_string ? "napi_string" : | |
theType == napi_symbol ? "napi_symbol" : | |
theType == napi_object ? "napi_object" : | |
theType == napi_function ? "napi_function" : "unknown"; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"targets": [ { | |
"target_name": "hello", | |
"include_dirs": [ | |
"<!(node -e \"require('nan')\")" | |
], | |
"sources": [ "hello.cc" ] | |
} ] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
response payload calculation: | |
request.respond() | |
-> retrieve | |
-> OK, request.target.transform( request.target.properties, request.options ) | |
-> update | |
-> OK, no payload [1] | |
-> delete | |
-> OK, no payload [1] | |
-> create |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| | |
> [email protected] install /usr/lib/node_modules/t2-cli/node_modules/usb | |
> node-pre-gyp install --fallback-to-build | |
node-pre-gyp ERR! Tried to download: https://github.com/tessel/node-usb/releases/download/1.2.0/usb_bindings-v1.2.0-node-v46-linux-x64.tar.gz | |
node-pre-gyp ERR! Pre-built binaries not found for [email protected] and [email protected] (node-v46 ABI) (falling back to source compile with node-gyp) | |
gyp WARN EACCES user "root" does not have permission to access the dev dir "/root/.node-gyp/4.6.0" | |
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/lib/node_modules/t2-cli/node_modules/usb/.node-gyp" | |
make: Entering directory '/usr/lib/node_modules/t2-cli/node_modules/usb/build' | |
make: *** No rule to make target '../.node-gyp/4.6.0/include/node/common.gypi', needed by 'Makefile'. Stop. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <uv.h> | |
void Init() { | |
printf("Init\n"); | |
} | |
struct old_module { | |
int version; | |
void *aPointer; |