Reviewers: rossberg,
Message:
ptal
Description:
initialize v8::Private with v8::String
[email protected]
BUG=
Please review this at https://codereview.chromium.org/179983002/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files (+6, -10 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
dd8f2685bc37115638f5332ddbefd42a79c16cea..73a1cc637fb30572f938ea6f7daa2476b6f2597e
100644
--- a/include/v8.h
+++ b/include/v8.h
@@ -1933,8 +1933,8 @@ class V8_EXPORT Private : public Data {
Local<Value> Name() const;
// Create a private symbol. If data is not NULL, it will be the print
name.
- static Local<Private> New(
- Isolate *isolate, const char* data = NULL, int length = -1);
+ static Local<Private> New(Isolate *isolate,
+ Local<String> name = Local<String>());
private:
Private();
Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index
2c7db3be1656f10d475dd8e1de71a89ed374cdd6..ab50b69e148f739dac8fd159e0018e1608c38688
100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -5984,18 +5984,13 @@ Local<Symbol> v8::Symbol::New(Isolate* isolate,
const char* data, int length) {
Local<Private> v8::Private::New(
- Isolate* isolate, const char* data, int length) {
+ Isolate* isolate, Local<String> name) {
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
EnsureInitializedForIsolate(i_isolate, "v8::Private::New()");
LOG_API(i_isolate, "Private::New()");
ENTER_V8(i_isolate);
i::Handle<i::Symbol> symbol = i_isolate->factory()->NewPrivateSymbol();
- if (data != NULL) {
- if (length == -1) length = i::StrLength(data);
- i::Handle<i::String> name = i_isolate->factory()->NewStringFromUtf8(
- i::Vector<const char>(data, length));
- symbol->set_name(*name);
- }
+ if (!name.IsEmpty()) symbol->set_name(*Utils::OpenHandle(*name));
Local<Symbol> result = Utils::ToLocal(symbol);
return v8::Handle<Private>(reinterpret_cast<Private*>(*result));
}
Index: test/cctest/test-api.cc
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
index
c5c932b7516cc70738ad918a9311dabe1e985427..d79e6c9d7db7b70debbe4ee6a2eb21ca43c7749d
100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -2844,7 +2844,8 @@ THREADED_TEST(PrivateProperties) {
v8::Local<v8::Object> obj = v8::Object::New(isolate);
v8::Local<v8::Private> priv1 = v8::Private::New(isolate);
- v8::Local<v8::Private> priv2 = v8::Private::New(isolate, "my-private");
+ v8::Local<v8::Private> priv2 = v8::Private::New(isolate,
+ v8_str("my-private"));
CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags);
--
--
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/groups/opt_out.