blob: 7461e66ccb5405b70e3b756c5590b1702eb46829 [file] [log] [blame]
weinig@apple.comf0ea3552008-07-01 01:11:22 +00001/*
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.com5dea6152010-05-21 18:19:42 +000027#include "JSObjectWithGlobalObject.h"
cwzwarich@webkit.org858b2b62008-11-05 23:37:21 +000028#include "Identifier.h"
weinig@apple.comf0ea3552008-07-01 01:11:22 +000029
cwzwarich@webkit.org3f782f62008-09-08 01:28:33 +000030namespace JSC {
weinig@apple.comf0ea3552008-07-01 01:11:22 +000031
weinig@apple.com0e2d66e2008-07-06 05:26:58 +000032 class FunctionPrototype;
weinig@apple.comf0ea3552008-07-01 01:11:22 +000033
oliver@apple.com5dea6152010-05-21 18:19:42 +000034 class InternalFunction : public JSObjectWithGlobalObject {
weinig@apple.com0e2d66e2008-07-06 05:26:58 +000035 public:
commit-queue@webkit.org6c25c522011-08-09 20:46:17 +000036 typedef JSObjectWithGlobalObject Base;
37
barraclough@apple.coma5540da2011-02-19 21:55:44 +000038 static JS_EXPORTDATA const ClassInfo s_info;
mrowe@apple.comdb57abe2008-09-30 19:38:36 +000039
barraclough@apple.comb749f0b2009-12-07 23:14:04 +000040 const UString& name(ExecState*);
41 const UString displayName(ExecState*);
42 const UString calculatedDisplayName(ExecState*);
weinig@apple.comf0ea3552008-07-01 01:11:22 +000043
oliver@apple.comee1bdc82011-09-06 21:51:00 +000044 static Structure* createStructure(JSGlobalData& globalData, JSGlobalObject* globalObject, JSValue proto)
mjs@apple.com221b4752008-09-22 15:03:52 +000045 {
oliver@apple.comee1bdc82011-09-06 21:51:00 +000046 return Structure::create(globalData, globalObject, proto, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount, &s_info);
mjs@apple.com221b4752008-09-22 15:03:52 +000047 }
48
weinig@apple.com0e2d66e2008-07-06 05:26:58 +000049 protected:
oliver@apple.come9eda782009-10-17 01:06:40 +000050 static const unsigned StructureFlags = ImplementsHasInstance | JSObject::StructureFlags;
51
oliver@apple.com5dea6152010-05-21 18:19:42 +000052 // Only used to allow us to determine the JSFunction vptr
oliver@apple.comb2fa0dc2011-04-15 23:55:42 +000053 InternalFunction(VPtrStealingHackType);
oliver@apple.com5dea6152010-05-21 18:19:42 +000054
ossy@webkit.orgf192b442011-09-07 07:01:29 +000055 InternalFunction(JSGlobalData*, JSGlobalObject*, Structure*, const Identifier&);
weinig@apple.comf0ea3552008-07-01 01:11:22 +000056
commit-queue@webkit.org6e5671b2011-09-01 23:49:23 +000057 void finishCreation(JSGlobalData&, JSGlobalObject*, const Identifier& name);
commit-queue@webkit.org53aecd22011-08-19 00:58:34 +000058
weinig@apple.com0e2d66e2008-07-06 05:26:58 +000059 private:
60 virtual CallType getCallData(CallData&) = 0;
barraclough@apple.coma5540da2011-02-19 21:55:44 +000061
62 virtual void vtableAnchor();
weinig@apple.com0e2d66e2008-07-06 05:26:58 +000063 };
weinig@apple.comf0ea3552008-07-01 01:11:22 +000064
ggaren@apple.comdc067b62009-05-01 22:43:39 +000065 InternalFunction* asInternalFunction(JSValue);
darin@apple.com5a494422008-10-18 23:08:12 +000066
ggaren@apple.comdc067b62009-05-01 22:43:39 +000067 inline InternalFunction* asInternalFunction(JSValue value)
darin@apple.com5a494422008-10-18 23:08:12 +000068 {
barraclough@apple.coma5540da2011-02-19 21:55:44 +000069 ASSERT(asObject(value)->inherits(&InternalFunction::s_info));
darin@apple.com5a494422008-10-18 23:08:12 +000070 return static_cast<InternalFunction*>(asObject(value));
71 }
72
cwzwarich@webkit.org3f782f62008-09-08 01:28:33 +000073} // namespace JSC
weinig@apple.comf0ea3552008-07-01 01:11:22 +000074
75#endif // InternalFunction_h