gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash ChangeLog server/edit_text_character.cpp ...


From: Sandro Santilli
Subject: [Gnash-commit] gnash ChangeLog server/edit_text_character.cpp ...
Date: Tue, 15 Jan 2008 14:17:44 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  08/01/15 14:17:44

Modified files:
        .              : ChangeLog 
        server         : edit_text_character.cpp 
        testsuite/actionscript.all: TextField.as 

Log message:
        initialize TextField as an AsBroadcaster, broadcast onChanged events
        (it seems onKillFocus and onSetFocus should not... no idea why).

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.5402&r2=1.5403
http://cvs.savannah.gnu.org/viewcvs/gnash/server/edit_text_character.cpp?cvsroot=gnash&r1=1.140&r2=1.141
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/actionscript.all/TextField.as?cvsroot=gnash&r1=1.40&r2=1.41

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.5402
retrieving revision 1.5403
diff -u -b -r1.5402 -r1.5403
--- ChangeLog   15 Jan 2008 11:48:17 -0000      1.5402
+++ ChangeLog   15 Jan 2008 14:17:43 -0000      1.5403
@@ -1,5 +1,14 @@
 2008-01-15 Sandro Santilli <address@hidden>
 
+       * server/edit_text_character.cpp: initialize TextField as an
+         AsBroadcaster, broadcast onChanged events (it seems onKillFocus
+         and onSetFocus should not... no idea why).
+       * testsuite/actionscript.all/TextField.as: test existance of
+         AsBroadcaster interface in TextField instance, updated expected
+         results.
+
+2008-01-15 Sandro Santilli <address@hidden>
+
        * server/as_object.cpp (tostring_method): don't check size of string
          returned by get_string_value, just return it as is.
          Fixes bug #22024.

Index: server/edit_text_character.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/edit_text_character.cpp,v
retrieving revision 1.140
retrieving revision 1.141
diff -u -b -r1.140 -r1.141
--- server/edit_text_character.cpp      26 Dec 2007 15:52:34 -0000      1.140
+++ server/edit_text_character.cpp      15 Jan 2008 14:17:43 -0000      1.141
@@ -17,7 +17,7 @@
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 //
 
