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

Side by Side Diff: src/accessors.h

Issue 2397603003: [runtime] Let native setters have a return value. (Closed)
Patch Set: Ouch. Created 4 years, 1 month 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
« no previous file with comments | « no previous file | src/accessors.cc » ('j') | 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 #ifndef V8_ACCESSORS_H_ 5 #ifndef V8_ACCESSORS_H_
6 #define V8_ACCESSORS_H_ 6 #define V8_ACCESSORS_H_
7 7
8 #include "include/v8.h" 8 #include "include/v8.h"
9 #include "src/allocation.h" 9 #include "src/allocation.h"
10 #include "src/globals.h" 10 #include "src/globals.h"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 v8::Local<v8::Name> name, \ 64 v8::Local<v8::Name> name, \
65 const v8::PropertyCallbackInfo<v8::Value>& info); \ 65 const v8::PropertyCallbackInfo<v8::Value>& info); \
66 static Handle<AccessorInfo> name##Info( \ 66 static Handle<AccessorInfo> name##Info( \
67 Isolate* isolate, \ 67 Isolate* isolate, \
68 PropertyAttributes attributes); 68 PropertyAttributes attributes);
69 ACCESSOR_INFO_LIST(ACCESSOR_INFO_DECLARATION) 69 ACCESSOR_INFO_LIST(ACCESSOR_INFO_DECLARATION)
70 #undef ACCESSOR_INFO_DECLARATION 70 #undef ACCESSOR_INFO_DECLARATION
71 71
72 #define ACCESSOR_SETTER_DECLARATION(name) \ 72 #define ACCESSOR_SETTER_DECLARATION(name) \
73 static void name(v8::Local<v8::Name> name, v8::Local<v8::Value> value, \ 73 static void name(v8::Local<v8::Name> name, v8::Local<v8::Value> value, \
74 const v8::PropertyCallbackInfo<void>& info); 74 const v8::PropertyCallbackInfo<v8::Boolean>& info);
75 ACCESSOR_SETTER_LIST(ACCESSOR_SETTER_DECLARATION) 75 ACCESSOR_SETTER_LIST(ACCESSOR_SETTER_DECLARATION)
76 #undef ACCESSOR_SETTER_DECLARATION 76 #undef ACCESSOR_SETTER_DECLARATION
77 77
78 static void ModuleNamespaceEntryGetter( 78 static void ModuleNamespaceEntryGetter(
79 v8::Local<v8::Name> name, 79 v8::Local<v8::Name> name,
80 const v8::PropertyCallbackInfo<v8::Value>& info); 80 const v8::PropertyCallbackInfo<v8::Value>& info);
81 static Handle<AccessorInfo> ModuleNamespaceEntryInfo( 81 static Handle<AccessorInfo> ModuleNamespaceEntryInfo(
82 Isolate* isolate, Handle<String> name, PropertyAttributes attributes); 82 Isolate* isolate, Handle<String> name, PropertyAttributes attributes);
83 83
84 enum DescriptorId { 84 enum DescriptorId {
85 #define ACCESSOR_INFO_DECLARATION(name) \ 85 #define ACCESSOR_INFO_DECLARATION(name) \
86 k##name##Getter, \ 86 k##name##Getter, \
87 k##name##Setter, 87 k##name##Setter,
88 ACCESSOR_INFO_LIST(ACCESSOR_INFO_DECLARATION) 88 ACCESSOR_INFO_LIST(ACCESSOR_INFO_DECLARATION)
89 #undef ACCESSOR_INFO_DECLARATION 89 #undef ACCESSOR_INFO_DECLARATION
90 descriptorCount 90 descriptorCount
91 }; 91 };
92 92
93 // Accessor functions called directly from the runtime system. 93 // Accessor functions called directly from the runtime system.
94 MUST_USE_RESULT static MaybeHandle<Object> FunctionSetPrototype( 94 MUST_USE_RESULT static MaybeHandle<Object> FunctionSetPrototype(
95 Handle<JSFunction> object, Handle<Object> value); 95 Handle<JSFunction> object, Handle<Object> value);
96 static Handle<JSObject> FunctionGetArguments(Handle<JSFunction> object); 96 static Handle<JSObject> FunctionGetArguments(Handle<JSFunction> object);
97 97
98 // Returns true for properties that are accessors to object fields. 98 // Returns true for properties that are accessors to object fields.
99 // If true, *object_offset contains offset of object field. 99 // If true, *object_offset contains offset of object field.
100 static bool IsJSObjectFieldAccessor(Handle<Map> map, Handle<Name> name, 100 static bool IsJSObjectFieldAccessor(Handle<Map> map, Handle<Name> name,
101 int* object_offset); 101 int* object_offset);
102 102
103 // Create an AccessorInfo. The setter is optional (can be nullptr).
104 //
105 // Note that the type of setter is AccessorNameBooleanSetterCallback instead
106 // of v8::AccessorNameSetterCallback. The difference is that the former can
107 // set a (boolean) return value. The setter should roughly follow the same
108 // conventions as many of the internal methods in objects.cc:
109 // - The return value is unset iff there was an exception.
110 // - If the ShouldThrow argument is true, the return value must not be false.
111 typedef void (*AccessorNameBooleanSetterCallback)(
112 Local<v8::Name> property, Local<v8::Value> value,
113 const PropertyCallbackInfo<v8::Boolean>& info);
114
103 static Handle<AccessorInfo> MakeAccessor( 115 static Handle<AccessorInfo> MakeAccessor(
104 Isolate* isolate, 116 Isolate* isolate, Handle<Name> name, AccessorNameGetterCallback getter,
105 Handle<Name> name, 117 AccessorNameBooleanSetterCallback setter, PropertyAttributes attributes);
106 AccessorNameGetterCallback getter,
107 AccessorNameSetterCallback setter,
108 PropertyAttributes attributes);
109 }; 118 };
110 119
111 } // namespace internal 120 } // namespace internal
112 } // namespace v8 121 } // namespace v8
113 122
114 #endif // V8_ACCESSORS_H_ 123 #endif // V8_ACCESSORS_H_
OLDNEW
« no previous file with comments | « no previous file | src/accessors.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698