gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash ChangeLog server/as_environment.cpp serve...


From: Sandro Santilli
Subject: [Gnash-commit] gnash ChangeLog server/as_environment.cpp serve...
Date: Tue, 31 Oct 2006 12:55:24 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  06/10/31 12:55:24

Modified files:
        .              : ChangeLog 
        server         : as_environment.cpp dlist.cpp dlist.h 
                         sprite_instance.cpp sprite_instance.h 
        testsuite/actionscript.all: MovieClip.as 

Log message:
        Implemented MovieClip.getNextHighestDepth() - see ChangeLog for details

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.1460&r2=1.1461
http://cvs.savannah.gnu.org/viewcvs/gnash/server/as_environment.cpp?cvsroot=gnash&r1=1.25&r2=1.26
http://cvs.savannah.gnu.org/viewcvs/gnash/server/dlist.cpp?cvsroot=gnash&r1=1.32&r2=1.33
http://cvs.savannah.gnu.org/viewcvs/gnash/server/dlist.h?cvsroot=gnash&r1=1.15&r2=1.16
http://cvs.savannah.gnu.org/viewcvs/gnash/server/sprite_instance.cpp?cvsroot=gnash&r1=1.70&r2=1.71
http://cvs.savannah.gnu.org/viewcvs/gnash/server/sprite_instance.h?cvsroot=gnash&r1=1.33&r2=1.34
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/actionscript.all/MovieClip.as?cvsroot=gnash&r1=1.6&r2=1.7

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.1460
retrieving revision 1.1461
diff -u -b -r1.1460 -r1.1461
--- ChangeLog   31 Oct 2006 12:25:31 -0000      1.1460
+++ ChangeLog   31 Oct 2006 12:55:24 -0000      1.1461
@@ -1,5 +1,20 @@
 2006-10-31 Sandro Santilli <address@hidden>
 
+       * testsuite/actionscript.all/MovieClip.as: added test
+         for getNextHighestDepth().
+       * server/:sprite_instance.{h,cpp}:
+         implemented getNextHighestDepth() ActionScript method;
+         changed init_builtins() to take a version number; called      
+         init_builtins only when really needed, as in constructor
+         the as_environment get_version() method will fail as 
+         the top-level movie_root would not have an associated
+         root movie yet (complex, yes... )
+         Made the getNextHighestDepth() AS method only available
+         when target movie is SWF7 or higher.
+       * server/: dlist.{h,cpp}:
+         added getNextHighestDepth() method.
+       * server/as_environment.cpp (get_version): more assertions
+         (we have an initialization problem there)
        * testsuite/movies.all/README: updated info about gravity-embed.swf
          (after last modification)
 

Index: server/as_environment.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/as_environment.cpp,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -b -r1.25 -r1.26
--- server/as_environment.cpp   29 Oct 2006 18:34:11 -0000      1.25
+++ server/as_environment.cpp   31 Oct 2006 12:55:24 -0000      1.26
@@ -16,7 +16,7 @@
 
 //
 
