gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash ChangeLog server/as_object.cpp testsuite/...


From: Sandro Santilli
Subject: [Gnash-commit] gnash ChangeLog server/as_object.cpp testsuite/...
Date: Mon, 04 Feb 2008 09:47:51 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  08/02/04 09:47:50

Modified files:
        .              : ChangeLog 
        server         : as_object.cpp 
        testsuite/actionscript.all: Global.as 

Log message:
        Fix handling of second argument to AsSetPropFlags (null, array or 
invalid).

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.5552&r2=1.5553
http://cvs.savannah.gnu.org/viewcvs/gnash/server/as_object.cpp?cvsroot=gnash&r1=1.95&r2=1.96
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/actionscript.all/Global.as?cvsroot=gnash&r1=1.40&r2=1.41

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.5552
retrieving revision 1.5553
diff -u -b -r1.5552 -r1.5553
--- ChangeLog   3 Feb 2008 09:18:49 -0000       1.5552
+++ ChangeLog   4 Feb 2008 09:47:49 -0000       1.5553
@@ -1,3 +1,10 @@
+2008-02-04 Sandro Santilli <address@hidden>
+
+       * server/as_object.cpp (setPropFlags): fix handling of second
+         argument (null, array or invalid).
+       * testsuite/actionscript.all/Global.as: add more tests for
+         AsSetPropFlags.
+
 2008-02-03 Bastiaan Jacques <address@hidden>
 
        * server/asobj/NetStreamGst.cpp: Add some more error handling and

Index: server/as_object.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/as_object.cpp,v
retrieving revision 1.95
retrieving revision 1.96
diff -u -b -r1.95 -r1.96
--- server/as_object.cpp        24 Jan 2008 16:13:55 -0000      1.95
+++ server/as_object.cpp        4 Feb 2008 09:47:50 -0000       1.96
@@ -31,6 +31,8 @@
 #include "fn_call.h" // for generic methods
 #include "Object.h" // for getObjectInterface
 #include "action.h" // for call_method
+#include "array.h" // for setPropFlags
+
 #include <set>
 #include <string>
 #include <boost/algorithm/string/case_conv.hpp>
@@ -578,6 +580,27 @@
        _members.dump(*this, to);
 }
 
+class FlagsSetterVisitor {
+       string_table& _st;
+       PropertyList& _pl;
+       int _setTrue;
+       int _setFalse;
+public:
+       FlagsSetterVisitor(string_table& st, PropertyList& pl, int setTrue, int 
setFalse)
+               :
+               _st(st),
+               _pl(pl),
+               _setTrue(setTrue),
+               _setFalse(setFalse)
+       {}
+
+       void visit(as_value& v)
+       {
+               string_table::key key = _st.find(v.to_string());
+               _pl.setFlags(key, _setTrue, _setFalse);
+       }
+};
+
 void
 as_object::setPropFlags(as_value& props_val, int set_false, int set_true)
 {
@@ -618,23 +641,19 @@
                return;
        }
 
-       boost::intrusive_ptr<as_object> props = props_val.to_object();
-
        // Evan: it seems that if set_true == 0 and set_false == 0,
        // this function acts as if the parameters were (object, null, 0x1, 0)
+#if 0 // bullshit, see actionscript.all/Global.as
        if (set_false == 0 && set_true == 0)
        {
-           props = NULL;
+           props_val.set_null();
            set_false = 0;
            set_true = 0x1;
        }
+#endif
 
-       if (props == NULL)
+       if (props_val.is_null())
        {
-               // TODO: this might be a comma-separated list
-               //       of props as a string !!
-               //
-
                // Take all the members of the object
                //std::pair<size_t, size_t> result = 
                _members.setFlagsAll(set_true, set_false);
@@ -647,12 +666,27 @@
                        m_prototype->_members.setFlagsAll(set_true, set_false);
                }
 #endif
+               return;
        }
-       else
+
+       boost::intrusive_ptr<as_object> props = props_val.to_object();
+       as_array_object* ary = dynamic_cast<as_array_object*>(props.get());
+       if ( ! ary )
        {
-               //std::pair<size_t, size_t> result = 
-               _members.setFlagsAll(props->_members, set_true, set_false);
+               IF_VERBOSE_ASCODING_ERRORS(
+               log_aserror(_("Invalid call to AsSetPropFlags: "
+                       "invalid second argument %s "
+                       "(expected string, null or an array)"),
+                       props_val.to_debug_string().c_str());
+               );
+               return;
        }
