| 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) \ |
| 46 V(ScriptSource) \ | 47 V(ScriptSource) \ |
| 47 V(ScriptName) \ | 48 V(ScriptName) \ |
| 48 V(ScriptId) \ | 49 V(ScriptId) \ |
| 49 V(ScriptLineOffset) \ | 50 V(ScriptLineOffset) \ |
| 50 V(ScriptColumnOffset) \ | 51 V(ScriptColumnOffset) \ |
| 51 V(ScriptType) \ | 52 V(ScriptType) \ |
| 52 V(ScriptCompilationType) \ | 53 V(ScriptCompilationType) \ |
| 53 V(ScriptLineEnds) \ | 54 V(ScriptLineEnds) \ |
| 54 V(ScriptContextData) \ | 55 V(ScriptContextData) \ |
| 55 V(ScriptEvalFromScript) \ | 56 V(ScriptEvalFromScript) \ |
| 56 V(ScriptEvalFromScriptPosition) \ | 57 V(ScriptEvalFromScriptPosition) \ |
| 57 V(ScriptEvalFromFunctionName) | 58 V(ScriptEvalFromFunctionName) |
| 58 | 59 |
| 59 #define ACCESSOR_INFO_LIST(V) \ | |
| 60 V(StringLength) \ | |
| 61 | |
| 62 // Accessors contains all predefined proxy accessors. | 60 // Accessors contains all predefined proxy accessors. |
| 63 | 61 |
| 64 class Accessors : public AllStatic { | 62 class Accessors : public AllStatic { |
| 65 public: | 63 public: |
| 66 // Accessor descriptors. | 64 // Accessor descriptors. |
| 67 #define ACCESSOR_DESCRIPTOR_DECLARATION(name) \ | 65 #define ACCESSOR_DESCRIPTOR_DECLARATION(name) \ |
| 68 static const AccessorDescriptor name; | 66 static const AccessorDescriptor name; |
| 69 ACCESSOR_DESCRIPTOR_LIST(ACCESSOR_DESCRIPTOR_DECLARATION) | 67 ACCESSOR_DESCRIPTOR_LIST(ACCESSOR_DESCRIPTOR_DECLARATION) |
| 70 #undef ACCESSOR_DESCRIPTOR_DECLARATION | 68 #undef ACCESSOR_DESCRIPTOR_DECLARATION |
| 71 | 69 |
| 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 | |
| 86 enum DescriptorId { | 70 enum DescriptorId { |
| 87 #define ACCESSOR_DESCRIPTOR_DECLARATION(name) \ | 71 #define ACCESSOR_DESCRIPTOR_DECLARATION(name) \ |
| 88 k##name, | 72 k##name, |
| 89 ACCESSOR_DESCRIPTOR_LIST(ACCESSOR_DESCRIPTOR_DECLARATION) | 73 ACCESSOR_DESCRIPTOR_LIST(ACCESSOR_DESCRIPTOR_DECLARATION) |
| 90 #undef ACCESSOR_DESCRIPTOR_DECLARATION | 74 #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 | |
| 96 descriptorCount | 75 descriptorCount |
| 97 }; | 76 }; |
| 98 | 77 |
| 99 // Accessor functions called directly from the runtime system. | 78 // Accessor functions called directly from the runtime system. |
| 100 static Handle<Object> FunctionSetPrototype(Handle<JSFunction> object, | 79 static Handle<Object> FunctionSetPrototype(Handle<JSFunction> object, |
| 101 Handle<Object> value); | 80 Handle<Object> value); |
| 102 static Handle<Object> FunctionGetPrototype(Handle<JSFunction> object); | 81 static Handle<Object> FunctionGetPrototype(Handle<JSFunction> object); |
| 103 static Handle<Object> FunctionGetArguments(Handle<JSFunction> object); | 82 static Handle<Object> FunctionGetArguments(Handle<JSFunction> object); |
| 104 | 83 |
| 105 // Accessor infos. | 84 // Accessor infos. |
| 106 static Handle<AccessorInfo> MakeModuleExport( | 85 static Handle<AccessorInfo> MakeModuleExport( |
| 107 Handle<String> name, int index, PropertyAttributes attributes); | 86 Handle<String> name, int index, PropertyAttributes attributes); |
| 108 | 87 |
| 109 // Returns true for properties that are accessors to object fields. | 88 // Returns true for properties that are accessors to object fields. |
| 110 // If true, *object_offset contains offset of object field. | 89 // If true, *object_offset contains offset of object field. |
| 111 template <class T> | 90 template <class T> |
| 112 static bool IsJSObjectFieldAccessor(typename T::TypeHandle type, | 91 static bool IsJSObjectFieldAccessor(typename T::TypeHandle type, |
| 113 Handle<String> name, | 92 Handle<String> name, |
| 114 int* object_offset); | 93 int* object_offset); |
| 115 | 94 |
| 95 |
| 116 private: | 96 private: |
| 117 // Accessor functions only used through the descriptor. | 97 // Accessor functions only used through the descriptor. |
| 118 static MaybeObject* FunctionSetPrototype(Isolate* isolate, | 98 static MaybeObject* FunctionSetPrototype(Isolate* isolate, |
| 119 JSObject* object, | 99 JSObject* object, |
| 120 Object*, | 100 Object*, |
| 121 void*); | 101 void*); |
| 122 static MaybeObject* FunctionGetPrototype(Isolate* isolate, | 102 static MaybeObject* FunctionGetPrototype(Isolate* isolate, |
| 123 Object* object, | 103 Object* object, |
| 124 void*); | 104 void*); |
| 125 static MaybeObject* FunctionGetLength(Isolate* isolate, | 105 static MaybeObject* FunctionGetLength(Isolate* isolate, |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 static Object* IllegalGetAccessor(Isolate* isolate, Object* object, void*); | 156 static Object* IllegalGetAccessor(Isolate* isolate, Object* object, void*); |
| 177 static MaybeObject* ReadOnlySetAccessor(Isolate* isolate, | 157 static MaybeObject* ReadOnlySetAccessor(Isolate* isolate, |
| 178 JSObject*, | 158 JSObject*, |
| 179 Object* value, | 159 Object* value, |
| 180 void*); | 160 void*); |
| 181 }; | 161 }; |
| 182 | 162 |
| 183 } } // namespace v8::internal | 163 } } // namespace v8::internal |
| 184 | 164 |
| 185 #endif // V8_ACCESSORS_H_ | 165 #endif // V8_ACCESSORS_H_ |
| OLD | NEW |