gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash ChangeLog server/as_value.cpp server/spri...


From: Sandro Santilli
Subject: [Gnash-commit] gnash ChangeLog server/as_value.cpp server/spri...
Date: Fri, 30 Mar 2007 07:23:19 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  07/03/30 07:23:19

Modified files:
        .              : ChangeLog 
        server         : as_value.cpp sprite_instance.cpp 
                         sprite_instance.h swf.h 
        server/vm      : ASHandlers.cpp 
        testsuite/actionscript.all: Makefile.am 
Added files:
        testsuite/actionscript.all: targetPath.as 

Log message:
                * server/as_value.cpp (to_sprite): don't attempt to resolve
                  the path to a sprite if this value is not a MOVIECLIP type.
                * server/swf.h: document ACTION_TARGETPATH
                * server/sprite_instance.{cpp,h}: implement getTarget(), have
                  get_text_value() call getTarget() internally.
                * server/vm/ASHandlers.cpp: Implement ActionTargetPath.
                * testsuite/actionscript.all/: Makefile.am, targetPath.as:
                  Test ACTION_TARGETPATH (0x45).

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.2723&r2=1.2724
http://cvs.savannah.gnu.org/viewcvs/gnash/server/as_value.cpp?cvsroot=gnash&r1=1.32&r2=1.33
http://cvs.savannah.gnu.org/viewcvs/gnash/server/sprite_instance.cpp?cvsroot=gnash&r1=1.210&r2=1.211
http://cvs.savannah.gnu.org/viewcvs/gnash/server/sprite_instance.h?cvsroot=gnash&r1=1.82&r2=1.83
http://cvs.savannah.gnu.org/viewcvs/gnash/server/swf.h?cvsroot=gnash&r1=1.29&r2=1.30
http://cvs.savannah.gnu.org/viewcvs/gnash/server/vm/ASHandlers.cpp?cvsroot=gnash&r1=1.77&r2=1.78
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/actionscript.all/Makefile.am?cvsroot=gnash&r1=1.69&r2=1.70
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/actionscript.all/targetPath.as?cvsroot=gnash&rev=1.1

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.2723
retrieving revision 1.2724
diff -u -b -r1.2723 -r1.2724
--- ChangeLog   29 Mar 2007 23:55:49 -0000      1.2723
+++ ChangeLog   30 Mar 2007 07:23:18 -0000      1.2724
@@ -1,3 +1,14 @@
+2007-03-30 Sandro Santilli <address@hidden>
+
+       * server/as_value.cpp (to_sprite): don't attempt to resolve
+         the path to a sprite if this value is not a MOVIECLIP type.
+       * server/swf.h: document ACTION_TARGETPATH
+       * server/sprite_instance.{cpp,h}: implement getTarget(), have
+         get_text_value() call getTarget() internally.
+       * server/vm/ASHandlers.cpp: Implement ActionTargetPath.
+       * testsuite/actionscript.all/: Makefile.am, targetPath.as:
+         Test ACTION_TARGETPATH (0x45).
+
 2007-03-29  Rob Savoye  <address@hidden>
 
        * configure.ac: Add --disable-menus since an embedded systems

Index: server/as_value.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/as_value.cpp,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -b -r1.32 -r1.33
--- server/as_value.cpp 22 Mar 2007 08:45:51 -0000      1.32
+++ server/as_value.cpp 30 Mar 2007 07:23:19 -0000      1.33
@@ -498,6 +498,8 @@
 sprite_instance*
 as_value::to_sprite() const
 {
+       if ( m_type != MOVIECLIP ) return NULL;
+
        // Evaluate target everytime an attempt is made 
        // to fetch a movieclip value.
        sprite_instance* root = VM::get().getRoot().get_root_movie();

Index: server/sprite_instance.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/sprite_instance.cpp,v
retrieving revision 1.210
retrieving revision 1.211
diff -u -b -r1.210 -r1.211
--- server/sprite_instance.cpp  29 Mar 2007 08:58:58 -0000      1.210
+++ server/sprite_instance.cpp  30 Mar 2007 07:23:19 -0000      1.211
@@ -3662,6 +3662,27 @@
        return _target;
 }
 
