Reviewers: danno, pfeldman, loislo,
Description:
Add a getter for value set with AllowCodeGenerationFromStrings
Please review this at http://codereview.chromium.org/9223016/
SVN Base: http://v8.googlecode.com/svn/branches/bleeding_edge/
Affected files:
M include/v8.h
M src/api.cc
M test/cctest/test-api.cc
Index: include/v8.h
===================================================================
--- include/v8.h (revision 10533)
+++ include/v8.h (working copy)
@@ -3539,6 +3539,12 @@
void AllowCodeGenerationFromStrings(bool allow);
/**
+ * Returns true if code generation from strings is allowed for the
context.
+ * For more details see AllowCodeGenerationFromStrings(bool)
documentation.
+ */
+ bool CodeGenerationFromStringsAllowed();
+
+ /**
* Stack-allocated class which sets the execution context for all
* operations executed within a local scope.
*/
Index: src/api.cc
===================================================================
--- src/api.cc (revision 10533)
+++ src/api.cc (working copy)
@@ -4313,6 +4313,19 @@
}
+bool Context::CodeGenerationFromStringsAllowed() {
+ i::Isolate* isolate = i::Isolate::Current();
+ if
(IsDeadCheck(isolate, "v8::Context::CodeGenerationFromStringsAllowed()")) {
+ return false;
+ }
+ ENTER_V8(isolate);
+ i::Object** ctx = reinterpret_cast<i::Object**>(this);
+ i::Handle<i::Context> context =
+ i::Handle<i::Context>::cast(i::Handle<i::Object>(ctx));
+ return !context->allow_code_gen_from_strings()->IsFalse();
+}
+
+
void V8::SetWrapperClassId(i::Object** global_handle, uint16_t class_id) {
i::GlobalHandles::SetWrapperClassId(global_handle, class_id);
}
Index: test/cctest/test-api.cc
===================================================================
--- test/cctest/test-api.cc (revision 10533)
+++ test/cctest/test-api.cc (working copy)
@@ -15558,10 +15558,12 @@
LocalContext context;
// eval and the Function constructor allowed by default.
+ CHECK(context->CodeGenerationFromStringsAllowed());
CheckCodeGenerationAllowed();
// Disallow eval and the Function constructor.
context->AllowCodeGenerationFromStrings(false);
+ CHECK(!context->CodeGenerationFromStringsAllowed());
CheckCodeGenerationDisallowed();
// Allow again.
@@ -15571,10 +15573,12 @@
// Disallow but setting a global callback that will allow the calls.
context->AllowCodeGenerationFromStrings(false);
V8::SetAllowCodeGenerationFromStringsCallback(&CodeGenerationAllowed);
+ CHECK(!context->CodeGenerationFromStringsAllowed());
CheckCodeGenerationAllowed();
// Set a callback that disallows the code generation.
V8::SetAllowCodeGenerationFromStringsCallback(&CodeGenerationDisallowed);
+ CHECK(!context->CodeGenerationFromStringsAllowed());
CheckCodeGenerationDisallowed();
}
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev