gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash ChangeLog server/gnash.h server/asobj/Glo...


From: Sandro Santilli
Subject: [Gnash-commit] gnash ChangeLog server/gnash.h server/asobj/Glo...
Date: Tue, 24 Jul 2007 14:19:32 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  07/07/24 14:19:32

Modified files:
        .              : ChangeLog 
        server         : gnash.h 
        server/asobj   : Global.cpp Key.cpp Key.h 
        testsuite/actionscript.all: Makefile.am 
Added files:
        testsuite/actionscript.all: Key.as 

Log message:
                * server/gnash.h: fix PGDN and PGUP key constants
                * server/asobj/Global.cpp: initialize the "Key" class
                  even in SWF5.
                * server/asobj/Key.cpp: use init_member rather then set_member
                  when initializing constants, reduce complexity of compile-time
                  switches for NEW_KEY_LISTENER_LIST_DESIGN, general cleanups.
                * testsuite/actionscript.all/: Makefile.am, Key.as: new testcase
                  for Key object

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.3805&r2=1.3806
http://cvs.savannah.gnu.org/viewcvs/gnash/server/gnash.h?cvsroot=gnash&r1=1.100&r2=1.101
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/Global.cpp?cvsroot=gnash&r1=1.65&r2=1.66
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/Key.cpp?cvsroot=gnash&r1=1.29&r2=1.30
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/Key.h?cvsroot=gnash&r1=1.23&r2=1.24
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/actionscript.all/Makefile.am?cvsroot=gnash&r1=1.74&r2=1.75
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/actionscript.all/Key.as?cvsroot=gnash&rev=1.1

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.3805
retrieving revision 1.3806
diff -u -b -r1.3805 -r1.3806
--- ChangeLog   24 Jul 2007 13:25:09 -0000      1.3805
+++ ChangeLog   24 Jul 2007 14:19:31 -0000      1.3806
@@ -1,3 +1,14 @@
+2007-07-24 Sandro Santilli <address@hidden>
+
+       * server/gnash.h: fix PGDN and PGUP key constants
+       * server/asobj/Global.cpp: initialize the "Key" class
+         even in SWF5.
+       * server/asobj/Key.cpp: use init_member rather then set_member
+         when initializing constants, reduce complexity of compile-time
+         switches for NEW_KEY_LISTENER_LIST_DESIGN, general cleanups.
+       * testsuite/actionscript.all/: Makefile.am, Key.as: new testcase
+         for Key object
+
 2007-07-24 Udo Giacomozzi <address@hidden>
 
        * server/dlist.cpp: handle masks of certain malformed(?) movies 
correctly

Index: server/gnash.h
===================================================================
RCS file: /sources/gnash/gnash/server/gnash.h,v
retrieving revision 1.100
retrieving revision 1.101
diff -u -b -r1.100 -r1.101
--- server/gnash.h      11 Jul 2007 02:58:00 -0000      1.100
+++ server/gnash.h      24 Jul 2007 14:19:31 -0000      1.101
@@ -465,8 +465,8 @@
        CAPSLOCK = 20,
        ESCAPE = 27,
        SPACE = 32,
-       PGDN,
-       PGUP,
+       PGUP = 33,
+       PGDN = 34,
        END = 35,
        HOME,
        LEFT,

Index: server/asobj/Global.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/Global.cpp,v
retrieving revision 1.65
retrieving revision 1.66
diff -u -b -r1.65 -r1.66
--- server/asobj/Global.cpp     3 Jul 2007 16:56:19 -0000       1.65
+++ server/asobj/Global.cpp     24 Jul 2007 14:19:31 -0000      1.66
@@ -17,7 +17,7 @@
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 //
 
