Commit b6ac16da authored by jochen's avatar jochen Committed by Commit bot

Remove v8::Private

Nothing uses it

R=rossberg@chromium.org
LOG=y
BUG=none

Review URL: https://codereview.chromium.org/1152523002

Cr-Commit-Position: refs/heads/master@{#28591}
parent 8c0e936a
......@@ -102,7 +102,6 @@ class String;
class StringObject;
class Symbol;
class SymbolObject;
class Private;
class Uint32;
class Utils;
class Value;
......@@ -311,7 +310,6 @@ class Local {
friend class String;
friend class Object;
friend class Context;
friend class Private;
template<class F> friend class internal::CustomArguments;
friend Local<Primitive> Undefined(Isolate* isolate);
friend Local<Primitive> Null(Isolate* isolate);
......@@ -2451,34 +2449,6 @@ class V8_EXPORT Symbol : public Name {
};
/**
* A private symbol
*
* This is an experimental feature. Use at your own risk.
*/
class V8_EXPORT Private : public Data {
public:
// Returns the print name string of the private symbol, or undefined if none.
Local<Value> Name() const;
// Create a private symbol. If name is not empty, it will be the description.
static Local<Private> New(
Isolate *isolate, Local<String> name = Local<String>());
// Retrieve a global private symbol. If a symbol with this name has not
// been retrieved in the same isolate before, it is created.
// Note that private symbols created this way are never collected, so
// they should only be used for statically fixed properties.
// Also, there is only one global name space for the names used as keys.
// To minimize the potential for clashes, use qualified names as keys,
// e.g., "Class#property".
static Local<Private> ForApi(Isolate *isolate, Local<String> name);
private:
Private();
};
/**
* A JavaScript number value (ECMA-262, 4.3.20)
*/
......@@ -2682,18 +2652,6 @@ class V8_EXPORT Object : public Value {
PropertyAttribute attribute = None,
AccessControl settings = DEFAULT);
/**
* Functionality for private properties.
* This is an experimental feature, use at your own risk.
* Note: Private properties are inherited. Do not rely on this, since it may
* change.
*/
// TODO(dcarney): convert these or remove?
bool HasPrivate(Handle<Private> key);
bool SetPrivate(Handle<Private> key, Handle<Value> value);
bool DeletePrivate(Handle<Private> key);
Local<Value> GetPrivate(Handle<Private> key);
/**
* Returns an array containing the names of the enumerable properties
* of this object, including properties from prototype objects. The
......
......@@ -3462,12 +3462,6 @@ bool v8::Object::ForceSet(v8::Handle<Value> key, v8::Handle<Value> value,
}
bool v8::Object::SetPrivate(v8::Handle<Private> key, v8::Handle<Value> value) {
return ForceSet(v8::Handle<Value>(reinterpret_cast<Value*>(*key)),
value, DontEnum);
}
namespace {
i::MaybeHandle<i::Object> DeleteObjectProperty(
......@@ -3546,11 +3540,6 @@ Local<Value> v8::Object::Get(uint32_t index) {
}
Local<Value> v8::Object::GetPrivate(v8::Handle<Private> key) {
return Get(v8::Handle<Value>(reinterpret_cast<Value*>(*key)));
}
Maybe<PropertyAttribute> v8::Object::GetPropertyAttributes(
Local<Context> context, Local<Value> key) {
PREPARE_FOR_EXECUTION_PRIMITIVE(
......@@ -3782,11 +3771,6 @@ bool v8::Object::Delete(v8::Handle<Value> key) {
}
bool v8::Object::DeletePrivate(v8::Handle<Private> key) {
return Delete(v8::Handle<Value>(reinterpret_cast<Value*>(*key)));
}
Maybe<bool> v8::Object::Has(Local<Context> context, Local<Value> key) {
PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::Get()", bool);
auto self = Utils::OpenHandle(this);
......@@ -3815,13 +3799,6 @@ bool v8::Object::Has(v8::Handle<Value> key) {
}
bool v8::Object::HasPrivate(v8::Handle<Private> key) {
// TODO(rossberg): this should use HasOwnProperty, but we'd need to
// generalise that to a (noy yet existant) Name argument first.
return Has(v8::Handle<Value>(reinterpret_cast<Value*>(*key)));
}
Maybe<bool> v8::Object::Delete(Local<Context> context, uint32_t index) {
PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::DeleteProperty()",
bool);
......@@ -5177,11 +5154,6 @@ Local<Value> Symbol::Name() const {
}
Local<Value> Private::Name() const {
return reinterpret_cast<const Symbol*>(this)->Name();
}
double Number::Value() const {
i::Handle<i::Object> obj = Utils::OpenHandle(this);
return obj->Number();
......@@ -6487,38 +6459,6 @@ Local<Symbol> v8::Symbol::GetToStringTag(Isolate* isolate) {
}
Local<Private> v8::Private::New(Isolate* isolate, Local<String> name) {
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
LOG_API(i_isolate, "Private::New()");
ENTER_V8(i_isolate);
i::Handle<i::Symbol> symbol = i_isolate->factory()->NewPrivateSymbol();
if (!name.IsEmpty()) symbol->set_name(*Utils::OpenHandle(*name));
Local<Symbol> result = Utils::ToLocal(symbol);
return v8::Handle<Private>(reinterpret_cast<Private*>(*result));
}
Local<Private> v8::Private::ForApi(Isolate* isolate, Local<String> name) {
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
i::Handle<i::String> i_name = Utils::OpenHandle(*name);
i::Handle<i::JSObject> registry = i_isolate->GetSymbolRegistry();
i::Handle<i::String> part = i_isolate->factory()->private_api_string();
i::Handle<i::JSObject> privates =
i::Handle<i::JSObject>::cast(
i::Object::GetPropertyOrElement(registry, part).ToHandleChecked());
i::Handle<i::Object> symbol =
i::Object::GetPropertyOrElement(privates, i_name).ToHandleChecked();
if (!symbol->IsSymbol()) {
DCHECK(symbol->IsUndefined());
symbol = i_isolate->factory()->NewPrivateSymbol();
i::Handle<i::Symbol>::cast(symbol)->set_name(*i_name);
i::JSObject::SetProperty(privates, i_name, symbol, i::STRICT).Assert();
}
Local<Symbol> result = Utils::ToLocal(i::Handle<i::Symbol>::cast(symbol));
return v8::Handle<Private>(reinterpret_cast<Private*>(*result));
}
Local<Number> v8::Number::New(Isolate* isolate, double value) {
i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
if (std::isnan(value)) {
......
......@@ -2434,65 +2434,6 @@ THREADED_TEST(SymbolTemplateProperties) {
}
THREADED_TEST(PrivateProperties) {
LocalContext env;
v8::Isolate* isolate = env->GetIsolate();
v8::HandleScope scope(isolate);
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, v8_str("my-private"));
CcTest::heap()->CollectAllGarbage();
CHECK(priv2->Name()->Equals(v8::String::NewFromUtf8(isolate, "my-private")));
// Make sure delete of a non-existent private symbol property works.
CHECK(obj->DeletePrivate(priv1));
CHECK(!obj->HasPrivate(priv1));
CHECK(obj->SetPrivate(priv1, v8::Integer::New(isolate, 1503)));
CHECK(obj->HasPrivate(priv1));
CHECK_EQ(1503, obj->GetPrivate(priv1)->Int32Value());
CHECK(obj->SetPrivate(priv1, v8::Integer::New(isolate, 2002)));
CHECK(obj->HasPrivate(priv1));
CHECK_EQ(2002, obj->GetPrivate(priv1)->Int32Value());
CHECK_EQ(0u, obj->GetOwnPropertyNames()->Length());
unsigned num_props = obj->GetPropertyNames()->Length();
CHECK(obj->Set(v8::String::NewFromUtf8(isolate, "bla"),
v8::Integer::New(isolate, 20)));
CHECK_EQ(1u, obj->GetOwnPropertyNames()->Length());
CHECK_EQ(num_props + 1, obj->GetPropertyNames()->Length());
CcTest::heap()->CollectAllGarbage();
// Add another property and delete it afterwards to force the object in
// slow case.
CHECK(obj->SetPrivate(priv2, v8::Integer::New(isolate, 2008)));
CHECK_EQ(2002, obj->GetPrivate(priv1)->Int32Value());
CHECK_EQ(2008, obj->GetPrivate(priv2)->Int32Value());
CHECK_EQ(2002, obj->GetPrivate(priv1)->Int32Value());
CHECK_EQ(1u, obj->GetOwnPropertyNames()->Length());
CHECK(obj->HasPrivate(priv1));
CHECK(obj->HasPrivate(priv2));
CHECK(obj->DeletePrivate(priv2));
CHECK(obj->HasPrivate(priv1));
CHECK(!obj->HasPrivate(priv2));
CHECK_EQ(2002, obj->GetPrivate(priv1)->Int32Value());
CHECK_EQ(1u, obj->GetOwnPropertyNames()->Length());
// Private properties are inherited (for the time being).
v8::Local<v8::Object> child = v8::Object::New(isolate);
child->SetPrototype(obj);
CHECK(child->HasPrivate(priv1));
CHECK_EQ(2002, child->GetPrivate(priv1)->Int32Value());
CHECK_EQ(0u, child->GetOwnPropertyNames()->Length());
}
THREADED_TEST(GlobalSymbols) {
LocalContext env;
v8::Isolate* isolate = env->GetIsolate();
......@@ -2541,28 +2482,6 @@ THREADED_TEST(WellKnownSymbols) {
}
THREADED_TEST(GlobalPrivates) {
LocalContext env;
v8::Isolate* isolate = env->GetIsolate();
v8::HandleScope scope(isolate);
v8::Local<String> name = v8_str("my-private");
v8::Local<v8::Private> glob = v8::Private::ForApi(isolate, name);
v8::Local<v8::Object> obj = v8::Object::New(isolate);
CHECK(obj->SetPrivate(glob, v8::Integer::New(isolate, 3)));
v8::Local<v8::Private> glob2 = v8::Private::ForApi(isolate, name);
CHECK(obj->HasPrivate(glob2));
v8::Local<v8::Private> priv = v8::Private::New(isolate, name);
CHECK(!obj->HasPrivate(priv));
CompileRun("var intern = %CreateGlobalPrivateSymbol('my-private')");
v8::Local<Value> intern = env->Global()->Get(v8_str("intern"));
CHECK(!obj->Has(intern));
}
class ScopedArrayBufferContents {
public:
explicit ScopedArrayBufferContents(const v8::ArrayBuffer::Contents& contents)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment