%PDF- <> %âãÏÓ endobj 2 0 obj <> endobj 3 0 obj <>/ExtGState<>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI] >>/Annots[ 28 0 R 29 0 R] /MediaBox[ 0 0 595.5 842.25] /Contents 4 0 R/Group<>/Tabs/S>> endobj ºaâÚÎΞ-ÌE1ÍØÄ÷{òò2ÿ ÛÖ^ÔÀá TÎ{¦?§®¥kuµùÕ5sLOšuY>endobj 2 0 obj<>endobj 2 0 obj<>endobj 2 0 obj<>endobj 2 0 obj<> endobj 2 0 obj<>endobj 2 0 obj<>es 3 0 R>> endobj 2 0 obj<> ox[ 0.000000 0.000000 609.600000 935.600000]/Fi endobj 3 0 obj<> endobj 7 1 obj<>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI]>>/Subtype/Form>> stream
#include <node.h> #include <node_buffer.h> #include <assert.h> namespace { using v8::Context; using v8::Isolate; using v8::Local; using v8::MaybeLocal; using v8::Object; using v8::Script; using v8::String; using v8::Value; inline void MakeBufferInNewContext( const v8::FunctionCallbackInfo<v8::Value>& args) { Isolate* isolate = args.GetIsolate(); Local<Context> context = Context::New(isolate); Context::Scope context_scope(context); // This should throw an exception, rather than actually do anything. MaybeLocal<Object> buf = node::Buffer::Copy(isolate, "foo", 3); assert(buf.IsEmpty()); } inline void RunInNewContext( const v8::FunctionCallbackInfo<v8::Value>& args) { Isolate* isolate = args.GetIsolate(); Local<Context> context = Context::New(isolate); Context::Scope context_scope(context); context->Global()->Set( context, String::NewFromUtf8(isolate, "data").ToLocalChecked(), args[1]).FromJust(); assert(args[0]->IsString()); // source code Local<Script> script; Local<Value> ret; if (!Script::Compile(context, args[0].As<String>()).ToLocal(&script) || !script->Run(context).ToLocal(&ret)) { return; } args.GetReturnValue().Set(ret); } inline void Initialize(Local<Object> exports, Local<Value> module, Local<Context> context) { NODE_SET_METHOD(exports, "runInNewContext", RunInNewContext); NODE_SET_METHOD(exports, "makeBufferInNewContext", MakeBufferInNewContext); } } // anonymous namespace NODE_MODULE_CONTEXT_AWARE(NODE_GYP_MODULE_NAME, Initialize)