[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ChangeLog server/sprite_instance.cpp serv...
From: |
Sandro Santilli |
Subject: |
[Gnash-commit] gnash ChangeLog server/sprite_instance.cpp serv... |
Date: |
Thu, 10 May 2007 09:26:56 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Sandro Santilli <strk> 07/05/10 09:26:56
Modified files:
. : ChangeLog
server : sprite_instance.cpp sprite_instance.h
testsuite/actionscript.all: MovieClip.as
Log message:
* server/sprite_instance.{cpp,h}: Implemented
MovieClip.getInstanceAtDepth() and MovieClip.getSWFVersion();
stubbed MovieClip.getTextSnapshot().
* testsuite/actionscript.all/MovieClip.as: tested
MovieClip.getSWFVersion() and MovieClip.getInstanceAtDepth().
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.3148&r2=1.3149
http://cvs.savannah.gnu.org/viewcvs/gnash/server/sprite_instance.cpp?cvsroot=gnash&r1=1.264&r2=1.265
http://cvs.savannah.gnu.org/viewcvs/gnash/server/sprite_instance.h?cvsroot=gnash&r1=1.104&r2=1.105
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/actionscript.all/MovieClip.as?cvsroot=gnash&r1=1.67&r2=1.68
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.3148
retrieving revision 1.3149
diff -u -b -r1.3148 -r1.3149
--- ChangeLog 10 May 2007 08:18:48 -0000 1.3148
+++ ChangeLog 10 May 2007 09:26:56 -0000 1.3149
@@ -1,5 +1,13 @@
2007-05-10 Sandro Santilli <address@hidden>
+ * server/sprite_instance.{cpp,h}: Implemented
+ MovieClip.getInstanceAtDepth() and MovieClip.getSWFVersion();
+ stubbed MovieClip.getTextSnapshot().
+ * testsuite/actionscript.all/MovieClip.as: tested
+ MovieClip.getSWFVersion() and MovieClip.getInstanceAtDepth().
+
+2007-05-10 Sandro Santilli <address@hidden>
+
* server/as_value.{cpp,h}: encoding of movieclip values
by target path made optional, to help future attempts
at changing it, due to conceptual bug found in it running
Index: server/sprite_instance.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/sprite_instance.cpp,v
retrieving revision 1.264
retrieving revision 1.265
diff -u -b -r1.264 -r1.265
--- server/sprite_instance.cpp 6 May 2007 13:35:37 -0000 1.264
+++ server/sprite_instance.cpp 10 May 2007 09:26:56 -0000 1.265
@@ -784,6 +784,26 @@
return as_value(static_cast<double>(nextdepth));
}
+//getInstanceAtDepth(depth:Number) : MovieClip
+static as_value
+sprite_getInstanceAtDepth(const fn_call& fn)
+{
+ boost::intrusive_ptr<sprite_instance> sprite =
ensureType<sprite_instance>(fn.this_ptr);
+
+ if ( fn.nargs < 1 )
+ {
+ IF_VERBOSE_ASCODING_ERRORS(
+ log_aserror("MovieClip.getInstanceAtDepth(): missing depth
argument");
+ );
+ return as_value();
+ }
+
+ int depth = fn.arg(0).to_number<int>(&fn.env());
+ boost::intrusive_ptr<character> ch =
sprite->get_character_at_depth(depth);
+ if ( ! ch ) return as_value(); // we want 'undefined', not 'null'
+ return as_value(ch.get());
+}
+
// getURL(url:String, [window:String], [method:String]) : Void
static as_value
sprite_getURL(const fn_call& fn)
@@ -800,6 +820,30 @@
return as_value();
}
+// getSWFVersion() : Number
+static as_value
+sprite_getSWFVersion(const fn_call& fn)
+{
+ boost::intrusive_ptr<sprite_instance> sprite =
ensureType<sprite_instance>(fn.this_ptr);
+
+ return as_value(sprite->getSWFVersion());
+}
+
+// getTextSnapshot() : TextSnapshot
+static as_value
+sprite_getTextSnapshot(const fn_call& fn)
+{
+ boost::intrusive_ptr<sprite_instance> sprite =
ensureType<sprite_instance>(fn.this_ptr);
+
+ static bool warned = false;
+ if ( ! warned )
+ {
+ log_unimpl("MovieClip.getTextSnapshot()");
+ warned=true;
+ }
+ return as_value();
+}
+
// getBounds(targetCoordinateSpace:Object) : Object
static as_value
sprite_getBounds(const fn_call& fn)
@@ -1413,6 +1457,7 @@
o.init_member("getBounds", new builtin_function(sprite_getBounds));
o.init_member("globalToLocal", new
builtin_function(sprite_globalToLocal));
o.init_member("localToGlobal", new
builtin_function(sprite_localToGlobal));
+ o.init_member("getSWFVersion", new
builtin_function(sprite_getSWFVersion));
if ( target_version < 6 ) return;
// SWF6 or higher
@@ -1429,10 +1474,12 @@
o.init_member("createTextField", new
builtin_function(sprite_create_text_field));
o.init_member("getDepth", new builtin_function(sprite_get_depth));
o.init_member("createEmptyMovieClip", new
builtin_function(sprite_create_empty_movieclip));
+ o.init_member("getTextSnapshot", new
builtin_function(sprite_getTextSnapshot));
if ( target_version < 7 ) return;
// SWF7 or higher
o.init_member("getNextHighestDepth", new
builtin_function(sprite_getNextHighestDepth));
+ o.init_member("getInstanceAtDepth", new
builtin_function(sprite_getInstanceAtDepth));
if ( target_version < 8 ) return;
// TODO: many more methods, see MovieClip class ...
Index: server/sprite_instance.h
===================================================================
RCS file: /sources/gnash/gnash/server/sprite_instance.h,v
retrieving revision 1.104
retrieving revision 1.105
diff -u -b -r1.104 -r1.105
--- server/sprite_instance.h 26 Apr 2007 12:31:44 -0000 1.104
+++ server/sprite_instance.h 10 May 2007 09:26:56 -0000 1.105
@@ -131,6 +131,15 @@
return m_def.get();
}
+ /// \brief
+ /// Return version of the SWF definition of this instance
+ /// as been parsed from.
+ //
+ int getSWFVersion()
+ {
+ return m_def->get_version();
+ }
+
/// Get the composite bounds of all component drawing elements
geometry::Range2d<float> getBounds() const;
@@ -306,7 +315,13 @@
void display();
void swap_characters(character* ch1, character* ch2);
+
+ /// Return the character at given depth in our DisplayList.
+ //
+ /// @return NULL if the specified depth is available (no chars there)
+ ///
character* get_character_at_depth(int depth);
+
character* add_empty_movieclip(const char* name, int depth);
boost::intrusive_ptr<character> add_textfield(const std::string& name,
Index: testsuite/actionscript.all/MovieClip.as
===================================================================
RCS file: /sources/gnash/gnash/testsuite/actionscript.all/MovieClip.as,v
retrieving revision 1.67
retrieving revision 1.68
diff -u -b -r1.67 -r1.68
--- testsuite/actionscript.all/MovieClip.as 24 Apr 2007 21:49:37 -0000
1.67
+++ testsuite/actionscript.all/MovieClip.as 10 May 2007 09:26:56 -0000
1.68
@@ -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.67 2007/04/24 21:49:37 strk Exp $";
+rcsid="$Id: MovieClip.as,v 1.68 2007/05/10 09:26:56 strk Exp $";
#include "check.as"
@@ -60,6 +60,8 @@
check_equals(typeof(mc.globalToLocal), 'function');
check_equals(typeof(mc.localToGlobal), 'function');
check_equals(typeof(mc.unloadMovie), 'function');
+check_equals(typeof(mc.getSWFVersion), 'function');
+check_equals(mc.getSWFVersion(), OUTPUT_VERSION);
// This seems unavailable
// when targetting SWF > 6
@@ -92,6 +94,9 @@
check_equals(typeof(mc.prevFrame), 'function');
check_equals(typeof(mc.stop), 'function');
check_equals(typeof(mc.swapDepths), 'function');
+ check_equals(typeof(mc.startDrag), 'function');
+ check_equals(typeof(mc.stopDrag), 'function');
+ check_equals(typeof(mc.getTextSnapshot), 'function');
// These two seem unavailable
// when targetting SWF > 6
@@ -106,16 +111,15 @@
#endif // OUTPUT_VERSION >= 6
#if OUTPUT_VERSION >= 7
- xcheck(mc.getInstanceAtDepth != undefined);
- xcheck(mc.getSWFVersion != undefined);
- xcheck(mc.getTextSnapshot != undefined);
+
+ check_equals(typeof(mc.getInstanceAtDepth), 'function');
+ check( MovieClip.prototype.hasOwnProperty('getInstanceAtDepth') );
+ check( ! mc.hasOwnProperty('getInstanceAtDepth') );
// can't confirm this works !
// maybe we should just NOT use the _root for this ?
//check(mc.loadVariables != undefined);
- check(mc.startDrag);
- check(mc.stopDrag);
xcheck(mc.enabled);
// maybe this is the start condition...
@@ -190,7 +194,7 @@
check_equals(mc._droptarget, "");
check_equals(typeof(mc._droptarget), "string");
#else
-//WARNING: we have player succeeds on this, and also player fails on this
+//WARNING: we have player 9 succeeds on this, and also player 7 fails on this
// don't know which one to trust.
xcheck_equals(mc._droptarget, "");
#endif
@@ -211,7 +215,7 @@
check_equals(typeof(mc._name), "string");
check_equals(typeof(mc), "movieclip");
#else
-//WARNING: we have player succeeds on this, and also player fails on this
+//WARNING: we have player 9 succeeds on this, and also player 7 fails on this
// don't know which one to trust.
xcheck_equals(mc._name, "");
#endif
@@ -241,10 +245,18 @@
check_equals(mc2.getBytesLoaded(), 0);
check_equals(mc2.getBytesTotal(), 0);
+#if OUTPUT_VERSION > 6
+check_equals(getInstanceAtDepth(50), mc2);
+#endif
+
var mc3 = createEmptyMovieClip("mc3_mc", 50);
check(mc3 != undefined);
check_equals(mc3.getDepth(), 50);
+#if OUTPUT_VERSION > 6
+check_equals(getInstanceAtDepth(50), mc3);
+#endif
+
// By default useHandCursor is false in SWF5 and true in later versions
#if OUTPUT_VERSION < 6
check_equals(mc3.useHandCursor, false);
@@ -322,7 +334,9 @@
check_equals(softref.member, 1);
check_equals(softref._target, "/hardref");
#if OUTPUT_VERSION > 6
+check_equals(getInstanceAtDepth(60), hardref);
removeMovieClip(hardref); // using ActionRemoveClip (0x25)
+check_equals(getInstanceAtDepth(60), undefined);
#else
// just to test another way, ActionRemoveClip in SWF6 will work as well
hardref.removeMovieClip(); // using the sprite's removeMovieClip
@@ -852,3 +866,25 @@
note("There is not '"+static_clip_name+"' clip statically-defined, so
we could not test localToGlobal() and globalToLocal() against it");
}
+
+//---------------------------------------------------------------------
+// TODO: Test getInstanceAtDepth
+// (tested somehow above, but I mean a well-focused test here)
+//---------------------------------------------------------------------
+
+#if OUTPUT_VERSION >= 7
+
+check_equals(typeof(getInstanceAtDepth(-6)), 'undefined');
+check_equals(typeof(getInstanceAtDepth()), 'undefined');
+createEmptyMovieClip("tt2", -6);
+check_equals(typeof(getInstanceAtDepth(-6)), 'movieclip');
+o = new Object; o.valueOf = function() { return -6; };
+check_equals(typeof(getInstanceAtDepth(o)), 'movieclip');
+check_equals(getInstanceAtDepth(o), tt2);
+check_equals(getInstanceAtDepth(-6.7), tt2);
+check_equals(getInstanceAtDepth(-6.2), tt2);
+
+// what if we point to a non-sprite instance ? is it still considered a
"movieclip" ?
+
+#endif // OUTPUT_VERSION >= 7
+