On Fri, Nov 23, 2018 at 7:09 AM Gautham B A <gautham.bangal...@gmail.com> wrote: > Hi all, > > I was wondering if it's alright to just return a v8::MaybeLocal<T> from a C++ > function. We know that v8::Local<T> objects must be escaped using a > v8::EscapableHandleScope if we are to return v8::Local<T> from a function. > But I couldn't find the corresponding Escape() overload for v8::MaybeLocal<T> > objects. > > void Callback(const v8::FunctionCallbackInfo<v8::Value> &args) { > } > > v8::MaybeLocal<v8::Object> GetValue(v8::Isolate *isolate, const > v8::Local<v8::Context> &context) { > v8::HandleScope handle_scope(isolate); > auto func = v8::Function::New(isolate, Callback); > v8::MaybeLocal<v8::Object> instance = func->NewInstance(context); // Do I > need to Escape() this "instance" ? If so, how? > return instance; // Is this alright? > } > > Thanks, > --Gautham
There's an EscapableHandleScope::EscapeMaybe() method that you can use in newer versions of V8 (starting with V8 6.9.something.) -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups "v8-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.