-/* $Id: edit_text_character.cpp,v 1.140 2007/12/26 15:52:34 strk Exp $ */
+/* $Id: edit_text_character.cpp,v 1.141 2008/01/15 14:17:43 strk Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -38,6 +38,8 @@
 #include "font.h" // for using the _font member
 #include "Object.h" // for getObjectInterface
 #include "namedStrings.h"
+#include "array.h" // for _listeners construction
+#include "AsBroadcaster.h" // for initializing self as a broadcaster
 
 #include <algorithm>
 #include <string>
@@ -67,8 +69,6 @@
 static as_value textfield_getTextFormat(const fn_call& fn);
 static as_value textfield_setNewTextFormat(const fn_call& fn);
 static as_value textfield_getNewTextFormat(const fn_call& fn);
-static as_value textfield_addListener(const fn_call& fn);
-static as_value textfield_removeListener(const fn_call& fn);
 
 static as_value textfield_getDepth(const fn_call& fn);
 static as_value textfield_getFontList(const fn_call& fn);
@@ -132,36 +132,6 @@
 }
 
 static as_value
-textfield_addListener(const fn_call& fn)
-{
-       boost::intrusive_ptr<edit_text_character> text = 
ensureType<edit_text_character>(fn.this_ptr);
-       UNUSED(text);
-
-       static bool warned = false;
-       if ( ! warned ) {
-               log_unimpl("TextField.addListener()");
-               warned = true;
-       }
-
-       return as_value();
-}
-
-static as_value
-textfield_removeListener(const fn_call& fn)
-{
-       boost::intrusive_ptr<edit_text_character> text = 
ensureType<edit_text_character>(fn.this_ptr);
-       UNUSED(text);
-
-       static bool warned = false;
-       if ( ! warned ) {
-               log_unimpl("TextField.removeListener()");
-               warned = true;
-       }
-
-       return as_value();
-}
-
-static as_value
 textfield_setNewTextFormat(const fn_call& fn)
 {
        boost::intrusive_ptr<edit_text_character> text = 
ensureType<edit_text_character>(fn.this_ptr);
@@ -297,6 +267,9 @@
 {
        int target_version = o.getVM().getSWFVersion();
 
+       // TextField is an AsBroadcaster
+        AsBroadcaster::initialize(o);
+
        // SWF5 or higher
        if ( target_version  < 6 ) return;
 
@@ -308,10 +281,6 @@
        o.init_member("setTextFormat", new 
builtin_function(textfield_setTextFormat));
        o.init_member("getTextFormat", new 
builtin_function(textfield_getTextFormat));
 
-       // TODO: make a normal AsBroadcaster ?
-       o.init_member("addListener", new 
builtin_function(textfield_addListener));
-       o.init_member("removeListener", new 
builtin_function(textfield_removeListener));
-
        o.init_member("setNewTextFormat", new 
builtin_function(textfield_setNewTextFormat));
        o.init_member("getNewTextFormat", new 
builtin_function(textfield_getNewTextFormat));
        o.init_member("getNewTextFormat", new 
builtin_function(textfield_getNewTextFormat));
@@ -429,6 +398,10 @@
 
        set_prototype(getTextFieldInterface());
 
+       as_array_object* ar = new as_array_object();
+       ar->push(this);
+       set_member(NSV::PROP_uLISTENERS, ar);
+
        // WARNING! remember to set the font *before* setting text value!
        set_font( m_def->get_font() );
 
@@ -2087,9 +2060,9 @@
 void
 edit_text_character::onChanged()
 {
-       string_table& st = _vm.getStringTable();
-       string_table::key key = st.find(PROPNAME("onChanged"));
-       callMethod(key);
+       as_value met(PROPNAME("onChanged"));
+       as_value targetVal(this);
+       callMethod(NSV::PROP_BROADCAST_MESSAGE, met, targetVal);
 }
 
 void

Index: testsuite/actionscript.all/TextField.as
===================================================================
RCS file: /sources/gnash/gnash/testsuite/actionscript.all/TextField.as,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -b -r1.40 -r1.41
--- testsuite/actionscript.all/TextField.as     5 Jan 2008 15:40:14 -0000       
1.40
+++ testsuite/actionscript.all/TextField.as     15 Jan 2008 14:17:43 -0000      
1.41
@@ -19,7 +19,7 @@
 // compile this test case with Ming makeswf, and then
 // execute it like this gnash -1 -r 0 -v out.swf
 
-rcsid="$Id: TextField.as,v 1.40 2008/01/05 15:40:14 strk Exp $";
+rcsid="$Id: TextField.as,v 1.41 2008/01/15 14:17:43 strk Exp $";
 
 #include "check.as"
 
@@ -41,11 +41,11 @@
  // See http://www.senocular.com/flash/tutorials/listenersasbroadcaster/?page=2
  check_equals(typeof(TextField.prototype.addListener), 'function');
  check_equals(typeof(TextField.prototype.removeListener), 'function');
- xcheck_equals(typeof(TextField.prototype.broadcastMessage), 'function');
- xcheck(TextField.prototype.hasOwnProperty("_listeners"));
- xcheck_equals(typeof(TextField.prototype._listeners), 'object');
- xcheck(TextField.prototype._listeners instanceof Array);
- xcheck_equals(TextField.prototype._listeners.length, 0);
+ check_equals(typeof(TextField.prototype.broadcastMessage), 'function');
+ check(TextField.prototype.hasOwnProperty("_listeners"));
+ check_equals(typeof(TextField.prototype._listeners), 'object');
+ check(TextField.prototype._listeners instanceof Array);
+ check_equals(TextField.prototype._listeners.length, 0);
 
 // NOTE: the following will be true after a call to createTextField ! Seek 
forward to see..
 xcheck( !TextField.prototype.hasOwnProperty('background'));
@@ -115,9 +115,12 @@
 #endif
 
 check_equals(typeof(tf), 'object');
-xcheck(tf.hasOwnProperty('_listeners'));
-xcheck_equals(tf._listeners.length, 1); // adds self to the listeners
-xcheck_equals(tf._listeners[0], tf); // adds self to the listeners set
+check(tf.hasOwnProperty('_listeners'));
+check_equals(tf._listeners.length, 1); // adds self to the listeners
+check_equals(tf._listeners[0], tf); // adds self to the listeners set
+check(!tf.hasOwnProperty('broadcastMessage'));
+check(!tf.hasOwnProperty('addListener'));
+check(!tf.hasOwnProperty('removeListener'));
 
 // NOTE: the following were false before the call to createTextField ! Seek 
backward to see..
 check( TextField.prototype.hasOwnProperty('background'));
@@ -812,9 +815,9 @@
 
 
 #if OUTPUT_VERSION < 8
- check_totals(387);
+ check_totals(390);
 #else
- check_totals(388);
+ check_totals(391);
 #endif
 
 #else // OUTPUT_VERSION <= 5




reply via email to

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