nan_maybe_43_inl.h
Go to the documentation of this file.
00001 /*********************************************************************
00002  * NAN - Native Abstractions for Node.js
00003  *
00004  * Copyright (c) 2016 NAN contributors
00005  *
00006  * MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
00007  ********************************************************************/
00008 
00009 #ifndef NAN_MAYBE_43_INL_H_
00010 #define NAN_MAYBE_43_INL_H_
00011 
00012 template<typename T>
00013 using MaybeLocal = v8::MaybeLocal<T>;
00014 
00015 template<typename T>
00016 using Maybe = v8::Maybe<T>;
00017 
00018 template<typename T>
00019 inline Maybe<T> Nothing() {
00020   return v8::Nothing<T>();
00021 }
00022 
00023 template<typename T>
00024 inline Maybe<T> Just(const T& t) {
00025   return v8::Just<T>(t);
00026 }
00027 
00028 v8::Local<v8::Context> GetCurrentContext();
00029 
00030 inline
00031 MaybeLocal<v8::String> ToDetailString(v8::Local<v8::Value> val) {
00032   return val->ToDetailString(GetCurrentContext());
00033 }
00034 
00035 inline
00036 MaybeLocal<v8::Uint32> ToArrayIndex(v8::Local<v8::Value> val) {
00037   return val->ToArrayIndex(GetCurrentContext());
00038 }
00039 
00040 inline
00041 Maybe<bool> Equals(v8::Local<v8::Value> a, v8::Local<v8::Value>(b)) {
00042   return a->Equals(GetCurrentContext(), b);
00043 }
00044 
00045 inline
00046 MaybeLocal<v8::Object> NewInstance(v8::Local<v8::Function> h) {
00047   return h->NewInstance(GetCurrentContext());
00048 }
00049 
00050 inline
00051 MaybeLocal<v8::Object> NewInstance(
00052       v8::Local<v8::Function> h
00053     , int argc
00054     , v8::Local<v8::Value> argv[]) {
00055   return h->NewInstance(GetCurrentContext(), argc, argv);
00056 }
00057 
00058 inline
00059 MaybeLocal<v8::Object> NewInstance(v8::Local<v8::ObjectTemplate> h) {
00060   return h->NewInstance(GetCurrentContext());
00061 }
00062 
00063 
00064 inline MaybeLocal<v8::Function> GetFunction(
00065     v8::Local<v8::FunctionTemplate> t) {
00066   return t->GetFunction(GetCurrentContext());
00067 }
00068 
00069 inline Maybe<bool> Set(
00070     v8::Local<v8::Object> obj
00071   , v8::Local<v8::Value> key
00072   , v8::Local<v8::Value> value) {
00073   return obj->Set(GetCurrentContext(), key, value);
00074 }
00075 
00076 inline Maybe<bool> Set(
00077     v8::Local<v8::Object> obj
00078   , uint32_t index
00079   , v8::Local<v8::Value> value) {
00080   return obj->Set(GetCurrentContext(), index, value);
00081 }
00082 
00083 inline Maybe<bool> ForceSet(
00084     v8::Local<v8::Object> obj
00085   , v8::Local<v8::Value> key
00086   , v8::Local<v8::Value> value
00087   , v8::PropertyAttribute attribs = v8::None) {
00088   return obj->ForceSet(GetCurrentContext(), key, value, attribs);
00089 }
00090 
00091 inline MaybeLocal<v8::Value> Get(
00092     v8::Local<v8::Object> obj
00093   , v8::Local<v8::Value> key) {
00094   return obj->Get(GetCurrentContext(), key);
00095 }
00096 
00097 inline
00098 MaybeLocal<v8::Value> Get(v8::Local<v8::Object> obj, uint32_t index) {
00099   return obj->Get(GetCurrentContext(), index);
00100 }
00101 
00102 inline v8::PropertyAttribute GetPropertyAttributes(
00103     v8::Local<v8::Object> obj
00104   , v8::Local<v8::Value> key) {
00105   return obj->GetPropertyAttributes(GetCurrentContext(), key).FromJust();
00106 }
00107 
00108 inline Maybe<bool> Has(
00109     v8::Local<v8::Object> obj
00110   , v8::Local<v8::String> key) {
00111   return obj->Has(GetCurrentContext(), key);
00112 }
00113 
00114 inline Maybe<bool> Has(v8::Local<v8::Object> obj, uint32_t index) {
00115   return obj->Has(GetCurrentContext(), index);
00116 }
00117 
00118 inline Maybe<bool> Delete(
00119     v8::Local<v8::Object> obj
00120   , v8::Local<v8::String> key) {
00121   return obj->Delete(GetCurrentContext(), key);
00122 }
00123 
00124 inline
00125 Maybe<bool> Delete(v8::Local<v8::Object> obj, uint32_t index) {
00126   return obj->Delete(GetCurrentContext(), index);
00127 }
00128 
00129 inline
00130 MaybeLocal<v8::Array> GetPropertyNames(v8::Local<v8::Object> obj) {
00131   return obj->GetPropertyNames(GetCurrentContext());
00132 }
00133 
00134 inline
00135 MaybeLocal<v8::Array> GetOwnPropertyNames(v8::Local<v8::Object> obj) {
00136   return obj->GetOwnPropertyNames(GetCurrentContext());
00137 }
00138 
00139 inline Maybe<bool> SetPrototype(
00140     v8::Local<v8::Object> obj
00141   , v8::Local<v8::Value> prototype) {
00142   return obj->SetPrototype(GetCurrentContext(), prototype);
00143 }
00144 
00145 inline MaybeLocal<v8::String> ObjectProtoToString(
00146     v8::Local<v8::Object> obj) {
00147   return obj->ObjectProtoToString(GetCurrentContext());
00148 }
00149 
00150 inline Maybe<bool> HasOwnProperty(
00151     v8::Local<v8::Object> obj
00152   , v8::Local<v8::String> key) {
00153   return obj->HasOwnProperty(GetCurrentContext(), key);
00154 }
00155 
00156 inline Maybe<bool> HasRealNamedProperty(
00157     v8::Local<v8::Object> obj
00158   , v8::Local<v8::String> key) {
00159   return obj->HasRealNamedProperty(GetCurrentContext(), key);
00160 }
00161 
00162 inline Maybe<bool> HasRealIndexedProperty(
00163     v8::Local<v8::Object> obj
00164   , uint32_t index) {
00165   return obj->HasRealIndexedProperty(GetCurrentContext(), index);
00166 }
00167 
00168 inline Maybe<bool> HasRealNamedCallbackProperty(
00169     v8::Local<v8::Object> obj
00170   , v8::Local<v8::String> key) {
00171   return obj->HasRealNamedCallbackProperty(GetCurrentContext(), key);
00172 }
00173 
00174 inline MaybeLocal<v8::Value> GetRealNamedPropertyInPrototypeChain(
00175     v8::Local<v8::Object> obj
00176   , v8::Local<v8::String> key) {
00177   return obj->GetRealNamedPropertyInPrototypeChain(GetCurrentContext(), key);
00178 }
00179 
00180 inline MaybeLocal<v8::Value> GetRealNamedProperty(
00181     v8::Local<v8::Object> obj
00182   , v8::Local<v8::String> key) {
00183   return obj->GetRealNamedProperty(GetCurrentContext(), key);
00184 }
00185 
00186 inline MaybeLocal<v8::Value> CallAsFunction(
00187     v8::Local<v8::Object> obj
00188   , v8::Local<v8::Object> recv
00189   , int argc
00190   , v8::Local<v8::Value> argv[]) {
00191   return obj->CallAsFunction(GetCurrentContext(), recv, argc, argv);
00192 }
00193 
00194 inline MaybeLocal<v8::Value> CallAsConstructor(
00195     v8::Local<v8::Object> obj
00196   , int argc, v8::Local<v8::Value> argv[]) {
00197   return obj->CallAsConstructor(GetCurrentContext(), argc, argv);
00198 }
00199 
00200 inline
00201 MaybeLocal<v8::String> GetSourceLine(v8::Local<v8::Message> msg) {
00202   return msg->GetSourceLine(GetCurrentContext());
00203 }
00204 
00205 inline Maybe<int> GetLineNumber(v8::Local<v8::Message> msg) {
00206   return msg->GetLineNumber(GetCurrentContext());
00207 }
00208 
00209 inline Maybe<int> GetStartColumn(v8::Local<v8::Message> msg) {
00210   return msg->GetStartColumn(GetCurrentContext());
00211 }
00212 
00213 inline Maybe<int> GetEndColumn(v8::Local<v8::Message> msg) {
00214   return msg->GetEndColumn(GetCurrentContext());
00215 }
00216 
00217 inline MaybeLocal<v8::Object> CloneElementAt(
00218     v8::Local<v8::Array> array
00219   , uint32_t index) {
00220 #if (NODE_MODULE_VERSION >= NODE_6_0_MODULE_VERSION)
00221   v8::EscapableHandleScope handle_scope(v8::Isolate::GetCurrent());
00222   v8::Local<v8::Context> context = GetCurrentContext();
00223   v8::Local<v8::Value> elem;
00224   if (!array->Get(context, index).ToLocal(&elem)) {
00225     return MaybeLocal<v8::Object>();
00226   }
00227   v8::Local<v8::Object> obj;
00228   if (!elem->ToObject(context).ToLocal(&obj)) {
00229     return MaybeLocal<v8::Object>();
00230   }
00231   return MaybeLocal<v8::Object>(handle_scope.Escape(obj->Clone()));
00232 #else
00233   return array->CloneElementAt(GetCurrentContext(), index);
00234 #endif
00235 }
00236 
00237 inline MaybeLocal<v8::Value> Call(
00238     v8::Local<v8::Function> fun
00239   , v8::Local<v8::Object> recv
00240   , int argc
00241   , v8::Local<v8::Value> argv[]) {
00242   return fun->Call(GetCurrentContext(), recv, argc, argv);
00243 }
00244 
00245 #endif  // NAN_MAYBE_43_INL_H_


dji_ronin
Author(s):
autogenerated on Sat Jun 8 2019 20:15:31