-/* $Id: as_environment.cpp,v 1.25 2006/10/29 18:34:11 rsavoye Exp $ */
+/* $Id: as_environment.cpp,v 1.26 2006/10/31 12:55:24 strk Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -477,8 +477,11 @@
 int
 as_environment::get_version() const
 {
+       assert(m_target);
        sprite_instance* si=m_target->get_root_movie();
+       assert(si);
        movie_definition* md=si->get_movie_definition();
+       assert(md);
        return md->get_version();
 }
 

Index: server/dlist.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/dlist.cpp,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -b -r1.32 -r1.33
--- server/dlist.cpp    29 Oct 2006 18:34:11 -0000      1.32
+++ server/dlist.cpp    31 Oct 2006 12:55:24 -0000      1.33
@@ -88,6 +88,26 @@
        }
 };
 
+int
+DisplayList::getNextHighestDepth() const
+{
+       unsigned int nexthighestdepth=0;
+       for (const_iterator it = _characters.begin(),
+                       itEnd = _characters.end();
+               it != itEnd; ++it)
+       {
+               character* ch = it->get_ptr();
+               assert(ch); // is this really needed ?
+
+               unsigned int chdepth = ch->get_depth();
+               if ( chdepth >= nexthighestdepth )
+               {
+                       nexthighestdepth = chdepth+1;
+               }
+       }
+       return nexthighestdepth;
+}
+
 character*
 DisplayList::get_character_at_depth(int depth)
 {

Index: server/dlist.h
===================================================================
RCS file: /sources/gnash/gnash/server/dlist.h,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -b -r1.15 -r1.16
--- server/dlist.h      29 Oct 2006 18:34:11 -0000      1.15
+++ server/dlist.h      31 Oct 2006 12:55:24 -0000      1.16
@@ -205,6 +205,14 @@
                return _characters.size();
        }
 
+       /// Return the next highest available depth
+       //
+       /// Placing an object at the depth returned by
+       /// this function should result in a character
+       /// that is displayd above all others
+       ///
+       int getNextHighestDepth() const;
+
 private:
 
        typedef std::list<DisplayItem> container_type;

Index: server/sprite_instance.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/sprite_instance.cpp,v
retrieving revision 1.70
retrieving revision 1.71
diff -u -b -r1.70 -r1.71
--- server/sprite_instance.cpp  29 Oct 2006 18:34:11 -0000      1.70
+++ server/sprite_instance.cpp  31 Oct 2006 12:55:24 -0000      1.71
@@ -548,6 +548,29 @@
        //assert(0); 
 }
 
+//getNextHighestDepth() : Number
+static void
+sprite_getNextHighestDepth(const fn_call& fn)
+{
+       sprite_instance* sprite = dynamic_cast<sprite_instance*>(fn.this_ptr);
+       if (sprite == NULL)
+       {
+               // Handle programming errors
+               log_error("getNextHighestDepth called against an object"
+                       " which is NOT a MovieClip (%s), "
+                       "returning undefined", typeid(fn.this_ptr).name());
+               fn.result->set_undefined();
+               return;
+       }
+
+       unsigned int nextdepth = sprite->getNextHighestDepth();
+       fn.result->set_double(static_cast<double>(nextdepth));
+}
+
+//------------------------------------------------
+// sprite_instance helper classes
+//------------------------------------------------
+
 
 class HeightFinder {
 public:
@@ -611,8 +634,6 @@
        //m_root->add_ref();    // @@ circular!
        m_as_environment.set_target(this);
 
-       init_builtins();
-
        // Initialize the flags for init action executed.
        m_init_actions_executed.resize(m_def->get_frame_count());
        for (std::vector<bool>::iterator p = m_init_actions_executed.begin(); p 
!= m_init_actions_executed.end(); ++p)
@@ -641,7 +662,7 @@
 // Initialize the Sprite/MovieClip builtin class 
 //
 as_object sprite_instance::as_builtins;
-void sprite_instance::init_builtins()
+void sprite_instance::init_builtins(int target_version)
 {
        static bool done=false;
        if ( done ) return;
@@ -663,6 +684,15 @@
        as_builtins.set_member("createEmptyMovieClip", 
&sprite_create_empty_movieclip);
        as_builtins.set_member("removeMovieClip", &sprite_remove_movieclip);
 
+       // The following interfaces should only
+       // be available when target SWF version is equal
+       // or above 7
+       if ( target_version  >= 7 )
+       {
+               as_builtins.set_member("getNextHighestDepth",
+                       &sprite_getNextHighestDepth);
+       }
+
        // @TODO
        //as_builtins.set_member("startDrag", &sprite_start_drag);
        //as_builtins.set_member("stopDrag", &sprite_stop_drag);
@@ -1553,6 +1583,8 @@
 void
 sprite_instance::execute_frame_tags(size_t frame, bool state_only)
 {
+       init_builtins(get_environment().get_version());
+
 
        // Keep this (particularly m_as_environment) alive during execution!
        smart_ptr<as_object>    this_ptr(this);
@@ -1593,6 +1625,8 @@
 
 void sprite_instance::execute_frame_tags_reverse(size_t frame)
 {
+       init_builtins(get_environment().get_version());
+
 
        // Keep this (particularly m_as_environment) alive during execution!
        smart_ptr<as_object>    this_ptr(this);
@@ -1610,6 +1644,8 @@
 
 void sprite_instance::execute_remove_tags(int frame)
 {
+       init_builtins(get_environment().get_version());
+
            assert(frame >= 0);
            assert((size_t)frame < m_def->get_frame_count());
 
@@ -2153,6 +2189,7 @@
 sprite_instance*
 sprite_instance::get_root_movie()
 {
+       assert(m_root);
        return m_root->get_root_movie();
 }
 

Index: server/sprite_instance.h
===================================================================
RCS file: /sources/gnash/gnash/server/sprite_instance.h,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -b -r1.33 -r1.34
--- server/sprite_instance.h    29 Oct 2006 18:34:11 -0000      1.33
+++ server/sprite_instance.h    31 Oct 2006 12:55:24 -0000      1.34
@@ -17,7 +17,7 @@
 // 
 //
 
-/* $Id: sprite_instance.h,v 1.33 2006/10/29 18:34:11 rsavoye Exp $ */
+/* $Id: sprite_instance.h,v 1.34 2006/10/31 12:55:24 strk Exp $ */
 
 // Stateful live Sprite instance
 
