CVSROOT: /sources/gnash Module name: gnash Changes by: Sandro Santilli <strk> 07/04/26 10:17:56
Modified files: . : ChangeLog server : as_value.cpp as_value.h testsuite/actionscript.all: Function.as Log message: * server/as_value.{cpp,h}: to_primitive() made private, and had calling any user-defined valueOf for objects; (equals): only return false when to_primitive() returns the same type we were already. * testsuite/actionscript.all/Function.as: two more successes. CVSWeb URLs: http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.2999&r2=1.3000 http://cvs.savannah.gnu.org/viewcvs/gnash/server/as_value.cpp?cvsroot=gnash&r1=1.45&r2=1.46 http://cvs.savannah.gnu.org/viewcvs/gnash/server/as_value.h?cvsroot=gnash&r1=1.49&r2=1.50 http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/actionscript.all/Function.as?cvsroot=gnash&r1=1.41&r2=1.42 Patches: Index: ChangeLog =================================================================== RCS file: /sources/gnash/gnash/ChangeLog,v retrieving revision 1.2999 retrieving revision 1.3000 diff -u -b -r1.2999 -r1.3000 --- ChangeLog 26 Apr 2007 09:53:00 -0000 1.2999 +++ ChangeLog 26 Apr 2007 10:17:56 -0000 1.3000 @@ -1,5 +1,13 @@ 2007-04-26 Sandro Santilli <[EMAIL PROTECTED]> + * server/as_value.{cpp,h}: to_primitive() made private, and had + calling any user-defined valueOf for objects; (equals): only + return false when to_primitive() returns the same type we were + already. + * testsuite/actionscript.all/Function.as: two more successes. + +2007-04-26 Sandro Santilli <[EMAIL PROTECTED]> + * server/as_value.cpp (equals): don't abort on object==movieclip ! * testsuite/actionscript.all/Function.as: add more tests 'this' reference in 'with' and 'function' scope (see bug #19704). Index: server/as_value.cpp =================================================================== RCS file: /sources/gnash/gnash/server/as_value.cpp,v retrieving revision 1.45 retrieving revision 1.46 diff -u -b -r1.45 -r1.46 --- server/as_value.cpp 26 Apr 2007 09:53:01 -0000 1.45 +++ server/as_value.cpp 26 Apr 2007 10:17:56 -0000 1.46 @@ -228,19 +228,25 @@ // Conversion to primitive value. as_value -as_value::to_primitive() const +as_value::to_primitive(as_environment& env) const { - switch (m_type) + if ( m_type == OBJECT || m_type == AS_FUNCTION ) + { + as_object* obj = m_object_value; + std::string methodname = "valueOf"; + lowercase_if_needed(methodname); + as_value method; + if ( obj->get_member(methodname, &method) ) + { + return call_method0(method, &env, obj); + } + else + { + log_msg(_("get_member(%s) returned false"), methodname.c_str()); + } + } + else { - case OBJECT: - case AS_FUNCTION: - return m_object_value->get_primitive_value(); - case UNDEFINED: - case NULLTYPE: - case BOOLEAN: - case STRING: - case NUMBER: - default: return *this; } @@ -659,38 +665,27 @@ return m_boolean_value == v.to_bool(); } - else if (m_type == MOVIECLIP || v.m_type == MOVIECLIP) - { - // if both are movieclips they should be compared by same value - // (see top of this function). - // In any other case we always return false. - // TODO: check if it's allowed that the primitive value - // of an object is a movieclip (maybe with an ActionScript hack...) - return false; - } - - else if (is_object()) + else if (m_type == OBJECT || m_type == AS_FUNCTION) { - assert ( ! v.is_object() ); + assert ( ! (v.m_type == OBJECT || v.m_type == AS_FUNCTION) ); // convert this value to a primitive and recurse - as_value v2 = to_primitive(); // TODO: should forward environment ? - if ( v2.is_object() ) return false; + if ( ! env ) return false; + as_value v2 = to_primitive(*env); // TODO: should forward environment ? + if ( v2.m_type == m_type ) return false; // no conversion else return v2.equals(v, env); } - else if (v.is_object()) + else if (v.m_type == OBJECT || v.m_type == AS_FUNCTION) { - assert ( ! is_object() ); + assert ( ! (m_type == OBJECT || m_type == AS_FUNCTION) ); // convert this value to a primitive and recurse - as_value v2 = v.to_primitive(); // TODO: should forward environment ? - if ( v2.is_object() ) return false; + if ( ! env ) return false; + as_value v2 = v.to_primitive(*env); // TODO: should forward environment ? + if ( v2.m_type == v.m_type ) return false; // no conversion else return equals(v2, env); } - else - { - assert(0); - } + return false; } // Sets *this to this string plus the given string. Index: server/as_value.h =================================================================== RCS file: /sources/gnash/gnash/server/as_value.h,v retrieving revision 1.49 retrieving revision 1.50 diff -u -b -r1.49 -r1.50 --- server/as_value.h 19 Apr 2007 14:25:40 -0000 1.49 +++ server/as_value.h 26 Apr 2007 10:17:56 -0000 1.50 @@ -14,7 +14,7 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -/* $Id: as_value.h,v 1.49 2007/04/19 14:25:40 martinwguy Exp $ */ +/* $Id: as_value.h,v 1.50 2007/04/26 10:17:56 strk Exp $ */ #ifndef GNASH_AS_VALUE_H #define GNASH_AS_VALUE_H @@ -358,12 +358,6 @@ /// bool to_bool_v5() const; - /// Return value as a primitive type - // - /// Primitive types are: undefined, null, boolean, string, number. - /// See ECMA-2.6.2 (section 4.3.2). - as_value to_primitive() const; - /// Return value as an object, converting primitive values as needed. // /// Make sure you don't break the intrusive_ptr chain @@ -529,6 +523,16 @@ private: + /// Return value as a primitive type + // + /// Primitive types are: undefined, null, boolean, string, number. + /// See ECMA-2.6.2 (section 4.3.2). + /// + /// @param env + /// The environment to use for calling the valueOf method. + /// + as_value to_primitive(as_environment& env) const; + /// Compare values of the same type // /// NOTE: will abort if values are not of the same type! Index: testsuite/actionscript.all/Function.as =================================================================== RCS file: /sources/gnash/gnash/testsuite/actionscript.all/Function.as,v retrieving revision 1.41 retrieving revision 1.42 diff -u -b -r1.41 -r1.42 --- testsuite/actionscript.all/Function.as 26 Apr 2007 09:55:56 -0000 1.41 +++ testsuite/actionscript.all/Function.as 26 Apr 2007 10:17:56 -0000 1.42 @@ -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: Function.as,v 1.41 2007/04/26 09:55:56 strk Exp $"; +rcsid="$Id: Function.as,v 1.42 2007/04/26 10:17:56 strk Exp $"; #include "check.as" @@ -642,4 +642,5 @@ // Quick test to verify that a movieclip is never equal to an object, despite it's primitive value o = new Object(); o.valueOf = function() { return _root; }; -xcheck_equals(_root, o); +check_equals(_root, o); +check_equals(o, _root); _______________________________________________ Gnash-commit mailing list Gnash-commit@gnu.org http://lists.gnu.org/mailman/listinfo/gnash-commit