OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 25 matching lines...) Expand all Loading... |
36 | 36 |
37 // The list of accessor descriptors. This is a second-order macro | 37 // The list of accessor descriptors. This is a second-order macro |
38 // taking a macro to be applied to all accessor descriptor names. | 38 // taking a macro to be applied to all accessor descriptor names. |
39 #define ACCESSOR_DESCRIPTOR_LIST(V) \ | 39 #define ACCESSOR_DESCRIPTOR_LIST(V) \ |
40 V(FunctionPrototype) \ | 40 V(FunctionPrototype) \ |
41 V(FunctionLength) \ | 41 V(FunctionLength) \ |
42 V(FunctionName) \ | 42 V(FunctionName) \ |
43 V(FunctionArguments) \ | 43 V(FunctionArguments) \ |
44 V(FunctionCaller) \ | 44 V(FunctionCaller) \ |
45 V(ArrayLength) \ | 45 V(ArrayLength) \ |
46 V(StringLength) \ | |
47 V(ScriptSource) \ | 46 V(ScriptSource) \ |
48 V(ScriptName) \ | 47 V(ScriptName) \ |
49 V(ScriptId) \ | 48 V(ScriptId) \ |
50 V(ScriptLineOffset) \ | 49 V(ScriptLineOffset) \ |
51 V(ScriptColumnOffset) \ | 50 V(ScriptColumnOffset) \ |
52 V(ScriptType) \ | 51 V(ScriptType) \ |
53 V(ScriptCompilationType) \ | 52 V(ScriptCompilationType) \ |
54 V(ScriptLineEnds) \ | 53 V(ScriptLineEnds) \ |
55 V(ScriptContextData) \ | 54 V(ScriptContextData) \ |
56 V(ScriptEvalFromScript) \ | 55 V(ScriptEvalFromScript) \ |
57 V(ScriptEvalFromScriptPosition) \ | 56 V(ScriptEvalFromScriptPosition) \ |
58 V(ScriptEvalFromFunctionName) | 57 V(ScriptEvalFromFunctionName) |
59 | 58 |
| 59 #define ACCESSOR_INFO_LIST(V) \ |
| 60 V(StringLength) \ |
| 61 |
60 // Accessors contains all predefined proxy accessors. | 62 // Accessors contains all predefined proxy accessors. |
61 | 63 |
62 class Accessors : public AllStatic { | 64 class Accessors : public AllStatic { |
63 public: | 65 public: |
64 // Accessor descriptors. | 66 // Accessor descriptors. |
65 #define ACCESSOR_DESCRIPTOR_DECLARATION(name) \ | 67 #define ACCESSOR_DESCRIPTOR_DECLARATION(name) \ |
66 static const AccessorDescriptor name; | 68 static const AccessorDescriptor name; |
67 ACCESSOR_DESCRIPTOR_LIST(ACCESSOR_DESCRIPTOR_DECLARATION) | 69 ACCESSOR_DESCRIPTOR_LIST(ACCESSOR_DESCRIPTOR_DECLARATION) |
68 #undef ACCESSOR_DESCRIPTOR_DECLARATION | 70 #undef ACCESSOR_DESCRIPTOR_DECLARATION |
69 | 71 |
| 72 #define ACCESSOR_INFO_DECLARATION(name) \ |
| 73 static void name##Getter( \ |
| 74 v8::Local<v8::String> name, \ |
| 75 const v8::PropertyCallbackInfo<v8::Value>& info); \ |
| 76 static void name##Setter( \ |
| 77 v8::Local<v8::String> name, \ |
| 78 v8::Local<v8::Value> value, \ |
| 79 const v8::PropertyCallbackInfo<void>& info); \ |
| 80 static Handle<AccessorInfo> name##Info( \ |
| 81 Isolate* isolate, \ |
| 82 PropertyAttributes attributes); |
| 83 ACCESSOR_INFO_LIST(ACCESSOR_INFO_DECLARATION) |
| 84 #undef ACCESSOR_INFO_DECLARATION |
| 85 |
70 enum DescriptorId { | 86 enum DescriptorId { |
71 #define ACCESSOR_DESCRIPTOR_DECLARATION(name) \ | 87 #define ACCESSOR_DESCRIPTOR_DECLARATION(name) \ |
72 k##name, | 88 k##name, |
73 ACCESSOR_DESCRIPTOR_LIST(ACCESSOR_DESCRIPTOR_DECLARATION) | 89 ACCESSOR_DESCRIPTOR_LIST(ACCESSOR_DESCRIPTOR_DECLARATION) |
74 #undef ACCESSOR_DESCRIPTOR_DECLARATION | 90 #undef ACCESSOR_DESCRIPTOR_DECLARATION |
| 91 #define ACCESSOR_INFO_DECLARATION(name) \ |
| 92 k##name##Getter, \ |
| 93 k##name##Setter, |
| 94 ACCESSOR_INFO_LIST(ACCESSOR_INFO_DECLARATION) |
| 95 #undef ACCESSOR_INFO_DECLARATION |
75 descriptorCount | 96 descriptorCount |
76 }; | 97 }; |
77 | 98 |
78 // Accessor functions called directly from the runtime system. | 99 // Accessor functions called directly from the runtime system. |
79 static Handle<Object> FunctionSetPrototype(Handle<JSFunction> object, | 100 static Handle<Object> FunctionSetPrototype(Handle<JSFunction> object, |
80 Handle<Object> value); | 101 Handle<Object> value); |
81 static Handle<Object> FunctionGetPrototype(Handle<JSFunction> object); | 102 static Handle<Object> FunctionGetPrototype(Handle<JSFunction> object); |
82 static Handle<Object> FunctionGetArguments(Handle<JSFunction> object); | 103 static Handle<Object> FunctionGetArguments(Handle<JSFunction> object); |
83 | 104 |
84 // Accessor infos. | 105 // Accessor infos. |
85 static Handle<AccessorInfo> MakeModuleExport( | 106 static Handle<AccessorInfo> MakeModuleExport( |
86 Handle<String> name, int index, PropertyAttributes attributes); | 107 Handle<String> name, int index, PropertyAttributes attributes); |
87 | 108 |
88 // Returns true for properties that are accessors to object fields. | 109 // Returns true for properties that are accessors to object fields. |
89 // If true, *object_offset contains offset of object field. | 110 // If true, *object_offset contains offset of object field. |
90 template <class T> | 111 template <class T> |
91 static bool IsJSObjectFieldAccessor(typename T::TypeHandle type, | 112 static bool IsJSObjectFieldAccessor(typename T::TypeHandle type, |
92 Handle<String> name, | 113 Handle<String> name, |
93 int* object_offset); | 114 int* object_offset); |
94 | 115 |
95 | |
96 private: | 116 private: |
97 // Accessor functions only used through the descriptor. | 117 // Accessor functions only used through the descriptor. |
98 static MaybeObject* FunctionSetPrototype(Isolate* isolate, | 118 static MaybeObject* FunctionSetPrototype(Isolate* isolate, |
99 JSObject* object, | 119 JSObject* object, |
100 Object*, | 120 Object*, |
101 void*); | 121 void*); |
102 static MaybeObject* FunctionGetPrototype(Isolate* isolate, | 122 static MaybeObject* FunctionGetPrototype(Isolate* isolate, |
103 Object* object, | 123 Object* object, |
104 void*); | 124 void*); |
105 static MaybeObject* FunctionGetLength(Isolate* isolate, | 125 static MaybeObject* FunctionGetLength(Isolate* isolate, |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 static Object* IllegalGetAccessor(Isolate* isolate, Object* object, void*); | 176 static Object* IllegalGetAccessor(Isolate* isolate, Object* object, void*); |
157 static MaybeObject* ReadOnlySetAccessor(Isolate* isolate, | 177 static MaybeObject* ReadOnlySetAccessor(Isolate* isolate, |
158 JSObject*, | 178 JSObject*, |
159 Object* value, | 179 Object* value, |
160 void*); | 180 void*); |
161 }; | 181 }; |
162 | 182 |
163 } } // namespace v8::internal | 183 } } // namespace v8::internal |
164 | 184 |
165 #endif // V8_ACCESSORS_H_ | 185 #endif // V8_ACCESSORS_H_ |
OLD | NEW |