gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash ChangeLog server/asobj/string.cpp testsui...


From: Sandro Santilli
Subject: [Gnash-commit] gnash ChangeLog server/asobj/string.cpp testsui...
Date: Sun, 30 Mar 2008 17:09:33 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  08/03/30 17:09:32

Modified files:
        .              : ChangeLog 
        server/asobj   : string.cpp 
        testsuite/actionscript.all: String.as 
        testsuite/swfdec: PASSING 

Log message:
        'length' is an instance, not class, member, and it can be overridden.
        string-properties-5.swf from swfdec still fails, 6,7,8 succeed.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.6093&r2=1.6094
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/string.cpp?cvsroot=gnash&r1=1.64&r2=1.65
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/actionscript.all/String.as?cvsroot=gnash&r1=1.50&r2=1.51
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/swfdec/PASSING?cvsroot=gnash&r1=1.111&r2=1.112

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.6093
retrieving revision 1.6094
diff -u -b -r1.6093 -r1.6094
--- ChangeLog   30 Mar 2008 15:41:12 -0000      1.6093
+++ ChangeLog   30 Mar 2008 17:09:31 -0000      1.6094
@@ -1,5 +1,13 @@
 2008-03-30 Sandro Santilli <address@hidden>
 
+       * server/asobj/string.cpp: 'length' is an instance, not class, member,
+         and it can be overridden.
+       * testsuite/actionscript.all/String.as: test 'length' member of string
+         instances.
+       * testsuite/swfdec/PASSING: string-properties-{6,7,8}.swf pass
+
+2008-03-30 Sandro Santilli <address@hidden>
+
        * server/asobj/Global.cpp: error to aserror, provide a null
          _global.o (don't ask me why, but that's expected...)
        * testsuite/swfdec/PASSING: global-variable-properties succeeds.

Index: server/asobj/string.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/string.cpp,v
retrieving revision 1.64
retrieving revision 1.65
diff -u -b -r1.64 -r1.65
--- server/asobj/string.cpp     28 Mar 2008 16:23:08 -0000      1.64
+++ server/asobj/string.cpp     30 Mar 2008 17:09:32 -0000      1.65
@@ -56,7 +56,6 @@
 
 // Forward declarations
 
-static as_value string_get_length(const fn_call& fn);
 static as_value string_concat(const fn_call& fn);
 static as_value string_slice(const fn_call& fn);
 static as_value string_split(const fn_call& fn);
@@ -132,10 +131,6 @@
        // ASnative(251, 13) - [String.prototype] substr
        vm.registerNative(string_sub_str, 251, 13);
        o.init_member("substr", vm.getNative(251, 13));
-
-       // This isn't advertised as native, so might be a proper property ?
-       o.init_readonly_property("length", string_get_length);
-
 }
 
 static as_object*
@@ -158,10 +153,15 @@
 {
 
 public:
-    string_as_object()
+    string_as_object(const std::string& s)
             :
-            as_object(getStringInterface())
-    {}
+            as_object(getStringInterface()),
+            _string(s)
+    {
+       std::wstring wstr = utf8::decodeCanonicalString(_string, 
_vm.getSWFVersion());
+       init_member(NSV::PROP_LENGTH, wstr.size(), 
as_prop_flags::dontDelete|as_prop_flags::dontEnum); // can override though
+    }
+
 
     bool useCustomToString() const { return false; }
 
@@ -176,8 +176,7 @@
         return as_value(_string);
     }
 
-    std::string& str()
-
+    const std::string& str()
     {
         return _string;
     }
@@ -186,18 +185,6 @@
     std::string _string;
 };
 
-static as_value
-string_get_length(const fn_call& fn)
-{
-    boost::intrusive_ptr<string_as_object> obj = 
ensureType<string_as_object>(fn.this_ptr);
-
-    int version = VM::get().getSWFVersion();
-
-    std::wstring wstr = utf8::decodeCanonicalString(obj->str(), version);
-
-    return as_value(wstr.size());
-}
-
 // all the arguments will be converted to string and concatenated
 static as_value
 string_concat(const fn_call& fn)
