[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] [SCM] Gnash branch, master, updated. e1fd4745b89f6d644001
From: |
Benjamin Wolsey |
Subject: |
[Gnash-commit] [SCM] Gnash branch, master, updated. e1fd4745b89f6d6440016fad085551eb807b5754 |
Date: |
Thu, 02 Dec 2010 14:11:17 +0000 |
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Gnash".
The branch, master has been updated
via e1fd4745b89f6d6440016fad085551eb807b5754 (commit)
from 5a8952cf6f6675fa7ce2bb91986133419459e3f4 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit//commit/?id=e1fd4745b89f6d6440016fad085551eb807b5754
commit e1fd4745b89f6d6440016fad085551eb807b5754
Author: Benjamin Wolsey <address@hidden>
Date: Thu Dec 2 15:08:33 2010 +0100
Use ptr_containers to make pointer handling simpler.
diff --git a/libcore/movie_root.cpp b/libcore/movie_root.cpp
index 0467794..d5775ca 100644
--- a/libcore/movie_root.cpp
+++ b/libcore/movie_root.cpp
@@ -110,12 +110,8 @@ class RemoveTargetCode
{
public:
RemoveTargetCode(DisplayObject* target) : _target(target) {}
- bool operator()(ExecutableCode* c) const {
- if (_target == c->target()) {
- delete c;
- return true;
- }
- return false;
+ bool operator()(const ExecutableCode& c) const {
+ return _target == c.target();
}
private:
DisplayObject* _target;
@@ -187,9 +183,8 @@ movie_root::nextUnnamedInstance()
void
movie_root::clearActionQueue()
{
- for (int lvl=0; lvl < PRIORITY_SIZE; ++lvl) {
+ for (size_t lvl = 0; lvl < _actionQueue.size(); ++lvl) {
ActionQueue& q = _actionQueue[lvl];
- deleteChecked(q.begin(), q.end());
q.clear();
}
}
@@ -714,14 +709,13 @@ movie_root::fire_mouse_event()
// FIXME: need_redraw might also depend on actual
// actions execution (consider updateAfterEvent).
- try
- {
+ try {
need_redraw = generate_mouse_button_events(*this, _mouseButtonState);
processActionQueue();
}
- catch (ActionLimitException& al)
- {
- boost::format fmt = boost::format(_("ActionLimits hit during mouse
event processing: %s. Disable scripts ?")) % al.what();
+ catch (const ActionLimitException& al) {
+ boost::format fmt = boost::format(_("ActionLimits hit during mouse "
+ "event processing: %s. Disable scripts ?")) % al.what();
handleActionLimitHit(fmt.str());
}
@@ -885,13 +879,13 @@ movie_root::advance()
executeTimers();
}
- catch (ActionLimitException& al) {
+ catch (const ActionLimitException& al) {
// The PP does not disable scripts when the stack limit is reached,
// but rather struggles on.
log_error(_("Action limit hit during advance: %s"), al.what());
clearActionQueue();
}
- catch (ActionParserException& e) {
+ catch (const ActionParserException& e) {
log_error(_("Buffer overread during advance: %s"), e.what());
clearActionQueue();
}
@@ -1344,7 +1338,7 @@ movie_root::processActionQueue(size_t lvl)
{
ActionQueue& q = _actionQueue[lvl];
- assert( minPopulatedPriorityQueue() == lvl );
+ assert(minPopulatedPriorityQueue() == lvl);
#ifdef GNASH_DEBUG
static unsigned calls=0;
@@ -1361,8 +1355,7 @@ movie_root::processActionQueue(size_t lvl)
// and a final call to .clear()
while (!q.empty()) {
- std::auto_ptr<ExecutableCode> code(q.front());
- q.pop_front();
+ std::auto_ptr<ExecutableCode> code(q.pop_front().release());
code->execute();
size_t minLevel = minPopulatedPriorityQueue();
@@ -1459,16 +1452,14 @@ void
movie_root::removeQueuedConstructor(DisplayObject* target)
{
ActionQueue& pr = _actionQueue[PRIORITY_CONSTRUCT];
-
- pr.erase(std::remove_if(pr.begin(), pr.end(), RemoveTargetCode(target)),
- pr.end());
+ pr.erase_if(RemoveTargetCode(target));
}
void
movie_root::pushAction(std::auto_ptr<ExecutableCode> code, size_t lvl)
{
assert(lvl < PRIORITY_SIZE);
- _actionQueue[lvl].push_back(code.release());
+ _actionQueue[lvl].push_back(code);
}
void
@@ -1481,7 +1472,7 @@ movie_root::pushAction(const action_buffer& buf,
DisplayObject* target)
std::auto_ptr<ExecutableCode> code(new GlobalCode(buf, target));
- _actionQueue[PRIORITY_DOACTION].push_back(code.release());
+ _actionQueue[PRIORITY_DOACTION].push_back(code);
}
void
@@ -1717,7 +1708,7 @@ movie_root::markReachableResources() const
{
const ActionQueue& q = _actionQueue[lvl];
std::for_each(q.begin(), q.end(),
- std::mem_fun(&ExecutableCode::markReachableResources));
+ std::mem_fun_ref(&ExecutableCode::markReachableResources));
}
if (_currentFocus) _currentFocus->setReachable();
diff --git a/libcore/movie_root.h b/libcore/movie_root.h
index b09211e..dd31703 100644
--- a/libcore/movie_root.h
+++ b/libcore/movie_root.h
@@ -71,10 +71,11 @@
#include <map>
#include <string>
#include <vector>
-#include <deque>
#include <list>
#include <set>
#include <bitset>
+#include <boost/array.hpp>
+#include <boost/ptr_container/ptr_deque.hpp>
#include <boost/noncopyable.hpp>
#include "smart_ptr.h" // GNASH_USE_GC
@@ -1031,11 +1032,12 @@ private:
/// A number of queues of code to execute
//
- /// This is a deque because it needs no insertion in the middle but
+ /// This is a ptr_deque because it needs no insertion in the middle but
/// frequent push_back and pop_front. We also have to traverse it, so
- /// a std::queue is not usable.
- typedef std::deque<ExecutableCode*> ActionQueue;
- ActionQueue _actionQueue[PRIORITY_SIZE];
+ /// a queue is not usable.
+ typedef boost::ptr_deque<ExecutableCode> ActionQueue;
+
+ boost::array<ActionQueue, PRIORITY_SIZE> _actionQueue;
/// Process all actions in the queue
void processActionQueue();
diff --git a/libcore/swf/DefineButtonTag.cpp b/libcore/swf/DefineButtonTag.cpp
index b149ce0..3db779e 100644
--- a/libcore/swf/DefineButtonTag.cpp
+++ b/libcore/swf/DefineButtonTag.cpp
@@ -18,12 +18,10 @@
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
-
-// Based on the public domain work of Thatcher Ulrich <address@hidden> 2003
-
#include "DefineButtonTag.h"
#include <string>
+#include <boost/functional.hpp>
#include "TypesParser.h"
#include "RunResources.h"
@@ -73,7 +71,6 @@ DefineButtonTag::DefineButtonTag(SWFStream& in,
movie_definition& m,
DefineButtonTag::~DefineButtonTag()
{
- deleteChecked(_buttonActions.begin(), _buttonActions.end());
}
@@ -207,19 +204,16 @@ DefineButtonTag::readDefineButton2Tag(SWFStream& in,
movie_definition& m)
// Read Button2ActionConditions
// Don't read past tag end
- while ( in.tell() < tagEndPosition )
- {
+ while (in.tell() < tagEndPosition) {
in.ensureBytes(2);
unsigned next_action_offset = in.read_u16();
- if ( next_action_offset )
- {
+ if (next_action_offset) {
next_action_pos = in.tell() + next_action_offset - 2;
- if ( next_action_pos > tagEndPosition )
- {
+ if (next_action_pos > tagEndPosition) {
IF_VERBOSE_MALFORMED_SWF(
- log_swferror(_("Next action offset (%u) in "
- "Button2ActionConditions points past "
- "the end of tag"), next_action_offset);
+ log_swferror(_("Next action offset (%u) in "
+ "Button2ActionConditions points past "
+ "the end of tag"), next_action_offset);
);
next_action_pos = tagEndPosition;
}
@@ -260,12 +254,9 @@ DefineButtonTag::getSWFVersion() const
bool
DefineButtonTag::hasKeyPressHandler() const
{
- for (size_t i = 0, e = _buttonActions.size(); i < e; ++i)
- {
- const ButtonAction& ba = *(_buttonActions[i]);
- if ( ba.triggeredByKeyPress() ) return true;
- }
- return false;
+ return std::find_if(_buttonActions.begin(), _buttonActions.end(),
+ boost::mem_fn(&ButtonAction::triggeredByKeyPress)) !=
+ _buttonActions.end();
}
//
diff --git a/libcore/swf/DefineButtonTag.h b/libcore/swf/DefineButtonTag.h
index 3d9f034..94be876 100644
--- a/libcore/swf/DefineButtonTag.h
+++ b/libcore/swf/DefineButtonTag.h
@@ -17,11 +17,11 @@
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
-
#ifndef GNASH_SWF_DEFINEBUTTONTAG_H
#define GNASH_SWF_DEFINEBUTTONTAG_H
#include <vector>
+#include <boost/ptr_container/ptr_vector.hpp>
#include <boost/scoped_ptr.hpp>
#include <boost/cstdint.hpp>
#include <memory>
@@ -124,7 +124,7 @@ private:
// This is a GC resource, so not owned by anyone.
const DefinitionTag* _definitionTag;
- int _buttonLayer;
+ int _buttonLayer;
SWFMatrix _matrix;
@@ -154,8 +154,7 @@ public:
bool triggeredBy(const event_id& ev) const;
/// Return true if this action is triggered by a keypress
- bool triggeredByKeyPress() const
- {
+ bool triggeredByKeyPress() const {
return (_conditions & KEYPRESS);
}
@@ -164,9 +163,7 @@ private:
/// Return the keycode triggering this action
//
/// Return 0 if no key is supposed to trigger us
- ///
- int getKeyCode() const
- {
+ int getKeyCode() const {
return (_conditions & KEYPRESS) >> 9;
}
@@ -183,7 +180,7 @@ private:
OVER_DOWN_TO_IDLE = 1 << 8,
KEYPRESS = 0xFE00 // highest 7 bits
};
- int _conditions;
+ int _conditions;
};
@@ -197,7 +194,7 @@ public:
const RunResources& r);
typedef std::vector<ButtonRecord> ButtonRecords;
- typedef std::vector<ButtonAction*> ButtonActions;
+ typedef boost::ptr_vector<ButtonAction> ButtonActions;
virtual ~DefineButtonTag();
@@ -246,14 +243,11 @@ public:
//
/// The functor will be passed a const action_buffer&
/// and is not expected to return anything.
- ///
template <class E>
- void forEachTrigger(const event_id& ev, E& f) const
- {
- for (size_t i = 0, e = _buttonActions.size(); i < e; ++i)
- {
- const ButtonAction& ba = *(_buttonActions[i]);
- if ( ba.triggeredBy(ev) ) f(ba._actions);
+ void forEachTrigger(const event_id& ev, E& f) const {
+ for (size_t i = 0, e = _buttonActions.size(); i < e; ++i) {
+ const ButtonAction& ba = _buttonActions[i];
+ if (ba.triggeredBy(ev)) f(ba._actions);
}
}
@@ -277,6 +271,7 @@ private:
boost::scoped_ptr<SWF::DefineButtonSoundTag> _soundTag;
ButtonRecords _buttonRecords;
+
ButtonActions _buttonActions;
/// Whether to enable the trackAsMenu property.
-----------------------------------------------------------------------
Summary of changes:
libcore/movie_root.cpp | 39 +++++++++++++++------------------------
libcore/movie_root.h | 12 +++++++-----
libcore/swf/DefineButtonTag.cpp | 29 ++++++++++-------------------
libcore/swf/DefineButtonTag.h | 27 +++++++++++----------------
4 files changed, 43 insertions(+), 64 deletions(-)
hooks/post-receive
--
Gnash
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] [SCM] Gnash branch, master, updated. e1fd4745b89f6d6440016fad085551eb807b5754,
Benjamin Wolsey <=