gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash ChangeLog server/as_function.cpp testsuit...


From: Sandro Santilli
Subject: [Gnash-commit] gnash ChangeLog server/as_function.cpp testsuit...
Date: Sat, 06 Oct 2007 06:28:29 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  07/10/06 06:28:29

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

Log message:
                * server/as_function.cpp (function_call): handle the case in 
which
                  first argument given to Function.call does not cast to an 
object.
                  The handling is not correct, but at least prevents assertion
                  failures and prints an ascoding error. Fixes bug #21236.
                * testsuite/actionscript.all/Function.as: add few more tests for
                  Function.call(<not-an-object>).

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.4549&r2=1.4550
http://cvs.savannah.gnu.org/viewcvs/gnash/server/as_function.cpp?cvsroot=gnash&r1=1.43&r2=1.44
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/actionscript.all/Function.as?cvsroot=gnash&r1=1.57&r2=1.58

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.4549
retrieving revision 1.4550
diff -u -b -r1.4549 -r1.4550
--- ChangeLog   6 Oct 2007 00:49:51 -0000       1.4549
+++ ChangeLog   6 Oct 2007 06:28:29 -0000       1.4550
@@ -1,3 +1,12 @@
+2007-10-06 Sandro Santilli <address@hidden>
+
+       * server/as_function.cpp (function_call): handle the case in which
+         first argument given to Function.call does not cast to an object.
+         The handling is not correct, but at least prevents assertion
+         failures and prints an ascoding error. Fixes bug #21236.
+       * testsuite/actionscript.all/Function.as: add few more tests for
+         Function.call(<not-an-object>).
+
 2007-10-05  Rob Savoye  <address@hidden>
 
        * macros/boost.m4: Adjust error messages when boost files aren't

Index: server/as_function.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/as_function.cpp,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -b -r1.43 -r1.44
--- server/as_function.cpp      28 Sep 2007 10:10:36 -0000      1.43
+++ server/as_function.cpp      6 Oct 2007 06:28:29 -0000       1.44
@@ -298,8 +298,29 @@
        else
        {
                // Get the object to use as 'this' reference
-               boost::intrusive_ptr<as_object> this_ptr = 
fn.arg(0).to_object();
+               as_value this_val = fn.arg(0);
+               boost::intrusive_ptr<as_object> this_ptr = this_val.to_object();
+
+               if ( ! this_ptr )
+               {
+                       // If the first argument is not an object, we should
+                       // not pass an object to the function, which I belive
+                       // should be allowed (but gnash code is not ready).
+                       // Anyway, the 'this' label inside the function should 
+                       // then be a strange object in that typeof() would 
return
+                       // 'object' but when compared to undefined matches !!
+                       // See actionscript.all/Function.as
+                       IF_VERBOSE_ASCODING_ERRORS(
+                       log_aserror(_("First argument to Function.call(%s) 
doesn't cast to object. "
+                               "Gnash will keep the current 'this' pointer as 
it is, "
+                               "but this is known to not be the correct way to 
handle "
+                               "such a malformed call."), 
this_val.to_debug_string().c_str());
+                       );
+               }
+               else
+               {
                new_fn_call.this_ptr = this_ptr;
+               }
                new_fn_call.nargs--;
                new_fn_call.set_offset(new_fn_call.offset()-1);
        }

Index: testsuite/actionscript.all/Function.as
===================================================================
RCS file: /sources/gnash/gnash/testsuite/actionscript.all/Function.as,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -b -r1.57 -r1.58
--- testsuite/actionscript.all/Function.as      29 Sep 2007 16:22:57 -0000      
1.57
+++ testsuite/actionscript.all/Function.as      6 Oct 2007 06:28:29 -0000       
1.58
@@ -21,7 +21,7 @@
 // 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.57 2007/09/29 16:22:57 strk Exp $";
+rcsid="$Id: Function.as,v 1.58 2007/10/06 06:28:29 strk Exp $";
 
 #include "check.as"
 
@@ -133,9 +133,31 @@
 
 #if OUTPUT_VERSION >= 6
 
-// Test Function.call(arg1, arg2, arg3)
+// Test Function.call(this, arg1, arg2, arg3)
 check_equals ( getThisName.call(this_ref, 1, 2, 3), "extname123" );
 
+// Test Function.call(null, arg1, arg2, arg3)
+nullcall = getThisName.call(null, 1, 2, 3);
+#if OUTPUT_VERSION > 6
+ check_equals ( typeof(nullcall), 'number' );
+ check ( isNaN(nullcall) );
+#else
+ check_equals ( nullcall, 6 );
+#endif
+
+function getThis () { ++c; return this; }
+o={};
+c=0;
+ret = getThis.call(o);
+check_equals(ret, o);
+check_equals(c, 1);
+ret = getThis.call(null);
+check_equals(c, 2);
+xcheck_equals(typeof(ret), 'object');
+xcheck_equals(ret, undefined); // an object type which returns 'undefined' as 
primitive value ?
+check( ! (ret === undefined) ); // an object type which returns 'undefined' as 
primitive value ?
+check( ! (ret === null) ); // an object type which returns 'undefined' as 
primitive value ?
+
 #else // OUTPUT_VERSION < 6
 
 check_equals ( typeOf(getThisName.call), 'undefined' );




reply via email to

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