blob: 28e260e30130ddd8c0ae796d663337298fe9cfa1 [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:
barraclough@apple.coma5540da2011-02-19 21:55:44 +000036 static JS_EXPORTDATA const ClassInfo s_info;
mrowe@apple.comdb57abe2008-09-30 19:38:36 +000037
barraclough@apple.comb749f0b2009-12-07 23:14:04 +000038 const UString& name(ExecState*);
39 const UString displayName(ExecState*);
40 const UString calculatedDisplayName(ExecState*);
weinig@apple.comf0ea3552008-07-01 01:11:22 +000041
oliver@apple.comb2fa0dc2011-04-15 23:55:42 +000042 static Structure* createStructure(JSGlobalData& globalData, JSValue proto)
mjs@apple.com221b4752008-09-22 15:03:52 +000043 {
oliver@apple.com90cf7d52011-03-16 20:09:07 +000044 return Structure::create(globalData, proto, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount, &s_info);
mjs@apple.com221b4752008-09-22 15:03:52 +000045 }
46
weinig@apple.com0e2d66e2008-07-06 05:26:58 +000047 protected:
oliver@apple.come9eda782009-10-17 01:06:40 +000048 static const unsigned StructureFlags = ImplementsHasInstance | JSObject::StructureFlags;
49
oliver@apple.com5dea6152010-05-21 18:19:42 +000050 // Only used to allow us to determine the JSFunction vptr
oliver@apple.comb2fa0dc2011-04-15 23:55:42 +000051 InternalFunction(VPtrStealingHackType);
oliver@apple.com5dea6152010-05-21 18:19:42 +000052
oliver@apple.comb2fa0dc2011-04-15 23:55:42 +000053 InternalFunction(JSGlobalData*, JSGlobalObject*, Structure*, const Identifier&);
weinig@apple.comf0ea3552008-07-01 01:11:22 +000054
weinig@apple.com0e2d66e2008-07-06 05:26:58 +000055 private:
56 virtual CallType getCallData(CallData&) = 0;
barraclough@apple.coma5540da2011-02-19 21:55:44 +000057
58 virtual void vtableAnchor();
weinig@apple.com0e2d66e2008-07-06 05:26:58 +000059 };
weinig@apple.comf0ea3552008-07-01 01:11:22 +000060
ggaren@apple.comdc067b62009-05-01 22:43:39 +000061 InternalFunction* asInternalFunction(JSValue);
darin@apple.com5a494422008-10-18 23:08:12 +000062
ggaren@apple.comdc067b62009-05-01 22:43:39 +000063 inline InternalFunction* asInternalFunction(JSValue value)
darin@apple.com5a494422008-10-18 23:08:12 +000064 {
barraclough@apple.coma5540da2011-02-19 21:55:44 +000065 ASSERT(asObject(value)->inherits(&InternalFunction::s_info));
darin@apple.com5a494422008-10-18 23:08:12 +000066 return static_cast<InternalFunction*>(asObject(value));
67 }
68
cwzwarich@webkit.org3f782f62008-09-08 01:28:33 +000069} // namespace JSC
weinig@apple.comf0ea3552008-07-01 01:11:22 +000070
71#endif // InternalFunction_h