File indexing completed on 2024-05-12 15:43:21

0001 /*
0002  *  This file is part of the KDE libraries
0003  *  Copyright (C) 1999-2000 Harri Porten (porten@kde.org)
0004  *  Copyright (C) 2006 Apple Computer, Inc.
0005  *
0006  *  This library is free software; you can redistribute it and/or
0007  *  modify it under the terms of the GNU Lesser General Public
0008  *  License as published by the Free Software Foundation; either
0009  *  version 2 of the License, or (at your option) any later version.
0010  *
0011  *  This library is distributed in the hope that it will be useful,
0012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
0013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0014  *  Lesser General Public License for more details.
0015  *
0016  *  You should have received a copy of the GNU Lesser General Public
0017  *  License along with this library; if not, write to the Free Software
0018  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
0019  *
0020  */
0021 
0022 #ifndef FUNCTION_OBJECT_H_
0023 #define FUNCTION_OBJECT_H_
0024 
0025 #include "object_object.h"
0026 #include "function.h"
0027 
0028 namespace KJS
0029 {
0030 
0031 /**
0032  * @internal
0033  *
0034  * Class to implement all methods that are properties of the
0035  * Function.prototype object
0036  */
0037 class FunctionProtoFunc : public InternalFunctionImp
0038 {
0039 public:
0040     FunctionProtoFunc(ExecState *, FunctionPrototype *, int i, int len, const Identifier &);
0041 
0042     JSValue *callAsFunction(ExecState *exec, JSObject *thisObj, const List &args) override;
0043 
0044     enum { ToString, Apply, Call, Bind };
0045 private:
0046     int id;
0047 };
0048 
0049 /**
0050  * @internal (but exported for KHTML)
0051  *
0052  * The initial value of the global variable's "Function" property
0053  */
0054 class KJS_EXPORT FunctionObjectImp : public InternalFunctionImp
0055 {
0056 public:
0057     FunctionObjectImp(ExecState *, FunctionPrototype *);
0058     ~FunctionObjectImp() override;
0059 
0060     bool implementsConstruct() const override;
0061     JSObject *construct(ExecState *, const List &args) override;
0062     JSObject *construct(ExecState *, const List &args, const Identifier &functionName, const UString &sourceURL, int lineNumber) override;
0063     JSValue *callAsFunction(ExecState *, JSObject *thisObj, const List &args) override;
0064 };
0065 
0066 } // namespace
0067 
0068 #endif // _FUNCTION_OBJECT_H_