gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash ChangeLog server/movie_root.cpp server/mo...


From: Sandro Santilli
Subject: [Gnash-commit] gnash ChangeLog server/movie_root.cpp server/mo...
Date: Tue, 27 Nov 2007 20:37:54 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  07/11/27 20:37:53

Modified files:
        .              : ChangeLog 
        server         : movie_root.cpp movie_root.h 
        server/asobj   : AsBroadcaster.cpp Mouse.cpp 
        testsuite/actionscript.all: Mouse.as 

Log message:
        Add support for Mouse AsBroadcaster interfaces.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.4986&r2=1.4987
http://cvs.savannah.gnu.org/viewcvs/gnash/server/movie_root.cpp?cvsroot=gnash&r1=1.128&r2=1.129
http://cvs.savannah.gnu.org/viewcvs/gnash/server/movie_root.h?cvsroot=gnash&r1=1.92&r2=1.93
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/AsBroadcaster.cpp?cvsroot=gnash&r1=1.12&r2=1.13
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/Mouse.cpp?cvsroot=gnash&r1=1.14&r2=1.15
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/actionscript.all/Mouse.as?cvsroot=gnash&r1=1.14&r2=1.15

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.4986
retrieving revision 1.4987
diff -u -b -r1.4986 -r1.4987
--- ChangeLog   27 Nov 2007 17:36:39 -0000      1.4986
+++ ChangeLog   27 Nov 2007 20:37:52 -0000      1.4987
@@ -1,5 +1,15 @@
 2007-11-27 Sandro Santilli <address@hidden>
 
+       * server/movie_root.{cpp,h}: notify mouse events to _global.Mouse
+         listeners
+       * server/asobj/Mouse.cpp: initialize _global.Mouse as an
+         AsBroadcaster.
+       * server/asobj/AsBroadcaster.cpp: reduce debugging output.
+       * testsuite/actionscript.all/Mouse.as: successes in AsBroadcaster
+         interfaces availability.
+
+2007-11-27 Sandro Santilli <address@hidden>
+
        * server/vm/ASHandlers.cpp (ActionMbSubString, ActionMbLength):
          always resize the vector passed as third argument to
          GuessEncoding so to contain at least one element each

Index: server/movie_root.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/movie_root.cpp,v
retrieving revision 1.128
retrieving revision 1.129
diff -u -b -r1.128 -r1.129
--- server/movie_root.cpp       22 Nov 2007 22:57:18 -0000      1.128
+++ server/movie_root.cpp       27 Nov 2007 20:37:53 -0000      1.129
@@ -340,6 +340,29 @@
        return _keyobject;
 }
 
+boost::intrusive_ptr<as_object>
+movie_root::getMouseObject()
+{
+       VM& vm = VM::get();
+
+       // TODO: test what happens with the global "Mouse" object
+       //       is removed or overridden by the user
+       if ( ! _mouseobject )
+       {
+               as_value val;
+               as_object* global = VM::get().getGlobal();
+
+               std::string objName = PROPNAME("Mouse");
+               if (global->get_member(vm.getStringTable().find(objName), &val) 
)
+               {
+                       //log_debug("Found member 'Mouse' in _global: %s", 
val.to_debug_string().c_str());
+                       _mouseobject = val.to_object();
+               }
+       }
+
+       return _mouseobject;
+}
+
 
 key_as_object *
 movie_root::notify_global_key(key::code k, bool down)
@@ -415,6 +438,7 @@
        return fire_mouse_event();
 }
 
+#if 0
 void
 movie_root::notify_mouse_state(int x, int y, int buttons)
 {
@@ -427,6 +451,7 @@
 
        assert(testInvariant());
 }
+#endif
 
 // Return wheter any action triggered by this event requires display redraw.
 // See page about events_handling (in movie_interface.h)
@@ -968,6 +993,14 @@
                }
        }
 
+       // Now broadcast message for Mouse listeners
+       typedef boost::intrusive_ptr<as_object> ObjPtr;
+       ObjPtr mouseObj = getMouseObject();
+       if ( mouseObj )
+       {
+               mouseObj->callMethod(NSV::PROP_BROADCAST_MESSAGE, 
as_value(PROPNAME(event.get_function_name())));
+       }
+
        assert(testInvariant());
 }
 
@@ -1266,9 +1299,12 @@
     // Mark character mouse listeners
     std::for_each(m_mouse_listeners.begin(), m_mouse_listeners.end(), 
boost::bind(&character::setReachable, _1));
 
