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

« back to all changes in this revision

Viewing changes to libcore/as_environment.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_AS_ENVIRONMENT_H
 
19
#define GNASH_AS_ENVIRONMENT_H
 
20
 
 
21
#include "smart_ptr.h" // GNASH_USE_GC
 
22
#include "dsodefs.h" // DSOEXPORT
 
23
#include "as_value.h" // for composition (vector + frame_slot)
 
24
#include "StringPredicates.h" // for Variables 
 
25
#include "as_object.h"
 
26
#include "SafeStack.h"
 
27
#include "CallStack.h" // for composition
 
28
 
 
29
#include <map> // for composition (Variables)
 
30
#include <string> // for frame_slot name
 
31
#include <vector>
 
32
#include <iostream> // for dump_stack inline
 
33
 
 
34
namespace gnash {
 
35
 
 
36
// Forward declarations
 
37
class character;
 
38
class VM;
 
39
 
 
40
/// ActionScript execution environment.
 
41
class as_environment
 
42
{
 
43
 
 
44
public:
 
45
 
 
46
        /// A stack of objects used for variables/members lookup
 
47
        //typedef std::vector<with_stack_entry> ScopeStack;
 
48
        typedef std::vector< boost::intrusive_ptr<as_object> > ScopeStack;
 
49
 
 
50
        /// The variables container (case-insensitive)
 
51
        typedef std::map<std::string, as_value, StringNoCaseLessThen> Variables;
 
52
 
 
53
        typedef std::vector<as_value> Registers;
 
54
 
 
55
        as_environment(VM& vm);
 
56
 
 
57
        VM& getVM() { return _vm; }
 
58
 
 
59
        character* get_target() { return m_target; }
 
60
 
 
61
        /// Set default target for timeline opcodes
 
62
        //
 
63
        /// @param target
 
64
        ///     A character to apply timeline opcodes on.
 
65
        ///     Zero is a valid target, disabling timeline
 
66
        ///     opcodes (would get ignored).
 
67
        ///
 
68
        void set_target(character* target);
 
69
 
 
70
        void set_original_target(character* target) { _original_target = target; }
 
71
 
 
72
        character* get_original_target() { return _original_target; }
 
73
 
 
74
        // Reset target to its original value
 
75
        void reset_target() { m_target = _original_target; }
 
76
 
 
77
        /// @{ Stack access/manipulation
 
78
 
 
79
        /// Push a value on the stack
 
80
        void    push(const as_value& val)
 
81
        {
 
82
                _stack.push(val);
 
83
        }
 
84
 
 
85
 
 
86
        /// Pops an as_value off the stack top and return it.
 
87
        as_value pop()
 
88
        {
 
89
                try {
 
90
                        return _stack.pop();
 
91
                } catch (StackException&) {
 
92
                        return undefVal;
 
93
                }
 
94
                //assert( ! _stack.empty() );
 
95
                //as_value result = m_stack.back();
 
96
                //m_stack.pop_back();
 
97
                //return result;
 
98
        }
 
99
 
 
100
        /// Get stack value at the given distance from top.
 
101
        //
 
102
        /// top(0) is actual stack top
 
103
        ///
 
104
        /// Throw StackException if index is out of range
 
105
        ///
 
106
        as_value& top(size_t dist)
 
107
        {
 
108
                try {
 
109
                        return _stack.top(dist);
 
110
                } catch (StackException&) {
 
111
                        return undefVal;
 
112
                }
 
113
                //size_t ssize = m_stack.size();
 
114
                //assert ( ssize > dist );
 
115
                //return m_stack[ssize - 1 - dist];
 
116
        }
 
117
 
 
118
        /// Get stack value at the given distance from bottom.
 
119
        //
 
120
        /// bottom(stack_size()-1) is actual stack top
 
121
        ///
 
122
        /// Throw StackException if index is out of range
 
123
        ///
 
124
        as_value& bottom(size_t index)
 
125
        {
 
126
                try {
 
127
                        return _stack.value(index);
 
128
                } catch (StackException&) {
 
129
                        return undefVal;
 
130
                }
 
131
                //assert ( m_stack.size() > index );
 
132
                //return m_stack[index];
 
133
        }
 
134
 
 
135
        /// Drop 'count' values off the top of the stack.
 
136
        //
 
137
        /// Throw StackException if there's not enough to drop
 
138
        ///
 
139
        void drop(size_t count)
 
140
        {
 
141
                // in case count > stack size, just drop all, forget about
 
142
                // exceptions...
 
143
                _stack.drop(std::min(count, _stack.size()));
 
144
                //size_t ssize = m_stack.size();
 
145
                //assert ( ssize >= count );
 
146
                //m_stack.resize(ssize - count);
 
147
        }
 
148
 
 
149
        /// Insert 'count' undefined values before 'offset'.
 
150
        //
 
151
        /// An offset of 0 will prepend the values,
 
152
        /// An offset of size() [too far] will append the values.
 
153
        ///
 
154
        void padStack(size_t offset, size_t count);
 
155
 
 
156
        size_t stack_size() const { return _stack.size(); }
 
157
 
 
158
        /// @}  stack access/manipulation
 
159
        ///
 
160
 
 
161
        /// \brief
 
162
        /// Return the (possibly UNDEFINED) value of the named variable
 
163
        //
 
164
        /// @param varname 
 
165
        ///     Variable name. Can contain path elements.
 
166
        ///     TODO: should be case-insensitive up to SWF6.
 
167
        ///     NOTE: no case conversion is performed currently,
 
168
        ///           so make sure you do it yourself. Note that
 
169
        ///           ActionExec performs the conversion
 
170
        ///           before calling this method.
 
171
        ///
 
172
        as_value get_variable(const std::string& varname) const;
 
173
 
 
174
        /// \brief
 
175
        /// Delete a variable, w/out support for the path, using
 
176
        /// a ScopeStack.
 
177
        //
 
178
        /// @param varname 
 
179
        ///     Variable name. Can not contain path elements.
 
180
        ///     TODO: should be case-insensitive up to SWF6.
 
181
        ///     NOTE: no case conversion is performed currently,
 
182
        ///           so make sure you do it yourself. Note that
 
183
        ///           ActionExec performs the conversion
 
184
        ///           before calling this method.
 
185
        ///
 
186
        /// @param scopeStack
 
187
        ///     The Scope stack to use for lookups.
 
188
        ///
 
189
        bool del_variable_raw(const std::string& varname,
 
190
                        const ScopeStack& scopeStack);
 
191
 
 
192
        /// Return the (possibly UNDEFINED) value of the named var.
 
193
        //
 
194
        /// @param varname 
 
195
        ///     Variable name. Can contain path elements.
 
196
        ///     TODO: should be case-insensitive up to SWF6.
 
197
        ///     NOTE: no case conversion is performed currently,
 
198
        ///           so make sure you do it yourself. Note that
 
199
        ///           ActionExec performs the conversion
 
200
        ///           before calling this method.
 
201
        ///
 
202
        /// @param scopeStack
 
203
        ///     The Scope stack to use for lookups.
 
204
        ///
 
205
        /// @param retTarget
 
206
        ///     If not NULL, the pointer will be set to the actual object containing the
 
207
        ///     found variable (if found).
 
208
        ///
 
209
        as_value get_variable(const std::string& varname,
 
210
                const ScopeStack& scopeStack, as_object** retTarget=NULL) const;
 
211
 
 
212
        /// \brief
 
213
        /// Given a path to variable, set its value.
 
214
        /// Variable name can contain path elements.
 
215
        //
 
216
        /// @param path 
 
217
        ///     Variable path.
 
218
        ///     TODO: should be case-insensitive up to SWF6.
 
219
        ///     NOTE: no case conversion is performed currently,
 
220
        ///           so make sure you do it yourself. Note that
 
221
        ///           ActionExec performs the conversion
 
222
        ///           before calling this method.
 
223
        ///
 
224
        /// @param val
 
225
        ///     The value to assign to the variable, if found.
 
226
        ///
 
227
        /// TODO: make this function return some info about the
 
228
        ///       variable being found and set ?
 
229
        ///
 
230
        void set_variable(const std::string& path, const as_value& val);
 
231
 
 
232
        /// Given a variable name, set its value (no support for path)
 
233
        //
 
234
        /// If no variable with that name is found, a new one
 
235
        /// will be created as a member of current target.
 
236
        ///
 
237
        /// @param var
 
238
        ///     Variable name. Can not contain path elements.
 
239
        ///     TODO: should be case-insensitive up to SWF6.
 
240
        ///
 
241
        /// @param val
 
242
        ///     The value to assign to the variable, if found.
 
243
        ///
 
244
        void set_variable_raw(const std::string& var, const as_value& val);
 
245
 
 
246
        /// \brief
 
247
        /// Given a path to variable, set its value.
 
248
        //
 
249
        /// If no variable with that name is found, a new one is created.
 
250
        ///
 
251
        /// For path-less variables, this would act as a proxy for
 
252
        /// set_variable_raw.
 
253
        ///
 
254
        /// @param path
 
255
        ///     Variable path. 
 
256
        ///     TODO: should be case-insensitive up to SWF6.
 
257
        ///
 
258
        /// @param val
 
259
        ///     The value to assign to the variable.
 
260
        ///
 
261
        /// @param scopeStack
 
262
        ///     The Scope stack to use for lookups.
 
263
        ///
 
264
        void set_variable(const std::string& path, const as_value& val,
 
265
                const ScopeStack& scopeStack);
 
266
 
 
267
        /// Set/initialize the value of the local variable.
 
268
        //
 
269
        /// If no *local* variable with that name is found, a new one
 
270
        /// will be created.
 
271
        ///
 
272
        /// @param varname
 
273
        ///     Variable name. Can not contain path elements.
 
274
        ///     TODO: should be case-insensitive up to SWF6.
 
275
        ///
 
276
        /// @param val
 
277
        ///     The value to assign to the variable. 
 
278
        ///
 
279
        void set_local(const std::string& varname, const as_value& val);
 
280
 
 
281
        /// \brief
 
282
        /// Add a local var with the given name and value to our
 
283
        /// current local frame. 
 
284
        ///
 
285
        /// Use this when you know the var
 
286
        /// doesn't exist yet, since it's faster than set_local();
 
287
        /// e.g. when setting up args for a function.
 
288
        ///
 
289
        void add_local(const std::string& varname, const as_value& val);
 
290
 
 
291
        /// Create the specified local var if it doesn't exist already.
 
292
        void    declare_local(const std::string& varname);
 
293
 
 
294
        /// Add 'count' local registers (add space to end)
 
295
        //
 
296
        /// Local registers are only meaningful within a function2 context.
 
297
        ///
 
298
        void add_local_registers(unsigned int register_count)
 
299
        {
 
300
                assert(!_localFrames.empty());
 
301
                return _localFrames.back().registers.resize(register_count);
 
302
        }
 
303
 
 
304
        /// Set value of a register (local or global).
 
305
        //
 
306
        /// When not in a function context the register will be
 
307
        /// global or none (if regnum is not in the valid range
 
308
        /// of global registers).
 
309
        ///
 
310
        /// When in a function context defining NO registers, 
 
311
        /// we'll behave the same as for a non-function context.
 
312
        ///
 
313
        /// When in a function context defining non-zero number
 
314
        /// of local registers, the register set will be local
 
315
        /// or none (if regnum is not in the valid range of local
 
316
        /// registers).
 
317
        ///
 
318
        /// @param regnum
 
319
        ///     Register number
 
320
        ///
 
321
        /// @param v
 
322
        ///     Value to assign to the register
 
323
        ///
 
324
        /// @return 0 if register num is invalid
 
325
        ///         1 if a global register was set
 
326
        ///         2 if a local register was set
 
327
        ///
 
328
        unsigned int setRegister(unsigned int regnum, const as_value& v);
 
329
 
 
330
        /// Get value of a register (local or global).
 
331
        //
 
332
        /// When not in a function context the register will be
 
333
        /// global or none (if regnum is not in the valid range
 
334
        /// of global registers).
 
335
        ///
 
336
        /// When in a function context defining NO registers, 
 
337
        /// we'll behave the same as for a non-function context.
 
338
        ///
 
339
        /// When in a function context defining non-zero number
 
340
        /// of local registers, the register set will be local
 
341
        /// or none (if regnum is not in the valid range of local
 
342
        /// registers).
 
343
        ///
 
344
        /// @param regnum
 
345
        ///     Register number
 
346
        ///
 
347
        /// @param v
 
348
        ///     Output parameter, will be set to register
 
349
        ///     value or untouched if 0 is returned.
 
350
        ///
 
351
        /// @return 0 if register num is invalid (v unmodified in this case)
 
352
        ///         1 if a global register was set
 
353
        ///         2 if a local register was set
 
354
        ///
 
355
        unsigned int getRegister(unsigned int regnum, as_value& v);
 
356
 
 
357
        /// Return a reference to the Nth local register.
 
358
        //
 
359
        /// Local registers are only meaningful within a function2 context.
 
360
        ///
 
361
        as_value& local_register(boost::uint8_t n)
 
362
        {
 
363
                assert(!_localFrames.empty());
 
364
                return _localFrames.back().registers[n];
 
365
        }
 
366
 
 
367
        /// Set the Nth local register to something
 
368
        void set_local_register(boost::uint8_t n, as_value &val)
 
369
        {
 
370
                if ( ! _localFrames.empty() )
 
371
                {
 
372
                        Registers& registers = _localFrames.back().registers;
 
373
                        if ( n < registers.size() )
 
374
                        {
 
375
                                registers[n] = val;
 
376
                        }
 
377
                }
 
378
        }
 
379
 
 
380
        /// Return a reference to the Nth global register.
 
381
        as_value& global_register(unsigned int n)
 
382
        {
 
383
                assert(n<4);
 
384
                return m_global_register[n];
 
385
        }
 
386
 
 
387
        /// Set the Nth local register to something
 
388
        void set_global_register(boost::uint8_t n, as_value &val) {
 
389
            if (n <= 4) {
 
390
                m_global_register[n] = val;
 
391
            }
 
392
        }
 
393
 
 
394
#ifdef GNASH_USE_GC
 
395
        /// Mark all reachable resources.
 
396
        //
 
397
        /// Reachable resources from an as_environment
 
398
        /// would be global registers, stack (expected to be empty
 
399
        /// actually), stack frames and targets (original and current).
 
400
        ///
 
401
        void markReachableResources() const;
 
402
#endif
 
403
 
 
404
        /// Find the sprite/movie referenced by the given path.
 
405
        //
 
406
        /// Supports both /slash/syntax and dot.syntax
 
407
        /// Case insensitive for SWF up to 6, sensitive from 7 up
 
408
        ///
 
409
        character* find_target(const std::string& path) const;
 
410
 
 
411
        /// Find the object referenced by the given path.
 
412
        //
 
413
        /// Supports both /slash/syntax and dot.syntax
 
414
        /// Case insensitive for SWF up to 6, sensitive from 7 up
 
415
        ///
 
416
        as_object* find_object(const std::string& path, const ScopeStack* scopeStack=NULL) const;
 
417
        
 
418
        /// Dump content of the stack to a std::ostream
 
419
        //
 
420
        /// @param out
 
421
        ///     The output stream, standard error if omitted.
 
422
        ///
 
423
        /// @param limit
 
424
        ///     If > 0, limit number of printed item by the given amount (from the top).
 
425
        ///     Unlimited by default;
 
426
        ///
 
427
        void dump_stack(std::ostream& out=std::cerr, unsigned int limit=0) const;
 
428
 
 
429
        /// Dump the local registers to a std::ostream
 
430
        //
 
431
        /// NOTE that nothing will be written to the stream if NO local registers
 
432
        ///      are set
 
433
        ///
 
434
        void dump_local_registers(std::ostream& out=std::cerr) const;
 
435
 
 
436
        /// Dump the global registers to a std::ostream
 
437
        void dump_global_registers(std::ostream& out=std::cerr) const;
 
438
 
 
439
        /// Dump the local variables to a std::ostream
 
440
        void dump_local_variables(std::ostream& out=std::cerr) const;
 
441
 
 
442
        /// Return the SWF version we're running for.
 
443
        //
 
444
        /// NOTE: this is the version encoded in the first loaded
 
445
        ///       movie, and cannot be changed during play even if
 
446
        ///       replacing the root movie with an externally loaded one.
 
447
        ///
 
448
        int get_version() const;
 
449
 
 
450
        /// See if the given variable name is actually a sprite path
 
451
        /// followed by a variable name.  These come in the format:
 
452
        ///
 
453
        ///     /path/to/some/sprite/:varname
 
454
        ///
 
455
        /// (or same thing, without the last '/')
 
456
        ///
 
457
        /// or
 
458
        ///     path.to.some.var
 
459
        ///
 
460
        /// If that's the format, puts the path part (no colon or
 
461
        /// trailing slash) in *path, and the varname part (no colon, no dot)
 
462
        /// in *var and returns true.
 
463
        ///
 
464
        /// If no colon or dot, returns false and leaves *path & *var alone.
 
465
        ///
 
466
        /// TODO: return an integer: 0 not a path, 1 a slash-based path, 2 a dot-based path
 
467
        ///
 
468
        static bool parse_path(const std::string& var_path, std::string& path,
 
469
                        std::string& var);
 
470
 
 
471
        /// \brief
 
472
        /// Try to parse a string as a variable path
 
473
        //
 
474
        /// Variable paths come in the form:
 
475
        ///
 
476
        ///     /path/to/some/sprite/:varname
 
477
        ///
 
478
        /// or
 
479
        ///
 
480
        ///     /path/to/some/sprite 
 
481
        ///
 
482
        /// or
 
483
        ///     path.to.some.var
 
484
        ///
 
485
        /// If there's no dot nor colon, or if the 'path' part
 
486
        /// does not resolve to an object, this function returns false.
 
487
        /// Otherwise, true is returned and 'target' and 'val'
 
488
        /// parameters are appropriaterly set.
 
489
        ///
 
490
        /// Note that if the parser variable name doesn't exist in the found
 
491
        /// target, the 'val' will be undefined, but no other way to tell whether
 
492
        /// the variable existed or not from the caller...
 
493
        ///
 
494
        bool parse_path(const std::string& var_path, as_object** target, as_value& val);
 
495
 
 
496
        /// A class to wrap frame access.  Stack allocating a frame guard
 
497
        /// will ensure that all CallFrame pushes have a corresponding
 
498
        /// CallFrame pop, even in the presence of extraordinary returns.
 
499
        class FrameGuard
 
500
        {
 
501
        as_environment& _env;
 
502
        public:
 
503
                FrameGuard(as_environment& env, as_function* func)
 
504
            :
 
505
            _env(env)
 
506
                {
 
507
            _env.pushCallFrame(func);
 
508
        }
 
509
 
 
510
                ~FrameGuard()
 
511
        {
 
512
            _env.popCallFrame();
 
513
        }
 
514
        };
 
515
 
 
516
        /// Get top element of the call stack
 
517
        //
 
518
        CallFrame& topCallFrame()
 
519
        {
 
520
                assert(!_localFrames.empty());
 
521
                return _localFrames.back();
 
522
        }
 
523
 
 
524
        /// Return the depth of call stack
 
525
        size_t callStackDepth()
 
526
        {
 
527
                return _localFrames.size();
 
528
        }
 
529
 
 
530
private:
 
531
 
 
532
        VM& _vm;
 
533
 
 
534
        /// Stack of as_values in this environment
 
535
        //std::vector<as_value> m_stack;
 
536
        SafeStack<as_value>&    _stack;
 
537
 
 
538
        static const short unsigned int numGlobalRegisters = 4;
 
539
 
 
540
        CallStack& _localFrames;
 
541
 
 
542
        as_value m_global_register[numGlobalRegisters];
 
543
 
 
544
        /// Movie target. 
 
545
        character* m_target;
 
546
 
 
547
        /// Movie target. 
 
548
        character* _original_target;
 
549
 
 
550
        /// Push a frame on the calls stack.
 
551
        //
 
552
        /// This should happen right before calling an ActionScript
 
553
        /// function. Function local registers and variables
 
554
        /// must be set *after* pushCallFrame has been invoked
 
555
        ///
 
556
        /// Call popCallFrame() at ActionScript function return.
 
557
        ///
 
558
        /// @param func
 
559
        ///     The function being called
 
560
        ///
 
561
        DSOEXPORT void pushCallFrame(as_function* func);
 
562
 
 
563
        /// Remove current call frame from the stack
 
564
        //
 
565
        /// This should happen when an ActionScript function returns.
 
566
        ///
 
567
        DSOEXPORT void popCallFrame();
 
568
        
 
569
        /// Return the (possibly UNDEFINED) value of the named variable.
 
570
        //
 
571
        /// @param varname 
 
572
        ///     Variable name. Can not contain path elements.
 
573
        ///     NOTE: no case conversion is performed currently,
 
574
        ///           so make sure you do it yourself. 
 
575
        ///
 
576
        as_value get_variable_raw(const std::string& varname) const;
 
577
 
 
578
        /// Given a variable name, set its value (no support for path)
 
579
        void set_variable_raw(const std::string& path, const as_value& val,
 
580
                const ScopeStack& scopeStack);
 
581
 
 
582
        /// Same of the above, but no support for path.
 
583
        ///
 
584
        /// @param retTarget
 
585
        ///     If not NULL, the pointer will be set to the actual object containing the
 
586
        ///     found variable (if found).
 
587
        ///
 
588
        as_value get_variable_raw(const std::string& varname,
 
589
                const ScopeStack& scopeStack, as_object** retTarget=NULL) const;
 
590
 
 
591
 
 
592
        /// \brief
 
593
        /// Get a local variable given its name,
 
594
        //
 
595
        /// @param varname
 
596
        ///     Name of the local variable
 
597
        ///
 
598
        /// @param ret
 
599
        ///     If a variable is found it's assigned to this parameter.
 
600
        ///     Untouched if the variable is not found.
 
601
        ///
 
602
        /// @param retTarget
 
603
        ///     If not NULL, the pointer will be set to the actual object containing the
 
604
        ///     found variable (if found).
 
605
        ///
 
606
        /// @return true if the variable was found, false otherwise
 
607
        ///
 
608
        bool findLocal(const std::string& varname, as_value& ret, as_object** retTarget=NULL);
 
609
 
 
610
        bool findLocal(const std::string& varname, as_value& ret, as_object** retTarget=NULL) const
 
611
        {
 
612
                return const_cast<as_environment*>(this)->findLocal(varname, ret, retTarget);
 
613
        }
 
614
 
 
615
        /// Find a variable in the given as_object
 
616
        //
 
617
        /// @param varname
 
618
        ///     Name of the local variable
 
619
        ///
 
620
        /// @param ret
 
621
        ///     If a variable is found it's assigned to this parameter.
 
622
        ///     Untouched if the variable is not found.
 
623
        ///
 
624
        /// @return true if the variable was found, false otherwise
 
625
        ///
 
626
        bool findLocal(as_object* locals, const std::string& name, as_value& ret);
 
627
 
 
628
        /// Delete a local variable
 
629
        //
 
630
        /// @param varname
 
631
        ///     Name of the local variable
 
632
        ///
 
633
        /// @return true if the variable was found and deleted, false otherwise
 
634
        ///
 
635
        bool delLocal(const std::string& varname);
 
636
 
 
637
        /// Delete a variable from the given as_object
 
638
        //
 
639
        /// @param varname
 
640
        ///     Name of the local variable
 
641
        ///
 
642
        /// @return true if the variable was found, false otherwise
 
643
        ///
 
644
        bool delLocal(as_object* locals, const std::string& varname);
 
645
 
 
646
        /// Set a local variable, if it exists.
 
647
        //
 
648
        /// @param varname
 
649
        ///     Name of the local variable
 
650
        ///
 
651
        /// @param val
 
652
        ///     Value to assign to the variable
 
653
        ///
 
654
        /// @return true if the variable was found, false otherwise
 
655
        ///
 
656
        bool setLocal(const std::string& varname, const as_value& val);
 
657
 
 
658
        /// Set a variable of the given object, if it exists.
 
659
        //
 
660
        /// @param varname
 
661
        ///     Name of the local variable
 
662
        ///
 
663
        /// @param val
 
664
        ///     Value to assign to the variable
 
665
        ///
 
666
        /// @return true if the variable was found, false otherwise
 
667
        ///
 
668
        bool setLocal(as_object* locals, const std::string& varname, const as_value& val);
 
669
 
 
670
        static as_value undefVal;
 
671
                
 
672
};
 
673
 
 
674
 
 
675
} // end namespace gnash
 
676
 
 
677
 
 
678
#endif // GNASH_AS_ENVIRONMENT_H
 
679
 
 
680
 
 
681
// Local Variables:
 
682
// mode: C++
 
683
// indent-tabs-mode: t
 
684
// End: