From ad36f9389077067fc8c990ba3655d7ac4fb6c286 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Fri, 14 Oct 2011 17:03:06 +1000 Subject: [PATCH] [V8] Allow access to the calling script data Change-Id: I626c8bd090b83af1379fbd85e42b2dae44b5723d Reviewed-by: Kent Hansen --- src/3rdparty/v8/include/v8.h | 1 + src/3rdparty/v8/src/api.cc | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/src/3rdparty/v8/include/v8.h b/src/3rdparty/v8/include/v8.h index 7e614d0..98d4e2c 100644 --- a/src/3rdparty/v8/include/v8.h +++ b/src/3rdparty/v8/include/v8.h @@ -3619,6 +3619,7 @@ class V8EXPORT Context { */ static Local GetCalling(); static Local GetCallingQmlGlobal(); + static Local GetCallingScriptData(); /** * Sets the security token for the context. To access an object in diff --git a/src/3rdparty/v8/src/api.cc b/src/3rdparty/v8/src/api.cc index bdf2e67..a33dd3c 100644 --- a/src/3rdparty/v8/src/api.cc +++ b/src/3rdparty/v8/src/api.cc @@ -4616,6 +4616,18 @@ v8::Local Context::GetCallingQmlGlobal() { } } +v8::Local Context::GetCallingScriptData() +{ + i::Isolate* isolate = i::Isolate::Current(); + if (IsDeadCheck(isolate, "v8::Context::GetCallingScriptData()")) { + return Local(); + } + + i::JavaScriptFrameIterator it; + if (it.done()) return Local(); + i::Handle script(i::Script::cast(i::JSFunction::cast(it.frame()->function())->shared()->script())); + return Utils::ToLocal(i::Handle(script->data())); +} v8::Local Context::Global() { if (IsDeadCheck(i::Isolate::Current(), "v8::Context::Global()")) { -- 2.7.4