package.nan_converters_43_inl.h Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of nan Show documentation
Show all versions of nan Show documentation
Native Abstractions for Node.js: C++ header for Node 0.8 -> 18 compatibility
/*********************************************************************
* NAN - Native Abstractions for Node.js
*
* Copyright (c) 2018 NAN contributors
*
* MIT License
********************************************************************/
#ifndef NAN_CONVERTERS_43_INL_H_
#define NAN_CONVERTERS_43_INL_H_
#define X(TYPE) \
imp::ToFactory::return_t \
imp::ToFactory::convert(v8::Local val) { \
v8::Isolate *isolate = v8::Isolate::GetCurrent(); \
v8::EscapableHandleScope scope(isolate); \
return scope.Escape( \
val->To ## TYPE(isolate->GetCurrentContext()) \
.FromMaybe(v8::Local())); \
}
X(Number)
X(String)
X(Object)
X(Integer)
X(Uint32)
X(Int32)
// V8 <= 7.0
#if V8_MAJOR_VERSION < 7 || (V8_MAJOR_VERSION == 7 && V8_MINOR_VERSION == 0)
X(Boolean)
#else
imp::ToFactory::return_t \
imp::ToFactory::convert(v8::Local val) { \
v8::Isolate *isolate = v8::Isolate::GetCurrent(); \
v8::EscapableHandleScope scope(isolate); \
return scope.Escape(val->ToBoolean(isolate)); \
}
#endif
#undef X
#define X(TYPE, NAME) \
imp::ToFactory::return_t \
imp::ToFactory::convert(v8::Local val) { \
v8::Isolate *isolate = v8::Isolate::GetCurrent(); \
v8::HandleScope scope(isolate); \
return val->NAME ## Value(isolate->GetCurrentContext()); \
}
X(double, Number)
X(int64_t, Integer)
X(uint32_t, Uint32)
X(int32_t, Int32)
// V8 <= 7.0
#if V8_MAJOR_VERSION < 7 || (V8_MAJOR_VERSION == 7 && V8_MINOR_VERSION == 0)
X(bool, Boolean)
#else
imp::ToFactory::return_t \
imp::ToFactory::convert(v8::Local val) { \
v8::Isolate *isolate = v8::Isolate::GetCurrent(); \
v8::HandleScope scope(isolate); \
return Just(val->BooleanValue(isolate)); \
}
#endif
#undef X
#endif // NAN_CONVERTERS_43_INL_H_
© 2015 - 2024 Weber Informatics LLC | Privacy Policy