1// -*- c-basic-offset: 2 -*-
2/*
3 * This file is part of the KDE libraries
4 * Copyright (C) 1999-2000 Harri Porten (porten@kde.org)
5 * Copyright (C) 2006 Apple Computer, Inc.
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser 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 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 *
21 */
22
23#ifndef FUNCTION_OBJECT_H_
24#define FUNCTION_OBJECT_H_
25
26#include "object_object.h"
27#include "function.h"
28
29namespace KJS {
30
31 /**
32 * @internal
33 *
34 * Class to implement all methods that are properties of the
35 * Function.prototype object
36 */
37 class FunctionProtoFunc : public InternalFunctionImp {
38 public:
39 FunctionProtoFunc(ExecState*, FunctionPrototype*, int i, int len, const Identifier&);
40
41 virtual JSValue *callAsFunction(ExecState *exec, JSObject *thisObj, const List &args);
42
43 enum { ToString, Apply, Call, Bind };
44 private:
45 int id;
46 };
47
48 /**
49 * @internal
50 *
51 * The initial value of the global variable's "Function" property
52 */
53 class FunctionObjectImp : public InternalFunctionImp {
54 public:
55 FunctionObjectImp(ExecState*, FunctionPrototype*);
56 virtual ~FunctionObjectImp();
57
58 virtual bool implementsConstruct() const;
59 virtual JSObject* construct(ExecState*, const List& args);
60 virtual JSObject* construct(ExecState*, const List& args, const Identifier& functionName, const UString& sourceURL, int lineNumber);
61 virtual JSValue* callAsFunction(ExecState*, JSObject* thisObj, const List& args);
62 };
63
64} // namespace
65
66#endif // _FUNCTION_OBJECT_H_
67