weinig@apple.com | f0ea355 | 2008-07-01 01:11:22 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) |
| 3 | * Copyright (C) 2003, 2006, 2007, 2008 Apple Inc. All rights reserved. |
| 4 | * Copyright (C) 2007 Cameron Zwarich (cwzwarich@uwaterloo.ca) |
| 5 | * Copyright (C) 2007 Maks Orlovich |
| 6 | * |
| 7 | * This library is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU Library General Public |
| 9 | * License as published by the Free Software Foundation; either |
| 10 | * version 2 of the License, or (at your option) any later version. |
| 11 | * |
| 12 | * This library is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | * Library General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU Library General Public License |
| 18 | * along with this library; see the file COPYING.LIB. If not, write to |
| 19 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 20 | * Boston, MA 02110-1301, USA. |
| 21 | * |
| 22 | */ |
| 23 | |
| 24 | #ifndef InternalFunction_h |
| 25 | #define InternalFunction_h |
| 26 | |
oliver@apple.com | 5dea615 | 2010-05-21 18:19:42 +0000 | [diff] [blame] | 27 | #include "JSObjectWithGlobalObject.h" |
cwzwarich@webkit.org | 858b2b6 | 2008-11-05 23:37:21 +0000 | [diff] [blame] | 28 | #include "Identifier.h" |
weinig@apple.com | f0ea355 | 2008-07-01 01:11:22 +0000 | [diff] [blame] | 29 | |
cwzwarich@webkit.org | 3f782f6 | 2008-09-08 01:28:33 +0000 | [diff] [blame] | 30 | namespace JSC { |
weinig@apple.com | f0ea355 | 2008-07-01 01:11:22 +0000 | [diff] [blame] | 31 | |
weinig@apple.com | 0e2d66e | 2008-07-06 05:26:58 +0000 | [diff] [blame] | 32 | class FunctionPrototype; |
weinig@apple.com | f0ea355 | 2008-07-01 01:11:22 +0000 | [diff] [blame] | 33 | |
oliver@apple.com | 5dea615 | 2010-05-21 18:19:42 +0000 | [diff] [blame] | 34 | class InternalFunction : public JSObjectWithGlobalObject { |
weinig@apple.com | 0e2d66e | 2008-07-06 05:26:58 +0000 | [diff] [blame] | 35 | public: |
commit-queue@webkit.org | 6c25c52 | 2011-08-09 20:46:17 +0000 | [diff] [blame] | 36 | typedef JSObjectWithGlobalObject Base; |
| 37 | |
barraclough@apple.com | a5540da | 2011-02-19 21:55:44 +0000 | [diff] [blame] | 38 | static JS_EXPORTDATA const ClassInfo s_info; |
mrowe@apple.com | db57abe | 2008-09-30 19:38:36 +0000 | [diff] [blame] | 39 | |
barraclough@apple.com | b749f0b | 2009-12-07 23:14:04 +0000 | [diff] [blame] | 40 | const UString& name(ExecState*); |
| 41 | const UString displayName(ExecState*); |
| 42 | const UString calculatedDisplayName(ExecState*); |
weinig@apple.com | f0ea355 | 2008-07-01 01:11:22 +0000 | [diff] [blame] | 43 | |
oliver@apple.com | ee1bdc8 | 2011-09-06 21:51:00 +0000 | [diff] [blame] | 44 | static Structure* createStructure(JSGlobalData& globalData, JSGlobalObject* globalObject, JSValue proto) |
mjs@apple.com | 221b475 | 2008-09-22 15:03:52 +0000 | [diff] [blame] | 45 | { |
oliver@apple.com | ee1bdc8 | 2011-09-06 21:51:00 +0000 | [diff] [blame] | 46 | return Structure::create(globalData, globalObject, proto, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount, &s_info); |
mjs@apple.com | 221b475 | 2008-09-22 15:03:52 +0000 | [diff] [blame] | 47 | } |
| 48 | |
weinig@apple.com | 0e2d66e | 2008-07-06 05:26:58 +0000 | [diff] [blame] | 49 | protected: |
oliver@apple.com | e9eda78 | 2009-10-17 01:06:40 +0000 | [diff] [blame] | 50 | static const unsigned StructureFlags = ImplementsHasInstance | JSObject::StructureFlags; |
| 51 | |
oliver@apple.com | 5dea615 | 2010-05-21 18:19:42 +0000 | [diff] [blame] | 52 | // Only used to allow us to determine the JSFunction vptr |
oliver@apple.com | b2fa0dc | 2011-04-15 23:55:42 +0000 | [diff] [blame] | 53 | InternalFunction(VPtrStealingHackType); |
oliver@apple.com | 5dea615 | 2010-05-21 18:19:42 +0000 | [diff] [blame] | 54 | |
ossy@webkit.org | f192b44 | 2011-09-07 07:01:29 +0000 | [diff] [blame^] | 55 | InternalFunction(JSGlobalData*, JSGlobalObject*, Structure*, const Identifier&); |
weinig@apple.com | f0ea355 | 2008-07-01 01:11:22 +0000 | [diff] [blame] | 56 | |
commit-queue@webkit.org | 6e5671b | 2011-09-01 23:49:23 +0000 | [diff] [blame] | 57 | void finishCreation(JSGlobalData&, JSGlobalObject*, const Identifier& name); |
commit-queue@webkit.org | 53aecd2 | 2011-08-19 00:58:34 +0000 | [diff] [blame] | 58 | |
weinig@apple.com | 0e2d66e | 2008-07-06 05:26:58 +0000 | [diff] [blame] | 59 | private: |
| 60 | virtual CallType getCallData(CallData&) = 0; |
barraclough@apple.com | a5540da | 2011-02-19 21:55:44 +0000 | [diff] [blame] | 61 | |
| 62 | virtual void vtableAnchor(); |
weinig@apple.com | 0e2d66e | 2008-07-06 05:26:58 +0000 | [diff] [blame] | 63 | }; |
weinig@apple.com | f0ea355 | 2008-07-01 01:11:22 +0000 | [diff] [blame] | 64 | |
ggaren@apple.com | dc067b6 | 2009-05-01 22:43:39 +0000 | [diff] [blame] | 65 | InternalFunction* asInternalFunction(JSValue); |
darin@apple.com | 5a49442 | 2008-10-18 23:08:12 +0000 | [diff] [blame] | 66 | |
ggaren@apple.com | dc067b6 | 2009-05-01 22:43:39 +0000 | [diff] [blame] | 67 | inline InternalFunction* asInternalFunction(JSValue value) |
darin@apple.com | 5a49442 | 2008-10-18 23:08:12 +0000 | [diff] [blame] | 68 | { |
barraclough@apple.com | a5540da | 2011-02-19 21:55:44 +0000 | [diff] [blame] | 69 | ASSERT(asObject(value)->inherits(&InternalFunction::s_info)); |
darin@apple.com | 5a49442 | 2008-10-18 23:08:12 +0000 | [diff] [blame] | 70 | return static_cast<InternalFunction*>(asObject(value)); |
| 71 | } |
| 72 | |
cwzwarich@webkit.org | 3f782f6 | 2008-09-08 01:28:33 +0000 | [diff] [blame] | 73 | } // namespace JSC |
weinig@apple.com | f0ea355 | 2008-07-01 01:11:22 +0000 | [diff] [blame] | 74 | |
| 75 | #endif // InternalFunction_h |