gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash ChangeLog server/sprite_instance.cpp test...


From: Sandro Santilli
Subject: [Gnash-commit] gnash ChangeLog server/sprite_instance.cpp test...
Date: Tue, 08 Jan 2008 10:36:57 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  08/01/08 10:36:57

Modified files:
        .              : ChangeLog 
        server         : sprite_instance.cpp 
        testsuite/actionscript.all: MovieClip.as 

Log message:
        implement MovieClip.meth() function.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.5338&r2=1.5339
http://cvs.savannah.gnu.org/viewcvs/gnash/server/sprite_instance.cpp?cvsroot=gnash&r1=1.429&r2=1.430
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/actionscript.all/MovieClip.as?cvsroot=gnash&r1=1.111&r2=1.112

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.5338
retrieving revision 1.5339
diff -u -b -r1.5338 -r1.5339
--- ChangeLog   8 Jan 2008 07:58:50 -0000       1.5338
+++ ChangeLog   8 Jan 2008 10:36:56 -0000       1.5339
@@ -1,5 +1,7 @@
 2008-01-08 Sandro Santilli <address@hidden>
 
+       * server/sprite_instance.cpp: implement MovieClip.meth() function.
+       * testsuite/actionscript.all/MovieClip.as: tests for MovieClip.meth().
        * testsuite/misc-mtasc.all/level99.as: add tests for _levelX._name
          being undefined.
 

Index: server/sprite_instance.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/sprite_instance.cpp,v
retrieving revision 1.429
retrieving revision 1.430
diff -u -b -r1.429 -r1.430
--- server/sprite_instance.cpp  7 Jan 2008 20:31:11 -0000       1.429
+++ server/sprite_instance.cpp  8 Jan 2008 10:36:57 -0000       1.430
@@ -877,6 +877,25 @@
        return as_value(sprite->getSWFVersion());
 }
 
+// MovieClip.meth(<string>) : Number
+//
+// Parses case-insensitive "get" and "post" into 1 and 2, 0 anything else
+// 
+static as_value
+sprite_meth(const fn_call& fn)
+{
+       boost::intrusive_ptr<sprite_instance> sprite = 
ensureType<sprite_instance>(fn.this_ptr);
+
+       if ( ! fn.nargs ) return as_value(0);
+       as_value& v = fn.arg(0);
+       if ( ! v.is_string() ) return as_value(0);
+       std::string s = v.to_string();
+       boost::to_lower(s);
+       if ( s == "get" ) return as_value(1);
+       if ( s == "post" )  return as_value(2);
+       return as_value(0);
+}
+
 // getTextSnapshot() : TextSnapshot
 static as_value
 sprite_getTextSnapshot(const fn_call& fn)
@@ -1783,6 +1802,7 @@
        o.init_member("globalToLocal", new 
builtin_function(sprite_globalToLocal));
        o.init_member("localToGlobal", new 
builtin_function(sprite_localToGlobal));
        o.init_member("getSWFVersion", new 
builtin_function(sprite_getSWFVersion));
+       o.init_member("meth", new builtin_function(sprite_meth));
        o.init_member("enabled", true); // see MovieClip.as testcase
 
        gettersetter = new builtin_function(&sprite_instance::lockroot_getset, 
NULL);

Index: testsuite/actionscript.all/MovieClip.as
===================================================================
RCS file: /sources/gnash/gnash/testsuite/actionscript.all/MovieClip.as,v
retrieving revision 1.111
retrieving revision 1.112
diff -u -b -r1.111 -r1.112
--- testsuite/actionscript.all/MovieClip.as     26 Dec 2007 12:35:13 -0000      
1.111
+++ testsuite/actionscript.all/MovieClip.as     8 Jan 2008 10:36:57 -0000       
1.112
@@ -20,7 +20,7 @@
 // compile this test case with Ming makeswf, and then
 // execute it like this gnash -1 -r 0 -v out.swf
 
-rcsid="$Id: MovieClip.as,v 1.111 2007/12/26 12:35:13 strk Exp $";
+rcsid="$Id: MovieClip.as,v 1.112 2008/01/08 10:36:57 strk Exp $";
 
 #include "check.as"
 
@@ -78,6 +78,7 @@
 check_equals(typeof(mc.globalToLocal), 'function');
 check_equals(typeof(mc.localToGlobal), 'function');
 check_equals(typeof(mc.unloadMovie), 'function');
+check_equals(typeof(mc.meth), 'function');
 check_equals(typeof(mc.getSWFVersion), 'function');
 check_equals(mc.getSWFVersion(), OUTPUT_VERSION);
 
@@ -87,6 +88,7 @@
 check(!MovieClip.prototype.hasOwnProperty('loadMovieNum'));
 check(!MovieClip.prototype.hasOwnProperty('valueOf')); 
 check(!MovieClip.prototype.hasOwnProperty('toString')); 
+check(MovieClip.prototype.hasOwnProperty('meth')); 
 #endif
 check_equals(typeof(mc.valueOf), 'function');
 check_equals(typeof(mc.toString), 'function');
@@ -1294,16 +1296,58 @@
 
 #endif // OUTPUT_VERSION >= 7
 
+//---------------------------------------------------------------------
+// Test the MovieClip.prototype.meth function
+//---------------------------------------------------------------------
+
+ret = _root.meth();
+check_equals(typeof(ret), 'number');
+check_equals(ret, 0);
+
+ret = _root.meth(1);
+check_equals(typeof(ret), 'number');
+check_equals(ret, 0);
+
+ret = _root.meth('post');
+check_equals(typeof(ret), 'number');
+check_equals(ret, 2);
+
+ret = _root.meth('POSt');
+check_equals(typeof(ret), 'number');
+check_equals(ret, 2);
+
+ret = _root.meth('pOStIcipate');
+check_equals(typeof(ret), 'number');
+check_equals(ret, 0);
+
+ret = _root.meth('G');
+check_equals(typeof(ret), 'number');
+check_equals(ret, 0);
+
+ret = _root.meth('geT');
+check_equals(typeof(ret), 'number');
+check_equals(ret, 1);
+
+ret = _root.meth('geTty');
+check_equals(typeof(ret), 'number');
+check_equals(ret, 0);
+
+o = {}; o.toString = function() { return "post"; };
+ret = _root.meth(o);
+check_equals(typeof(ret), 'number');
+check_equals(ret, 0);
+
+
 #if OUTPUT_VERSION < 6
- check_totals(166); // SWF5
+ check_totals(185); // SWF5
 #else
 #if OUTPUT_VERSION < 7
- check_totals(561); // SWF6
+ check_totals(581); // SWF6
 #else
 #if OUTPUT_VERSION < 8
- check_totals(578); // SWF7
+ check_totals(598); // SWF7
 #else
- check_totals(579); // SWF8+
+ check_totals(599); // SWF8+
 #endif
 #endif
 #endif




reply via email to

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