-/* $Id: Global.cpp,v 1.65 2007/07/03 16:56:19 strk Exp $ */
+/* $Id: Global.cpp,v 1.66 2007/07/24 14:19:31 strk Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -424,6 +424,7 @@
        number_class_init(*this); 
        string_class_init(*this); 
        array_class_init(*this);
+       key_class_init(*this); // Key
        init_member("escape", new builtin_function(as_global_escape));
        init_member("unescape", new builtin_function(as_global_unescape));
        init_member("parseFloat", new builtin_function(as_global_parsefloat));
@@ -446,7 +447,6 @@
        textsnapshot_class_init(*this);
        init_member("LocalConnection", new 
builtin_function(localconnection_new));
        init_member("TextFormat", new builtin_function(textformat_new));
-       key_class_init(*this); // Key
        video_class_init(*this); // Video
        camera_class_init(*this); // Camera
        microphone_class_init(*this); // Microphone

Index: server/asobj/Key.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/Key.cpp,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -b -r1.29 -r1.30
--- server/asobj/Key.cpp        17 Jul 2007 06:04:22 -0000      1.29
+++ server/asobj/Key.cpp        24 Jul 2007 14:19:31 -0000      1.30
@@ -34,55 +34,6 @@
 
 namespace gnash {
 
-Key::Key() {
-}
-
-Key::~Key() {
-}
-
-
-void
-Key::addListener()
-{
-    log_unimpl (__FUNCTION__);
-}
-
-void
-Key::getAscii()
-{
-    log_unimpl (__FUNCTION__);
-}
-
-void
-Key::getCode()
-{
-    log_unimpl (__FUNCTION__);
-}
-
-void
-Key::isDown()
-{
-    log_unimpl (__FUNCTION__);
-}
-
-void
-Key::isToggled()
-{
-    log_unimpl (__FUNCTION__);
-}
-
-void
-Key::removeListener()
-{
-    log_unimpl (__FUNCTION__);
-}
-as_value
-key_new(const fn_call& /* fn */)
-{
-    key_as_object *key_obj = new key_as_object;
-    return as_value(key_obj);
-}
-
 /************************************************************************
  *
  * This has been moved from action.cpp, when things are clean
@@ -203,7 +154,9 @@
         target->unregisterUserHandler();
     }
 }
-#else
+
+#else // ndef NEW_KEY_LISTENER_LIST_DESIGN
+
 void
 key_as_object::add_listener(boost::intrusive_ptr<as_object> listener)
 {
@@ -235,61 +188,56 @@
         iter++;
     }
 }
-#endif
+#endif // ndef NEW_KEY_LISTENER_LIST_DESIGN
+
 int
 key_as_object::get_last_key_pressed() const
 {
     return m_last_key_pressed;
 }
 
-#ifdef NEW_KEY_LISTENER_LIST_DESIGN
+
 as_value
 key_add_listener(const fn_call& fn)
 {
+
+    boost::intrusive_ptr<key_as_object> ko = 
ensureType<key_as_object>(fn.this_ptr);
+
     if (fn.nargs < 1)
     {
-        log_error(_("key_add_listener needs one argument (the listener 
object)"));
+        IF_VERBOSE_ASCODING_ERRORS(
+        log_aserror(_("Key.addListener needs one argument (the listener 
object)"));
+        );
         return as_value();
     }
 
     boost::intrusive_ptr<as_object> toadd = fn.arg(0).to_object();
     if (toadd == NULL)
     {
-        log_error(_("key_add_listener passed a NULL object; ignored"));
+        IF_VERBOSE_ASCODING_ERRORS(
+        log_aserror(_("Key.addListener passed a NULL object; ignored"));
+        );
         return as_value();
     }
 
-    boost::intrusive_ptr<key_as_object> ko = 
ensureType<key_as_object>(fn.this_ptr);
+#ifdef NEW_KEY_LISTENER_LIST_DESIGN
 
     ko->add_listener(KeyListener(toadd, KeyListener::USER_DEF));
-    return as_value();
-}
-#else
-as_value
-key_add_listener(const fn_call& fn)
-{
-    if (fn.nargs < 1)
-    {
-        log_error(_("key_add_listener needs one argument (the listener 
object)"));
-        return as_value();
-    }
 
-    boost::intrusive_ptr<as_object> listener = fn.arg(0).to_object();
-    if (listener == NULL)
-    {
-        log_error(_("key_add_listener passed a NULL object; ignored"));
-        return as_value();
-    }
+#else // ndef NEW_KEY_LISTENER_LIST_DESIGN
 
-    boost::intrusive_ptr<key_as_object> ko = 
ensureType<key_as_object>(fn.this_ptr);
+    ko->add_listener(toadd);
+
+#endif // ndef NEW_KEY_LISTENER_LIST_DESIGN
 
-    ko->add_listener(listener);
     return as_value();
 }
-#endif
-as_value    key_get_ascii(const fn_call& fn)
+
+
 // Return the ascii value of the last key pressed.
 /// FIXME: return the ascii number(not string) of the last pressed key!
+static as_value   
+key_get_ascii(const fn_call& fn)
 {
     boost::intrusive_ptr<key_as_object> ko = 
ensureType<key_as_object>(fn.this_ptr);
 
@@ -303,97 +251,93 @@
     buf[0] = (char) code;
     buf[1] = 0;
 
+    log_unimpl("Key.getAscii partially implemented");
+
     return as_value(buf);
 }
 
-as_value    key_get_code(const fn_call& fn)
 // Returns the keycode of the last key pressed.
+static as_value   
+key_get_code(const fn_call& fn)
 {
     boost::intrusive_ptr<key_as_object> ko = 
ensureType<key_as_object>(fn.this_ptr);
 
     return as_value(ko->get_last_key_pressed());
 }
 
-as_value    key_is_down(const fn_call& fn)
-// Return true if the specified (first arg keycode) key is pressed.
+/// Return true if the specified (first arg keycode) key is pressed.
+static as_value   
+key_is_down(const fn_call& fn)
 {
+    boost::intrusive_ptr<key_as_object> ko = 
ensureType<key_as_object>(fn.this_ptr);
+
     if (fn.nargs < 1)
     {
-        log_error(_("key_is_down needs one argument (the key code)"));
+        IF_VERBOSE_ASCODING_ERRORS(
+        log_aserror(_("Key.isDown needs one argument (the key code)"));
+        );
         return as_value();
     }
 
-    int code = (int) fn.arg(0).to_number();
-
-    boost::intrusive_ptr<key_as_object> ko = 
ensureType<key_as_object>(fn.this_ptr);
+    int code = fn.arg(0).to_number<int>();
 
     return as_value(ko->is_key_down(code));
 }
 
-as_value    key_is_toggled(const fn_call& /* fn */)
-// Given the keycode of NUM_LOCK or CAPSLOCK, returns true if
-// the associated state is on.
+/// \brief
+/// Given the keycode of NUM_LOCK or CAPSLOCK, returns true if
+/// the associated state is on.
+///
+static as_value   
+key_is_toggled(const fn_call& /* fn */)
 {
+    log_unimpl("Key.isToggled");
     // @@ TODO
     return as_value(false);
 }
