00001 // 00002 // Copyright (C) 2007, 2008, 2009, 2010 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 00019 #ifndef GNASH_CLASS_HIERARCHY_H 00020 #define GNASH_CLASS_HIERARCHY_H 00021 00022 #ifdef HAVE_CONFIG_H 00023 #include "gnashconfig.h" 00024 #endif 00025 00026 00027 #ifdef ENABLE_AVM2 00028 # include "SafeStack.h" 00029 # include "Class.h" 00030 # include "Namespace.h" 00031 # include "BoundValues.h" 00032 # include "asException.h" 00033 # include "Method.h" 00034 #endif 00035 00036 #include <map> 00037 #include <string> 00038 #include <list> 00039 #include <vector> 00040 #include <ostream> 00041 00042 namespace gnash { 00043 00044 class Extension; 00045 class as_object; 00046 00048 class ClassHierarchy 00049 { 00050 public: 00051 struct ExtensionClass 00052 { 00054 std::string file_name; 00055 00064 std::string init_name; 00065 00066 const ObjectURI uri; 00067 00069 int version; 00070 }; 00071 00072 struct NativeClass 00073 { 00074 00076 typedef void (*InitFunc)(as_object& obj, const ObjectURI& uri); 00077 00078 NativeClass(InitFunc init, const ObjectURI& u, int ver) 00079 : 00080 initializer(init), 00081 uri(u), 00082 version(ver) 00083 {} 00084 00088 InitFunc initializer; 00089 00091 const ObjectURI uri; 00092 00094 int version; 00095 }; 00096 00100 ClassHierarchy(as_object* global, Extension* e) 00101 : 00102 mGlobal(global), 00103 mExtension(e) 00104 {} 00105 00108 ~ClassHierarchy(); 00109 00110 typedef std::vector<NativeClass> NativeClasses; 00111 00118 bool declareClass(ExtensionClass& c); 00119 00126 bool declareClass(const NativeClass& c); 00127 00129 void declareAll(const NativeClasses& classes); 00130 00132 void markReachableResources() const; 00133 00134 private: 00135 as_object* mGlobal; 00136 Extension* mExtension; 00137 }; 00138 00139 std::ostream& 00140 operator<< (std::ostream& os, const ClassHierarchy::NativeClass& c); 00141 00142 std::ostream& 00143 operator<< (std::ostream& os, const ClassHierarchy::ExtensionClass& c); 00144 00145 } 00146 #endif 00147