gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] /srv/bzr/gnash/trunk r11560: More cleanups, more passes.


From: Benjamin Wolsey
Subject: [Gnash-commit] /srv/bzr/gnash/trunk r11560: More cleanups, more passes.
Date: Tue, 13 Oct 2009 13:52:52 +0200
User-agent: Bazaar (1.16.1)

------------------------------------------------------------
revno: 11560 [merge]
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Tue 2009-10-13 13:52:52 +0200
message:
  More cleanups, more passes.
modified:
  libcore/as_environment.cpp
  libcore/as_environment.h
  libcore/asobj/flash/display/MovieClip_as.cpp
  libcore/swf_function.cpp
  testsuite/swfdec/PASSING
=== modified file 'libcore/as_environment.cpp'
--- a/libcore/as_environment.cpp        2009-10-09 06:32:11 +0000
+++ b/libcore/as_environment.cpp        2009-10-13 10:10:53 +0000
@@ -162,13 +162,6 @@
     }
 }
 
-as_value
-as_environment::get_variable(const std::string& varname) const
-{
-    static ScopeStack empty_scopeStack;
-    return get_variable(varname, empty_scopeStack);
-}
-
 static bool
 validRawVariableName(const std::string& varname)
 {
@@ -371,13 +364,6 @@
     }
 }
 
-void
-as_environment::set_variable(const std::string& varname, const as_value& val)
-{
-    static ScopeStack empty_scopeStack;
-    set_variable(varname, val, empty_scopeStack);
-}
-
 // No path rigamarole.
 void
 as_environment::set_variable_raw(const std::string& varname,

=== modified file 'libcore/as_environment.h'
--- a/libcore/as_environment.h  2009-10-09 06:32:11 +0000
+++ b/libcore/as_environment.h  2009-10-13 10:10:53 +0000
@@ -129,18 +129,6 @@
     size_t stack_size() const { return _stack.size(); }
 
     /// \brief
-    /// Return the (possibly UNDEFINED) value of the named variable
-    //
-    /// @param varname 
-    /// Variable name. Can contain path elements.
-    /// TODO: should be case-insensitive up to SWF6.
-    /// NOTE: no case conversion is performed currently,
-    ///       so make sure you do it yourself. Note that
-    ///       ActionExec performs the conversion
-    ///       before calling this method.
-    as_value get_variable(const std::string& varname) const;
-
-    /// \brief
     /// Delete a variable, w/out support for the path, using
     /// a ScopeStack.
     //
@@ -179,26 +167,6 @@
 
     /// \brief
     /// Given a path to variable, set its value.
-    /// Variable name can contain path elements.
-    //
-    /// @param path 
-    /// Variable path.
-    /// TODO: should be case-insensitive up to SWF6.
-    /// NOTE: no case conversion is performed currently,
-    ///       so make sure you do it yourself. Note that
-    ///       ActionExec performs the conversion
-    ///       before calling this method.
-    ///
-    /// @param val
-    /// The value to assign to the variable, if found.
-    ///
-    /// TODO: make this function return some info about the
-    ///       variable being found and set ?
-    ///
-    void set_variable(const std::string& path, const as_value& val);
-
-    /// \brief
-    /// Given a path to variable, set its value.
     //
     /// If no variable with that name is found, a new one is created.
     ///

=== modified file 'libcore/asobj/flash/display/MovieClip_as.cpp'
--- a/libcore/asobj/flash/display/MovieClip_as.cpp      2009-10-13 07:32:05 
+0000
+++ b/libcore/asobj/flash/display/MovieClip_as.cpp      2009-10-13 09:07:45 
+0000
@@ -681,49 +681,45 @@
 
     // Lower bound of source depth below which swapDepth has no effect
     // (below Timeline/static zone)
-    if ( this_depth < DisplayObject::lowerAccessibleBound )
+    if (this_depth < DisplayObject::lowerAccessibleBound)
     {
         IF_VERBOSE_ASCODING_ERRORS(
             std::stringstream ss;
             fn.dump_args(ss);
             log_aserror(_("%s.swapDepths(%s): won't swap a clip below "
-                    "depth %d (%d)"),
-            movieclip->getTarget(), ss.str(), 
DisplayObject::lowerAccessibleBound,
+                "depth %d (%d)"), movieclip->getTarget(), ss.str(),
+                DisplayObject::lowerAccessibleBound,
                 this_depth);
-        );
+        )
         return as_value();
     }
 
-    typedef boost::intrusive_ptr<DisplayObject> CharPtr;
-    typedef boost::intrusive_ptr<MovieClip> SpritePtr;
-
-    SpritePtr this_parent = dynamic_cast<MovieClip*>(
-            movieclip->get_parent());
+    MovieClip* this_parent = dynamic_cast<MovieClip*>(movieclip->get_parent());
 
     //CharPtr target = NULL;
     int target_depth = 0;
 
     // movieclip.swapDepth(movieclip)
