package.nan_maybe_pre_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_MAYBE_PRE_43_INL_H_
#define NAN_MAYBE_PRE_43_INL_H_
template
class MaybeLocal {
public:
inline MaybeLocal() : val_(v8::Local()) {}
template
# if NODE_MODULE_VERSION >= NODE_0_12_MODULE_VERSION
inline
MaybeLocal(v8::Local that) : val_(that) {} // NOLINT(runtime/explicit)
# else
inline
MaybeLocal(v8::Local that) : // NOLINT(runtime/explicit)
val_(*reinterpret_cast*>(&that)) {}
# endif
inline bool IsEmpty() const { return val_.IsEmpty(); }
template
inline bool ToLocal(v8::Local *out) const {
*out = val_;
return !IsEmpty();
}
inline v8::Local ToLocalChecked() const {
#if defined(V8_ENABLE_CHECKS)
assert(!IsEmpty() && "ToLocalChecked is Empty");
#endif // V8_ENABLE_CHECKS
return val_;
}
template
inline v8::Local FromMaybe(v8::Local default_value) const {
return IsEmpty() ? default_value : v8::Local(val_);
}
private:
v8::Local val_;
};
inline
MaybeLocal ToDetailString(v8::Handle val) {
return MaybeLocal(val->ToDetailString());
}
inline
MaybeLocal ToArrayIndex(v8::Handle val) {
return MaybeLocal(val->ToArrayIndex());
}
inline
Maybe Equals(v8::Handle a, v8::Handle(b)) {
return Just(a->Equals(b));
}
inline
MaybeLocal NewInstance(v8::Handle h) {
return MaybeLocal(h->NewInstance());
}
inline
MaybeLocal NewInstance(
v8::Local h
, int argc
, v8::Local argv[]) {
return MaybeLocal(h->NewInstance(argc, argv));
}
inline
MaybeLocal NewInstance(v8::Handle h) {
return MaybeLocal(h->NewInstance());
}
inline
MaybeLocal GetFunction(v8::Handle t) {
return MaybeLocal(t->GetFunction());
}
inline Maybe Set(
v8::Handle obj
, v8::Handle key
, v8::Handle value) {
return Just(obj->Set(key, value));
}
inline Maybe Set(
v8::Handle obj
, uint32_t index
, v8::Handle value) {
return Just(obj->Set(index, value));
}
#include "nan_define_own_property_helper.h" // NOLINT(build/include)
inline Maybe DefineOwnProperty(
v8::Handle obj
, v8::Handle key
, v8::Handle value
, v8::PropertyAttribute attribs = v8::None) {
v8::PropertyAttribute current = obj->GetPropertyAttributes(key);
return imp::DefineOwnPropertyHelper(current, obj, key, value, attribs);
}
NAN_DEPRECATED inline Maybe ForceSet(
v8::Handle obj
, v8::Handle key
, v8::Handle value
, v8::PropertyAttribute attribs = v8::None) {
return Just(obj->ForceSet(key, value, attribs));
}
inline MaybeLocal Get(
v8::Handle obj
, v8::Handle key) {
return MaybeLocal(obj->Get(key));
}
inline MaybeLocal Get(
v8::Handle obj
, uint32_t index) {
return MaybeLocal(obj->Get(index));
}
inline Maybe GetPropertyAttributes(
v8::Handle obj
, v8::Handle key) {
return Just(obj->GetPropertyAttributes(key));
}
inline Maybe Has(
v8::Handle obj
, v8::Handle key) {
return Just(obj->Has(key));
}
inline Maybe Has(
v8::Handle obj
, uint32_t index) {
return Just(obj->Has(index));
}
inline Maybe Delete(
v8::Handle obj
, v8::Handle key) {
return Just(obj->Delete(key));
}
inline Maybe Delete(
v8::Handle obj
, uint32_t index) {
return Just(obj->Delete(index));
}
inline
MaybeLocal GetPropertyNames(v8::Handle obj) {
return MaybeLocal(obj->GetPropertyNames());
}
inline
MaybeLocal GetOwnPropertyNames(v8::Handle obj) {
return MaybeLocal(obj->GetOwnPropertyNames());
}
inline Maybe SetPrototype(
v8::Handle obj
, v8::Handle prototype) {
return Just(obj->SetPrototype(prototype));
}
inline MaybeLocal ObjectProtoToString(
v8::Handle obj) {
return MaybeLocal(obj->ObjectProtoToString());
}
inline Maybe HasOwnProperty(
v8::Handle obj
, v8::Handle key) {
return Just(obj->HasOwnProperty(key));
}
inline Maybe HasRealNamedProperty(
v8::Handle obj
, v8::Handle key) {
return Just(obj->HasRealNamedProperty(key));
}
inline Maybe HasRealIndexedProperty(
v8::Handle obj
, uint32_t index) {
return Just(obj->HasRealIndexedProperty(index));
}
inline Maybe HasRealNamedCallbackProperty(
v8::Handle obj
, v8::Handle key) {
return Just(obj->HasRealNamedCallbackProperty(key));
}
inline MaybeLocal GetRealNamedPropertyInPrototypeChain(
v8::Handle obj
, v8::Handle key) {
return MaybeLocal(
obj->GetRealNamedPropertyInPrototypeChain(key));
}
inline MaybeLocal GetRealNamedProperty(
v8::Handle obj
, v8::Handle key) {
return MaybeLocal(obj->GetRealNamedProperty(key));
}
inline MaybeLocal CallAsFunction(
v8::Handle obj
, v8::Handle recv
, int argc
, v8::Handle argv[]) {
return MaybeLocal(obj->CallAsFunction(recv, argc, argv));
}
inline MaybeLocal CallAsConstructor(
v8::Handle obj
, int argc
, v8::Local argv[]) {
return MaybeLocal(obj->CallAsConstructor(argc, argv));
}
inline
MaybeLocal GetSourceLine(v8::Handle msg) {
return MaybeLocal(msg->GetSourceLine());
}
inline Maybe GetLineNumber(v8::Handle msg) {
return Just(msg->GetLineNumber());
}
inline Maybe GetStartColumn(v8::Handle msg) {
return Just(msg->GetStartColumn());
}
inline Maybe GetEndColumn(v8::Handle msg) {
return Just(msg->GetEndColumn());
}
inline MaybeLocal CloneElementAt(
v8::Handle array
, uint32_t index) {
return MaybeLocal(array->CloneElementAt(index));
}
inline MaybeLocal Call(
v8::Local fun
, v8::Local recv
, int argc
, v8::Local argv[]) {
return MaybeLocal(fun->Call(recv, argc, argv));
}
#endif // NAN_MAYBE_PRE_43_INL_H_
© 2015 - 2024 Weber Informatics LLC | Privacy Policy