Revision: 10578
Author: [email protected]
Date: Wed Feb 1 04:58:34 2012
Log: Add a getter for value set with AllowCodeGenerationFromStrings
Review URL: https://chromiumcodereview.appspot.com/9223016
http://code.google.com/p/v8/source/detail?r=10578
Modified:
/branches/bleeding_edge/include/v8.h
/branches/bleeding_edge/src/api.cc
/branches/bleeding_edge/test/cctest/test-api.cc
=======================================
--- /branches/bleeding_edge/include/v8.h Wed Jan 25 04:45:54 2012
+++ /branches/bleeding_edge/include/v8.h Wed Feb 1 04:58:34 2012
@@ -3538,6 +3538,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 IsCodeGenerationFromStringsAllowed();
+
/**
* Stack-allocated class which sets the execution context for all
* operations executed within a local scope.
=======================================
--- /branches/bleeding_edge/src/api.cc Wed Jan 25 08:31:25 2012
+++ /branches/bleeding_edge/src/api.cc Wed Feb 1 04:58:34 2012
@@ -4311,6 +4311,20 @@
context->set_allow_code_gen_from_strings(
allow ? isolate->heap()->true_value() :
isolate->heap()->false_value());
}
+
+
+bool Context::IsCodeGenerationFromStringsAllowed() {
+ i::Isolate* isolate = i::Isolate::Current();
+ if (IsDeadCheck(isolate,
+ "v8::Context::IsCodeGenerationFromStringsAllowed()")) {
+ 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) {
=======================================
--- /branches/bleeding_edge/test/cctest/test-api.cc Wed Jan 25 04:45:54 2012
+++ /branches/bleeding_edge/test/cctest/test-api.cc Wed Feb 1 04:58:34 2012
@@ -15558,10 +15558,12 @@
LocalContext context;
// eval and the Function constructor allowed by default.
+ CHECK(context->IsCodeGenerationFromStringsAllowed());
CheckCodeGenerationAllowed();
// Disallow eval and the Function constructor.
context->AllowCodeGenerationFromStrings(false);
+ CHECK(!context->IsCodeGenerationFromStringsAllowed());
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->IsCodeGenerationFromStringsAllowed());
CheckCodeGenerationAllowed();
// Set a callback that disallows the code generation.
V8::SetAllowCodeGenerationFromStringsCallback(&CodeGenerationDisallowed);
+ CHECK(!context->IsCodeGenerationFromStringsAllowed());
CheckCodeGenerationDisallowed();
}
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev