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

Unified Diff: src/accessors.cc

Issue 232933003: Revert r20652 "Handlify and convert string.length to new API-style accessor." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 8 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/accessors.h ('k') | src/bootstrapper.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/accessors.cc
diff --git a/src/accessors.cc b/src/accessors.cc
index 35fff00230633704a2aefbf3c99880d6a84e647d..8dbd9c96ab2b1a87ed7e4ad583888d5c923664c5 100644
--- a/src/accessors.cc
+++ b/src/accessors.cc
@@ -37,33 +37,11 @@
#include "isolate.h"
#include "list-inl.h"
#include "property-details.h"
-#include "api.h"
namespace v8 {
namespace internal {
-static Handle<AccessorInfo> MakeAccessor(Isolate* isolate,
- Handle<String> name,
- AccessorGetterCallback getter,
- AccessorSetterCallback setter,
- PropertyAttributes attributes) {
- Factory* factory = isolate->factory();
- Handle<ExecutableAccessorInfo> info = factory->NewExecutableAccessorInfo();
- info->set_property_attributes(attributes);
- info->set_all_can_read(true);
- info->set_all_can_write(true);
- info->set_prohibits_overwriting(true);
- info->set_name(*factory->length_string());
- info->set_property_attributes(attributes);
- Handle<Object> get = v8::FromCData(isolate, getter);
- Handle<Object> set = v8::FromCData(isolate, setter);
- info->set_getter(*get);
- if (!(attributes & ReadOnly)) info->set_setter(*set);
- return info;
-}
-
-
template <class C>
static C* FindInstanceOf(Isolate* isolate, Object* obj) {
for (Object* cur = obj; !cur->IsNull(); cur = cur->GetPrototype(isolate)) {
@@ -256,42 +234,24 @@ const AccessorDescriptor Accessors::ArrayLength = {
// Accessors::StringLength
//
-void Accessors::StringLengthGetter(
- 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* value = *Utils::OpenHandle(*info.This());
- Object* result;
- if (value->IsJSValue()) value = JSValue::cast(value)->value();
- if (value->IsString()) {
- result = Smi::FromInt(String::cast(value)->length());
- } else {
- // If object is not a string we return 0 to be compatible with WebKit.
- // Note: Firefox returns the length of ToString(object).
- result = Smi::FromInt(0);
- }
- info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(result, isolate)));
-}
-
-void Accessors::StringLengthSetter(
- v8::Local<v8::String> name,
- v8::Local<v8::Value> value,
- const v8::PropertyCallbackInfo<void>& info) {
- UNREACHABLE();
+MaybeObject* Accessors::StringGetLength(Isolate* isolate,
+ Object* object,
+ void*) {
+ Object* value = object;
+ if (object->IsJSValue()) value = JSValue::cast(object)->value();
+ if (value->IsString()) return Smi::FromInt(String::cast(value)->length());
+ // If object is not a string we return 0 to be compatible with WebKit.
+ // Note: Firefox returns the length of ToString(object).
+ return Smi::FromInt(0);
}
-Handle<AccessorInfo> Accessors::StringLengthInfo(
- Isolate* isolate, PropertyAttributes attributes) {
- return MakeAccessor(isolate,
- isolate->factory()->length_string(),
- &StringLengthGetter,
- &StringLengthSetter,
- attributes);
-}
+const AccessorDescriptor Accessors::StringLength = {
+ StringGetLength,
+ IllegalSetter,
+ 0
+};
//
« no previous file with comments | « src/accessors.h ('k') | src/bootstrapper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698