@@ -234,7 +221,7 @@
 {
     boost::intrusive_ptr<string_as_object> obj = 
ensureType<string_as_object>(fn.this_ptr);
 
-    int version = VM::get().getSWFVersion();
+    int version = obj->getVM().getSWFVersion();
 
     // Make a copy.
     std::wstring wstr = utf8::decodeCanonicalString(obj->str(), version);
@@ -269,16 +256,15 @@
     boost::intrusive_ptr<string_as_object> obj =
         ensureType<string_as_object>(fn.this_ptr);
 
-    int version = VM::get().getSWFVersion();
+    VM& vm = obj->getVM(); 
+    int SWFVersion = vm.getSWFVersion();
 
-    std::wstring wstr = utf8::decodeCanonicalString(obj->str(), version);
+    std::wstring wstr = utf8::decodeCanonicalString(obj->str(), SWFVersion);
 
     as_value val;
 
     boost::intrusive_ptr<as_array_object> array(new as_array_object());
 
-    int SWFVersion = VM::get().getSWFVersion();
-
     if (fn.nargs == 0)
     {
         val.set_std_string(obj->str());
@@ -287,7 +273,7 @@
         return as_value(array.get());
     }
 
-    const std::wstring& delim = 
utf8::decodeCanonicalString(fn.arg(0).to_string(), version);
+    const std::wstring& delim = 
utf8::decodeCanonicalString(fn.arg(0).to_string(), SWFVersion);
 
     // SWF5 didn't support multichar or empty delimiter
     if ( SWFVersion < 6 )
@@ -322,7 +308,7 @@
 
     if ( delim.empty() ) {
         for (unsigned i=0; i <max; i++) {
-            val.set_std_string(utf8::encodeCanonicalString(wstr.substr(i, 1), 
version));
+            val.set_std_string(utf8::encodeCanonicalString(wstr.substr(i, 1), 
SWFVersion));
             array->push(val);
         }
 
@@ -338,7 +324,7 @@
         if (pos != std::wstring::npos) {
             val.set_std_string(utf8::encodeCanonicalString(
                        wstr.substr(prevpos, pos - prevpos),
-                       version));
+                       SWFVersion));
             array->push(val);
             num++;
             prevpos = pos + delim.size();
@@ -346,7 +332,7 @@
         } else {
             val.set_std_string(utf8::encodeCanonicalString(
                        wstr.substr(prevpos),
-                       version));
+                       SWFVersion));
             array->push(val);
             break;
         }
