1 /* 2 * This file is part of the KDE libraries 3 * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) 4 * Copyright (C) 2006 Apple Computer, Inc. 5 * 6 * This library is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU Lesser General Public 8 * License as published by the Free Software Foundation; either 9 * version 2 of the License, or (at your option) any later version. 10 * 11 * This library is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * Lesser General Public License for more details. 15 * 16 * You should have received a copy of the GNU Lesser General Public 17 * License along with this library; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 * 20 */ 21 22 #ifndef FUNCTION_OBJECT_H_ 23 #define FUNCTION_OBJECT_H_ 24 25 #include "object_object.h" 26 #include "function.h" 27 28 namespace KJS 29 { 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 { 39 public: 40 FunctionProtoFunc(ExecState *, FunctionPrototype *, int i, int len, const Identifier &); 41 42 JSValue *callAsFunction(ExecState *exec, JSObject *thisObj, const List &args) override; 43 44 enum { ToString, Apply, Call, Bind }; 45 private: 46 int id; 47 }; 48 49 /** 50 * @internal (but exported for KHTML) 51 * 52 * The initial value of the global variable's "Function" property 53 */ 54 class KJS_EXPORT FunctionObjectImp : public InternalFunctionImp 55 { 56 public: 57 FunctionObjectImp(ExecState *, FunctionPrototype *); 58 ~FunctionObjectImp() override; 59 60 bool implementsConstruct() const override; 61 JSObject *construct(ExecState *, const List &args) override; 62 JSObject *construct(ExecState *, const List &args, const Identifier &functionName, const UString &sourceURL, int lineNumber) override; 63 JSValue *callAsFunction(ExecState *, JSObject *thisObj, const List &args) override; 64 }; 65 66 } // namespace 67 68 #endif // _FUNCTION_OBJECT_H_ 69