as_function.h

Go to the documentation of this file.
00001 // 
00002 //   Copyright (C) 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
00003 // 
00004 // This program is free software; you can redistribute it and/or modify
00005 // it under the terms of the GNU General Public License as published by
00006 // the Free Software Foundation; either version 3 of the License, or
00007 // (at your option) any later version.
00008 // 
00009 // This program is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 // GNU General Public License for more details.
00013 // 
00014 // You should have received a copy of the GNU General Public License
00015 // along with this program; if not, write to the Free Software
00016 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00017 
00018 #ifndef _GNASH_AS_FUNCTION_H_
00019 #define _GNASH_AS_FUNCTION_H_
00020 
00021 #ifdef HAVE_CONFIG_H
00022 #include "gnashconfig.h"
00023 #endif
00024 
00025 #include "as_object.h" // for inheritance
00026 
00027 // Forward declarations
00028 namespace gnash {
00029         class fn_call;
00030         class builtin_function;
00031 }
00032 
00033 namespace gnash {
00034 
00036 //
00065 class as_function : public as_object
00066 {
00067 public:
00068 
00070         virtual ~as_function() {}
00071 
00072         // Avoid RTTI
00073         as_function* to_function() { return this; }
00074 
00076         virtual as_value operator()(const fn_call& fn)=0;
00077 
00079         as_value call(const fn_call& fn) { return operator()(fn); }
00080 
00082         // 
00098         boost::intrusive_ptr<as_object> constructInstance( as_environment& env,
00099                         unsigned nargs, unsigned first_arg_index);
00100 
00103         boost::intrusive_ptr<as_object> getPrototype();
00104 
00106         void extends(as_function& superclass);
00107 
00109         virtual bool isBuiltin()  { return false; }
00110 
00113         std::string get_text_value() const
00114         {
00115                 return "[type Function]";
00116         }
00117 
00119         static boost::intrusive_ptr<builtin_function> getFunctionConstructor();
00120 
00121 #ifdef GNASH_USE_GC
00123         //
00131         virtual void markReachableResources() const
00132         {
00133                 markAsFunctionReachable();
00134         }
00135 #endif // GNASH_USE_GC
00136 
00137 protected:
00138 
00139 #ifdef GNASH_USE_GC
00142         //
00146         void markAsFunctionReachable() const
00147         {
00148                 //_properties->setReachable();
00149 
00150                 markAsObjectReachable();
00151         }
00152 #endif // GNASH_USE_GC
00153 
00155         //
00159         as_function();
00160 
00162         //
00170         as_function(as_object* iface);
00171 
00173         //
00178         //boost::intrusive_ptr<as_object>       _properties;
00179 
00180 private:
00181 
00182         void setPrototype(as_object* proto);
00183 };
00184 
00186 void function_class_init(as_object& global);
00187 
00188 // To be made statics instead
00189 as_value function_apply(const fn_call& fn);
00190 as_value function_call(const fn_call& fn);
00191 
00192 
00193 } // end of gnash namespace
00194 
00195 // _GNASH_AS_FUNCTION_H_
00196 #endif
00197 

Generated on Thu Mar 6 18:25:06 2008 for Gnash by  doxygen 1.5.4