gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash ChangeLog server/asobj/MovieClipLoader.cp...


From: Sandro Santilli
Subject: [Gnash-commit] gnash ChangeLog server/asobj/MovieClipLoader.cp...
Date: Fri, 21 Dec 2007 02:27:53 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  07/12/21 02:27:53

Modified files:
        .              : ChangeLog 
        server/asobj   : MovieClipLoader.cpp 
        testsuite/actionscript.all: MovieClipLoader.as 

Log message:
        don't abort if MovieClipLoader.getProgress is called w/out an argument,
        make the members of returned object enumerable.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.5237&r2=1.5238
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/MovieClipLoader.cpp?cvsroot=gnash&r1=1.39&r2=1.40
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/actionscript.all/MovieClipLoader.as?cvsroot=gnash&r1=1.6&r2=1.7

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.5237
retrieving revision 1.5238
diff -u -b -r1.5237 -r1.5238
--- ChangeLog   21 Dec 2007 00:56:07 -0000      1.5237
+++ ChangeLog   21 Dec 2007 02:27:52 -0000      1.5238
@@ -1,3 +1,11 @@
+2007-12-20 Sandro Santilli <address@hidden>
+
+       * server/asobj/MovieClipLoader.cpp: don't abort if getProgress
+         is called w/out an argument, make the members of returned object
+         enumerable.
+       * testsuite/actionscript.all/MovieClipLoader.as: test
+         MovieClipLoader.getProgress.
+
 2007-12-20  Rob Savoye  <address@hidden>
 
        * server/asobj/SharedObject.cpp: Use the domain name as part of the

Index: server/asobj/MovieClipLoader.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/MovieClipLoader.cpp,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -b -r1.39 -r1.40
--- server/asobj/MovieClipLoader.cpp    20 Dec 2007 14:28:50 -0000      1.39
+++ server/asobj/MovieClipLoader.cpp    21 Dec 2007 02:27:52 -0000      1.40
@@ -34,6 +34,7 @@
 #include "log.h"
 #include "URL.h" // for url parsing
 #include "VM.h" // for the string table.
+#include "string_table.h" // for the string table.
 #include "builtin_function.h"
 #include "Object.h" // for getObjectInterface
 #include "AsBroadcaster.h" // for initializing self as a broadcaster
@@ -43,6 +44,7 @@
 #include <typeinfo> 
 #include <string>
 #include <set>
