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

« back to all changes in this revision

Viewing changes to server/swf_function.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) 2005, 2006, 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
 
#ifndef __GNASH_SWF_FUNCTION_H__
19
 
#define __GNASH_SWF_FUNCTION_H__
20
 
 
21
 
#ifdef HAVE_CONFIG_H
22
 
#include "gnashconfig.h"
23
 
#endif
24
 
 
25
 
#include "impl.h"
26
 
#include "as_function.h" // for inheritance
27
 
#include "as_object.h" // for composition (vector element)
28
 
#include "VM.h" //fow SWF version
29
 
//#include "with_stack_entry.h" // for composition (vector element)
30
 
 
31
 
#include <boost/algorithm/string/case_conv.hpp> 
32
 
#include <cassert>
33
 
#include <string>
34
 
 
35
 
// Forward declarations
36
 
namespace gnash {
37
 
        class action_buffer;
38
 
        class as_environmnet;
39
 
        class as_array_object;
40
 
}
41
 
 
42
 
namespace gnash {
43
 
 
44
 
/// SWF-defined Function 
45
 
class swf_function : public as_function
46
 
{
47
 
 
48
 
private:
49
 
 
50
 
        /// Action buffer containing the function definition
51
 
        const action_buffer* m_action_buffer;
52
 
 
53
 
        /// @@ might need some kind of ref count here, but beware cycles
54
 
        as_environment* m_env;
55
 
 
56
 
        typedef std::vector< boost::intrusive_ptr<as_object> > ScopeStack;
57
 
 
58
 
        /// Scope stack on function definition.
59
 
        ScopeStack _scopeStack;
60
 
 
61
 
        /// \brief
62
 
        /// Offset within the action_buffer where
63
 
        /// start of the function is found.
64
 
        size_t  m_start_pc;
65
 
 
66
 
        /// Length of the function within the action_buffer
67
 
        //
68
 
        /// This is currently expressed in bytes as the
69
 
        /// action_buffer is just a blog of memory corresponding
70
 
        /// to a DoAction block
71
 
        size_t m_length;
72
 
 
73
 
        struct arg_spec
74
 
        {
75
 
                int m_register;
76
 
                std::string m_name;
77
 
        };
78
 
        std::vector<arg_spec>   m_args;
79
 
        bool    m_is_function2;
80
 
        boost::uint8_t  m_local_register_count;
81
 
 
82
 
        /// used by function2 to control implicit arg register assignments
83
 
        // 
84
 
        /// See http://sswf.sourceforge.net/SWFalexref.html#action_declare_function2
85
 
        boost::uint16_t m_function2_flags;
86
 
 
87
 
        /// Return an 'arguments' object.
88
 
        //
89
 
        /// The 'arguments' variable is an array with an additional
90
 
        /// 'callee' member, set to the function being called.
91
 
        ///
92
 
        /// NOTE: the callee as_object will be stored in an as_value, thus
93
 
        ///       getting wrapped into an intrusive_ptr. Make sure you have
94
 
        ///       a reference on it!
95
 
        ///       
96
 
        ///
97
 
        static as_array_object* getArguments(swf_function& callee, const fn_call& fn);
98
 
 
99
 
public:
100
 
 
101
 
        enum SWFDefineFunction2Flags
102
 
        {
103
 
                /// Bind one register to "this" 
104
 
                PRELOAD_THIS = 0x01, // 1
105
 
 
106
 
                /// No "this" variable accessible by-name 
107
 
                SUPPRESS_THIS = 0x02, // 2
108
 
 
109
 
                /// Bind one register to "arguments" 
110
 
                PRELOAD_ARGUMENTS = 0x04, // 4
111
 
 
112
 
                /// No "argument" variable accessible by-name 
113
 
                SUPPRESS_ARGUMENTS = 0x08, // 8
114
 
 
115
 
                /// Bind one register to "super" 
116
 
                PRELOAD_SUPER = 0x10, // 16
117
 
 
118
 
                /// No "super" variable accessible by-name 
119
 
                SUPPRESS_SUPER = 0x20, // 32
120
 
 
121
 
                /// Bind one register to "_root" 
122
 
                PRELOAD_ROOT = 0x40, // 64
123
 
 
124
 
                /// Bind one register to "_parent" 
125
 
                PRELOAD_PARENT = 0x80, // 128
126
 
 
127
 
                /// Bind one register to "_global" 
128
 
                //
129
 
                /// TODO: check this. See http://sswf.sourceforge.net/SWFalexref.html#action_declare_function2
130
 
                ///       Looks like flags would look swapped
131
 
                PRELOAD_GLOBAL = 256 // 0x100
132
 
 
133
 
        };
134
 
 
135
 
 
136
 
        ~swf_function();
137
 
 
138
 
        /// Default constructor
139
 
        //
140
 
        /// Creates a Function object inheriting
141
 
        /// the Function interface (apply,call)
142
 
        ///
143
 
        //swf_function();
144
 
 
145
 
        /// Construct a Built-in ActionScript class 
146
 
        //
147
 
        /// The provided export_iface as_object is what will end
148
 
        /// up being the class's 'prototype' member, caller must
149
 
        /// make sure to provide it with a 'constructor' member
150
 
        /// pointing to the function that creates an instance of
151
 
        /// that class.
152
 
        /// All built-in classes derive from the Function
153
 
        /// built-in class, whose exported interface will be 
154
 
        /// accessible trought their __proto__ member.
155
 
        ///
156
 
        /// @param export_iface the exported interface
157
 
        ///
158
 
        //swf_function(as_object* export_iface);
159
 
        // USE THE builtin_function instead!
160
 
 
161
 
        /// \brief
162
 
        /// Create an ActionScript function as defined in an
163
 
        /// action_buffer starting at offset 'start'
164
 
        //
165
 
        /// NULL environment is allowed -- if so, then
166
 
        /// functions will be executed in the caller's
167
 
        /// environment, rather than the environment where they
168
 
        /// were defined.
169
 
        ///
170
 
        swf_function(const action_buffer* ab,
171
 
                as_environment* env,
172
 
                size_t start,
173
 
                const ScopeStack& with_stack);
174
 
 
175
 
        const ScopeStack& getScopeStack() const
176
 
        {
177
 
                return _scopeStack;
178
 
        }
179
 
 
180
 
        const action_buffer& getActionBuffer() const
181
 
        {
182
 
                assert(m_action_buffer);
183
 
                return *m_action_buffer;
184
 
        }
185
 
 
186
 
        size_t getStartPC() const
187
 
        {
188
 
                return m_start_pc;
189
 
        }
190
 
 
191
 
        size_t getLength() const
192
 
        {
193
 
                return m_length;
194
 
        }
195
 
 
196
 
        bool isFunction2() const
197
 
        {
198
 
                return m_is_function2;
199
 
        }
200
 
 
201
 
        void    set_is_function2() { m_is_function2 = true; }
202
 
 
203
 
        void    set_local_register_count(boost::uint8_t ct) { assert(m_is_function2); m_local_register_count = ct; }
204
 
 
205
 
        void    set_function2_flags(boost::uint16_t flags) { assert(m_is_function2); m_function2_flags = flags; }
206
 
 
207
 
        void    add_arg(int arg_register, const char* name)
208
 
        {
209
 
                assert(arg_register == 0 || m_is_function2 == true);
210
 
                m_args.resize(m_args.size() + 1);
211
 
                m_args.back().m_register = arg_register;
212
 
                m_args.back().m_name = PROPNAME(name);
213
 
        }
214
 
 
215
 
        void    set_length(int len);
216
 
 
217
 
        /// Dispatch.
218
 
        as_value        operator()(const fn_call& fn);
219
 
 
220
 
        //void  lazy_create_properties();
221
 
 
222
 
#ifdef GNASH_USE_GC
223
 
        /// Mark reachable resources. Override from as_function.
224
 
        //
225
 
        /// Reachable resources from this object is it's scope stack
226
 
        /// and the prototype.
227
 
        ///
228
 
        virtual void markReachableResources() const;
229
 
#endif // GNASH_USE_GC
230
 
};
231
 
 
232
 
 
233
 
} // end of gnash namespace
234
 
 
235
 
// __GNASH_SWF_FUNCTION_H__
236
 
#endif
237