+const std::string&
+sprite_instance::getTarget() const
+{
+       if ( ! _target_dot.empty() ) return _target_dot;
+
+       std::string levelString = "_level0"; // TODO: support real levels!
+
+       const std::string& targetPath = getTargetPath();
+       if ( targetPath == "/" ) _target_dot = levelString;
+       else
+       {
+               _target_dot = levelString + targetPath;
+               for (std::string::size_type i=0; i<_target_dot.length(); ++i)
+               {
+                       if ( _target_dot[i] == '/' ) _target_dot[i] = '.';
+               }
+       }
+
+       return _target_dot;
+}
+
 /*private*/
 std::string
 sprite_instance::computeTargetPath() const
@@ -3710,22 +3731,7 @@
 const char*
 sprite_instance::get_text_value() const
 {
-       if ( ! _target_dot.empty() ) return _target_dot.c_str();
-
-       std::string levelString = "_level0"; // TODO: support real levels!
-
-       const std::string& targetPath = getTargetPath();
-       if ( targetPath == "/" ) _target_dot = levelString;
-       else
-       {
-               _target_dot = levelString + targetPath;
-               for (std::string::size_type i=0; i<_target_dot.length(); ++i)
-               {
-                       if ( _target_dot[i] == '/' ) _target_dot[i] = '.';
-               }
-       }
-
-       return _target_dot.c_str();
+       return getTarget().c_str();
 }
 
 // WARNING: THIS SNIPPET NEEDS THE CHARACTER TO BE "INSTANTIATED", which is

Index: server/sprite_instance.h
===================================================================
RCS file: /sources/gnash/gnash/server/sprite_instance.h,v
retrieving revision 1.82
retrieving revision 1.83
diff -u -b -r1.82 -r1.83
--- server/sprite_instance.h    29 Mar 2007 08:58:58 -0000      1.82
+++ server/sprite_instance.h    30 Mar 2007 07:23:19 -0000      1.83
@@ -17,7 +17,7 @@
 // 
 //
 
-/* $Id: sprite_instance.h,v 1.82 2007/03/29 08:58:58 strk Exp $ */
+/* $Id: sprite_instance.h,v 1.83 2007/03/30 07:23:19 strk Exp $ */
 
 // Stateful live Sprite instance
 
@@ -631,10 +631,16 @@
 
        /// Return full path to this object, in slash notation
        //
-       /// e.g. "/_level0/sprite1/sprite2/ourSprite"
+       /// e.g. "/sprite1/sprite2/ourSprite"
        ///
        const std::string& getTargetPath() const;
 
+       /// Return full path to this object, in dot notation
+       //
+       /// e.g. "_level0.sprite1.sprite2.ourSprite"
+       ///
+       const std::string& getTarget() const;
+
        /// Override for character::set_name to proprely update
        /// _target and _target_dot.
        virtual void set_name(const char* name);

Index: server/swf.h
===================================================================
RCS file: /sources/gnash/gnash/server/swf.h,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -b -r1.29 -r1.30
--- server/swf.h        15 Mar 2007 22:39:53 -0000      1.29
+++ server/swf.h        30 Mar 2007 07:23:19 -0000      1.30
@@ -274,6 +274,14 @@
     ACTION_INITOBJECT              = 0x43,
 
     ACTION_TYPEOF                  = 0x44,
+
+    /// SWF5
+    ///
+    /// Pop a value from the stack. If it is a valid movieclip push
+    /// it's target back on the stack (example: _level0.sprite1.sprite2).
+    ///
+    /// http://sswf.sourceforge.net/SWFalexref.html#action_get_target
+    ///
     ACTION_TARGETPATH              = 0x45,
 
     /// SWF5

