[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] /srv/bzr/gnash/trunk r11588: More small corrections, remo
From: |
Benjamin Wolsey |
Subject: |
[Gnash-commit] /srv/bzr/gnash/trunk r11588: More small corrections, removal of static data. |
Date: |
Mon, 26 Oct 2009 08:28:55 +0100 |
User-agent: |
Bazaar (1.16.1) |
------------------------------------------------------------
revno: 11588 [merge]
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Mon 2009-10-26 08:28:55 +0100
message:
More small corrections, removal of static data.
modified:
libcore/asobj/Globals.cpp
libcore/asobj/LoadVars_as.cpp
libcore/asobj/MovieClipLoader.cpp
libcore/asobj/MovieClipLoader.h
testsuite/actionscript.all/LoadVars.as
testsuite/swfdec/PASSING
=== modified file 'libcore/asobj/Globals.cpp'
--- a/libcore/asobj/Globals.cpp 2009-10-23 09:36:32 +0000
+++ b/libcore/asobj/Globals.cpp 2009-10-23 15:28:46 +0000
@@ -534,7 +534,7 @@
(N(sharedobject_class_init, NSV::CLASS_SHARED_OBJECT,
NSV::CLASS_OBJECT, NS_GLOBAL, 5))
(N(loadvars_class_init, NSV::CLASS_LOAD_VARS, NSV::CLASS_OBJECT,
- NS_GLOBAL, 6))
+ NS_GLOBAL, 5))
(N(localconnection_class_init, NSV::CLASS_LOCALCONNECTION,
NSV::CLASS_OBJECT, NS_GLOBAL, 6))
(N(customactions_class_init, NSV::CLASS_CUSTOM_ACTIONS,
@@ -548,7 +548,7 @@
(N(contextmenuitem_class_init, NSV::CLASS_CONTEXTMENUITEM,
NSV::CLASS_OBJECT, NS_GLOBAL, 5))
(N(moviecliploader_class_init, NSV::CLASS_MOVIE_CLIP_LOADER,
- NSV::CLASS_OBJECT, NS_GLOBAL, 7))
+ NSV::CLASS_OBJECT, NS_GLOBAL, 5))
(N(Error_class_init, NSV::CLASS_ERROR, NSV::CLASS_OBJECT, NS_GLOBAL,
5))
(N(accessibility_class_init, NSV::CLASS_ACCESSIBILITY,
NSV::CLASS_OBJECT, NS_GLOBAL, 5));
@@ -1525,6 +1525,7 @@
registerTextFieldNative(global);
registerButtonNative(global);
registerVideoNative(global);
+ registerMovieClipLoaderNative(global);
registerXMLSocketNative(global);
registerSharedObjectNative(global);
registerKeyboardNative(global);
=== modified file 'libcore/asobj/LoadVars_as.cpp'
--- a/libcore/asobj/LoadVars_as.cpp 2009-10-23 09:36:32 +0000
+++ b/libcore/asobj/LoadVars_as.cpp 2009-10-23 12:51:22 +0000
@@ -68,18 +68,20 @@
Global_as& gl = getGlobal(o);
VM& vm = getVM(o);
- o.init_member("decode", vm.getNative(301, 3));
- o.init_member("load", vm.getNative(301, 0));
- o.init_member("send", vm.getNative(301, 1));
- o.init_member("sendAndLoad", vm.getNative(301, 2));
+ const int flags = as_object::DefaultFlags | PropFlags::onlySWF6Up;
+
+ o.init_member("decode", vm.getNative(301, 3), flags);
+ o.init_member("load", vm.getNative(301, 0), flags);
+ o.init_member("send", vm.getNative(301, 1), flags);
+ o.init_member("sendAndLoad", vm.getNative(301, 2), flags);
/// This handles getBytesLoaded, getBytesTotal, and addRequestHeader
- attachLoadableInterface(o, as_object::DefaultFlags);
+ attachLoadableInterface(o, flags);
- o.init_member("toString", gl.createFunction(loadvars_tostring));
- o.init_member("onData", gl.createFunction(loadvars_onData));
- o.init_member("onLoad", gl.createFunction(loadvars_onLoad));
- o.init_member("contentType", "application/x-www-form-urlencoded");
+ o.init_member("toString", gl.createFunction(loadvars_tostring), flags);
+ o.init_member("onData", gl.createFunction(loadvars_onData), flags);
+ o.init_member("onLoad", gl.createFunction(loadvars_onLoad), flags);
+ o.init_member("contentType", "application/x-www-form-urlencoded", flags);
}
as_value
=== modified file 'libcore/asobj/MovieClipLoader.cpp'
--- a/libcore/asobj/MovieClipLoader.cpp 2009-10-23 06:25:25 +0000
+++ b/libcore/asobj/MovieClipLoader.cpp 2009-10-23 17:32:35 +0000
@@ -40,6 +40,7 @@
#include "AsBroadcaster.h" // for initializing self as a broadcaster
#include "namedStrings.h"
#include "ExecutableCode.h"
+#include "NativeFunction.h"
#include <string>
@@ -50,12 +51,11 @@
// Forward declarations
namespace {
- as_value moviecliploader_loadclip(const fn_call& fn);
- as_value moviecliploader_unloadclip(const fn_call& fn);
- as_value moviecliploader_getprogress(const fn_call& fn);
+ as_value moviecliploader_loadClip(const fn_call& fn);
+ as_value moviecliploader_unloadClip(const fn_call& fn);
+ as_value moviecliploader_getProgress(const fn_call& fn);
as_value moviecliploader_new(const fn_call& fn);
void attachMovieClipLoaderInterface(as_object& o);
- as_object* getMovieClipLoaderInterface();
}
/// This class is used to queue a function call action
@@ -116,56 +116,100 @@
};
-class MovieClipLoader: public as_object
-{
-public:
-
- MovieClipLoader();
-
- ~MovieClipLoader() {}
-
- /// MovieClip
- bool loadClip(const std::string& url, MovieClip* target);
-
- void unloadClip();
-
-protected:
-
- void markReachableResources() const {
- markAsObjectReachable();
- }
-
-private:
-};
-
-MovieClipLoader::MovieClipLoader()
- :
- as_object(getMovieClipLoaderInterface())
-{
-
- as_object* ar = getGlobal(*this).createArray();
- ar->callMethod(NSV::PROP_PUSH, this);
- set_member(NSV::PROP_uLISTENERS, ar);
-}
-
-bool
-MovieClipLoader::loadClip(const std::string& url_str, MovieClip* target)
-{
-
- movie_root& mr = getRoot(*this);
-
- URL url(url_str, mr.runResources().baseURL());
+void
+registerMovieClipLoaderNative(as_object& global)
+{
+ VM& vm = getVM(global);
+ vm.registerNative(moviecliploader_loadClip, 112, 100);
+ vm.registerNative(moviecliploader_getProgress, 112, 101);
+ vm.registerNative(moviecliploader_unloadClip, 112, 102);
+}
+
+/// Extern.
+void
+moviecliploader_class_init(as_object& where, const ObjectURI& uri)
+{
+ // This is going to be the where Number "class"/"function"
+ Global_as& gl = getGlobal(where);
+
+ as_object* proto = gl.createObject();;
+
+ as_object* cl = gl.createClass(&moviecliploader_new, proto);
+ attachMovieClipLoaderInterface(*proto);
+
+ AsBroadcaster::initialize(*proto);
+
+ string_table& st = getStringTable(where);
+ as_object* null = 0;
+ gl.callMethod(st.find("ASSetPropFlags"), proto, null, 1027);
+
+ where.init_member(getName(uri), cl, as_object::DefaultFlags,
+ getNamespace(uri));
+}
+
+
+namespace {
+
+void
+attachMovieClipLoaderInterface(as_object& o)
+{
+
+ const int flags = PropFlags::onlySWF7Up;
+
+ VM& vm = getVM(o);
+
+ o.init_member("loadClip", vm.getNative(112, 100), flags);
+ o.init_member("getProgress", vm.getNative(112, 101), flags);
+ o.init_member("unloadClip", vm.getNative(112, 102), flags);
+
+}
+
+as_value
+moviecliploader_loadClip(const fn_call& fn)
+{
+
+ as_object* ptr = ensure<ValidThis>(fn);
+
+ if ( fn.nargs < 2 ) {
+ IF_VERBOSE_ASCODING_ERRORS(
+ std::stringstream ss; fn.dump_args(ss);
+ log_aserror(_("MovieClipLoader.loadClip(%s): missing arguments"),
+ ss.str());
+ );
+ return as_value(false);
+ }
+
+ const std::string& str_url = fn.arg(0).to_string();
+
+ as_value tgt_arg = fn.arg(1);
+
+ std::string tgt_str = tgt_arg.to_string();
+ DisplayObject* target = fn.env().find_target(tgt_str);
+
+ if (!target) {
+ IF_VERBOSE_ASCODING_ERRORS(
+ log_aserror(_("Could not find target %s (evaluated from %s)"),
+ tgt_str, tgt_arg);
+ );
+ return as_value(false);
+ }
+
+ MovieClip* sprite = target->to_movie();
+ if (!sprite) {
+ IF_VERBOSE_ASCODING_ERRORS(
+ log_aserror(_("Target %s is not a sprite instance (%s)"),
+ target->getTarget(), typeName(*target));
+ );
+ return as_value(false);
+ }
+
+ as_value targetVal(sprite);
+
+ movie_root& mr = getRoot(*ptr);
+ URL url(str_url, mr.runResources().baseURL());
-#if GNASH_DEBUG
- log_debug(_(" resolved url: %s"), url.str());
-#endif
-
- as_value targetVal(target);
- log_debug("Target is %s", targetVal);
-
- bool ret = target->loadMovie(url);
- if ( ! ret )
- {
+ bool ret = sprite->loadMovie(url);
+ if (!ret) {
// FIXME: docs suggest the string can be either "URLNotFound" or
// "LoadNeverCompleted". This is neither of them:
@@ -175,32 +219,31 @@
// was attempted (sandbox) or no status information is available
// (supposedly the Adobe mozilla plugin).
as_value arg2(0.0);
- callMethod(NSV::PROP_BROADCAST_MESSAGE, "onLoadError",
targetVal,
+ ptr->callMethod(NSV::PROP_BROADCAST_MESSAGE, "onLoadError",
sprite,
arg1, arg2);
- return false;
+ return as_value(true);
}
// this is to resolve the soft ref
MovieClip* newChar = targetVal.to_sprite();
- if ( ! newChar )
- {
+ if (!newChar) {
// We could assert, but let's try to be nicer...
log_error("MovieClip::loadMovie destroyed self without
replacing?");
- return false;
+ return as_value(true);
}
// Dispatch onLoadStart
- callMethod(NSV::PROP_BROADCAST_MESSAGE, "onLoadStart", targetVal);
+ ptr->callMethod(NSV::PROP_BROADCAST_MESSAGE, "onLoadStart", targetVal);
// Dispatch onLoadProgress
size_t bytesLoaded = newChar->get_bytes_loaded();
size_t bytesTotal = newChar->get_bytes_total();
- callMethod(NSV::PROP_BROADCAST_MESSAGE, "onLoadProgress", targetVal,
+ ptr->callMethod(NSV::PROP_BROADCAST_MESSAGE, "onLoadProgress",
targetVal,
bytesLoaded, bytesTotal);
// Dispatch onLoadComplete
- callMethod(NSV::PROP_BROADCAST_MESSAGE, "onLoadComplete", targetVal,
+ ptr->callMethod(NSV::PROP_BROADCAST_MESSAGE, "onLoadComplete",
targetVal,
as_value(0.0)); // TODO: find semantic of last arg
/// This event must be dispatched when actions
@@ -210,120 +253,17 @@
/// and thus queue all actions in first frame, we'll queue the
/// onLoadInit call next, so it happens after the former.
std::auto_ptr<ExecutableCode> code(
- new DelayedFunctionCall(this, NSV::PROP_BROADCAST_MESSAGE,
+ new DelayedFunctionCall(ptr, NSV::PROP_BROADCAST_MESSAGE,
"onLoadInit", targetVal));
- getRoot(*this).pushAction(code, movie_root::apDOACTION);
-
- return true;
-}
-
-void
-MovieClipLoader::unloadClip()
-{
- GNASH_REPORT_FUNCTION;
-}
-
-/// Extern.
-void
-moviecliploader_class_init(as_object& global, const ObjectURI& uri)
-{
- // This is going to be the global Number "class"/"function"
- Global_as& gl = getGlobal(global);
- as_object* cl = gl.createClass(&moviecliploader_new,
- getMovieClipLoaderInterface());
- global.init_member(getName(uri), cl, as_object::DefaultFlags,
- getNamespace(uri));
-}
-
-
-namespace {
-
-void
-attachMovieClipLoaderInterface(as_object& o)
-{
- Global_as& gl = getGlobal(o);
- o.init_member("loadClip", gl.createFunction(moviecliploader_loadclip));
- o.init_member("unloadClip",
- gl.createFunction(moviecliploader_unloadclip));
- o.init_member("getProgress",
- gl.createFunction(moviecliploader_getprogress));
-
- // NOTE: we want addListener/removeListener/broadcastMessage
- // but don't what the _listeners property here...
- // TODO: add an argument to AsBroadcaster::initialize skip listeners ?
- AsBroadcaster::initialize(o);
- o.delProperty(NSV::PROP_uLISTENERS);
-
-}
-
-as_object*
-getMovieClipLoaderInterface()
-{
- static boost::intrusive_ptr<as_object> o;
- if ( o == NULL )
- {
- o = new as_object(getObjectInterface());
- attachMovieClipLoaderInterface(*o);
- }
- return o.get();
-}
-
-as_value
-moviecliploader_loadclip(const fn_call& fn)
-{
-
- MovieClipLoader* ptr = ensure<ThisIs<MovieClipLoader> >(fn);
-
- if ( fn.nargs < 2 )
- {
- IF_VERBOSE_ASCODING_ERRORS(
- std::stringstream ss; fn.dump_args(ss);
- log_aserror(_("MovieClipLoader.loadClip(%s): missing
arguments"),
- ss.str());
- );
- return as_value(false);
- }
-
- as_value url_arg = fn.arg(0);
- std::string str_url = url_arg.to_string();
-
- as_value tgt_arg = fn.arg(1);
- std::string tgt_str = tgt_arg.to_string();
- DisplayObject* target = fn.env().find_target(tgt_str);
- if ( ! target )
- {
- IF_VERBOSE_ASCODING_ERRORS(
- log_aserror(_("Could not find target %s (evaluated from %s)"),
- tgt_str, tgt_arg);
- );
- return as_value(false);
- }
-
- MovieClip* sprite = target->to_movie();
- if ( ! sprite )
- {
- IF_VERBOSE_ASCODING_ERRORS(
- log_aserror(_("Target %s is not a sprite instance (%s)"),
- target->getTarget(), typeName(*target));
- );
- return as_value(false);
- }
-
-#if GNASH_DEBUG
- log_debug(_("load clip: %s, target is: %p\n"),
- str_url, (void*)sprite);
-#endif
-
- ptr->loadClip(str_url, sprite);
-
- // We always want to return true unless something went wrong
+ getRoot(*ptr).pushAction(code, movie_root::apDOACTION);
+
return as_value(true);
}
as_value
-moviecliploader_unloadclip(const fn_call& fn)
+moviecliploader_unloadClip(const fn_call& fn)
{
const std::string filespec = fn.arg(0).to_string();
log_unimpl (_("%s: %s"), __PRETTY_FUNCTION__, filespec);
@@ -331,18 +271,22 @@
}
as_value
-moviecliploader_new(const fn_call& /* fn */)
+moviecliploader_new(const fn_call& fn)
{
-
- as_object* mov_obj = new MovieClipLoader;
-
- return as_value(mov_obj);
+ as_object* ptr = ensure<ValidThis>(fn);
+ Global_as& gl = getGlobal(fn);
+
+ as_object* array = gl.createArray();
+ array->callMethod(NSV::PROP_PUSH, ptr);
+ ptr->set_member(NSV::PROP_uLISTENERS, array);
+ ptr->set_member_flags(NSV::PROP_uLISTENERS, as_object::DefaultFlags);
+ return as_value();
}
// Invoked every time the loading content is written to disk during
// the loading process.
as_value
-moviecliploader_getprogress(const fn_call& fn)
+moviecliploader_getProgress(const fn_call& fn)
{
if ( ! fn.nargs )
@@ -355,8 +299,7 @@
boost::intrusive_ptr<as_object> target =
fn.arg(0).to_object(getGlobal(fn));
- if ( ! target.get() )
- {
+ if (!target.get()) {
IF_VERBOSE_ASCODING_ERRORS(
log_aserror(_("MovieClipLoader.getProgress(%s): first argument
is "
"not an object"), fn.arg(0));
@@ -365,8 +308,7 @@
}
MovieClip* sp = target->to_movie();
- if ( ! sp )
- {
+ if (!sp) {
IF_VERBOSE_ASCODING_ERRORS(
log_aserror(_("MovieClipLoader.getProgress(%s): first argument
is "
"not an sprite"), fn.arg(0));
@@ -375,7 +317,7 @@
}
- boost::intrusive_ptr<as_object> mcl_obj = new as_object;
+ as_object* mcl_obj = new as_object;
size_t bytesLoaded = sp->get_bytes_loaded();
size_t bytesTotal = sp->get_bytes_total();
@@ -386,7 +328,7 @@
mcl_obj->set_member(st.find("bytesLoaded"), bytesLoaded);
mcl_obj->set_member(st.find("bytesTotal"), bytesTotal);
- return as_value(mcl_obj.get()); // will keep alive
+ return as_value(mcl_obj);
}
} // anonymous namespace
=== modified file 'libcore/asobj/MovieClipLoader.h'
--- a/libcore/asobj/MovieClipLoader.h 2009-07-16 08:30:06 +0000
+++ b/libcore/asobj/MovieClipLoader.h 2009-10-23 15:28:46 +0000
@@ -27,6 +27,8 @@
/// Initialize the global MovieClipLoader class
void moviecliploader_class_init(as_object& global, const ObjectURI& uri);
+void registerMovieClipLoaderNative(as_object& global);
+
} // end of gnash namespace
// GNASH_MOVIECLIPLOADER_H
=== modified file 'testsuite/actionscript.all/LoadVars.as'
--- a/testsuite/actionscript.all/LoadVars.as 2009-07-01 07:11:33 +0000
+++ b/testsuite/actionscript.all/LoadVars.as 2009-10-23 12:37:50 +0000
@@ -27,12 +27,12 @@
#if OUTPUT_VERSION < 6
-xcheck_equals(typeof(LoadVars), 'function');
+check_equals(typeof(LoadVars), 'function');
var loadvarsObj = new LoadVars;
// test the LoadVars constuctor
-xcheck_equals (typeof(loadvarsObj), 'object');
+check_equals (typeof(loadvarsObj), 'object');
check_totals(2);
=== modified file 'testsuite/swfdec/PASSING'
--- a/testsuite/swfdec/PASSING 2009-10-23 10:34:10 +0000
+++ b/testsuite/swfdec/PASSING 2009-10-23 15:29:39 +0000
@@ -760,12 +760,17 @@
movieclip-hittest-target-5.swf:6d484ea1799df7f08eac134be82bacd4
moviecliploader-constructor-5.swf:fd0fb9a785017456810f06b61c109d35
moviecliploader-constructor-6.swf:e50f068ebde835d503c43ae1fcaf4371
+moviecliploader-constructor-7.swf:d521cb4d73849b824db9333bb04ff4a8
+moviecliploader-constructor-8.swf:f2c66f1a23cf602c8161b3cec7c83bae
moviecliploader-getprogress-5.swf:0d58d1e3762e678c27f38309c34906ec
moviecliploader-getprogress-6.swf:80231ce07d7197f269532a7d9f920c06
moviecliploader-known-image-size-7.swf:62f495b0354dbe7dcb80ef256392843a
moviecliploader-known-image-size-8.swf:32aaecb1e0735b6c94e980d21753e698
moviecliploader-level-5.swf:fa26ae6da1ec573daae0ce5357a419c5
moviecliploader-level-6.swf:cd9f65f627a47a906c4d140e8e518160
+moviecliploader-properties-6.swf:85084f5ae86539dfedf525b204762dbf
+moviecliploader-properties-7.swf:f10fa0e2b443f46af6780465633ceb75
+moviecliploader-properties-8.swf:78fa86752025a314051eae11806c1498
moviecliploader-unknown-format-5.swf:b28db9ff343a9487fbb90adfc46725b9
moviecliploader-unknown-format-6.swf:08cab100a05f91617b55f30492ff814d
movieclip-lockroot-5.swf:fe978aade775b3701f8813fde797c8cd
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] /srv/bzr/gnash/trunk r11588: More small corrections, removal of static data.,
Benjamin Wolsey <=