Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(693)

Unified Diff: src/api.cc

Issue 48923002: Provide private symbols through internal APIs (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Make privates a non-value; comments Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/api.h ('k') | src/array-iterator.js » ('j') | src/objects.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index 0bb374f2dc69bea8e712d4962363e835bfbb80bc..7b5d2438f812f5d8b93644cafb69ee27196b99d3 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -2772,7 +2772,7 @@ void v8::String::CheckCast(v8::Value* that) {
void v8::Symbol::CheckCast(v8::Value* that) {
i::Handle<i::Object> obj = Utils::OpenHandle(that);
- ApiCheck(obj->IsSymbol(),
+ ApiCheck(obj->IsSymbol() && !obj->IsPrivate(),
"v8::Symbol::Cast()",
"Could not convert to symbol");
}
@@ -3184,6 +3184,11 @@ bool v8::Object::ForceSet(v8::Handle<Value> key,
}
+bool v8::Object::SetPrivate(v8::Handle<Private> key, v8::Handle<Value> value) {
+ return Set(*reinterpret_cast<v8::Handle<Value>*>(&key), value, DontEnum);
+}
+
+
bool v8::Object::ForceDelete(v8::Handle<Value> key) {
i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
ON_BAILOUT(isolate, "v8::Object::ForceDelete()", return false);
@@ -3235,6 +3240,11 @@ Local<Value> v8::Object::Get(uint32_t index) {
}
+Local<Value> v8::Object::GetPrivate(v8::Handle<Private> key) {
+ return Get(*reinterpret_cast<v8::Handle<Value>*>(&key));
+}
+
+
PropertyAttribute v8::Object::GetPropertyAttributes(v8::Handle<Value> key) {
i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
ON_BAILOUT(isolate, "v8::Object::GetPropertyAttribute()",
@@ -3434,6 +3444,11 @@ bool v8::Object::Delete(v8::Handle<Value> key) {
}
+bool v8::Object::DeletePrivate(v8::Handle<Private> key) {
+ return Delete(*reinterpret_cast<v8::Handle<Value>*>(&key));
+}
+
+
bool v8::Object::Has(v8::Handle<Value> key) {
i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
ON_BAILOUT(isolate, "v8::Object::Has()", return false);
@@ -3448,6 +3463,11 @@ bool v8::Object::Has(v8::Handle<Value> key) {
}
+bool v8::Object::HasPrivate(v8::Handle<Private> key) {
+ return Has(*reinterpret_cast<v8::Handle<Value>*>(&key));
+}
+
+
bool v8::Object::Delete(uint32_t index) {
i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
ON_BAILOUT(isolate, "v8::Object::DeleteProperty()",
@@ -4863,6 +4883,14 @@ const v8::String::ExternalAsciiStringResource*
Local<Value> Symbol::Name() const {
i::Handle<i::Symbol> sym = Utils::OpenHandle(this);
+ ASSERT(!sym->IsPrivate());
+ i::Handle<i::Object> name(sym->name(), sym->GetIsolate());
+ return Utils::ToLocal(name);
+}
+
+
+Local<Value> Private::Name() const {
+ i::Handle<i::Private> sym = Utils::OpenHandle(this);
i::Handle<i::Object> name(sym->name(), sym->GetIsolate());
return Utils::ToLocal(name);
}
@@ -6149,6 +6177,31 @@ Local<Symbol> v8::Symbol::New(Isolate* isolate, const char* data, int length) {
}
+Local<Private> v8::Private::New(Isolate* isolate) {
+ 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::Private> result = i_isolate->factory()->NewPrivate();
+ return Utils::ToLocal(result);
+}
+
+
+Local<Private> v8::Private::New(
+ Isolate* isolate, const char* data, int length) {
+ i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
+ EnsureInitializedForIsolate(i_isolate, "v8::Private::New()");
+ LOG_API(i_isolate, "Private::New(char)");
+ ENTER_V8(i_isolate);
+ if (length == -1) length = i::StrLength(data);
+ i::Handle<i::String> name = i_isolate->factory()->NewStringFromUtf8(
+ i::Vector<const char>(data, length));
+ i::Handle<i::Private> result = i_isolate->factory()->NewPrivate();
+ result->set_name(*name);
+ return Utils::ToLocal(result);
Yang 2013/10/29 12:47:26 I think you could unify those two New functions by
rossberg 2013/10/29 15:08:19 Done (also for the Symbol class).
+}
+
+
Local<Number> v8::Number::New(double value) {
i::Isolate* isolate = i::Isolate::Current();
EnsureInitializedForIsolate(isolate, "v8::Number::New()");
« no previous file with comments | « src/api.h ('k') | src/array-iterator.js » ('j') | src/objects.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698