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
3 // found in the LICENSE file.
5 #ifndef V8_ACCESSORS_H_
6 #define V8_ACCESSORS_H_
8 #include "include/v8.h"
9 #include "src/allocation.h"
10 #include "src/globals.h"
11 #include "src/handles.h"
12 #include "src/property-details.h"
17 // Forward declarations.
18 class ExecutableAccessorInfo;
20 // The list of accessor descriptors. This is a second-order macro
21 // taking a macro to be applied to all accessor descriptor names.
22 #define ACCESSOR_INFO_LIST(V) \
23 V(ArgumentsIterator) \
25 V(FunctionArguments) \
29 V(FunctionPrototype) \
30 V(ScriptColumnOffset) \
31 V(ScriptCompilationType) \
32 V(ScriptContextData) \
33 V(ScriptEvalFromScript) \
34 V(ScriptEvalFromScriptPosition) \
35 V(ScriptEvalFromFunctionName) \
43 V(ScriptSourceMappingUrl) \
44 V(ScriptIsEmbedderDebugScript) \
47 // Accessors contains all predefined proxy accessors.
49 class Accessors : public AllStatic {
51 // Accessor descriptors.
52 #define ACCESSOR_INFO_DECLARATION(name) \
53 static void name##Getter( \
54 v8::Local<v8::Name> name, \
55 const v8::PropertyCallbackInfo<v8::Value>& info); \
56 static void name##Setter( \
57 v8::Local<v8::Name> name, \
58 v8::Local<v8::Value> value, \
59 const v8::PropertyCallbackInfo<void>& info); \
60 static Handle<AccessorInfo> name##Info( \
62 PropertyAttributes attributes);
63 ACCESSOR_INFO_LIST(ACCESSOR_INFO_DECLARATION)
64 #undef ACCESSOR_INFO_DECLARATION
67 #define ACCESSOR_INFO_DECLARATION(name) \
70 ACCESSOR_INFO_LIST(ACCESSOR_INFO_DECLARATION)
71 #undef ACCESSOR_INFO_DECLARATION
75 // Accessor functions called directly from the runtime system.
76 MUST_USE_RESULT static MaybeHandle<Object> FunctionSetPrototype(
77 Handle<JSFunction> object, Handle<Object> value);
78 static Handle<Object> FunctionGetArguments(Handle<JSFunction> object);
81 static Handle<AccessorInfo> MakeModuleExport(
82 Handle<String> name, int index, PropertyAttributes attributes);
84 // Returns true for properties that are accessors to object fields.
85 // If true, *object_offset contains offset of object field.
86 static bool IsJSObjectFieldAccessor(Handle<Map> map, Handle<Name> name,
89 // Returns true for properties that are accessors to ArrayBufferView and
90 // derived classes fields. If true, *object_offset contains offset of
91 // object field. The caller still has to check whether the underlying
92 // buffer was neutered.
93 static bool IsJSArrayBufferViewFieldAccessor(Handle<Map> map,
97 static Handle<AccessorInfo> MakeAccessor(
100 AccessorNameGetterCallback getter,
101 AccessorNameSetterCallback setter,
102 PropertyAttributes attributes);
104 static Handle<ExecutableAccessorInfo> CloneAccessor(
106 Handle<ExecutableAccessorInfo> accessor);
109 } // namespace internal
112 #endif // V8_ACCESSORS_H_