[Top][All Lists]
[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: |
Sat, 25 Nov 2006 11:06:58 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Sandro Santilli <strk> 06/11/25 11:06:58
Modified files:
. : ChangeLog
server/asobj : string.cpp
testsuite/actionscript.all: String.as
Log message:
Patch by Michael Meier <address@hidden>:
* testsuite/actionscript.all/String.as: fixed to match
expected behaviour.
* server/asobj/string.cpp: implement 'length' with the
add_property() interface.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.1755&r2=1.1756
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/string.cpp?cvsroot=gnash&r1=1.7&r2=1.8
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/actionscript.all/String.as?cvsroot=gnash&r1=1.5&r2=1.6
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.1755
retrieving revision 1.1756
diff -u -b -r1.1755 -r1.1756
--- ChangeLog 25 Nov 2006 11:04:47 -0000 1.1755
+++ ChangeLog 25 Nov 2006 11:06:58 -0000 1.1756
@@ -1,3 +1,10 @@
+2006-11-25 Michael Meier <address@hidden>
+
+ * testsuite/actionscript.all/String.as: fixed to match
+ expected behaviour.
+ * server/asobj/string.cpp: implement 'length' with the
+ add_property() interface.
+
2006-11-25 Markus Gothe <address@hidden>
* backend/render_handler_ogl.cpp: #ifdef'd VITALY to get OGL working.
Index: server/asobj/string.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/string.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- server/asobj/string.cpp 22 Nov 2006 09:28:37 -0000 1.7
+++ server/asobj/string.cpp 25 Nov 2006 11:06:58 -0000 1.8
@@ -18,7 +18,7 @@
//
//
-/* $Id: string.cpp,v 1.7 2006/11/22 09:28:37 strk Exp $ */
+/* $Id: string.cpp,v 1.8 2006/11/25 11:06:58 strk Exp $ */
// Implementation of ActionScript String class.
@@ -34,6 +34,8 @@
namespace gnash {
// Forward declarations
+static void string_get_length(const fn_call& fn);
+static void string_set_length(const fn_call& fn);
static void string_concat(const fn_call& fn);
static void string_slice(const fn_call& fn);
static void string_split(const fn_call& fn);
@@ -66,6 +68,11 @@
o.set_member("charCodeAt", &string_char_code_at);
o.set_member("toUpperCase", &string_to_upper_case);
o.set_member("toLowerCase", &string_to_lower_case);
+
+ boost::intrusive_ptr<builtin_function> length_getter(new
builtin_function(&string_get_length,NULL));
+ boost::intrusive_ptr<builtin_function> length_setter(new
builtin_function(&string_set_length,NULL));
+ o.add_property(std::string("length"),*length_getter,*length_setter);
+
}
static as_object*
@@ -91,18 +98,23 @@
{
}
- virtual bool get_member(const tu_stringi& name, as_value* val) {
+};
- if (name == "length")
- {
- val->set_int(m_string.utf8_length());
- return true;
- }
- return get_member_default(name,val);
- }
+static void
+string_get_length(const fn_call& fn)
+{
+ fn.result->set_int(((tu_string_as_object*)
fn.this_ptr)->m_string.utf8_length());
+ return;
-};
+}
+
+static void
+string_set_length(const fn_call& /*fn*/)
+{
+ IF_VERBOSE_ASCODING_ERRORS(log_msg("String: length property is
read-only"));
+ return;
+}
// all the arguments will be converted to string and concatenated
static void
@@ -110,11 +122,12 @@
{
tu_string this_string = ((tu_string_as_object*) fn.this_ptr)->m_string;
- int len = 0;
+ int len = strlen(this_string.c_str());
+ int pos = len;
for (int i = 0; i < fn.nargs; i++) len += strlen(fn.arg(i).to_string());
char *newstr = new char[len + 1];
- int pos = 0;
+ memcpy(newstr, this_string.c_str(),pos); // because pos at the moments
holds the strlen of this_string!
for (int i = 0; i < fn.nargs; i++)
{
int len = strlen(fn.arg(i).to_string());
Index: testsuite/actionscript.all/String.as
===================================================================
RCS file: /sources/gnash/gnash/testsuite/actionscript.all/String.as,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- testsuite/actionscript.all/String.as 22 Nov 2006 09:28:37 -0000
1.5
+++ testsuite/actionscript.all/String.as 25 Nov 2006 11:06:58 -0000
1.6
@@ -1,7 +1,7 @@
// Mike Carlson's test program for actionscript strings
// June 19th, 2006
-rcsid="$Id: String.as,v 1.5 2006/11/22 09:28:37 strk Exp $";
+rcsid="$Id: String.as,v 1.6 2006/11/25 11:06:58 strk Exp $";
#include "check.as"
@@ -50,7 +50,8 @@
check_equals ( a.substring(5,2), "cde" );
check_equals ( a.substring(5,7), "fg" );
check_equals ( a.length, 26 );
-check_equals ( a.concat("sir ","william",15), "sir william15");
+check_equals ( a.concat("sir ","william",15), "abcdefghijklmnopqrstuvwxyzsir
william15");
+
// Test inheritance with built-in functions
var stringInstance = new String();