gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash ChangeLog server/as_environment.cpp serve...


From: Sandro Santilli
Subject: [Gnash-commit] gnash ChangeLog server/as_environment.cpp serve...
Date: Thu, 14 Dec 2006 14:06:06 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  06/12/14 14:06:06

Modified files:
        .              : ChangeLog 
        server         : as_environment.cpp as_environment.h 
        testsuite/actionscript.all: Function.as 

Log message:
                * server/as_environment.{h,cpp}: add an additional
                  argument to findLocal() to specify wheter the seek
                  should descend in upper frames; descend when getting,
                  deleting and setting variables; don't descend when
                  setting or declaring a *local* variable (set_local,
                  declare_local).
                * testsuite/actionscript.all/Function.as: added tests
                  for timeline-local variable access from within a function
                  (see bug #18523).

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.1938&r2=1.1939
http://cvs.savannah.gnu.org/viewcvs/gnash/server/as_environment.cpp?cvsroot=gnash&r1=1.40&r2=1.41
http://cvs.savannah.gnu.org/viewcvs/gnash/server/as_environment.h?cvsroot=gnash&r1=1.30&r2=1.31
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/actionscript.all/Function.as?cvsroot=gnash&r1=1.17&r2=1.18

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.1938
retrieving revision 1.1939
diff -u -b -r1.1938 -r1.1939
--- ChangeLog   13 Dec 2006 21:38:51 -0000      1.1938
+++ ChangeLog   14 Dec 2006 14:06:06 -0000      1.1939
@@ -1,3 +1,15 @@
+2006-12-14 Sandro Santilli <address@hidden>
+
+       * server/as_environment.{h,cpp}: add an additional
+         argument to findLocal() to specify wheter the seek
+         should descend in upper frames; descend when getting,
+         deleting and setting variables; don't descend when
+         setting or declaring a *local* variable (set_local,
+         declare_local).
+       * testsuite/actionscript.all/Function.as: added tests
+         for timeline-local variable access from within a function
+         (see bug #18523).
+
 2006-12-13 Sandro Santilli <address@hidden>
 
        * server/parser/action_buffer.cpp: neater output

Index: server/as_environment.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/as_environment.cpp,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -b -r1.40 -r1.41
--- server/as_environment.cpp   13 Dec 2006 11:09:12 -0000      1.40
+++ server/as_environment.cpp   14 Dec 2006 14:06:06 -0000      1.41
@@ -16,7 +16,7 @@
 
 //
 
-/* $Id: as_environment.cpp,v 1.40 2006/12/13 11:09:12 strk Exp $ */
+/* $Id: as_environment.cpp,v 1.41 2006/12/14 14:06:06 strk Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -91,8 +91,8 @@
        }
     }
 
-    // Check locals.
-    LocalFrames::const_iterator it = findLocal(varname);
+    // Check locals for getting them
+    LocalFrames::const_iterator it = findLocal(varname, true);
     if (it != endLocal()) {
        // Get local var.
        return it->m_value;
@@ -158,8 +158,8 @@
                }
        }
 
-       // Check locals.
-       LocalFrames::iterator it = findLocal(varname);
+       // Check locals for deletion.
+       LocalFrames::iterator it = findLocal(varname, true);
        if (it != endLocal())
        {
                // delete local var.
@@ -243,8 +243,8 @@
                }
        }
     
-    // Check locals.
-    LocalFrames::iterator it = findLocal(varname);
+    // Check locals for setting them
+    LocalFrames::iterator it = findLocal(varname, true);
     if (it != endLocal()) {
        // Set local var.
        it->m_value = val;
@@ -270,6 +270,8 @@
 as_environment::set_local(const std::string& varname, const as_value& val)
 {
     // Is it in the current frame already?
+    // TODO: should we descend to upper frames ?
+    //       (probably not as we want to update it)
     LocalFrames::iterator it = findLocal(varname), itEnd=endLocal();
     if (it == itEnd) {
        // Not in frame; create a new local var.
@@ -297,6 +299,8 @@
 as_environment::declare_local(const std::string& varname)
 {
     // Is it in the current frame already?
+    // TODO: should we descend to upper frames ?
+    //       (probably not as we want to declare it)
     LocalFrames::const_iterator it = findLocal(varname), itEnd=endLocal();
     if (it == itEnd) {
        // Not in frame; create a new local var.
@@ -558,31 +562,12 @@
 
 /*private*/
 as_environment::LocalFrames::iterator
-as_environment::findLocal(const std::string& varname)
+as_environment::findLocal(const std::string& varname, bool descend)
 {
-#if 0
-       LocalFrames::reverse_iterator itEnd=m_local_frames.rend();
-       for (LocalFrames::reverse_iterator it=m_local_frames.rbegin();
-                       it != itEnd;
-                       ++it)
-       {
-               const frame_slot& slot = *it;
-               if ( slot.m_name.length() == 0 )
-               {
-                       // End of local frame; stop looking.
-                       return itEnd;
-               }
-               else if ( slot.m_name == varname )
-               {
-                       return it;
-               }
-       }
-       return itEnd;
-#else
        for (int i = m_local_frames.size() - 1; i >= 0; i--)
        {
                const frame_slot&       slot = m_local_frames[i];
-               if (slot.m_name.length() == 0)
+               if (!descend && slot.m_name.length() == 0)
                {
                        // End of local frame; stop looking.
                        return endLocal();
@@ -594,7 +579,6 @@
                }
        }
        return endLocal();
-#endif
 }
 
 }

Index: server/as_environment.h
===================================================================
RCS file: /sources/gnash/gnash/server/as_environment.h,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -b -r1.30 -r1.31
--- server/as_environment.h     8 Dec 2006 23:11:25 -0000       1.30
+++ server/as_environment.h     14 Dec 2006 14:06:06 -0000      1.31
@@ -18,7 +18,7 @@
 //
 //
 
-/* $Id: as_environment.h,v 1.30 2006/12/08 23:11:25 strk Exp $ */
+/* $Id: as_environment.h,v 1.31 2006/12/14 14:06:06 strk Exp $ */
 
 #ifndef GNASH_AS_ENVIRONMENT_H
 #define GNASH_AS_ENVIRONMENT_H
@@ -324,13 +324,22 @@
                const std::vector<with_stack_entry>& with_stack) const;
 
 