+
+       // The passed argument has to be considered an array
+       //std::pair<size_t, size_t> result = 
+       FlagsSetterVisitor visitor(getVM().getStringTable(), _members, 
set_true, set_false);
+       ary->visitAll(visitor);
+       //_members.setFlagsAll(props->_members, set_true, set_false);
 }
 
 

Index: testsuite/actionscript.all/Global.as
===================================================================
RCS file: /sources/gnash/gnash/testsuite/actionscript.all/Global.as,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -b -r1.40 -r1.41
--- testsuite/actionscript.all/Global.as        30 Jan 2008 17:21:29 -0000      
1.40
+++ testsuite/actionscript.all/Global.as        4 Feb 2008 09:47:50 -0000       
1.41
@@ -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: Global.as,v 1.40 2008/01/30 17:21:29 bwy Exp $";
+rcsid="$Id: Global.as,v 1.41 2008/02/04 09:47:50 strk Exp $";
 
 #include "check.as"
 
@@ -272,20 +272,101 @@
 #endif // OUTPUT_VERSION == 7
 
 
+o = {};
+var tmp = new Array;
+for (var i in o) tmp.push(i);
+check_equals(tmp.length, 0);
+
+o.a = 1;
+o.b = 2;
+o.c = 3;
+tmp = new Array;
+for (var i in o) tmp.push(i);
+check_equals(tmp.length, 3);
+
+// ASSetPropFlags passing an array of property names
+
+ret = ASSetPropFlags(o, ["b"], 1); // an array of prop names
+check_equals(typeof(ret), 'undefined');
+tmp = new Array;
+for (var i in o) tmp.push(i);
+check_equals(tmp.length, 2);
+tmp.sort();
+check_equals(tmp[0], 'a');
+check_equals(tmp[1], 'c');
+
+// ASSetPropFlags passing an non-array object for property names 
+// (invalid)
+
+ret = ASSetPropFlags(o, {c:2}, 1); // an object is not valid, must be an array
+check_equals(typeof(ret), 'undefined');
+tmp = new Array;
+for (var i in o) tmp.push(i);
+check_equals(tmp.length, 2);
+tmp.sort();
+check_equals(tmp[0], 'a');
+check_equals(tmp[1], 'c');
+
+// ASSetPropFlags passing an array-like object for property names 
+// (still invalid)
+
+p = {};
+p.length = 1;
+p['0'] = 'c';
+ret = ASSetPropFlags(o, p, 1); 
+check_equals(typeof(ret), 'undefined');
+tmp = new Array;
+for (var i in o) tmp.push(i);
+check_equals(tmp.length, 2);
+tmp.sort();
+check_equals(tmp[0], 'a');
+check_equals(tmp[1], 'c');
+
+// ASSetPropFlags passing undefined for property names 
+// (still invalid)
+
+ret = ASSetPropFlags(o, undefined, 1); 
+check_equals(typeof(ret), 'undefined');
+tmp = new Array;
+for (var i in o) tmp.push(i);
+check_equals(tmp.length, 2);
+
+// ASSetPropFlags passing null for property names 
+// (still invalid)
+
+ret = ASSetPropFlags(o, null, 1); 
+check_equals(typeof(ret), 'undefined');
+tmp = new Array;
+for (var i in o) tmp.push(i);
+check_equals(tmp.length, 0);
+
+// ASSetPropFlags passing a string and 0,0 true/false sets
+
+o = {a:1, b:2, c:3};
+ASSetPropFlags(o, "b", 1, 0); 
+tmp = new Array; for (var i in o) tmp.push(i);
+check_equals(tmp.length, 2);
+
+ASSetPropFlags(o, ['c'], 0, 0);  // 0,0 has no special meaning
+tmp = new Array; for (var i in o) tmp.push(i);
+check_equals(tmp.length, 2);
+
+
+
 //------------------------------------------------------------
 // END OF TEST
 //------------------------------------------------------------
 
 #if OUTPUT_VERSION == 5
-       check_totals(57); // SWF5
+       check_totals(77); // SWF5
 #else
 # if OUTPUT_VERSION == 6
-       check_totals(91); // SWF6
+       check_totals(111); // SWF6
 # else
 #  if OUTPUT_VERSION == 7
-       check_totals(73); // SWF7
+       check_totals(93); // SWF7
 #  else
-       check_totals(60); // SWF8+
+       check_totals(80); // SWF8+
 #  endif
 # endif
 #endif




reply via email to

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