Reviewers: Yang,
Description:
Add FunctionTemplate::GetClassName to API.
The SetClassName is already there, need also the getter.
[email protected]
Please review this at https://codereview.chromium.org/377213002/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files (+19, -0 lines):
M include/v8.h
M src/api.cc
M test/cctest/test-api.cc
Index: include/v8.h
diff --git a/include/v8.h b/include/v8.h
index
88e9a611cc142277eac35ed717f3e390b2ba09d1..fc8276aeb4fb038e9442f6e7819e717c5c4a4d98
100644
--- a/include/v8.h
+++ b/include/v8.h
@@ -3481,6 +3481,9 @@ class V8_EXPORT FunctionTemplate : public Template {
*/
void SetClassName(Handle<String> name);
+ /** Returns the class name of the FunctionTemplate. */
+ Local<String> GetClassName();
+
/**
* Determines whether the __proto__ accessor ignores instances of
* the function template. If instances of the function template are
Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index
8238922453bfb48130955ebbf8eb8c63e5e72b36..b9678ba764bc53861b0672bd81d6c3e1da2485a9
100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -1243,6 +1243,20 @@ void FunctionTemplate::SetClassName(Handle<String>
name) {
}
+Local<String> FunctionTemplate::GetClassName() {
+ i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
+ ENTER_V8(isolate);
+ EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate));
+ i::Handle<i::FunctionTemplateInfo> self = Utils::OpenHandle(this);
+ i::Handle<i::Object> name(self->class_name(), isolate);
+ if (name->IsString()) {
+ return scope.Escape(Utils::ToLocal(i::Handle<i::String>::cast(name)));
+ } else {
+ return Local<String>();
+ }
+}
+
+
void FunctionTemplate::SetHiddenPrototype(bool value) {
i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
ENTER_V8(isolate);
Index: test/cctest/test-api.cc
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
index
0ddf5ba7651470ae1cb6ec6ed9fd0fa04f6b2ba1..371b1b7255252d2ca9e6d6f4088e805d07ac70bc
100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -13070,6 +13070,8 @@ THREADED_TEST(ObjectProtoToString) {
LocalContext context;
+ CHECK_EQ(v8_str("MyClass"), templ->GetClassName());
+
Local<String> customized_tostring = v8_str("customized toString");
// Replace Object.prototype.toString
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.