-#ifdef NEW_KEY_LISTENER_LIST_DESIGN
-as_value    
+
+/// Remove a previously-added listener.
+static as_value    
 key_remove_listener(const fn_call& fn)
-// Remove a previously-added listener.
 {
+
     if (fn.nargs < 1)
     {
-        log_error(_("key_remove_listener needs one argument (the listener 
object)"));
+        IF_VERBOSE_ASCODING_ERRORS(
+        log_aserror(_("Key.removeListener needs one argument (the listener 
object)"));
+        );
         return as_value();
     }
 
     boost::intrusive_ptr<as_object> toremove = fn.arg(0).to_object();
     if (toremove == NULL)
     {
-        log_error(_("key_remove_listener passed a NULL object; ignored"));
+        IF_VERBOSE_ASCODING_ERRORS(
+        log_aserror(_("Key.removeListener passed a NULL object; ignored"));
+        );
         return as_value();
     }
 
     boost::intrusive_ptr<key_as_object> ko = 
ensureType<key_as_object>(fn.this_ptr); 
 
     ko->remove_listener(toremove);
-    return as_value();
-}
-#else
-as_value    key_remove_listener(const fn_call& fn)
-// Remove a previously-added listener.
-{
-    if (fn.nargs < 1)
-    {
-        log_error(_("key_remove_listener needs one argument (the listener 
object)"));
-        return as_value();
-    }
-
-    boost::intrusive_ptr<as_object> listener = fn.arg(0).to_object();
-    if (listener == NULL)
-    {
-        log_error(_("key_remove_listener passed a NULL object; ignored"));
-        return as_value();
-    }
-
-    boost::intrusive_ptr<key_as_object> ko = 
ensureType<key_as_object>(fn.this_ptr); 
 
-    ko->remove_listener(listener);
     return as_value();
 }
-#endif
+
 void key_class_init(as_object& global)
 {
 
 //  GNASH_REPORT_FUNCTION;
+//
+    int swfversion = VM::get().getSWFVersion();
 
     // Create built-in key object.
     // NOTE: _global.Key *is* an object, not a constructor
     as_object*  key_obj = new key_as_object;
 
     // constants
-#define KEY_CONST(k) key_obj->set_member(#k, key::k)
+#define KEY_CONST(k) key_obj->init_member(#k, key::k)
     KEY_CONST(BACKSPACE);
     KEY_CONST(CAPSLOCK);
     KEY_CONST(CONTROL);
@@ -414,13 +358,17 @@
     KEY_CONST(UP);
 
     // methods
-    key_obj->init_member("addListener", new 
builtin_function(key_add_listener));
     key_obj->init_member("getAscii", new builtin_function(key_get_ascii));
     key_obj->init_member("getCode", new builtin_function(key_get_code));
     key_obj->init_member("isDown", new builtin_function(key_is_down));
     key_obj->init_member("isToggled", new builtin_function(key_is_toggled));
-    key_obj->init_member("removeListener", new 
builtin_function(key_remove_listener));
 
+    // These are only for SWF6 and up
+    if ( swfversion > 5 )
+    {
+        key_obj->init_member("addListener", new 
builtin_function(key_add_listener));
+        key_obj->init_member("removeListener", new 
builtin_function(key_remove_listener));
+    }
 
     global.init_member("Key", key_obj);
 }

Index: server/asobj/Key.h
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/Key.h,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -b -r1.23 -r1.24
--- server/asobj/Key.h  17 Jul 2007 06:04:22 -0000      1.23
+++ server/asobj/Key.h  24 Jul 2007 14:19:32 -0000      1.24
@@ -16,7 +16,7 @@
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 // 
 
-/* $Id: Key.h,v 1.23 2007/07/17 06:04:22 zoulunkai Exp $ */
+/* $Id: Key.h,v 1.24 2007/07/24 14:19:32 strk Exp $ */
 
 #ifndef __KEY_H__
 #define __KEY_H__
@@ -43,53 +43,6 @@
 class KeyListener; //forward declaration
 #endif
 
-// TODO: drop this, probably unused
-class DSOEXPORT Key {
-public:
-    Key();
-    ~Key();
-   void addListener();
-   void getAscii();
-   void getCode();
-   void isDown();
-   void isToggled();
-   void removeListener();
-private:
-    bool _BACKSPACE;
-    bool _CAPSLOCK;
-    bool _CONTROL;
-    bool _DELETEKEY;
-    bool _DOWN;
-    bool _END;
-    bool _ENTER;
-    bool _ESCAPE;
-    bool _HOME;
-    bool _INSERT;
-    bool _LEFT;
-    bool _onKeyDown;
-    bool _onKeyUp;
-    bool _PGDN;
-    bool _PGUP;
-    bool _RIGHT;
-    bool _SHIFT;
-    bool _SPACE;
-    bool _TAB;
-    bool _UP;
-};
-
-//class key_as_object : public as_object
-//{
-//public:
-    //Key obj;
-//};
-
-as_value key_addlistener(const fn_call& fn);
-as_value key_getascii(const fn_call& fn);
-as_value key_getcode(const fn_call& fn);
-as_value key_isdown(const fn_call& fn);
-as_value key_istoggled(const fn_call& fn);
-as_value key_removelistener(const fn_call& fn);
-
 /************************************************************************
  *
  * This has been moved from action.cpp, when things are clean

Index: testsuite/actionscript.all/Makefile.am
===================================================================
RCS file: /sources/gnash/gnash/testsuite/actionscript.all/Makefile.am,v
retrieving revision 1.74
retrieving revision 1.75
diff -u -b -r1.74 -r1.75
--- testsuite/actionscript.all/Makefile.am      12 Jul 2007 01:51:06 -0000      
1.74
+++ testsuite/actionscript.all/Makefile.am      24 Jul 2007 14:19:32 -0000      
1.75
@@ -16,7 +16,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: Makefile.am,v 1.74 2007/07/12 01:51:06 zoulunkai Exp $
+# $Id: Makefile.am,v 1.75 2007/07/24 14:19:32 strk Exp $
 
 AUTOMAKE_OPTIONS = dejagnu
 
@@ -81,6 +81,7 @@
        Date.as                 \
        Error.as                \
        Global.as               \
+       Key.as                  \
        LoadVars.as             \
        Math.as                 \
        Microphone.as           \

Index: testsuite/actionscript.all/Key.as
===================================================================
RCS file: testsuite/actionscript.all/Key.as
diff -N testsuite/actionscript.all/Key.as
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ testsuite/actionscript.all/Key.as   24 Jul 2007 14:19:32 -0000      1.1
@@ -0,0 +1,87 @@
+// 
+//   Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc.
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+
+// Test case for Stage ActionScript class
+// compile this test case with Ming makeswf, and then
+// execute it like this gnash -1 -r 0 -v out.swf
+
+rcsid="$Id: Key.as,v 1.1 2007/07/24 14:19:32 strk Exp $";
+
+#include "check.as"
+
+check_equals (typeof(Key), 'object');
+
+var keyObj = new Key;
+check_equals (typeof(keyObj), 'undefined');
+
+check_equals(Key.__proto__, Object.prototype);
+
+// Methods
+#if OUTPUT_VERSION > 5
+check_equals(typeof(Key.addListener), 'function');
+check_equals(typeof(Key.removeListener), 'function');
+#else // OUTPUT_VERSION <= 5
+check_equals(typeof(Key.addListener), 'undefined');
+check_equals(typeof(Key.removeListener), 'undefined');
+#endif // OUTPUT_VERSION <= 5
+check_equals(typeof(Key.getAscii), 'function');
+check_equals(typeof(Key.getCode), 'function');
+check_equals(typeof(Key.isDown), 'function');
+check_equals(typeof(Key.isToggled), 'function');
+
+// Properties
+check_equals(typeof(Key.CAPSLOCK), 'number');
+check_equals(Key.CAPSLOCK, 20);
+check_equals(typeof(Key.TAB), 'number');
+check_equals(Key.TAB, 9);
+check_equals(typeof(Key.CONTROL), 'number');
+check_equals(Key.CONTROL, 17);
+check_equals(typeof(Key.SHIFT), 'number');
+check_equals(Key.SHIFT, 16);
+check_equals(typeof(Key.DELETEKEY), 'number');
+check_equals(Key.DELETEKEY, 46);
+check_equals(typeof(Key.INSERT), 'number');
+check_equals(Key.INSERT, 45);
+check_equals(typeof(Key.BACKSPACE), 'number');
+check_equals(Key.BACKSPACE, 8);
+check_equals(typeof(Key.LEFT), 'number');
+check_equals(Key.LEFT, 37);
+check_equals(typeof(Key.UP), 'number');
+check_equals(Key.UP, 38);
+check_equals(typeof(Key.RIGHT), 'number');
+check_equals(Key.RIGHT, 39);
+check_equals(typeof(Key.DOWN), 'number');
+check_equals(Key.DOWN, 40);
+check_equals(typeof(Key.HOME), 'number');
+check_equals(Key.HOME, 36);
+check_equals(typeof(Key.END), 'number');
+check_equals(Key.END, 35);
+check_equals(typeof(Key.ENTER), 'number');
+check_equals(Key.ENTER, 13);
+check_equals(typeof(Key.ESCAPE), 'number');
+check_equals(Key.ESCAPE, 27);
+check_equals(typeof(Key.PGDN), 'number');
+check_equals(Key.PGDN, 34);
+check_equals(typeof(Key.PGUP), 'number');
+check_equals(Key.PGUP, 33);
+check_equals(typeof(Key.SPACE), 'number');
+check_equals(Key.SPACE, 32);
+
+// Event handlers are:
+// onKeyUp
+// onKeyDown




reply via email to

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