ager@chromium.org | 9258b6b | 2008-09-11 09:11:10 +0000 | [diff] [blame] | 1 | // Copyright 2006-2008 the V8 project authors. All rights reserved. |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 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 { namespace internal { |
| 32 | |
| 33 | // The list of accessor descriptors. This is a second-order macro |
| 34 | // taking a macro to be applied to all accessor descriptor names. |
| 35 | #define ACCESSOR_DESCRIPTOR_LIST(V) \ |
| 36 | V(FunctionPrototype) \ |
| 37 | V(FunctionLength) \ |
| 38 | V(FunctionName) \ |
| 39 | V(FunctionArguments) \ |
| 40 | V(FunctionCaller) \ |
| 41 | V(ArrayLength) \ |
| 42 | V(StringLength) \ |
| 43 | V(ScriptSource) \ |
| 44 | V(ScriptName) \ |
| 45 | V(ScriptLineOffset) \ |
| 46 | V(ScriptColumnOffset) \ |
| 47 | V(ScriptType) \ |
| 48 | V(ObjectPrototype) |
| 49 | |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 50 | // Accessors contains all predefined proxy accessors. |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 51 | |
| 52 | class Accessors : public AllStatic { |
| 53 | public: |
| 54 | // Accessor descriptors. |
| 55 | #define ACCESSOR_DESCRIPTOR_DECLARATION(name) \ |
| 56 | static const AccessorDescriptor name; |
| 57 | ACCESSOR_DESCRIPTOR_LIST(ACCESSOR_DESCRIPTOR_DECLARATION) |
| 58 | #undef ACCESSOR_DESCRIPTOR_DECLARATION |
| 59 | |
| 60 | enum DescriptorId { |
| 61 | #define ACCESSOR_DESCRIPTOR_DECLARATION(name) \ |
| 62 | k##name, |
| 63 | ACCESSOR_DESCRIPTOR_LIST(ACCESSOR_DESCRIPTOR_DECLARATION) |
| 64 | #undef ACCESSOR_DESCRIPTOR_DECLARATION |
| 65 | descriptorCount |
| 66 | }; |
| 67 | |
| 68 | // Accessor functions called directly from the runtime system. |
| 69 | static Object* FunctionGetPrototype(Object* object, void*); |
| 70 | static Object* FunctionSetPrototype(JSObject* object, Object* value, void*); |
| 71 | private: |
| 72 | // Accessor functions only used through the descriptor. |
| 73 | static Object* FunctionGetLength(Object* object, void*); |
| 74 | static Object* FunctionGetName(Object* object, void*); |
| 75 | static Object* FunctionGetArguments(Object* object, void*); |
| 76 | static Object* FunctionGetCaller(Object* object, void*); |
| 77 | static Object* ArraySetLength(JSObject* object, Object* value, void*); |
| 78 | static Object* ArrayGetLength(Object* object, void*); |
| 79 | static Object* StringGetLength(Object* object, void*); |
| 80 | static Object* ScriptGetName(Object* object, void*); |
| 81 | static Object* ScriptGetSource(Object* object, void*); |
| 82 | static Object* ScriptGetLineOffset(Object* object, void*); |
| 83 | static Object* ScriptGetColumnOffset(Object* object, void*); |
| 84 | static Object* ScriptGetType(Object* object, void*); |
| 85 | static Object* ObjectGetPrototype(Object* receiver, void*); |
| 86 | static Object* ObjectSetPrototype(JSObject* receiver, Object* value, void*); |
| 87 | |
| 88 | // Helper functions. |
| 89 | static Object* FlattenNumber(Object* value); |
| 90 | static Object* IllegalSetter(JSObject*, Object*, void*); |
| 91 | static Object* IllegalGetAccessor(Object* object, void*); |
| 92 | static Object* ReadOnlySetAccessor(JSObject*, Object* value, void*); |
| 93 | }; |
| 94 | |
| 95 | } } // namespace v8::internal |
| 96 | |
| 97 | #endif // V8_ACCESSORS_H_ |