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 | |
kasperl@chromium.org | 71affb5 | 2009-05-26 05:44:31 +0000 | [diff] [blame] | 31 | namespace v8 { |
| 32 | namespace internal { |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 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) \ |
kasperl@chromium.org | 7be3c99 | 2009-03-12 07:19:55 +0000 | [diff] [blame] | 46 | V(ScriptId) \ |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 47 | V(ScriptLineOffset) \ |
| 48 | V(ScriptColumnOffset) \ |
ager@chromium.org | 65dad4b | 2009-04-23 08:48:43 +0000 | [diff] [blame] | 49 | V(ScriptData) \ |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 50 | V(ScriptType) \ |
iposva@chromium.org | 245aa85 | 2009-02-10 00:49:54 +0000 | [diff] [blame] | 51 | V(ScriptLineEnds) \ |
ager@chromium.org | 9085a01 | 2009-05-11 19:22:57 +0000 | [diff] [blame] | 52 | V(ScriptContextData) \ |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 53 | V(ObjectPrototype) |
| 54 | |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 55 | // Accessors contains all predefined proxy accessors. |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 56 | |
| 57 | class Accessors : public AllStatic { |
| 58 | public: |
| 59 | // Accessor descriptors. |
| 60 | #define ACCESSOR_DESCRIPTOR_DECLARATION(name) \ |
| 61 | static const AccessorDescriptor name; |
| 62 | ACCESSOR_DESCRIPTOR_LIST(ACCESSOR_DESCRIPTOR_DECLARATION) |
| 63 | #undef ACCESSOR_DESCRIPTOR_DECLARATION |
| 64 | |
| 65 | enum DescriptorId { |
| 66 | #define ACCESSOR_DESCRIPTOR_DECLARATION(name) \ |
| 67 | k##name, |
| 68 | ACCESSOR_DESCRIPTOR_LIST(ACCESSOR_DESCRIPTOR_DECLARATION) |
| 69 | #undef ACCESSOR_DESCRIPTOR_DECLARATION |
| 70 | descriptorCount |
| 71 | }; |
| 72 | |
| 73 | // Accessor functions called directly from the runtime system. |
| 74 | static Object* FunctionGetPrototype(Object* object, void*); |
| 75 | static Object* FunctionSetPrototype(JSObject* object, Object* value, void*); |
| 76 | private: |
| 77 | // Accessor functions only used through the descriptor. |
| 78 | static Object* FunctionGetLength(Object* object, void*); |
| 79 | static Object* FunctionGetName(Object* object, void*); |
| 80 | static Object* FunctionGetArguments(Object* object, void*); |
| 81 | static Object* FunctionGetCaller(Object* object, void*); |
| 82 | static Object* ArraySetLength(JSObject* object, Object* value, void*); |
| 83 | static Object* ArrayGetLength(Object* object, void*); |
| 84 | static Object* StringGetLength(Object* object, void*); |
| 85 | static Object* ScriptGetName(Object* object, void*); |
kasperl@chromium.org | 7be3c99 | 2009-03-12 07:19:55 +0000 | [diff] [blame] | 86 | static Object* ScriptGetId(Object* object, void*); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 87 | static Object* ScriptGetSource(Object* object, void*); |
| 88 | static Object* ScriptGetLineOffset(Object* object, void*); |
| 89 | static Object* ScriptGetColumnOffset(Object* object, void*); |
ager@chromium.org | 65dad4b | 2009-04-23 08:48:43 +0000 | [diff] [blame] | 90 | static Object* ScriptGetData(Object* object, void*); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 91 | static Object* ScriptGetType(Object* object, void*); |
iposva@chromium.org | 245aa85 | 2009-02-10 00:49:54 +0000 | [diff] [blame] | 92 | static Object* ScriptGetLineEnds(Object* object, void*); |
ager@chromium.org | 9085a01 | 2009-05-11 19:22:57 +0000 | [diff] [blame] | 93 | static Object* ScriptGetContextData(Object* object, void*); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 94 | static Object* ObjectGetPrototype(Object* receiver, void*); |
| 95 | static Object* ObjectSetPrototype(JSObject* receiver, Object* value, void*); |
| 96 | |
| 97 | // Helper functions. |
| 98 | static Object* FlattenNumber(Object* value); |
| 99 | static Object* IllegalSetter(JSObject*, Object*, void*); |
| 100 | static Object* IllegalGetAccessor(Object* object, void*); |
| 101 | static Object* ReadOnlySetAccessor(JSObject*, Object* value, void*); |
| 102 | }; |
| 103 | |
| 104 | } } // namespace v8::internal |
| 105 | |
| 106 | #endif // V8_ACCESSORS_H_ |