/********************************************************************* * NAN - Native Abstractions for Node.js * * Copyright (c) 2015 NAN contributors * * MIT License ********************************************************************/ #ifndef NAN_MAYBE_43_INL_H_ #define NAN_MAYBE_43_INL_H_ template using MaybeLocal = v8::MaybeLocal; template using Maybe = v8::Maybe; template NAN_INLINE Maybe Nothing() { return v8::Nothing(); } template NAN_INLINE Maybe Just(const T& t) { return v8::Just(t); } v8::Local GetCurrentContext(); NAN_INLINE MaybeLocal ToDetailString(v8::Local val) { return val->ToDetailString(GetCurrentContext()); } NAN_INLINE MaybeLocal ToArrayIndex(v8::Local val) { return val->ToArrayIndex(GetCurrentContext()); } NAN_INLINE Maybe Equals(v8::Local a, v8::Local(b)) { return a->Equals(GetCurrentContext(), b); } NAN_INLINE MaybeLocal NewInstance(v8::Local h) { return MaybeLocal(h->NewInstance(GetCurrentContext())); } NAN_INLINE MaybeLocal NewInstance( v8::Local h , int argc , v8::Local argv[]) { return MaybeLocal(h->NewInstance(GetCurrentContext(), argc, argv)); } NAN_INLINE MaybeLocal NewInstance(v8::Local h) { return MaybeLocal(h->NewInstance(GetCurrentContext())); } NAN_INLINE MaybeLocal GetFunction( v8::Local t) { return t->GetFunction(GetCurrentContext()); } NAN_INLINE Maybe Set( v8::Local obj , v8::Local key , v8::Local value) { return obj->Set(GetCurrentContext(), key, value); } NAN_INLINE Maybe Set( v8::Local obj , uint32_t index , v8::Local value) { return obj->Set(GetCurrentContext(), index, value); } NAN_INLINE Maybe ForceSet( v8::Local obj , v8::Local key , v8::Local value , v8::PropertyAttribute attribs = v8::None) { return obj->ForceSet(GetCurrentContext(), key, value, attribs); } NAN_INLINE MaybeLocal Get( v8::Local obj , v8::Local key) { return obj->Get(GetCurrentContext(), key); } NAN_INLINE MaybeLocal Get(v8::Local obj, uint32_t index) { return obj->Get(GetCurrentContext(), index); } NAN_INLINE v8::PropertyAttribute GetPropertyAttributes( v8::Local obj , v8::Local key) { return obj->GetPropertyAttributes(GetCurrentContext(), key).FromJust(); } NAN_INLINE Maybe Has( v8::Local obj , v8::Local key) { return obj->Has(GetCurrentContext(), key); } NAN_INLINE Maybe Has(v8::Local obj, uint32_t index) { return obj->Has(GetCurrentContext(), index); } NAN_INLINE Maybe Delete( v8::Local obj , v8::Local key) { return obj->Delete(GetCurrentContext(), key); } NAN_INLINE Maybe Delete(v8::Local obj, uint32_t index) { return obj->Delete(GetCurrentContext(), index); } NAN_INLINE MaybeLocal GetPropertyNames(v8::Local obj) { return obj->GetPropertyNames(GetCurrentContext()); } NAN_INLINE MaybeLocal GetOwnPropertyNames(v8::Local obj) { return obj->GetOwnPropertyNames(GetCurrentContext()); } NAN_INLINE Maybe SetPrototype( v8::Local obj , v8::Local prototype) { return obj->SetPrototype(GetCurrentContext(), prototype); } NAN_INLINE MaybeLocal ObjectProtoToString( v8::Local obj) { return obj->ObjectProtoToString(GetCurrentContext()); } NAN_INLINE Maybe HasOwnProperty( v8::Local obj , v8::Local key) { return obj->HasOwnProperty(GetCurrentContext(), key); } NAN_INLINE Maybe HasRealNamedProperty( v8::Local obj , v8::Local key) { return obj->HasRealNamedProperty(GetCurrentContext(), key); } NAN_INLINE Maybe HasRealIndexedProperty( v8::Local obj , uint32_t index) { return obj->HasRealIndexedProperty(GetCurrentContext(), index); } NAN_INLINE Maybe HasRealNamedCallbackProperty( v8::Local obj , v8::Local key) { return obj->HasRealNamedCallbackProperty(GetCurrentContext(), key); } NAN_INLINE MaybeLocal GetRealNamedPropertyInPrototypeChain( v8::Local obj , v8::Local key) { return obj->GetRealNamedPropertyInPrototypeChain(GetCurrentContext(), key); } NAN_INLINE MaybeLocal GetRealNamedProperty( v8::Local obj , v8::Local key) { return obj->GetRealNamedProperty(GetCurrentContext(), key); } NAN_INLINE MaybeLocal CallAsFunction( v8::Local obj , v8::Local recv , int argc , v8::Local argv[]) { return obj->CallAsFunction(GetCurrentContext(), recv, argc, argv); } NAN_INLINE MaybeLocal CallAsConstructor( v8::Local obj , int argc, v8::Local argv[]) { return obj->CallAsConstructor(GetCurrentContext(), argc, argv); } NAN_INLINE MaybeLocal GetSourceLine(v8::Local msg) { return msg->GetSourceLine(GetCurrentContext()); } NAN_INLINE Maybe GetLineNumber(v8::Local msg) { return msg->GetLineNumber(GetCurrentContext()); } NAN_INLINE Maybe GetStartColumn(v8::Local msg) { return msg->GetStartColumn(GetCurrentContext()); } NAN_INLINE Maybe GetEndColumn(v8::Local msg) { return msg->GetEndColumn(GetCurrentContext()); } NAN_INLINE MaybeLocal CloneElementAt( v8::Local array , uint32_t index) { return array->CloneElementAt(GetCurrentContext(), index); } #endif // NAN_MAYBE_43_INL_H_