[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] /srv/bzr/gnash/trunk r10750: Clean up MovieClipLoader.
From: |
Benjamin Wolsey |
Subject: |
[Gnash-commit] /srv/bzr/gnash/trunk r10750: Clean up MovieClipLoader. |
Date: |
Mon, 30 Mar 2009 17:27:53 +0200 |
User-agent: |
Bazaar (1.5) |
------------------------------------------------------------
revno: 10750
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Mon 2009-03-30 17:27:53 +0200
message:
Clean up MovieClipLoader.
modified:
libcore/asobj/LoadableObject.cpp
libcore/asobj/MovieClipLoader.cpp
------------------------------------------------------------
revno: 10749.1.1
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Mon 2009-03-30 09:22:26 +0200
message:
Clean up MovieClipLoader.
modified:
libcore/asobj/MovieClipLoader.cpp
------------------------------------------------------------
revno: 10749.1.2
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Mon 2009-03-30 09:45:40 +0200
message:
Modify interface.
modified:
libcore/asobj/MovieClipLoader.cpp
------------------------------------------------------------
revno: 10749.1.3
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Mon 2009-03-30 11:49:01 +0200
message:
Minor improvement to LoadableObject.
modified:
libcore/asobj/LoadableObject.cpp
------------------------------------------------------------
revno: 10749.1.4
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Mon 2009-03-30 11:50:27 +0200
message:
Move empty dtor inline.
modified:
libcore/asobj/MovieClipLoader.cpp
=== modified file 'libcore/asobj/LoadableObject.cpp'
--- a/libcore/asobj/LoadableObject.cpp 2009-03-17 09:44:00 +0000
+++ b/libcore/asobj/LoadableObject.cpp 2009-03-30 09:49:01 +0000
@@ -190,7 +190,11 @@
LoadableObject::queueLoad(std::auto_ptr<IOChannel> str)
{
- bool startTimer = _loadThreads.empty();
+ // We don't need to check before adding a timer, but
+ // this may optimize slightly (it was already in the code).
+ if (_loadThreads.empty()) {
+ getVM().getRoot().addAdvanceCallback(this);
+ }
std::auto_ptr<LoadThread> lt (new LoadThread(str));
@@ -199,14 +203,8 @@
// of onData invocation.
// Doing so also avoids processing queued load
// request immediately
- //
_loadThreads.push_front(lt.release());
- if (startTimer)
- {
- getVM().getRoot().addAdvanceCallback(this);
- }
-
_bytesLoaded = 0;
_bytesTotal = -1;
=== modified file 'libcore/asobj/MovieClipLoader.cpp'
--- a/libcore/asobj/MovieClipLoader.cpp 2009-02-25 22:33:03 +0000
+++ b/libcore/asobj/MovieClipLoader.cpp 2009-03-30 09:50:27 +0000
@@ -46,41 +46,54 @@
namespace gnash {
- /// This class is used to queue a function call action
- //
- /// Exact use is to queue onLoadInit, which should be invoked
- /// after actions of in first frame of a loaded movie are executed.
- /// Since those actions are queued the only way to execute something
- /// after them is to queue the function call as well.
- ///
- /// The class might be made more general and accessible outside
- /// of the MovieClipLoader class. For now it only works for
- /// calling a function with a two argument.
- ///
- class DelayedFunctionCall: public ExecutableCode {
-
- public:
-
- DelayedFunctionCall(as_object* target, string_table::key name, const
as_value& arg1, const as_value& arg2)
- :
- _target(target),
- _name(name),
- _arg1(arg1),
- _arg2(arg2)
+
+// 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_new(const fn_call& fn);
+ void attachMovieClipLoaderInterface(as_object& o);
+ as_object* getMovieClipLoaderInterface();
+}
+
+/// This class is used to queue a function call action
+//
+/// Exact use is to queue onLoadInit, which should be invoked
+/// after actions of in first frame of a loaded movie are executed.
+/// Since those actions are queued the only way to execute something
+/// after them is to queue the function call as well.
+///
+/// The class might be made more general and accessible outside
+/// of the MovieClipLoader class. For now it only works for
+/// calling a function with a two argument.
+///
+class DelayedFunctionCall : public ExecutableCode
+{
+
+public:
+
+ DelayedFunctionCall(as_object* target, string_table::key name,
+ const as_value& arg1, const as_value& arg2)
+ :
+ _target(target),
+ _name(name),
+ _arg1(arg1),
+ _arg2(arg2)
{}
ExecutableCode* clone() const
{
- return new DelayedFunctionCall(*this);
+ return new DelayedFunctionCall(*this);
}
virtual void execute()
{
- _target->callMethod(_name, _arg1, _arg2);
+ _target->callMethod(_name, _arg1, _arg2);
}
- #ifdef GNASH_USE_GC
+#ifdef GNASH_USE_GC
/// Mark reachable resources (for the GC)
//
/// Reachable resources are:
@@ -92,50 +105,15 @@
_arg1.setReachable();
_arg2.setReachable();
}
- #endif // GNASH_USE_GC
+#endif // GNASH_USE_GC
- private:
+private:
as_object* _target;
string_table::key _name;
as_value _arg1, _arg2;
- };
-
-// Forward declarations
-static as_value moviecliploader_loadclip(const fn_call& fn);
-static as_value moviecliploader_unloadclip(const fn_call& fn);
-static as_value moviecliploader_getprogress(const fn_call& fn);
-static as_value moviecliploader_new(const fn_call& fn);
-
-static void
-attachMovieClipLoaderInterface(as_object& o)
-{
- o.init_member("loadClip", new
builtin_function(moviecliploader_loadclip));
- o.init_member("unloadClip",
- new builtin_function(moviecliploader_unloadclip));
- o.init_member("getProgress",
- new builtin_function(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);
-
-}
-
-static as_object*
-getMovieClipLoaderInterface()
-{
- static boost::intrusive_ptr<as_object> o;
- if ( o == NULL )
- {
- o = new as_object(getObjectInterface());
- attachMovieClipLoaderInterface(*o);
- }
- return o.get();
-}
+};
class MovieClipLoader: public as_object
{
@@ -143,20 +121,19 @@
MovieClipLoader();
- ~MovieClipLoader();
+ ~MovieClipLoader() {}
/// MovieClip
- bool loadClip(const std::string& url, MovieClip& target);
+ bool loadClip(const std::string& url, MovieClip* target);
void unloadClip();
+protected:
+
+ void markReachableResources() const {
+ }
+
private:
-
- bool _started;
- bool _completed;
- std::string _filespec;
- int _progress;
- bool _error;
};
MovieClipLoader::MovieClipLoader()
@@ -169,12 +146,8 @@
set_member(NSV::PROP_uLISTENERS, ar);
}
-MovieClipLoader::~MovieClipLoader()
-{
-}
-
bool
-MovieClipLoader::loadClip(const std::string& url_str, MovieClip& target)
+MovieClipLoader::loadClip(const std::string& url_str, MovieClip* target)
{
movie_root& mr = _vm.getRoot();
@@ -185,10 +158,10 @@
log_debug(_(" resolved url: %s"), url.str());
#endif
- as_value targetVal(&target);
+ as_value targetVal(target);
log_debug("Target is %s", targetVal);
- bool ret = target.loadMovie(url);
+ bool ret = target->loadMovie(url);
if ( ! ret )
{
@@ -246,10 +219,57 @@
void
MovieClipLoader::unloadClip()
{
- GNASH_REPORT_FUNCTION;
-}
-
-static as_value
+ GNASH_REPORT_FUNCTION;
+}
+
+/// Extern.
+void
+moviecliploader_class_init(as_object& global)
+{
+ // This is going to be the global Number "class"/"function"
+ static boost::intrusive_ptr<builtin_function> cl = NULL;
+
+ if (cl == NULL)
+ {
+ cl=new builtin_function(&moviecliploader_new,
+ getMovieClipLoaderInterface());
+ }
+ global.init_member("MovieClipLoader", cl.get());
+}
+
+
+namespace {
+
+void
+attachMovieClipLoaderInterface(as_object& o)
+{
+ o.init_member("loadClip", new
builtin_function(moviecliploader_loadclip));
+ o.init_member("unloadClip",
+ new builtin_function(moviecliploader_unloadclip));
+ o.init_member("getProgress",
+ new builtin_function(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)
{
@@ -296,14 +316,14 @@
str_url, (void*)sprite);
#endif
- ptr->loadClip(str_url, *sprite);
+ ptr->loadClip(str_url, sprite);
// We always want to return true unless something went wrong
return as_value(true);
}
-static as_value
+as_value
moviecliploader_unloadclip(const fn_call& fn)
{
const std::string filespec = fn.arg(0).to_string();
@@ -311,7 +331,7 @@
return as_value();
}
-static as_value
+as_value
moviecliploader_new(const fn_call& /* fn */)
{
@@ -322,7 +342,7 @@
// Invoked every time the loading content is written to disk during
// the loading process.
-static as_value
+as_value
moviecliploader_getprogress(const fn_call& fn)
{
@@ -373,18 +393,5 @@
return as_value(mcl_obj.get()); // will keep alive
}
-void
-moviecliploader_class_init(as_object& global)
-{
- // This is going to be the global Number "class"/"function"
- static boost::intrusive_ptr<builtin_function> cl=NULL;
-
- if ( cl == NULL )
- {
- cl=new builtin_function(&moviecliploader_new,
- getMovieClipLoaderInterface());
- }
- global.init_member("MovieClipLoader", cl.get());
-}
-
+} // anonymous namespace
} // end of gnash namespace
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] /srv/bzr/gnash/trunk r10750: Clean up MovieClipLoader.,
Benjamin Wolsey <=