@@ -487,6 +487,17 @@
                return m_display_list;
        }
 
+       /// Return the next highest available depth
+       //
+       /// Placing an object at the depth returned by
+       /// this function should result in a character
+       /// that is displayd above all others
+       ///
+       int getNextHighestDepth() const {
+               return m_display_list.getNextHighestDepth();
+       }
+
+
 private:
 
 
@@ -523,7 +534,19 @@
 
        // For built-in sprite ActionScript methods.
        static as_object as_builtins;
-       static void init_builtins();
+
+       /// Initialize built-ins for target SWF version
+       //
+       /// Some interfaces might be unavailable in certaing
+       /// versions.
+       ///
+       /// NOTE: if you call this multiple times with different
+       ///       target versions only the first invocation will
+       ///       have an effect.
+       ///
+       /// TODO: move to implementation file...
+       ///
+       static void init_builtins(int target_version);
 
        /// Increment m_current_frame, and take care of looping.
        void increment_frame_and_check_for_loop();

Index: testsuite/actionscript.all/MovieClip.as
===================================================================
RCS file: /sources/gnash/gnash/testsuite/actionscript.all/MovieClip.as,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- testsuite/actionscript.all/MovieClip.as     29 Oct 2006 18:34:18 -0000      
1.6
+++ testsuite/actionscript.all/MovieClip.as     31 Oct 2006 12:55:24 -0000      
1.7
@@ -22,7 +22,7 @@
 // compile this test case with Ming makeswf, and then
 // execute it like this gnash -1 -r 0 -v out.swf
 
-rcsid="$Id: MovieClip.as,v 1.6 2006/10/29 18:34:18 rsavoye Exp $";
+rcsid="$Id: MovieClip.as,v 1.7 2006/10/31 12:55:24 strk Exp $";
 
 #include "check.as"
 
@@ -60,7 +60,6 @@
 
 if (OUTPUT_VERSION >= 7) {
     xcheck(mc.getInstanceAtDepth != undefined);
-    xcheck(mc.getNextHighestDepth != undefined);
     xcheck(mc.getSWFVersion != undefined);
     xcheck(mc.getTextSnapshot != undefined);
     xcheck(mc.lineStyle != undefined);
@@ -77,6 +76,8 @@
     xcheck(mc.focusEnabled != undefined);
     xcheck(mc.hitArea != undefined);
     xcheck(mc.menu != undefined);
+} else {
+   check_equals(mc.getNextHighestDepth(), undefined);
 }
 
 xcheck(mc.getURL != undefined);




reply via email to

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