+#include <boost/algorithm/string/case_conv.hpp> // for PROPNAME 
 
 namespace gnash {
 
@@ -324,20 +326,30 @@
 static as_value
 moviecliploader_getprogress(const fn_call& fn)
 {
-  //log_msg(_("%s: nargs = %d"), __FUNCTION__, nargs);
+       //log_debug(_("%s: nargs = %d"), __FUNCTION__, nargs);
   
   boost::intrusive_ptr<MovieClipLoader> ptr = 
ensureType<MovieClipLoader>(fn.this_ptr);
   
+       if ( ! fn.nargs )
+       {
+               IF_VERBOSE_ASCODING_ERRORS(
+               log_aserror(_("MovieClipLoader.getProgress(): missing 
argument"));
+               );
+               return as_value();
+       }
+
   boost::intrusive_ptr<as_object> target = fn.arg(0).to_object();
   
   struct mcl *mcl_data = ptr->getProgress(target.get());
 
   boost::intrusive_ptr<mcl_as_object> mcl_obj ( new mcl_as_object );
 
-  mcl_obj->init_member("bytesLoaded", mcl_data->bytes_loaded);
-  mcl_obj->init_member("bytesTotal",  mcl_data->bytes_total);
+       // We want these to be enumerable
+       string_table& st = ptr->getVM().getStringTable();
+       mcl_obj->set_member(st.find(PROPNAME("bytesLoaded")), 
mcl_data->bytes_loaded);
+       mcl_obj->set_member(st.find(PROPNAME("bytesTotal")),  
mcl_data->bytes_total);
   
-  return as_value(mcl_obj.get()); // will store in a boost::intrusive_ptr
+       return as_value(mcl_obj.get()); // will keep alive
 }
 
 void

Index: testsuite/actionscript.all/MovieClipLoader.as
===================================================================
RCS file: /sources/gnash/gnash/testsuite/actionscript.all/MovieClipLoader.as,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- testsuite/actionscript.all/MovieClipLoader.as       20 Dec 2007 14:28:50 
-0000      1.6
+++ testsuite/actionscript.all/MovieClipLoader.as       21 Dec 2007 02:27:53 
-0000      1.7
@@ -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: MovieClipLoader.as,v 1.6 2007/12/20 14:28:50 strk Exp $";
+rcsid="$Id: MovieClipLoader.as,v 1.7 2007/12/21 02:27:53 strk Exp $";
 
 #include "check.as"
 
@@ -68,7 +68,7 @@
 MovieClipLoader.prototype.bm = MovieClipLoader.prototype.broadcastMessage;
 MovieClipLoader.prototype.broadcastMessage = function(arg1, arg2, arg3, arg4)
 {
-       note("Broadcasting "+arg1);
+       //note("Broadcasting "+arg1);
        //this.bm(arg1, arg2, arg3, arg4);
        this.bm.apply(this, arguments);
 };
@@ -126,11 +126,8 @@
 };
 totalProgressCalls=0;
 
-mcl.onLoadError = function(target, msg, n)
+nextTestOrEnd = function()
 {
-       check_equals(arguments.length, 3);
-       check_equals(target, expected.target);
-       note("onLoadError called ("+msg+")");
        if ( state.nextFunction == undefined )
        {
                // we don't know how many times onLoadProgress will be called
@@ -141,9 +138,10 @@
                // the bug from supposedly subsequent callbacks, which check for
                // a local flag set by the onLoadProgress handler.
                //
-               progCallbackTests = totalProgressCalls*6;
+               var testsPerProgressCallback = 15;
+               progCallbackTests = totalProgressCalls*testsPerProgressCallback;
                note("Number of onLoadProgress runs: "+totalProgressCalls+" - 
tests: "+progCallbackTests);
-               if ( expect.failtotals ) {
+               if ( expected.failtotals ) {
                        xcheck_totals(expected.totals + progCallbackTests);
                } else {
                        check_totals(expected.totals + progCallbackTests);
@@ -154,6 +152,14 @@
        {
                state.nextFunction();
        }
+};
+
+mcl.onLoadError = function(target, msg, n)
+{
+       check_equals(arguments.length, 3);
+       check_equals(target, expected.target);
+       note("onLoadError called ("+msg+")");
+       nextTestOrEnd();
        //dumpObj(arguments);
 };
 
@@ -162,17 +168,37 @@
        check_equals(arguments.length, 1);
        check_equals(target, expected.target);
        state.onLoadStartCalls++;
+       note("onLoadStart("+target+", "+target._url+") called");
        //note("onLoadStart called with "+arguments.length+" args:"); 
dumpObj(arguments);
 };
 
 mcl.onLoadProgress = function(target, bytesLoaded, bytesTotal)
 {
+       //note("onLoadProgress("+target+", "+target._url+") called");
+
        check_equals(arguments.length, 3);
        check_equals(target, expected.target);
        check_equals(state.onLoadStartCalls, 1);
        check_equals(typeof(bytesLoaded), 'number')
        check_equals(typeof(bytesTotal), 'number')
        check(bytesTotal <= bytesTotal);
+
+       check_equals(this, mcl);
+
+       var tmp = this.getProgress();
+       check_equals(typeof(tmp), 'undefined');
+
+       var prog = this.getProgress(target);
+       check_equals(typeof(prog), 'object');
+       check_equals(prog.__proto__, undefined);
+       check_equals(prog.bytesLoaded, bytesLoaded);
+       check_equals(prog.bytesTotal, bytesTotal);
+       var progcopy = {}; var progcount=0;
+       for (var i in prog) { progcopy[i] = prog[i]; progcount++; }
+       check_equals(progcount, 2);
+       check_equals(progcopy.bytesLoaded, bytesLoaded);
+       check_equals(progcopy.bytesTotal, bytesTotal);
+
        ++state.onLoadProgressCalls;
        ++totalProgressCalls;
        //note("onLoadProgress called with "+arguments.length+" args:"); 
dumpObj(arguments);
@@ -180,6 +206,7 @@
 
 mcl.onLoadComplete = function(target, n)
 {
+       note("onLoadComplete("+target+", "+target._url+") called");
        check_equals(arguments.length, 2);
        check_equals(target, expected.target);
        check_equals(state.onLoadStartCalls, 1);
@@ -192,6 +219,7 @@
 
 mcl.onLoadInit = function(target)
 {
+       note("onLoadInit("+target+", "+target._url+") called");
        check_equals(arguments.length, 1);
        check_equals(target, expected.target);
        check_equals(state.onLoadStartCalls, 1);
@@ -201,30 +229,7 @@
 
        //note("target.var1: "+target.var1);
        //note("onLoadInit called with "+arguments.length+" args:"); 
dumpObj(arguments);
-       if ( state.nextFunction == undefined )
-       {
-               // we don't know how many times onLoadProgress will be called
-               // so we have that handler increment a totalProgressCalls and
-               // we use that value to  figure out how many tests to expect to
-               // be run (6 tests each onLoadProgress call).
-               // Note that if we miss to call onLoadProgress at all we'd catch
-               // the bug from supposedly subsequent callbacks, which check for
-               // a local flag set by the onLoadProgress handler.
-               //
-               progCallbackTests = totalProgressCalls*6;
-               note("Number of onLoadProgress runs: "+totalProgressCalls+" - 
tests: "+progCallbackTests);
-               if ( expect.failtotals ) {
-                       xcheck_totals(expected.totals + progCallbackTests);
-               } else {
-                       check_totals(expected.totals + progCallbackTests);
-               }
-               
-               play();
-       }
-       else
-       {
-               state.nextFunction();
-       }
+       nextTestOrEnd();
 };
 
 check( ! mcl.loadClip() );
@@ -263,12 +268,15 @@
        // onLoadProgress)
        //
        // subtract the number of progress callback runs reported when playing 
from the totals to get the correct number
+       // BUT MAKE SURE nextTestOrEnd CONTAINS THE CORRECT 
testsPerProgressCallback INFO !!
        //
        expected.totals = 57;
        // gnash doesn't call onLoadInit if the data at the url is not an SWF 
or JPG
        // (or whatever else can become a movie_instance), while the PP does.
        // So in this testcase, the attempt to load vars.txt is invalid for 
Gnash
        // (triggers onLoadError) 
+       // TODO: fix gnash to be compatible and find out if there's anything
+       //       actually dont for loadVariable-like data
        //
        expected.failtotals = true;
 




reply via email to

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