-    // Mark global key object
+    // Mark global Key object
     if ( _keyobject ) _keyobject->setReachable();
 
+    // Mark global Mouse object
+    if ( _mouseobject ) _mouseobject->setReachable();
+
     // Mark character being dragged, if any
     m_drag_state.markReachableResources();
 

Index: server/movie_root.h
===================================================================
RCS file: /sources/gnash/gnash/server/movie_root.h,v
retrieving revision 1.92
retrieving revision 1.93
diff -u -b -r1.92 -r1.93
--- server/movie_root.h 22 Nov 2007 22:57:18 -0000      1.92
+++ server/movie_root.h 27 Nov 2007 20:37:53 -0000      1.93
@@ -15,7 +15,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: movie_root.h,v 1.92 2007/11/22 22:57:18 strk Exp $ */
+/* $Id: movie_root.h,v 1.93 2007/11/27 20:37:53 strk Exp $ */
 
 /// \page events_handling Handling of user events
 ///
@@ -252,7 +252,7 @@
 
     /// The host app can use this to tell the movie where the
     /// user's mouse pointer is.
-    void notify_mouse_state(int x, int y, int buttons);
+    //void notify_mouse_state(int x, int y, int buttons);
 
     /// \brief
     /// The host app can use this to tell the movie when
@@ -516,6 +516,7 @@
     /// - Key listeners (m_key_listeners)
     /// - Mouse listeners (m_mouse_listeners)
     /// - global Key object (_keyobject)
+    /// - global Mouse object (_mouseobject)
     /// - Any character being dragged 
     ///
     void markReachableResources() const;
@@ -676,6 +677,8 @@
 
     boost::intrusive_ptr<key_as_object> _keyobject;
 
+    boost::intrusive_ptr<as_object> _mouseobject;
+
     /// Objects listening for mouse events (down,up,move)
     MouseListeners m_mouse_listeners;
 
@@ -760,6 +763,12 @@
     ///
     boost::intrusive_ptr<key_as_object> getKeyObject();
 
+    /// Return the global Mouse object 
+    //
+    /// TODO: expose the mouse_as_object directly for faster calls ?
+    ///
+    boost::intrusive_ptr<as_object> getMouseObject();
+
     /// Boundaries of the Stage are always world boundaries
     /// and are only invalidated by changes in the background
     /// color.

Index: server/asobj/AsBroadcaster.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/AsBroadcaster.cpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- server/asobj/AsBroadcaster.cpp      20 Nov 2007 22:14:48 -0000      1.12
+++ server/asobj/AsBroadcaster.cpp      27 Nov 2007 20:37:53 -0000      1.13
@@ -106,7 +106,7 @@
 {
        as_object* asb = getAsBroadcaster();
 
-       log_debug("Initializing object %p as an AsBroadcaster", (void*)&o);
+       //log_debug("Initializing object %p as an AsBroadcaster", (void*)&o);
 
        as_value tmp;
 
@@ -168,7 +168,7 @@
 
        AsBroadcaster::initialize(*tgt);
 
-       log_debug("AsBroadcaster.initialize(%s): TESTING", 
tgtval.to_debug_string().c_str());
+       //log_debug("AsBroadcaster.initialize(%s): TESTING", 
tgtval.to_debug_string().c_str());
 
        return as_value();
 }
@@ -230,7 +230,7 @@
                listeners->push(newListener);
        }
 
-       log_debug("%p.addListener(%s) TESTING", (void*)fn.this_ptr.get(), 
fn.dump_args().c_str());
+       //log_debug("%p.addListener(%s) TESTING", (void*)fn.this_ptr.get(), 
fn.dump_args().c_str());
        return as_value(true);
 
 }
@@ -365,7 +365,7 @@
 
        unsigned int dispatched = visitor.eventsDispatched();
 
-       log_debug("AsBroadcaster.broadcastMessage() dispatched %u events", 
dispatched);
+       //log_debug("AsBroadcaster.broadcastMessage() dispatched %u events", 
dispatched);
 
        if ( dispatched ) return as_value(true);
        else return as_value(); // undefined

Index: server/asobj/Mouse.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/Mouse.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -b -r1.14 -r1.15
--- server/asobj/Mouse.cpp      31 Aug 2007 21:53:32 -0000      1.14
+++ server/asobj/Mouse.cpp      27 Nov 2007 20:37:53 -0000      1.15
@@ -27,26 +27,28 @@
 #include "fn_call.h"
 #include "smart_ptr.h" // for boost intrusive_ptr
 #include "builtin_function.h" // need builtin_function
