Removed deprecated functions from v8's external API.

Removed the following deprecated functions:

   * Object::GetPointerFromInternalField
   * Object::SetPointerInInternalField
   * External::Wrap
   * External::Unwrap
   * Context::GetData
   * Context::SetData

They have been deprecated in the 3.15 branch and are not used by Chrome anymore.
Furthermore, judging from bug reports and email threads, embedders like node.js
and others are already using 3.15, too. All removed API entries can be emulated
by a one-liner, so adapting should not be hard for anybody.

We want to introduce more deprecations soon, but to keep things simple and avoid
having old and not-so-old deprecations in v8.h, the 3.15 deprecations are now
removed.

In general, the strategy of keeping deprecated things for one stable release and
then removing them seems to be a good compromise between a maintenance nightmare
and annoying external embedders. :-)

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@13372 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent eadcc1c1
......@@ -1635,22 +1635,6 @@ class V8EXPORT Object : public Value {
/** Sets the value in an internal field. */
void SetInternalField(int index, Handle<Value> value);
/**
* Gets a native pointer from an internal field. Deprecated. If the pointer is
* always 2-byte-aligned, use GetAlignedPointerFromInternalField instead,
* otherwise use a combination of GetInternalField, External::Cast and
* External::Value.
*/
V8_DEPRECATED(void* GetPointerFromInternalField(int index));
/**
* Sets a native pointer in an internal field. Deprecated. If the pointer is
* always 2-byte aligned, use SetAlignedPointerInInternalField instead,
* otherwise use a combination of External::New and SetInternalField.
*/
V8_DEPRECATED(V8_INLINE(void SetPointerInInternalField(int index,
void* value)));
/**
* Gets a 2-byte-aligned native pointer from an internal field. This field
* must have been set by SetAlignedPointerInInternalField, everything else
......@@ -2005,12 +1989,6 @@ class V8EXPORT RegExp : public Object {
*/
class V8EXPORT External : public Value {
public:
/** Deprecated, use New instead. */
V8_DEPRECATED(V8_INLINE(static Local<Value> Wrap(void* value)));
/** Deprecated, use a combination of Cast and Value instead. */
V8_DEPRECATED(V8_INLINE(static void* Unwrap(Handle<Value> obj)));
static Local<External> New(void* value);
V8_INLINE(static External* Cast(Value* obj));
void* Value() const;
......@@ -3818,18 +3796,6 @@ class V8EXPORT Context {
/** Returns true if V8 has a current context. */
static bool InContext();
/**
* Gets embedder data with index 0. Deprecated, use GetEmbedderData with index
* 0 instead.
*/
V8_DEPRECATED(V8_INLINE(Local<Value> GetData()));
/**
* Sets embedder data with index 0. Deprecated, use SetEmbedderData with index
* 0 instead.
*/
V8_DEPRECATED(V8_INLINE(void SetData(Handle<Value> value)));
/**
* Gets the embedder data with the given index, which must have been set by a
* previous call to SetEmbedderData with the same index. Note that index 0
......@@ -4524,11 +4490,6 @@ Local<Value> Object::GetInternalField(int index) {
}
void Object::SetPointerInInternalField(int index, void* value) {
SetInternalField(index, External::New(value));
}
void* Object::GetAlignedPointerFromInternalField(int index) {
#ifndef V8_ENABLE_CHECKS
typedef internal::Object O;
......@@ -4733,16 +4694,6 @@ Function* Function::Cast(v8::Value* value) {
}
Local<Value> External::Wrap(void* value) {
return External::New(value);
}
void* External::Unwrap(Handle<v8::Value> obj) {
return External::Cast(*obj)->Value();
}
External* External::Cast(v8::Value* value) {
#ifdef V8_ENABLE_CHECKS
CheckCast(value);
......@@ -4819,15 +4770,6 @@ void* Isolate::GetData() {
}
Local<Value> Context::GetData() {
return GetEmbedderData(0);
}
void Context::SetData(Handle<Value> data) {
SetEmbedderData(0, data);
}
Local<Value> Context::GetEmbedderData(int index) {
#ifndef V8_ENABLE_CHECKS
typedef internal::Object O;
......
......@@ -4435,14 +4435,6 @@ static void* ExternalValue(i::Object* obj) {
}
void* Object::GetPointerFromInternalField(int index) {
i::Handle<i::JSObject> obj = Utils::OpenHandle(this);
const char* location = "v8::Object::GetPointerFromInternalField()";
if (!InternalFieldOK(obj, index, location)) return NULL;
return ExternalValue(obj->GetInternalField(index));
}
// --- E n v i r o n m e n t ---
......
......@@ -25,9 +25,6 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// We want to test our deprecated API entries, too.
#define V8_DISABLE_DEPRECATIONS 1
#include <limits.h>
#ifndef WIN32
......@@ -887,7 +884,7 @@ THREADED_TEST(FunctionTemplateSetLength) {
static void* expected_ptr;
static v8::Handle<v8::Value> callback(const v8::Arguments& args) {
void* ptr = v8::External::Unwrap(args.Data());
void* ptr = v8::External::Cast(*args.Data())->Value();
CHECK_EQ(expected_ptr, ptr);
return v8::True();
}
......@@ -897,7 +894,7 @@ static void TestExternalPointerWrapping() {
v8::HandleScope scope;
LocalContext env;
v8::Handle<v8::Value> data = v8::External::Wrap(expected_ptr);
v8::Handle<v8::Value> data = v8::External::New(expected_ptr);
v8::Handle<v8::Object> obj = v8::Object::New();
obj->Set(v8_str("func"),
......@@ -2025,82 +2022,12 @@ THREADED_TEST(GlobalObjectInternalFields) {
}
THREADED_TEST(InternalFieldsNativePointers) {
v8::HandleScope scope;
LocalContext env;
Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New();
Local<v8::ObjectTemplate> instance_templ = templ->InstanceTemplate();
instance_templ->SetInternalFieldCount(1);
Local<v8::Object> obj = templ->GetFunction()->NewInstance();
CHECK_EQ(1, obj->InternalFieldCount());
CHECK(obj->GetPointerFromInternalField(0) == NULL);
char* data = new char[100];
void* aligned = data;
CHECK_EQ(0, static_cast<int>(reinterpret_cast<uintptr_t>(aligned) & 0x1));
void* unaligned = data + 1;
CHECK_EQ(1, static_cast<int>(reinterpret_cast<uintptr_t>(unaligned) & 0x1));
// Check reading and writing aligned pointers.
obj->SetPointerInInternalField(0, aligned);
HEAP->CollectAllGarbage(i::Heap::kNoGCFlags);
CHECK_EQ(aligned, obj->GetPointerFromInternalField(0));
// Check reading and writing unaligned pointers.
obj->SetPointerInInternalField(0, unaligned);
HEAP->CollectAllGarbage(i::Heap::kNoGCFlags);
CHECK_EQ(unaligned, obj->GetPointerFromInternalField(0));
delete[] data;
}
THREADED_TEST(InternalFieldsNativePointersAndExternal) {
v8::HandleScope scope;
LocalContext env;
Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New();
Local<v8::ObjectTemplate> instance_templ = templ->InstanceTemplate();
instance_templ->SetInternalFieldCount(1);
Local<v8::Object> obj = templ->GetFunction()->NewInstance();
CHECK_EQ(1, obj->InternalFieldCount());
CHECK(obj->GetPointerFromInternalField(0) == NULL);
char* data = new char[100];
void* aligned = data;
CHECK_EQ(0, static_cast<int>(reinterpret_cast<uintptr_t>(aligned) & 0x1));
void* unaligned = data + 1;
CHECK_EQ(1, static_cast<int>(reinterpret_cast<uintptr_t>(unaligned) & 0x1));
obj->SetPointerInInternalField(0, aligned);
HEAP->CollectAllGarbage(i::Heap::kNoGCFlags);
CHECK_EQ(aligned, v8::External::Unwrap(obj->GetInternalField(0)));
obj->SetPointerInInternalField(0, unaligned);
HEAP->CollectAllGarbage(i::Heap::kNoGCFlags);
CHECK_EQ(unaligned, v8::External::Unwrap(obj->GetInternalField(0)));
obj->SetInternalField(0, v8::External::Wrap(aligned));
HEAP->CollectAllGarbage(i::Heap::kNoGCFlags);
CHECK_EQ(aligned, obj->GetPointerFromInternalField(0));
obj->SetInternalField(0, v8::External::Wrap(unaligned));
HEAP->CollectAllGarbage(i::Heap::kNoGCFlags);
CHECK_EQ(unaligned, obj->GetPointerFromInternalField(0));
delete[] data;
}
static void CheckAlignedPointerInInternalField(Handle<v8::Object> obj,
void* value) {
CHECK_EQ(0, static_cast<int>(reinterpret_cast<uintptr_t>(value) & 0x1));
obj->SetPointerInInternalField(0, value);
obj->SetAlignedPointerInInternalField(0, value);
HEAP->CollectAllGarbage(i::Heap::kNoGCFlags);
CHECK_EQ(value, obj->GetPointerFromInternalField(0));
CHECK_EQ(value, obj->GetAlignedPointerFromInternalField(0));
}
......@@ -2355,18 +2282,18 @@ THREADED_TEST(External) {
// Make sure unaligned pointers are wrapped properly.
char* data = i::StrDup("0123456789");
Local<v8::Value> zero = v8::External::Wrap(&data[0]);
Local<v8::Value> one = v8::External::Wrap(&data[1]);
Local<v8::Value> two = v8::External::Wrap(&data[2]);
Local<v8::Value> three = v8::External::Wrap(&data[3]);
Local<v8::Value> zero = v8::External::New(&data[0]);
Local<v8::Value> one = v8::External::New(&data[1]);
Local<v8::Value> two = v8::External::New(&data[2]);
Local<v8::Value> three = v8::External::New(&data[3]);
char* char_ptr = reinterpret_cast<char*>(v8::External::Unwrap(zero));
char* char_ptr = reinterpret_cast<char*>(v8::External::Cast(*zero)->Value());
CHECK_EQ('0', *char_ptr);
char_ptr = reinterpret_cast<char*>(v8::External::Unwrap(one));
char_ptr = reinterpret_cast<char*>(v8::External::Cast(*one)->Value());
CHECK_EQ('1', *char_ptr);
char_ptr = reinterpret_cast<char*>(v8::External::Unwrap(two));
char_ptr = reinterpret_cast<char*>(v8::External::Cast(*two)->Value());
CHECK_EQ('2', *char_ptr);
char_ptr = reinterpret_cast<char*>(v8::External::Unwrap(three));
char_ptr = reinterpret_cast<char*>(v8::External::Cast(*three)->Value());
CHECK_EQ('3', *char_ptr);
i::DeleteArray(data);
}
......@@ -9904,7 +9831,8 @@ THREADED_TEST(InterceptorCallICCachedFromGlobal) {
static v8::Handle<Value> InterceptorCallICFastApi(Local<String> name,
const AccessorInfo& info) {
ApiTestFuzzer::Fuzz();
int* call_count = reinterpret_cast<int*>(v8::External::Unwrap(info.Data()));
int* call_count =
reinterpret_cast<int*>(v8::External::Cast(*info.Data())->Value());
++(*call_count);
if ((*call_count) % 20 == 0) {
HEAP->CollectAllGarbage(i::Heap::kNoGCFlags);
......@@ -10063,7 +9991,7 @@ THREADED_TEST(InterceptorCallICFastApi_TrivialSignature) {
v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate();
templ->SetNamedPropertyHandler(InterceptorCallICFastApi,
NULL, NULL, NULL, NULL,
v8::External::Wrap(&interceptor_call_count));
v8::External::New(&interceptor_call_count));
LocalContext context;
v8::Handle<v8::Function> fun = fun_templ->GetFunction();
GenerateSomeGarbage();
......@@ -10091,7 +10019,7 @@ THREADED_TEST(InterceptorCallICFastApi_SimpleSignature) {
v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate();
templ->SetNamedPropertyHandler(InterceptorCallICFastApi,
NULL, NULL, NULL, NULL,
v8::External::Wrap(&interceptor_call_count));
v8::External::New(&interceptor_call_count));
LocalContext context;
v8::Handle<v8::Function> fun = fun_templ->GetFunction();
GenerateSomeGarbage();
......@@ -10122,7 +10050,7 @@ THREADED_TEST(InterceptorCallICFastApi_SimpleSignature_Miss1) {
v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate();
templ->SetNamedPropertyHandler(InterceptorCallICFastApi,
NULL, NULL, NULL, NULL,
v8::External::Wrap(&interceptor_call_count));
v8::External::New(&interceptor_call_count));
LocalContext context;
v8::Handle<v8::Function> fun = fun_templ->GetFunction();
GenerateSomeGarbage();
......@@ -10159,7 +10087,7 @@ THREADED_TEST(InterceptorCallICFastApi_SimpleSignature_Miss2) {
v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate();
templ->SetNamedPropertyHandler(InterceptorCallICFastApi,
NULL, NULL, NULL, NULL,
v8::External::Wrap(&interceptor_call_count));
v8::External::New(&interceptor_call_count));
LocalContext context;
v8::Handle<v8::Function> fun = fun_templ->GetFunction();
GenerateSomeGarbage();
......@@ -10196,7 +10124,7 @@ THREADED_TEST(InterceptorCallICFastApi_SimpleSignature_Miss3) {
v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate();
templ->SetNamedPropertyHandler(InterceptorCallICFastApi,
NULL, NULL, NULL, NULL,
v8::External::Wrap(&interceptor_call_count));
v8::External::New(&interceptor_call_count));
LocalContext context;
v8::Handle<v8::Function> fun = fun_templ->GetFunction();
GenerateSomeGarbage();
......@@ -10236,7 +10164,7 @@ THREADED_TEST(InterceptorCallICFastApi_SimpleSignature_TypeError) {
v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate();
templ->SetNamedPropertyHandler(InterceptorCallICFastApi,
NULL, NULL, NULL, NULL,
v8::External::Wrap(&interceptor_call_count));
v8::External::New(&interceptor_call_count));
LocalContext context;
v8::Handle<v8::Function> fun = fun_templ->GetFunction();
GenerateSomeGarbage();
......@@ -15472,7 +15400,7 @@ TEST(Regress528) {
context->Enter();
Local<v8::String> obj = v8::String::New("");
context->SetData(obj);
context->SetEmbedderData(0, obj);
CompileRun(source_simple);
context->Exit();
}
......
......@@ -27,9 +27,6 @@
#ifdef ENABLE_DEBUGGER_SUPPORT
// TODO(svenpanne): Do not use Context::GetData and Context::SetData.
#define V8_DISABLE_DEPRECATIONS 1
#include <stdlib.h>
#include "v8.h"
......@@ -6222,7 +6219,7 @@ static v8::Handle<v8::Value> expected_context_data;
// Check that the expected context is the one generating the debug event.
static void ContextCheckMessageHandler(const v8::Debug::Message& message) {
CHECK(message.GetEventContext() == expected_context);
CHECK(message.GetEventContext()->GetData()->StrictEquals(
CHECK(message.GetEventContext()->GetEmbedderData(0)->StrictEquals(
expected_context_data));
message_handler_hit_count++;
......@@ -6255,16 +6252,16 @@ TEST(ContextData) {
context_2 = v8::Context::New(NULL, global_template, global_object);
// Default data value is undefined.
CHECK(context_1->GetData()->IsUndefined());
CHECK(context_2->GetData()->IsUndefined());
CHECK(context_1->GetEmbedderData(0)->IsUndefined());
CHECK(context_2->GetEmbedderData(0)->IsUndefined());
// Set and check different data values.
v8::Handle<v8::String> data_1 = v8::String::New("1");
v8::Handle<v8::String> data_2 = v8::String::New("2");
context_1->SetData(data_1);
context_2->SetData(data_2);
CHECK(context_1->GetData()->StrictEquals(data_1));
CHECK(context_2->GetData()->StrictEquals(data_2));
context_1->SetEmbedderData(0, data_1);
context_2->SetEmbedderData(0, data_2);
CHECK(context_1->GetEmbedderData(0)->StrictEquals(data_1));
CHECK(context_2->GetEmbedderData(0)->StrictEquals(data_2));
// Simple test function which causes a break.
const char* source = "function f() { debugger; }";
......@@ -6419,12 +6416,12 @@ static void ExecuteScriptForContextCheck() {
context_1 = v8::Context::New(NULL, global_template);
// Default data value is undefined.
CHECK(context_1->GetData()->IsUndefined());
CHECK(context_1->GetEmbedderData(0)->IsUndefined());
// Set and check a data value.
v8::Handle<v8::String> data_1 = v8::String::New("1");
context_1->SetData(data_1);
CHECK(context_1->GetData()->StrictEquals(data_1));
context_1->SetEmbedderData(0, data_1);
CHECK(context_1->GetEmbedderData(0)->StrictEquals(data_1));
// Simple test function with eval that causes a break.
const char* source = "function f() { eval('debugger;'); }";
......@@ -6465,7 +6462,7 @@ static int continue_command_send_count = 0;
static void DebugEvalContextCheckMessageHandler(
const v8::Debug::Message& message) {
CHECK(message.GetEventContext() == expected_context);
CHECK(message.GetEventContext()->GetData()->StrictEquals(
CHECK(message.GetEventContext()->GetEmbedderData(0)->StrictEquals(
expected_context_data));
message_handler_hit_count++;
......
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