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