Commit de5f609d authored by ulan@chromium.org's avatar ulan@chromium.org

Handlify and convert Script accesssors to new API-style accessors.

BUG=
R=yangguo@chromium.org

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@20799 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent e05b58f0
......@@ -54,8 +54,7 @@ static Handle<AccessorInfo> MakeAccessor(Isolate* isolate,
info->set_all_can_read(true);
info->set_all_can_write(true);
info->set_prohibits_overwriting(false);
info->set_name(*factory->length_string());
info->set_property_attributes(attributes);
info->set_name(*name);
Handle<Object> get = v8::FromCData(isolate, getter);
Handle<Object> set = v8::FromCData(isolate, setter);
info->set_getter(*get);
......@@ -294,101 +293,184 @@ Handle<AccessorInfo> Accessors::StringLengthInfo(
//
// Accessors::ScriptSource
// Accessors::ScriptColumnOffset
//
MaybeObject* Accessors::ScriptGetSource(Isolate* isolate,
Object* object,
void*) {
Object* script = JSValue::cast(object)->value();
return Script::cast(script)->source();
void Accessors::ScriptColumnOffsetGetter(
v8::Local<v8::String> name,
const v8::PropertyCallbackInfo<v8::Value>& info) {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate());
DisallowHeapAllocation no_allocation;
HandleScope scope(isolate);
Object* object = *Utils::OpenHandle(*info.This());
Object* res = Script::cast(JSValue::cast(object)->value())->column_offset();
info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(res, isolate)));
}
const AccessorDescriptor Accessors::ScriptSource = {
ScriptGetSource,
IllegalSetter,
0
};
void Accessors::ScriptColumnOffsetSetter(
v8::Local<v8::String> name,
v8::Local<v8::Value> value,
const v8::PropertyCallbackInfo<void>& info) {
UNREACHABLE();
}
Handle<AccessorInfo> Accessors::ScriptColumnOffsetInfo(
Isolate* isolate, PropertyAttributes attributes) {
Handle<String> name(isolate->factory()->InternalizeOneByteString(
STATIC_ASCII_VECTOR("column_offset")));
return MakeAccessor(isolate,
name,
&ScriptColumnOffsetGetter,
&ScriptColumnOffsetSetter,
attributes);
}
//
// Accessors::ScriptName
// Accessors::ScriptId
//
MaybeObject* Accessors::ScriptGetName(Isolate* isolate,
Object* object,
void*) {
Object* script = JSValue::cast(object)->value();
return Script::cast(script)->name();
void Accessors::ScriptIdGetter(
v8::Local<v8::String> name,
const v8::PropertyCallbackInfo<v8::Value>& info) {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate());
DisallowHeapAllocation no_allocation;
HandleScope scope(isolate);
Object* object = *Utils::OpenHandle(*info.This());
Object* id = Script::cast(JSValue::cast(object)->value())->id();
info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(id, isolate)));
}
const AccessorDescriptor Accessors::ScriptName = {
ScriptGetName,
IllegalSetter,
0
};
void Accessors::ScriptIdSetter(
v8::Local<v8::String> name,
v8::Local<v8::Value> value,
const v8::PropertyCallbackInfo<void>& info) {
UNREACHABLE();
}
Handle<AccessorInfo> Accessors::ScriptIdInfo(
Isolate* isolate, PropertyAttributes attributes) {
Handle<String> name(isolate->factory()->InternalizeOneByteString(
STATIC_ASCII_VECTOR("id")));
return MakeAccessor(isolate,
name,
&ScriptIdGetter,
&ScriptIdSetter,
attributes);
}
//
// Accessors::ScriptId
// Accessors::ScriptName
//
MaybeObject* Accessors::ScriptGetId(Isolate* isolate, Object* object, void*) {
Object* script = JSValue::cast(object)->value();
return Script::cast(script)->id();
void Accessors::ScriptNameGetter(
v8::Local<v8::String> name,
const v8::PropertyCallbackInfo<v8::Value>& info) {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate());
DisallowHeapAllocation no_allocation;
HandleScope scope(isolate);
Object* object = *Utils::OpenHandle(*info.This());
Object* source = Script::cast(JSValue::cast(object)->value())->name();
info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(source, isolate)));
}
const AccessorDescriptor Accessors::ScriptId = {
ScriptGetId,
IllegalSetter,
0
};
void Accessors::ScriptNameSetter(
v8::Local<v8::String> name,
v8::Local<v8::Value> value,
const v8::PropertyCallbackInfo<void>& info) {
UNREACHABLE();
}
Handle<AccessorInfo> Accessors::ScriptNameInfo(
Isolate* isolate, PropertyAttributes attributes) {
return MakeAccessor(isolate,
isolate->factory()->name_string(),
&ScriptNameGetter,
&ScriptNameSetter,
attributes);
}
//
// Accessors::ScriptLineOffset
// Accessors::ScriptSource
//
MaybeObject* Accessors::ScriptGetLineOffset(Isolate* isolate,
Object* object,
void*) {
Object* script = JSValue::cast(object)->value();
return Script::cast(script)->line_offset();
void Accessors::ScriptSourceGetter(
v8::Local<v8::String> name,
const v8::PropertyCallbackInfo<v8::Value>& info) {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate());
DisallowHeapAllocation no_allocation;
HandleScope scope(isolate);
Object* object = *Utils::OpenHandle(*info.This());
Object* source = Script::cast(JSValue::cast(object)->value())->source();
info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(source, isolate)));
}
const AccessorDescriptor Accessors::ScriptLineOffset = {
ScriptGetLineOffset,
IllegalSetter,
0
};
void Accessors::ScriptSourceSetter(
v8::Local<v8::String> name,
v8::Local<v8::Value> value,
const v8::PropertyCallbackInfo<void>& info) {
UNREACHABLE();
}
Handle<AccessorInfo> Accessors::ScriptSourceInfo(
Isolate* isolate, PropertyAttributes attributes) {
return MakeAccessor(isolate,
isolate->factory()->source_string(),
&ScriptSourceGetter,
&ScriptSourceSetter,
attributes);
}
//
// Accessors::ScriptColumnOffset
// Accessors::ScriptLineOffset
//
MaybeObject* Accessors::ScriptGetColumnOffset(Isolate* isolate,
Object* object,
void*) {
Object* script = JSValue::cast(object)->value();
return Script::cast(script)->column_offset();
void Accessors::ScriptLineOffsetGetter(
v8::Local<v8::String> name,
const v8::PropertyCallbackInfo<v8::Value>& info) {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate());
DisallowHeapAllocation no_allocation;
HandleScope scope(isolate);
Object* object = *Utils::OpenHandle(*info.This());
Object* res = Script::cast(JSValue::cast(object)->value())->line_offset();
info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(res, isolate)));
}
const AccessorDescriptor Accessors::ScriptColumnOffset = {
ScriptGetColumnOffset,
IllegalSetter,
0
};
void Accessors::ScriptLineOffsetSetter(
v8::Local<v8::String> name,
v8::Local<v8::Value> value,
const v8::PropertyCallbackInfo<void>& info) {
UNREACHABLE();
}
Handle<AccessorInfo> Accessors::ScriptLineOffsetInfo(
Isolate* isolate, PropertyAttributes attributes) {
Handle<String> name(isolate->factory()->InternalizeOneByteString(
STATIC_ASCII_VECTOR("line_offset")));
return MakeAccessor(isolate,
name,
&ScriptLineOffsetGetter,
&ScriptLineOffsetSetter,
attributes);
}
//
......
......@@ -43,11 +43,6 @@ namespace internal {
V(FunctionArguments) \
V(FunctionCaller) \
V(ArrayLength) \
V(ScriptSource) \
V(ScriptName) \
V(ScriptId) \
V(ScriptLineOffset) \
V(ScriptColumnOffset) \
V(ScriptType) \
V(ScriptCompilationType) \
V(ScriptLineEnds) \
......@@ -57,6 +52,11 @@ namespace internal {
V(ScriptEvalFromFunctionName)
#define ACCESSOR_INFO_LIST(V) \
V(ScriptColumnOffset) \
V(ScriptId) \
V(ScriptLineOffset) \
V(ScriptName) \
V(ScriptSource) \
V(StringLength) \
// Accessors contains all predefined proxy accessors.
......@@ -137,16 +137,6 @@ class Accessors : public AllStatic {
Object*,
void*);
static MaybeObject* ArrayGetLength(Isolate* isolate, Object* object, void*);
static MaybeObject* StringGetLength(Isolate* isolate, Object* object, void*);
static MaybeObject* ScriptGetName(Isolate* isolate, Object* object, void*);
static MaybeObject* ScriptGetId(Isolate* isolate, Object* object, void*);
static MaybeObject* ScriptGetSource(Isolate* isolate, Object* object, void*);
static MaybeObject* ScriptGetLineOffset(Isolate* isolate,
Object* object,
void*);
static MaybeObject* ScriptGetColumnOffset(Isolate* isolate,
Object* object,
void*);
static MaybeObject* ScriptGetType(Isolate* isolate, Object* object, void*);
static MaybeObject* ScriptGetCompilationType(Isolate* isolate,
Object* object,
......
......@@ -1682,22 +1682,6 @@ bool Genesis::InstallNatives() {
Handle<Map> script_map = Handle<Map>(script_fun->initial_map());
Map::EnsureDescriptorSlack(script_map, 13);
Handle<Foreign> script_source(
factory()->NewForeign(&Accessors::ScriptSource));
Handle<Foreign> script_name(factory()->NewForeign(&Accessors::ScriptName));
Handle<String> id_string(factory()->InternalizeOneByteString(
STATIC_ASCII_VECTOR("id")));
Handle<Foreign> script_id(factory()->NewForeign(&Accessors::ScriptId));
Handle<String> line_offset_string(
factory()->InternalizeOneByteString(
STATIC_ASCII_VECTOR("line_offset")));
Handle<Foreign> script_line_offset(
factory()->NewForeign(&Accessors::ScriptLineOffset));
Handle<String> column_offset_string(
factory()->InternalizeOneByteString(
STATIC_ASCII_VECTOR("column_offset")));
Handle<Foreign> script_column_offset(
factory()->NewForeign(&Accessors::ScriptColumnOffset));
Handle<String> type_string(factory()->InternalizeOneByteString(
STATIC_ASCII_VECTOR("type")));
Handle<Foreign> script_type(factory()->NewForeign(&Accessors::ScriptType));
......@@ -1733,30 +1717,44 @@ bool Genesis::InstallNatives() {
PropertyAttributes attribs =
static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY);
Handle<AccessorInfo> script_column =
Accessors::ScriptColumnOffsetInfo(isolate(), attribs);
{
CallbacksDescriptor d(
factory()->source_string(), script_source, attribs);
CallbacksDescriptor d(Handle<Name>(Name::cast(script_column->name())),
script_column, attribs);
script_map->AppendDescriptor(&d);
}
Handle<AccessorInfo> script_id =
Accessors::ScriptIdInfo(isolate(), attribs);
{
CallbacksDescriptor d(factory()->name_string(), script_name, attribs);
CallbacksDescriptor d(Handle<Name>(Name::cast(script_id->name())),
script_id, attribs);
script_map->AppendDescriptor(&d);
}
Handle<AccessorInfo> script_name =
Accessors::ScriptNameInfo(isolate(), attribs);
{
CallbacksDescriptor d(id_string, script_id, attribs);
CallbacksDescriptor d(Handle<Name>(Name::cast(script_name->name())),
script_name, attribs);
script_map->AppendDescriptor(&d);
}
Handle<AccessorInfo> script_line =
Accessors::ScriptLineOffsetInfo(isolate(), attribs);
{
CallbacksDescriptor d(line_offset_string, script_line_offset, attribs);
CallbacksDescriptor d(Handle<Name>(Name::cast(script_line->name())),
script_line, attribs);
script_map->AppendDescriptor(&d);
}
Handle<AccessorInfo> script_source =
Accessors::ScriptSourceInfo(isolate(), attribs);
{
CallbacksDescriptor d(
column_offset_string, script_column_offset, attribs);
CallbacksDescriptor d(Handle<Name>(Name::cast(script_source->name())),
script_source, attribs);
script_map->AppendDescriptor(&d);
}
......
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