~ubuntu-branches/ubuntu/saucy/gnash/saucy-proposed

« back to all changes in this revision

Viewing changes to libcore/asobj/ClassHierarchy.h

  • Committer: Bazaar Package Importer
  • Author(s): Alexander Sack
  • Date: 2008-10-13 14:29:49 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: james.westby@ubuntu.com-20081013142949-f6qdvnu4mn05ltdc
Tags: 0.8.4~~bzr9980-0ubuntu1
* new upstream release 0.8.4 (LP: #240325)
* ship new lib usr/lib/gnash/libmozsdk.so.* in mozilla-plugin-gnash
  - update debian/mozilla-plugin-gnash.install
* ship new lib usr/lib/gnash/libgnashnet.so.* in gnash-common
  - update debian/gnash-common.install
* add basic debian/build_head script to build latest CVS head packages.
  - add debian/build_head
* new sound architecture requires build depend on libsdl1.2-dev
  - update debian/control
* head build script now has been completely migrated to bzr (upstream +
  ubuntu)
  - update debian/build_head
* disable kde gui until klash/qt4 has been fixed; keep kde packages as empty
  packages for now.
  - update debian/rules
  - debian/klash.install
  - debian/klash.links
  - debian/klash.manpages
  - debian/konqueror-plugin-gnash.install
* drop libkonq5-dev build dependency accordingly
  - update debian/control
* don't install headers manually anymore. gnash doesnt provide a -dev
  package after all
  - update debian/rules
* update libs installed in gnash-common; libgnashserver-*.so is not available
  anymore (removed); in turn we add the new libgnashcore-*.so
  - update debian/gnash-common.install
* use -Os for optimization and properly pass CXXFLAGS=$(CFLAGS) to configure
  - update debian/rules
* touch firefox .autoreg in postinst of mozilla plugin
  - update debian/mozilla-plugin-gnash.postinst
* link gnash in ubufox plugins directory for the plugin alternative switcher
  - add debian/mozilla-plugin-gnash.links
* suggest ubufox accordingly
  - update debian/control
* add new required build-depends on libgif-dev
  - update debian/control
* add Xb-Npp-Description and Xb-Npp-File as new plugin database meta data
  - update debian/control

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// 
 
2
//   Copyright (C) 2007, 2008 Free Software Foundation, Inc.
 
3
//
 
4
// This program is free software; you can redistribute it and/or modify
 
5
// it under the terms of the GNU General Public License as published by
 
6
// the Free Software Foundation; either version 3 of the License, or
 
7
// (at your option) any later version.
 
8
//
 
9
// This program is distributed in the hope that it will be useful,
 
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
// GNU General Public License for more details.
 
13
//
 
14
// You should have received a copy of the GNU General Public License
 
15
// along with this program; if not, write to the Free Software
 
16
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
17
//
 
18
 
 
19
#ifndef GNASH_CLASS_HIERARCHY_H
 
20
#define GNASH_CLASS_HIERARCHY_H
 
21
 
 
22
#include <list>
 
23
#include <vector>
 
24
#include <ostream>
 
25
 
 
26
#include "as_object.h"
 
27
#include "asClass.h"
 
28
#include "SafeStack.h"
 
29
 
 
30
namespace gnash {
 
31
 
 
32
class Extension;
 
33
class asClass;
 
34
class asMethod;
 
35
class asException;
 
36
class asBoundValue;
 
37
class asBoundAccessor;
 
38
class as_object;
 
39
 
 
40
/// Register all of the ActionScript classes, with their dependencies.
 
41
class ClassHierarchy
 
42
{
 
43
public:
 
44
        struct extensionClass
 
45
        {
 
46
                /// \brief
 
47
                /// The file name which contains the library, relative to the 
 
48
                /// plugins directory.
 
49
                std::string file_name;
 
50
 
 
51
                /// \brief Initialization function name
 
52
                ///
 
53
                /// The name of the function which will yield the prototype
 
54
                /// object. It should be a function with signature:
 
55
                /// void init_name(as_object &obj);
 
56
                /// which sets its prototype as the member 'name' in the
 
57
                /// object. See extensions/mysql/mysql_db.cpp function
 
58
                /// mysql_class_init
 
59
                std::string init_name;
 
60
 
 
61
                /// \brief The name of the class.
 
62
                string_table::key name;
 
63
 
 
64
                /// \brief
 
65
                /// The name of the inherited class.
 
66
                /// Ordinarily should be CLASS_OBJECT
 
67
                string_table::key super_name;
 
68
 
 
69
                /// \brief
 
70
                /// The name of the namespace in which this belongs.
 
71
                string_table::key namespace_name;
 
72
 
 
73
                /// \brief
 
74
                /// The version at which this should be added.
 
75
                int version;
 
76
        };
 
77
 
 
78
        struct nativeClass
 
79
        {
 
80
                /// The type of function to use for initing.
 
81
                typedef void (*init_func)(as_object& obj);
 
82
 
 
83
                /// \brief
 
84
                /// The initialization function
 
85
                ///
 
86
                /// See extensionClass.init_name for the necessary function.
 
87
                init_func initializer;
 
88
 
 
89
                /// The name of the class.
 
90
                string_table::key name;
 
91
 
 
92
                /// \brief
 
93
                /// The name of the inherited class. Object is assumed if
 
94
                /// none is given. (Unless name is itself Object)
 
95
                string_table::key super_name;
 
96
 
 
97
                /// \brief
 
98
                /// The name of the namespace in which this belongs.
 
99
                string_table::key namespace_name;
 
100
 
 
101
                /// \brief
 
102
                /// The version at which this should be added.
 
103
                int version;
 
104
        };
 
105
 
 
106
        /// \brief
 
107
        /// Declare an ActionScript class, with information on how
 
108
        /// to load it from an extension.
 
109
        ///
 
110
        /// @param c
 
111
        /// The extensionClass structure which defines the class.
 
112
        ///
 
113
        /// @return true, unless the class with c.name already existed.
 
114
        bool declareClass(extensionClass& c);
 
115
 
 
116
        /// \brief
 
117
        /// Declare an ActionScript class, with information on how
 
118
        /// to instantiate it from the core.
 
119
        ///
 
120
        /// @param c
 
121
        /// The nativeClass structure which defines the class.
 
122
        ///
 
123
        /// @return true, unless the class with c.name already existed.
 
124
        bool declareClass(const nativeClass& c);
 
125
 
 
126
        /// \brief
 
127
        /// Declare all of the native and extension classes from the
 
128
        /// tables contained in the source file.
 
129
        ///
 
130
        void massDeclare(int version);
 
131
 
 
132
        /// The global namespace
 
133
        ///
 
134
        /// Get the global namespace.  This is not the Global object -- it only
 
135
        /// contains the classes, not any globally available functions or anything
 
136
        /// else.
 
137
        asNamespace* getGlobalNs() { return mGlobalNamespace; }
 
138
 
 
139
        // Chad: Document
 
140
        as_object* newOfType(string_table::key /*whattype*/) { return NULL; }
 
141
 
 
142
        /// Find a namespace with the given uri.
 
143
        ///
 
144
        /// @return 
 
145
        /// The namespace with the given uri or NULL if it doesn't exist.
 
146
        asNamespace *findNamespace(string_table::key uri)
 
147
        {
 
148
                namespacesContainer::iterator i;
 
149
                if (mNamespaces.empty())
 
150
                        return NULL;
 
151
                i = mNamespaces.find(uri);
 
152
                if (i == mNamespaces.end())
 
153
                        return NULL;
 
154
                return &i->second;
 
155
        }
 
156
 
 
157
        /// \brief
 
158
        /// Obtain a new anonymous namespace. Use this to let the object keep track
 
159
        /// of all namespaces, even private ones. Namespaces obtained in this way
 
160
        /// can't ever be found. (They must be kept and passed to the appropriate
 
161
        /// objects.)
 
162
        ///
 
163
        asNamespace* anonNamespace(string_table::key uri)
 
164
        {
 
165
                mAnonNamespaces.grow(1); 
 
166
                asNamespace *n = &mAnonNamespaces.top(0); 
 
167
                n->setURI(uri); 
 
168
                return n; 
 
169
        }
 
170
 
 
171
        /// \brief
 
172
        /// Add a namespace to the set. Don't use to add unnamed namespaces.
 
173
        /// Will overwrite existing namespaces 'kind' and 'prefix' values. 
 
174
        /// Returns the added space.
 
175
        asNamespace* addNamespace(string_table::key uri)
 
176
        {
 
177
                asNamespace *n = findNamespace(uri);
 
178
                if (n)
 
179
                        return n;
 
180
                // The set should create it automatically here. TODO: Make sure
 
181
                mNamespaces[uri].setURI(uri);
 
182
                return &mNamespaces[uri];
 
183
        }
 
184
 
 
185
        /// Set the extension object, since it wasn't set on construction.
 
186
        void setExtension(Extension *e) { mExtension = e; }
 
187
 
 
188
        /// Set the global object, for registrations.
 
189
        void setGlobal(as_object *g) { mGlobal = g; }
 
190
 
 
191
        /// Mark objects for garbage collector.
 
192
        void markReachableResources() const;
 
193
 
 
194
        /// Create a new asClass object for use.
 
195
        asClass *newClass()
 
196
        { mClassMemory.grow(1); return &mClassMemory.top(0); }
 
197
 
 
198
        asException *newException()
 
199
        { mExceptionMemory.grow(1); return &mExceptionMemory.top(0); }
 
200
 
 
201
        /// Create a new asMethod object for use.
 
202
        asMethod *newMethod()
 
203
        { mMethodMemory.grow(1); return &mMethodMemory.top(0); }
 
204
 
 
205
        asBoundValue *newBoundValue()
 
206
        { mBoundValueMemory.grow(1); return &mBoundValueMemory.top(0); }
 
207
 
 
208
        asBoundAccessor *newBoundAccessor()
 
209
        { mBoundAccessorMemory.grow(1); return &mBoundAccessorMemory.top(0); }
 
210
 
 
211
        /// \brief
 
212
        /// Construct the declaration object. Later set the global and
 
213
        /// extension objects using setGlobal and setExtension
 
214
        ClassHierarchy() :
 
215
                mGlobal(NULL), mGlobalNamespace(NULL), mExtension(NULL),
 
216
                mAnonNamespaces(),
 
217
                mClassMemory(), mExceptionMemory(),
 
218
                mMethodMemory(),
 
219
                mBoundValueMemory(), mBoundAccessorMemory()
 
220
        { mGlobalNamespace = anonNamespace(0); }
 
221
 
 
222
        /// \brief
 
223
        /// Delete our private namespaces.
 
224
        ~ClassHierarchy();
 
225
 
 
226
private:
 
227
        as_object *mGlobal;
 
228
        asNamespace *mGlobalNamespace;
 
229
        Extension *mExtension;
 
230
 
 
231
        typedef std::map<string_table::key, asNamespace> namespacesContainer;
 
232
        namespacesContainer mNamespaces;
 
233
        SafeStack<asNamespace> mAnonNamespaces;
 
234
        SafeStack<asClass> mClassMemory;
 
235
        SafeStack<asException> mExceptionMemory;
 
236
        SafeStack<asMethod> mMethodMemory;
 
237
        SafeStack<asBoundValue> mBoundValueMemory;
 
238
        SafeStack<asBoundAccessor> mBoundAccessorMemory;
 
239
};
 
240
 
 
241
std::ostream& operator << (std::ostream& os, const ClassHierarchy::nativeClass& c);
 
242
std::ostream& operator << (std::ostream& os, const ClassHierarchy::extensionClass& c);
 
243
 
 
244
} /* namespace gnash */
 
245
#endif /* GNASH_CLASS_HIERARCHY_H */
 
246