Index: server/vm/ASHandlers.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/vm/ASHandlers.cpp,v
retrieving revision 1.77
retrieving revision 1.78
diff -u -b -r1.77 -r1.78
--- server/vm/ASHandlers.cpp    29 Mar 2007 17:23:31 -0000      1.77
+++ server/vm/ASHandlers.cpp    30 Mar 2007 07:23:19 -0000      1.78
@@ -14,7 +14,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: ASHandlers.cpp,v 1.77 2007/03/29 17:23:31 strk Exp $ */
+/* $Id: ASHandlers.cpp,v 1.78 2007/03/30 07:23:19 strk Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -1063,12 +1063,12 @@
        {
                as_object* obj = thread.getTarget();
 
-               log_msg("ActionGetProperty(<empty>) called, target is %p", 
(void*)obj);
+               //log_msg("ActionGetProperty(<empty>) called, target is %p", 
(void*)obj);
 
                target = dynamic_cast<character*>(obj);
                if ( ! target )
                {
-                       log_msg("ActionGetProperty(<empty>) called, but current 
target is not a character");
+                       log_warning("ActionGetProperty(<empty>) called, but 
current target is not a character");
                }
        }
        else
@@ -2341,11 +2341,26 @@
 }
 
 void
-SWFHandlers::ActionTargetPath(ActionExec& /*thread*/)
+SWFHandlers::ActionTargetPath(ActionExec& thread)
 {
 //    GNASH_REPORT_FUNCTION;
-//    as_environment& env = thread.env;
-    dbglogfile << __PRETTY_FUNCTION__ << ": unimplemented!" << endl;
+
+       as_environment& env = thread.env;
+
+       thread.ensureStack(1);  // object
+
+       boost::intrusive_ptr<sprite_instance> sp = env.top(0).to_sprite();
+       if ( sp )
+       {
+               env.top(0).set_std_string(sp->getTarget());
+       }
+       else
+       {
+               IF_VERBOSE_ASCODING_ERRORS(
+               log_aserror("Argument to TargetPath() doesn't cast to a 
movieclip");
+               );
+               env.top(0).set_undefined();
+       }
 }
 
 // Push a each object's member value on the stack

Index: testsuite/actionscript.all/Makefile.am
===================================================================
RCS file: /sources/gnash/gnash/testsuite/actionscript.all/Makefile.am,v
retrieving revision 1.69
retrieving revision 1.70
diff -u -b -r1.69 -r1.70
--- testsuite/actionscript.all/Makefile.am      28 Mar 2007 20:01:04 -0000      
1.69
+++ testsuite/actionscript.all/Makefile.am      30 Mar 2007 07:23:19 -0000      
1.70
@@ -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.69 2007/03/28 20:01:04 strk Exp $
+# $Id: Makefile.am,v 1.70 2007/03/30 07:23:19 strk Exp $
 
 AUTOMAKE_OPTIONS = dejagnu
 
@@ -72,6 +72,7 @@
        delete.as               \
        getvariable.as          \
        swap.as                 \
+       targetPath.as           \
        Boolean.as              \
        Camera.as               \
        Color.as                \

Index: testsuite/actionscript.all/targetPath.as
===================================================================
RCS file: testsuite/actionscript.all/targetPath.as
diff -N testsuite/actionscript.all/targetPath.as
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ testsuite/actionscript.all/targetPath.as    30 Mar 2007 07:23:19 -0000      
1.1
@@ -0,0 +1,74 @@
+// 
+//   Copyright (C) 2007 Free Software Foundation, Inc.
+//
+// This program is free software; you can redistribute it and/or modchecky
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 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; check not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fcheckth Floor, Boston, MA  02110-1301  
USA
+//
+
+/*
+ *  Test targetPath tags (0x45)
+ */
+
+rcsid="$Id: targetPath.as,v 1.1 2007/03/30 07:23:19 strk Exp $";
+
+#include "check.as"
+
+check_equals(targetPath(_root), "_level0");
+
+// targetPath(null)
+asm {
+push "a"
+push null
+targetPath
+setvariable
+};
+check_equals(typeof(a), 'undefined');
+
+// targetPath(undefined)
+asm {
+push "a"
+push undefined
+targetPath
+setvariable
+};
+check_equals(typeof(a), 'undefined');
+
+// targetPath("str")
+asm {
+push "a"
+push "str"
+targetPath
+setvariable
+};
+check_equals(typeof(a), 'undefined');
+
+// targetPath(9)
+asm {
+push "a"
+push 9
+targetPath
+setvariable
+};
+check_equals(typeof(a), 'undefined');
+
+
+// targetPath("_root")
+asm {
+push "a"
+push "_root"
+targetPath
+setvariable
+};
+check_equals(typeof(a), 'undefined');
+




reply via email to

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