[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] /srv/bzr/gnash/trunk r10409: Minor fix to Button properti
From: |
Benjamin Wolsey |
Subject: |
[Gnash-commit] /srv/bzr/gnash/trunk r10409: Minor fix to Button properties, various AS tests. |
Date: |
Thu, 11 Dec 2008 14:28:01 +0100 |
User-agent: |
Bazaar (1.5) |
------------------------------------------------------------
revno: 10409
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Thu 2008-12-11 14:28:01 +0100
message:
Minor fix to Button properties, various AS tests.
modified:
libcore/Button.cpp
libcore/Button.h
libcore/asobj/AsBroadcaster.cpp
libcore/asobj/AsBroadcaster.h
libcore/asobj/ClassHierarchy.cpp
testsuite/actionscript.all/AsBroadcaster.as
testsuite/misc-ming.all/ButtonEventsTest.c
testsuite/swfdec/Makefile.am
------------------------------------------------------------
revno: 10407.1.2
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Thu 2008-12-11 12:34:15 +0100
message:
Tidy up AsBroadcaster, add some more tests.
modified:
libcore/asobj/AsBroadcaster.cpp
libcore/asobj/AsBroadcaster.h
testsuite/actionscript.all/AsBroadcaster.as
------------------------------------------------------------
revno: 10407.1.3
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Thu 2008-12-11 13:23:46 +0100
message:
Implement Button.enabled as a normal, overwritable property.
modified:
libcore/Button.cpp
libcore/Button.h
testsuite/misc-ming.all/ButtonEventsTest.c
testsuite/swfdec/Makefile.am
------------------------------------------------------------
revno: 10407.1.4
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Thu 2008-12-11 14:07:41 +0100
message:
Line breaks, indentation, typenames.
modified:
libcore/Button.cpp
libcore/Button.h
libcore/asobj/ClassHierarchy.cpp
=== modified file 'libcore/Button.cpp'
--- a/libcore/Button.cpp 2008-12-05 09:37:07 +0000
+++ b/libcore/Button.cpp 2008-12-11 13:07:41 +0000
@@ -287,8 +287,8 @@
gettersetter = character::name_getset;
o.init_property(NSV::PROP_uNAME, gettersetter, gettersetter);
- gettersetter = &Button::enabled_getset;
- o.init_property(NSV::PROP_ENABLED, *gettersetter, *gettersetter);
+ const int unprotected = 0;
+ o.init_member(NSV::PROP_ENABLED, true, unprotected);
}
@@ -298,8 +298,7 @@
m_last_mouse_flags(IDLE),
m_mouse_flags(IDLE),
m_mouse_state(UP),
- _def(def),
- m_enabled(true)
+ _def(def)
{
set_prototype(getButtonInterface());
@@ -319,39 +318,13 @@
bool
-Button::get_enabled()
-{
- return m_enabled;
-}
-
-void
-Button::set_enabled(bool value)
-{
- if (value == m_enabled) return;
- m_enabled = value;
-
- // NOTE: no visual change
-}
-
-
-as_value
-Button::enabled_getset(const fn_call& fn)
-{
- boost::intrusive_ptr<Button> ptr = ensureType<Button>(fn.this_ptr);
-
- as_value rv;
-
- if ( fn.nargs == 0 ) // getter
- {
- rv = as_value(ptr->get_enabled());
- }
- else // setter
- {
- ptr->set_enabled(fn.arg(0).to_bool());
- }
- return rv;
-}
-
+Button::isEnabled()
+{
+ as_value enabled;
+ if (!get_member(NSV::PROP_ENABLED, &enabled)) return false;
+
+ return enabled.to_bool();
+}
// called from Key listener only
@@ -417,7 +390,7 @@
// Return the topmost entity that the given point covers. NULL if none.
// I.e. check against ourself.
{
- if ( (!isVisible()) || (!get_enabled()))
+ if (!isVisible() || !isEnabled())
{
return 0;
}
@@ -464,7 +437,7 @@
parent->getWorldMatrix().transform(wp);
}
- for (CharsVect::const_iterator i = _hitCharacters.begin(),
+ for (DisplayObjects::const_iterator i = _hitCharacters.begin(),
e = _hitCharacters.end(); i !=e; ++i)
{
if ((*i)->pointInVisibleShape(wp.x, wp.y))
@@ -640,15 +613,14 @@
// Copy all the characters to the new list, skipping NULL
// characters, optionally including unloaded characters.
- std::remove_copy_if(_stateCharacters.begin(),
- _stateCharacters.end(),
+ std::remove_copy_if(_stateCharacters.begin(), _stateCharacters.end(),
std::back_inserter(list),
boost::bind(&isCharacterNull, _1, includeUnloaded));
}
void
-Button::get_active_records(RecSet& list, MouseState state)
+Button::get_active_records(ActiveRecords& list, MouseState state)
{
list.clear();
@@ -705,7 +677,7 @@
#endif
// Get new state records
- RecSet newChars;
+ ActiveRecords newChars;
get_active_records(newChars, new_state);
// For each possible record, check if it should still be there
@@ -773,7 +745,9 @@
ch->set_cxform(cx);
ch->set_depth(ch_depth);
assert(ch->get_parent() == this);
- assert(ch->get_name().empty()); // no way to specify a name
for button chars anyway...
+
+ // no way to specify a name for button chars anyway...
+ assert(ch->get_name().empty());
if ( ch->wantsInstanceName() )
{
@@ -874,13 +848,13 @@
Button::getChildByName(const std::string& name)
{
// Get all currently active characters, including unloaded
- CharsVect actChars;
+ DisplayObjects actChars;
getActiveCharacters(actChars, true);
// Lower depth first for duplicated names, so we sort
std::sort(actChars.begin(), actChars.end(), charDepthLessThen);
- for (CharsVect::iterator i=actChars.begin(), e=actChars.end(); i!=e; ++i)
+ for (DisplayObjects::iterator i=actChars.begin(), e=actChars.end(); i!=e;
++i)
{
character* const child = *i;
@@ -910,14 +884,12 @@
saveOriginalTarget(); // for soft refs
- // Register this button instance as a live character
- // do we need this???
- //_vm.getRoot().addLiveChar(this);
+ // Don't register this button instance as a live character.
// Instantiate the hit characters
- RecSet hitChars;
+ ActiveRecords hitChars;
get_active_records(hitChars, HIT);
- for (RecSet::iterator i=hitChars.begin(),e=hitChars.end(); i!=e; ++i)
+ for (ActiveRecords::iterator i=hitChars.begin(),e=hitChars.end(); i!=e;
++i)
{
SWF::ButtonRecord& bdef = _def.buttonRecords()[*i];
@@ -926,7 +898,8 @@
int ch_depth = bdef.m_button_layer+character::staticDepthOffset+1;
int ch_id = bdef.m_character_id;
- character* ch = bdef.m_character_def->create_character_instance(this,
ch_id);
+ character* ch =
+ bdef.m_character_def->create_character_instance(this, ch_id);
ch->setMatrix(mat, true); // update caches
ch->set_cxform(cx); // TODO: who cares about color ?
ch->set_depth(ch_depth); // TODO: check if we care about depth, and
why ...
@@ -944,10 +917,10 @@
_stateCharacters.resize(_def.buttonRecords().size());
// Instantiate the default state characters
- RecSet upChars;
+ ActiveRecords upChars;
get_active_records(upChars, UP);
- //log_debug("At StagePlacementCallback, button %s got %d active chars for
state UP", getTarget(), upChars.size());
- for (RecSet::iterator i=upChars.begin(),e=upChars.end(); i!=e; ++i)
+
+ for (ActiveRecords::iterator i=upChars.begin(),e=upChars.end(); i!=e; ++i)
{
int rno = *i;
SWF::ButtonRecord& bdef = _def.buttonRecords()[rno];
@@ -987,7 +960,7 @@
_def.setReachable();
// Mark state characters as reachable
- for (CharsVect::const_iterator i=_stateCharacters.begin(),
e=_stateCharacters.end();
+ for (DisplayObjects::const_iterator i=_stateCharacters.begin(),
e=_stateCharacters.end();
i!=e; ++i)
{
character* ch = *i;
@@ -995,8 +968,8 @@
}
// Mark hit characters as reachable
- for (CharsVect::const_iterator i=_hitCharacters.begin(),
e=_hitCharacters.end();
- i!=e; ++i)
+ for (DisplayObjects::const_iterator i = _hitCharacters.begin(),
+ e=_hitCharacters.end(); i != e; ++i)
{
character* ch = *i;
assert ( ch );
@@ -1014,15 +987,15 @@
bool childsHaveUnload = false;
- // We need to unload all childs, or the global instance list will keep
growing forever !
- //std::for_each(_stateCharacters.begin(), _stateCharacters.end(),
boost::bind(&character::unload, _1));
- for (CharsVect::iterator i=_stateCharacters.begin(),
e=_stateCharacters.end(); i!=e; ++i)
+ // We need to unload all children, or the global instance list
+ // will keep growing forever !
+ for (DisplayObjects::iterator i = _stateCharacters.begin(),
+ e = _stateCharacters.end(); i != e; ++i)
{
character* ch = *i;
if ( ! ch ) continue;
if ( ch->isUnloaded() ) continue;
if ( ch->unload() ) childsHaveUnload = true;
- //log_debug("Button child %s (%s) unloaded", ch->getTarget(),
typeName(*ch));
}
// NOTE: we don't need to ::unload or ::destroy here
@@ -1041,15 +1014,15 @@
void
Button::destroy()
{
- //log_debug("Button %s being destroyed", getTarget());
- for (CharsVect::iterator i=_stateCharacters.begin(),
e=_stateCharacters.end(); i!=e; ++i)
+ for (DisplayObjects::iterator i = _stateCharacters.begin(),
+ e=_stateCharacters.end(); i != e; ++i)
{
character* ch = *i;
if ( ! ch ) continue;
if ( ch->isDestroyed() ) continue;
ch->destroy();
- *i = NULL;
+ *i = 0;
}
// NOTE: we don't need to ::unload or ::destroy here
@@ -1065,100 +1038,92 @@
bool
Button::get_member(string_table::key name_key, as_value* val,
- string_table::key nsname)
+ string_table::key nsname)
{
- // FIXME: use addProperty interface for these !!
- // TODO: or at least have a character:: protected method take
- // care of these ?
- // Duplicates code in character::get_path_element_character too..
- //
- if (name_key == NSV::PROP_uROOT)
- {
- // getAsRoot() will take care of _lockroot
- val->set_as_object( const_cast<MovieClip*>( getAsRoot() ) );
- return true;
- }
-
- // NOTE: availability of _global doesn't depend on VM version
- // but on actual movie version. Example: if an SWF4 loads
- // an SWF6 (to, say, _level2), _global will be unavailable
- // to the SWF4 code but available to the SWF6 one.
- //
- if ( getSWFVersion() > 5 && name_key == NSV::PROP_uGLOBAL ) // see
MovieClip.as
- {
- // The "_global" ref was added in SWF6
- val->set_as_object( _vm.getGlobal() );
- return true;
- }
-
- const std::string& name = _vm.getStringTable().value(name_key);
-
- movie_root& mr = _vm.getRoot();
- unsigned int levelno;
- if ( mr.isLevelTarget(name, levelno) )
- {
- movie_instance* mo = mr.getLevel(levelno).get();
- if ( mo )
- {
- val->set_as_object(mo);
- return true;
- }
- else
- {
- return false;
- }
- }
-
- // TOCHECK : Try object members, BEFORE display list items
- //
- if (as_object::get_member(name_key, val, nsname))
- {
-
-// ... trying to be useful to Flash coders ...
-// The check should actually be performed before any return
-// prior to the one due to a match in the DisplayList.
-// It's off by default anyway, so not a big deal.
-// See bug #18457
+ // FIXME: use addProperty interface for these !!
+ // TODO: or at least have a character:: protected method take
+ // care of these ?
+ // Duplicates code in character::get_path_element_character too..
+ //
+ if (name_key == NSV::PROP_uROOT) {
+ // getAsRoot() will take care of _lockroot
+ val->set_as_object( const_cast<MovieClip*>( getAsRoot() ) );
+ return true;
+ }
+
+ // NOTE: availability of _global doesn't depend on VM version
+ // but on actual movie version. Example: if an SWF4 loads
+ // an SWF6 (to, say, _level2), _global will be unavailable
+ // to the SWF4 code but available to the SWF6 one.
+ //
+ // see MovieClip.as
+ if ( getSWFVersion() > 5 && name_key == NSV::PROP_uGLOBAL ) {
+ // The "_global" ref was added in SWF6
+ val->set_as_object( _vm.getGlobal() );
+ return true;
+ }
+
+ const std::string& name = _vm.getStringTable().value(name_key);
+
+ movie_root& mr = _vm.getRoot();
+ unsigned int levelno;
+ if ( mr.isLevelTarget(name, levelno) ) {
+ movie_instance* mo = mr.getLevel(levelno).get();
+ if ( mo ) {
+ val->set_as_object(mo);
+ return true;
+ }
+ else {
+ return false;
+ }
+ }
+
+ // TOCHECK : Try object members, BEFORE display list items
+ //
+ if (as_object::get_member(name_key, val, nsname))
+ {
+
+ // ... trying to be useful to Flash coders ...
+ // The check should actually be performed before any return
+ // prior to the one due to a match in the DisplayList.
+ // It's off by default anyway, so not a big deal.
+ // See bug #18457
#define CHECK_FOR_NAME_CLASHES 1
#ifdef CHECK_FOR_NAME_CLASHES
- IF_VERBOSE_ASCODING_ERRORS(
- if ( getChildByName(name) )
- {
- log_aserror(_("A button member (%s) clashes with "
- "the name of an existing character "
- "in its display list. "
- "The member will hide the "
- "character"), name);
- }
- );
+ IF_VERBOSE_ASCODING_ERRORS(
+ if ( getChildByName(name) )
+ {
+ log_aserror(_("A button member (%s) clashes with "
+ "the name of an existing character "
+ "in its display list. "
+ "The member will hide the "
+ "character"), name);
+ }
+ );
#endif
- return true;
- }
-
-
- // Try items on our display list.
- character* ch = getChildByName(name);
-
- if (ch)
- {
- // Found object.
-
- // If the object is an ActionScript referenciable one we
- // return it, otherwise we return ourselves
- if ( ch->isActionScriptReferenceable() )
- {
- val->set_as_object(ch);
- }
- else
- {
- val->set_as_object(this);
- }
-
- return true;
- }
-
- return false;
+ return true;
+ }
+
+ // Try items on our display list.
+ character* ch = getChildByName(name);
+
+ if (ch) {
+ // Found object.
+
+ // If the object is an ActionScript referenciable one we
+ // return it, otherwise we return ourselves
+ if ( ch->isActionScriptReferenceable() ) {
+ val->set_as_object(ch);
+ }
+ else {
+ val->set_as_object(this);
+ }
+
+ return true;
+ }
+
+ return false;
}
@@ -1190,7 +1155,7 @@
}
void
-button_class_init(as_object& global)
+Button::init(as_object& global)
{
// This is going to be the global Button "class"/"function"
static boost::intrusive_ptr<builtin_function> cl=NULL;
=== modified file 'libcore/Button.h'
--- a/libcore/Button.h 2008-12-01 15:16:02 +0000
+++ b/libcore/Button.h 2008-12-11 13:07:41 +0000
@@ -45,8 +45,10 @@
{
public:
- typedef std::vector< character* > CharsVect;
- typedef std::set<int> RecSet;
+ typedef std::vector< character* > DisplayObjects;
+
+ /// A container for holding the id of active button records.
+ typedef std::set<int> ActiveRecords;
enum mouse_flags
{
@@ -77,6 +79,9 @@
~Button();
+ /// Initialize the global Button class
+ static void init(as_object& global);
+
// See dox in as_object.h
bool get_member(string_table::key name, as_value* val,
string_table::key nsname = 0);
@@ -124,10 +129,7 @@
// See dox in character.h
bool pointInShape(boost::int32_t x, boost::int32_t y) const;
- static as_value enabled_getset(const fn_call& fn);
-
- bool get_enabled();
- void set_enabled(bool value);
+ bool isEnabled();
/// Receive a stage placement notification
//
@@ -166,9 +168,9 @@
SWF::DefineButtonTag& _def;
- CharsVect _stateCharacters;
+ DisplayObjects _stateCharacters;
- CharsVect _hitCharacters;
+ DisplayObjects _hitCharacters;
/// Returns all characters that are active based on the current state.
//
@@ -191,7 +193,8 @@
/// @param list The container to push unmodifiable characters into.
void getActiveCharacters(std::vector<const character*>& list) const;
- /// Returns all characters (record nums) that should be active on the
given state.
+ /// Returns all characters (record nums) that should be active on
+ /// the given state.
//
/// @param list
/// The set to push active characters record number into
@@ -199,7 +202,7 @@
/// @param state
/// The state we're interested in
///
- void get_active_records(RecSet& list, MouseState state);
+ void get_active_records(ActiveRecords& list, MouseState state);
/// Return any state character whose name matches the given string
//
@@ -216,13 +219,8 @@
/// the button definition this is an instance of.
int getSWFVersion() const;
- bool m_enabled;
-
};
-/// Initialize the global Button class
-void button_class_init(as_object& global);
-
} // end namespace gnash
=== modified file 'libcore/asobj/AsBroadcaster.cpp'
--- a/libcore/asobj/AsBroadcaster.cpp 2008-12-02 13:28:42 +0000
+++ b/libcore/asobj/AsBroadcaster.cpp 2008-12-11 11:34:15 +0000
@@ -30,10 +30,23 @@
#include "Object.h" // for getObjectInterface
#include "namedStrings.h"
-#include <boost/algorithm/string/case_conv.hpp> // for PROPNAME
-
namespace gnash {
+// Forward declarations.
+namespace {
+ as_value asbroadcaster_addListener(const fn_call& fn);
+ as_value asbroadcaster_removeListener(const fn_call& fn);
+ as_value asbroadcaster_broadcastMessage(const fn_call& fn);
+ as_value asbroadcaster_initialize(const fn_call& fn);
+ as_value asbroadcaster_ctor(const fn_call& fn);
+
+ as_object* getAsBroadcasterInterface();
+}
+
+
+/// Helper for notifying listeners
+namespace {
+
class BroadcasterVisitor
{
@@ -98,6 +111,11 @@
void reset() { _dispatched=0; }
};
+}
+
+/// AsBroadcaster class
+
+
void
AsBroadcaster::initialize(as_object& o)
{
@@ -114,7 +132,7 @@
}
o.set_member(NSV::PROP_BROADCAST_MESSAGE,
- new builtin_function(AsBroadcaster::broadcastMessage_method));
+ new builtin_function(asbroadcaster_broadcastMessage));
o.set_member(NSV::PROP_uLISTENERS, new Array_as());
@@ -129,8 +147,58 @@
#endif
}
+as_object*
+AsBroadcaster::getAsBroadcaster()
+{
+ VM& vm = VM::get();
+
+ static boost::intrusive_ptr<as_object> obj = NULL;
+ if ( ! obj )
+ {
+ obj = new builtin_function(asbroadcaster_ctor,
+ getAsBroadcasterInterface());
+ vm.addStatic(obj.get()); // correct ?
+
+ const int flags = as_prop_flags::dontEnum |
+ as_prop_flags::dontDelete |
+ as_prop_flags::readOnly |
+ as_prop_flags::onlySWF6Up;
+
+ // NOTE: we may add NSV::PROP_INITIALIZE, unavailable at
+ // time of writing. Anyway, since AsBroadcaster is the only
+ // class we know using an 'initialize' method we might as
+ // well save the string_table size in case we'll not load
+ // the class.
+ obj->init_member("initialize",
+ new builtin_function(asbroadcaster_initialize),
+ flags);
+ obj->init_member(NSV::PROP_ADD_LISTENER,
+ new builtin_function(asbroadcaster_addListener),
+ flags);
+ obj->init_member(NSV::PROP_REMOVE_LISTENER,
+ new builtin_function(asbroadcaster_removeListener),
+ flags);
+ obj->init_member(NSV::PROP_BROADCAST_MESSAGE,
+ new builtin_function(asbroadcaster_broadcastMessage),
+ flags);
+ }
+
+ return obj.get();
+}
+
+
+void
+AsBroadcaster_init(as_object& global)
+{
+ // _global.AsBroadcaster is NOT a class, but a simple object
+ global.init_member("AsBroadcaster", AsBroadcaster::getAsBroadcaster());
+}
+
+
+namespace {
+
as_value
-AsBroadcaster::initialize_method(const fn_call& fn)
+asbroadcaster_initialize(const fn_call& fn)
{
if ( fn.nargs < 1 )
{
@@ -166,9 +234,8 @@
return as_value();
}
-
as_value
-AsBroadcaster::addListener_method(const fn_call& fn)
+asbroadcaster_addListener(const fn_call& fn)
{
boost::intrusive_ptr<as_object> obj = fn.this_ptr;
@@ -225,13 +292,12 @@
listeners->push(newListener);
}
- //log_debug("%p.addListener(%s) TESTING", (void*)fn.this_ptr.get(),
fn.dump_args());
return as_value(true);
}
as_value
-AsBroadcaster::removeListener_method(const fn_call& fn)
+asbroadcaster_removeListener(const fn_call& fn)
{
boost::intrusive_ptr<as_object> obj = fn.this_ptr;
@@ -244,9 +310,8 @@
if (!obj->get_member(NSV::PROP_uLISTENERS, &listenersValue) )
{
IF_VERBOSE_ASCODING_ERRORS(
- log_aserror(_("%p.addListener(%s): this object has no
_listeners member"),
- (void*)fn.this_ptr.get(),
- fn.dump_args());
+ log_aserror(_("%p.addListener(%s): this object has no
_listeners "
+ "member"), (void*)fn.this_ptr.get(), fn.dump_args());
);
return as_value(false); // TODO: check this
}
@@ -255,9 +320,9 @@
if ( ! listenersValue.is_object() )
{
IF_VERBOSE_ASCODING_ERRORS(
- log_aserror(_("%p.addListener(%s): this object's _listener
isn't an object: %s"),
- (void*)fn.this_ptr.get(),
- fn.dump_args(), listenersValue);
+ log_aserror(_("%p.addListener(%s): this object's _listener
isn't "
+ "an object: %s"), (void*)fn.this_ptr.get(), fn.dump_args(),
+ listenersValue);
);
return as_value(false); // TODO: check this
}
@@ -268,22 +333,27 @@
as_value listenerToRemove; assert(listenerToRemove.is_undefined());
if ( fn.nargs ) listenerToRemove = fn.arg(0);
- boost::intrusive_ptr<Array_as> listeners =
boost::dynamic_pointer_cast<Array_as>(listenersObj);
+ boost::intrusive_ptr<Array_as> listeners =
+ boost::dynamic_pointer_cast<Array_as>(listenersObj);
if ( ! listeners )
{
IF_VERBOSE_ASCODING_ERRORS(
- log_aserror(_("%p.addListener(%s): this object's _listener
isn't an array: %s"),
- (void*)fn.this_ptr.get(),
- fn.dump_args(), listenersValue);
+ log_aserror(_("%p.addListener(%s): this object's _listener
isn't an "
+ "array: %s"), (void*)fn.this_ptr.get(), fn.dump_args(),
+ listenersValue);
);
// TODO: implement brute force scan of pseudo-array
- unsigned int length =
listenersObj->getMember(NSV::PROP_LENGTH).to_int();
+ unsigned int length =
+ listenersObj->getMember(NSV::PROP_LENGTH).to_int();
+
+ string_table& st = obj->getVM().getStringTable();
+
for (unsigned int i=0; i<length; ++i)
{
as_value iVal(i);
std::string n = iVal.to_string();
- as_value v =
listenersObj->getMember(VM::get().getStringTable().find(n));
+ as_value v = listenersObj->getMember(st.find(n));
if ( v.equals(listenerToRemove) )
{
listenersObj->callMethod(NSV::PROP_SPLICE,
iVal, as_value(1));
@@ -296,16 +366,19 @@
else
{
// Remove the first listener matching the new value
- // See
http://www.senocular.com/flash/tutorials/listenersasbroadcaster/?page=2
- // TODO: make this call as a normal (don't want to rely on
_listeners type at all)
+ // See http://www.senocular.com/flash/tutorials/
+ // listenersasbroadcaster/?page=2
+ // TODO: make this call as a normal (don't want to
+ // rely on _listeners type at all)
bool removed = listeners->removeFirst(listenerToRemove);
return as_value(removed);
}
}
+
as_value
-AsBroadcaster::broadcastMessage_method(const fn_call& fn)
+asbroadcaster_broadcastMessage(const fn_call& fn)
{
boost::intrusive_ptr<as_object> obj = fn.this_ptr;
@@ -318,9 +391,9 @@
if ( ! obj->get_member(NSV::PROP_uLISTENERS, &listenersValue) )
{
IF_VERBOSE_ASCODING_ERRORS(
- log_aserror(_("%p.addListener(%s): this object has no
_listeners member"),
- (void*)fn.this_ptr.get(),
- fn.dump_args());
+ log_aserror(_("%p.addListener(%s): this object has no "
+ "_listeners member"), (void*)fn.this_ptr.get(),
+ fn.dump_args());
);
return as_value(); // TODO: check this
}
@@ -329,28 +402,31 @@
if ( ! listenersValue.is_object() )
{
IF_VERBOSE_ASCODING_ERRORS(
- log_aserror(_("%p.addListener(%s): this object's _listener
isn't an object: %s"),
- (void*)fn.this_ptr.get(),
- fn.dump_args(), listenersValue);
- );
- return as_value(); // TODO: check this
- }
-
- boost::intrusive_ptr<Array_as> listeners =
boost::dynamic_pointer_cast<Array_as>(listenersValue.to_object());
- if ( ! listeners )
- {
- IF_VERBOSE_ASCODING_ERRORS(
- log_aserror(_("%p.addListener(%s): this object's _listener
isn't an array: %s"),
- (void*)fn.this_ptr.get(),
- fn.dump_args(), listenersValue);
- );
- return as_value(); // TODO: check this
- }
-
- if ( ! fn.nargs )
- {
- IF_VERBOSE_ASCODING_ERRORS(
- log_aserror("%p.broadcastMessage() needs an argument",
(void*)fn.this_ptr.get());
+ log_aserror(_("%p.addListener(%s): this object's _listener "
+ "isn't an object: %s"), (void*)fn.this_ptr.get(),
+ fn.dump_args(), listenersValue);
+ );
+ return as_value(); // TODO: check this
+ }
+
+ boost::intrusive_ptr<Array_as> listeners =
+ boost::dynamic_pointer_cast<Array_as>(listenersValue.to_object());
+
+ if ( ! listeners )
+ {
+ IF_VERBOSE_ASCODING_ERRORS(
+ log_aserror(_("%p.addListener(%s): this object's _listener "
+ "isn't an array: %s"), (void*)fn.this_ptr.get(),
+ fn.dump_args(), listenersValue);
+ );
+ return as_value(); // TODO: check this
+ }
+
+ if (!fn.nargs)
+ {
+ IF_VERBOSE_ASCODING_ERRORS(
+ log_aserror("%p.broadcastMessage() needs an argument",
+ (void*)fn.this_ptr.get());
);
return as_value();
}
@@ -360,14 +436,13 @@
unsigned int dispatched = visitor.eventsDispatched();
- //log_debug("AsBroadcaster.broadcastMessage() dispatched %u events",
dispatched);
-
if ( dispatched ) return as_value(true);
- else return as_value(); // undefined
+
+ return as_value();
}
-static as_object*
+as_object*
getAsBroadcasterInterface()
{
static boost::intrusive_ptr<as_object> o=NULL;
@@ -379,57 +454,13 @@
return o.get();
}
-static as_value
-AsBroadcaster_ctor(const fn_call& /*fn*/)
+as_value
+asbroadcaster_ctor(const fn_call& /*fn*/)
{
as_object* obj = new as_object(getAsBroadcasterInterface());
- return as_value(obj); // will keep alive
-}
-
-as_object*
-AsBroadcaster::getAsBroadcaster()
-{
- VM& vm = VM::get();
-
- static boost::intrusive_ptr<as_object> obj = NULL;
- if ( ! obj )
- {
- obj = new builtin_function(AsBroadcaster_ctor,
- getAsBroadcasterInterface());
- vm.addStatic(obj.get()); // correct ?
-
- const int flags = as_prop_flags::dontEnum |
- as_prop_flags::dontDelete |
- as_prop_flags::readOnly |
- as_prop_flags::onlySWF6Up;
-
- // NOTE: we may add NSV::PROP_INITIALIZE, unavailable at
- // time of writing. Anyway, since AsBroadcaster is the only
- // class we know using an 'initialize' method we might as
- // well save the string_table size in case we'll not load
- // the class.
- obj->init_member("initialize",
- new builtin_function(AsBroadcaster::initialize_method),
- flags);
- obj->init_member(NSV::PROP_ADD_LISTENER,
- new builtin_function(AsBroadcaster::addListener_method),
- flags);
- obj->init_member(NSV::PROP_REMOVE_LISTENER,
- new builtin_function(AsBroadcaster::removeListener_method),
- flags);
- obj->init_member(NSV::PROP_BROADCAST_MESSAGE,
- new builtin_function( AsBroadcaster::broadcastMessage_method),
- flags);
- }
-
- return obj.get();
-}
-
-void
-AsBroadcaster_init(as_object& global)
-{
- // _global.AsBroadcaster is NOT a class, but a simple object
- global.init_member("AsBroadcaster", AsBroadcaster::getAsBroadcaster());
-}
+ return as_value(obj);
+}
+
+} // anonymous namespace
} // end of gnash namespace
=== modified file 'libcore/asobj/AsBroadcaster.h'
--- a/libcore/asobj/AsBroadcaster.h 2008-12-11 08:18:23 +0000
+++ b/libcore/asobj/AsBroadcaster.h 2008-12-11 11:34:15 +0000
@@ -54,12 +54,6 @@
///
static as_object* getAsBroadcaster();
-private:
-
- static as_value addListener_method(const fn_call& fn);
- static as_value removeListener_method(const fn_call& fn);
- static as_value broadcastMessage_method(const fn_call& fn);
-
};
void AsBroadcaster_init(as_object& global);
=== modified file 'libcore/asobj/ClassHierarchy.cpp'
--- a/libcore/asobj/ClassHierarchy.cpp 2008-12-09 13:32:22 +0000
+++ b/libcore/asobj/ClassHierarchy.cpp 2008-12-11 13:07:41 +0000
@@ -293,7 +293,7 @@
{ textfield_class_init, NSV::CLASS_TEXT_FIELD, 0, NSV::NS_FLASH_TEXT, 3
},
{ math_class_init, NSV::CLASS_MATH, 0, NS_GLOBAL, 4 },
{ boolean_class_init, NSV::CLASS_BOOLEAN, NSV::CLASS_OBJECT, NS_GLOBAL,
5 },
- { button_class_init, NSV::CLASS_BUTTON, NSV::CLASS_OBJECT, NS_GLOBAL, 5
},
+ { Button::init, NSV::CLASS_BUTTON, NSV::CLASS_OBJECT, NS_GLOBAL, 5 },
{ color_class_init, NSV::CLASS_COLOR, NSV::CLASS_OBJECT, NS_GLOBAL, 5 },
{ selection_class_init, NSV::CLASS_SELECTION, NSV::CLASS_OBJECT,
NS_UNKNOWN, 5 },
{ sound_class_init, NSV::CLASS_SOUND, NSV::CLASS_OBJECT,
NSV::NS_FLASH_MEDIA, 5 },
=== modified file 'testsuite/actionscript.all/AsBroadcaster.as'
--- a/testsuite/actionscript.all/AsBroadcaster.as 2008-11-07 08:40:42
+0000
+++ b/testsuite/actionscript.all/AsBroadcaster.as 2008-12-11 11:34:15
+0000
@@ -79,6 +79,13 @@
check_equals(typeof(bcast.removeListener), 'function');
check_equals(typeof(bcast.broadcastMessage), 'function');
+bob = { _listeners:5, addListener:"string" };
+check_equals(bob._listeners, 5);
+check_equals(bob.addListener, "string");
+AsBroadcaster.initialize(bob);
+check_equals(typeof(bob._listeners), "object");
+check_equals(typeof(bob.addListener), "function");
+
//--------------------------------
// Some insane calls...
//--------------------------------
@@ -312,6 +319,6 @@
// See swfdec/test/trace/asbroadcaster-override.as for more info
//-----------------------------------------------------------------------------------
-check_totals(111);
+check_totals(115);
#endif // OUTPUT_VERSION < 6
=== modified file 'testsuite/misc-ming.all/ButtonEventsTest.c'
--- a/testsuite/misc-ming.all/ButtonEventsTest.c 2008-10-06 15:22:23
+0000
+++ b/testsuite/misc-ming.all/ButtonEventsTest.c 2008-12-11 12:23:46
+0000
@@ -731,9 +731,17 @@
{
add_actions(mo,
+ "check_equals(square1.button.enabled, true);"
+ "square1.button.enabled = 6;"
+ "check_equals(square1.button.enabled, 6);"
+ "square1.button.enabled = 'string';"
+ "check_equals(square1.button.enabled, 'string');"
+ "square1.button._visible = false;"
+ "check_equals(square1.button.enabled, 'string');"
+ "square1.button._visible = true;"
"square1.button.enabled = false;"
"stop();"
- "_root.totals(156);"
+ "_root.totals(160);"
"_root.note('-- Button disabled, try playing with it,
nothing should happen --');"
);
SWFMovie_nextFrame(mo); /* showFrame */
=== modified file 'testsuite/swfdec/Makefile.am'
--- a/testsuite/swfdec/Makefile.am 2008-10-30 16:46:00 +0000
+++ b/testsuite/swfdec/Makefile.am 2008-12-11 12:23:46 +0000
@@ -174,7 +174,7 @@
GNASH_GC_TRIGGER_THRESHOLD=0 GNASHRC=../gnashrc $(SHELL) $$i; \
done; \
fi; \
- echo "Number of discrepant lines (for information only): `LC_ALL=C
${EGREP} "^-\|^+" *.log | wc -l`"
+ echo "Number of discrepant lines (for information only): `LC_ALL=C grep
-e "^-\|^+" *.log | wc -l`"
site-update: site.exp
@rm -fr site.exp.bak
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] /srv/bzr/gnash/trunk r10409: Minor fix to Button properties, various AS tests.,
Benjamin Wolsey <=