-//#include "VM.h" // for registering static
+#include "VM.h" // for registerNative
 #include "Object.h" // for getObjectInterface
+#include "AsBroadcaster.h" // for initializing self as a broadcaster
 
 namespace gnash {
 
-as_value mouse_addlistener(const fn_call& fn);
 as_value mouse_hide(const fn_call& fn);
-as_value mouse_removelistener(const fn_call& fn);
 as_value mouse_show(const fn_call& fn);
 as_value mouse_ctor(const fn_call& fn);
 
 static void
 attachMouseInterface(as_object& o)
 {
+       VM& vm = o.getVM();
+
        // TODO: Mouse is an object, not a constructor ! Attach these interface 
to
        //       the singleton Mouse object then !
-       o.init_member("addListener", new builtin_function(mouse_addlistener));
-       o.init_member("hide", new builtin_function(mouse_hide));
-       o.init_member("removeListener", new 
builtin_function(mouse_removelistener));
-       o.init_member("show", new builtin_function(mouse_show));
+       vm.registerNative(mouse_show, 5, 0);
+       o.init_member("show", vm.getNative(5, 0));
+
+       vm.registerNative(mouse_hide, 5, 1);
+       o.init_member("hide", vm.getNative(5, 1));
 }
 
 static as_object*
@@ -69,7 +71,13 @@
        mouse_as_object()
                :
                as_object(getMouseInterface())
-       {}
+       {
+               int swfversion = _vm.getSWFVersion();
+               if ( swfversion > 5 )
+               {
+                       AsBroadcaster::initialize(*this);
+               }
+       }
 
        // override from as_object ?
        //std::string get_text_value() const { return "Mouse"; }
@@ -79,20 +87,6 @@
 
 };
 
-as_value mouse_addlistener(const fn_call& fn)
-{
-    boost::intrusive_ptr<mouse_as_object> 
obj=ensureType<mouse_as_object>(fn.this_ptr);
-    UNUSED(obj);
-
-    static bool warned=false;
-    if ( ! warned )
-    {
-        log_unimpl (__FUNCTION__);
-        warned=true;
-    }
-    return as_value();
-}
-
 as_value mouse_hide(const fn_call& fn)
 {
     boost::intrusive_ptr<mouse_as_object> 
obj=ensureType<mouse_as_object>(fn.this_ptr);
@@ -107,20 +101,6 @@
     return as_value();
 }
 
-as_value mouse_removelistener(const fn_call& fn)
-{
-    boost::intrusive_ptr<mouse_as_object> 
obj=ensureType<mouse_as_object>(fn.this_ptr);
-    UNUSED(obj);
-
-    static bool warned=false;
-    if ( ! warned )
-    {
-        log_unimpl (__FUNCTION__);
-        warned=true;
-    }
-    return as_value();
-}
-
 as_value mouse_show(const fn_call& fn)
 {
     boost::intrusive_ptr<mouse_as_object> 
obj=ensureType<mouse_as_object>(fn.this_ptr);

Index: testsuite/actionscript.all/Mouse.as
===================================================================
RCS file: /sources/gnash/gnash/testsuite/actionscript.all/Mouse.as,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -b -r1.14 -r1.15
--- testsuite/actionscript.all/Mouse.as 29 Sep 2007 16:22:57 -0000      1.14
+++ testsuite/actionscript.all/Mouse.as 27 Nov 2007 20:37:53 -0000      1.15
@@ -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: Mouse.as,v 1.14 2007/09/29 16:22:57 strk Exp $";
+rcsid="$Id: Mouse.as,v 1.15 2007/11/27 20:37:53 strk Exp $";
 
 #include "check.as"
 
@@ -39,10 +39,10 @@
  // See http://www.senocular.com/flash/tutorials/listenersasbroadcaster/?page=2
  check_equals ( typeof(Mouse.removeListener), 'function' );
  check_equals ( typeof(Mouse.addListener), 'function' );
- xcheck_equals( typeof(Mouse.broadcastMessage), 'function' );
- xcheck(Mouse.hasOwnProperty("_listeners"));
- xcheck_equals(typeof(Mouse._listeners), 'object');
- xcheck(Mouse._listeners instanceof Array);
+ check_equals( typeof(Mouse.broadcastMessage), 'function' );
+ check(Mouse.hasOwnProperty("_listeners"));
+ check_equals(typeof(Mouse._listeners), 'object');
+ check(Mouse._listeners instanceof Array);
 
 #endif // OUTPUT_VERSION > 5
 




reply via email to

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