mirror of
https://kevinblog.sytes.net/Code/Jibo-Revival-Group/RoboCommander.git
synced 2026-06-15 12:26:05 +00:00
Initial commit
This commit is contained in:
1
node_modules/nan/include_dirs.js
generated
vendored
Normal file
1
node_modules/nan/include_dirs.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
console.log(require('path').relative('.', __dirname));
|
||||
2794
node_modules/nan/nan.h
generated
vendored
Normal file
2794
node_modules/nan/nan.h
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
88
node_modules/nan/nan_callbacks.h
generated
vendored
Normal file
88
node_modules/nan/nan_callbacks.h
generated
vendored
Normal file
@@ -0,0 +1,88 @@
|
||||
/*********************************************************************
|
||||
* NAN - Native Abstractions for Node.js
|
||||
*
|
||||
* Copyright (c) 2018 NAN contributors
|
||||
*
|
||||
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
|
||||
********************************************************************/
|
||||
|
||||
#ifndef NAN_CALLBACKS_H_
|
||||
#define NAN_CALLBACKS_H_
|
||||
|
||||
template<typename T> class FunctionCallbackInfo;
|
||||
template<typename T> class PropertyCallbackInfo;
|
||||
template<typename T> class Global;
|
||||
|
||||
typedef void(*FunctionCallback)(const FunctionCallbackInfo<v8::Value>&);
|
||||
typedef void(*GetterCallback)
|
||||
(v8::Local<v8::String>, const PropertyCallbackInfo<v8::Value>&);
|
||||
typedef void(*SetterCallback)(
|
||||
v8::Local<v8::String>,
|
||||
v8::Local<v8::Value>,
|
||||
const PropertyCallbackInfo<void>&);
|
||||
typedef void(*PropertyGetterCallback)(
|
||||
v8::Local<v8::String>,
|
||||
const PropertyCallbackInfo<v8::Value>&);
|
||||
typedef void(*PropertySetterCallback)(
|
||||
v8::Local<v8::String>,
|
||||
v8::Local<v8::Value>,
|
||||
const PropertyCallbackInfo<v8::Value>&);
|
||||
typedef void(*PropertyEnumeratorCallback)
|
||||
(const PropertyCallbackInfo<v8::Array>&);
|
||||
typedef void(*PropertyDeleterCallback)(
|
||||
v8::Local<v8::String>,
|
||||
const PropertyCallbackInfo<v8::Boolean>&);
|
||||
typedef void(*PropertyQueryCallback)(
|
||||
v8::Local<v8::String>,
|
||||
const PropertyCallbackInfo<v8::Integer>&);
|
||||
typedef void(*IndexGetterCallback)(
|
||||
uint32_t,
|
||||
const PropertyCallbackInfo<v8::Value>&);
|
||||
typedef void(*IndexSetterCallback)(
|
||||
uint32_t,
|
||||
v8::Local<v8::Value>,
|
||||
const PropertyCallbackInfo<v8::Value>&);
|
||||
typedef void(*IndexEnumeratorCallback)
|
||||
(const PropertyCallbackInfo<v8::Array>&);
|
||||
typedef void(*IndexDeleterCallback)(
|
||||
uint32_t,
|
||||
const PropertyCallbackInfo<v8::Boolean>&);
|
||||
typedef void(*IndexQueryCallback)(
|
||||
uint32_t,
|
||||
const PropertyCallbackInfo<v8::Integer>&);
|
||||
|
||||
namespace imp {
|
||||
typedef v8::Local<v8::AccessorSignature> Sig;
|
||||
|
||||
static const int kDataIndex = 0;
|
||||
|
||||
static const int kFunctionIndex = 1;
|
||||
static const int kFunctionFieldCount = 2;
|
||||
|
||||
static const int kGetterIndex = 1;
|
||||
static const int kSetterIndex = 2;
|
||||
static const int kAccessorFieldCount = 3;
|
||||
|
||||
static const int kPropertyGetterIndex = 1;
|
||||
static const int kPropertySetterIndex = 2;
|
||||
static const int kPropertyEnumeratorIndex = 3;
|
||||
static const int kPropertyDeleterIndex = 4;
|
||||
static const int kPropertyQueryIndex = 5;
|
||||
static const int kPropertyFieldCount = 6;
|
||||
|
||||
static const int kIndexPropertyGetterIndex = 1;
|
||||
static const int kIndexPropertySetterIndex = 2;
|
||||
static const int kIndexPropertyEnumeratorIndex = 3;
|
||||
static const int kIndexPropertyDeleterIndex = 4;
|
||||
static const int kIndexPropertyQueryIndex = 5;
|
||||
static const int kIndexPropertyFieldCount = 6;
|
||||
|
||||
} // end of namespace imp
|
||||
|
||||
#if NODE_MODULE_VERSION > NODE_0_10_MODULE_VERSION
|
||||
# include "nan_callbacks_12_inl.h" // NOLINT(build/include)
|
||||
#else
|
||||
# include "nan_callbacks_pre_12_inl.h" // NOLINT(build/include)
|
||||
#endif
|
||||
|
||||
#endif // NAN_CALLBACKS_H_
|
||||
514
node_modules/nan/nan_callbacks_12_inl.h
generated
vendored
Normal file
514
node_modules/nan/nan_callbacks_12_inl.h
generated
vendored
Normal file
@@ -0,0 +1,514 @@
|
||||
/*********************************************************************
|
||||
* NAN - Native Abstractions for Node.js
|
||||
*
|
||||
* Copyright (c) 2018 NAN contributors
|
||||
*
|
||||
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
|
||||
********************************************************************/
|
||||
|
||||
#ifndef NAN_CALLBACKS_12_INL_H_
|
||||
#define NAN_CALLBACKS_12_INL_H_
|
||||
|
||||
template<typename T>
|
||||
class ReturnValue {
|
||||
v8::ReturnValue<T> value_;
|
||||
|
||||
public:
|
||||
template <class S>
|
||||
explicit inline ReturnValue(const v8::ReturnValue<S> &value) :
|
||||
value_(value) {}
|
||||
template <class S>
|
||||
explicit inline ReturnValue(const ReturnValue<S>& that)
|
||||
: value_(that.value_) {
|
||||
TYPE_CHECK(T, S);
|
||||
}
|
||||
|
||||
// Handle setters
|
||||
template <typename S> inline void Set(const v8::Local<S> &handle) {
|
||||
TYPE_CHECK(T, S);
|
||||
value_.Set(handle);
|
||||
}
|
||||
|
||||
template <typename S> inline void Set(const Global<S> &handle) {
|
||||
TYPE_CHECK(T, S);
|
||||
#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 4 || \
|
||||
(V8_MAJOR_VERSION == 4 && defined(V8_MINOR_VERSION) && \
|
||||
(V8_MINOR_VERSION > 5 || (V8_MINOR_VERSION == 5 && \
|
||||
defined(V8_BUILD_NUMBER) && V8_BUILD_NUMBER >= 8))))
|
||||
value_.Set(handle);
|
||||
#else
|
||||
value_.Set(*reinterpret_cast<const v8::Persistent<S>*>(&handle));
|
||||
const_cast<Global<S> &>(handle).Reset();
|
||||
#endif
|
||||
}
|
||||
|
||||
// Fast primitive setters
|
||||
inline void Set(bool value) {
|
||||
TYPE_CHECK(T, v8::Boolean);
|
||||
value_.Set(value);
|
||||
}
|
||||
|
||||
inline void Set(double i) {
|
||||
TYPE_CHECK(T, v8::Number);
|
||||
value_.Set(i);
|
||||
}
|
||||
|
||||
inline void Set(int32_t i) {
|
||||
TYPE_CHECK(T, v8::Integer);
|
||||
value_.Set(i);
|
||||
}
|
||||
|
||||
inline void Set(uint32_t i) {
|
||||
TYPE_CHECK(T, v8::Integer);
|
||||
value_.Set(i);
|
||||
}
|
||||
|
||||
// Fast JS primitive setters
|
||||
inline void SetNull() {
|
||||
TYPE_CHECK(T, v8::Primitive);
|
||||
value_.SetNull();
|
||||
}
|
||||
|
||||
inline void SetUndefined() {
|
||||
TYPE_CHECK(T, v8::Primitive);
|
||||
value_.SetUndefined();
|
||||
}
|
||||
|
||||
inline void SetEmptyString() {
|
||||
TYPE_CHECK(T, v8::String);
|
||||
value_.SetEmptyString();
|
||||
}
|
||||
|
||||
// Convenience getter for isolate
|
||||
inline v8::Isolate *GetIsolate() const {
|
||||
return value_.GetIsolate();
|
||||
}
|
||||
|
||||
// Pointer setter: Uncompilable to prevent inadvertent misuse.
|
||||
template<typename S>
|
||||
inline void Set(S *whatever) { TYPE_CHECK(S*, v8::Primitive); }
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
class FunctionCallbackInfo {
|
||||
const v8::FunctionCallbackInfo<T> &info_;
|
||||
const v8::Local<v8::Value> data_;
|
||||
|
||||
public:
|
||||
explicit inline FunctionCallbackInfo(
|
||||
const v8::FunctionCallbackInfo<T> &info
|
||||
, v8::Local<v8::Value> data) :
|
||||
info_(info)
|
||||
, data_(data) {}
|
||||
|
||||
inline ReturnValue<T> GetReturnValue() const {
|
||||
return ReturnValue<T>(info_.GetReturnValue());
|
||||
}
|
||||
|
||||
#if NODE_MAJOR_VERSION < 10
|
||||
inline v8::Local<v8::Function> Callee() const { return info_.Callee(); }
|
||||
#endif
|
||||
inline v8::Local<v8::Value> Data() const { return data_; }
|
||||
inline v8::Local<v8::Object> Holder() const { return info_.Holder(); }
|
||||
inline bool IsConstructCall() const { return info_.IsConstructCall(); }
|
||||
inline int Length() const { return info_.Length(); }
|
||||
inline v8::Local<v8::Value> operator[](int i) const { return info_[i]; }
|
||||
inline v8::Local<v8::Object> This() const { return info_.This(); }
|
||||
inline v8::Isolate *GetIsolate() const { return info_.GetIsolate(); }
|
||||
|
||||
|
||||
protected:
|
||||
static const int kHolderIndex = 0;
|
||||
static const int kIsolateIndex = 1;
|
||||
static const int kReturnValueDefaultValueIndex = 2;
|
||||
static const int kReturnValueIndex = 3;
|
||||
static const int kDataIndex = 4;
|
||||
static const int kCalleeIndex = 5;
|
||||
static const int kContextSaveIndex = 6;
|
||||
static const int kArgsLength = 7;
|
||||
|
||||
private:
|
||||
NAN_DISALLOW_ASSIGN_COPY_MOVE(FunctionCallbackInfo)
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
class PropertyCallbackInfo {
|
||||
const v8::PropertyCallbackInfo<T> &info_;
|
||||
const v8::Local<v8::Value> data_;
|
||||
|
||||
public:
|
||||
explicit inline PropertyCallbackInfo(
|
||||
const v8::PropertyCallbackInfo<T> &info
|
||||
, const v8::Local<v8::Value> data) :
|
||||
info_(info)
|
||||
, data_(data) {}
|
||||
|
||||
inline v8::Isolate* GetIsolate() const { return info_.GetIsolate(); }
|
||||
inline v8::Local<v8::Value> Data() const { return data_; }
|
||||
inline v8::Local<v8::Object> This() const { return info_.This(); }
|
||||
inline v8::Local<v8::Object> Holder() const { return info_.Holder(); }
|
||||
inline ReturnValue<T> GetReturnValue() const {
|
||||
return ReturnValue<T>(info_.GetReturnValue());
|
||||
}
|
||||
|
||||
protected:
|
||||
static const int kHolderIndex = 0;
|
||||
static const int kIsolateIndex = 1;
|
||||
static const int kReturnValueDefaultValueIndex = 2;
|
||||
static const int kReturnValueIndex = 3;
|
||||
static const int kDataIndex = 4;
|
||||
static const int kThisIndex = 5;
|
||||
static const int kArgsLength = 6;
|
||||
|
||||
private:
|
||||
NAN_DISALLOW_ASSIGN_COPY_MOVE(PropertyCallbackInfo)
|
||||
};
|
||||
|
||||
namespace imp {
|
||||
static
|
||||
void FunctionCallbackWrapper(const v8::FunctionCallbackInfo<v8::Value> &info) {
|
||||
v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
|
||||
FunctionCallback callback = reinterpret_cast<FunctionCallback>(
|
||||
reinterpret_cast<intptr_t>(
|
||||
obj->GetInternalField(kFunctionIndex).As<v8::External>()->Value()));
|
||||
FunctionCallbackInfo<v8::Value>
|
||||
cbinfo(info, obj->GetInternalField(kDataIndex));
|
||||
callback(cbinfo);
|
||||
}
|
||||
|
||||
typedef void (*NativeFunction)(const v8::FunctionCallbackInfo<v8::Value> &);
|
||||
|
||||
#if NODE_MODULE_VERSION > NODE_0_12_MODULE_VERSION
|
||||
static
|
||||
void GetterCallbackWrapper(
|
||||
v8::Local<v8::Name> property
|
||||
, const v8::PropertyCallbackInfo<v8::Value> &info) {
|
||||
v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
|
||||
PropertyCallbackInfo<v8::Value>
|
||||
cbinfo(info, obj->GetInternalField(kDataIndex));
|
||||
GetterCallback callback = reinterpret_cast<GetterCallback>(
|
||||
reinterpret_cast<intptr_t>(
|
||||
obj->GetInternalField(kGetterIndex).As<v8::External>()->Value()));
|
||||
callback(property.As<v8::String>(), cbinfo);
|
||||
}
|
||||
|
||||
typedef void (*NativeGetter)
|
||||
(v8::Local<v8::Name>, const v8::PropertyCallbackInfo<v8::Value> &);
|
||||
|
||||
static
|
||||
void SetterCallbackWrapper(
|
||||
v8::Local<v8::Name> property
|
||||
, v8::Local<v8::Value> value
|
||||
, const v8::PropertyCallbackInfo<void> &info) {
|
||||
v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
|
||||
PropertyCallbackInfo<void>
|
||||
cbinfo(info, obj->GetInternalField(kDataIndex));
|
||||
SetterCallback callback = reinterpret_cast<SetterCallback>(
|
||||
reinterpret_cast<intptr_t>(
|
||||
obj->GetInternalField(kSetterIndex).As<v8::External>()->Value()));
|
||||
callback(property.As<v8::String>(), value, cbinfo);
|
||||
}
|
||||
|
||||
typedef void (*NativeSetter)(
|
||||
v8::Local<v8::Name>
|
||||
, v8::Local<v8::Value>
|
||||
, const v8::PropertyCallbackInfo<void> &);
|
||||
#else
|
||||
static
|
||||
void GetterCallbackWrapper(
|
||||
v8::Local<v8::String> property
|
||||
, const v8::PropertyCallbackInfo<v8::Value> &info) {
|
||||
v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
|
||||
PropertyCallbackInfo<v8::Value>
|
||||
cbinfo(info, obj->GetInternalField(kDataIndex));
|
||||
GetterCallback callback = reinterpret_cast<GetterCallback>(
|
||||
reinterpret_cast<intptr_t>(
|
||||
obj->GetInternalField(kGetterIndex).As<v8::External>()->Value()));
|
||||
callback(property, cbinfo);
|
||||
}
|
||||
|
||||
typedef void (*NativeGetter)
|
||||
(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value> &);
|
||||
|
||||
static
|
||||
void SetterCallbackWrapper(
|
||||
v8::Local<v8::String> property
|
||||
, v8::Local<v8::Value> value
|
||||
, const v8::PropertyCallbackInfo<void> &info) {
|
||||
v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
|
||||
PropertyCallbackInfo<void>
|
||||
cbinfo(info, obj->GetInternalField(kDataIndex));
|
||||
SetterCallback callback = reinterpret_cast<SetterCallback>(
|
||||
reinterpret_cast<intptr_t>(
|
||||
obj->GetInternalField(kSetterIndex).As<v8::External>()->Value()));
|
||||
callback(property, value, cbinfo);
|
||||
}
|
||||
|
||||
typedef void (*NativeSetter)(
|
||||
v8::Local<v8::String>
|
||||
, v8::Local<v8::Value>
|
||||
, const v8::PropertyCallbackInfo<void> &);
|
||||
#endif
|
||||
|
||||
#if NODE_MODULE_VERSION > NODE_0_12_MODULE_VERSION
|
||||
static
|
||||
void PropertyGetterCallbackWrapper(
|
||||
v8::Local<v8::Name> property
|
||||
, const v8::PropertyCallbackInfo<v8::Value> &info) {
|
||||
v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
|
||||
PropertyCallbackInfo<v8::Value>
|
||||
cbinfo(info, obj->GetInternalField(kDataIndex));
|
||||
PropertyGetterCallback callback = reinterpret_cast<PropertyGetterCallback>(
|
||||
reinterpret_cast<intptr_t>(
|
||||
obj->GetInternalField(kPropertyGetterIndex)
|
||||
.As<v8::External>()->Value()));
|
||||
callback(property.As<v8::String>(), cbinfo);
|
||||
}
|
||||
|
||||
typedef void (*NativePropertyGetter)
|
||||
(v8::Local<v8::Name>, const v8::PropertyCallbackInfo<v8::Value> &);
|
||||
|
||||
static
|
||||
void PropertySetterCallbackWrapper(
|
||||
v8::Local<v8::Name> property
|
||||
, v8::Local<v8::Value> value
|
||||
, const v8::PropertyCallbackInfo<v8::Value> &info) {
|
||||
v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
|
||||
PropertyCallbackInfo<v8::Value>
|
||||
cbinfo(info, obj->GetInternalField(kDataIndex));
|
||||
PropertySetterCallback callback = reinterpret_cast<PropertySetterCallback>(
|
||||
reinterpret_cast<intptr_t>(
|
||||
obj->GetInternalField(kPropertySetterIndex)
|
||||
.As<v8::External>()->Value()));
|
||||
callback(property.As<v8::String>(), value, cbinfo);
|
||||
}
|
||||
|
||||
typedef void (*NativePropertySetter)(
|
||||
v8::Local<v8::Name>
|
||||
, v8::Local<v8::Value>
|
||||
, const v8::PropertyCallbackInfo<v8::Value> &);
|
||||
|
||||
static
|
||||
void PropertyEnumeratorCallbackWrapper(
|
||||
const v8::PropertyCallbackInfo<v8::Array> &info) {
|
||||
v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
|
||||
PropertyCallbackInfo<v8::Array>
|
||||
cbinfo(info, obj->GetInternalField(kDataIndex));
|
||||
PropertyEnumeratorCallback callback =
|
||||
reinterpret_cast<PropertyEnumeratorCallback>(reinterpret_cast<intptr_t>(
|
||||
obj->GetInternalField(kPropertyEnumeratorIndex)
|
||||
.As<v8::External>()->Value()));
|
||||
callback(cbinfo);
|
||||
}
|
||||
|
||||
typedef void (*NativePropertyEnumerator)
|
||||
(const v8::PropertyCallbackInfo<v8::Array> &);
|
||||
|
||||
static
|
||||
void PropertyDeleterCallbackWrapper(
|
||||
v8::Local<v8::Name> property
|
||||
, const v8::PropertyCallbackInfo<v8::Boolean> &info) {
|
||||
v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
|
||||
PropertyCallbackInfo<v8::Boolean>
|
||||
cbinfo(info, obj->GetInternalField(kDataIndex));
|
||||
PropertyDeleterCallback callback = reinterpret_cast<PropertyDeleterCallback>(
|
||||
reinterpret_cast<intptr_t>(
|
||||
obj->GetInternalField(kPropertyDeleterIndex)
|
||||
.As<v8::External>()->Value()));
|
||||
callback(property.As<v8::String>(), cbinfo);
|
||||
}
|
||||
|
||||
typedef void (NativePropertyDeleter)
|
||||
(v8::Local<v8::Name>, const v8::PropertyCallbackInfo<v8::Boolean> &);
|
||||
|
||||
static
|
||||
void PropertyQueryCallbackWrapper(
|
||||
v8::Local<v8::Name> property
|
||||
, const v8::PropertyCallbackInfo<v8::Integer> &info) {
|
||||
v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
|
||||
PropertyCallbackInfo<v8::Integer>
|
||||
cbinfo(info, obj->GetInternalField(kDataIndex));
|
||||
PropertyQueryCallback callback = reinterpret_cast<PropertyQueryCallback>(
|
||||
reinterpret_cast<intptr_t>(
|
||||
obj->GetInternalField(kPropertyQueryIndex)
|
||||
.As<v8::External>()->Value()));
|
||||
callback(property.As<v8::String>(), cbinfo);
|
||||
}
|
||||
|
||||
typedef void (*NativePropertyQuery)
|
||||
(v8::Local<v8::Name>, const v8::PropertyCallbackInfo<v8::Integer> &);
|
||||
#else
|
||||
static
|
||||
void PropertyGetterCallbackWrapper(
|
||||
v8::Local<v8::String> property
|
||||
, const v8::PropertyCallbackInfo<v8::Value> &info) {
|
||||
v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
|
||||
PropertyCallbackInfo<v8::Value>
|
||||
cbinfo(info, obj->GetInternalField(kDataIndex));
|
||||
PropertyGetterCallback callback = reinterpret_cast<PropertyGetterCallback>(
|
||||
reinterpret_cast<intptr_t>(
|
||||
obj->GetInternalField(kPropertyGetterIndex)
|
||||
.As<v8::External>()->Value()));
|
||||
callback(property, cbinfo);
|
||||
}
|
||||
|
||||
typedef void (*NativePropertyGetter)
|
||||
(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value> &);
|
||||
|
||||
static
|
||||
void PropertySetterCallbackWrapper(
|
||||
v8::Local<v8::String> property
|
||||
, v8::Local<v8::Value> value
|
||||
, const v8::PropertyCallbackInfo<v8::Value> &info) {
|
||||
v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
|
||||
PropertyCallbackInfo<v8::Value>
|
||||
cbinfo(info, obj->GetInternalField(kDataIndex));
|
||||
PropertySetterCallback callback = reinterpret_cast<PropertySetterCallback>(
|
||||
reinterpret_cast<intptr_t>(
|
||||
obj->GetInternalField(kPropertySetterIndex)
|
||||
.As<v8::External>()->Value()));
|
||||
callback(property, value, cbinfo);
|
||||
}
|
||||
|
||||
typedef void (*NativePropertySetter)(
|
||||
v8::Local<v8::String>
|
||||
, v8::Local<v8::Value>
|
||||
, const v8::PropertyCallbackInfo<v8::Value> &);
|
||||
|
||||
static
|
||||
void PropertyEnumeratorCallbackWrapper(
|
||||
const v8::PropertyCallbackInfo<v8::Array> &info) {
|
||||
v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
|
||||
PropertyCallbackInfo<v8::Array>
|
||||
cbinfo(info, obj->GetInternalField(kDataIndex));
|
||||
PropertyEnumeratorCallback callback =
|
||||
reinterpret_cast<PropertyEnumeratorCallback>(reinterpret_cast<intptr_t>(
|
||||
obj->GetInternalField(kPropertyEnumeratorIndex)
|
||||
.As<v8::External>()->Value()));
|
||||
callback(cbinfo);
|
||||
}
|
||||
|
||||
typedef void (*NativePropertyEnumerator)
|
||||
(const v8::PropertyCallbackInfo<v8::Array> &);
|
||||
|
||||
static
|
||||
void PropertyDeleterCallbackWrapper(
|
||||
v8::Local<v8::String> property
|
||||
, const v8::PropertyCallbackInfo<v8::Boolean> &info) {
|
||||
v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
|
||||
PropertyCallbackInfo<v8::Boolean>
|
||||
cbinfo(info, obj->GetInternalField(kDataIndex));
|
||||
PropertyDeleterCallback callback = reinterpret_cast<PropertyDeleterCallback>(
|
||||
reinterpret_cast<intptr_t>(
|
||||
obj->GetInternalField(kPropertyDeleterIndex)
|
||||
.As<v8::External>()->Value()));
|
||||
callback(property, cbinfo);
|
||||
}
|
||||
|
||||
typedef void (NativePropertyDeleter)
|
||||
(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Boolean> &);
|
||||
|
||||
static
|
||||
void PropertyQueryCallbackWrapper(
|
||||
v8::Local<v8::String> property
|
||||
, const v8::PropertyCallbackInfo<v8::Integer> &info) {
|
||||
v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
|
||||
PropertyCallbackInfo<v8::Integer>
|
||||
cbinfo(info, obj->GetInternalField(kDataIndex));
|
||||
PropertyQueryCallback callback = reinterpret_cast<PropertyQueryCallback>(
|
||||
reinterpret_cast<intptr_t>(
|
||||
obj->GetInternalField(kPropertyQueryIndex)
|
||||
.As<v8::External>()->Value()));
|
||||
callback(property, cbinfo);
|
||||
}
|
||||
|
||||
typedef void (*NativePropertyQuery)
|
||||
(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Integer> &);
|
||||
#endif
|
||||
|
||||
static
|
||||
void IndexGetterCallbackWrapper(
|
||||
uint32_t index, const v8::PropertyCallbackInfo<v8::Value> &info) {
|
||||
v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
|
||||
PropertyCallbackInfo<v8::Value>
|
||||
cbinfo(info, obj->GetInternalField(kDataIndex));
|
||||
IndexGetterCallback callback = reinterpret_cast<IndexGetterCallback>(
|
||||
reinterpret_cast<intptr_t>(
|
||||
obj->GetInternalField(kIndexPropertyGetterIndex)
|
||||
.As<v8::External>()->Value()));
|
||||
callback(index, cbinfo);
|
||||
}
|
||||
|
||||
typedef void (*NativeIndexGetter)
|
||||
(uint32_t, const v8::PropertyCallbackInfo<v8::Value> &);
|
||||
|
||||
static
|
||||
void IndexSetterCallbackWrapper(
|
||||
uint32_t index
|
||||
, v8::Local<v8::Value> value
|
||||
, const v8::PropertyCallbackInfo<v8::Value> &info) {
|
||||
v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
|
||||
PropertyCallbackInfo<v8::Value>
|
||||
cbinfo(info, obj->GetInternalField(kDataIndex));
|
||||
IndexSetterCallback callback = reinterpret_cast<IndexSetterCallback>(
|
||||
reinterpret_cast<intptr_t>(
|
||||
obj->GetInternalField(kIndexPropertySetterIndex)
|
||||
.As<v8::External>()->Value()));
|
||||
callback(index, value, cbinfo);
|
||||
}
|
||||
|
||||
typedef void (*NativeIndexSetter)(
|
||||
uint32_t
|
||||
, v8::Local<v8::Value>
|
||||
, const v8::PropertyCallbackInfo<v8::Value> &);
|
||||
|
||||
static
|
||||
void IndexEnumeratorCallbackWrapper(
|
||||
const v8::PropertyCallbackInfo<v8::Array> &info) {
|
||||
v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
|
||||
PropertyCallbackInfo<v8::Array>
|
||||
cbinfo(info, obj->GetInternalField(kDataIndex));
|
||||
IndexEnumeratorCallback callback = reinterpret_cast<IndexEnumeratorCallback>(
|
||||
reinterpret_cast<intptr_t>(
|
||||
obj->GetInternalField(
|
||||
kIndexPropertyEnumeratorIndex).As<v8::External>()->Value()));
|
||||
callback(cbinfo);
|
||||
}
|
||||
|
||||
typedef void (*NativeIndexEnumerator)
|
||||
(const v8::PropertyCallbackInfo<v8::Array> &);
|
||||
|
||||
static
|
||||
void IndexDeleterCallbackWrapper(
|
||||
uint32_t index, const v8::PropertyCallbackInfo<v8::Boolean> &info) {
|
||||
v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
|
||||
PropertyCallbackInfo<v8::Boolean>
|
||||
cbinfo(info, obj->GetInternalField(kDataIndex));
|
||||
IndexDeleterCallback callback = reinterpret_cast<IndexDeleterCallback>(
|
||||
reinterpret_cast<intptr_t>(
|
||||
obj->GetInternalField(kIndexPropertyDeleterIndex)
|
||||
.As<v8::External>()->Value()));
|
||||
callback(index, cbinfo);
|
||||
}
|
||||
|
||||
typedef void (*NativeIndexDeleter)
|
||||
(uint32_t, const v8::PropertyCallbackInfo<v8::Boolean> &);
|
||||
|
||||
static
|
||||
void IndexQueryCallbackWrapper(
|
||||
uint32_t index, const v8::PropertyCallbackInfo<v8::Integer> &info) {
|
||||
v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
|
||||
PropertyCallbackInfo<v8::Integer>
|
||||
cbinfo(info, obj->GetInternalField(kDataIndex));
|
||||
IndexQueryCallback callback = reinterpret_cast<IndexQueryCallback>(
|
||||
reinterpret_cast<intptr_t>(
|
||||
obj->GetInternalField(kIndexPropertyQueryIndex)
|
||||
.As<v8::External>()->Value()));
|
||||
callback(index, cbinfo);
|
||||
}
|
||||
|
||||
typedef void (*NativeIndexQuery)
|
||||
(uint32_t, const v8::PropertyCallbackInfo<v8::Integer> &);
|
||||
} // end of namespace imp
|
||||
|
||||
#endif // NAN_CALLBACKS_12_INL_H_
|
||||
520
node_modules/nan/nan_callbacks_pre_12_inl.h
generated
vendored
Normal file
520
node_modules/nan/nan_callbacks_pre_12_inl.h
generated
vendored
Normal file
@@ -0,0 +1,520 @@
|
||||
/*********************************************************************
|
||||
* NAN - Native Abstractions for Node.js
|
||||
*
|
||||
* Copyright (c) 2018 NAN contributors
|
||||
*
|
||||
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
|
||||
********************************************************************/
|
||||
|
||||
#ifndef NAN_CALLBACKS_PRE_12_INL_H_
|
||||
#define NAN_CALLBACKS_PRE_12_INL_H_
|
||||
|
||||
namespace imp {
|
||||
template<typename T> class ReturnValueImp;
|
||||
} // end of namespace imp
|
||||
|
||||
template<typename T>
|
||||
class ReturnValue {
|
||||
v8::Isolate *isolate_;
|
||||
v8::Persistent<T> *value_;
|
||||
friend class imp::ReturnValueImp<T>;
|
||||
|
||||
public:
|
||||
template <class S>
|
||||
explicit inline ReturnValue(v8::Isolate *isolate, v8::Persistent<S> *p) :
|
||||
isolate_(isolate), value_(p) {}
|
||||
template <class S>
|
||||
explicit inline ReturnValue(const ReturnValue<S>& that)
|
||||
: isolate_(that.isolate_), value_(that.value_) {
|
||||
TYPE_CHECK(T, S);
|
||||
}
|
||||
|
||||
// Handle setters
|
||||
template <typename S> inline void Set(const v8::Local<S> &handle) {
|
||||
TYPE_CHECK(T, S);
|
||||
value_->Dispose();
|
||||
*value_ = v8::Persistent<T>::New(handle);
|
||||
}
|
||||
|
||||
template <typename S> inline void Set(const Global<S> &handle) {
|
||||
TYPE_CHECK(T, S);
|
||||
value_->Dispose();
|
||||
*value_ = v8::Persistent<T>::New(handle.persistent);
|
||||
const_cast<Global<S> &>(handle).Reset();
|
||||
}
|
||||
|
||||
// Fast primitive setters
|
||||
inline void Set(bool value) {
|
||||
v8::HandleScope scope;
|
||||
|
||||
TYPE_CHECK(T, v8::Boolean);
|
||||
value_->Dispose();
|
||||
*value_ = v8::Persistent<T>::New(v8::Boolean::New(value));
|
||||
}
|
||||
|
||||
inline void Set(double i) {
|
||||
v8::HandleScope scope;
|
||||
|
||||
TYPE_CHECK(T, v8::Number);
|
||||
value_->Dispose();
|
||||
*value_ = v8::Persistent<T>::New(v8::Number::New(i));
|
||||
}
|
||||
|
||||
inline void Set(int32_t i) {
|
||||
v8::HandleScope scope;
|
||||
|
||||
TYPE_CHECK(T, v8::Integer);
|
||||
value_->Dispose();
|
||||
*value_ = v8::Persistent<T>::New(v8::Int32::New(i));
|
||||
}
|
||||
|
||||
inline void Set(uint32_t i) {
|
||||
v8::HandleScope scope;
|
||||
|
||||
TYPE_CHECK(T, v8::Integer);
|
||||
value_->Dispose();
|
||||
*value_ = v8::Persistent<T>::New(v8::Uint32::NewFromUnsigned(i));
|
||||
}
|
||||
|
||||
// Fast JS primitive setters
|
||||
inline void SetNull() {
|
||||
v8::HandleScope scope;
|
||||
|
||||
TYPE_CHECK(T, v8::Primitive);
|
||||
value_->Dispose();
|
||||
*value_ = v8::Persistent<T>::New(v8::Null());
|
||||
}
|
||||
|
||||
inline void SetUndefined() {
|
||||
v8::HandleScope scope;
|
||||
|
||||
TYPE_CHECK(T, v8::Primitive);
|
||||
value_->Dispose();
|
||||
*value_ = v8::Persistent<T>::New(v8::Undefined());
|
||||
}
|
||||
|
||||
inline void SetEmptyString() {
|
||||
v8::HandleScope scope;
|
||||
|
||||
TYPE_CHECK(T, v8::String);
|
||||
value_->Dispose();
|
||||
*value_ = v8::Persistent<T>::New(v8::String::Empty());
|
||||
}
|
||||
|
||||
// Convenience getter for isolate
|
||||
inline v8::Isolate *GetIsolate() const {
|
||||
return isolate_;
|
||||
}
|
||||
|
||||
// Pointer setter: Uncompilable to prevent inadvertent misuse.
|
||||
template<typename S>
|
||||
inline void Set(S *whatever) { TYPE_CHECK(S*, v8::Primitive); }
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
class FunctionCallbackInfo {
|
||||
const v8::Arguments &args_;
|
||||
v8::Local<v8::Value> data_;
|
||||
ReturnValue<T> return_value_;
|
||||
v8::Persistent<T> retval_;
|
||||
|
||||
public:
|
||||
explicit inline FunctionCallbackInfo(
|
||||
const v8::Arguments &args
|
||||
, v8::Local<v8::Value> data) :
|
||||
args_(args)
|
||||
, data_(data)
|
||||
, return_value_(args.GetIsolate(), &retval_)
|
||||
, retval_(v8::Persistent<T>::New(v8::Undefined())) {}
|
||||
|
||||
inline ~FunctionCallbackInfo() {
|
||||
retval_.Dispose();
|
||||
retval_.Clear();
|
||||
}
|
||||
|
||||
inline ReturnValue<T> GetReturnValue() const {
|
||||
return ReturnValue<T>(return_value_);
|
||||
}
|
||||
|
||||
inline v8::Local<v8::Function> Callee() const { return args_.Callee(); }
|
||||
inline v8::Local<v8::Value> Data() const { return data_; }
|
||||
inline v8::Local<v8::Object> Holder() const { return args_.Holder(); }
|
||||
inline bool IsConstructCall() const { return args_.IsConstructCall(); }
|
||||
inline int Length() const { return args_.Length(); }
|
||||
inline v8::Local<v8::Value> operator[](int i) const { return args_[i]; }
|
||||
inline v8::Local<v8::Object> This() const { return args_.This(); }
|
||||
inline v8::Isolate *GetIsolate() const { return args_.GetIsolate(); }
|
||||
|
||||
|
||||
protected:
|
||||
static const int kHolderIndex = 0;
|
||||
static const int kIsolateIndex = 1;
|
||||
static const int kReturnValueDefaultValueIndex = 2;
|
||||
static const int kReturnValueIndex = 3;
|
||||
static const int kDataIndex = 4;
|
||||
static const int kCalleeIndex = 5;
|
||||
static const int kContextSaveIndex = 6;
|
||||
static const int kArgsLength = 7;
|
||||
|
||||
private:
|
||||
NAN_DISALLOW_ASSIGN_COPY_MOVE(FunctionCallbackInfo)
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
class PropertyCallbackInfoBase {
|
||||
const v8::AccessorInfo &info_;
|
||||
const v8::Local<v8::Value> data_;
|
||||
|
||||
public:
|
||||
explicit inline PropertyCallbackInfoBase(
|
||||
const v8::AccessorInfo &info
|
||||
, const v8::Local<v8::Value> data) :
|
||||
info_(info)
|
||||
, data_(data) {}
|
||||
|
||||
inline v8::Isolate* GetIsolate() const { return info_.GetIsolate(); }
|
||||
inline v8::Local<v8::Value> Data() const { return data_; }
|
||||
inline v8::Local<v8::Object> This() const { return info_.This(); }
|
||||
inline v8::Local<v8::Object> Holder() const { return info_.Holder(); }
|
||||
|
||||
protected:
|
||||
static const int kHolderIndex = 0;
|
||||
static const int kIsolateIndex = 1;
|
||||
static const int kReturnValueDefaultValueIndex = 2;
|
||||
static const int kReturnValueIndex = 3;
|
||||
static const int kDataIndex = 4;
|
||||
static const int kThisIndex = 5;
|
||||
static const int kArgsLength = 6;
|
||||
|
||||
private:
|
||||
NAN_DISALLOW_ASSIGN_COPY_MOVE(PropertyCallbackInfoBase)
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
class PropertyCallbackInfo : public PropertyCallbackInfoBase<T> {
|
||||
ReturnValue<T> return_value_;
|
||||
v8::Persistent<T> retval_;
|
||||
|
||||
public:
|
||||
explicit inline PropertyCallbackInfo(
|
||||
const v8::AccessorInfo &info
|
||||
, const v8::Local<v8::Value> data) :
|
||||
PropertyCallbackInfoBase<T>(info, data)
|
||||
, return_value_(info.GetIsolate(), &retval_)
|
||||
, retval_(v8::Persistent<T>::New(v8::Undefined())) {}
|
||||
|
||||
inline ~PropertyCallbackInfo() {
|
||||
retval_.Dispose();
|
||||
retval_.Clear();
|
||||
}
|
||||
|
||||
inline ReturnValue<T> GetReturnValue() const { return return_value_; }
|
||||
};
|
||||
|
||||
template<>
|
||||
class PropertyCallbackInfo<v8::Array> :
|
||||
public PropertyCallbackInfoBase<v8::Array> {
|
||||
ReturnValue<v8::Array> return_value_;
|
||||
v8::Persistent<v8::Array> retval_;
|
||||
|
||||
public:
|
||||
explicit inline PropertyCallbackInfo(
|
||||
const v8::AccessorInfo &info
|
||||
, const v8::Local<v8::Value> data) :
|
||||
PropertyCallbackInfoBase<v8::Array>(info, data)
|
||||
, return_value_(info.GetIsolate(), &retval_)
|
||||
, retval_(v8::Persistent<v8::Array>::New(v8::Local<v8::Array>())) {}
|
||||
|
||||
inline ~PropertyCallbackInfo() {
|
||||
retval_.Dispose();
|
||||
retval_.Clear();
|
||||
}
|
||||
|
||||
inline ReturnValue<v8::Array> GetReturnValue() const {
|
||||
return return_value_;
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
class PropertyCallbackInfo<v8::Boolean> :
|
||||
public PropertyCallbackInfoBase<v8::Boolean> {
|
||||
ReturnValue<v8::Boolean> return_value_;
|
||||
v8::Persistent<v8::Boolean> retval_;
|
||||
|
||||
public:
|
||||
explicit inline PropertyCallbackInfo(
|
||||
const v8::AccessorInfo &info
|
||||
, const v8::Local<v8::Value> data) :
|
||||
PropertyCallbackInfoBase<v8::Boolean>(info, data)
|
||||
, return_value_(info.GetIsolate(), &retval_)
|
||||
, retval_(v8::Persistent<v8::Boolean>::New(v8::Local<v8::Boolean>())) {}
|
||||
|
||||
inline ~PropertyCallbackInfo() {
|
||||
retval_.Dispose();
|
||||
retval_.Clear();
|
||||
}
|
||||
|
||||
inline ReturnValue<v8::Boolean> GetReturnValue() const {
|
||||
return return_value_;
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
class PropertyCallbackInfo<v8::Integer> :
|
||||
public PropertyCallbackInfoBase<v8::Integer> {
|
||||
ReturnValue<v8::Integer> return_value_;
|
||||
v8::Persistent<v8::Integer> retval_;
|
||||
|
||||
public:
|
||||
explicit inline PropertyCallbackInfo(
|
||||
const v8::AccessorInfo &info
|
||||
, const v8::Local<v8::Value> data) :
|
||||
PropertyCallbackInfoBase<v8::Integer>(info, data)
|
||||
, return_value_(info.GetIsolate(), &retval_)
|
||||
, retval_(v8::Persistent<v8::Integer>::New(v8::Local<v8::Integer>())) {}
|
||||
|
||||
inline ~PropertyCallbackInfo() {
|
||||
retval_.Dispose();
|
||||
retval_.Clear();
|
||||
}
|
||||
|
||||
inline ReturnValue<v8::Integer> GetReturnValue() const {
|
||||
return return_value_;
|
||||
}
|
||||
};
|
||||
|
||||
namespace imp {
|
||||
template<typename T>
|
||||
class ReturnValueImp : public ReturnValue<T> {
|
||||
public:
|
||||
explicit ReturnValueImp(ReturnValue<T> that) :
|
||||
ReturnValue<T>(that) {}
|
||||
inline v8::Handle<T> Value() {
|
||||
return *ReturnValue<T>::value_;
|
||||
}
|
||||
};
|
||||
|
||||
static
|
||||
v8::Handle<v8::Value> FunctionCallbackWrapper(const v8::Arguments &args) {
|
||||
v8::Local<v8::Object> obj = args.Data().As<v8::Object>();
|
||||
FunctionCallback callback = reinterpret_cast<FunctionCallback>(
|
||||
reinterpret_cast<intptr_t>(
|
||||
obj->GetInternalField(kFunctionIndex).As<v8::External>()->Value()));
|
||||
FunctionCallbackInfo<v8::Value>
|
||||
cbinfo(args, obj->GetInternalField(kDataIndex));
|
||||
callback(cbinfo);
|
||||
return ReturnValueImp<v8::Value>(cbinfo.GetReturnValue()).Value();
|
||||
}
|
||||
|
||||
typedef v8::Handle<v8::Value> (*NativeFunction)(const v8::Arguments &);
|
||||
|
||||
static
|
||||
v8::Handle<v8::Value> GetterCallbackWrapper(
|
||||
v8::Local<v8::String> property, const v8::AccessorInfo &info) {
|
||||
v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
|
||||
PropertyCallbackInfo<v8::Value>
|
||||
cbinfo(info, obj->GetInternalField(kDataIndex));
|
||||
GetterCallback callback = reinterpret_cast<GetterCallback>(
|
||||
reinterpret_cast<intptr_t>(
|
||||
obj->GetInternalField(kGetterIndex).As<v8::External>()->Value()));
|
||||
callback(property, cbinfo);
|
||||
return ReturnValueImp<v8::Value>(cbinfo.GetReturnValue()).Value();
|
||||
}
|
||||
|
||||
typedef v8::Handle<v8::Value> (*NativeGetter)
|
||||
(v8::Local<v8::String>, const v8::AccessorInfo &);
|
||||
|
||||
static
|
||||
void SetterCallbackWrapper(
|
||||
v8::Local<v8::String> property
|
||||
, v8::Local<v8::Value> value
|
||||
, const v8::AccessorInfo &info) {
|
||||
v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
|
||||
PropertyCallbackInfo<void>
|
||||
cbinfo(info, obj->GetInternalField(kDataIndex));
|
||||
SetterCallback callback = reinterpret_cast<SetterCallback>(
|
||||
reinterpret_cast<intptr_t>(
|
||||
obj->GetInternalField(kSetterIndex).As<v8::External>()->Value()));
|
||||
callback(property, value, cbinfo);
|
||||
}
|
||||
|
||||
typedef void (*NativeSetter)
|
||||
(v8::Local<v8::String>, v8::Local<v8::Value>, const v8::AccessorInfo &);
|
||||
|
||||
static
|
||||
v8::Handle<v8::Value> PropertyGetterCallbackWrapper(
|
||||
v8::Local<v8::String> property, const v8::AccessorInfo &info) {
|
||||
v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
|
||||
PropertyCallbackInfo<v8::Value>
|
||||
cbinfo(info, obj->GetInternalField(kDataIndex));
|
||||
PropertyGetterCallback callback = reinterpret_cast<PropertyGetterCallback>(
|
||||
reinterpret_cast<intptr_t>(
|
||||
obj->GetInternalField(kPropertyGetterIndex)
|
||||
.As<v8::External>()->Value()));
|
||||
callback(property, cbinfo);
|
||||
return ReturnValueImp<v8::Value>(cbinfo.GetReturnValue()).Value();
|
||||
}
|
||||
|
||||
typedef v8::Handle<v8::Value> (*NativePropertyGetter)
|
||||
(v8::Local<v8::String>, const v8::AccessorInfo &);
|
||||
|
||||
static
|
||||
v8::Handle<v8::Value> PropertySetterCallbackWrapper(
|
||||
v8::Local<v8::String> property
|
||||
, v8::Local<v8::Value> value
|
||||
, const v8::AccessorInfo &info) {
|
||||
v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
|
||||
PropertyCallbackInfo<v8::Value>
|
||||
cbinfo(info, obj->GetInternalField(kDataIndex));
|
||||
PropertySetterCallback callback = reinterpret_cast<PropertySetterCallback>(
|
||||
reinterpret_cast<intptr_t>(
|
||||
obj->GetInternalField(kPropertySetterIndex)
|
||||
.As<v8::External>()->Value()));
|
||||
callback(property, value, cbinfo);
|
||||
return ReturnValueImp<v8::Value>(cbinfo.GetReturnValue()).Value();
|
||||
}
|
||||
|
||||
typedef v8::Handle<v8::Value> (*NativePropertySetter)
|
||||
(v8::Local<v8::String>, v8::Local<v8::Value>, const v8::AccessorInfo &);
|
||||
|
||||
static
|
||||
v8::Handle<v8::Array> PropertyEnumeratorCallbackWrapper(
|
||||
const v8::AccessorInfo &info) {
|
||||
v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
|
||||
PropertyCallbackInfo<v8::Array>
|
||||
cbinfo(info, obj->GetInternalField(kDataIndex));
|
||||
PropertyEnumeratorCallback callback =
|
||||
reinterpret_cast<PropertyEnumeratorCallback>(reinterpret_cast<intptr_t>(
|
||||
obj->GetInternalField(kPropertyEnumeratorIndex)
|
||||
.As<v8::External>()->Value()));
|
||||
callback(cbinfo);
|
||||
return ReturnValueImp<v8::Array>(cbinfo.GetReturnValue()).Value();
|
||||
}
|
||||
|
||||
typedef v8::Handle<v8::Array> (*NativePropertyEnumerator)
|
||||
(const v8::AccessorInfo &);
|
||||
|
||||
static
|
||||
v8::Handle<v8::Boolean> PropertyDeleterCallbackWrapper(
|
||||
v8::Local<v8::String> property
|
||||
, const v8::AccessorInfo &info) {
|
||||
v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
|
||||
PropertyCallbackInfo<v8::Boolean>
|
||||
cbinfo(info, obj->GetInternalField(kDataIndex));
|
||||
PropertyDeleterCallback callback = reinterpret_cast<PropertyDeleterCallback>(
|
||||
reinterpret_cast<intptr_t>(
|
||||
obj->GetInternalField(kPropertyDeleterIndex)
|
||||
.As<v8::External>()->Value()));
|
||||
callback(property, cbinfo);
|
||||
return ReturnValueImp<v8::Boolean>(cbinfo.GetReturnValue()).Value();
|
||||
}
|
||||
|
||||
typedef v8::Handle<v8::Boolean> (NativePropertyDeleter)
|
||||
(v8::Local<v8::String>, const v8::AccessorInfo &);
|
||||
|
||||
static
|
||||
v8::Handle<v8::Integer> PropertyQueryCallbackWrapper(
|
||||
v8::Local<v8::String> property, const v8::AccessorInfo &info) {
|
||||
v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
|
||||
PropertyCallbackInfo<v8::Integer>
|
||||
cbinfo(info, obj->GetInternalField(kDataIndex));
|
||||
PropertyQueryCallback callback = reinterpret_cast<PropertyQueryCallback>(
|
||||
reinterpret_cast<intptr_t>(
|
||||
obj->GetInternalField(kPropertyQueryIndex)
|
||||
.As<v8::External>()->Value()));
|
||||
callback(property, cbinfo);
|
||||
return ReturnValueImp<v8::Integer>(cbinfo.GetReturnValue()).Value();
|
||||
}
|
||||
|
||||
typedef v8::Handle<v8::Integer> (*NativePropertyQuery)
|
||||
(v8::Local<v8::String>, const v8::AccessorInfo &);
|
||||
|
||||
static
|
||||
v8::Handle<v8::Value> IndexGetterCallbackWrapper(
|
||||
uint32_t index, const v8::AccessorInfo &info) {
|
||||
v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
|
||||
PropertyCallbackInfo<v8::Value>
|
||||
cbinfo(info, obj->GetInternalField(kDataIndex));
|
||||
IndexGetterCallback callback = reinterpret_cast<IndexGetterCallback>(
|
||||
reinterpret_cast<intptr_t>(
|
||||
obj->GetInternalField(kIndexPropertyGetterIndex)
|
||||
.As<v8::External>()->Value()));
|
||||
callback(index, cbinfo);
|
||||
return ReturnValueImp<v8::Value>(cbinfo.GetReturnValue()).Value();
|
||||
}
|
||||
|
||||
typedef v8::Handle<v8::Value> (*NativeIndexGetter)
|
||||
(uint32_t, const v8::AccessorInfo &);
|
||||
|
||||
static
|
||||
v8::Handle<v8::Value> IndexSetterCallbackWrapper(
|
||||
uint32_t index
|
||||
, v8::Local<v8::Value> value
|
||||
, const v8::AccessorInfo &info) {
|
||||
v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
|
||||
PropertyCallbackInfo<v8::Value>
|
||||
cbinfo(info, obj->GetInternalField(kDataIndex));
|
||||
IndexSetterCallback callback = reinterpret_cast<IndexSetterCallback>(
|
||||
reinterpret_cast<intptr_t>(
|
||||
obj->GetInternalField(kIndexPropertySetterIndex)
|
||||
.As<v8::External>()->Value()));
|
||||
callback(index, value, cbinfo);
|
||||
return ReturnValueImp<v8::Value>(cbinfo.GetReturnValue()).Value();
|
||||
}
|
||||
|
||||
typedef v8::Handle<v8::Value> (*NativeIndexSetter)
|
||||
(uint32_t, v8::Local<v8::Value>, const v8::AccessorInfo &);
|
||||
|
||||
static
|
||||
v8::Handle<v8::Array> IndexEnumeratorCallbackWrapper(
|
||||
const v8::AccessorInfo &info) {
|
||||
v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
|
||||
PropertyCallbackInfo<v8::Array>
|
||||
cbinfo(info, obj->GetInternalField(kDataIndex));
|
||||
IndexEnumeratorCallback callback = reinterpret_cast<IndexEnumeratorCallback>(
|
||||
reinterpret_cast<intptr_t>(
|
||||
obj->GetInternalField(kIndexPropertyEnumeratorIndex)
|
||||
.As<v8::External>()->Value()));
|
||||
callback(cbinfo);
|
||||
return ReturnValueImp<v8::Array>(cbinfo.GetReturnValue()).Value();
|
||||
}
|
||||
|
||||
typedef v8::Handle<v8::Array> (*NativeIndexEnumerator)
|
||||
(const v8::AccessorInfo &);
|
||||
|
||||
static
|
||||
v8::Handle<v8::Boolean> IndexDeleterCallbackWrapper(
|
||||
uint32_t index, const v8::AccessorInfo &info) {
|
||||
v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
|
||||
PropertyCallbackInfo<v8::Boolean>
|
||||
cbinfo(info, obj->GetInternalField(kDataIndex));
|
||||
IndexDeleterCallback callback = reinterpret_cast<IndexDeleterCallback>(
|
||||
reinterpret_cast<intptr_t>(
|
||||
obj->GetInternalField(kIndexPropertyDeleterIndex)
|
||||
.As<v8::External>()->Value()));
|
||||
callback(index, cbinfo);
|
||||
return ReturnValueImp<v8::Boolean>(cbinfo.GetReturnValue()).Value();
|
||||
}
|
||||
|
||||
typedef v8::Handle<v8::Boolean> (*NativeIndexDeleter)
|
||||
(uint32_t, const v8::AccessorInfo &);
|
||||
|
||||
static
|
||||
v8::Handle<v8::Integer> IndexQueryCallbackWrapper(
|
||||
uint32_t index, const v8::AccessorInfo &info) {
|
||||
v8::Local<v8::Object> obj = info.Data().As<v8::Object>();
|
||||
PropertyCallbackInfo<v8::Integer>
|
||||
cbinfo(info, obj->GetInternalField(kDataIndex));
|
||||
IndexQueryCallback callback = reinterpret_cast<IndexQueryCallback>(
|
||||
reinterpret_cast<intptr_t>(
|
||||
obj->GetInternalField(kIndexPropertyQueryIndex)
|
||||
.As<v8::External>()->Value()));
|
||||
callback(index, cbinfo);
|
||||
return ReturnValueImp<v8::Integer>(cbinfo.GetReturnValue()).Value();
|
||||
}
|
||||
|
||||
typedef v8::Handle<v8::Integer> (*NativeIndexQuery)
|
||||
(uint32_t, const v8::AccessorInfo &);
|
||||
} // end of namespace imp
|
||||
|
||||
#endif // NAN_CALLBACKS_PRE_12_INL_H_
|
||||
72
node_modules/nan/nan_converters.h
generated
vendored
Normal file
72
node_modules/nan/nan_converters.h
generated
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
/*********************************************************************
|
||||
* NAN - Native Abstractions for Node.js
|
||||
*
|
||||
* Copyright (c) 2018 NAN contributors
|
||||
*
|
||||
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
|
||||
********************************************************************/
|
||||
|
||||
#ifndef NAN_CONVERTERS_H_
|
||||
#define NAN_CONVERTERS_H_
|
||||
|
||||
namespace imp {
|
||||
template<typename T> struct ToFactoryBase {
|
||||
typedef MaybeLocal<T> return_t;
|
||||
};
|
||||
template<typename T> struct ValueFactoryBase { typedef Maybe<T> return_t; };
|
||||
|
||||
template<typename T> struct ToFactory;
|
||||
|
||||
template<>
|
||||
struct ToFactory<v8::Function> : ToFactoryBase<v8::Function> {
|
||||
static inline return_t convert(v8::Local<v8::Value> val) {
|
||||
if (val.IsEmpty() || !val->IsFunction()) return MaybeLocal<v8::Function>();
|
||||
return MaybeLocal<v8::Function>(val.As<v8::Function>());
|
||||
}
|
||||
};
|
||||
|
||||
#define X(TYPE) \
|
||||
template<> \
|
||||
struct ToFactory<v8::TYPE> : ToFactoryBase<v8::TYPE> { \
|
||||
static inline return_t convert(v8::Local<v8::Value> val); \
|
||||
};
|
||||
|
||||
X(Boolean)
|
||||
X(Number)
|
||||
X(String)
|
||||
X(Object)
|
||||
X(Integer)
|
||||
X(Uint32)
|
||||
X(Int32)
|
||||
|
||||
#undef X
|
||||
|
||||
#define X(TYPE) \
|
||||
template<> \
|
||||
struct ToFactory<TYPE> : ValueFactoryBase<TYPE> { \
|
||||
static inline return_t convert(v8::Local<v8::Value> val); \
|
||||
};
|
||||
|
||||
X(bool)
|
||||
X(double)
|
||||
X(int64_t)
|
||||
X(uint32_t)
|
||||
X(int32_t)
|
||||
|
||||
#undef X
|
||||
} // end of namespace imp
|
||||
|
||||
template<typename T>
|
||||
inline
|
||||
typename imp::ToFactory<T>::return_t To(v8::Local<v8::Value> val) {
|
||||
return imp::ToFactory<T>::convert(val);
|
||||
}
|
||||
|
||||
#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 4 || \
|
||||
(V8_MAJOR_VERSION == 4 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION >= 3))
|
||||
# include "nan_converters_43_inl.h"
|
||||
#else
|
||||
# include "nan_converters_pre_43_inl.h"
|
||||
#endif
|
||||
|
||||
#endif // NAN_CONVERTERS_H_
|
||||
48
node_modules/nan/nan_converters_43_inl.h
generated
vendored
Normal file
48
node_modules/nan/nan_converters_43_inl.h
generated
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
/*********************************************************************
|
||||
* NAN - Native Abstractions for Node.js
|
||||
*
|
||||
* Copyright (c) 2018 NAN contributors
|
||||
*
|
||||
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
|
||||
********************************************************************/
|
||||
|
||||
#ifndef NAN_CONVERTERS_43_INL_H_
|
||||
#define NAN_CONVERTERS_43_INL_H_
|
||||
|
||||
#define X(TYPE) \
|
||||
imp::ToFactory<v8::TYPE>::return_t \
|
||||
imp::ToFactory<v8::TYPE>::convert(v8::Local<v8::Value> val) { \
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent(); \
|
||||
v8::EscapableHandleScope scope(isolate); \
|
||||
return scope.Escape( \
|
||||
val->To ## TYPE(isolate->GetCurrentContext()) \
|
||||
.FromMaybe(v8::Local<v8::TYPE>())); \
|
||||
}
|
||||
|
||||
X(Boolean)
|
||||
X(Number)
|
||||
X(String)
|
||||
X(Object)
|
||||
X(Integer)
|
||||
X(Uint32)
|
||||
X(Int32)
|
||||
|
||||
#undef X
|
||||
|
||||
#define X(TYPE, NAME) \
|
||||
imp::ToFactory<TYPE>::return_t \
|
||||
imp::ToFactory<TYPE>::convert(v8::Local<v8::Value> val) { \
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent(); \
|
||||
v8::HandleScope scope(isolate); \
|
||||
return val->NAME ## Value(isolate->GetCurrentContext()); \
|
||||
}
|
||||
|
||||
X(bool, Boolean)
|
||||
X(double, Number)
|
||||
X(int64_t, Integer)
|
||||
X(uint32_t, Uint32)
|
||||
X(int32_t, Int32)
|
||||
|
||||
#undef X
|
||||
|
||||
#endif // NAN_CONVERTERS_43_INL_H_
|
||||
42
node_modules/nan/nan_converters_pre_43_inl.h
generated
vendored
Normal file
42
node_modules/nan/nan_converters_pre_43_inl.h
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
/*********************************************************************
|
||||
* NAN - Native Abstractions for Node.js
|
||||
*
|
||||
* Copyright (c) 2018 NAN contributors
|
||||
*
|
||||
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
|
||||
********************************************************************/
|
||||
|
||||
#ifndef NAN_CONVERTERS_PRE_43_INL_H_
|
||||
#define NAN_CONVERTERS_PRE_43_INL_H_
|
||||
|
||||
#define X(TYPE) \
|
||||
imp::ToFactory<v8::TYPE>::return_t \
|
||||
imp::ToFactory<v8::TYPE>::convert(v8::Local<v8::Value> val) { \
|
||||
return val->To ## TYPE(); \
|
||||
}
|
||||
|
||||
X(Boolean)
|
||||
X(Number)
|
||||
X(String)
|
||||
X(Object)
|
||||
X(Integer)
|
||||
X(Uint32)
|
||||
X(Int32)
|
||||
|
||||
#undef X
|
||||
|
||||
#define X(TYPE, NAME) \
|
||||
imp::ToFactory<TYPE>::return_t \
|
||||
imp::ToFactory<TYPE>::convert(v8::Local<v8::Value> val) { \
|
||||
return Just(val->NAME ## Value()); \
|
||||
}
|
||||
|
||||
X(bool, Boolean)
|
||||
X(double, Number)
|
||||
X(int64_t, Integer)
|
||||
X(uint32_t, Uint32)
|
||||
X(int32_t, Int32)
|
||||
|
||||
#undef X
|
||||
|
||||
#endif // NAN_CONVERTERS_PRE_43_INL_H_
|
||||
29
node_modules/nan/nan_define_own_property_helper.h
generated
vendored
Normal file
29
node_modules/nan/nan_define_own_property_helper.h
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
/*********************************************************************
|
||||
* NAN - Native Abstractions for Node.js
|
||||
*
|
||||
* Copyright (c) 2018 NAN contributors
|
||||
*
|
||||
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
|
||||
********************************************************************/
|
||||
|
||||
#ifndef NAN_DEFINE_OWN_PROPERTY_HELPER_H_
|
||||
#define NAN_DEFINE_OWN_PROPERTY_HELPER_H_
|
||||
|
||||
namespace imp {
|
||||
|
||||
inline Maybe<bool> DefineOwnPropertyHelper(
|
||||
v8::PropertyAttribute current
|
||||
, v8::Handle<v8::Object> obj
|
||||
, v8::Handle<v8::String> key
|
||||
, v8::Handle<v8::Value> value
|
||||
, v8::PropertyAttribute attribs = v8::None) {
|
||||
return !(current & v8::DontDelete) || // configurable OR
|
||||
(!(current & v8::ReadOnly) && // writable AND
|
||||
!((attribs ^ current) & ~v8::ReadOnly)) // same excluding RO
|
||||
? Just<bool>(obj->ForceSet(key, value, attribs))
|
||||
: Nothing<bool>();
|
||||
}
|
||||
|
||||
} // end of namespace imp
|
||||
|
||||
#endif // NAN_DEFINE_OWN_PROPERTY_HELPER_H_
|
||||
399
node_modules/nan/nan_implementation_12_inl.h
generated
vendored
Normal file
399
node_modules/nan/nan_implementation_12_inl.h
generated
vendored
Normal file
@@ -0,0 +1,399 @@
|
||||
/*********************************************************************
|
||||
* NAN - Native Abstractions for Node.js
|
||||
*
|
||||
* Copyright (c) 2018 NAN contributors
|
||||
*
|
||||
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
|
||||
********************************************************************/
|
||||
|
||||
#ifndef NAN_IMPLEMENTATION_12_INL_H_
|
||||
#define NAN_IMPLEMENTATION_12_INL_H_
|
||||
//==============================================================================
|
||||
// node v0.11 implementation
|
||||
//==============================================================================
|
||||
|
||||
namespace imp {
|
||||
|
||||
//=== Array ====================================================================
|
||||
|
||||
Factory<v8::Array>::return_t
|
||||
Factory<v8::Array>::New() {
|
||||
return v8::Array::New(v8::Isolate::GetCurrent());
|
||||
}
|
||||
|
||||
Factory<v8::Array>::return_t
|
||||
Factory<v8::Array>::New(int length) {
|
||||
return v8::Array::New(v8::Isolate::GetCurrent(), length);
|
||||
}
|
||||
|
||||
//=== Boolean ==================================================================
|
||||
|
||||
Factory<v8::Boolean>::return_t
|
||||
Factory<v8::Boolean>::New(bool value) {
|
||||
return v8::Boolean::New(v8::Isolate::GetCurrent(), value);
|
||||
}
|
||||
|
||||
//=== Boolean Object ===========================================================
|
||||
|
||||
Factory<v8::BooleanObject>::return_t
|
||||
Factory<v8::BooleanObject>::New(bool value) {
|
||||
#if (NODE_MODULE_VERSION >= NODE_6_0_MODULE_VERSION)
|
||||
return v8::BooleanObject::New(
|
||||
v8::Isolate::GetCurrent(), value).As<v8::BooleanObject>();
|
||||
#else
|
||||
return v8::BooleanObject::New(value).As<v8::BooleanObject>();
|
||||
#endif
|
||||
}
|
||||
|
||||
//=== Context ==================================================================
|
||||
|
||||
Factory<v8::Context>::return_t
|
||||
Factory<v8::Context>::New( v8::ExtensionConfiguration* extensions
|
||||
, v8::Local<v8::ObjectTemplate> tmpl
|
||||
, v8::Local<v8::Value> obj) {
|
||||
return v8::Context::New(v8::Isolate::GetCurrent(), extensions, tmpl, obj);
|
||||
}
|
||||
|
||||
//=== Date =====================================================================
|
||||
|
||||
#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 4 || \
|
||||
(V8_MAJOR_VERSION == 4 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION >= 3))
|
||||
Factory<v8::Date>::return_t
|
||||
Factory<v8::Date>::New(double value) {
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::EscapableHandleScope scope(isolate);
|
||||
return scope.Escape(v8::Date::New(isolate->GetCurrentContext(), value)
|
||||
.FromMaybe(v8::Local<v8::Value>()).As<v8::Date>());
|
||||
}
|
||||
#else
|
||||
Factory<v8::Date>::return_t
|
||||
Factory<v8::Date>::New(double value) {
|
||||
return v8::Date::New(v8::Isolate::GetCurrent(), value).As<v8::Date>();
|
||||
}
|
||||
#endif
|
||||
|
||||
//=== External =================================================================
|
||||
|
||||
Factory<v8::External>::return_t
|
||||
Factory<v8::External>::New(void * value) {
|
||||
return v8::External::New(v8::Isolate::GetCurrent(), value);
|
||||
}
|
||||
|
||||
//=== Function =================================================================
|
||||
|
||||
Factory<v8::Function>::return_t
|
||||
Factory<v8::Function>::New( FunctionCallback callback
|
||||
, v8::Local<v8::Value> data) {
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::EscapableHandleScope scope(isolate);
|
||||
v8::Local<v8::ObjectTemplate> tpl = v8::ObjectTemplate::New(isolate);
|
||||
tpl->SetInternalFieldCount(imp::kFunctionFieldCount);
|
||||
v8::Local<v8::Object> obj = NewInstance(tpl).ToLocalChecked();
|
||||
|
||||
obj->SetInternalField(
|
||||
imp::kFunctionIndex
|
||||
, v8::External::New(isolate, reinterpret_cast<void *>(callback)));
|
||||
|
||||
v8::Local<v8::Value> val = v8::Local<v8::Value>::New(isolate, data);
|
||||
|
||||
if (!val.IsEmpty()) {
|
||||
obj->SetInternalField(imp::kDataIndex, val);
|
||||
}
|
||||
|
||||
return scope.Escape(v8::Function::New( isolate
|
||||
, imp::FunctionCallbackWrapper
|
||||
, obj));
|
||||
}
|
||||
|
||||
//=== Function Template ========================================================
|
||||
|
||||
Factory<v8::FunctionTemplate>::return_t
|
||||
Factory<v8::FunctionTemplate>::New( FunctionCallback callback
|
||||
, v8::Local<v8::Value> data
|
||||
, v8::Local<v8::Signature> signature) {
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
if (callback) {
|
||||
v8::EscapableHandleScope scope(isolate);
|
||||
v8::Local<v8::ObjectTemplate> tpl = v8::ObjectTemplate::New(isolate);
|
||||
tpl->SetInternalFieldCount(imp::kFunctionFieldCount);
|
||||
v8::Local<v8::Object> obj = NewInstance(tpl).ToLocalChecked();
|
||||
|
||||
obj->SetInternalField(
|
||||
imp::kFunctionIndex
|
||||
, v8::External::New(isolate, reinterpret_cast<void *>(callback)));
|
||||
v8::Local<v8::Value> val = v8::Local<v8::Value>::New(isolate, data);
|
||||
|
||||
if (!val.IsEmpty()) {
|
||||
obj->SetInternalField(imp::kDataIndex, val);
|
||||
}
|
||||
|
||||
return scope.Escape(v8::FunctionTemplate::New( isolate
|
||||
, imp::FunctionCallbackWrapper
|
||||
, obj
|
||||
, signature));
|
||||
} else {
|
||||
return v8::FunctionTemplate::New(isolate, 0, data, signature);
|
||||
}
|
||||
}
|
||||
|
||||
//=== Number ===================================================================
|
||||
|
||||
Factory<v8::Number>::return_t
|
||||
Factory<v8::Number>::New(double value) {
|
||||
return v8::Number::New(v8::Isolate::GetCurrent(), value);
|
||||
}
|
||||
|
||||
//=== Number Object ============================================================
|
||||
|
||||
Factory<v8::NumberObject>::return_t
|
||||
Factory<v8::NumberObject>::New(double value) {
|
||||
return v8::NumberObject::New( v8::Isolate::GetCurrent()
|
||||
, value).As<v8::NumberObject>();
|
||||
}
|
||||
|
||||
//=== Integer, Int32 and Uint32 ================================================
|
||||
|
||||
template <typename T>
|
||||
typename IntegerFactory<T>::return_t
|
||||
IntegerFactory<T>::New(int32_t value) {
|
||||
return To<T>(T::New(v8::Isolate::GetCurrent(), value));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
typename IntegerFactory<T>::return_t
|
||||
IntegerFactory<T>::New(uint32_t value) {
|
||||
return To<T>(T::NewFromUnsigned(v8::Isolate::GetCurrent(), value));
|
||||
}
|
||||
|
||||
Factory<v8::Uint32>::return_t
|
||||
Factory<v8::Uint32>::New(int32_t value) {
|
||||
return To<v8::Uint32>(
|
||||
v8::Uint32::NewFromUnsigned(v8::Isolate::GetCurrent(), value));
|
||||
}
|
||||
|
||||
Factory<v8::Uint32>::return_t
|
||||
Factory<v8::Uint32>::New(uint32_t value) {
|
||||
return To<v8::Uint32>(
|
||||
v8::Uint32::NewFromUnsigned(v8::Isolate::GetCurrent(), value));
|
||||
}
|
||||
|
||||
//=== Object ===================================================================
|
||||
|
||||
Factory<v8::Object>::return_t
|
||||
Factory<v8::Object>::New() {
|
||||
return v8::Object::New(v8::Isolate::GetCurrent());
|
||||
}
|
||||
|
||||
//=== Object Template ==========================================================
|
||||
|
||||
Factory<v8::ObjectTemplate>::return_t
|
||||
Factory<v8::ObjectTemplate>::New() {
|
||||
return v8::ObjectTemplate::New(v8::Isolate::GetCurrent());
|
||||
}
|
||||
|
||||
//=== RegExp ===================================================================
|
||||
|
||||
#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 4 || \
|
||||
(V8_MAJOR_VERSION == 4 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION >= 3))
|
||||
Factory<v8::RegExp>::return_t
|
||||
Factory<v8::RegExp>::New(
|
||||
v8::Local<v8::String> pattern
|
||||
, v8::RegExp::Flags flags) {
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::EscapableHandleScope scope(isolate);
|
||||
return scope.Escape(
|
||||
v8::RegExp::New(isolate->GetCurrentContext(), pattern, flags)
|
||||
.FromMaybe(v8::Local<v8::RegExp>()));
|
||||
}
|
||||
#else
|
||||
Factory<v8::RegExp>::return_t
|
||||
Factory<v8::RegExp>::New(
|
||||
v8::Local<v8::String> pattern
|
||||
, v8::RegExp::Flags flags) {
|
||||
return v8::RegExp::New(pattern, flags);
|
||||
}
|
||||
#endif
|
||||
|
||||
//=== Script ===================================================================
|
||||
|
||||
#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 4 || \
|
||||
(V8_MAJOR_VERSION == 4 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION >= 3))
|
||||
Factory<v8::Script>::return_t
|
||||
Factory<v8::Script>::New( v8::Local<v8::String> source) {
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::EscapableHandleScope scope(isolate);
|
||||
v8::ScriptCompiler::Source src(source);
|
||||
return scope.Escape(
|
||||
v8::ScriptCompiler::Compile(isolate->GetCurrentContext(), &src)
|
||||
.FromMaybe(v8::Local<v8::Script>()));
|
||||
}
|
||||
|
||||
Factory<v8::Script>::return_t
|
||||
Factory<v8::Script>::New( v8::Local<v8::String> source
|
||||
, v8::ScriptOrigin const& origin) {
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::EscapableHandleScope scope(isolate);
|
||||
v8::ScriptCompiler::Source src(source, origin);
|
||||
return scope.Escape(
|
||||
v8::ScriptCompiler::Compile(isolate->GetCurrentContext(), &src)
|
||||
.FromMaybe(v8::Local<v8::Script>()));
|
||||
}
|
||||
#else
|
||||
Factory<v8::Script>::return_t
|
||||
Factory<v8::Script>::New( v8::Local<v8::String> source) {
|
||||
v8::ScriptCompiler::Source src(source);
|
||||
return v8::ScriptCompiler::Compile(v8::Isolate::GetCurrent(), &src);
|
||||
}
|
||||
|
||||
Factory<v8::Script>::return_t
|
||||
Factory<v8::Script>::New( v8::Local<v8::String> source
|
||||
, v8::ScriptOrigin const& origin) {
|
||||
v8::ScriptCompiler::Source src(source, origin);
|
||||
return v8::ScriptCompiler::Compile(v8::Isolate::GetCurrent(), &src);
|
||||
}
|
||||
#endif
|
||||
|
||||
//=== Signature ================================================================
|
||||
|
||||
Factory<v8::Signature>::return_t
|
||||
Factory<v8::Signature>::New(Factory<v8::Signature>::FTH receiver) {
|
||||
return v8::Signature::New(v8::Isolate::GetCurrent(), receiver);
|
||||
}
|
||||
|
||||
//=== String ===================================================================
|
||||
|
||||
Factory<v8::String>::return_t
|
||||
Factory<v8::String>::New() {
|
||||
return v8::String::Empty(v8::Isolate::GetCurrent());
|
||||
}
|
||||
|
||||
#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 4 || \
|
||||
(V8_MAJOR_VERSION == 4 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION >= 3))
|
||||
Factory<v8::String>::return_t
|
||||
Factory<v8::String>::New(const char * value, int length) {
|
||||
return v8::String::NewFromUtf8(
|
||||
v8::Isolate::GetCurrent(), value, v8::NewStringType::kNormal, length);
|
||||
}
|
||||
|
||||
Factory<v8::String>::return_t
|
||||
Factory<v8::String>::New(std::string const& value) {
|
||||
assert(value.size() <= INT_MAX && "string too long");
|
||||
return v8::String::NewFromUtf8(v8::Isolate::GetCurrent(),
|
||||
value.data(), v8::NewStringType::kNormal, static_cast<int>(value.size()));
|
||||
}
|
||||
|
||||
Factory<v8::String>::return_t
|
||||
Factory<v8::String>::New(const uint16_t * value, int length) {
|
||||
return v8::String::NewFromTwoByte(v8::Isolate::GetCurrent(), value,
|
||||
v8::NewStringType::kNormal, length);
|
||||
}
|
||||
|
||||
Factory<v8::String>::return_t
|
||||
Factory<v8::String>::New(v8::String::ExternalStringResource * value) {
|
||||
return v8::String::NewExternalTwoByte(v8::Isolate::GetCurrent(), value);
|
||||
}
|
||||
|
||||
Factory<v8::String>::return_t
|
||||
Factory<v8::String>::New(ExternalOneByteStringResource * value) {
|
||||
return v8::String::NewExternalOneByte(v8::Isolate::GetCurrent(), value);
|
||||
}
|
||||
#else
|
||||
Factory<v8::String>::return_t
|
||||
Factory<v8::String>::New(const char * value, int length) {
|
||||
return v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), value,
|
||||
v8::String::kNormalString, length);
|
||||
}
|
||||
|
||||
Factory<v8::String>::return_t
|
||||
Factory<v8::String>::New(
|
||||
std::string const& value) /* NOLINT(build/include_what_you_use) */ {
|
||||
assert(value.size() <= INT_MAX && "string too long");
|
||||
return v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), value.data(),
|
||||
v8::String::kNormalString,
|
||||
static_cast<int>(value.size()));
|
||||
}
|
||||
|
||||
Factory<v8::String>::return_t
|
||||
Factory<v8::String>::New(const uint16_t * value, int length) {
|
||||
return v8::String::NewFromTwoByte(v8::Isolate::GetCurrent(), value,
|
||||
v8::String::kNormalString, length);
|
||||
}
|
||||
|
||||
Factory<v8::String>::return_t
|
||||
Factory<v8::String>::New(v8::String::ExternalStringResource * value) {
|
||||
return v8::String::NewExternal(v8::Isolate::GetCurrent(), value);
|
||||
}
|
||||
|
||||
Factory<v8::String>::return_t
|
||||
Factory<v8::String>::New(ExternalOneByteStringResource * value) {
|
||||
return v8::String::NewExternal(v8::Isolate::GetCurrent(), value);
|
||||
}
|
||||
#endif
|
||||
|
||||
//=== String Object ============================================================
|
||||
|
||||
Factory<v8::StringObject>::return_t
|
||||
Factory<v8::StringObject>::New(v8::Local<v8::String> value) {
|
||||
return v8::StringObject::New(value).As<v8::StringObject>();
|
||||
}
|
||||
|
||||
//=== Unbound Script ===========================================================
|
||||
|
||||
#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 4 || \
|
||||
(V8_MAJOR_VERSION == 4 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION >= 3))
|
||||
Factory<v8::UnboundScript>::return_t
|
||||
Factory<v8::UnboundScript>::New(v8::Local<v8::String> source) {
|
||||
v8::ScriptCompiler::Source src(source);
|
||||
return v8::ScriptCompiler::CompileUnboundScript(
|
||||
v8::Isolate::GetCurrent(), &src);
|
||||
}
|
||||
|
||||
Factory<v8::UnboundScript>::return_t
|
||||
Factory<v8::UnboundScript>::New( v8::Local<v8::String> source
|
||||
, v8::ScriptOrigin const& origin) {
|
||||
v8::ScriptCompiler::Source src(source, origin);
|
||||
return v8::ScriptCompiler::CompileUnboundScript(
|
||||
v8::Isolate::GetCurrent(), &src);
|
||||
}
|
||||
#else
|
||||
Factory<v8::UnboundScript>::return_t
|
||||
Factory<v8::UnboundScript>::New(v8::Local<v8::String> source) {
|
||||
v8::ScriptCompiler::Source src(source);
|
||||
return v8::ScriptCompiler::CompileUnbound(v8::Isolate::GetCurrent(), &src);
|
||||
}
|
||||
|
||||
Factory<v8::UnboundScript>::return_t
|
||||
Factory<v8::UnboundScript>::New( v8::Local<v8::String> source
|
||||
, v8::ScriptOrigin const& origin) {
|
||||
v8::ScriptCompiler::Source src(source, origin);
|
||||
return v8::ScriptCompiler::CompileUnbound(v8::Isolate::GetCurrent(), &src);
|
||||
}
|
||||
#endif
|
||||
|
||||
} // end of namespace imp
|
||||
|
||||
//=== Presistents and Handles ==================================================
|
||||
|
||||
#if NODE_MODULE_VERSION < IOJS_3_0_MODULE_VERSION
|
||||
template <typename T>
|
||||
inline v8::Local<T> New(v8::Handle<T> h) {
|
||||
return v8::Local<T>::New(v8::Isolate::GetCurrent(), h);
|
||||
}
|
||||
#endif
|
||||
|
||||
template <typename T, typename M>
|
||||
inline v8::Local<T> New(v8::Persistent<T, M> const& p) {
|
||||
return v8::Local<T>::New(v8::Isolate::GetCurrent(), p);
|
||||
}
|
||||
|
||||
template <typename T, typename M>
|
||||
inline v8::Local<T> New(Persistent<T, M> const& p) {
|
||||
return v8::Local<T>::New(v8::Isolate::GetCurrent(), p);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline v8::Local<T> New(Global<T> const& p) {
|
||||
return v8::Local<T>::New(v8::Isolate::GetCurrent(), p);
|
||||
}
|
||||
|
||||
#endif // NAN_IMPLEMENTATION_12_INL_H_
|
||||
263
node_modules/nan/nan_implementation_pre_12_inl.h
generated
vendored
Normal file
263
node_modules/nan/nan_implementation_pre_12_inl.h
generated
vendored
Normal file
@@ -0,0 +1,263 @@
|
||||
/*********************************************************************
|
||||
* NAN - Native Abstractions for Node.js
|
||||
*
|
||||
* Copyright (c) 2018 NAN contributors
|
||||
*
|
||||
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
|
||||
********************************************************************/
|
||||
|
||||
#ifndef NAN_IMPLEMENTATION_PRE_12_INL_H_
|
||||
#define NAN_IMPLEMENTATION_PRE_12_INL_H_
|
||||
|
||||
//==============================================================================
|
||||
// node v0.10 implementation
|
||||
//==============================================================================
|
||||
|
||||
namespace imp {
|
||||
|
||||
//=== Array ====================================================================
|
||||
|
||||
Factory<v8::Array>::return_t
|
||||
Factory<v8::Array>::New() {
|
||||
return v8::Array::New();
|
||||
}
|
||||
|
||||
Factory<v8::Array>::return_t
|
||||
Factory<v8::Array>::New(int length) {
|
||||
return v8::Array::New(length);
|
||||
}
|
||||
|
||||
//=== Boolean ==================================================================
|
||||
|
||||
Factory<v8::Boolean>::return_t
|
||||
Factory<v8::Boolean>::New(bool value) {
|
||||
return v8::Boolean::New(value)->ToBoolean();
|
||||
}
|
||||
|
||||
//=== Boolean Object ===========================================================
|
||||
|
||||
Factory<v8::BooleanObject>::return_t
|
||||
Factory<v8::BooleanObject>::New(bool value) {
|
||||
return v8::BooleanObject::New(value).As<v8::BooleanObject>();
|
||||
}
|
||||
|
||||
//=== Context ==================================================================
|
||||
|
||||
Factory<v8::Context>::return_t
|
||||
Factory<v8::Context>::New( v8::ExtensionConfiguration* extensions
|
||||
, v8::Local<v8::ObjectTemplate> tmpl
|
||||
, v8::Local<v8::Value> obj) {
|
||||
v8::Persistent<v8::Context> ctx = v8::Context::New(extensions, tmpl, obj);
|
||||
v8::Local<v8::Context> lctx = v8::Local<v8::Context>::New(ctx);
|
||||
ctx.Dispose();
|
||||
return lctx;
|
||||
}
|
||||
|
||||
//=== Date =====================================================================
|
||||
|
||||
Factory<v8::Date>::return_t
|
||||
Factory<v8::Date>::New(double value) {
|
||||
return v8::Date::New(value).As<v8::Date>();
|
||||
}
|
||||
|
||||
//=== External =================================================================
|
||||
|
||||
Factory<v8::External>::return_t
|
||||
Factory<v8::External>::New(void * value) {
|
||||
return v8::External::New(value);
|
||||
}
|
||||
|
||||
//=== Function =================================================================
|
||||
|
||||
Factory<v8::Function>::return_t
|
||||
Factory<v8::Function>::New( FunctionCallback callback
|
||||
, v8::Local<v8::Value> data) {
|
||||
v8::HandleScope scope;
|
||||
|
||||
return scope.Close(Factory<v8::FunctionTemplate>::New(
|
||||
callback, data, v8::Local<v8::Signature>())
|
||||
->GetFunction());
|
||||
}
|
||||
|
||||
|
||||
//=== FunctionTemplate =========================================================
|
||||
|
||||
Factory<v8::FunctionTemplate>::return_t
|
||||
Factory<v8::FunctionTemplate>::New( FunctionCallback callback
|
||||
, v8::Local<v8::Value> data
|
||||
, v8::Local<v8::Signature> signature) {
|
||||
if (callback) {
|
||||
v8::HandleScope scope;
|
||||
|
||||
v8::Local<v8::ObjectTemplate> tpl = v8::ObjectTemplate::New();
|
||||
tpl->SetInternalFieldCount(imp::kFunctionFieldCount);
|
||||
v8::Local<v8::Object> obj = tpl->NewInstance();
|
||||
|
||||
obj->SetInternalField(
|
||||
imp::kFunctionIndex
|
||||
, v8::External::New(reinterpret_cast<void *>(callback)));
|
||||
|
||||
v8::Local<v8::Value> val = v8::Local<v8::Value>::New(data);
|
||||
|
||||
if (!val.IsEmpty()) {
|
||||
obj->SetInternalField(imp::kDataIndex, val);
|
||||
}
|
||||
|
||||
// Note(agnat): Emulate length argument here. Unfortunately, I couldn't find
|
||||
// a way. Have at it though...
|
||||
return scope.Close(
|
||||
v8::FunctionTemplate::New(imp::FunctionCallbackWrapper
|
||||
, obj
|
||||
, signature));
|
||||
} else {
|
||||
return v8::FunctionTemplate::New(0, data, signature);
|
||||
}
|
||||
}
|
||||
|
||||
//=== Number ===================================================================
|
||||
|
||||
Factory<v8::Number>::return_t
|
||||
Factory<v8::Number>::New(double value) {
|
||||
return v8::Number::New(value);
|
||||
}
|
||||
|
||||
//=== Number Object ============================================================
|
||||
|
||||
Factory<v8::NumberObject>::return_t
|
||||
Factory<v8::NumberObject>::New(double value) {
|
||||
return v8::NumberObject::New(value).As<v8::NumberObject>();
|
||||
}
|
||||
|
||||
//=== Integer, Int32 and Uint32 ================================================
|
||||
|
||||
template <typename T>
|
||||
typename IntegerFactory<T>::return_t
|
||||
IntegerFactory<T>::New(int32_t value) {
|
||||
return To<T>(T::New(value));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
typename IntegerFactory<T>::return_t
|
||||
IntegerFactory<T>::New(uint32_t value) {
|
||||
return To<T>(T::NewFromUnsigned(value));
|
||||
}
|
||||
|
||||
Factory<v8::Uint32>::return_t
|
||||
Factory<v8::Uint32>::New(int32_t value) {
|
||||
return To<v8::Uint32>(v8::Uint32::NewFromUnsigned(value));
|
||||
}
|
||||
|
||||
Factory<v8::Uint32>::return_t
|
||||
Factory<v8::Uint32>::New(uint32_t value) {
|
||||
return To<v8::Uint32>(v8::Uint32::NewFromUnsigned(value));
|
||||
}
|
||||
|
||||
|
||||
//=== Object ===================================================================
|
||||
|
||||
Factory<v8::Object>::return_t
|
||||
Factory<v8::Object>::New() {
|
||||
return v8::Object::New();
|
||||
}
|
||||
|
||||
//=== Object Template ==========================================================
|
||||
|
||||
Factory<v8::ObjectTemplate>::return_t
|
||||
Factory<v8::ObjectTemplate>::New() {
|
||||
return v8::ObjectTemplate::New();
|
||||
}
|
||||
|
||||
//=== RegExp ===================================================================
|
||||
|
||||
Factory<v8::RegExp>::return_t
|
||||
Factory<v8::RegExp>::New(
|
||||
v8::Local<v8::String> pattern
|
||||
, v8::RegExp::Flags flags) {
|
||||
return v8::RegExp::New(pattern, flags);
|
||||
}
|
||||
|
||||
//=== Script ===================================================================
|
||||
|
||||
Factory<v8::Script>::return_t
|
||||
Factory<v8::Script>::New( v8::Local<v8::String> source) {
|
||||
return v8::Script::New(source);
|
||||
}
|
||||
Factory<v8::Script>::return_t
|
||||
Factory<v8::Script>::New( v8::Local<v8::String> source
|
||||
, v8::ScriptOrigin const& origin) {
|
||||
return v8::Script::New(source, const_cast<v8::ScriptOrigin*>(&origin));
|
||||
}
|
||||
|
||||
//=== Signature ================================================================
|
||||
|
||||
Factory<v8::Signature>::return_t
|
||||
Factory<v8::Signature>::New(Factory<v8::Signature>::FTH receiver) {
|
||||
return v8::Signature::New(receiver);
|
||||
}
|
||||
|
||||
//=== String ===================================================================
|
||||
|
||||
Factory<v8::String>::return_t
|
||||
Factory<v8::String>::New() {
|
||||
return v8::String::Empty();
|
||||
}
|
||||
|
||||
Factory<v8::String>::return_t
|
||||
Factory<v8::String>::New(const char * value, int length) {
|
||||
return v8::String::New(value, length);
|
||||
}
|
||||
|
||||
Factory<v8::String>::return_t
|
||||
Factory<v8::String>::New(
|
||||
std::string const& value) /* NOLINT(build/include_what_you_use) */ {
|
||||
assert(value.size() <= INT_MAX && "string too long");
|
||||
return v8::String::New(value.data(), static_cast<int>(value.size()));
|
||||
}
|
||||
|
||||
Factory<v8::String>::return_t
|
||||
Factory<v8::String>::New(const uint16_t * value, int length) {
|
||||
return v8::String::New(value, length);
|
||||
}
|
||||
|
||||
Factory<v8::String>::return_t
|
||||
Factory<v8::String>::New(v8::String::ExternalStringResource * value) {
|
||||
return v8::String::NewExternal(value);
|
||||
}
|
||||
|
||||
Factory<v8::String>::return_t
|
||||
Factory<v8::String>::New(v8::String::ExternalAsciiStringResource * value) {
|
||||
return v8::String::NewExternal(value);
|
||||
}
|
||||
|
||||
//=== String Object ============================================================
|
||||
|
||||
Factory<v8::StringObject>::return_t
|
||||
Factory<v8::StringObject>::New(v8::Local<v8::String> value) {
|
||||
return v8::StringObject::New(value).As<v8::StringObject>();
|
||||
}
|
||||
|
||||
} // end of namespace imp
|
||||
|
||||
//=== Presistents and Handles ==================================================
|
||||
|
||||
template <typename T>
|
||||
inline v8::Local<T> New(v8::Handle<T> h) {
|
||||
return v8::Local<T>::New(h);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline v8::Local<T> New(v8::Persistent<T> const& p) {
|
||||
return v8::Local<T>::New(p);
|
||||
}
|
||||
|
||||
template <typename T, typename M>
|
||||
inline v8::Local<T> New(Persistent<T, M> const& p) {
|
||||
return v8::Local<T>::New(p.persistent);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline v8::Local<T> New(Global<T> const& p) {
|
||||
return v8::Local<T>::New(p.persistent);
|
||||
}
|
||||
|
||||
#endif // NAN_IMPLEMENTATION_PRE_12_INL_H_
|
||||
166
node_modules/nan/nan_json.h
generated
vendored
Normal file
166
node_modules/nan/nan_json.h
generated
vendored
Normal file
@@ -0,0 +1,166 @@
|
||||
/*********************************************************************
|
||||
* NAN - Native Abstractions for Node.js
|
||||
*
|
||||
* Copyright (c) 2018 NAN contributors
|
||||
*
|
||||
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
|
||||
********************************************************************/
|
||||
|
||||
#ifndef NAN_JSON_H_
|
||||
#define NAN_JSON_H_
|
||||
|
||||
#if NODE_MODULE_VERSION < NODE_0_12_MODULE_VERSION
|
||||
#define NAN_JSON_H_NEED_PARSE 1
|
||||
#else
|
||||
#define NAN_JSON_H_NEED_PARSE 0
|
||||
#endif // NODE_MODULE_VERSION < NODE_0_12_MODULE_VERSION
|
||||
|
||||
#if NODE_MODULE_VERSION >= NODE_7_0_MODULE_VERSION
|
||||
#define NAN_JSON_H_NEED_STRINGIFY 0
|
||||
#else
|
||||
#define NAN_JSON_H_NEED_STRINGIFY 1
|
||||
#endif // NODE_MODULE_VERSION >= NODE_7_0_MODULE_VERSION
|
||||
|
||||
class JSON {
|
||||
public:
|
||||
JSON() {
|
||||
#if NAN_JSON_H_NEED_PARSE + NAN_JSON_H_NEED_STRINGIFY
|
||||
Nan::HandleScope scope;
|
||||
|
||||
Nan::MaybeLocal<v8::Value> maybe_global_json = Nan::Get(
|
||||
Nan::GetCurrentContext()->Global(),
|
||||
Nan::New("JSON").ToLocalChecked()
|
||||
);
|
||||
|
||||
assert(!maybe_global_json.IsEmpty() && "global JSON is empty");
|
||||
v8::Local<v8::Value> val_global_json = maybe_global_json.ToLocalChecked();
|
||||
|
||||
assert(val_global_json->IsObject() && "global JSON is not an object");
|
||||
Nan::MaybeLocal<v8::Object> maybe_obj_global_json =
|
||||
Nan::To<v8::Object>(val_global_json);
|
||||
|
||||
assert(!maybe_obj_global_json.IsEmpty() && "global JSON object is empty");
|
||||
v8::Local<v8::Object> global_json = maybe_obj_global_json.ToLocalChecked();
|
||||
|
||||
#if NAN_JSON_H_NEED_PARSE
|
||||
Nan::MaybeLocal<v8::Value> maybe_parse_method = Nan::Get(
|
||||
global_json, Nan::New("parse").ToLocalChecked()
|
||||
);
|
||||
|
||||
assert(!maybe_parse_method.IsEmpty() && "JSON.parse is empty");
|
||||
v8::Local<v8::Value> parse_method = maybe_parse_method.ToLocalChecked();
|
||||
|
||||
assert(parse_method->IsFunction() && "JSON.parse is not a function");
|
||||
parse_cb_.Reset(parse_method.As<v8::Function>());
|
||||
#endif // NAN_JSON_H_NEED_PARSE
|
||||
|
||||
#if NAN_JSON_H_NEED_STRINGIFY
|
||||
Nan::MaybeLocal<v8::Value> maybe_stringify_method = Nan::Get(
|
||||
global_json, Nan::New("stringify").ToLocalChecked()
|
||||
);
|
||||
|
||||
assert(!maybe_stringify_method.IsEmpty() && "JSON.stringify is empty");
|
||||
v8::Local<v8::Value> stringify_method =
|
||||
maybe_stringify_method.ToLocalChecked();
|
||||
|
||||
assert(
|
||||
stringify_method->IsFunction() && "JSON.stringify is not a function"
|
||||
);
|
||||
stringify_cb_.Reset(stringify_method.As<v8::Function>());
|
||||
#endif // NAN_JSON_H_NEED_STRINGIFY
|
||||
#endif // NAN_JSON_H_NEED_PARSE + NAN_JSON_H_NEED_STRINGIFY
|
||||
}
|
||||
|
||||
inline
|
||||
Nan::MaybeLocal<v8::Value> Parse(v8::Local<v8::String> json_string) {
|
||||
Nan::EscapableHandleScope scope;
|
||||
#if NAN_JSON_H_NEED_PARSE
|
||||
return scope.Escape(parse(json_string));
|
||||
#else
|
||||
Nan::MaybeLocal<v8::Value> result;
|
||||
#if NODE_MODULE_VERSION >= NODE_0_12_MODULE_VERSION && \
|
||||
NODE_MODULE_VERSION <= IOJS_2_0_MODULE_VERSION
|
||||
result = v8::JSON::Parse(json_string);
|
||||
#else
|
||||
#if NODE_MODULE_VERSION > NODE_6_0_MODULE_VERSION
|
||||
v8::Local<v8::Context> context_or_isolate = Nan::GetCurrentContext();
|
||||
#else
|
||||
v8::Isolate* context_or_isolate = v8::Isolate::GetCurrent();
|
||||
#endif // NODE_MODULE_VERSION > NODE_6_0_MODULE_VERSION
|
||||
result = v8::JSON::Parse(context_or_isolate, json_string);
|
||||
#endif // NODE_MODULE_VERSION >= NODE_0_12_MODULE_VERSION &&
|
||||
// NODE_MODULE_VERSION <= IOJS_2_0_MODULE_VERSION
|
||||
if (result.IsEmpty()) return v8::Local<v8::Value>();
|
||||
return scope.Escape(result.ToLocalChecked());
|
||||
#endif // NAN_JSON_H_NEED_PARSE
|
||||
}
|
||||
|
||||
inline
|
||||
Nan::MaybeLocal<v8::String> Stringify(v8::Local<v8::Object> json_object) {
|
||||
Nan::EscapableHandleScope scope;
|
||||
Nan::MaybeLocal<v8::String> result =
|
||||
#if NAN_JSON_H_NEED_STRINGIFY
|
||||
Nan::To<v8::String>(stringify(json_object));
|
||||
#else
|
||||
v8::JSON::Stringify(Nan::GetCurrentContext(), json_object);
|
||||
#endif // NAN_JSON_H_NEED_STRINGIFY
|
||||
if (result.IsEmpty()) return v8::Local<v8::String>();
|
||||
return scope.Escape(result.ToLocalChecked());
|
||||
}
|
||||
|
||||
inline
|
||||
Nan::MaybeLocal<v8::String> Stringify(v8::Local<v8::Object> json_object,
|
||||
v8::Local<v8::String> gap) {
|
||||
Nan::EscapableHandleScope scope;
|
||||
Nan::MaybeLocal<v8::String> result =
|
||||
#if NAN_JSON_H_NEED_STRINGIFY
|
||||
Nan::To<v8::String>(stringify(json_object, gap));
|
||||
#else
|
||||
v8::JSON::Stringify(Nan::GetCurrentContext(), json_object, gap);
|
||||
#endif // NAN_JSON_H_NEED_STRINGIFY
|
||||
if (result.IsEmpty()) return v8::Local<v8::String>();
|
||||
return scope.Escape(result.ToLocalChecked());
|
||||
}
|
||||
|
||||
private:
|
||||
NAN_DISALLOW_ASSIGN_COPY_MOVE(JSON)
|
||||
#if NAN_JSON_H_NEED_PARSE
|
||||
Nan::Callback parse_cb_;
|
||||
#endif // NAN_JSON_H_NEED_PARSE
|
||||
#if NAN_JSON_H_NEED_STRINGIFY
|
||||
Nan::Callback stringify_cb_;
|
||||
#endif // NAN_JSON_H_NEED_STRINGIFY
|
||||
|
||||
#if NAN_JSON_H_NEED_PARSE
|
||||
inline v8::Local<v8::Value> parse(v8::Local<v8::Value> arg) {
|
||||
assert(!parse_cb_.IsEmpty() && "parse_cb_ is empty");
|
||||
AsyncResource resource("nan:JSON.parse");
|
||||
return parse_cb_.Call(1, &arg, &resource).FromMaybe(v8::Local<v8::Value>());
|
||||
}
|
||||
#endif // NAN_JSON_H_NEED_PARSE
|
||||
|
||||
#if NAN_JSON_H_NEED_STRINGIFY
|
||||
inline v8::Local<v8::Value> stringify(v8::Local<v8::Value> arg) {
|
||||
assert(!stringify_cb_.IsEmpty() && "stringify_cb_ is empty");
|
||||
AsyncResource resource("nan:JSON.stringify");
|
||||
return stringify_cb_.Call(1, &arg, &resource)
|
||||
.FromMaybe(v8::Local<v8::Value>());
|
||||
}
|
||||
|
||||
inline v8::Local<v8::Value> stringify(v8::Local<v8::Value> arg,
|
||||
v8::Local<v8::String> gap) {
|
||||
assert(!stringify_cb_.IsEmpty() && "stringify_cb_ is empty");
|
||||
|
||||
v8::Local<v8::Value> argv[] = {
|
||||
arg,
|
||||
Nan::Null(),
|
||||
gap
|
||||
};
|
||||
AsyncResource resource("nan:JSON.stringify");
|
||||
return stringify_cb_.Call(3, argv, &resource)
|
||||
.FromMaybe(v8::Local<v8::Value>());
|
||||
}
|
||||
#endif // NAN_JSON_H_NEED_STRINGIFY
|
||||
};
|
||||
|
||||
#endif // NAN_JSON_H_
|
||||
369
node_modules/nan/nan_maybe_43_inl.h
generated
vendored
Normal file
369
node_modules/nan/nan_maybe_43_inl.h
generated
vendored
Normal file
@@ -0,0 +1,369 @@
|
||||
/*********************************************************************
|
||||
* NAN - Native Abstractions for Node.js
|
||||
*
|
||||
* Copyright (c) 2018 NAN contributors
|
||||
*
|
||||
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
|
||||
********************************************************************/
|
||||
|
||||
#ifndef NAN_MAYBE_43_INL_H_
|
||||
#define NAN_MAYBE_43_INL_H_
|
||||
|
||||
template<typename T>
|
||||
using MaybeLocal = v8::MaybeLocal<T>;
|
||||
|
||||
template<typename T>
|
||||
using Maybe = v8::Maybe<T>;
|
||||
|
||||
template<typename T>
|
||||
inline Maybe<T> Nothing() {
|
||||
return v8::Nothing<T>();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline Maybe<T> Just(const T& t) {
|
||||
return v8::Just<T>(t);
|
||||
}
|
||||
|
||||
inline
|
||||
MaybeLocal<v8::String> ToDetailString(v8::Local<v8::Value> val) {
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::EscapableHandleScope scope(isolate);
|
||||
return scope.Escape(val->ToDetailString(isolate->GetCurrentContext())
|
||||
.FromMaybe(v8::Local<v8::String>()));
|
||||
}
|
||||
|
||||
inline
|
||||
MaybeLocal<v8::Uint32> ToArrayIndex(v8::Local<v8::Value> val) {
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::EscapableHandleScope scope(isolate);
|
||||
return scope.Escape(val->ToArrayIndex(isolate->GetCurrentContext())
|
||||
.FromMaybe(v8::Local<v8::Uint32>()));
|
||||
}
|
||||
|
||||
inline
|
||||
Maybe<bool> Equals(v8::Local<v8::Value> a, v8::Local<v8::Value>(b)) {
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::HandleScope scope(isolate);
|
||||
return a->Equals(isolate->GetCurrentContext(), b);
|
||||
}
|
||||
|
||||
inline
|
||||
MaybeLocal<v8::Object> NewInstance(v8::Local<v8::Function> h) {
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::EscapableHandleScope scope(isolate);
|
||||
return scope.Escape(h->NewInstance(isolate->GetCurrentContext())
|
||||
.FromMaybe(v8::Local<v8::Object>()));
|
||||
}
|
||||
|
||||
inline
|
||||
MaybeLocal<v8::Object> NewInstance(
|
||||
v8::Local<v8::Function> h
|
||||
, int argc
|
||||
, v8::Local<v8::Value> argv[]) {
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::EscapableHandleScope scope(isolate);
|
||||
return scope.Escape(h->NewInstance(isolate->GetCurrentContext(), argc, argv)
|
||||
.FromMaybe(v8::Local<v8::Object>()));
|
||||
}
|
||||
|
||||
inline
|
||||
MaybeLocal<v8::Object> NewInstance(v8::Local<v8::ObjectTemplate> h) {
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::EscapableHandleScope scope(isolate);
|
||||
return scope.Escape(h->NewInstance(isolate->GetCurrentContext())
|
||||
.FromMaybe(v8::Local<v8::Object>()));
|
||||
}
|
||||
|
||||
|
||||
inline MaybeLocal<v8::Function> GetFunction(
|
||||
v8::Local<v8::FunctionTemplate> t) {
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::EscapableHandleScope scope(isolate);
|
||||
return scope.Escape(t->GetFunction(isolate->GetCurrentContext())
|
||||
.FromMaybe(v8::Local<v8::Function>()));
|
||||
}
|
||||
|
||||
inline Maybe<bool> Set(
|
||||
v8::Local<v8::Object> obj
|
||||
, v8::Local<v8::Value> key
|
||||
, v8::Local<v8::Value> value) {
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::HandleScope scope(isolate);
|
||||
return obj->Set(isolate->GetCurrentContext(), key, value);
|
||||
}
|
||||
|
||||
inline Maybe<bool> Set(
|
||||
v8::Local<v8::Object> obj
|
||||
, uint32_t index
|
||||
, v8::Local<v8::Value> value) {
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::HandleScope scope(isolate);
|
||||
return obj->Set(isolate->GetCurrentContext(), index, value);
|
||||
}
|
||||
|
||||
#if NODE_MODULE_VERSION < NODE_4_0_MODULE_VERSION
|
||||
#include "nan_define_own_property_helper.h" // NOLINT(build/include)
|
||||
#endif
|
||||
|
||||
inline Maybe<bool> DefineOwnProperty(
|
||||
v8::Local<v8::Object> obj
|
||||
, v8::Local<v8::String> key
|
||||
, v8::Local<v8::Value> value
|
||||
, v8::PropertyAttribute attribs = v8::None) {
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::HandleScope scope(isolate);
|
||||
#if NODE_MODULE_VERSION >= NODE_4_0_MODULE_VERSION
|
||||
return obj->DefineOwnProperty(isolate->GetCurrentContext(), key, value,
|
||||
attribs);
|
||||
#else
|
||||
Maybe<v8::PropertyAttribute> maybeCurrent =
|
||||
obj->GetPropertyAttributes(isolate->GetCurrentContext(), key);
|
||||
if (maybeCurrent.IsNothing()) {
|
||||
return Nothing<bool>();
|
||||
}
|
||||
v8::PropertyAttribute current = maybeCurrent.FromJust();
|
||||
return imp::DefineOwnPropertyHelper(current, obj, key, value, attribs);
|
||||
#endif
|
||||
}
|
||||
|
||||
NAN_DEPRECATED inline Maybe<bool> ForceSet(
|
||||
v8::Local<v8::Object> obj
|
||||
, v8::Local<v8::Value> key
|
||||
, v8::Local<v8::Value> value
|
||||
, v8::PropertyAttribute attribs = v8::None) {
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::HandleScope scope(isolate);
|
||||
#if NODE_MODULE_VERSION >= NODE_9_0_MODULE_VERSION
|
||||
return key->IsName()
|
||||
? obj->DefineOwnProperty(isolate->GetCurrentContext(),
|
||||
key.As<v8::Name>(), value, attribs)
|
||||
: Nothing<bool>();
|
||||
#else
|
||||
return obj->ForceSet(isolate->GetCurrentContext(), key, value, attribs);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline MaybeLocal<v8::Value> Get(
|
||||
v8::Local<v8::Object> obj
|
||||
, v8::Local<v8::Value> key) {
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::EscapableHandleScope scope(isolate);
|
||||
return scope.Escape(obj->Get(isolate->GetCurrentContext(), key)
|
||||
.FromMaybe(v8::Local<v8::Value>()));
|
||||
}
|
||||
|
||||
inline
|
||||
MaybeLocal<v8::Value> Get(v8::Local<v8::Object> obj, uint32_t index) {
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::EscapableHandleScope scope(isolate);
|
||||
return scope.Escape(obj->Get(isolate->GetCurrentContext(), index)
|
||||
.FromMaybe(v8::Local<v8::Value>()));
|
||||
}
|
||||
|
||||
inline v8::PropertyAttribute GetPropertyAttributes(
|
||||
v8::Local<v8::Object> obj
|
||||
, v8::Local<v8::Value> key) {
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::HandleScope scope(isolate);
|
||||
return obj->GetPropertyAttributes(isolate->GetCurrentContext(), key)
|
||||
.FromJust();
|
||||
}
|
||||
|
||||
inline Maybe<bool> Has(
|
||||
v8::Local<v8::Object> obj
|
||||
, v8::Local<v8::String> key) {
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::HandleScope scope(isolate);
|
||||
return obj->Has(isolate->GetCurrentContext(), key);
|
||||
}
|
||||
|
||||
inline Maybe<bool> Has(v8::Local<v8::Object> obj, uint32_t index) {
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::HandleScope scope(isolate);
|
||||
return obj->Has(isolate->GetCurrentContext(), index);
|
||||
}
|
||||
|
||||
inline Maybe<bool> Delete(
|
||||
v8::Local<v8::Object> obj
|
||||
, v8::Local<v8::String> key) {
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::HandleScope scope(isolate);
|
||||
return obj->Delete(isolate->GetCurrentContext(), key);
|
||||
}
|
||||
|
||||
inline
|
||||
Maybe<bool> Delete(v8::Local<v8::Object> obj, uint32_t index) {
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::HandleScope scope(isolate);
|
||||
return obj->Delete(isolate->GetCurrentContext(), index);
|
||||
}
|
||||
|
||||
inline
|
||||
MaybeLocal<v8::Array> GetPropertyNames(v8::Local<v8::Object> obj) {
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::EscapableHandleScope scope(isolate);
|
||||
return scope.Escape(obj->GetPropertyNames(isolate->GetCurrentContext())
|
||||
.FromMaybe(v8::Local<v8::Array>()));
|
||||
}
|
||||
|
||||
inline
|
||||
MaybeLocal<v8::Array> GetOwnPropertyNames(v8::Local<v8::Object> obj) {
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::EscapableHandleScope scope(isolate);
|
||||
return scope.Escape(obj->GetOwnPropertyNames(isolate->GetCurrentContext())
|
||||
.FromMaybe(v8::Local<v8::Array>()));
|
||||
}
|
||||
|
||||
inline Maybe<bool> SetPrototype(
|
||||
v8::Local<v8::Object> obj
|
||||
, v8::Local<v8::Value> prototype) {
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::HandleScope scope(isolate);
|
||||
return obj->SetPrototype(isolate->GetCurrentContext(), prototype);
|
||||
}
|
||||
|
||||
inline MaybeLocal<v8::String> ObjectProtoToString(
|
||||
v8::Local<v8::Object> obj) {
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::EscapableHandleScope scope(isolate);
|
||||
return scope.Escape(obj->ObjectProtoToString(isolate->GetCurrentContext())
|
||||
.FromMaybe(v8::Local<v8::String>()));
|
||||
}
|
||||
|
||||
inline Maybe<bool> HasOwnProperty(
|
||||
v8::Local<v8::Object> obj
|
||||
, v8::Local<v8::String> key) {
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::HandleScope scope(isolate);
|
||||
return obj->HasOwnProperty(isolate->GetCurrentContext(), key);
|
||||
}
|
||||
|
||||
inline Maybe<bool> HasRealNamedProperty(
|
||||
v8::Local<v8::Object> obj
|
||||
, v8::Local<v8::String> key) {
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::HandleScope scope(isolate);
|
||||
return obj->HasRealNamedProperty(isolate->GetCurrentContext(), key);
|
||||
}
|
||||
|
||||
inline Maybe<bool> HasRealIndexedProperty(
|
||||
v8::Local<v8::Object> obj
|
||||
, uint32_t index) {
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::HandleScope scope(isolate);
|
||||
return obj->HasRealIndexedProperty(isolate->GetCurrentContext(), index);
|
||||
}
|
||||
|
||||
inline Maybe<bool> HasRealNamedCallbackProperty(
|
||||
v8::Local<v8::Object> obj
|
||||
, v8::Local<v8::String> key) {
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::HandleScope scope(isolate);
|
||||
return obj->HasRealNamedCallbackProperty(isolate->GetCurrentContext(), key);
|
||||
}
|
||||
|
||||
inline MaybeLocal<v8::Value> GetRealNamedPropertyInPrototypeChain(
|
||||
v8::Local<v8::Object> obj
|
||||
, v8::Local<v8::String> key) {
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::EscapableHandleScope scope(isolate);
|
||||
return scope.Escape(obj->GetRealNamedPropertyInPrototypeChain(
|
||||
isolate->GetCurrentContext(), key)
|
||||
.FromMaybe(v8::Local<v8::Value>()));
|
||||
}
|
||||
|
||||
inline MaybeLocal<v8::Value> GetRealNamedProperty(
|
||||
v8::Local<v8::Object> obj
|
||||
, v8::Local<v8::String> key) {
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::EscapableHandleScope scope(isolate);
|
||||
return scope.Escape(
|
||||
obj->GetRealNamedProperty(isolate->GetCurrentContext(), key)
|
||||
.FromMaybe(v8::Local<v8::Value>()));
|
||||
}
|
||||
|
||||
inline MaybeLocal<v8::Value> CallAsFunction(
|
||||
v8::Local<v8::Object> obj
|
||||
, v8::Local<v8::Object> recv
|
||||
, int argc
|
||||
, v8::Local<v8::Value> argv[]) {
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::EscapableHandleScope scope(isolate);
|
||||
return scope.Escape(
|
||||
obj->CallAsFunction(isolate->GetCurrentContext(), recv, argc, argv)
|
||||
.FromMaybe(v8::Local<v8::Value>()));
|
||||
}
|
||||
|
||||
inline MaybeLocal<v8::Value> CallAsConstructor(
|
||||
v8::Local<v8::Object> obj
|
||||
, int argc, v8::Local<v8::Value> argv[]) {
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::EscapableHandleScope scope(isolate);
|
||||
return scope.Escape(
|
||||
obj->CallAsConstructor(isolate->GetCurrentContext(), argc, argv)
|
||||
.FromMaybe(v8::Local<v8::Value>()));
|
||||
}
|
||||
|
||||
inline
|
||||
MaybeLocal<v8::String> GetSourceLine(v8::Local<v8::Message> msg) {
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::EscapableHandleScope scope(isolate);
|
||||
return scope.Escape(msg->GetSourceLine(isolate->GetCurrentContext())
|
||||
.FromMaybe(v8::Local<v8::String>()));
|
||||
}
|
||||
|
||||
inline Maybe<int> GetLineNumber(v8::Local<v8::Message> msg) {
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::HandleScope scope(isolate);
|
||||
return msg->GetLineNumber(isolate->GetCurrentContext());
|
||||
}
|
||||
|
||||
inline Maybe<int> GetStartColumn(v8::Local<v8::Message> msg) {
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::HandleScope scope(isolate);
|
||||
return msg->GetStartColumn(isolate->GetCurrentContext());
|
||||
}
|
||||
|
||||
inline Maybe<int> GetEndColumn(v8::Local<v8::Message> msg) {
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::HandleScope scope(isolate);
|
||||
return msg->GetEndColumn(isolate->GetCurrentContext());
|
||||
}
|
||||
|
||||
inline MaybeLocal<v8::Object> CloneElementAt(
|
||||
v8::Local<v8::Array> array
|
||||
, uint32_t index) {
|
||||
#if (NODE_MODULE_VERSION >= NODE_6_0_MODULE_VERSION)
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::EscapableHandleScope scope(isolate);
|
||||
v8::Local<v8::Context> context = isolate->GetCurrentContext();
|
||||
v8::Local<v8::Value> elem;
|
||||
v8::Local<v8::Object> obj;
|
||||
if (!array->Get(context, index).ToLocal(&elem)) {
|
||||
return scope.Escape(obj);
|
||||
}
|
||||
if (!elem->ToObject(context).ToLocal(&obj)) {
|
||||
return scope.Escape(v8::Local<v8::Object>());
|
||||
}
|
||||
return scope.Escape(obj->Clone());
|
||||
#else
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::EscapableHandleScope scope(isolate);
|
||||
return scope.Escape(array->CloneElementAt(isolate->GetCurrentContext(), index)
|
||||
.FromMaybe(v8::Local<v8::Object>()));
|
||||
#endif
|
||||
}
|
||||
|
||||
inline MaybeLocal<v8::Value> Call(
|
||||
v8::Local<v8::Function> fun
|
||||
, v8::Local<v8::Object> recv
|
||||
, int argc
|
||||
, v8::Local<v8::Value> argv[]) {
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::EscapableHandleScope scope(isolate);
|
||||
return scope.Escape(fun->Call(isolate->GetCurrentContext(), recv, argc, argv)
|
||||
.FromMaybe(v8::Local<v8::Value>()));
|
||||
}
|
||||
|
||||
#endif // NAN_MAYBE_43_INL_H_
|
||||
316
node_modules/nan/nan_maybe_pre_43_inl.h
generated
vendored
Normal file
316
node_modules/nan/nan_maybe_pre_43_inl.h
generated
vendored
Normal file
@@ -0,0 +1,316 @@
|
||||
/*********************************************************************
|
||||
* NAN - Native Abstractions for Node.js
|
||||
*
|
||||
* Copyright (c) 2018 NAN contributors
|
||||
*
|
||||
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
|
||||
********************************************************************/
|
||||
|
||||
#ifndef NAN_MAYBE_PRE_43_INL_H_
|
||||
#define NAN_MAYBE_PRE_43_INL_H_
|
||||
|
||||
template<typename T>
|
||||
class MaybeLocal {
|
||||
public:
|
||||
inline MaybeLocal() : val_(v8::Local<T>()) {}
|
||||
|
||||
template<typename S>
|
||||
# if NODE_MODULE_VERSION >= NODE_0_12_MODULE_VERSION
|
||||
inline
|
||||
MaybeLocal(v8::Local<S> that) : val_(that) {} // NOLINT(runtime/explicit)
|
||||
# else
|
||||
inline
|
||||
MaybeLocal(v8::Local<S> that) : // NOLINT(runtime/explicit)
|
||||
val_(*reinterpret_cast<v8::Local<T>*>(&that)) {}
|
||||
# endif
|
||||
|
||||
inline bool IsEmpty() const { return val_.IsEmpty(); }
|
||||
|
||||
template<typename S>
|
||||
inline bool ToLocal(v8::Local<S> *out) const {
|
||||
*out = val_;
|
||||
return !IsEmpty();
|
||||
}
|
||||
|
||||
inline v8::Local<T> ToLocalChecked() const {
|
||||
#if defined(V8_ENABLE_CHECKS)
|
||||
assert(!IsEmpty() && "ToLocalChecked is Empty");
|
||||
#endif // V8_ENABLE_CHECKS
|
||||
return val_;
|
||||
}
|
||||
|
||||
template<typename S>
|
||||
inline v8::Local<S> FromMaybe(v8::Local<S> default_value) const {
|
||||
return IsEmpty() ? default_value : v8::Local<S>(val_);
|
||||
}
|
||||
|
||||
private:
|
||||
v8::Local<T> val_;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
class Maybe {
|
||||
public:
|
||||
inline bool IsNothing() const { return !has_value_; }
|
||||
inline bool IsJust() const { return has_value_; }
|
||||
|
||||
inline T FromJust() const {
|
||||
#if defined(V8_ENABLE_CHECKS)
|
||||
assert(IsJust() && "FromJust is Nothing");
|
||||
#endif // V8_ENABLE_CHECKS
|
||||
return value_;
|
||||
}
|
||||
|
||||
inline T FromMaybe(const T& default_value) const {
|
||||
return has_value_ ? value_ : default_value;
|
||||
}
|
||||
|
||||
inline bool operator==(const Maybe &other) const {
|
||||
return (IsJust() == other.IsJust()) &&
|
||||
(!IsJust() || FromJust() == other.FromJust());
|
||||
}
|
||||
|
||||
inline bool operator!=(const Maybe &other) const {
|
||||
return !operator==(other);
|
||||
}
|
||||
|
||||
private:
|
||||
Maybe() : has_value_(false) {}
|
||||
explicit Maybe(const T& t) : has_value_(true), value_(t) {}
|
||||
bool has_value_;
|
||||
T value_;
|
||||
|
||||
template<typename U>
|
||||
friend Maybe<U> Nothing();
|
||||
template<typename U>
|
||||
friend Maybe<U> Just(const U& u);
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
inline Maybe<T> Nothing() {
|
||||
return Maybe<T>();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline Maybe<T> Just(const T& t) {
|
||||
return Maybe<T>(t);
|
||||
}
|
||||
|
||||
inline
|
||||
MaybeLocal<v8::String> ToDetailString(v8::Handle<v8::Value> val) {
|
||||
return MaybeLocal<v8::String>(val->ToDetailString());
|
||||
}
|
||||
|
||||
inline
|
||||
MaybeLocal<v8::Uint32> ToArrayIndex(v8::Handle<v8::Value> val) {
|
||||
return MaybeLocal<v8::Uint32>(val->ToArrayIndex());
|
||||
}
|
||||
|
||||
inline
|
||||
Maybe<bool> Equals(v8::Handle<v8::Value> a, v8::Handle<v8::Value>(b)) {
|
||||
return Just<bool>(a->Equals(b));
|
||||
}
|
||||
|
||||
inline
|
||||
MaybeLocal<v8::Object> NewInstance(v8::Handle<v8::Function> h) {
|
||||
return MaybeLocal<v8::Object>(h->NewInstance());
|
||||
}
|
||||
|
||||
inline
|
||||
MaybeLocal<v8::Object> NewInstance(
|
||||
v8::Local<v8::Function> h
|
||||
, int argc
|
||||
, v8::Local<v8::Value> argv[]) {
|
||||
return MaybeLocal<v8::Object>(h->NewInstance(argc, argv));
|
||||
}
|
||||
|
||||
inline
|
||||
MaybeLocal<v8::Object> NewInstance(v8::Handle<v8::ObjectTemplate> h) {
|
||||
return MaybeLocal<v8::Object>(h->NewInstance());
|
||||
}
|
||||
|
||||
inline
|
||||
MaybeLocal<v8::Function> GetFunction(v8::Handle<v8::FunctionTemplate> t) {
|
||||
return MaybeLocal<v8::Function>(t->GetFunction());
|
||||
}
|
||||
|
||||
inline Maybe<bool> Set(
|
||||
v8::Handle<v8::Object> obj
|
||||
, v8::Handle<v8::Value> key
|
||||
, v8::Handle<v8::Value> value) {
|
||||
return Just<bool>(obj->Set(key, value));
|
||||
}
|
||||
|
||||
inline Maybe<bool> Set(
|
||||
v8::Handle<v8::Object> obj
|
||||
, uint32_t index
|
||||
, v8::Handle<v8::Value> value) {
|
||||
return Just<bool>(obj->Set(index, value));
|
||||
}
|
||||
|
||||
#include "nan_define_own_property_helper.h" // NOLINT(build/include)
|
||||
|
||||
inline Maybe<bool> DefineOwnProperty(
|
||||
v8::Handle<v8::Object> obj
|
||||
, v8::Handle<v8::String> key
|
||||
, v8::Handle<v8::Value> value
|
||||
, v8::PropertyAttribute attribs = v8::None) {
|
||||
v8::PropertyAttribute current = obj->GetPropertyAttributes(key);
|
||||
return imp::DefineOwnPropertyHelper(current, obj, key, value, attribs);
|
||||
}
|
||||
|
||||
NAN_DEPRECATED inline Maybe<bool> ForceSet(
|
||||
v8::Handle<v8::Object> obj
|
||||
, v8::Handle<v8::Value> key
|
||||
, v8::Handle<v8::Value> value
|
||||
, v8::PropertyAttribute attribs = v8::None) {
|
||||
return Just<bool>(obj->ForceSet(key, value, attribs));
|
||||
}
|
||||
|
||||
inline MaybeLocal<v8::Value> Get(
|
||||
v8::Handle<v8::Object> obj
|
||||
, v8::Handle<v8::Value> key) {
|
||||
return MaybeLocal<v8::Value>(obj->Get(key));
|
||||
}
|
||||
|
||||
inline MaybeLocal<v8::Value> Get(
|
||||
v8::Handle<v8::Object> obj
|
||||
, uint32_t index) {
|
||||
return MaybeLocal<v8::Value>(obj->Get(index));
|
||||
}
|
||||
|
||||
inline Maybe<v8::PropertyAttribute> GetPropertyAttributes(
|
||||
v8::Handle<v8::Object> obj
|
||||
, v8::Handle<v8::Value> key) {
|
||||
return Just<v8::PropertyAttribute>(obj->GetPropertyAttributes(key));
|
||||
}
|
||||
|
||||
inline Maybe<bool> Has(
|
||||
v8::Handle<v8::Object> obj
|
||||
, v8::Handle<v8::String> key) {
|
||||
return Just<bool>(obj->Has(key));
|
||||
}
|
||||
|
||||
inline Maybe<bool> Has(
|
||||
v8::Handle<v8::Object> obj
|
||||
, uint32_t index) {
|
||||
return Just<bool>(obj->Has(index));
|
||||
}
|
||||
|
||||
inline Maybe<bool> Delete(
|
||||
v8::Handle<v8::Object> obj
|
||||
, v8::Handle<v8::String> key) {
|
||||
return Just<bool>(obj->Delete(key));
|
||||
}
|
||||
|
||||
inline Maybe<bool> Delete(
|
||||
v8::Handle<v8::Object> obj
|
||||
, uint32_t index) {
|
||||
return Just<bool>(obj->Delete(index));
|
||||
}
|
||||
|
||||
inline
|
||||
MaybeLocal<v8::Array> GetPropertyNames(v8::Handle<v8::Object> obj) {
|
||||
return MaybeLocal<v8::Array>(obj->GetPropertyNames());
|
||||
}
|
||||
|
||||
inline
|
||||
MaybeLocal<v8::Array> GetOwnPropertyNames(v8::Handle<v8::Object> obj) {
|
||||
return MaybeLocal<v8::Array>(obj->GetOwnPropertyNames());
|
||||
}
|
||||
|
||||
inline Maybe<bool> SetPrototype(
|
||||
v8::Handle<v8::Object> obj
|
||||
, v8::Handle<v8::Value> prototype) {
|
||||
return Just<bool>(obj->SetPrototype(prototype));
|
||||
}
|
||||
|
||||
inline MaybeLocal<v8::String> ObjectProtoToString(
|
||||
v8::Handle<v8::Object> obj) {
|
||||
return MaybeLocal<v8::String>(obj->ObjectProtoToString());
|
||||
}
|
||||
|
||||
inline Maybe<bool> HasOwnProperty(
|
||||
v8::Handle<v8::Object> obj
|
||||
, v8::Handle<v8::String> key) {
|
||||
return Just<bool>(obj->HasOwnProperty(key));
|
||||
}
|
||||
|
||||
inline Maybe<bool> HasRealNamedProperty(
|
||||
v8::Handle<v8::Object> obj
|
||||
, v8::Handle<v8::String> key) {
|
||||
return Just<bool>(obj->HasRealNamedProperty(key));
|
||||
}
|
||||
|
||||
inline Maybe<bool> HasRealIndexedProperty(
|
||||
v8::Handle<v8::Object> obj
|
||||
, uint32_t index) {
|
||||
return Just<bool>(obj->HasRealIndexedProperty(index));
|
||||
}
|
||||
|
||||
inline Maybe<bool> HasRealNamedCallbackProperty(
|
||||
v8::Handle<v8::Object> obj
|
||||
, v8::Handle<v8::String> key) {
|
||||
return Just<bool>(obj->HasRealNamedCallbackProperty(key));
|
||||
}
|
||||
|
||||
inline MaybeLocal<v8::Value> GetRealNamedPropertyInPrototypeChain(
|
||||
v8::Handle<v8::Object> obj
|
||||
, v8::Handle<v8::String> key) {
|
||||
return MaybeLocal<v8::Value>(
|
||||
obj->GetRealNamedPropertyInPrototypeChain(key));
|
||||
}
|
||||
|
||||
inline MaybeLocal<v8::Value> GetRealNamedProperty(
|
||||
v8::Handle<v8::Object> obj
|
||||
, v8::Handle<v8::String> key) {
|
||||
return MaybeLocal<v8::Value>(obj->GetRealNamedProperty(key));
|
||||
}
|
||||
|
||||
inline MaybeLocal<v8::Value> CallAsFunction(
|
||||
v8::Handle<v8::Object> obj
|
||||
, v8::Handle<v8::Object> recv
|
||||
, int argc
|
||||
, v8::Handle<v8::Value> argv[]) {
|
||||
return MaybeLocal<v8::Value>(obj->CallAsFunction(recv, argc, argv));
|
||||
}
|
||||
|
||||
inline MaybeLocal<v8::Value> CallAsConstructor(
|
||||
v8::Handle<v8::Object> obj
|
||||
, int argc
|
||||
, v8::Local<v8::Value> argv[]) {
|
||||
return MaybeLocal<v8::Value>(obj->CallAsConstructor(argc, argv));
|
||||
}
|
||||
|
||||
inline
|
||||
MaybeLocal<v8::String> GetSourceLine(v8::Handle<v8::Message> msg) {
|
||||
return MaybeLocal<v8::String>(msg->GetSourceLine());
|
||||
}
|
||||
|
||||
inline Maybe<int> GetLineNumber(v8::Handle<v8::Message> msg) {
|
||||
return Just<int>(msg->GetLineNumber());
|
||||
}
|
||||
|
||||
inline Maybe<int> GetStartColumn(v8::Handle<v8::Message> msg) {
|
||||
return Just<int>(msg->GetStartColumn());
|
||||
}
|
||||
|
||||
inline Maybe<int> GetEndColumn(v8::Handle<v8::Message> msg) {
|
||||
return Just<int>(msg->GetEndColumn());
|
||||
}
|
||||
|
||||
inline MaybeLocal<v8::Object> CloneElementAt(
|
||||
v8::Handle<v8::Array> array
|
||||
, uint32_t index) {
|
||||
return MaybeLocal<v8::Object>(array->CloneElementAt(index));
|
||||
}
|
||||
|
||||
inline MaybeLocal<v8::Value> Call(
|
||||
v8::Local<v8::Function> fun
|
||||
, v8::Local<v8::Object> recv
|
||||
, int argc
|
||||
, v8::Local<v8::Value> argv[]) {
|
||||
return MaybeLocal<v8::Value>(fun->Call(recv, argc, argv));
|
||||
}
|
||||
|
||||
#endif // NAN_MAYBE_PRE_43_INL_H_
|
||||
340
node_modules/nan/nan_new.h
generated
vendored
Normal file
340
node_modules/nan/nan_new.h
generated
vendored
Normal file
@@ -0,0 +1,340 @@
|
||||
/*********************************************************************
|
||||
* NAN - Native Abstractions for Node.js
|
||||
*
|
||||
* Copyright (c) 2018 NAN contributors
|
||||
*
|
||||
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
|
||||
********************************************************************/
|
||||
|
||||
#ifndef NAN_NEW_H_
|
||||
#define NAN_NEW_H_
|
||||
|
||||
namespace imp { // scnr
|
||||
|
||||
// TODO(agnat): Generalize
|
||||
template <typename T> v8::Local<T> To(v8::Local<v8::Integer> i);
|
||||
|
||||
template <>
|
||||
inline
|
||||
v8::Local<v8::Integer>
|
||||
To<v8::Integer>(v8::Local<v8::Integer> i) {
|
||||
return Nan::To<v8::Integer>(i).ToLocalChecked();
|
||||
}
|
||||
|
||||
template <>
|
||||
inline
|
||||
v8::Local<v8::Int32>
|
||||
To<v8::Int32>(v8::Local<v8::Integer> i) {
|
||||
return Nan::To<v8::Int32>(i).ToLocalChecked();
|
||||
}
|
||||
|
||||
template <>
|
||||
inline
|
||||
v8::Local<v8::Uint32>
|
||||
To<v8::Uint32>(v8::Local<v8::Integer> i) {
|
||||
return Nan::To<v8::Uint32>(i).ToLocalChecked();
|
||||
}
|
||||
|
||||
template <typename T> struct FactoryBase {
|
||||
typedef v8::Local<T> return_t;
|
||||
};
|
||||
|
||||
template <typename T> struct MaybeFactoryBase {
|
||||
typedef MaybeLocal<T> return_t;
|
||||
};
|
||||
|
||||
template <typename T> struct Factory;
|
||||
|
||||
template <>
|
||||
struct Factory<v8::Array> : FactoryBase<v8::Array> {
|
||||
static inline return_t New();
|
||||
static inline return_t New(int length);
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Factory<v8::Boolean> : FactoryBase<v8::Boolean> {
|
||||
static inline return_t New(bool value);
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Factory<v8::BooleanObject> : FactoryBase<v8::BooleanObject> {
|
||||
static inline return_t New(bool value);
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Factory<v8::Context> : FactoryBase<v8::Context> {
|
||||
static inline
|
||||
return_t
|
||||
New( v8::ExtensionConfiguration* extensions = NULL
|
||||
, v8::Local<v8::ObjectTemplate> tmpl = v8::Local<v8::ObjectTemplate>()
|
||||
, v8::Local<v8::Value> obj = v8::Local<v8::Value>());
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Factory<v8::Date> : MaybeFactoryBase<v8::Date> {
|
||||
static inline return_t New(double value);
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Factory<v8::External> : FactoryBase<v8::External> {
|
||||
static inline return_t New(void *value);
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Factory<v8::Function> : FactoryBase<v8::Function> {
|
||||
static inline
|
||||
return_t
|
||||
New( FunctionCallback callback
|
||||
, v8::Local<v8::Value> data = v8::Local<v8::Value>());
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Factory<v8::FunctionTemplate> : FactoryBase<v8::FunctionTemplate> {
|
||||
static inline
|
||||
return_t
|
||||
New( FunctionCallback callback = NULL
|
||||
, v8::Local<v8::Value> data = v8::Local<v8::Value>()
|
||||
, v8::Local<v8::Signature> signature = v8::Local<v8::Signature>());
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Factory<v8::Number> : FactoryBase<v8::Number> {
|
||||
static inline return_t New(double value);
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Factory<v8::NumberObject> : FactoryBase<v8::NumberObject> {
|
||||
static inline return_t New(double value);
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct IntegerFactory : FactoryBase<T> {
|
||||
typedef typename FactoryBase<T>::return_t return_t;
|
||||
static inline return_t New(int32_t value);
|
||||
static inline return_t New(uint32_t value);
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Factory<v8::Integer> : IntegerFactory<v8::Integer> {};
|
||||
|
||||
template <>
|
||||
struct Factory<v8::Int32> : IntegerFactory<v8::Int32> {};
|
||||
|
||||
template <>
|
||||
struct Factory<v8::Uint32> : FactoryBase<v8::Uint32> {
|
||||
static inline return_t New(int32_t value);
|
||||
static inline return_t New(uint32_t value);
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Factory<v8::Object> : FactoryBase<v8::Object> {
|
||||
static inline return_t New();
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Factory<v8::ObjectTemplate> : FactoryBase<v8::ObjectTemplate> {
|
||||
static inline return_t New();
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Factory<v8::RegExp> : MaybeFactoryBase<v8::RegExp> {
|
||||
static inline return_t New(
|
||||
v8::Local<v8::String> pattern, v8::RegExp::Flags flags);
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Factory<v8::Script> : MaybeFactoryBase<v8::Script> {
|
||||
static inline return_t New( v8::Local<v8::String> source);
|
||||
static inline return_t New( v8::Local<v8::String> source
|
||||
, v8::ScriptOrigin const& origin);
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Factory<v8::Signature> : FactoryBase<v8::Signature> {
|
||||
typedef v8::Local<v8::FunctionTemplate> FTH;
|
||||
static inline return_t New(FTH receiver = FTH());
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Factory<v8::String> : MaybeFactoryBase<v8::String> {
|
||||
static inline return_t New();
|
||||
static inline return_t New(const char *value, int length = -1);
|
||||
static inline return_t New(const uint16_t *value, int length = -1);
|
||||
static inline return_t New(std::string const& value);
|
||||
|
||||
static inline return_t New(v8::String::ExternalStringResource * value);
|
||||
static inline return_t New(ExternalOneByteStringResource * value);
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Factory<v8::StringObject> : FactoryBase<v8::StringObject> {
|
||||
static inline return_t New(v8::Local<v8::String> value);
|
||||
};
|
||||
|
||||
} // end of namespace imp
|
||||
|
||||
#if (NODE_MODULE_VERSION >= 12)
|
||||
|
||||
namespace imp {
|
||||
|
||||
template <>
|
||||
struct Factory<v8::UnboundScript> : MaybeFactoryBase<v8::UnboundScript> {
|
||||
static inline return_t New( v8::Local<v8::String> source);
|
||||
static inline return_t New( v8::Local<v8::String> source
|
||||
, v8::ScriptOrigin const& origin);
|
||||
};
|
||||
|
||||
} // end of namespace imp
|
||||
|
||||
# include "nan_implementation_12_inl.h"
|
||||
|
||||
#else // NODE_MODULE_VERSION >= 12
|
||||
|
||||
# include "nan_implementation_pre_12_inl.h"
|
||||
|
||||
#endif
|
||||
|
||||
//=== API ======================================================================
|
||||
|
||||
template <typename T>
|
||||
typename imp::Factory<T>::return_t
|
||||
New() {
|
||||
return imp::Factory<T>::New();
|
||||
}
|
||||
|
||||
template <typename T, typename A0>
|
||||
typename imp::Factory<T>::return_t
|
||||
New(A0 arg0) {
|
||||
return imp::Factory<T>::New(arg0);
|
||||
}
|
||||
|
||||
template <typename T, typename A0, typename A1>
|
||||
typename imp::Factory<T>::return_t
|
||||
New(A0 arg0, A1 arg1) {
|
||||
return imp::Factory<T>::New(arg0, arg1);
|
||||
}
|
||||
|
||||
template <typename T, typename A0, typename A1, typename A2>
|
||||
typename imp::Factory<T>::return_t
|
||||
New(A0 arg0, A1 arg1, A2 arg2) {
|
||||
return imp::Factory<T>::New(arg0, arg1, arg2);
|
||||
}
|
||||
|
||||
template <typename T, typename A0, typename A1, typename A2, typename A3>
|
||||
typename imp::Factory<T>::return_t
|
||||
New(A0 arg0, A1 arg1, A2 arg2, A3 arg3) {
|
||||
return imp::Factory<T>::New(arg0, arg1, arg2, arg3);
|
||||
}
|
||||
|
||||
// Note(agnat): When passing overloaded function pointers to template functions
|
||||
// as generic arguments the compiler needs help in picking the right overload.
|
||||
// These two functions handle New<Function> and New<FunctionTemplate> with
|
||||
// all argument variations.
|
||||
|
||||
// v8::Function and v8::FunctionTemplate with one or two arguments
|
||||
template <typename T>
|
||||
typename imp::Factory<T>::return_t
|
||||
New( FunctionCallback callback
|
||||
, v8::Local<v8::Value> data = v8::Local<v8::Value>()) {
|
||||
return imp::Factory<T>::New(callback, data);
|
||||
}
|
||||
|
||||
// v8::Function and v8::FunctionTemplate with three arguments
|
||||
template <typename T, typename A2>
|
||||
typename imp::Factory<T>::return_t
|
||||
New( FunctionCallback callback
|
||||
, v8::Local<v8::Value> data = v8::Local<v8::Value>()
|
||||
, A2 a2 = A2()) {
|
||||
return imp::Factory<T>::New(callback, data, a2);
|
||||
}
|
||||
|
||||
// Convenience
|
||||
|
||||
#if NODE_MODULE_VERSION < IOJS_3_0_MODULE_VERSION
|
||||
template <typename T> inline v8::Local<T> New(v8::Handle<T> h);
|
||||
#endif
|
||||
|
||||
#if NODE_MODULE_VERSION > NODE_0_10_MODULE_VERSION
|
||||
template <typename T, typename M>
|
||||
inline v8::Local<T> New(v8::Persistent<T, M> const& p);
|
||||
#else
|
||||
template <typename T> inline v8::Local<T> New(v8::Persistent<T> const& p);
|
||||
#endif
|
||||
template <typename T, typename M>
|
||||
inline v8::Local<T> New(Persistent<T, M> const& p);
|
||||
template <typename T>
|
||||
inline v8::Local<T> New(Global<T> const& p);
|
||||
|
||||
inline
|
||||
imp::Factory<v8::Boolean>::return_t
|
||||
New(bool value) {
|
||||
return New<v8::Boolean>(value);
|
||||
}
|
||||
|
||||
inline
|
||||
imp::Factory<v8::Int32>::return_t
|
||||
New(int32_t value) {
|
||||
return New<v8::Int32>(value);
|
||||
}
|
||||
|
||||
inline
|
||||
imp::Factory<v8::Uint32>::return_t
|
||||
New(uint32_t value) {
|
||||
return New<v8::Uint32>(value);
|
||||
}
|
||||
|
||||
inline
|
||||
imp::Factory<v8::Number>::return_t
|
||||
New(double value) {
|
||||
return New<v8::Number>(value);
|
||||
}
|
||||
|
||||
inline
|
||||
imp::Factory<v8::String>::return_t
|
||||
New(std::string const& value) { // NOLINT(build/include_what_you_use)
|
||||
return New<v8::String>(value);
|
||||
}
|
||||
|
||||
inline
|
||||
imp::Factory<v8::String>::return_t
|
||||
New(const char * value, int length) {
|
||||
return New<v8::String>(value, length);
|
||||
}
|
||||
|
||||
inline
|
||||
imp::Factory<v8::String>::return_t
|
||||
New(const uint16_t * value, int length) {
|
||||
return New<v8::String>(value, length);
|
||||
}
|
||||
|
||||
inline
|
||||
imp::Factory<v8::String>::return_t
|
||||
New(const char * value) {
|
||||
return New<v8::String>(value);
|
||||
}
|
||||
|
||||
inline
|
||||
imp::Factory<v8::String>::return_t
|
||||
New(const uint16_t * value) {
|
||||
return New<v8::String>(value);
|
||||
}
|
||||
|
||||
inline
|
||||
imp::Factory<v8::String>::return_t
|
||||
New(v8::String::ExternalStringResource * value) {
|
||||
return New<v8::String>(value);
|
||||
}
|
||||
|
||||
inline
|
||||
imp::Factory<v8::String>::return_t
|
||||
New(ExternalOneByteStringResource * value) {
|
||||
return New<v8::String>(value);
|
||||
}
|
||||
|
||||
inline
|
||||
imp::Factory<v8::RegExp>::return_t
|
||||
New(v8::Local<v8::String> pattern, v8::RegExp::Flags flags) {
|
||||
return New<v8::RegExp>(pattern, flags);
|
||||
}
|
||||
|
||||
#endif // NAN_NEW_H_
|
||||
155
node_modules/nan/nan_object_wrap.h
generated
vendored
Normal file
155
node_modules/nan/nan_object_wrap.h
generated
vendored
Normal file
@@ -0,0 +1,155 @@
|
||||
/*********************************************************************
|
||||
* NAN - Native Abstractions for Node.js
|
||||
*
|
||||
* Copyright (c) 2018 NAN contributors
|
||||
*
|
||||
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
|
||||
********************************************************************/
|
||||
|
||||
#ifndef NAN_OBJECT_WRAP_H_
|
||||
#define NAN_OBJECT_WRAP_H_
|
||||
|
||||
class ObjectWrap {
|
||||
public:
|
||||
ObjectWrap() {
|
||||
refs_ = 0;
|
||||
}
|
||||
|
||||
|
||||
virtual ~ObjectWrap() {
|
||||
if (persistent().IsEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
assert(persistent().IsNearDeath());
|
||||
persistent().ClearWeak();
|
||||
persistent().Reset();
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
static inline T* Unwrap(v8::Local<v8::Object> object) {
|
||||
assert(!object.IsEmpty());
|
||||
assert(object->InternalFieldCount() > 0);
|
||||
// Cast to ObjectWrap before casting to T. A direct cast from void
|
||||
// to T won't work right when T has more than one base class.
|
||||
void* ptr = GetInternalFieldPointer(object, 0);
|
||||
ObjectWrap* wrap = static_cast<ObjectWrap*>(ptr);
|
||||
return static_cast<T*>(wrap);
|
||||
}
|
||||
|
||||
|
||||
inline v8::Local<v8::Object> handle() const {
|
||||
return New(handle_);
|
||||
}
|
||||
|
||||
|
||||
inline Persistent<v8::Object>& persistent() {
|
||||
return handle_;
|
||||
}
|
||||
|
||||
|
||||
protected:
|
||||
inline void Wrap(v8::Local<v8::Object> object) {
|
||||
assert(persistent().IsEmpty());
|
||||
assert(object->InternalFieldCount() > 0);
|
||||
SetInternalFieldPointer(object, 0, this);
|
||||
persistent().Reset(object);
|
||||
MakeWeak();
|
||||
}
|
||||
|
||||
#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 4 || \
|
||||
(V8_MAJOR_VERSION == 4 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION >= 3))
|
||||
|
||||
inline void MakeWeak() {
|
||||
persistent().v8::PersistentBase<v8::Object>::SetWeak(
|
||||
this, WeakCallback, v8::WeakCallbackType::kParameter);
|
||||
persistent().MarkIndependent();
|
||||
}
|
||||
|
||||
#elif NODE_MODULE_VERSION > NODE_0_10_MODULE_VERSION
|
||||
|
||||
inline void MakeWeak() {
|
||||
persistent().v8::PersistentBase<v8::Object>::SetWeak(this, WeakCallback);
|
||||
persistent().MarkIndependent();
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
inline void MakeWeak() {
|
||||
persistent().persistent.MakeWeak(this, WeakCallback);
|
||||
persistent().MarkIndependent();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* Ref() marks the object as being attached to an event loop.
|
||||
* Refed objects will not be garbage collected, even if
|
||||
* all references are lost.
|
||||
*/
|
||||
virtual void Ref() {
|
||||
assert(!persistent().IsEmpty());
|
||||
persistent().ClearWeak();
|
||||
refs_++;
|
||||
}
|
||||
|
||||
/* Unref() marks an object as detached from the event loop. This is its
|
||||
* default state. When an object with a "weak" reference changes from
|
||||
* attached to detached state it will be freed. Be careful not to access
|
||||
* the object after making this call as it might be gone!
|
||||
* (A "weak reference" means an object that only has a
|
||||
* persistant handle.)
|
||||
*
|
||||
* DO NOT CALL THIS FROM DESTRUCTOR
|
||||
*/
|
||||
virtual void Unref() {
|
||||
assert(!persistent().IsEmpty());
|
||||
assert(!persistent().IsWeak());
|
||||
assert(refs_ > 0);
|
||||
if (--refs_ == 0)
|
||||
MakeWeak();
|
||||
}
|
||||
|
||||
int refs_; // ro
|
||||
|
||||
private:
|
||||
NAN_DISALLOW_ASSIGN_COPY_MOVE(ObjectWrap)
|
||||
#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 4 || \
|
||||
(V8_MAJOR_VERSION == 4 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION >= 3))
|
||||
|
||||
static void
|
||||
WeakCallback(v8::WeakCallbackInfo<ObjectWrap> const& info) {
|
||||
ObjectWrap* wrap = info.GetParameter();
|
||||
assert(wrap->refs_ == 0);
|
||||
assert(wrap->handle_.IsNearDeath());
|
||||
wrap->handle_.Reset();
|
||||
delete wrap;
|
||||
}
|
||||
|
||||
#elif NODE_MODULE_VERSION > NODE_0_10_MODULE_VERSION
|
||||
|
||||
static void
|
||||
WeakCallback(v8::WeakCallbackData<v8::Object, ObjectWrap> const& data) {
|
||||
ObjectWrap* wrap = data.GetParameter();
|
||||
assert(wrap->refs_ == 0);
|
||||
assert(wrap->handle_.IsNearDeath());
|
||||
wrap->handle_.Reset();
|
||||
delete wrap;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
static void WeakCallback(v8::Persistent<v8::Value> value, void *data) {
|
||||
ObjectWrap *wrap = static_cast<ObjectWrap*>(data);
|
||||
assert(wrap->refs_ == 0);
|
||||
assert(wrap->handle_.IsNearDeath());
|
||||
wrap->handle_.Reset();
|
||||
delete wrap;
|
||||
}
|
||||
|
||||
#endif
|
||||
Persistent<v8::Object> handle_;
|
||||
};
|
||||
|
||||
|
||||
#endif // NAN_OBJECT_WRAP_H_
|
||||
132
node_modules/nan/nan_persistent_12_inl.h
generated
vendored
Normal file
132
node_modules/nan/nan_persistent_12_inl.h
generated
vendored
Normal file
@@ -0,0 +1,132 @@
|
||||
/*********************************************************************
|
||||
* NAN - Native Abstractions for Node.js
|
||||
*
|
||||
* Copyright (c) 2018 NAN contributors
|
||||
*
|
||||
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
|
||||
********************************************************************/
|
||||
|
||||
#ifndef NAN_PERSISTENT_12_INL_H_
|
||||
#define NAN_PERSISTENT_12_INL_H_
|
||||
|
||||
template<typename T, typename M> class Persistent :
|
||||
public v8::Persistent<T, M> {
|
||||
public:
|
||||
inline Persistent() : v8::Persistent<T, M>() {}
|
||||
|
||||
template<typename S> inline Persistent(v8::Local<S> that) :
|
||||
v8::Persistent<T, M>(v8::Isolate::GetCurrent(), that) {}
|
||||
|
||||
template<typename S, typename M2>
|
||||
inline
|
||||
Persistent(const v8::Persistent<S, M2> &that) : // NOLINT(runtime/explicit)
|
||||
v8::Persistent<T, M2>(v8::Isolate::GetCurrent(), that) {}
|
||||
|
||||
inline void Reset() { v8::PersistentBase<T>::Reset(); }
|
||||
|
||||
template <typename S>
|
||||
inline void Reset(const v8::Local<S> &other) {
|
||||
v8::PersistentBase<T>::Reset(v8::Isolate::GetCurrent(), other);
|
||||
}
|
||||
|
||||
template <typename S>
|
||||
inline void Reset(const v8::PersistentBase<S> &other) {
|
||||
v8::PersistentBase<T>::Reset(v8::Isolate::GetCurrent(), other);
|
||||
}
|
||||
|
||||
template<typename P>
|
||||
inline void SetWeak(
|
||||
P *parameter
|
||||
, typename WeakCallbackInfo<P>::Callback callback
|
||||
, WeakCallbackType type);
|
||||
|
||||
private:
|
||||
inline T *operator*() const { return *PersistentBase<T>::persistent; }
|
||||
|
||||
template<typename S, typename M2>
|
||||
inline void Copy(const Persistent<S, M2> &that) {
|
||||
TYPE_CHECK(T, S);
|
||||
|
||||
this->Reset();
|
||||
|
||||
if (!that.IsEmpty()) {
|
||||
this->Reset(that);
|
||||
M::Copy(that, this);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 4 || \
|
||||
(V8_MAJOR_VERSION == 4 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION >= 3))
|
||||
template<typename T>
|
||||
class Global : public v8::Global<T> {
|
||||
public:
|
||||
inline Global() : v8::Global<T>() {}
|
||||
|
||||
template<typename S> inline Global(v8::Local<S> that) :
|
||||
v8::Global<T>(v8::Isolate::GetCurrent(), that) {}
|
||||
|
||||
template<typename S>
|
||||
inline
|
||||
Global(const v8::PersistentBase<S> &that) : // NOLINT(runtime/explicit)
|
||||
v8::Global<S>(v8::Isolate::GetCurrent(), that) {}
|
||||
|
||||
inline void Reset() { v8::PersistentBase<T>::Reset(); }
|
||||
|
||||
template <typename S>
|
||||
inline void Reset(const v8::Local<S> &other) {
|
||||
v8::PersistentBase<T>::Reset(v8::Isolate::GetCurrent(), other);
|
||||
}
|
||||
|
||||
template <typename S>
|
||||
inline void Reset(const v8::PersistentBase<S> &other) {
|
||||
v8::PersistentBase<T>::Reset(v8::Isolate::GetCurrent(), other);
|
||||
}
|
||||
|
||||
template<typename P>
|
||||
inline void SetWeak(
|
||||
P *parameter
|
||||
, typename WeakCallbackInfo<P>::Callback callback
|
||||
, WeakCallbackType type) {
|
||||
reinterpret_cast<Persistent<T>*>(this)->SetWeak(
|
||||
parameter, callback, type);
|
||||
}
|
||||
};
|
||||
#else
|
||||
template<typename T>
|
||||
class Global : public v8::UniquePersistent<T> {
|
||||
public:
|
||||
inline Global() : v8::UniquePersistent<T>() {}
|
||||
|
||||
template<typename S> inline Global(v8::Local<S> that) :
|
||||
v8::UniquePersistent<T>(v8::Isolate::GetCurrent(), that) {}
|
||||
|
||||
template<typename S>
|
||||
inline
|
||||
Global(const v8::PersistentBase<S> &that) : // NOLINT(runtime/explicit)
|
||||
v8::UniquePersistent<S>(v8::Isolate::GetCurrent(), that) {}
|
||||
|
||||
inline void Reset() { v8::PersistentBase<T>::Reset(); }
|
||||
|
||||
template <typename S>
|
||||
inline void Reset(const v8::Local<S> &other) {
|
||||
v8::PersistentBase<T>::Reset(v8::Isolate::GetCurrent(), other);
|
||||
}
|
||||
|
||||
template <typename S>
|
||||
inline void Reset(const v8::PersistentBase<S> &other) {
|
||||
v8::PersistentBase<T>::Reset(v8::Isolate::GetCurrent(), other);
|
||||
}
|
||||
|
||||
template<typename P>
|
||||
inline void SetWeak(
|
||||
P *parameter
|
||||
, typename WeakCallbackInfo<P>::Callback callback
|
||||
, WeakCallbackType type) {
|
||||
reinterpret_cast<Persistent<T>*>(this)->SetWeak(
|
||||
parameter, callback, type);
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif // NAN_PERSISTENT_12_INL_H_
|
||||
242
node_modules/nan/nan_persistent_pre_12_inl.h
generated
vendored
Normal file
242
node_modules/nan/nan_persistent_pre_12_inl.h
generated
vendored
Normal file
@@ -0,0 +1,242 @@
|
||||
/*********************************************************************
|
||||
* NAN - Native Abstractions for Node.js
|
||||
*
|
||||
* Copyright (c) 2018 NAN contributors
|
||||
*
|
||||
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
|
||||
********************************************************************/
|
||||
|
||||
#ifndef NAN_PERSISTENT_PRE_12_INL_H_
|
||||
#define NAN_PERSISTENT_PRE_12_INL_H_
|
||||
|
||||
template<typename T>
|
||||
class PersistentBase {
|
||||
v8::Persistent<T> persistent;
|
||||
template<typename U>
|
||||
friend v8::Local<U> New(const PersistentBase<U> &p);
|
||||
template<typename U, typename M>
|
||||
friend v8::Local<U> New(const Persistent<U, M> &p);
|
||||
template<typename U>
|
||||
friend v8::Local<U> New(const Global<U> &p);
|
||||
template<typename S> friend class ReturnValue;
|
||||
|
||||
public:
|
||||
inline PersistentBase() :
|
||||
persistent() {}
|
||||
|
||||
inline void Reset() {
|
||||
persistent.Dispose();
|
||||
persistent.Clear();
|
||||
}
|
||||
|
||||
template<typename S>
|
||||
inline void Reset(const v8::Local<S> &other) {
|
||||
TYPE_CHECK(T, S);
|
||||
|
||||
if (!persistent.IsEmpty()) {
|
||||
persistent.Dispose();
|
||||
}
|
||||
|
||||
if (other.IsEmpty()) {
|
||||
persistent.Clear();
|
||||
} else {
|
||||
persistent = v8::Persistent<T>::New(other);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename S>
|
||||
inline void Reset(const PersistentBase<S> &other) {
|
||||
TYPE_CHECK(T, S);
|
||||
|
||||
if (!persistent.IsEmpty()) {
|
||||
persistent.Dispose();
|
||||
}
|
||||
|
||||
if (other.IsEmpty()) {
|
||||
persistent.Clear();
|
||||
} else {
|
||||
persistent = v8::Persistent<T>::New(other.persistent);
|
||||
}
|
||||
}
|
||||
|
||||
inline bool IsEmpty() const { return persistent.IsEmpty(); }
|
||||
|
||||
inline void Empty() { persistent.Clear(); }
|
||||
|
||||
template<typename S>
|
||||
inline bool operator==(const PersistentBase<S> &that) const {
|
||||
return this->persistent == that.persistent;
|
||||
}
|
||||
|
||||
template<typename S>
|
||||
inline bool operator==(const v8::Local<S> &that) const {
|
||||
return this->persistent == that;
|
||||
}
|
||||
|
||||
template<typename S>
|
||||
inline bool operator!=(const PersistentBase<S> &that) const {
|
||||
return !operator==(that);
|
||||
}
|
||||
|
||||
template<typename S>
|
||||
inline bool operator!=(const v8::Local<S> &that) const {
|
||||
return !operator==(that);
|
||||
}
|
||||
|
||||
template<typename P>
|
||||
inline void SetWeak(
|
||||
P *parameter
|
||||
, typename WeakCallbackInfo<P>::Callback callback
|
||||
, WeakCallbackType type);
|
||||
|
||||
inline void ClearWeak() { persistent.ClearWeak(); }
|
||||
|
||||
inline void MarkIndependent() { persistent.MarkIndependent(); }
|
||||
|
||||
inline bool IsIndependent() const { return persistent.IsIndependent(); }
|
||||
|
||||
inline bool IsNearDeath() const { return persistent.IsNearDeath(); }
|
||||
|
||||
inline bool IsWeak() const { return persistent.IsWeak(); }
|
||||
|
||||
private:
|
||||
inline explicit PersistentBase(v8::Persistent<T> that) :
|
||||
persistent(that) { }
|
||||
inline explicit PersistentBase(T *val) : persistent(val) {}
|
||||
template<typename S, typename M> friend class Persistent;
|
||||
template<typename S> friend class Global;
|
||||
friend class ObjectWrap;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
class NonCopyablePersistentTraits {
|
||||
public:
|
||||
typedef Persistent<T, NonCopyablePersistentTraits<T> >
|
||||
NonCopyablePersistent;
|
||||
static const bool kResetInDestructor = false;
|
||||
template<typename S, typename M>
|
||||
inline static void Copy(const Persistent<S, M> &source,
|
||||
NonCopyablePersistent *dest) {
|
||||
Uncompilable<v8::Object>();
|
||||
}
|
||||
|
||||
template<typename O> inline static void Uncompilable() {
|
||||
TYPE_CHECK(O, v8::Primitive);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct CopyablePersistentTraits {
|
||||
typedef Persistent<T, CopyablePersistentTraits<T> > CopyablePersistent;
|
||||
static const bool kResetInDestructor = true;
|
||||
template<typename S, typename M>
|
||||
static inline void Copy(const Persistent<S, M> &source,
|
||||
CopyablePersistent *dest) {}
|
||||
};
|
||||
|
||||
template<typename T, typename M> class Persistent :
|
||||
public PersistentBase<T> {
|
||||
public:
|
||||
inline Persistent() {}
|
||||
|
||||
template<typename S> inline Persistent(v8::Handle<S> that)
|
||||
: PersistentBase<T>(v8::Persistent<T>::New(that)) {
|
||||
TYPE_CHECK(T, S);
|
||||
}
|
||||
|
||||
inline Persistent(const Persistent &that) : PersistentBase<T>() {
|
||||
Copy(that);
|
||||
}
|
||||
|
||||
template<typename S, typename M2>
|
||||
inline Persistent(const Persistent<S, M2> &that) :
|
||||
PersistentBase<T>() {
|
||||
Copy(that);
|
||||
}
|
||||
|
||||
inline Persistent &operator=(const Persistent &that) {
|
||||
Copy(that);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class S, class M2>
|
||||
inline Persistent &operator=(const Persistent<S, M2> &that) {
|
||||
Copy(that);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline ~Persistent() {
|
||||
if (M::kResetInDestructor) this->Reset();
|
||||
}
|
||||
|
||||
private:
|
||||
inline T *operator*() const { return *PersistentBase<T>::persistent; }
|
||||
|
||||
template<typename S, typename M2>
|
||||
inline void Copy(const Persistent<S, M2> &that) {
|
||||
TYPE_CHECK(T, S);
|
||||
|
||||
this->Reset();
|
||||
|
||||
if (!that.IsEmpty()) {
|
||||
this->persistent = v8::Persistent<T>::New(that.persistent);
|
||||
M::Copy(that, this);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
class Global : public PersistentBase<T> {
|
||||
struct RValue {
|
||||
inline explicit RValue(Global* obj) : object(obj) {}
|
||||
Global* object;
|
||||
};
|
||||
|
||||
public:
|
||||
inline Global() : PersistentBase<T>(0) { }
|
||||
|
||||
template <typename S>
|
||||
inline Global(v8::Local<S> that) // NOLINT(runtime/explicit)
|
||||
: PersistentBase<T>(v8::Persistent<T>::New(that)) {
|
||||
TYPE_CHECK(T, S);
|
||||
}
|
||||
|
||||
template <typename S>
|
||||
inline Global(const PersistentBase<S> &that) // NOLINT(runtime/explicit)
|
||||
: PersistentBase<T>(that) {
|
||||
TYPE_CHECK(T, S);
|
||||
}
|
||||
/**
|
||||
* Move constructor.
|
||||
*/
|
||||
inline Global(RValue rvalue) // NOLINT(runtime/explicit)
|
||||
: PersistentBase<T>(rvalue.object->persistent) {
|
||||
rvalue.object->Reset();
|
||||
}
|
||||
inline ~Global() { this->Reset(); }
|
||||
/**
|
||||
* Move via assignment.
|
||||
*/
|
||||
template<typename S>
|
||||
inline Global &operator=(Global<S> rhs) {
|
||||
TYPE_CHECK(T, S);
|
||||
this->Reset(rhs.persistent);
|
||||
rhs.Reset();
|
||||
return *this;
|
||||
}
|
||||
/**
|
||||
* Cast operator for moves.
|
||||
*/
|
||||
inline operator RValue() { return RValue(this); }
|
||||
/**
|
||||
* Pass allows returning uniques from functions, etc.
|
||||
*/
|
||||
Global Pass() { return Global(RValue(this)); }
|
||||
|
||||
private:
|
||||
Global(Global &);
|
||||
void operator=(Global &);
|
||||
template<typename S> friend class ReturnValue;
|
||||
};
|
||||
|
||||
#endif // NAN_PERSISTENT_PRE_12_INL_H_
|
||||
73
node_modules/nan/nan_private.h
generated
vendored
Normal file
73
node_modules/nan/nan_private.h
generated
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
/*********************************************************************
|
||||
* NAN - Native Abstractions for Node.js
|
||||
*
|
||||
* Copyright (c) 2018 NAN contributors
|
||||
*
|
||||
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
|
||||
********************************************************************/
|
||||
|
||||
#ifndef NAN_PRIVATE_H_
|
||||
#define NAN_PRIVATE_H_
|
||||
|
||||
inline Maybe<bool>
|
||||
HasPrivate(v8::Local<v8::Object> object, v8::Local<v8::String> key) {
|
||||
HandleScope scope;
|
||||
#if NODE_MODULE_VERSION >= NODE_6_0_MODULE_VERSION
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::Local<v8::Context> context = isolate->GetCurrentContext();
|
||||
v8::Local<v8::Private> private_key = v8::Private::ForApi(isolate, key);
|
||||
return object->HasPrivate(context, private_key);
|
||||
#else
|
||||
return Just(!object->GetHiddenValue(key).IsEmpty());
|
||||
#endif
|
||||
}
|
||||
|
||||
inline MaybeLocal<v8::Value>
|
||||
GetPrivate(v8::Local<v8::Object> object, v8::Local<v8::String> key) {
|
||||
#if NODE_MODULE_VERSION >= NODE_6_0_MODULE_VERSION
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::EscapableHandleScope scope(isolate);
|
||||
v8::Local<v8::Context> context = isolate->GetCurrentContext();
|
||||
v8::Local<v8::Private> private_key = v8::Private::ForApi(isolate, key);
|
||||
v8::MaybeLocal<v8::Value> v = object->GetPrivate(context, private_key);
|
||||
return scope.Escape(v.ToLocalChecked());
|
||||
#else
|
||||
EscapableHandleScope scope;
|
||||
v8::Local<v8::Value> v = object->GetHiddenValue(key);
|
||||
if (v.IsEmpty()) {
|
||||
v = Undefined();
|
||||
}
|
||||
return scope.Escape(v);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline Maybe<bool> SetPrivate(
|
||||
v8::Local<v8::Object> object,
|
||||
v8::Local<v8::String> key,
|
||||
v8::Local<v8::Value> value) {
|
||||
#if NODE_MODULE_VERSION >= NODE_6_0_MODULE_VERSION
|
||||
HandleScope scope;
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::Local<v8::Context> context = isolate->GetCurrentContext();
|
||||
v8::Local<v8::Private> private_key = v8::Private::ForApi(isolate, key);
|
||||
return object->SetPrivate(context, private_key, value);
|
||||
#else
|
||||
return Just(object->SetHiddenValue(key, value));
|
||||
#endif
|
||||
}
|
||||
|
||||
inline Maybe<bool> DeletePrivate(
|
||||
v8::Local<v8::Object> object,
|
||||
v8::Local<v8::String> key) {
|
||||
#if NODE_MODULE_VERSION >= NODE_6_0_MODULE_VERSION
|
||||
HandleScope scope;
|
||||
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
||||
v8::Local<v8::Private> private_key = v8::Private::ForApi(isolate, key);
|
||||
return object->DeletePrivate(isolate->GetCurrentContext(), private_key);
|
||||
#else
|
||||
return Just(object->DeleteHiddenValue(key));
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif // NAN_PRIVATE_H_
|
||||
|
||||
305
node_modules/nan/nan_string_bytes.h
generated
vendored
Normal file
305
node_modules/nan/nan_string_bytes.h
generated
vendored
Normal file
@@ -0,0 +1,305 @@
|
||||
// Copyright Joyent, Inc. and other Node contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||
// persons to whom the Software is furnished to do so, subject to the
|
||||
// following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
#ifndef NAN_STRING_BYTES_H_
|
||||
#define NAN_STRING_BYTES_H_
|
||||
|
||||
// Decodes a v8::Local<v8::String> or Buffer to a raw char*
|
||||
|
||||
namespace imp {
|
||||
|
||||
using v8::Local;
|
||||
using v8::Object;
|
||||
using v8::String;
|
||||
using v8::Value;
|
||||
|
||||
|
||||
//// Base 64 ////
|
||||
|
||||
#define base64_encoded_size(size) ((size + 2 - ((size + 2) % 3)) / 3 * 4)
|
||||
|
||||
|
||||
|
||||
//// HEX ////
|
||||
|
||||
static bool contains_non_ascii_slow(const char* buf, size_t len) {
|
||||
for (size_t i = 0; i < len; ++i) {
|
||||
if (buf[i] & 0x80) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
static bool contains_non_ascii(const char* src, size_t len) {
|
||||
if (len < 16) {
|
||||
return contains_non_ascii_slow(src, len);
|
||||
}
|
||||
|
||||
const unsigned bytes_per_word = sizeof(void*);
|
||||
const unsigned align_mask = bytes_per_word - 1;
|
||||
const unsigned unaligned = reinterpret_cast<uintptr_t>(src) & align_mask;
|
||||
|
||||
if (unaligned > 0) {
|
||||
const unsigned n = bytes_per_word - unaligned;
|
||||
if (contains_non_ascii_slow(src, n)) return true;
|
||||
src += n;
|
||||
len -= n;
|
||||
}
|
||||
|
||||
|
||||
#if defined(__x86_64__) || defined(_WIN64)
|
||||
const uintptr_t mask = 0x8080808080808080ll;
|
||||
#else
|
||||
const uintptr_t mask = 0x80808080l;
|
||||
#endif
|
||||
|
||||
const uintptr_t* srcw = reinterpret_cast<const uintptr_t*>(src);
|
||||
|
||||
for (size_t i = 0, n = len / bytes_per_word; i < n; ++i) {
|
||||
if (srcw[i] & mask) return true;
|
||||
}
|
||||
|
||||
const unsigned remainder = len & align_mask;
|
||||
if (remainder > 0) {
|
||||
const size_t offset = len - remainder;
|
||||
if (contains_non_ascii_slow(src + offset, remainder)) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
static void force_ascii_slow(const char* src, char* dst, size_t len) {
|
||||
for (size_t i = 0; i < len; ++i) {
|
||||
dst[i] = src[i] & 0x7f;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void force_ascii(const char* src, char* dst, size_t len) {
|
||||
if (len < 16) {
|
||||
force_ascii_slow(src, dst, len);
|
||||
return;
|
||||
}
|
||||
|
||||
const unsigned bytes_per_word = sizeof(void*);
|
||||
const unsigned align_mask = bytes_per_word - 1;
|
||||
const unsigned src_unalign = reinterpret_cast<uintptr_t>(src) & align_mask;
|
||||
const unsigned dst_unalign = reinterpret_cast<uintptr_t>(dst) & align_mask;
|
||||
|
||||
if (src_unalign > 0) {
|
||||
if (src_unalign == dst_unalign) {
|
||||
const unsigned unalign = bytes_per_word - src_unalign;
|
||||
force_ascii_slow(src, dst, unalign);
|
||||
src += unalign;
|
||||
dst += unalign;
|
||||
len -= src_unalign;
|
||||
} else {
|
||||
force_ascii_slow(src, dst, len);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(__x86_64__) || defined(_WIN64)
|
||||
const uintptr_t mask = ~0x8080808080808080ll;
|
||||
#else
|
||||
const uintptr_t mask = ~0x80808080l;
|
||||
#endif
|
||||
|
||||
const uintptr_t* srcw = reinterpret_cast<const uintptr_t*>(src);
|
||||
uintptr_t* dstw = reinterpret_cast<uintptr_t*>(dst);
|
||||
|
||||
for (size_t i = 0, n = len / bytes_per_word; i < n; ++i) {
|
||||
dstw[i] = srcw[i] & mask;
|
||||
}
|
||||
|
||||
const unsigned remainder = len & align_mask;
|
||||
if (remainder > 0) {
|
||||
const size_t offset = len - remainder;
|
||||
force_ascii_slow(src + offset, dst + offset, remainder);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static size_t base64_encode(const char* src,
|
||||
size_t slen,
|
||||
char* dst,
|
||||
size_t dlen) {
|
||||
// We know how much we'll write, just make sure that there's space.
|
||||
assert(dlen >= base64_encoded_size(slen) &&
|
||||
"not enough space provided for base64 encode");
|
||||
|
||||
dlen = base64_encoded_size(slen);
|
||||
|
||||
unsigned a;
|
||||
unsigned b;
|
||||
unsigned c;
|
||||
unsigned i;
|
||||
unsigned k;
|
||||
unsigned n;
|
||||
|
||||
static const char table[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
"abcdefghijklmnopqrstuvwxyz"
|
||||
"0123456789+/";
|
||||
|
||||
i = 0;
|
||||
k = 0;
|
||||
n = slen / 3 * 3;
|
||||
|
||||
while (i < n) {
|
||||
a = src[i + 0] & 0xff;
|
||||
b = src[i + 1] & 0xff;
|
||||
c = src[i + 2] & 0xff;
|
||||
|
||||
dst[k + 0] = table[a >> 2];
|
||||
dst[k + 1] = table[((a & 3) << 4) | (b >> 4)];
|
||||
dst[k + 2] = table[((b & 0x0f) << 2) | (c >> 6)];
|
||||
dst[k + 3] = table[c & 0x3f];
|
||||
|
||||
i += 3;
|
||||
k += 4;
|
||||
}
|
||||
|
||||
if (n != slen) {
|
||||
switch (slen - n) {
|
||||
case 1:
|
||||
a = src[i + 0] & 0xff;
|
||||
dst[k + 0] = table[a >> 2];
|
||||
dst[k + 1] = table[(a & 3) << 4];
|
||||
dst[k + 2] = '=';
|
||||
dst[k + 3] = '=';
|
||||
break;
|
||||
|
||||
case 2:
|
||||
a = src[i + 0] & 0xff;
|
||||
b = src[i + 1] & 0xff;
|
||||
dst[k + 0] = table[a >> 2];
|
||||
dst[k + 1] = table[((a & 3) << 4) | (b >> 4)];
|
||||
dst[k + 2] = table[(b & 0x0f) << 2];
|
||||
dst[k + 3] = '=';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return dlen;
|
||||
}
|
||||
|
||||
|
||||
static size_t hex_encode(const char* src, size_t slen, char* dst, size_t dlen) {
|
||||
// We know how much we'll write, just make sure that there's space.
|
||||
assert(dlen >= slen * 2 &&
|
||||
"not enough space provided for hex encode");
|
||||
|
||||
dlen = slen * 2;
|
||||
for (uint32_t i = 0, k = 0; k < dlen; i += 1, k += 2) {
|
||||
static const char hex[] = "0123456789abcdef";
|
||||
uint8_t val = static_cast<uint8_t>(src[i]);
|
||||
dst[k + 0] = hex[val >> 4];
|
||||
dst[k + 1] = hex[val & 15];
|
||||
}
|
||||
|
||||
return dlen;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static Local<Value> Encode(const char* buf,
|
||||
size_t buflen,
|
||||
enum Encoding encoding) {
|
||||
assert(buflen <= node::Buffer::kMaxLength);
|
||||
if (!buflen && encoding != BUFFER)
|
||||
return New("").ToLocalChecked();
|
||||
|
||||
Local<String> val;
|
||||
switch (encoding) {
|
||||
case BUFFER:
|
||||
return CopyBuffer(buf, buflen).ToLocalChecked();
|
||||
|
||||
case ASCII:
|
||||
if (contains_non_ascii(buf, buflen)) {
|
||||
char* out = new char[buflen];
|
||||
force_ascii(buf, out, buflen);
|
||||
val = New<String>(out, buflen).ToLocalChecked();
|
||||
delete[] out;
|
||||
} else {
|
||||
val = New<String>(buf, buflen).ToLocalChecked();
|
||||
}
|
||||
break;
|
||||
|
||||
case UTF8:
|
||||
val = New<String>(buf, buflen).ToLocalChecked();
|
||||
break;
|
||||
|
||||
case BINARY: {
|
||||
// TODO(isaacs) use ExternalTwoByteString?
|
||||
const unsigned char *cbuf = reinterpret_cast<const unsigned char*>(buf);
|
||||
uint16_t * twobytebuf = new uint16_t[buflen];
|
||||
for (size_t i = 0; i < buflen; i++) {
|
||||
// XXX is the following line platform independent?
|
||||
twobytebuf[i] = cbuf[i];
|
||||
}
|
||||
val = New<String>(twobytebuf, buflen).ToLocalChecked();
|
||||
delete[] twobytebuf;
|
||||
break;
|
||||
}
|
||||
|
||||
case BASE64: {
|
||||
size_t dlen = base64_encoded_size(buflen);
|
||||
char* dst = new char[dlen];
|
||||
|
||||
size_t written = base64_encode(buf, buflen, dst, dlen);
|
||||
assert(written == dlen);
|
||||
|
||||
val = New<String>(dst, dlen).ToLocalChecked();
|
||||
delete[] dst;
|
||||
break;
|
||||
}
|
||||
|
||||
case UCS2: {
|
||||
const uint16_t* data = reinterpret_cast<const uint16_t*>(buf);
|
||||
val = New<String>(data, buflen / 2).ToLocalChecked();
|
||||
break;
|
||||
}
|
||||
|
||||
case HEX: {
|
||||
size_t dlen = buflen * 2;
|
||||
char* dst = new char[dlen];
|
||||
size_t written = hex_encode(buf, buflen, dst, dlen);
|
||||
assert(written == dlen);
|
||||
|
||||
val = New<String>(dst, dlen).ToLocalChecked();
|
||||
delete[] dst;
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
assert(0 && "unknown encoding");
|
||||
break;
|
||||
}
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
#undef base64_encoded_size
|
||||
|
||||
} // end of namespace imp
|
||||
|
||||
#endif // NAN_STRING_BYTES_H_
|
||||
90
node_modules/nan/nan_typedarray_contents.h
generated
vendored
Normal file
90
node_modules/nan/nan_typedarray_contents.h
generated
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
/*********************************************************************
|
||||
* NAN - Native Abstractions for Node.js
|
||||
*
|
||||
* Copyright (c) 2018 NAN contributors
|
||||
*
|
||||
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
|
||||
********************************************************************/
|
||||
|
||||
#ifndef NAN_TYPEDARRAY_CONTENTS_H_
|
||||
#define NAN_TYPEDARRAY_CONTENTS_H_
|
||||
|
||||
template<typename T>
|
||||
class TypedArrayContents {
|
||||
public:
|
||||
inline explicit TypedArrayContents(v8::Local<v8::Value> from) :
|
||||
length_(0), data_(NULL) {
|
||||
HandleScope scope;
|
||||
|
||||
size_t length = 0;
|
||||
void* data = NULL;
|
||||
|
||||
#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 4 || \
|
||||
(V8_MAJOR_VERSION == 4 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION >= 3))
|
||||
|
||||
if (from->IsArrayBufferView()) {
|
||||
v8::Local<v8::ArrayBufferView> array =
|
||||
v8::Local<v8::ArrayBufferView>::Cast(from);
|
||||
|
||||
const size_t byte_length = array->ByteLength();
|
||||
const ptrdiff_t byte_offset = array->ByteOffset();
|
||||
v8::Local<v8::ArrayBuffer> buffer = array->Buffer();
|
||||
|
||||
length = byte_length / sizeof(T);
|
||||
data = static_cast<char*>(buffer->GetContents().Data()) + byte_offset;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
if (from->IsObject() && !from->IsNull()) {
|
||||
v8::Local<v8::Object> array = v8::Local<v8::Object>::Cast(from);
|
||||
|
||||
MaybeLocal<v8::Value> buffer = Get(array,
|
||||
New<v8::String>("buffer").ToLocalChecked());
|
||||
MaybeLocal<v8::Value> byte_length = Get(array,
|
||||
New<v8::String>("byteLength").ToLocalChecked());
|
||||
MaybeLocal<v8::Value> byte_offset = Get(array,
|
||||
New<v8::String>("byteOffset").ToLocalChecked());
|
||||
|
||||
if (!buffer.IsEmpty() &&
|
||||
!byte_length.IsEmpty() && byte_length.ToLocalChecked()->IsUint32() &&
|
||||
!byte_offset.IsEmpty() && byte_offset.ToLocalChecked()->IsUint32()) {
|
||||
data = array->GetIndexedPropertiesExternalArrayData();
|
||||
if(data) {
|
||||
length = byte_length.ToLocalChecked()->Uint32Value() / sizeof(T);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER >= 1900 || __cplusplus >= 201103L
|
||||
assert(reinterpret_cast<uintptr_t>(data) % alignof (T) == 0);
|
||||
#elif defined(_MSC_VER) && _MSC_VER >= 1600 || defined(__GNUC__)
|
||||
assert(reinterpret_cast<uintptr_t>(data) % __alignof(T) == 0);
|
||||
#else
|
||||
assert(reinterpret_cast<uintptr_t>(data) % sizeof (T) == 0);
|
||||
#endif
|
||||
|
||||
length_ = length;
|
||||
data_ = static_cast<T*>(data);
|
||||
}
|
||||
|
||||
inline size_t length() const { return length_; }
|
||||
inline T* operator*() { return data_; }
|
||||
inline const T* operator*() const { return data_; }
|
||||
|
||||
private:
|
||||
NAN_DISALLOW_ASSIGN_COPY_MOVE(TypedArrayContents)
|
||||
|
||||
//Disable heap allocation
|
||||
void *operator new(size_t size);
|
||||
void operator delete(void *, size_t) {
|
||||
abort();
|
||||
}
|
||||
|
||||
size_t length_;
|
||||
T* data_;
|
||||
};
|
||||
|
||||
#endif // NAN_TYPEDARRAY_CONTENTS_H_
|
||||
432
node_modules/nan/nan_weak.h
generated
vendored
Normal file
432
node_modules/nan/nan_weak.h
generated
vendored
Normal file
@@ -0,0 +1,432 @@
|
||||
/*********************************************************************
|
||||
* NAN - Native Abstractions for Node.js
|
||||
*
|
||||
* Copyright (c) 2018 NAN contributors
|
||||
*
|
||||
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
|
||||
********************************************************************/
|
||||
|
||||
#ifndef NAN_WEAK_H_
|
||||
#define NAN_WEAK_H_
|
||||
|
||||
static const int kInternalFieldsInWeakCallback = 2;
|
||||
static const int kNoInternalFieldIndex = -1;
|
||||
|
||||
#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 4 || \
|
||||
(V8_MAJOR_VERSION == 4 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION >= 3))
|
||||
# define NAN_WEAK_PARAMETER_CALLBACK_DATA_TYPE_ \
|
||||
v8::WeakCallbackInfo<WeakCallbackInfo<T> > const&
|
||||
# define NAN_WEAK_TWOFIELD_CALLBACK_DATA_TYPE_ \
|
||||
NAN_WEAK_PARAMETER_CALLBACK_DATA_TYPE_
|
||||
# define NAN_WEAK_PARAMETER_CALLBACK_SIG_ NAN_WEAK_PARAMETER_CALLBACK_DATA_TYPE_
|
||||
# define NAN_WEAK_TWOFIELD_CALLBACK_SIG_ NAN_WEAK_TWOFIELD_CALLBACK_DATA_TYPE_
|
||||
#elif NODE_MODULE_VERSION > IOJS_1_1_MODULE_VERSION
|
||||
# define NAN_WEAK_PARAMETER_CALLBACK_DATA_TYPE_ \
|
||||
v8::PhantomCallbackData<WeakCallbackInfo<T> > const&
|
||||
# define NAN_WEAK_TWOFIELD_CALLBACK_DATA_TYPE_ \
|
||||
NAN_WEAK_PARAMETER_CALLBACK_DATA_TYPE_
|
||||
# define NAN_WEAK_PARAMETER_CALLBACK_SIG_ NAN_WEAK_PARAMETER_CALLBACK_DATA_TYPE_
|
||||
# define NAN_WEAK_TWOFIELD_CALLBACK_SIG_ NAN_WEAK_TWOFIELD_CALLBACK_DATA_TYPE_
|
||||
#elif NODE_MODULE_VERSION > NODE_0_12_MODULE_VERSION
|
||||
# define NAN_WEAK_PARAMETER_CALLBACK_DATA_TYPE_ \
|
||||
v8::PhantomCallbackData<WeakCallbackInfo<T> > const&
|
||||
# define NAN_WEAK_TWOFIELD_CALLBACK_DATA_TYPE_ \
|
||||
v8::InternalFieldsCallbackData<WeakCallbackInfo<T>, void> const&
|
||||
# define NAN_WEAK_PARAMETER_CALLBACK_SIG_ NAN_WEAK_PARAMETER_CALLBACK_DATA_TYPE_
|
||||
# define NAN_WEAK_TWOFIELD_CALLBACK_SIG_ NAN_WEAK_TWOFIELD_CALLBACK_DATA_TYPE_
|
||||
#elif NODE_MODULE_VERSION > NODE_0_10_MODULE_VERSION
|
||||
# define NAN_WEAK_CALLBACK_DATA_TYPE_ \
|
||||
v8::WeakCallbackData<S, WeakCallbackInfo<T> > const&
|
||||
# define NAN_WEAK_CALLBACK_SIG_ NAN_WEAK_CALLBACK_DATA_TYPE_
|
||||
#else
|
||||
# define NAN_WEAK_CALLBACK_DATA_TYPE_ void *
|
||||
# define NAN_WEAK_CALLBACK_SIG_ \
|
||||
v8::Persistent<v8::Value>, NAN_WEAK_CALLBACK_DATA_TYPE_
|
||||
#endif
|
||||
|
||||
template<typename T>
|
||||
class WeakCallbackInfo {
|
||||
public:
|
||||
typedef void (*Callback)(const WeakCallbackInfo<T>& data);
|
||||
WeakCallbackInfo(
|
||||
Persistent<v8::Value> *persistent
|
||||
, Callback callback
|
||||
, void *parameter
|
||||
, void *field1 = 0
|
||||
, void *field2 = 0) :
|
||||
callback_(callback), isolate_(0), parameter_(parameter) {
|
||||
std::memcpy(&persistent_, persistent, sizeof (v8::Persistent<v8::Value>));
|
||||
internal_fields_[0] = field1;
|
||||
internal_fields_[1] = field2;
|
||||
}
|
||||
inline v8::Isolate *GetIsolate() const { return isolate_; }
|
||||
inline T *GetParameter() const { return static_cast<T*>(parameter_); }
|
||||
inline void *GetInternalField(int index) const {
|
||||
assert((index == 0 || index == 1) && "internal field index out of bounds");
|
||||
if (index == 0) {
|
||||
return internal_fields_[0];
|
||||
} else {
|
||||
return internal_fields_[1];
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
NAN_DISALLOW_ASSIGN_COPY_MOVE(WeakCallbackInfo)
|
||||
Callback callback_;
|
||||
v8::Isolate *isolate_;
|
||||
void *parameter_;
|
||||
void *internal_fields_[kInternalFieldsInWeakCallback];
|
||||
v8::Persistent<v8::Value> persistent_;
|
||||
template<typename S, typename M> friend class Persistent;
|
||||
template<typename S> friend class PersistentBase;
|
||||
#if NODE_MODULE_VERSION <= NODE_0_12_MODULE_VERSION
|
||||
# if NODE_MODULE_VERSION > NODE_0_10_MODULE_VERSION
|
||||
template<typename S>
|
||||
static void invoke(NAN_WEAK_CALLBACK_SIG_ data);
|
||||
template<typename S>
|
||||
static WeakCallbackInfo *unwrap(NAN_WEAK_CALLBACK_DATA_TYPE_ data);
|
||||
# else
|
||||
static void invoke(NAN_WEAK_CALLBACK_SIG_ data);
|
||||
static WeakCallbackInfo *unwrap(NAN_WEAK_CALLBACK_DATA_TYPE_ data);
|
||||
# endif
|
||||
#else
|
||||
# if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 4 || \
|
||||
(V8_MAJOR_VERSION == 4 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION >= 3))
|
||||
template<bool isFirstPass>
|
||||
static void invokeparameter(NAN_WEAK_PARAMETER_CALLBACK_SIG_ data);
|
||||
template<bool isFirstPass>
|
||||
static void invoketwofield(NAN_WEAK_TWOFIELD_CALLBACK_SIG_ data);
|
||||
# else
|
||||
static void invokeparameter(NAN_WEAK_PARAMETER_CALLBACK_SIG_ data);
|
||||
static void invoketwofield(NAN_WEAK_TWOFIELD_CALLBACK_SIG_ data);
|
||||
# endif
|
||||
static WeakCallbackInfo *unwrapparameter(
|
||||
NAN_WEAK_PARAMETER_CALLBACK_DATA_TYPE_ data);
|
||||
static WeakCallbackInfo *unwraptwofield(
|
||||
NAN_WEAK_TWOFIELD_CALLBACK_DATA_TYPE_ data);
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 4 || \
|
||||
(V8_MAJOR_VERSION == 4 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION >= 3))
|
||||
|
||||
template<typename T>
|
||||
template<bool isFirstPass>
|
||||
void
|
||||
WeakCallbackInfo<T>::invokeparameter(NAN_WEAK_PARAMETER_CALLBACK_SIG_ data) {
|
||||
WeakCallbackInfo<T> *cbinfo = unwrapparameter(data);
|
||||
if (isFirstPass) {
|
||||
cbinfo->persistent_.Reset();
|
||||
data.SetSecondPassCallback(invokeparameter<false>);
|
||||
} else {
|
||||
cbinfo->callback_(*cbinfo);
|
||||
delete cbinfo;
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
template<bool isFirstPass>
|
||||
void
|
||||
WeakCallbackInfo<T>::invoketwofield(NAN_WEAK_TWOFIELD_CALLBACK_SIG_ data) {
|
||||
WeakCallbackInfo<T> *cbinfo = unwraptwofield(data);
|
||||
if (isFirstPass) {
|
||||
cbinfo->persistent_.Reset();
|
||||
data.SetSecondPassCallback(invoketwofield<false>);
|
||||
} else {
|
||||
cbinfo->callback_(*cbinfo);
|
||||
delete cbinfo;
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
WeakCallbackInfo<T> *WeakCallbackInfo<T>::unwrapparameter(
|
||||
NAN_WEAK_PARAMETER_CALLBACK_DATA_TYPE_ data) {
|
||||
WeakCallbackInfo<T> *cbinfo =
|
||||
static_cast<WeakCallbackInfo<T>*>(data.GetParameter());
|
||||
cbinfo->isolate_ = data.GetIsolate();
|
||||
return cbinfo;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
WeakCallbackInfo<T> *WeakCallbackInfo<T>::unwraptwofield(
|
||||
NAN_WEAK_TWOFIELD_CALLBACK_DATA_TYPE_ data) {
|
||||
WeakCallbackInfo<T> *cbinfo =
|
||||
static_cast<WeakCallbackInfo<T>*>(data.GetInternalField(0));
|
||||
cbinfo->isolate_ = data.GetIsolate();
|
||||
return cbinfo;
|
||||
}
|
||||
|
||||
#undef NAN_WEAK_PARAMETER_CALLBACK_SIG_
|
||||
#undef NAN_WEAK_TWOFIELD_CALLBACK_SIG_
|
||||
#undef NAN_WEAK_PARAMETER_CALLBACK_DATA_TYPE_
|
||||
#undef NAN_WEAK_TWOFIELD_CALLBACK_DATA_TYPE_
|
||||
# elif NODE_MODULE_VERSION > NODE_0_12_MODULE_VERSION
|
||||
|
||||
template<typename T>
|
||||
void
|
||||
WeakCallbackInfo<T>::invokeparameter(NAN_WEAK_PARAMETER_CALLBACK_SIG_ data) {
|
||||
WeakCallbackInfo<T> *cbinfo = unwrapparameter(data);
|
||||
cbinfo->persistent_.Reset();
|
||||
cbinfo->callback_(*cbinfo);
|
||||
delete cbinfo;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void
|
||||
WeakCallbackInfo<T>::invoketwofield(NAN_WEAK_TWOFIELD_CALLBACK_SIG_ data) {
|
||||
WeakCallbackInfo<T> *cbinfo = unwraptwofield(data);
|
||||
cbinfo->persistent_.Reset();
|
||||
cbinfo->callback_(*cbinfo);
|
||||
delete cbinfo;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
WeakCallbackInfo<T> *WeakCallbackInfo<T>::unwrapparameter(
|
||||
NAN_WEAK_PARAMETER_CALLBACK_DATA_TYPE_ data) {
|
||||
WeakCallbackInfo<T> *cbinfo =
|
||||
static_cast<WeakCallbackInfo<T>*>(data.GetParameter());
|
||||
cbinfo->isolate_ = data.GetIsolate();
|
||||
return cbinfo;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
WeakCallbackInfo<T> *WeakCallbackInfo<T>::unwraptwofield(
|
||||
NAN_WEAK_TWOFIELD_CALLBACK_DATA_TYPE_ data) {
|
||||
WeakCallbackInfo<T> *cbinfo =
|
||||
static_cast<WeakCallbackInfo<T>*>(data.GetInternalField1());
|
||||
cbinfo->isolate_ = data.GetIsolate();
|
||||
return cbinfo;
|
||||
}
|
||||
|
||||
#undef NAN_WEAK_PARAMETER_CALLBACK_SIG_
|
||||
#undef NAN_WEAK_TWOFIELD_CALLBACK_SIG_
|
||||
#undef NAN_WEAK_PARAMETER_CALLBACK_DATA_TYPE_
|
||||
#undef NAN_WEAK_TWOFIELD_CALLBACK_DATA_TYPE_
|
||||
#elif NODE_MODULE_VERSION > NODE_0_10_MODULE_VERSION
|
||||
|
||||
template<typename T>
|
||||
template<typename S>
|
||||
void WeakCallbackInfo<T>::invoke(NAN_WEAK_CALLBACK_SIG_ data) {
|
||||
WeakCallbackInfo<T> *cbinfo = unwrap(data);
|
||||
cbinfo->persistent_.Reset();
|
||||
cbinfo->callback_(*cbinfo);
|
||||
delete cbinfo;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
template<typename S>
|
||||
WeakCallbackInfo<T> *WeakCallbackInfo<T>::unwrap(
|
||||
NAN_WEAK_CALLBACK_DATA_TYPE_ data) {
|
||||
void *parameter = data.GetParameter();
|
||||
WeakCallbackInfo<T> *cbinfo =
|
||||
static_cast<WeakCallbackInfo<T>*>(parameter);
|
||||
cbinfo->isolate_ = data.GetIsolate();
|
||||
return cbinfo;
|
||||
}
|
||||
|
||||
#undef NAN_WEAK_CALLBACK_SIG_
|
||||
#undef NAN_WEAK_CALLBACK_DATA_TYPE_
|
||||
#else
|
||||
|
||||
template<typename T>
|
||||
void WeakCallbackInfo<T>::invoke(NAN_WEAK_CALLBACK_SIG_ data) {
|
||||
WeakCallbackInfo<T> *cbinfo = unwrap(data);
|
||||
cbinfo->persistent_.Dispose();
|
||||
cbinfo->persistent_.Clear();
|
||||
cbinfo->callback_(*cbinfo);
|
||||
delete cbinfo;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
WeakCallbackInfo<T> *WeakCallbackInfo<T>::unwrap(
|
||||
NAN_WEAK_CALLBACK_DATA_TYPE_ data) {
|
||||
WeakCallbackInfo<T> *cbinfo =
|
||||
static_cast<WeakCallbackInfo<T>*>(data);
|
||||
cbinfo->isolate_ = v8::Isolate::GetCurrent();
|
||||
return cbinfo;
|
||||
}
|
||||
|
||||
#undef NAN_WEAK_CALLBACK_SIG_
|
||||
#undef NAN_WEAK_CALLBACK_DATA_TYPE_
|
||||
#endif
|
||||
|
||||
#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 4 || \
|
||||
(V8_MAJOR_VERSION == 4 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION >= 3))
|
||||
template<typename T, typename M>
|
||||
template<typename P>
|
||||
inline void Persistent<T, M>::SetWeak(
|
||||
P *parameter
|
||||
, typename WeakCallbackInfo<P>::Callback callback
|
||||
, WeakCallbackType type) {
|
||||
WeakCallbackInfo<P> *wcbd;
|
||||
if (type == WeakCallbackType::kParameter) {
|
||||
wcbd = new WeakCallbackInfo<P>(
|
||||
reinterpret_cast<Persistent<v8::Value>*>(this)
|
||||
, callback
|
||||
, parameter);
|
||||
v8::PersistentBase<T>::SetWeak(
|
||||
wcbd
|
||||
, WeakCallbackInfo<P>::template invokeparameter<true>
|
||||
, type);
|
||||
} else {
|
||||
v8::Local<T>* self = reinterpret_cast<v8::Local<T>*>(this);
|
||||
assert((*self)->IsObject());
|
||||
int count = (*self)->InternalFieldCount();
|
||||
void *internal_fields[kInternalFieldsInWeakCallback] = {0, 0};
|
||||
for (int i = 0; i < count && i < kInternalFieldsInWeakCallback; i++) {
|
||||
internal_fields[i] = (*self)->GetAlignedPointerFromInternalField(i);
|
||||
}
|
||||
wcbd = new WeakCallbackInfo<P>(
|
||||
reinterpret_cast<Persistent<v8::Value>*>(this)
|
||||
, callback
|
||||
, 0
|
||||
, internal_fields[0]
|
||||
, internal_fields[1]);
|
||||
(*self)->SetAlignedPointerInInternalField(0, wcbd);
|
||||
v8::PersistentBase<T>::SetWeak(
|
||||
static_cast<WeakCallbackInfo<P>*>(0)
|
||||
, WeakCallbackInfo<P>::template invoketwofield<true>
|
||||
, type);
|
||||
}
|
||||
}
|
||||
#elif NODE_MODULE_VERSION > IOJS_1_1_MODULE_VERSION
|
||||
template<typename T, typename M>
|
||||
template<typename P>
|
||||
inline void Persistent<T, M>::SetWeak(
|
||||
P *parameter
|
||||
, typename WeakCallbackInfo<P>::Callback callback
|
||||
, WeakCallbackType type) {
|
||||
WeakCallbackInfo<P> *wcbd;
|
||||
if (type == WeakCallbackType::kParameter) {
|
||||
wcbd = new WeakCallbackInfo<P>(
|
||||
reinterpret_cast<Persistent<v8::Value>*>(this)
|
||||
, callback
|
||||
, parameter);
|
||||
v8::PersistentBase<T>::SetPhantom(
|
||||
wcbd
|
||||
, WeakCallbackInfo<P>::invokeparameter);
|
||||
} else {
|
||||
v8::Local<T>* self = reinterpret_cast<v8::Local<T>*>(this);
|
||||
assert((*self)->IsObject());
|
||||
int count = (*self)->InternalFieldCount();
|
||||
void *internal_fields[kInternalFieldsInWeakCallback] = {0, 0};
|
||||
for (int i = 0; i < count && i < kInternalFieldsInWeakCallback; i++) {
|
||||
internal_fields[i] = (*self)->GetAlignedPointerFromInternalField(i);
|
||||
}
|
||||
wcbd = new WeakCallbackInfo<P>(
|
||||
reinterpret_cast<Persistent<v8::Value>*>(this)
|
||||
, callback
|
||||
, 0
|
||||
, internal_fields[0]
|
||||
, internal_fields[1]);
|
||||
(*self)->SetAlignedPointerInInternalField(0, wcbd);
|
||||
v8::PersistentBase<T>::SetPhantom(
|
||||
static_cast<WeakCallbackInfo<P>*>(0)
|
||||
, WeakCallbackInfo<P>::invoketwofield
|
||||
, 0
|
||||
, count > 1 ? 1 : kNoInternalFieldIndex);
|
||||
}
|
||||
}
|
||||
#elif NODE_MODULE_VERSION > NODE_0_12_MODULE_VERSION
|
||||
template<typename T, typename M>
|
||||
template<typename P>
|
||||
inline void Persistent<T, M>::SetWeak(
|
||||
P *parameter
|
||||
, typename WeakCallbackInfo<P>::Callback callback
|
||||
, WeakCallbackType type) {
|
||||
WeakCallbackInfo<P> *wcbd;
|
||||
if (type == WeakCallbackType::kParameter) {
|
||||
wcbd = new WeakCallbackInfo<P>(
|
||||
reinterpret_cast<Persistent<v8::Value>*>(this)
|
||||
, callback
|
||||
, parameter);
|
||||
v8::PersistentBase<T>::SetPhantom(
|
||||
wcbd
|
||||
, WeakCallbackInfo<P>::invokeparameter);
|
||||
} else {
|
||||
v8::Local<T>* self = reinterpret_cast<v8::Local<T>*>(this);
|
||||
assert((*self)->IsObject());
|
||||
int count = (*self)->InternalFieldCount();
|
||||
void *internal_fields[kInternalFieldsInWeakCallback] = {0, 0};
|
||||
for (int i = 0; i < count && i < kInternalFieldsInWeakCallback; i++) {
|
||||
internal_fields[i] = (*self)->GetAlignedPointerFromInternalField(i);
|
||||
}
|
||||
wcbd = new WeakCallbackInfo<P>(
|
||||
reinterpret_cast<Persistent<v8::Value>*>(this)
|
||||
, callback
|
||||
, 0
|
||||
, internal_fields[0]
|
||||
, internal_fields[1]);
|
||||
(*self)->SetAlignedPointerInInternalField(0, wcbd);
|
||||
v8::PersistentBase<T>::SetPhantom(
|
||||
WeakCallbackInfo<P>::invoketwofield
|
||||
, 0
|
||||
, count > 1 ? 1 : kNoInternalFieldIndex);
|
||||
}
|
||||
}
|
||||
#elif NODE_MODULE_VERSION > NODE_0_10_MODULE_VERSION
|
||||
template<typename T, typename M>
|
||||
template<typename P>
|
||||
inline void Persistent<T, M>::SetWeak(
|
||||
P *parameter
|
||||
, typename WeakCallbackInfo<P>::Callback callback
|
||||
, WeakCallbackType type) {
|
||||
WeakCallbackInfo<P> *wcbd;
|
||||
if (type == WeakCallbackType::kParameter) {
|
||||
wcbd = new WeakCallbackInfo<P>(
|
||||
reinterpret_cast<Persistent<v8::Value>*>(this)
|
||||
, callback
|
||||
, parameter);
|
||||
v8::PersistentBase<T>::SetWeak(wcbd, WeakCallbackInfo<P>::invoke);
|
||||
} else {
|
||||
v8::Local<T>* self = reinterpret_cast<v8::Local<T>*>(this);
|
||||
assert((*self)->IsObject());
|
||||
int count = (*self)->InternalFieldCount();
|
||||
void *internal_fields[kInternalFieldsInWeakCallback] = {0, 0};
|
||||
for (int i = 0; i < count && i < kInternalFieldsInWeakCallback; i++) {
|
||||
internal_fields[i] = (*self)->GetAlignedPointerFromInternalField(i);
|
||||
}
|
||||
wcbd = new WeakCallbackInfo<P>(
|
||||
reinterpret_cast<Persistent<v8::Value>*>(this)
|
||||
, callback
|
||||
, 0
|
||||
, internal_fields[0]
|
||||
, internal_fields[1]);
|
||||
v8::PersistentBase<T>::SetWeak(wcbd, WeakCallbackInfo<P>::invoke);
|
||||
}
|
||||
}
|
||||
#else
|
||||
template<typename T>
|
||||
template<typename P>
|
||||
inline void PersistentBase<T>::SetWeak(
|
||||
P *parameter
|
||||
, typename WeakCallbackInfo<P>::Callback callback
|
||||
, WeakCallbackType type) {
|
||||
WeakCallbackInfo<P> *wcbd;
|
||||
if (type == WeakCallbackType::kParameter) {
|
||||
wcbd = new WeakCallbackInfo<P>(
|
||||
reinterpret_cast<Persistent<v8::Value>*>(this)
|
||||
, callback
|
||||
, parameter);
|
||||
persistent.MakeWeak(wcbd, WeakCallbackInfo<P>::invoke);
|
||||
} else {
|
||||
v8::Local<T>* self = reinterpret_cast<v8::Local<T>*>(this);
|
||||
assert((*self)->IsObject());
|
||||
int count = (*self)->InternalFieldCount();
|
||||
void *internal_fields[kInternalFieldsInWeakCallback] = {0, 0};
|
||||
for (int i = 0; i < count && i < kInternalFieldsInWeakCallback; i++) {
|
||||
internal_fields[i] = (*self)->GetPointerFromInternalField(i);
|
||||
}
|
||||
wcbd = new WeakCallbackInfo<P>(
|
||||
reinterpret_cast<Persistent<v8::Value>*>(this)
|
||||
, callback
|
||||
, 0
|
||||
, internal_fields[0]
|
||||
, internal_fields[1]);
|
||||
persistent.MakeWeak(wcbd, WeakCallbackInfo<P>::invoke);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // NAN_WEAK_H_
|
||||
21
node_modules/nan/package.json
generated
vendored
Normal file
21
node_modules/nan/package.json
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"name": "nan",
|
||||
"version": "2.11.0",
|
||||
"description": "Native Abstractions for Node.js: C++ header for Node 0.8 -> 9 compatibility",
|
||||
"main": "include_dirs.js",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/nodejs/nan.git"
|
||||
},
|
||||
"devDependencies": {
|
||||
"bindings": "~1.2.1",
|
||||
"commander": "^2.8.1",
|
||||
"glob": "^5.0.14",
|
||||
"request": "=2.81.0",
|
||||
"node-gyp": "~3.6.2",
|
||||
"readable-stream": "^2.1.4",
|
||||
"tap": "~0.7.1",
|
||||
"xtend": "~4.0.0"
|
||||
},
|
||||
"license": "MIT"
|
||||
}
|
||||
412
node_modules/nan/tools/1to2.js
generated
vendored
Executable file
412
node_modules/nan/tools/1to2.js
generated
vendored
Executable file
@@ -0,0 +1,412 @@
|
||||
#!/usr/bin/env node
|
||||
/*********************************************************************
|
||||
* NAN - Native Abstractions for Node.js
|
||||
*
|
||||
* Copyright (c) 2018 NAN contributors
|
||||
*
|
||||
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
|
||||
********************************************************************/
|
||||
|
||||
var commander = require('commander'),
|
||||
fs = require('fs'),
|
||||
glob = require('glob'),
|
||||
groups = [],
|
||||
total = 0,
|
||||
warning1 = '/* ERROR: Rewrite using Buffer */\n',
|
||||
warning2 = '\\/\\* ERROR\\: Rewrite using Buffer \\*\\/\\n',
|
||||
length,
|
||||
i;
|
||||
|
||||
fs.readFile(__dirname + '/package.json', 'utf8', function (err, data) {
|
||||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
|
||||
commander
|
||||
.version(JSON.parse(data).version)
|
||||
.usage('[options] <file ...>')
|
||||
.parse(process.argv);
|
||||
|
||||
if (!process.argv.slice(2).length) {
|
||||
commander.outputHelp();
|
||||
}
|
||||
});
|
||||
|
||||
/* construct strings representing regular expressions
|
||||
each expression contains a unique group allowing for identification of the match
|
||||
the index of this key group, relative to the regular expression in question,
|
||||
is indicated by the first array member */
|
||||
|
||||
/* simple substistutions, key group is the entire match, 0 */
|
||||
groups.push([0, [
|
||||
'_NAN_',
|
||||
'NODE_SET_METHOD',
|
||||
'NODE_SET_PROTOTYPE_METHOD',
|
||||
'NanAsciiString',
|
||||
'NanEscapeScope',
|
||||
'NanReturnValue',
|
||||
'NanUcs2String'].join('|')]);
|
||||
|
||||
/* substitutions of parameterless macros, key group is 1 */
|
||||
groups.push([1, ['(', [
|
||||
'NanEscapableScope',
|
||||
'NanReturnNull',
|
||||
'NanReturnUndefined',
|
||||
'NanScope'].join('|'), ')\\(\\)'].join('')]);
|
||||
|
||||
/* replace TryCatch with NanTryCatch once, gobbling possible namespace, key group 2 */
|
||||
groups.push([2, '(?:(?:v8\\:\\:)?|(Nan)?)(TryCatch)']);
|
||||
|
||||
/* NanNew("string") will likely not fail a ToLocalChecked(), key group 1 */
|
||||
groups.push([1, ['(NanNew)', '(\\("[^\\"]*"[^\\)]*\\))(?!\\.ToLocalChecked\\(\\))'].join('')]);
|
||||
|
||||
/* Removed v8 APIs, warn that the code needs rewriting using node::Buffer, key group 2 */
|
||||
groups.push([2, ['(', warning2, ')?', '^.*?(', [
|
||||
'GetIndexedPropertiesExternalArrayDataLength',
|
||||
'GetIndexedPropertiesExternalArrayData',
|
||||
'GetIndexedPropertiesExternalArrayDataType',
|
||||
'GetIndexedPropertiesPixelData',
|
||||
'GetIndexedPropertiesPixelDataLength',
|
||||
'HasIndexedPropertiesInExternalArrayData',
|
||||
'HasIndexedPropertiesInPixelData',
|
||||
'SetIndexedPropertiesToExternalArrayData',
|
||||
'SetIndexedPropertiesToPixelData'].join('|'), ')'].join('')]);
|
||||
|
||||
/* No need for NanScope in V8-exposed methods, key group 2 */
|
||||
groups.push([2, ['((', [
|
||||
'NAN_METHOD',
|
||||
'NAN_GETTER',
|
||||
'NAN_SETTER',
|
||||
'NAN_PROPERTY_GETTER',
|
||||
'NAN_PROPERTY_SETTER',
|
||||
'NAN_PROPERTY_ENUMERATOR',
|
||||
'NAN_PROPERTY_DELETER',
|
||||
'NAN_PROPERTY_QUERY',
|
||||
'NAN_INDEX_GETTER',
|
||||
'NAN_INDEX_SETTER',
|
||||
'NAN_INDEX_ENUMERATOR',
|
||||
'NAN_INDEX_DELETER',
|
||||
'NAN_INDEX_QUERY'].join('|'), ')\\([^\\)]*\\)\\s*\\{)\\s*NanScope\\(\\)\\s*;'].join('')]);
|
||||
|
||||
/* v8::Value::ToXXXXXXX returns v8::MaybeLocal<T>, key group 3 */
|
||||
groups.push([3, ['([\\s\\(\\)])([^\\s\\(\\)]+)->(', [
|
||||
'Boolean',
|
||||
'Number',
|
||||
'String',
|
||||
'Object',
|
||||
'Integer',
|
||||
'Uint32',
|
||||
'Int32'].join('|'), ')\\('].join('')]);
|
||||
|
||||
/* v8::Value::XXXXXXXValue returns v8::Maybe<T>, key group 3 */
|
||||
groups.push([3, ['([\\s\\(\\)])([^\\s\\(\\)]+)->((?:', [
|
||||
'Boolean',
|
||||
'Number',
|
||||
'Integer',
|
||||
'Uint32',
|
||||
'Int32'].join('|'), ')Value)\\('].join('')]);
|
||||
|
||||
/* NAN_WEAK_CALLBACK macro was removed, write out callback definition, key group 1 */
|
||||
groups.push([1, '(NAN_WEAK_CALLBACK)\\(([^\\s\\)]+)\\)']);
|
||||
|
||||
/* node::ObjectWrap and v8::Persistent have been replaced with Nan implementations, key group 1 */
|
||||
groups.push([1, ['(', [
|
||||
'NanDisposePersistent',
|
||||
'NanObjectWrapHandle'].join('|'), ')\\s*\\(\\s*([^\\s\\)]+)'].join('')]);
|
||||
|
||||
/* Since NanPersistent there is no need for NanMakeWeakPersistent, key group 1 */
|
||||
groups.push([1, '(NanMakeWeakPersistent)\\s*\\(\\s*([^\\s,]+)\\s*,\\s*']);
|
||||
|
||||
/* Many methods of v8::Object and others now return v8::MaybeLocal<T>, key group 3 */
|
||||
groups.push([3, ['([\\s])([^\\s]+)->(', [
|
||||
'GetEndColumn',
|
||||
'GetFunction',
|
||||
'GetLineNumber',
|
||||
'NewInstance',
|
||||
'GetPropertyNames',
|
||||
'GetOwnPropertyNames',
|
||||
'GetSourceLine',
|
||||
'GetStartColumn',
|
||||
'ObjectProtoToString',
|
||||
'ToArrayIndex',
|
||||
'ToDetailString',
|
||||
'CallAsConstructor',
|
||||
'CallAsFunction',
|
||||
'CloneElementAt',
|
||||
'Delete',
|
||||
'ForceSet',
|
||||
'Get',
|
||||
'GetPropertyAttributes',
|
||||
'GetRealNamedProperty',
|
||||
'GetRealNamedPropertyInPrototypeChain',
|
||||
'Has',
|
||||
'HasOwnProperty',
|
||||
'HasRealIndexedProperty',
|
||||
'HasRealNamedCallbackProperty',
|
||||
'HasRealNamedProperty',
|
||||
'Set',
|
||||
'SetAccessor',
|
||||
'SetIndexedPropertyHandler',
|
||||
'SetNamedPropertyHandler',
|
||||
'SetPrototype'].join('|'), ')\\('].join('')]);
|
||||
|
||||
/* You should get an error if any of these fail anyways,
|
||||
or handle the error better, it is indicated either way, key group 2 */
|
||||
groups.push([2, ['NanNew(<(?:v8\\:\\:)?(', ['Date', 'String', 'RegExp'].join('|'), ')>)(\\([^\\)]*\\))(?!\\.ToLocalChecked\\(\\))'].join('')]);
|
||||
|
||||
/* v8::Value::Equals now returns a v8::Maybe, key group 3 */
|
||||
groups.push([3, '([\\s\\(\\)])([^\\s\\(\\)]+)->(Equals)\\(([^\\s\\)]+)']);
|
||||
|
||||
/* NanPersistent makes this unnecessary, key group 1 */
|
||||
groups.push([1, '(NanAssignPersistent)(?:<v8\\:\\:[^>]+>)?\\(([^,]+),\\s*']);
|
||||
|
||||
/* args has been renamed to info, key group 2 */
|
||||
groups.push([2, '(\\W)(args)(\\W)'])
|
||||
|
||||
/* node::ObjectWrap was replaced with NanObjectWrap, key group 2 */
|
||||
groups.push([2, '(\\W)(?:node\\:\\:)?(ObjectWrap)(\\W)']);
|
||||
|
||||
/* v8::Persistent was replaced with NanPersistent, key group 2 */
|
||||
groups.push([2, '(\\W)(?:v8\\:\\:)?(Persistent)(\\W)']);
|
||||
|
||||
/* counts the number of capturing groups in a well-formed regular expression,
|
||||
ignoring non-capturing groups and escaped parentheses */
|
||||
function groupcount(s) {
|
||||
var positive = s.match(/\((?!\?)/g),
|
||||
negative = s.match(/\\\(/g);
|
||||
return (positive ? positive.length : 0) - (negative ? negative.length : 0);
|
||||
}
|
||||
|
||||
/* compute the absolute position of each key group in the joined master RegExp */
|
||||
for (i = 1, length = groups.length; i < length; i++) {
|
||||
total += groupcount(groups[i - 1][1]);
|
||||
groups[i][0] += total;
|
||||
}
|
||||
|
||||
/* create the master RegExp, whis is the union of all the groups' expressions */
|
||||
master = new RegExp(groups.map(function (a) { return a[1]; }).join('|'), 'gm');
|
||||
|
||||
/* replacement function for String.replace, receives 21 arguments */
|
||||
function replace() {
|
||||
/* simple expressions */
|
||||
switch (arguments[groups[0][0]]) {
|
||||
case '_NAN_':
|
||||
return 'NAN_';
|
||||
case 'NODE_SET_METHOD':
|
||||
return 'NanSetMethod';
|
||||
case 'NODE_SET_PROTOTYPE_METHOD':
|
||||
return 'NanSetPrototypeMethod';
|
||||
case 'NanAsciiString':
|
||||
return 'NanUtf8String';
|
||||
case 'NanEscapeScope':
|
||||
return 'scope.Escape';
|
||||
case 'NanReturnNull':
|
||||
return 'info.GetReturnValue().SetNull';
|
||||
case 'NanReturnValue':
|
||||
return 'info.GetReturnValue().Set';
|
||||
case 'NanUcs2String':
|
||||
return 'v8::String::Value';
|
||||
default:
|
||||
}
|
||||
|
||||
/* macros without arguments */
|
||||
switch (arguments[groups[1][0]]) {
|
||||
case 'NanEscapableScope':
|
||||
return 'NanEscapableScope scope'
|
||||
case 'NanReturnUndefined':
|
||||
return 'return';
|
||||
case 'NanScope':
|
||||
return 'NanScope scope';
|
||||
default:
|
||||
}
|
||||
|
||||
/* TryCatch, emulate negative backref */
|
||||
if (arguments[groups[2][0]] === 'TryCatch') {
|
||||
return arguments[groups[2][0] - 1] ? arguments[0] : 'NanTryCatch';
|
||||
}
|
||||
|
||||
/* NanNew("foo") --> NanNew("foo").ToLocalChecked() */
|
||||
if (arguments[groups[3][0]] === 'NanNew') {
|
||||
return [arguments[0], '.ToLocalChecked()'].join('');
|
||||
}
|
||||
|
||||
/* insert warning for removed functions as comment on new line above */
|
||||
switch (arguments[groups[4][0]]) {
|
||||
case 'GetIndexedPropertiesExternalArrayData':
|
||||
case 'GetIndexedPropertiesExternalArrayDataLength':
|
||||
case 'GetIndexedPropertiesExternalArrayDataType':
|
||||
case 'GetIndexedPropertiesPixelData':
|
||||
case 'GetIndexedPropertiesPixelDataLength':
|
||||
case 'HasIndexedPropertiesInExternalArrayData':
|
||||
case 'HasIndexedPropertiesInPixelData':
|
||||
case 'SetIndexedPropertiesToExternalArrayData':
|
||||
case 'SetIndexedPropertiesToPixelData':
|
||||
return arguments[groups[4][0] - 1] ? arguments[0] : [warning1, arguments[0]].join('');
|
||||
default:
|
||||
}
|
||||
|
||||
/* remove unnecessary NanScope() */
|
||||
switch (arguments[groups[5][0]]) {
|
||||
case 'NAN_GETTER':
|
||||
case 'NAN_METHOD':
|
||||
case 'NAN_SETTER':
|
||||
case 'NAN_INDEX_DELETER':
|
||||
case 'NAN_INDEX_ENUMERATOR':
|
||||
case 'NAN_INDEX_GETTER':
|
||||
case 'NAN_INDEX_QUERY':
|
||||
case 'NAN_INDEX_SETTER':
|
||||
case 'NAN_PROPERTY_DELETER':
|
||||
case 'NAN_PROPERTY_ENUMERATOR':
|
||||
case 'NAN_PROPERTY_GETTER':
|
||||
case 'NAN_PROPERTY_QUERY':
|
||||
case 'NAN_PROPERTY_SETTER':
|
||||
return arguments[groups[5][0] - 1];
|
||||
default:
|
||||
}
|
||||
|
||||
/* Value converstion */
|
||||
switch (arguments[groups[6][0]]) {
|
||||
case 'Boolean':
|
||||
case 'Int32':
|
||||
case 'Integer':
|
||||
case 'Number':
|
||||
case 'Object':
|
||||
case 'String':
|
||||
case 'Uint32':
|
||||
return [arguments[groups[6][0] - 2], 'NanTo<v8::', arguments[groups[6][0]], '>(', arguments[groups[6][0] - 1]].join('');
|
||||
default:
|
||||
}
|
||||
|
||||
/* other value conversion */
|
||||
switch (arguments[groups[7][0]]) {
|
||||
case 'BooleanValue':
|
||||
return [arguments[groups[7][0] - 2], 'NanTo<bool>(', arguments[groups[7][0] - 1]].join('');
|
||||
case 'Int32Value':
|
||||
return [arguments[groups[7][0] - 2], 'NanTo<int32_t>(', arguments[groups[7][0] - 1]].join('');
|
||||
case 'IntegerValue':
|
||||
return [arguments[groups[7][0] - 2], 'NanTo<int64_t>(', arguments[groups[7][0] - 1]].join('');
|
||||
case 'Uint32Value':
|
||||
return [arguments[groups[7][0] - 2], 'NanTo<uint32_t>(', arguments[groups[7][0] - 1]].join('');
|
||||
default:
|
||||
}
|
||||
|
||||
/* NAN_WEAK_CALLBACK */
|
||||
if (arguments[groups[8][0]] === 'NAN_WEAK_CALLBACK') {
|
||||
return ['template<typename T>\nvoid ',
|
||||
arguments[groups[8][0] + 1], '(const NanWeakCallbackInfo<T> &data)'].join('');
|
||||
}
|
||||
|
||||
/* use methods on NAN classes instead */
|
||||
switch (arguments[groups[9][0]]) {
|
||||
case 'NanDisposePersistent':
|
||||
return [arguments[groups[9][0] + 1], '.Reset('].join('');
|
||||
case 'NanObjectWrapHandle':
|
||||
return [arguments[groups[9][0] + 1], '->handle('].join('');
|
||||
default:
|
||||
}
|
||||
|
||||
/* use method on NanPersistent instead */
|
||||
if (arguments[groups[10][0]] === 'NanMakeWeakPersistent') {
|
||||
return arguments[groups[10][0] + 1] + '.SetWeak(';
|
||||
}
|
||||
|
||||
/* These return Maybes, the upper ones take no arguments */
|
||||
switch (arguments[groups[11][0]]) {
|
||||
case 'GetEndColumn':
|
||||
case 'GetFunction':
|
||||
case 'GetLineNumber':
|
||||
case 'GetOwnPropertyNames':
|
||||
case 'GetPropertyNames':
|
||||
case 'GetSourceLine':
|
||||
case 'GetStartColumn':
|
||||
case 'NewInstance':
|
||||
case 'ObjectProtoToString':
|
||||
case 'ToArrayIndex':
|
||||
case 'ToDetailString':
|
||||
return [arguments[groups[11][0] - 2], 'Nan', arguments[groups[11][0]], '(', arguments[groups[11][0] - 1]].join('');
|
||||
case 'CallAsConstructor':
|
||||
case 'CallAsFunction':
|
||||
case 'CloneElementAt':
|
||||
case 'Delete':
|
||||
case 'ForceSet':
|
||||
case 'Get':
|
||||
case 'GetPropertyAttributes':
|
||||
case 'GetRealNamedProperty':
|
||||
case 'GetRealNamedPropertyInPrototypeChain':
|
||||
case 'Has':
|
||||
case 'HasOwnProperty':
|
||||
case 'HasRealIndexedProperty':
|
||||
case 'HasRealNamedCallbackProperty':
|
||||
case 'HasRealNamedProperty':
|
||||
case 'Set':
|
||||
case 'SetAccessor':
|
||||
case 'SetIndexedPropertyHandler':
|
||||
case 'SetNamedPropertyHandler':
|
||||
case 'SetPrototype':
|
||||
return [arguments[groups[11][0] - 2], 'Nan', arguments[groups[11][0]], '(', arguments[groups[11][0] - 1], ', '].join('');
|
||||
default:
|
||||
}
|
||||
|
||||
/* Automatic ToLocalChecked(), take it or leave it */
|
||||
switch (arguments[groups[12][0]]) {
|
||||
case 'Date':
|
||||
case 'String':
|
||||
case 'RegExp':
|
||||
return ['NanNew', arguments[groups[12][0] - 1], arguments[groups[12][0] + 1], '.ToLocalChecked()'].join('');
|
||||
default:
|
||||
}
|
||||
|
||||
/* NanEquals is now required for uniformity */
|
||||
if (arguments[groups[13][0]] === 'Equals') {
|
||||
return [arguments[groups[13][0] - 1], 'NanEquals(', arguments[groups[13][0] - 1], ', ', arguments[groups[13][0] + 1]].join('');
|
||||
}
|
||||
|
||||
/* use method on replacement class instead */
|
||||
if (arguments[groups[14][0]] === 'NanAssignPersistent') {
|
||||
return [arguments[groups[14][0] + 1], '.Reset('].join('');
|
||||
}
|
||||
|
||||
/* args --> info */
|
||||
if (arguments[groups[15][0]] === 'args') {
|
||||
return [arguments[groups[15][0] - 1], 'info', arguments[groups[15][0] + 1]].join('');
|
||||
}
|
||||
|
||||
/* ObjectWrap --> NanObjectWrap */
|
||||
if (arguments[groups[16][0]] === 'ObjectWrap') {
|
||||
return [arguments[groups[16][0] - 1], 'NanObjectWrap', arguments[groups[16][0] + 1]].join('');
|
||||
}
|
||||
|
||||
/* Persistent --> NanPersistent */
|
||||
if (arguments[groups[17][0]] === 'Persistent') {
|
||||
return [arguments[groups[17][0] - 1], 'NanPersistent', arguments[groups[17][0] + 1]].join('');
|
||||
}
|
||||
|
||||
/* This should not happen. A switch is probably missing a case if it does. */
|
||||
throw 'Unhandled match: ' + arguments[0];
|
||||
}
|
||||
|
||||
/* reads a file, runs replacement and writes it back */
|
||||
function processFile(file) {
|
||||
fs.readFile(file, {encoding: 'utf8'}, function (err, data) {
|
||||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
|
||||
/* run replacement twice, might need more runs */
|
||||
fs.writeFile(file, data.replace(master, replace).replace(master, replace), function (err) {
|
||||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/* process file names from command line and process the identified files */
|
||||
for (i = 2, length = process.argv.length; i < length; i++) {
|
||||
glob(process.argv[i], function (err, matches) {
|
||||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
matches.forEach(processFile);
|
||||
});
|
||||
}
|
||||
15
node_modules/nan/tools/package.json
generated
vendored
Normal file
15
node_modules/nan/tools/package.json
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"name": "1to2",
|
||||
"version": "1.0.0",
|
||||
"description": "NAN 1 -> 2 Migration Script",
|
||||
"main": "1to2.js",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/nodejs/nan.git"
|
||||
},
|
||||
"dependencies": {
|
||||
"glob": "~5.0.10",
|
||||
"commander": "~2.8.1"
|
||||
},
|
||||
"license": "MIT"
|
||||
}
|
||||
Reference in New Issue
Block a user