-    if ( SpritePtr target_movieclip = fn.arg(0).to_sprite() )
-    {
-        if ( movieclip == target_movieclip )
-        {
+    if (MovieClip* target_movieclip = fn.arg(0).to_sprite()) {
+
+        if (movieclip == target_movieclip) {
             IF_VERBOSE_ASCODING_ERRORS(
-            log_aserror(_("%s.swapDepths(%s): invalid call, swapping to 
self?"),
-                movieclip->getTarget(), target_movieclip->getTarget());
-            );
+                log_aserror(_("%s.swapDepths(%s): invalid call, "
+                    "swapping to self?"), movieclip->getTarget(),
+                    target_movieclip->getTarget());
+            )
             return as_value();
         }
 
-        SpritePtr target_parent =
+        MovieClip* target_parent =
             dynamic_cast<MovieClip*>(movieclip->get_parent());
-        if ( this_parent != target_parent )
-        {
+
+        if (this_parent != target_parent) {
             IF_VERBOSE_ASCODING_ERRORS(
-            log_aserror(_("%s.swapDepths(%s): invalid call, the two "
+                log_aserror(_("%s.swapDepths(%s): invalid call, the two "
                     "DisplayObjects don't have the same parent"),
-                movieclip->getTarget(), target_movieclip->getTarget());
-            );
+                    movieclip->getTarget(), target_movieclip->getTarget());
+            )
             return as_value();
         }
 
@@ -733,7 +729,7 @@
         // to avoid unecessary bounds invalidation and immunizing
         // the instance from subsequent PlaceObject tags attempting
         // to transform it.
-        if ( movieclip->get_depth() == target_depth )
+        if (movieclip->get_depth() == target_depth)
         {
             IF_VERBOSE_ASCODING_ERRORS(
                 std::stringstream ss; fn.dump_args(ss);
@@ -746,28 +742,35 @@
     }
 
     // movieclip.swapDepth(depth)
-    else
-    {
-        double td = fn.arg(0).to_number();
-        if ( isNaN(td) )
-        {
-            IF_VERBOSE_ASCODING_ERRORS(
-            std::stringstream ss; fn.dump_args(ss);
-            log_aserror(_("%s.swapDepths(%s): first argument invalid "
-                "(neither a movieclip nor a number)"),
-                movieclip->getTarget(), ss.str());
-            );
+    else {
+        
+        const double td = fn.arg(0).to_number();
+        if (isNaN(td)) {
+            IF_VERBOSE_ASCODING_ERRORS(
+                std::stringstream ss; fn.dump_args(ss);
+                log_aserror(_("%s.swapDepths(%s): first argument invalid "
+                    "(neither a movieclip nor a number)"),
+                    movieclip->getTarget(), ss.str());
+            )
+            return as_value();
+        }
+        if (td > DisplayObject::upperAccessibleBound) {
+            IF_VERBOSE_ASCODING_ERRORS(
+                std::stringstream ss; fn.dump_args(ss);
+                log_aserror(_("%s.swapDepths(%s): requested depth is above "
+                    "the accessible range."),
+                    movieclip->getTarget(), ss.str());
+            )
             return as_value();
         }
 
-        target_depth = int(td);
+        target_depth = static_cast<int>(td);
 
         // Check we're not swapping the our own depth so
         // to avoid unecessary bounds invalidation and immunizing
         // the instance from subsequent PlaceObjec tags attempting
         // to transform it.
-        if ( movieclip->get_depth() == target_depth )
-        {
+        if (movieclip->get_depth() == target_depth) {
             IF_VERBOSE_ASCODING_ERRORS(
             std::stringstream ss; fn.dump_args(ss);
             log_aserror(_("%s.swapDepths(%s): ignored, DisplayObject already "
@@ -776,19 +779,13 @@
             );
             return as_value();
         }
-
-
         // TODO : check other kind of validities ?
-
-
     }
 
-    if ( this_parent )
-    {
+    if (this_parent) {
         this_parent->swapDepths(movieclip.get(), target_depth);
     }
-    else
-    {
+    else {
         movie_root& root = getRoot(fn);
         root.swapLevels(movieclip, target_depth);
         return as_value();

=== modified file 'libcore/swf_function.cpp'
--- a/libcore/swf_function.cpp  2009-08-27 06:58:37 +0000
+++ b/libcore/swf_function.cpp  2009-10-13 10:32:52 +0000
@@ -135,23 +135,19 @@
        DisplayObject* orig_target = m_env.get_original_target();
 
        // Some features are version-dependant.
-       unsigned swfversion = vm.getSWFVersion();
+       const int swfversion = vm.getSWFVersion();
        as_object *super = NULL;
-       if (swfversion > 5)
-       {
+       if (swfversion > 5) {
                super = fn.super;
        }
-       else
-       {
+       else {
                // In SWF5, when 'this' is a DisplayObject it becomes
                // the target for this function call.
                // See actionscript.all/setProperty.as
                // 
-               if ( fn.this_ptr )
-               {
+               if (fn.this_ptr) {
                        DisplayObject* ch = fn.this_ptr->toDisplayObject();
-                       if ( ch )
-                       {
+                       if (ch) {
                                target = ch;
                                orig_target = ch;
                        }
@@ -176,12 +172,10 @@
                for (size_t i=0, n=m_args.size(); i<n; ++i)
                {
                        assert(m_args[i].m_register == 0);
-                       if ( i < fn.nargs )
-                       {
+                       if (i < fn.nargs) {
                                m_env.add_local(m_args[i].m_name, fn.arg(i));
                        }
-                       else
-                       {
+                       else {
                                // Still declare named arguments, even if
                                // they are not passed from caller
                                // See bug #22203
@@ -194,8 +188,7 @@
                m_env.set_local("this", fn.this_ptr);
 
                // Add 'super' (SWF6+ only)
-               if ( super && swfversion > 5 )
-               {
+               if (super && swfversion > 5) {
                        m_env.set_local("super", as_value(super));
                }
 
@@ -213,49 +206,37 @@
                // @@ why start at 1 ? Note that starting at 0 makes    
                // intro.swf movie fail to play correctly.
                unsigned int current_reg = 1;
-               if ( (m_function2_flags & PRELOAD_THIS) && ! (m_function2_flags 
& SUPPRESS_THIS) )
-               {
+               if ((m_function2_flags & PRELOAD_THIS) &&
+                !(m_function2_flags & SUPPRESS_THIS)) {
                        // preload 'this' into a register.
                        m_env.setRegister(current_reg, as_value(fn.this_ptr)); 
                        current_reg++;
                }
 
-               if (m_function2_flags & SUPPRESS_THIS)
-               {
-                       // Don't put 'this' into a local var.
-               }
-               else
-               {
+               if (!(m_function2_flags & SUPPRESS_THIS)) {
                        // Put 'this' in a local var.
                        m_env.add_local("this", as_value(fn.this_ptr));
                }
 
                // Init arguments array, if it's going to be needed.
-               boost::intrusive_ptr<Array_as>  arg_array;
-               if ((m_function2_flags & PRELOAD_ARGUMENTS) || ! 
(m_function2_flags & SUPPRESS_ARGUMENTS))
-               {
+               boost::intrusive_ptr<Array_as> arg_array;
+               if ((m_function2_flags & PRELOAD_ARGUMENTS) || 
+                !(m_function2_flags & SUPPRESS_ARGUMENTS)) {
                        arg_array = getArguments(*this, fn, caller);
                }
 
-               if (m_function2_flags & PRELOAD_ARGUMENTS)
-               {
+               if (m_function2_flags & PRELOAD_ARGUMENTS) {
                        // preload 'arguments' into a register.
                        m_env.setRegister(current_reg, 
as_value(arg_array.get()));
                        current_reg++;
                }
 
-               if (m_function2_flags & SUPPRESS_ARGUMENTS)
-               {
-                       // Don't put 'arguments' in a local var.
-               }
-               else
-               {
+               if (!(m_function2_flags & SUPPRESS_ARGUMENTS)) {
                        // Put 'arguments' in a local var.
                        m_env.add_local("arguments", as_value(arg_array.get()));
                }
 
-               if ( (m_function2_flags & PRELOAD_SUPER) && swfversion > 5)
-               {
+               if ((m_function2_flags & PRELOAD_SUPER) && swfversion > 5) {
                        // Put 'super' in a register (SWF6+ only).
                        // TOCHECK: should we still set it if not available ?
                        if ( super ) {
@@ -264,85 +245,69 @@
                        }
                }
 
-               if (m_function2_flags & SUPPRESS_SUPER)
-               {
-                       // Don't put 'super' in a local var.
-               }
-               else if ( super && swfversion > 5 )
-               {
-                       // TOCHECK: should we still set it if unavailable ?
-                       // Put 'super' in a local var (SWF6+ only)
-                       m_env.add_local("super", as_value(super));
+               if (!(m_function2_flags & SUPPRESS_SUPER)) {
+                   if (super && swfversion > 5) {
+                // TOCHECK: should we still set it if unavailable ?
+                // Put 'super' in a local var (SWF6+ only)
+                m_env.add_local("super", as_value(super));
+            }
                }
 
-               if (m_function2_flags & PRELOAD_ROOT) 
-               {
+               if (m_function2_flags & PRELOAD_ROOT) {
                        // Put '_root' (if any) in a register.
                        DisplayObject* tgtch = m_env.get_target();
-                       if ( tgtch )
-                       {
-                               // NOTE: _lockroot will be hanlded by 
getAsRoot()
+                       if (tgtch) {
+                               // NOTE: _lockroot will be handled by 
getAsRoot()
                                as_object* r = tgtch->getAsRoot();
                                m_env.setRegister(current_reg, as_value(r));
-                               current_reg++;
+                               ++current_reg;
                        }
                }
 
-               if (m_function2_flags & PRELOAD_PARENT)
-               {
-                       // Put '_parent' in a register.
-                       as_value parent = m_env.get_variable("_parent");
-                       //m_env.local_register(current_reg) = parent;
-                       m_env.setRegister(current_reg, parent);
-                       current_reg++;
+               if (m_function2_flags & PRELOAD_PARENT) {
+                       DisplayObject* tgtch = m_env.get_target();
+            if (tgtch) {
+                as_object* parent = tgtch->get_parent();
+                m_env.setRegister(current_reg, parent);
+                ++current_reg;
+            }
                }
 
-               if (m_function2_flags & PRELOAD_GLOBAL)
-               {
+               if (m_function2_flags & PRELOAD_GLOBAL) {
                        // Put '_global' in a register.
                        as_object* global = vm.getGlobal();
-                       
//m_env.local_register(current_reg).set_as_object(global);
                        m_env.setRegister(current_reg, as_value(global));
-                       current_reg++;
+                       ++current_reg;
                }
 
                // Handle the explicit args.
                // This must be done after implicit ones,
-               // as the explicit override the implicits: see 
swfdec/definefunction2-override
-               for (size_t i=0, n=m_args.size(); i<n; ++i)
-               {
-                       if ( ! m_args[i].m_register ) // not a register, 
declare as local
-                       {
-                               if ( i < fn.nargs )
-                               {
+               // as the explicit override the implicits:
+        // see swfdec/definefunction2-override
+               for (size_t i = 0, n = m_args.size(); i < n; ++i) {
+            // not a register, declare as local
+                       if (!m_args[i].m_register) {
+                               if (i < fn.nargs) {
                                        // Conventional arg passing: create a 
local var.
                                        m_env.add_local(m_args[i].m_name, 
fn.arg(i));
                                }
-                               else
-                               {
+                               else {
                                        // Still declare named arguments, even 
if
                                        // they are not passed from caller
                                        // See bug #22203
                                        m_env.declare_local(m_args[i].m_name);
                                }
                        }
-                       else
-                       {
-                               if ( i < fn.nargs )
-                               {
+                       else {
+                               if (i < fn.nargs) {
                                        // Pass argument into a register.
-                                       int     reg = m_args[i].m_register;
-                                       //m_env.local_register(reg) = fn.arg(i);
+                                       const int reg = m_args[i].m_register;
                                        m_env.setRegister(reg, fn.arg(i));
                                }
-                               else
-                               {
-                                       // The argument was not passed, no
-                                       // need to setup a register I guess..
-                               }
+                // If no argument was passed, no need to setup a register
+                // I guess.
                        }
                }
-
        }
 
        as_value result;

=== modified file 'testsuite/swfdec/PASSING'
--- a/testsuite/swfdec/PASSING  2009-10-13 08:09:53 +0000
+++ b/testsuite/swfdec/PASSING  2009-10-13 10:23:35 +0000
@@ -754,6 +754,9 @@
 movieclip-swap-depths-7.swf:fb8d472e5da28d95684ce067fccae829
 movieclip-swap-depths-8.swf:a02edb0c644d0a47fee7c3ca5135d748
 movieclip-swap-depths-range-5.swf:7bb6af574af7655b76bc705de95f21a3
+movieclip-swap-depths-range-6.swf:b18e19373561a3d9fe1ad25b18164e6f
+movieclip-swap-depths-range-7.swf:a9a55664a8d61a45b688b12b83709ad5
+movieclip-swap-depths-range-8.swf:6152061b5a021c7db49fa8ba163e51b9
 movieclip-target-5.swf:28c37b3a6a910310876edd7cbc801189
 movieclip-target-6.swf:05b920ce25223634a33446718716e51e
 movieclip-target-7.swf:fca8a267d9a4d2e7aa6dd47be281ac02


reply via email to

[Prev in Thread] Current Thread [Next in Thread]