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