00001 // 00002 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Free Software 00003 // Foundation, Inc 00004 // 00005 // This program is free software; you can redistribute it and/or modify 00006 // it under the terms of the GNU General Public License as published by 00007 // the Free Software Foundation; either version 3 of the License, or 00008 // (at your option) any later version. 00009 // 00010 // This program is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 // GNU General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU General Public License 00016 // along with this program; if not, write to the Free Software 00017 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00018 00019 #ifndef GNASH_AS_FUNCTION_H 00020 #define GNASH_AS_FUNCTION_H 00021 00022 #include <string> 00023 #include "as_object.h" // for inheritance 00024 00025 // Forward declarations 00026 namespace gnash { 00027 class NativeFunction; 00028 class Global_as; 00029 template <typename T> class FunctionArgs; 00030 } 00031 00032 namespace gnash { 00033 00035 // 00061 class as_function : public as_object 00062 { 00063 public: 00064 00066 virtual ~as_function() {} 00067 00068 // Avoid RTTI 00069 as_function* to_function() { return this; } 00070 00074 virtual as_value call(const fn_call& fn) = 0; 00075 00076 virtual const std::string& stringValue() const; 00077 00079 // 00082 // 00087 // 00098 as_object* construct(as_object& newobj, const as_environment& env, 00099 FunctionArgs<as_value>& args); 00100 00102 virtual bool isBuiltin() { return false; } 00103 00105 static NativeFunction* getFunctionConstructor(); 00106 00107 protected: 00108 00110 // 00113 as_function(Global_as& gl); 00114 00115 }; 00116 00117 00119 // 00123 // 00129 as_object* constructInstance(as_function& ctor, const as_environment& env, 00130 FunctionArgs<as_value>& args); 00131 00133 void function_class_init(as_object& global, const ObjectURI& uri); 00134 void registerFunctionNative(as_object& global); 00135 00136 } // gnash namespace 00137 00138 #endif 00139