+       /// \brief
        /// Return an iterator to the local variable with given name,
        /// or an iterator to it's end() iterator if none found
-       LocalFrames::iterator findLocal(const std::string& varname);
+       //
+       /// @param varname
+       ///     Name of the local variable
+       ///
+       /// @param descend
+       ///     If true the seek don't stop at local frame top, but
+       ///     descends in upper frames. By default it is false.
+       ///
+       LocalFrames::iterator findLocal(const std::string& varname, bool 
descend=false);
 
-       LocalFrames::const_iterator findLocal(const std::string& varname) const
+       LocalFrames::const_iterator findLocal(const std::string& varname, bool 
descend=false) const
        {
-               return const_cast<as_environment*>(this)->findLocal(varname);
+               return const_cast<as_environment*>(this)->findLocal(varname, 
descend);
        }
 
        LocalFrames::iterator endLocal() {

Index: testsuite/actionscript.all/Function.as
===================================================================
RCS file: /sources/gnash/gnash/testsuite/actionscript.all/Function.as,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -b -r1.17 -r1.18
--- testsuite/actionscript.all/Function.as      22 Nov 2006 14:58:25 -0000      
1.17
+++ testsuite/actionscript.all/Function.as      14 Dec 2006 14:06:06 -0000      
1.18
@@ -20,16 +20,18 @@
 // compile this test case with Ming makeswf, and then
 // execute it like this gnash -1 -r 0 -v out.swf
 
-rcsid="$Id: Function.as,v 1.17 2006/11/22 14:58:25 strk Exp $";
+rcsid="$Id: Function.as,v 1.18 2006/12/14 14:06:06 strk Exp $";
 
 #include "check.as"
 
 
+#if 0
+
 // Define a function returning 'this'.name and the given args
 function getThisName(a,b,c) { return this.name+a+b+c; }
 
 check (getThisName != undefined);
-check ( typeof(getThisName) == "function" );
+check_equals ( typeof(getThisName), "function" );
 
 // Test Function.apply(this_ref)
 var this_ref = {name:"extname"};
@@ -144,3 +146,113 @@
 check ( testInstance instanceof TestClass );
 check ( stringInstance instanceof String );
 
+#endif
+
+//----------------------------------------------------------
+//
+// Test access of a timeline locals from within a function
+//
+//----------------------------------------------------------
+
+// These are timeline "locals" (note the 'var' prefix).
+// They should produce DEFINELOCAL tags
+var tl_local = "tl_local";
+var todelete = "deleteme";
+var tooverride = "tooverride";
+a_func = function() {
+
+       // get a "local" var of this function
+       var localvar = "lv";
+       check_equals(localvar, "lv");
+
+       // get a "local" var of the timeline
+       check_equals(tl_local, "tl_local");
+
+       // A "local" var of this function with
+       // hides a "local" var of the timeline
+       // with the same name, but just within
+       // this context (there's another check
+       // outside the function to verify the
+       // original value is preserved there)
+       var tooverride = "overridden";
+       check_equals(tooverride, "overridden");
+
+       // set a "local" var of the timeline
+       tl_local = "tl_local2";
+
+       // delete a "local" var of the timeline
+       delete todelete;
+
+       // create a new variable of the timeline
+       tl_new = "tl_new";
+
+       // create a new function "local" for this function.
+       check(! delete fl_func); // make sure there's no other
+       var fl_func = function() { };
+
+       // create a new function on the timeline
+       // (this only works with SWF6 or up)
+       check(! delete f_func); // make sure there's no other
+       f_func = function() { };
+
+};
+check_equals(f_func, undefined); // will be created by a_func() call
+check_equals(tl_new, undefined); // will be created by a_func() call
+a_func(); // create tl_new and f_func
+check_equals(tl_local, "tl_local2");
+check_equals(todelete, undefined);
+check_equals(tooverride, "tooverride");
+check_equals(tl_new, "tl_new");
+check_equals(fl_func, undefined);
+check_equals(typeof(f_func), 'function'); // created by a_func() call
+
+//----------------------------------------------------------
+//
+// Test nested functions
+//
+//----------------------------------------------------------
+
+var result1 = "initial_result1_value";
+var result2 = "initial_result2_value";
+// just to make sure that eval works (more of a Ming test this one..)
+check_equals(eval("result1"), "initial_result1_value");
+
+outer_func = function() 
+{
+       var a = "hello";
+
+       // inner_func should be created on the timeline,
+       // see previous tests block
+       inner_func = function(var_ref) 
+       {
+               return(eval(var_ref));
+       };
+  
+       result1 = inner_func("a");  // should return "hello"
+};
+
+//call outer_func to set result1
+check_equals(typeof(outer_func), 'function');
+outer_func(); 
+
+// call inner_func to set result2
+check_equals(typeof(inner_func), 'function');
+result2 = inner_func("a");  // should return "hello"
+
+#if OUTPUT_VERSION >= 6
+
+  check_equals ( result1, "hello" );
+
+  // Gnash fails here, we want this fixed!
+  xcheck_equals ( result2, "hello" );
+
+#else // SWF5 or lower seems unable to work with nested functions
+
+  xcheck_equals ( result1, undefined );
+
+  // Gnash succeeds here, but that's for the same reason why it
+  // fails in the SWF6+ section above...
+  check_equals ( result2, undefined );
+
+#endif
+




reply via email to

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