@@ -395,7 +381,7 @@
 {
     boost::intrusive_ptr<string_as_object> obj = 
ensureType<string_as_object>(fn.this_ptr);
 
-    int version = VM::get().getSWFVersion();
+    int version = obj->getVM().getSWFVersion();
 
     std::wstring wstr = utf8::decodeCanonicalString(obj->str(), version);
 
@@ -432,7 +418,7 @@
 {
     boost::intrusive_ptr<string_as_object> obj = 
ensureType<string_as_object>(fn.this_ptr);
 
-    int version = VM::get().getSWFVersion();
+    int version = obj->getVM().getSWFVersion();
 
     const std::wstring& wstr = utf8::decodeCanonicalString(obj->str(), 
version);
 
@@ -481,7 +467,7 @@
 {
     boost::intrusive_ptr<string_as_object> obj = 
ensureType<string_as_object>(fn.this_ptr);
 
-    int version = VM::get().getSWFVersion();
+    int version = obj->getVM().getSWFVersion();
 
     const std::wstring& wstr = utf8::decodeCanonicalString(obj->str(), 
version);
 
@@ -673,9 +659,7 @@
                return as_value(str);
        }
        
-       boost::intrusive_ptr<string_as_object> obj = new string_as_object;
-
-       obj->str() = str;
+       boost::intrusive_ptr<string_as_object> obj = new string_as_object(str);
 
        return as_value(obj.get());
 }

Index: testsuite/actionscript.all/String.as
===================================================================
RCS file: /sources/gnash/gnash/testsuite/actionscript.all/String.as,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -b -r1.50 -r1.51
--- testsuite/actionscript.all/String.as        30 Mar 2008 12:55:48 -0000      
1.50
+++ testsuite/actionscript.all/String.as        30 Mar 2008 17:09:32 -0000      
1.51
@@ -17,7 +17,7 @@
 // Original author: Mike Carlson - June 19th, 2006
 
 
-rcsid="$Id: String.as,v 1.50 2008/03/30 12:55:48 strk Exp $";
+rcsid="$Id: String.as,v 1.51 2008/03/30 17:09:32 strk Exp $";
 #include "check.as"
 
 check_equals(typeof(String), 'function');
@@ -36,6 +36,7 @@
 check_equals(typeof(String.prototype.substring), 'function');
 check_equals(typeof(String.prototype.split), 'function');
 check_equals(typeof(String.prototype.substr), 'function');
+check_equals(typeof(String.prototype.length), 'undefined');
 check_equals(typeof(String.prototype.fromCharCode), 'undefined');
 #if OUTPUT_VERSION > 5
  check_equals(typeof(String.valueOf), 'function');
@@ -75,6 +76,7 @@
 check(String.prototype.hasOwnProperty('substring'));
 check(String.prototype.hasOwnProperty('split'));
 check(String.prototype.hasOwnProperty('substr'));
+check(!String.prototype.hasOwnProperty('length'));
 #endif
 
 
@@ -82,6 +84,10 @@
 
 var a;
 a = new String("wallawallawashinGTON");
+check_equals(a.length, 20);
+#if OUTPUT_VERSION > 5
+check(a.hasOwnProperty('length'));
+#endif
 check_equals(typeof(a), 'object');
 check(a instanceof String);
 check(a instanceof Object);
@@ -756,8 +762,29 @@
 r = "s:"+s;
 check_equals(r, "s:");
 
+//----------------------------------------------------------------------
+// Test the 'length' property
+//----------------------------------------------------------------------
+
+a = "123";
+check_equals(a.length, 3);
+a.length = 2;
+check_equals(a.length, 3); // well, it's a string after all, not an object
+a = new String("123");
+check_equals(a.length, 3);
+a.length = 2;
+check_equals(a.length, 2); // can override
+check_equals(a, "123"); // not changing the actual string
+a.length = "another string";
+check_equals(a.length, "another string"); // can also be of a different type
+delete a.length;
+check_equals(a.length, "another string"); // can't be deleted
+#if OUTPUT_VERSION > 5
+ check(a.hasOwnProperty('length'));
+#endif
+
 #if OUTPUT_VERSION < 6
- check_totals(204);
+ check_totals(213);
 #else
- check_totals(235);
+ check_totals(247);
 #endif

Index: testsuite/swfdec/PASSING
===================================================================
RCS file: /sources/gnash/gnash/testsuite/swfdec/PASSING,v
retrieving revision 1.111
retrieving revision 1.112
diff -u -b -r1.111 -r1.112
--- testsuite/swfdec/PASSING    30 Mar 2008 15:41:13 -0000      1.111
+++ testsuite/swfdec/PASSING    30 Mar 2008 17:09:32 -0000      1.112
@@ -704,6 +704,9 @@
 stringlength-5.swf:bf014dcc64776fb859ff878286f56b16
 stringlength-6.swf:94b4de2a590c915696b4a783338a1f05
 stringlength-7.swf:140952977abb85b966f1e5c4447854ce
+string-properties-6.swf:6e04c332f503311867082ab55f22b16b
+string-properties-7.swf:bf61a4b0a4cc67c8df63203407ac243c
+string-properties-8.swf:b5d56ec26bad2fa2c7833f44e5148fd8
 string-slice-5.swf:a98bdbd8ce5ff3cfd5406d3a9d04de33
 string-slice-6.swf:cfe7fde1085617b6673fda9895162e32
 string-slice-7.swf:eaed0b05db4e5a01579a94f283f8a068




reply via email to

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