Update with current status
[gnash.git] / libcore / ClassHierarchy.h
blob8532f1c58bf1bdc6bb7522a9973426b86eedb882
1 //
2 // Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012
3 // Free Software Foundation, Inc.
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 #ifndef GNASH_CLASS_HIERARCHY_H
21 #define GNASH_CLASS_HIERARCHY_H
23 #ifdef HAVE_CONFIG_H
24 #include "gnashconfig.h"
25 #endif
27 #include <string>
28 #include <vector>
30 #include "ObjectURI.h"
32 namespace gnash {
33 class Extension;
34 class as_object;
37 namespace gnash {
39 /// Register all of the ActionScript classes, with their dependencies.
40 class ClassHierarchy
42 public:
43 struct ExtensionClass
45 /// The filename for the library relative to the plugins directory.
46 std::string file_name;
48 /// Initialization function name
49 ///
50 /// The name of the function which will yield the prototype
51 /// object. It should be a function with signature:
52 /// void init_name(as_object &obj);
53 /// which sets its prototype as the member 'name' in the
54 /// object. See extensions/mysql/mysql_db.cpp function
55 /// mysql_class_init
56 std::string init_name;
58 const ObjectURI uri;
60 /// The version at which this should be added.
61 int version;
64 struct NativeClass
67 /// The type of function to use for initialization
68 typedef void (*InitFunc)(as_object& obj, const ObjectURI& uri);
70 NativeClass(InitFunc init, ObjectURI u, int ver)
72 initializer(init),
73 uri(std::move(u)),
74 version(ver)
77 /// The initialization function
78 ///
79 /// See ExtensionClass.init_name for the necessary function.
80 InitFunc initializer;
82 /// The name of the class.
83 const ObjectURI uri;
85 /// The version at which this should be visible.
86 int version;
89 /// \brief
90 /// Construct the declaration object. Later set the global and
91 /// extension objects using setGlobal and setExtension
92 ClassHierarchy(as_object* global)
94 mGlobal(global)
97 /// \brief
98 /// Delete our private namespaces.
99 ~ClassHierarchy();
101 typedef std::vector<NativeClass> NativeClasses;
103 /// Declare an ActionScript class and how to instantiate it from the core.
105 /// @param c
106 /// The NativeClass structure which defines the class.
108 /// @return true, unless the class with c.name already existed.
109 bool declareClass(const NativeClass& c);
111 /// Declare a list of native classes.
112 void declareAll(const NativeClasses& classes);
114 /// Mark objects for garbage collector.
115 void markReachableResources() const {}
117 private:
118 as_object* mGlobal;
122 #endif