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

Side by Side Diff: src/accessors.cc

Issue 285643008: Revert PropertyCallbackInfo::This() signature change from r21022. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « include/v8.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "v8.h" 5 #include "v8.h"
6 #include "accessors.h" 6 #include "accessors.h"
7 7
8 #include "compiler.h" 8 #include "compiler.h"
9 #include "contexts.h" 9 #include "contexts.h"
10 #include "deoptimizer.h" 10 #include "deoptimizer.h"
11 #include "execution.h" 11 #include "execution.h"
12 #include "factory.h" 12 #include "factory.h"
13 #include "frames-inl.h" 13 #include "frames-inl.h"
14 #include "isolate.h" 14 #include "isolate.h"
15 #include "list-inl.h" 15 #include "list-inl.h"
16 #include "property-details.h" 16 #include "property-details.h"
17 #include "api.h" 17 #include "api.h"
18 18
19 namespace v8 { 19 namespace v8 {
20 namespace internal { 20 namespace internal {
21 21
22 22
23 // We have a slight impedance mismatch between the external API and the way we
24 // use callbacks internally: Externally, callbacks can only be used with
25 // v8::Object, but internally we even have callbacks on entities which are
26 // higher in the hierarchy, so we can only return i::Object here, not
27 // i::JSObject.
28 Handle<Object> GetThisFrom(const v8::PropertyCallbackInfo<v8::Value>& info) {
29 return Utils::OpenHandle(*v8::Local<v8::Value>(info.This()));
30 }
31
32
23 Handle<AccessorInfo> Accessors::MakeAccessor( 33 Handle<AccessorInfo> Accessors::MakeAccessor(
24 Isolate* isolate, 34 Isolate* isolate,
25 Handle<String> name, 35 Handle<String> name,
26 AccessorGetterCallback getter, 36 AccessorGetterCallback getter,
27 AccessorSetterCallback setter, 37 AccessorSetterCallback setter,
28 PropertyAttributes attributes) { 38 PropertyAttributes attributes) {
29 Factory* factory = isolate->factory(); 39 Factory* factory = isolate->factory();
30 Handle<ExecutableAccessorInfo> info = factory->NewExecutableAccessorInfo(); 40 Handle<ExecutableAccessorInfo> info = factory->NewExecutableAccessorInfo();
31 info->set_property_attributes(attributes); 41 info->set_property_attributes(attributes);
32 info->set_all_can_read(false); 42 info->set_all_can_read(false);
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 return value; 149 return value;
140 } 150 }
141 151
142 152
143 void Accessors::ArrayLengthGetter( 153 void Accessors::ArrayLengthGetter(
144 v8::Local<v8::String> name, 154 v8::Local<v8::String> name,
145 const v8::PropertyCallbackInfo<v8::Value>& info) { 155 const v8::PropertyCallbackInfo<v8::Value>& info) {
146 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); 156 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate());
147 DisallowHeapAllocation no_allocation; 157 DisallowHeapAllocation no_allocation;
148 HandleScope scope(isolate); 158 HandleScope scope(isolate);
149 Object* object = *Utils::OpenHandle(*info.This()); 159 Object* object = *GetThisFrom(info);
150 // Traverse the prototype chain until we reach an array. 160 // Traverse the prototype chain until we reach an array.
151 JSArray* holder = FindInstanceOf<JSArray>(isolate, object); 161 JSArray* holder = FindInstanceOf<JSArray>(isolate, object);
152 Object* result; 162 Object* result;
153 if (holder != NULL) { 163 if (holder != NULL) {
154 result = holder->length(); 164 result = holder->length();
155 } else { 165 } else {
156 result = Smi::FromInt(0); 166 result = Smi::FromInt(0);
157 } 167 }
158 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(result, isolate))); 168 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(result, isolate)));
159 } 169 }
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 // 232 //
223 // Accessors::StringLength 233 // Accessors::StringLength
224 // 234 //
225 235
226 void Accessors::StringLengthGetter( 236 void Accessors::StringLengthGetter(
227 v8::Local<v8::String> name, 237 v8::Local<v8::String> name,
228 const v8::PropertyCallbackInfo<v8::Value>& info) { 238 const v8::PropertyCallbackInfo<v8::Value>& info) {
229 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); 239 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate());
230 DisallowHeapAllocation no_allocation; 240 DisallowHeapAllocation no_allocation;
231 HandleScope scope(isolate); 241 HandleScope scope(isolate);
232 Object* value = *Utils::OpenHandle(*info.This()); 242 Object* value = *GetThisFrom(info);
233 Object* result; 243 Object* result;
234 if (value->IsJSValue()) value = JSValue::cast(value)->value(); 244 if (value->IsJSValue()) value = JSValue::cast(value)->value();
235 if (value->IsString()) { 245 if (value->IsString()) {
236 result = Smi::FromInt(String::cast(value)->length()); 246 result = Smi::FromInt(String::cast(value)->length());
237 } else { 247 } else {
238 // If object is not a string we return 0 to be compatible with WebKit. 248 // If object is not a string we return 0 to be compatible with WebKit.
239 // Note: Firefox returns the length of ToString(object). 249 // Note: Firefox returns the length of ToString(object).
240 result = Smi::FromInt(0); 250 result = Smi::FromInt(0);
241 } 251 }
242 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(result, isolate))); 252 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(result, isolate)));
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after
817 Isolate* isolate = function->GetIsolate(); 827 Isolate* isolate = function->GetIsolate();
818 return SetFunctionPrototype(isolate, function, prototype); 828 return SetFunctionPrototype(isolate, function, prototype);
819 } 829 }
820 830
821 831
822 void Accessors::FunctionPrototypeGetter( 832 void Accessors::FunctionPrototypeGetter(
823 v8::Local<v8::String> name, 833 v8::Local<v8::String> name,
824 const v8::PropertyCallbackInfo<v8::Value>& info) { 834 const v8::PropertyCallbackInfo<v8::Value>& info) {
825 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); 835 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate());
826 HandleScope scope(isolate); 836 HandleScope scope(isolate);
827 Handle<Object> object = Utils::OpenHandle(*info.This()); 837 Handle<Object> object = GetThisFrom(info);
828 Handle<Object> result = GetFunctionPrototype(isolate, object); 838 Handle<Object> result = GetFunctionPrototype(isolate, object);
829 info.GetReturnValue().Set(Utils::ToLocal(result)); 839 info.GetReturnValue().Set(Utils::ToLocal(result));
830 } 840 }
831 841
832 842
833 void Accessors::FunctionPrototypeSetter( 843 void Accessors::FunctionPrototypeSetter(
834 v8::Local<v8::String> name, 844 v8::Local<v8::String> name,
835 v8::Local<v8::Value> val, 845 v8::Local<v8::Value> val,
836 const v8::PropertyCallbackInfo<void>& info) { 846 const v8::PropertyCallbackInfo<void>& info) {
837 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); 847 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate());
(...skipping 19 matching lines...) Expand all
857 // 867 //
858 // Accessors::FunctionLength 868 // Accessors::FunctionLength
859 // 869 //
860 870
861 871
862 void Accessors::FunctionLengthGetter( 872 void Accessors::FunctionLengthGetter(
863 v8::Local<v8::String> name, 873 v8::Local<v8::String> name,
864 const v8::PropertyCallbackInfo<v8::Value>& info) { 874 const v8::PropertyCallbackInfo<v8::Value>& info) {
865 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); 875 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate());
866 HandleScope scope(isolate); 876 HandleScope scope(isolate);
867 Handle<Object> object = Utils::OpenHandle(*info.This()); 877 Handle<Object> object = GetThisFrom(info);
868 MaybeHandle<JSFunction> maybe_function; 878 MaybeHandle<JSFunction> maybe_function;
869 879
870 { 880 {
871 DisallowHeapAllocation no_allocation; 881 DisallowHeapAllocation no_allocation;
872 JSFunction* function = FindInstanceOf<JSFunction>(isolate, *object); 882 JSFunction* function = FindInstanceOf<JSFunction>(isolate, *object);
873 if (function != NULL) maybe_function = Handle<JSFunction>(function); 883 if (function != NULL) maybe_function = Handle<JSFunction>(function);
874 } 884 }
875 885
876 int length = 0; 886 int length = 0;
877 Handle<JSFunction> function; 887 Handle<JSFunction> function;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
915 // 925 //
916 // Accessors::FunctionName 926 // Accessors::FunctionName
917 // 927 //
918 928
919 929
920 void Accessors::FunctionNameGetter( 930 void Accessors::FunctionNameGetter(
921 v8::Local<v8::String> name, 931 v8::Local<v8::String> name,
922 const v8::PropertyCallbackInfo<v8::Value>& info) { 932 const v8::PropertyCallbackInfo<v8::Value>& info) {
923 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); 933 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate());
924 HandleScope scope(isolate); 934 HandleScope scope(isolate);
925 Handle<Object> object = Utils::OpenHandle(*info.This()); 935 Handle<Object> object = GetThisFrom(info);
926 MaybeHandle<JSFunction> maybe_function; 936 MaybeHandle<JSFunction> maybe_function;
927 937
928 { 938 {
929 DisallowHeapAllocation no_allocation; 939 DisallowHeapAllocation no_allocation;
930 JSFunction* function = FindInstanceOf<JSFunction>(isolate, *object); 940 JSFunction* function = FindInstanceOf<JSFunction>(isolate, *object);
931 if (function != NULL) maybe_function = Handle<JSFunction>(function); 941 if (function != NULL) maybe_function = Handle<JSFunction>(function);
932 } 942 }
933 943
934 Handle<JSFunction> function; 944 Handle<JSFunction> function;
935 Handle<Object> result; 945 Handle<Object> result;
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
1064 Handle<Object> Accessors::FunctionGetArguments(Handle<JSFunction> function) { 1074 Handle<Object> Accessors::FunctionGetArguments(Handle<JSFunction> function) {
1065 return GetFunctionArguments(function->GetIsolate(), function); 1075 return GetFunctionArguments(function->GetIsolate(), function);
1066 } 1076 }
1067 1077
1068 1078
1069 void Accessors::FunctionArgumentsGetter( 1079 void Accessors::FunctionArgumentsGetter(
1070 v8::Local<v8::String> name, 1080 v8::Local<v8::String> name,
1071 const v8::PropertyCallbackInfo<v8::Value>& info) { 1081 const v8::PropertyCallbackInfo<v8::Value>& info) {
1072 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); 1082 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate());
1073 HandleScope scope(isolate); 1083 HandleScope scope(isolate);
1074 Handle<Object> object = Utils::OpenHandle(*info.This()); 1084 Handle<Object> object = GetThisFrom(info);
1075 MaybeHandle<JSFunction> maybe_function; 1085 MaybeHandle<JSFunction> maybe_function;
1076 1086
1077 { 1087 {
1078 DisallowHeapAllocation no_allocation; 1088 DisallowHeapAllocation no_allocation;
1079 JSFunction* function = FindInstanceOf<JSFunction>(isolate, *object); 1089 JSFunction* function = FindInstanceOf<JSFunction>(isolate, *object);
1080 if (function != NULL) maybe_function = Handle<JSFunction>(function); 1090 if (function != NULL) maybe_function = Handle<JSFunction>(function);
1081 } 1091 }
1082 1092
1083 Handle<JSFunction> function; 1093 Handle<JSFunction> function;
1084 Handle<Object> result; 1094 Handle<Object> result;
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
1203 } 1213 }
1204 return Handle<JSFunction>(caller); 1214 return Handle<JSFunction>(caller);
1205 } 1215 }
1206 1216
1207 1217
1208 void Accessors::FunctionCallerGetter( 1218 void Accessors::FunctionCallerGetter(
1209 v8::Local<v8::String> name, 1219 v8::Local<v8::String> name,
1210 const v8::PropertyCallbackInfo<v8::Value>& info) { 1220 const v8::PropertyCallbackInfo<v8::Value>& info) {
1211 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); 1221 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate());
1212 HandleScope scope(isolate); 1222 HandleScope scope(isolate);
1213 Handle<Object> object = Utils::OpenHandle(*info.This()); 1223 Handle<Object> object = GetThisFrom(info);
1214 MaybeHandle<JSFunction> maybe_function; 1224 MaybeHandle<JSFunction> maybe_function;
1215 { 1225 {
1216 DisallowHeapAllocation no_allocation; 1226 DisallowHeapAllocation no_allocation;
1217 JSFunction* function = FindInstanceOf<JSFunction>(isolate, *object); 1227 JSFunction* function = FindInstanceOf<JSFunction>(isolate, *object);
1218 if (function != NULL) maybe_function = Handle<JSFunction>(function); 1228 if (function != NULL) maybe_function = Handle<JSFunction>(function);
1219 } 1229 }
1220 Handle<JSFunction> function; 1230 Handle<JSFunction> function;
1221 Handle<Object> result; 1231 Handle<Object> result;
1222 if (maybe_function.ToHandle(&function)) { 1232 if (maybe_function.ToHandle(&function)) {
1223 MaybeHandle<JSFunction> maybe_caller; 1233 MaybeHandle<JSFunction> maybe_caller;
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
1312 info->set_data(Smi::FromInt(index)); 1322 info->set_data(Smi::FromInt(index));
1313 Handle<Object> getter = v8::FromCData(isolate, &ModuleGetExport); 1323 Handle<Object> getter = v8::FromCData(isolate, &ModuleGetExport);
1314 Handle<Object> setter = v8::FromCData(isolate, &ModuleSetExport); 1324 Handle<Object> setter = v8::FromCData(isolate, &ModuleSetExport);
1315 info->set_getter(*getter); 1325 info->set_getter(*getter);
1316 if (!(attributes & ReadOnly)) info->set_setter(*setter); 1326 if (!(attributes & ReadOnly)) info->set_setter(*setter);
1317 return info; 1327 return info;
1318 } 1328 }
1319 1329
1320 1330
1321 } } // namespace v8::internal 1331 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « include/v8.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698