blob: 596e9573fc13fd9cd0c1bbdd46bab6536bf52562 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
From 2081f6baaab81d60564680de600b4dcf03de6cd4 Mon Sep 17 00:00:00 2001
From: Aaron Kennedy <aaron.kennedy@nokia.com>
Date: Fri, 14 Oct 2011 17:03:06 +1000
Subject: [PATCH 05/13] Allow access to the calling script data
---
include/v8.h | 1 +
src/api.cc | 12 ++++++++++++
2 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/include/v8.h b/include/v8.h
index 193e2fe..c094d08 100644
--- a/include/v8.h
+++ b/include/v8.h
@@ -3517,6 +3517,7 @@ class V8EXPORT Context {
*/
static Local<Context> GetCalling();
static Local<Object> GetCallingQmlGlobal();
+ static Local<Value> GetCallingScriptData();
/**
* Sets the security token for the context. To access an object in
diff --git a/src/api.cc b/src/api.cc
index 2d3d97a..54df40d 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -4370,6 +4370,18 @@ v8::Local<v8::Object> Context::GetCallingQmlGlobal() {
}
}
+v8::Local<v8::Value> Context::GetCallingScriptData()
+{
+ i::Isolate* isolate = i::Isolate::Current();
+ if (IsDeadCheck(isolate, "v8::Context::GetCallingScriptData()")) {
+ return Local<Object>();
+ }
+
+ i::JavaScriptFrameIterator it;
+ if (it.done()) return Local<Object>();
+ i::Handle<i::Script> script(i::Script::cast(i::JSFunction::cast(it.frame()->function())->shared()->script()));
+ return Utils::ToLocal(i::Handle<i::Object>(script->data()));
+}
v8::Local<v8::Object> Context::Global() {
if (IsDeadCheck(i::Isolate::Current(), "v8::Context::Global()")) {
--
1.7.4.1
|