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 "allocation.h"
14 // The list of accessor descriptors. This is a second-order macro
15 // taking a macro to be applied to all accessor descriptor names.
16 #define ACCESSOR_INFO_LIST(V) \
18 V(FunctionArguments) \
22 V(FunctionPrototype) \
23 V(ScriptColumnOffset) \
24 V(ScriptCompilationType) \
25 V(ScriptContextData) \
26 V(ScriptEvalFromScript) \
27 V(ScriptEvalFromScriptPosition) \
28 V(ScriptEvalFromFunctionName) \
37 // Accessors contains all predefined proxy accessors.
39 class Accessors : public AllStatic {
41 // Accessor descriptors.
42 #define ACCESSOR_INFO_DECLARATION(name) \
43 static void name##Getter( \
44 v8::Local<v8::String> name, \
45 const v8::PropertyCallbackInfo<v8::Value>& info); \
46 static void name##Setter( \
47 v8::Local<v8::String> name, \
48 v8::Local<v8::Value> value, \
49 const v8::PropertyCallbackInfo<void>& info); \
50 static Handle<AccessorInfo> name##Info( \
52 PropertyAttributes attributes);
53 ACCESSOR_INFO_LIST(ACCESSOR_INFO_DECLARATION)
54 #undef ACCESSOR_INFO_DECLARATION
57 #define ACCESSOR_INFO_DECLARATION(name) \
60 ACCESSOR_INFO_LIST(ACCESSOR_INFO_DECLARATION)
61 #undef ACCESSOR_INFO_DECLARATION
65 // Accessor functions called directly from the runtime system.
66 static Handle<Object> FunctionSetPrototype(Handle<JSFunction> object,
67 Handle<Object> value);
68 static Handle<Object> FunctionGetPrototype(Handle<JSFunction> object);
69 static Handle<Object> FunctionGetArguments(Handle<JSFunction> object);
72 static Handle<AccessorInfo> MakeModuleExport(
73 Handle<String> name, int index, PropertyAttributes attributes);
75 // Returns true for properties that are accessors to object fields.
76 // If true, *object_offset contains offset of object field.
78 static bool IsJSObjectFieldAccessor(typename T::TypeHandle type,
82 static Handle<AccessorInfo> MakeAccessor(
85 AccessorGetterCallback getter,
86 AccessorSetterCallback setter,
87 PropertyAttributes attributes);
91 static Handle<Object> FlattenNumber(Isolate* isolate, Handle<Object> value);
94 } } // namespace v8::internal
96 #endif // V8_ACCESSORS_H_