Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 1 | // Copyright 2006-2008 the V8 project authors. All rights reserved. |
| 2 | // Redistribution and use in source and binary forms, with or without |
| 3 | // modification, are permitted provided that the following conditions are |
| 4 | // met: |
| 5 | // |
| 6 | // * Redistributions of source code must retain the above copyright |
| 7 | // notice, this list of conditions and the following disclaimer. |
| 8 | // * Redistributions in binary form must reproduce the above |
| 9 | // copyright notice, this list of conditions and the following |
| 10 | // disclaimer in the documentation and/or other materials provided |
| 11 | // with the distribution. |
| 12 | // * Neither the name of Google Inc. nor the names of its |
| 13 | // contributors may be used to endorse or promote products derived |
| 14 | // from this software without specific prior written permission. |
| 15 | // |
| 16 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 19 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 20 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 21 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | |
| 28 | #ifndef V8_ACCESSORS_H_ |
| 29 | #define V8_ACCESSORS_H_ |
| 30 | |
| 31 | namespace v8 { |
| 32 | namespace internal { |
| 33 | |
| 34 | // The list of accessor descriptors. This is a second-order macro |
| 35 | // taking a macro to be applied to all accessor descriptor names. |
| 36 | #define ACCESSOR_DESCRIPTOR_LIST(V) \ |
| 37 | V(FunctionPrototype) \ |
| 38 | V(FunctionLength) \ |
| 39 | V(FunctionName) \ |
| 40 | V(FunctionArguments) \ |
| 41 | V(FunctionCaller) \ |
| 42 | V(ArrayLength) \ |
| 43 | V(StringLength) \ |
| 44 | V(ScriptSource) \ |
| 45 | V(ScriptName) \ |
| 46 | V(ScriptId) \ |
| 47 | V(ScriptLineOffset) \ |
| 48 | V(ScriptColumnOffset) \ |
| 49 | V(ScriptData) \ |
| 50 | V(ScriptType) \ |
| 51 | V(ScriptCompilationType) \ |
| 52 | V(ScriptLineEnds) \ |
| 53 | V(ScriptContextData) \ |
Steve Block | d0582a6 | 2009-12-15 09:54:21 +0000 | [diff] [blame^] | 54 | V(ScriptEvalFromScript) \ |
| 55 | V(ScriptEvalFromScriptPosition) \ |
| 56 | V(ScriptEvalFromFunctionName) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 57 | V(ObjectPrototype) |
| 58 | |
| 59 | // Accessors contains all predefined proxy accessors. |
| 60 | |
| 61 | class Accessors : public AllStatic { |
| 62 | public: |
| 63 | // Accessor descriptors. |
| 64 | #define ACCESSOR_DESCRIPTOR_DECLARATION(name) \ |
| 65 | static const AccessorDescriptor name; |
| 66 | ACCESSOR_DESCRIPTOR_LIST(ACCESSOR_DESCRIPTOR_DECLARATION) |
| 67 | #undef ACCESSOR_DESCRIPTOR_DECLARATION |
| 68 | |
| 69 | enum DescriptorId { |
| 70 | #define ACCESSOR_DESCRIPTOR_DECLARATION(name) \ |
| 71 | k##name, |
| 72 | ACCESSOR_DESCRIPTOR_LIST(ACCESSOR_DESCRIPTOR_DECLARATION) |
| 73 | #undef ACCESSOR_DESCRIPTOR_DECLARATION |
| 74 | descriptorCount |
| 75 | }; |
| 76 | |
| 77 | // Accessor functions called directly from the runtime system. |
| 78 | static Object* FunctionGetPrototype(Object* object, void*); |
| 79 | static Object* FunctionSetPrototype(JSObject* object, Object* value, void*); |
| 80 | private: |
| 81 | // Accessor functions only used through the descriptor. |
| 82 | static Object* FunctionGetLength(Object* object, void*); |
| 83 | static Object* FunctionGetName(Object* object, void*); |
| 84 | static Object* FunctionGetArguments(Object* object, void*); |
| 85 | static Object* FunctionGetCaller(Object* object, void*); |
| 86 | static Object* ArraySetLength(JSObject* object, Object* value, void*); |
| 87 | static Object* ArrayGetLength(Object* object, void*); |
| 88 | static Object* StringGetLength(Object* object, void*); |
| 89 | static Object* ScriptGetName(Object* object, void*); |
| 90 | static Object* ScriptGetId(Object* object, void*); |
| 91 | static Object* ScriptGetSource(Object* object, void*); |
| 92 | static Object* ScriptGetLineOffset(Object* object, void*); |
| 93 | static Object* ScriptGetColumnOffset(Object* object, void*); |
| 94 | static Object* ScriptGetData(Object* object, void*); |
| 95 | static Object* ScriptGetType(Object* object, void*); |
| 96 | static Object* ScriptGetCompilationType(Object* object, void*); |
| 97 | static Object* ScriptGetLineEnds(Object* object, void*); |
| 98 | static Object* ScriptGetContextData(Object* object, void*); |
Steve Block | d0582a6 | 2009-12-15 09:54:21 +0000 | [diff] [blame^] | 99 | static Object* ScriptGetEvalFromScript(Object* object, void*); |
| 100 | static Object* ScriptGetEvalFromScriptPosition(Object* object, void*); |
| 101 | static Object* ScriptGetEvalFromFunctionName(Object* object, void*); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 102 | static Object* ObjectGetPrototype(Object* receiver, void*); |
| 103 | static Object* ObjectSetPrototype(JSObject* receiver, Object* value, void*); |
| 104 | |
| 105 | // Helper functions. |
| 106 | static Object* FlattenNumber(Object* value); |
| 107 | static Object* IllegalSetter(JSObject*, Object*, void*); |
| 108 | static Object* IllegalGetAccessor(Object* object, void*); |
| 109 | static Object* ReadOnlySetAccessor(JSObject*, Object* value, void*); |
| 110 | }; |
| 111 | |
| 112 | } } // namespace v8::internal |
| 113 | |
| 114 | #endif // V8_ACCESSORS_H_ |