[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] /srv/bzr/gnash/trunk r11551: More cleanup of properties.
From: |
Benjamin Wolsey |
Subject: |
[Gnash-commit] /srv/bzr/gnash/trunk r11551: More cleanup of properties. Drop button::get_member. |
Date: |
Wed, 07 Oct 2009 11:30:57 +0200 |
User-agent: |
Bazaar (1.16.1) |
------------------------------------------------------------
revno: 11551 [merge]
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Wed 2009-10-07 11:30:57 +0200
message:
More cleanup of properties. Drop button::get_member.
Move functions around.
modified:
libcore/Button.cpp
libcore/Button.h
libcore/DisplayObject.cpp
libcore/DisplayObject.h
libcore/MovieClip.cpp
libcore/MovieClip.h
libcore/as_value.cpp
libcore/as_value.h
libcore/asobj/Error_as.cpp
libcore/asobj/Namespace_as.cpp
libcore/asobj/QName_as.cpp
libcore/asobj/flash/external/ExternalInterface_as.cpp
libcore/asobj/flash/geom/ColorTransform_as.cpp
libcore/asobj/flash/geom/Matrix_as.cpp
libcore/asobj/flash/geom/Point_as.cpp
libcore/asobj/flash/geom/Rectangle_as.cpp
libcore/asobj/flash/geom/Transform_as.cpp
libcore/asobj/flash/net/FileReferenceList_as.cpp
libcore/asobj/flash/net/FileReference_as.cpp
libcore/asobj/flash/text/TextRenderer_as.cpp
libcore/movie_root.cpp
libcore/movie_root.h
libcore/vm/ASHandlers.cpp
libcore/vm/Machine.cpp
libcore/vm/VM.cpp
libcore/vm/VM.h
testsuite/actionscript.all/TextField.as
testsuite/misc-ming.all/ButtonPropertiesTest.c
testsuite/swfdec/PASSING
=== modified file 'libcore/Button.cpp'
--- a/libcore/Button.cpp 2009-10-06 08:10:12 +0000
+++ b/libcore/Button.cpp 2009-10-07 07:01:31 +0000
@@ -504,18 +504,16 @@
const SWF::DefineButtonSoundTag::ButtonSound& bs =
_def->buttonSound(bi);
- // DisplayObject zero is considered as null DisplayObject
+ // character zero is considered as null character
if (!bs.soundID) break;
// No actual sound ?
if (!bs.sample) break;
- if (bs.soundInfo.stopPlayback)
- {
+ if (bs.soundInfo.stopPlayback) {
s->stop_sound(bs.sample->m_sound_handler_id);
}
- else
- {
+ else {
const SWF::SoundInfoRecord& sinfo = bs.soundInfo;
const sound::SoundEnvelopes* env =
@@ -549,9 +547,7 @@
// check for built-in event handler.
std::auto_ptr<ExecutableCode> code ( get_event_handler(event) );
- if ( code.get() )
- {
- //log_debug(_("Got statically-defined handler for event: %s"), event);
+ if (code.get()) {
mr.pushAction(code, movie_root::apDOACTION);
}
@@ -876,21 +872,16 @@
_def->setReachable();
// Mark state DisplayObjects as reachable
- for (DisplayObjects::const_iterator i=_stateCharacters.begin(),
e=_stateCharacters.end();
- i!=e; ++i)
+ for (DisplayObjects::const_iterator i = _stateCharacters.begin(),
+ e = _stateCharacters.end(); i != e; ++i)
{
DisplayObject* ch = *i;
- if ( ch ) ch->setReachable();
+ if (ch) ch->setReachable();
}
// Mark hit DisplayObjects as reachable
- for (DisplayObjects::const_iterator i = _hitCharacters.begin(),
- e=_hitCharacters.end(); i != e; ++i)
- {
- DisplayObject* ch = *i;
- assert ( ch );
- ch->setReachable();
- }
+ std::for_each(_hitCharacters.begin(), _hitCharacters.end(),
+ std::mem_fun(&as_object::setReachable));
// DisplayObject class members
markDisplayObjectReachable();
@@ -909,9 +900,8 @@
e = _stateCharacters.end(); i != e; ++i)
{
DisplayObject* ch = *i;
- if ( ! ch ) continue;
- if ( ch->unloaded() ) continue;
- if ( ch->unload() ) childsHaveUnload = true;
+ if (!ch || ch->unloaded()) continue;
+ if (ch->unload()) childsHaveUnload = true;
}
// NOTE: we don't need to ::unload or ::destroy here
@@ -932,13 +922,10 @@
{
for (DisplayObjects::iterator i = _stateCharacters.begin(),
- e=_stateCharacters.end(); i != e; ++i)
- {
+ e=_stateCharacters.end(); i != e; ++i) {
DisplayObject* ch = *i;
- if ( ! ch ) continue;
- if ( ch->isDestroyed() ) continue;
+ if (!ch || ch->isDestroyed()) continue;
ch->destroy();
- *i = 0;
}
// NOTE: we don't need to ::unload or ::destroy here
@@ -952,79 +939,6 @@
DisplayObject::destroy();
}
-bool
-Button::get_member(string_table::key name_key, as_value* val,
- string_table::key nsname)
-{
- // FIXME: use addProperty interface for these !!
- // TODO: or at least have a DisplayObject:: protected method take
- // care of these ?
- // Duplicates code in DisplayObject::getPathElementSeparator too..
- //
- if (name_key == NSV::PROP_uROOT) {
- // getAsRoot() will take care of _lockroot
- val->set_as_object(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 (getMovieVersion() > 5 && name_key == NSV::PROP_uGLOBAL ) {
- // The "_global" ref was added in SWF6
- val->set_as_object(getGlobal(*this));
- return true;
- }
-
- const std::string& name = getStringTable(*this).value(name_key);
-
- movie_root& mr = getRoot(*this);
- unsigned int levelno;
- if ( mr.isLevelTarget(name, levelno) ) {
- Movie* 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 DisplayObject "
- "in its display list. "
- "The member will hide the "
- "DisplayObject"), name);
- }
- );
-#endif
-
- return true;
- }
-
- return false;
-
-}
-
int
Button::getMovieVersion() const
{
@@ -1107,7 +1021,7 @@
case MOUSESTATE_DOWN: return "DOWN";
case MOUSESTATE_OVER: return "OVER";
case MOUSESTATE_HIT: return "HIT";
- default: return "UNKNOWN (error?)";
+ default: std::abort();
}
}
=== modified file 'libcore/Button.h'
--- a/libcore/Button.h 2009-10-01 13:19:43 +0000
+++ b/libcore/Button.h 2009-10-06 14:18:18 +0000
@@ -77,10 +77,6 @@
static const char* mouseStateName(MouseState s);
- // See dox in as_object.h
- bool get_member(string_table::key name, as_value* val,
- string_table::key nsname = 0);
-
bool mouseEnabled() const { return true; }
virtual bool trackAsMenu();
=== modified file 'libcore/DisplayObject.cpp'
--- a/libcore/DisplayObject.cpp 2009-10-04 09:38:44 +0000
+++ b/libcore/DisplayObject.cpp 2009-10-07 07:01:31 +0000
@@ -74,9 +74,6 @@
const int DisplayObject::removedDepthOffset;
const int DisplayObject::noClipDepthValue;
-// Initialize unnamed instance count
-unsigned int DisplayObject::_lastUnnamedInstanceNum = 0;
-
DisplayObject::DisplayObject(DisplayObject* parent, int id)
:
m_parent(parent),
@@ -106,12 +103,12 @@
setDisplayObject();
}
-/*protected static*/
std::string
DisplayObject::getNextUnnamedInstanceName()
{
- std::stringstream ss;
- ss << "instance" << ++_lastUnnamedInstanceNum;
+ movie_root& mr = getRoot(*this);
+ std::ostringstream ss;
+ ss << "instance" << mr.nextUnnamedInstance();
return ss.str();
}
@@ -933,22 +930,49 @@
getDisplayObjectProperty(as_object& obj, string_table::key key,
as_value& val)
{
+
+ DisplayObject& o = static_cast<DisplayObject&>(obj);
+
+ // These properties have normal case-sensitivity.
+ // They are tested to exist for TextField, MovieClip, and Button
+ // but do not belong to the inheritance chain.
+ switch (key)
+ {
+ default:
+ break;
+ case NSV::PROP_uROOT:
+ if (getSWFVersion(o) < 5) break;
+ val = o.getAsRoot();
+ return true;
+ case NSV::PROP_uGLOBAL:
+ if (getSWFVersion(o) < 6) break;
+ val = getGlobal(o);
+ return true;
+ }
+
+ string_table& st = getStringTable(obj);
+ const std::string& propname = st.value(key);
+
+ // Check _level0.._level9
+ movie_root& mr = getRoot(o);
+ unsigned int levelno;
+ if (mr.isLevelTarget(propname, levelno)) {
+ Movie* mo = mr.getLevel(levelno).get();
+ if (mo) {
+ val = mo;
+ return true;
+ }
+ return false;
+ }
const Getters& getters = displayObjectGetters();
- // TODO: _root and _global also seem to be magic properties, but are
- // case sensitive in version 7 and above
-
// These magic properties are case insensitive in all versions!
- string_table& st = getStringTable(obj);
- const std::string& propname = st.value(key);
const string_table::key noCaseKey =
st.find(boost::to_lower_copy(propname));
Getters::const_iterator it = getters.find(noCaseKey);
if (it == getters.end()) return false;
- DisplayObject& o = static_cast<DisplayObject&>(obj);
-
val = (*it->second)(o);
return true;
}
@@ -961,11 +985,6 @@
const Setters& setters = displayObjectSetters();
- // TODO: _root and _global also seem to be magic properties, but are
- // case sensitive in version 7 and above. They are tested to exist for
- // TextField, MovieClip, and Button but do not belong to the
- // inheritance chain.
-
// These magic properties are case insensitive in all versions!
string_table& st = getStringTable(obj);
const std::string& propname = st.value(key);
=== modified file 'libcore/DisplayObject.h'
--- a/libcore/DisplayObject.h 2009-10-01 13:19:43 +0000
+++ b/libcore/DisplayObject.h 2009-10-07 07:01:31 +0000
@@ -346,7 +346,7 @@
{
// TODO: fix this !
log_error("Our mask maskee is not us");
- return NULL; // for correctness;
+ return NULL;
}
return _mask;
}
@@ -698,7 +698,7 @@
/// clear_invalidated() is called in between.
///
/// NOTE: Marking a DisplayObject as invalidated automatically marks
- /// it's parent as being invalidated.
+ /// its parent as being invalidated.
///
/// @see \ref region_update
///
@@ -715,7 +715,7 @@
/// Called by a child to signalize it has changed visibily. The
/// difference to set_invalidated() is that *this* DisplayObject does
/// not need to redraw itself completely. This function will
- /// recursively inform all it's parents of the change.
+ /// recursively inform all its parents of the change.
void set_child_invalidated();
@@ -878,7 +878,7 @@
#endif
/// Used to assign a name to unnamed instances
- static std::string getNextUnnamedInstanceName();
+ std::string getNextUnnamedInstanceName();
enum BlendMode
{
@@ -1088,9 +1088,6 @@
int m_clip_depth;
Events _event_handlers;
- /// Used to assign a name to unnamed instances
- static unsigned int _lastUnnamedInstanceNum;
-
/// Set to yes when this instance has been unloaded
bool _unloaded;
=== modified file 'libcore/MovieClip.cpp'
--- a/libcore/MovieClip.cpp 2009-10-01 13:19:43 +0000
+++ b/libcore/MovieClip.cpp 2009-10-07 07:01:18 +0000
@@ -493,46 +493,7 @@
MovieClip::get_member(string_table::key name_key, as_value* val,
string_table::key nsname)
{
- // FIXME: use addProperty interface for these !!
- // TODO: or at least have a DisplayObject protected method take
- // care of these ?
- // Duplicates code in DisplayObject::getPathElementSeparator too.
- if (getMovieVersion() > 4 && name_key == NSV::PROP_uROOT)
- {
- // getAsRoot() will take care of _lockroot
- val->set_as_object(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 (getMovieVersion() > 5 && name_key == NSV::PROP_uGLOBAL)
- {
- // The "_global" ref was added in SWF6
- val->set_as_object(getGlobal(*this));
- return true;
- }
-
- const std::string& name = getStringTable(*this).value(name_key);
-
- movie_root& mr = getRoot(*this);
- unsigned int levelno;
- if ( mr.isLevelTarget(name, levelno) )
- {
- Movie* mo = mr.getLevel(levelno).get();
- if ( mo )
- {
- val->set_as_object(mo);
- return true;
- }
- else
- {
- return false;
- }
- }
+
// Own members take precendence over display list items
// (see testcase VarAndCharClash.swf in testsuite/misc-ming.all)
@@ -549,6 +510,7 @@
return true;
}
+ const std::string& name = getStringTable(*this).value(name_key);
if (getDisplayObjectProperty(*this, name_key, *val)) return true;
// Try items on our display list.
@@ -1552,14 +1514,6 @@
use_old_cxform, use_old_matrix);
}
-int
-MovieClip::get_id_at_depth(int depth)
-{
- DisplayObject* ch = _displayList.getDisplayObjectAtDepth(depth);
- if ( ! ch ) return -1;
- return ch->get_id();
-}
-
void
MovieClip::increment_frame_and_check_for_loop()
{
=== modified file 'libcore/MovieClip.h'
--- a/libcore/MovieClip.h 2009-10-01 13:19:43 +0000
+++ b/libcore/MovieClip.h 2009-10-07 07:01:18 +0000
@@ -479,11 +479,6 @@
/// Execute a single action buffer (DOACTION block)
void execute_action(const action_buffer& ab);
- /// For debugging -- return the id of the DisplayObject
- /// at the specified depth.
- /// Return -1 if nobody's home.
- int get_id_at_depth(int depth);
-
MovieClip* to_movie () { return this; }
/// The various methods for sending data in requests.
=== modified file 'libcore/as_value.cpp'
--- a/libcore/as_value.cpp 2009-10-07 08:40:42 +0000
+++ b/libcore/as_value.cpp 2009-10-07 09:30:57 +0000
@@ -1898,102 +1898,6 @@
}
}
-void
-newAdd(as_value& left, const as_value& right, VM& vm)
-{
- // We can't change the original value.
- as_value r(right);
-
- // The order of the operations is important: right is converted to
- // primitive before left.
-
- try { r = r.to_primitive(); }
- catch (ActionTypeError& e)
- {
- log_debug(_("%s.to_primitive() threw an error during "
- "ActionNewAdd"), r);
- }
-
- try { left = left.to_primitive(); }
- catch (ActionTypeError& e)
- {
- log_debug(_("%s.to_primitive() threw an error during "
- "ActionNewAdd"), left);
- }
-
-#if GNASH_DEBUG
- log_debug(_("(%s + %s) [primitive conversion done]"), left, r);
-#endif
-
- if (left.is_string() || r.is_string()) {
-
- // use string semantic
- const int version = vm.getSWFVersion();
- convertToString(left, vm);
- left.string_concat(r.to_string_versioned(version));
- return;
- }
-
- // Otherwise use numeric semantic
- const double v1num = left.to_number();
- const double v2num = r.to_number();
- left.set_double(v2num + v1num);
-
-}
-
-as_value
-as_value::newLessThan(const as_value& op2_in) const
-{
- const as_value& op1_in = *this;
-
- as_value operand1;
- as_value operand2;
-
- try { operand1 = op1_in.to_primitive(); }
- catch (ActionTypeError& e)
- {
- log_debug("%s.to_primitive() threw an error during ActionNewLessThen",
- op1_in);
- }
-
- try { operand2 = op2_in.to_primitive(); }
- catch (ActionTypeError& e)
- {
- log_debug("%s.to_primitive() threw an error during ActionNewLessThen",
- op2_in);
- }
-
- as_value ret;
-
- if ( operand1.is_string() && operand2.is_string() )
- {
- ret.set_bool(operand1.to_string() < operand2.to_string());
- }
- else
- {
- const double op1 = operand1.to_number();
- const double op2 = operand2.to_number();
-
- if ( isNaN(op1) || isNaN(op2) )
- {
- ret.set_undefined();
- }
- else
- {
- ret.set_bool(op1 < op2);
- }
- }
- return ret;
-}
-
-void
-subtract(as_value& left, const as_value& right, VM& /*vm*/)
-{
- const double operand2 = right.to_number();
- const double operand1 = left.to_number();
- left.set_double(operand1 - operand2);
-}
-
static boost::uint16_t
readNetworkShort(const boost::uint8_t* buf) {
=== modified file 'libcore/as_value.h'
--- a/libcore/as_value.h 2009-10-04 19:40:47 +0000
+++ b/libcore/as_value.h 2009-10-07 07:46:44 +0000
@@ -584,10 +584,6 @@
/// Sets this value to this string plus the given string.
void string_concat(const std::string& str);
- /// Equivalent of ActionNewLessThan
- as_value newLessThan(const as_value& op2_in) const;
-
-
/// Set any object value as reachable (for the GC)
//
/// Object values are values stored by pointer (objects and functions)
@@ -675,17 +671,6 @@
};
-/// Carry out ActionNewAdd
-//
-/// @param left The as_value to add to.
-/// @param right The as_value to add.
-/// @param vm The VM executing the operation.
-//
-/// TODO: Consider whether it would be better to pass something
-/// other than the VM. But it is a VM operation, so it
-/// is logically sound.
-void newAdd(as_value& left, const as_value& right, VM& vm);
-
/// Force type to number.
as_value& convertToNumber(as_value& v, VM& vm);
@@ -695,13 +680,6 @@
/// Force type to bool.
as_value& convertToBoolean(as_value& v, VM& vm);
-/// Carry out ActionSubtract
-//
-/// @param left The as_value to subtract from.
-/// @param right The as_value to subtract.
-/// @param vm The VM executing the operation.
-void subtract(as_value& left, const as_value& right, VM& vm);
-
inline std::ostream& operator<< (std::ostream& os, const as_value& v) {
return os << v.toDebugString();
}
=== modified file 'libcore/asobj/Error_as.cpp'
--- a/libcore/asobj/Error_as.cpp 2009-08-26 14:29:24 +0000
+++ b/libcore/asobj/Error_as.cpp 2009-10-07 06:18:09 +0000
@@ -30,7 +30,7 @@
#include "builtin_function.h" // need builtin_function
#include "GnashException.h" // for ActionException
#include "Object.h" // for AS inheritance
-#include "VM.h" // for addStatics
+#include "VM.h"
#include <sstream>
=== modified file 'libcore/asobj/Namespace_as.cpp'
--- a/libcore/asobj/Namespace_as.cpp 2009-07-29 05:40:20 +0000
+++ b/libcore/asobj/Namespace_as.cpp 2009-10-07 06:18:09 +0000
@@ -45,52 +45,17 @@
void attachNamespaceInterface(as_object& o);
}
-
-class Namespace_as : public as_object
-{
-
-public:
-
- Namespace_as()
- :
- as_object(getNamespaceInterface())
- {}
-
-};
-
-
// extern
void
namespace_class_init(as_object& where, const ObjectURI& uri)
{
- boost::intrusive_ptr<as_object> cl;
-
- Global_as* gl = getGlobal(where);
- as_object* proto = getNamespaceInterface();
- cl = gl->createClass(&namespace_ctor, proto);
-
- where.init_member(getName(uri), cl.get(), as_object::DefaultFlags,
- getNamespace(uri));
+ registerBuiltinClass(where, namespace_ctor, attachNamespaceInterface,
+ 0, uri);
}
namespace {
-as_object*
-getNamespaceInterface()
-{
- static boost::intrusive_ptr<as_object> o;
-
- if (!o) {
- o = new as_object(getObjectInterface());
- VM::get().addStatic(o.get());
- attachNamespaceInterface(*o);
- }
-
- return o.get();
-}
-
-
void
attachNamespaceInterface(as_object& o)
{
@@ -116,9 +81,9 @@
as_value
namespace_ctor(const fn_call& /*fn*/)
{
+ // TODO: probably needs Relay.
log_unimpl("Namespace");
- boost::intrusive_ptr<as_object> ns = new Namespace_as;
- return as_value(ns.get());
+ return as_value();
}
} // anonymous namespace
=== modified file 'libcore/asobj/QName_as.cpp'
--- a/libcore/asobj/QName_as.cpp 2009-07-29 05:40:20 +0000
+++ b/libcore/asobj/QName_as.cpp 2009-10-07 06:18:09 +0000
@@ -62,33 +62,18 @@
void
qname_class_init(as_object& where, const ObjectURI& uri)
{
- boost::intrusive_ptr<as_object> cl;
Global_as* gl = getGlobal(where);
- as_object* proto = getQNameInterface();
- cl = gl->createClass(&qname_ctor, proto);
+ as_object* proto = gl->createObject();
+ as_object* cl = gl->createClass(&qname_ctor, proto);
- where.init_member(getName(uri), cl.get(), as_object::DefaultFlags,
+ where.init_member(getName(uri), cl, as_object::DefaultFlags,
getNamespace(uri));
}
namespace {
-as_object*
-getQNameInterface()
-{
- static boost::intrusive_ptr<as_object> o;
-
- if (!o) {
- o = new as_object(getObjectInterface());
- VM::get().addStatic(o.get());
- }
-
- return o.get();
-}
-
-
void
attachQNameInterface(as_object& o)
{
@@ -111,11 +96,11 @@
}
as_value
-qname_ctor(const fn_call& /*fn*/)
+qname_ctor(const fn_call& fn)
{
- boost::intrusive_ptr<as_object> ns = new QName_as;
- attachQNameInterface(*ns);
- return as_value(ns.get());
+ as_object* obj = ensureType<as_object>(fn.this_ptr).get();
+ attachQNameInterface(*obj);
+ return as_value();
}
} // anonymous namespace
=== modified file 'libcore/asobj/flash/external/ExternalInterface_as.cpp'
--- a/libcore/asobj/flash/external/ExternalInterface_as.cpp 2009-08-27
06:30:46 +0000
+++ b/libcore/asobj/flash/external/ExternalInterface_as.cpp 2009-10-07
05:53:36 +0000
@@ -30,7 +30,7 @@
#include "builtin_function.h" // need builtin_function
#include "GnashException.h" // for ActionException
#include "Object.h" // for AS inheritance
-#include "VM.h" // for addStatics
+#include "VM.h"
#include <sstream>
=== modified file 'libcore/asobj/flash/geom/ColorTransform_as.cpp'
--- a/libcore/asobj/flash/geom/ColorTransform_as.cpp 2009-08-27 08:15:33
+0000
+++ b/libcore/asobj/flash/geom/ColorTransform_as.cpp 2009-10-07 05:52:30
+0000
@@ -30,7 +30,7 @@
#include "builtin_function.h"
#include "NativeFunction.h"
#include "Object.h" // for AS inheritance
-#include "VM.h" // for addStatics
+#include "VM.h"
#include <sstream>
=== modified file 'libcore/asobj/flash/geom/Matrix_as.cpp'
--- a/libcore/asobj/flash/geom/Matrix_as.cpp 2009-10-04 11:00:36 +0000
+++ b/libcore/asobj/flash/geom/Matrix_as.cpp 2009-10-07 05:52:30 +0000
@@ -26,7 +26,7 @@
#include "builtin_function.h" // need builtin_function
#include "GnashException.h" // for ActionException
#include "Object.h" // for AS inheritance
-#include "VM.h"
+#include "VM.h"
#include <cmath>
#include <boost/numeric/ublas/matrix.hpp> // boost matrix
=== modified file 'libcore/asobj/flash/geom/Point_as.cpp'
--- a/libcore/asobj/flash/geom/Point_as.cpp 2009-10-04 11:00:36 +0000
+++ b/libcore/asobj/flash/geom/Point_as.cpp 2009-10-07 08:06:57 +0000
@@ -26,7 +26,7 @@
#include "builtin_function.h" // need builtin_function
#include "GnashException.h" // for ActionException
#include "Object.h" // for AS inheritance
-#include "VM.h" // for addStatics
+#include "VM.h"
#include "GnashNumeric.h"
#include <sstream>
@@ -625,7 +625,8 @@
IF_VERBOSE_ASCODING_ERRORS(
std::stringstream ss;
fn.dump_args(ss);
- log_aserror("flash.geom.Point(%s): %s", ss.str(), _("arguments
after the first two discarded"));
+ log_aserror("flash.geom.Point(%s): %s", ss.str(),
+ _("arguments after the first two discarded"));
);
} while(0);
}
=== modified file 'libcore/asobj/flash/geom/Rectangle_as.cpp'
--- a/libcore/asobj/flash/geom/Rectangle_as.cpp 2009-10-04 12:19:33 +0000
+++ b/libcore/asobj/flash/geom/Rectangle_as.cpp 2009-10-07 07:46:44 +0000
@@ -30,7 +30,7 @@
#include "builtin_function.h" // need builtin_function
#include "GnashException.h" // for ActionException
#include "Object.h" // for AS inheritance
-#include "VM.h" // for addStatics
+#include "VM.h"
#include "as_value.h"
#include "namedStrings.h"
#include "GnashNumeric.h" // isFinite
@@ -208,19 +208,19 @@
// NOTE: order of tests is important, see actionscript.all/Rectangle.as
- as_value ret = x_as.newLessThan(rect_x_as);
+ as_value ret = newLessThan(x_as, rect_x_as, vm);
if ( ret.is_undefined() ) return as_value();
if ( ret.to_bool() ) return as_value(false);
- ret = x_as.newLessThan(rect_x1_as);
+ ret = newLessThan(x_as, rect_x1_as, vm);
if ( ret.is_undefined() ) return as_value();
if ( ! ret.to_bool() ) return as_value(false);
- ret = y_as.newLessThan(rect_y_as);
+ ret = newLessThan(y_as, rect_y_as, vm);
if ( ret.is_undefined() ) return as_value();
if ( ret.to_bool() ) return as_value(false);
- ret = y_as.newLessThan(rect_y1_as);
+ ret = newLessThan(y_as, rect_y1_as, vm);
if ( ret.is_undefined() ) return as_value();
if ( ! ret.to_bool() ) return as_value(false);
=== modified file 'libcore/asobj/flash/geom/Transform_as.cpp'
--- a/libcore/asobj/flash/geom/Transform_as.cpp 2009-09-29 10:36:57 +0000
+++ b/libcore/asobj/flash/geom/Transform_as.cpp 2009-10-07 05:52:30 +0000
@@ -30,7 +30,7 @@
#include "builtin_function.h" // need builtin_function
#include "GnashException.h" // for ActionException
#include "Object.h" // for AS inheritance
-#include "VM.h" // for addStatics
+#include "VM.h"
#include "MovieClip.h" // For MovieClip
#include "ColorTransform_as.h"
#include "GnashNumeric.h"
=== modified file 'libcore/asobj/flash/net/FileReferenceList_as.cpp'
--- a/libcore/asobj/flash/net/FileReferenceList_as.cpp 2009-09-29 10:05:48
+0000
+++ b/libcore/asobj/flash/net/FileReferenceList_as.cpp 2009-10-07 05:53:36
+0000
@@ -30,7 +30,7 @@
#include "builtin_function.h" // need builtin_function
#include "GnashException.h" // for ActionException
#include "Object.h" // for AS inheritance
-#include "VM.h" // for addStatics
+#include "VM.h"
#include <sstream>
=== modified file 'libcore/asobj/flash/net/FileReference_as.cpp'
--- a/libcore/asobj/flash/net/FileReference_as.cpp 2009-08-21 08:59:14
+0000
+++ b/libcore/asobj/flash/net/FileReference_as.cpp 2009-10-07 05:53:36
+0000
@@ -30,7 +30,7 @@
#include "builtin_function.h" // need builtin_function
#include "GnashException.h" // for ActionException
#include "Object.h" // for AS inheritance
-#include "VM.h" // for addStatics
+#include "VM.h"
#include <sstream>
=== modified file 'libcore/asobj/flash/text/TextRenderer_as.cpp'
--- a/libcore/asobj/flash/text/TextRenderer_as.cpp 2009-08-18 15:30:47
+0000
+++ b/libcore/asobj/flash/text/TextRenderer_as.cpp 2009-10-07 06:05:11
+0000
@@ -26,116 +26,64 @@
#include "log.h"
#include "fn_call.h"
#include "Global_as.h"
-#include "smart_ptr.h" // for boost intrusive_ptr
-#include "builtin_function.h" // need builtin_function
-#include "GnashException.h" // for ActionException
-#include "Object.h" // for AS inheritance
-#include "VM.h" // for addStatics
+#include "smart_ptr.h"
+#include "builtin_function.h"
+#include "Object.h"
+#include "VM.h"
#include <sstream>
namespace gnash {
-
-static as_value TextRenderer_setAdvancedAntialiasingTable(const fn_call& fn);
-static as_value TextRenderer_maxLevel_getset(const fn_call& fn);
-
-as_value TextRenderer_ctor(const fn_call& fn);
-
-static void
-attachTextRendererInterface(as_object& /*o*/)
+namespace {
+ void attachTextRendererStaticProperties(as_object& o);
+ as_value textrenderer_setAdvancedAntialiasingTable(const fn_call& fn);
+ as_value textrenderer_maxLevel(const fn_call& fn);
+ as_value textrenderer_ctor(const fn_call& fn);
+}
+
+// extern
+void
+textrenderer_class_init(as_object& where, const ObjectURI& uri)
{
+ registerBuiltinClass(where, textrenderer_ctor, 0,
+ attachTextRendererStaticProperties, uri);
}
-static void
+namespace {
+
+void
attachTextRendererStaticProperties(as_object& o)
{
Global_as* gl = getGlobal(o);
- o.init_member("setAdvancedAntialiasingTable",
gl->createFunction(TextRenderer_setAdvancedAntialiasingTable));
- o.init_property("maxLevel", TextRenderer_maxLevel_getset,
TextRenderer_maxLevel_getset);
-}
-
-static as_object*
-getTextRendererInterface()
-{
- static boost::intrusive_ptr<as_object> o;
-
- if ( ! o )
- {
- // TODO: check if this class should inherit from Object
- // or from a different class
- o = new as_object(getObjectInterface());
- VM::get().addStatic(o.get());
-
- attachTextRendererInterface(*o);
-
- }
-
- return o.get();
-}
-
-class TextRenderer_as: public as_object
-{
-
-public:
-
- TextRenderer_as()
- :
- as_object(getTextRendererInterface())
- {}
-};
-
-
-
-static as_value
-TextRenderer_setAdvancedAntialiasingTable(const fn_call& fn)
-{
- boost::intrusive_ptr<TextRenderer_as> ptr =
ensureType<TextRenderer_as>(fn.this_ptr);
- UNUSED(ptr);
- LOG_ONCE( log_unimpl (__FUNCTION__) );
- return as_value();
-}
-
-static as_value
-TextRenderer_maxLevel_getset(const fn_call& fn)
-{
- boost::intrusive_ptr<TextRenderer_as> ptr =
ensureType<TextRenderer_as>(fn.this_ptr);
- UNUSED(ptr);
- LOG_ONCE( log_unimpl (__FUNCTION__) );
- return as_value();
-}
-
-
-as_value
-TextRenderer_ctor(const fn_call& fn)
-{
- boost::intrusive_ptr<as_object> obj = new TextRenderer_as;
-
- if ( fn.nargs )
- {
- std::stringstream ss;
- fn.dump_args(ss);
- LOG_ONCE( log_unimpl("TextRenderer(%s): %s", ss.str(), _("arguments
discarded")) );
- }
-
- return as_value(obj.get()); // will keep alive
-}
-
-// extern
-void textrenderer_class_init(as_object& where, const ObjectURI& uri)
-{
- // This is going to be the TextRenderer "class"/"function"
- // in the 'where' package
- boost::intrusive_ptr<as_object> cl;
- Global_as* gl = getGlobal(where);
- as_object* proto = getTextRendererInterface();
- cl = gl->createClass(&TextRenderer_ctor, proto);
- attachTextRendererStaticProperties(*cl);
-
- // Register _global.TextRenderer
- where.init_member(getName(uri), cl.get(), as_object::DefaultFlags,
- getNamespace(uri));
+ o.init_member("setAdvancedAntialiasingTable",
+ gl->createFunction(textrenderer_setAdvancedAntialiasingTable));
+ o.init_property("maxLevel", textrenderer_maxLevel, textrenderer_maxLevel);
+}
+
+
+as_value
+textrenderer_setAdvancedAntialiasingTable(const fn_call& /*fn*/)
+{
+ LOG_ONCE( log_unimpl (__FUNCTION__) );
+ return as_value();
+}
+
+as_value
+textrenderer_maxLevel(const fn_call& /*fn*/)
+{
+ LOG_ONCE( log_unimpl (__FUNCTION__) );
+ return as_value();
+}
+
+
+as_value
+textrenderer_ctor(const fn_call& /*fn*/)
+{
+ return as_value();
+}
+
}
} // end of gnash namespace
=== modified file 'libcore/movie_root.cpp'
--- a/libcore/movie_root.cpp 2009-10-01 13:19:43 +0000
+++ b/libcore/movie_root.cpp 2009-10-07 07:01:31 +0000
@@ -127,7 +127,8 @@
_recursionLimit(256),
_timeoutLimit(15),
_movieAdvancementDelay(83), // ~12 fps by default
- _lastMovieAdvancement(0)
+ _lastMovieAdvancement(0),
+ _unnamedInstance(0)
{
// This takes care of informing the renderer (if present) too.
setQuality(QUALITY_HIGH);
@@ -144,6 +145,13 @@
// of the queue.
}
+
+size_t
+movie_root::nextUnnamedInstance()
+{
+ return ++_unnamedInstance;
+}
+
void
movie_root::clearActionQueue()
{
=== modified file 'libcore/movie_root.h'
--- a/libcore/movie_root.h 2009-10-01 13:19:43 +0000
+++ b/libcore/movie_root.h 2009-10-07 07:01:31 +0000
@@ -417,6 +417,9 @@
_rootMovie->setPlayState(s);
}
+ /// Get a unique number for unnamed instances.
+ size_t nextUnnamedInstance();
+
/// Notify still loaded DisplayObject listeners for key events
DSOEXPORT void notify_key_listeners(key::code k, bool down);
@@ -1217,6 +1220,9 @@
// time of last movie advancement, in milliseconds
unsigned int _lastMovieAdvancement;
+
+ size_t _unnamedInstance;
+
};
DSOEXPORT short stringToStageAlign(const std::string& s);
=== modified file 'libcore/vm/ASHandlers.cpp'
--- a/libcore/vm/ASHandlers.cpp 2009-10-07 08:40:42 +0000
+++ b/libcore/vm/ASHandlers.cpp 2009-10-07 09:30:57 +0000
@@ -3014,66 +3014,8 @@
void
SWFHandlers::ActionNewLessThan(ActionExec& thread)
{
-
as_environment& env = thread.env;
-
- as_value operand1 = env.top(1);
- as_value operand2 = env.top(0);
-
- try { operand1 = operand1.to_primitive(as_value::NUMBER); }
- catch (ActionTypeError& e)
- {
- log_debug(_("%s.to_primitive() threw an error during "
- "ActionNewLessThan"), operand1);
- }
- if ( operand1.is_object() && !operand1.is_sprite() )
- {
- // comparison involving an object (NOT sprite!) is always false
- env.top(1).set_bool(false);
- env.drop(1);
- return;
- }
-
- try { operand2 = operand2.to_primitive(as_value::NUMBER); }
- catch (ActionTypeError& e)
- {
- log_debug(_("%s.to_primitive() threw an error during "
- "ActionNewLessThan"), operand2);
- }
- if ( operand2.is_object() && !operand2.is_sprite() )
- {
- // comparison involving an object (NOT sprite!) is always false
- env.top(1).set_bool(false);
- env.drop(1);
- return;
- }
-
- if ( operand1.is_string() && operand2.is_string() )
- {
- const std::string& s1 = operand1.to_string();
- const std::string& s2 = operand2.to_string();
- // Don't ask me why, but an empty string is not less than a non-empty
one
- if ( s1.empty() ) {
- env.top(1).set_bool(false);
- } else if ( s2.empty() ) {
- env.top(1).set_bool(true);
- }
- else env.top(1).set_bool(s1 < s2);
- }
- else
- {
- const double op1 = operand1.to_number();
- const double op2 = operand2.to_number();
-
- if ( isNaN(op1) || isNaN(op2) )
- {
- env.top(1).set_undefined();
- }
- else
- {
- env.top(1).set_bool(op1<op2);
- }
- }
+ env.top(1) = newLessThan(env.top(1), env.top(0), getVM(env));
env.drop(1);
}
=== modified file 'libcore/vm/Machine.cpp'
--- a/libcore/vm/Machine.cpp 2009-10-04 12:19:33 +0000
+++ b/libcore/vm/Machine.cpp 2009-10-07 07:46:44 +0000
@@ -722,7 +722,7 @@
as_value b = pop_stack();
as_value a = pop_stack();
const boost::int32_t bytes = mStream->read_S24();
- const bool jump = a.newLessThan(b).to_bool();
+ const bool jump = newLessThan(a, b, _vm).to_bool();
if (jump) {
log_abc("Jumping... %d bytes.", bytes);
mStream->seekBy(bytes);
=== modified file 'libcore/vm/VM.cpp'
--- a/libcore/vm/VM.cpp 2009-08-18 08:00:20 +0000
+++ b/libcore/vm/VM.cpp 2009-10-07 08:06:47 +0000
@@ -293,6 +293,111 @@
return f;
}
+///////////////////////////////////////////////////////////////////////
+//
+// Value ops
+//
+///////////////////////////////////////////////////////////////////////
+
+void
+newAdd(as_value& op1, const as_value& op2, VM& vm)
+{
+ // We can't change the original value.
+ as_value r(op2);
+
+ // The order of the operations is important: op2 is converted to
+ // primitive before op1.
+
+ try { r = r.to_primitive(); }
+ catch (ActionTypeError& e)
+ {
+ log_debug(_("%s.to_primitive() threw an error during "
+ "ActionNewAdd"), r);
+ }
+
+ try { op1 = op1.to_primitive(); }
+ catch (ActionTypeError& e)
+ {
+ log_debug(_("%s.to_primitive() threw an error during "
+ "ActionNewAdd"), op1);
+ }
+
+#if GNASH_DEBUG
+ log_debug(_("(%s + %s) [primitive conversion done]"), op1, r);
+#endif
+
+ if (op1.is_string() || r.is_string()) {
+
+ // use string semantic
+ const int version = vm.getSWFVersion();
+ convertToString(op1, vm);
+ op1.string_concat(r.to_string_versioned(version));
+ return;
+ }
+
+ // Otherwise use numeric semantic
+ const double num1 = op1.to_number();
+ const double num2 = r.to_number();
+ op1.set_double(num2 + num1);
+
+}
+
+void
+subtract(as_value& op1, const as_value& op2, VM& /*vm*/)
+{
+ const double num2 = op2.to_number();
+ const double num1 = op1.to_number();
+ op1.set_double(num1 - num2);
+}
+
+as_value
+newLessThan(const as_value& op1, const as_value& op2, VM& vm)
+{
+
+ as_value operand1(op1);
+ as_value operand2(op2);
+
+ try { operand1 = op1.to_primitive(as_value::NUMBER); }
+ catch (ActionTypeError& e)
+ {
+ log_debug("%s.to_primitive() threw an error during ActionNewLessThen",
+ op1);
+ }
+
+ if (operand1.is_object() && !operand1.is_sprite()) {
+ return false;
+ }
+
+ try { operand2 = op2.to_primitive(as_value::NUMBER); }
+ catch (ActionTypeError& e)
+ {
+ log_debug("%s.to_primitive() threw an error during ActionNewLessThen",
+ op2);
+ }
+
+ if (operand2.is_object() && !operand2.is_sprite()) {
+ return false;
+ }
+
+ if (operand1.is_string() && operand2.is_string())
+ {
+ const std::string& s1 = operand1.to_string();
+ const std::string& s2 = operand2.to_string();
+ if (s1.empty()) return false;
+ if (s2.empty()) return true;
+ return as_value(s1 < s2);
+ }
+
+ const double num1 = operand1.to_number();
+ const double num2 = operand2.to_number();
+
+ if (isNaN(num1) || isNaN(num2)) {
+ return as_value();
+ }
+ return as_value(num1 < num2);
+}
+
+
} // end of namespace gnash
=== modified file 'libcore/vm/VM.h'
--- a/libcore/vm/VM.h 2009-08-18 06:49:40 +0000
+++ b/libcore/vm/VM.h 2009-10-07 07:46:44 +0000
@@ -345,6 +345,46 @@
};
+/////////////////////////////////////////////////////////////////////////////
+///
+/// VM ops on as_value.
+///
+/// These are currently used in:
+/// 1. VM (AVM1)
+/// 2. Machine (AVM2)
+/// 3. Gnash's C++ implementation of ActionScript.
+///
+/// Usage 3 replicates VM behaviour, but does not use the VM's stack or other
+/// resources. This can lead to different behaviour, for instance when there
+/// are limits on the stack size. Such cases are probably rare.
+///
+/////////////////////////////////////////////////////////////////////////////
+
+/// Carry out ActionNewAdd
+//
+/// @param op1 The as_value to add to.
+/// @param op2 The as_value to add.
+/// @param vm The VM executing the operation.
+//
+/// TODO: Consider whether it would be better to pass something
+/// other than the VM. But it is a VM operation, so it
+/// is logically sound.
+void newAdd(as_value& op1, const as_value& op2, VM& vm);
+
+/// Carry out ActionSubtract
+//
+/// @param op1 The as_value to subtract from.
+/// @param op2 The as_value to subtract.
+/// @param vm The VM executing the operation.
+void subtract(as_value& op1, const as_value& op2, VM& vm);
+
+/// Carry out ActionSubtract
+//
+/// @param op1 The first comparand.
+/// @param op2 The second comparand.
+/// @param vm The VM executing the operation.
+as_value newLessThan(const as_value& op1, const as_value& op2, VM& vm);
+
/// Return true if the VM is executing AS3 (ABC bytecode).
inline bool
isAS3(VM& vm)
=== modified file 'testsuite/actionscript.all/TextField.as'
--- a/testsuite/actionscript.all/TextField.as 2009-10-04 09:36:21 +0000
+++ b/testsuite/actionscript.all/TextField.as 2009-10-06 14:21:50 +0000
@@ -435,15 +435,22 @@
// Check TextField._root and _global
//-------------------------------------------------------------------------
-xcheck(tf._root);
-xcheck_equals(_root, _root.tf._root);
-
-xcheck(tf._global);
-xcheck_equals(_global, _root.tf._global);
+check(tf._root);
+check_equals(_root, _root.tf._root);
+
+check(tf._global);
+check_equals(_global, _root.tf._global);
+
+check(tf._level0);
+
+// They would exist if they had been loaded...
+check(!tf._level1);
+check(!tf._level2);
#if OUTPUT_VERSION > 6
-xcheck(tf._root != tf._ROOT);
-xcheck(tf._root != tf._GLOBAL);
+check(tf._root != tf._ROOT);
+check(tf._root != tf._GLOBAL);
+check(tf._level0 != tf._LEVEL0);
#endif
//-------------------------------------------------------------------------
@@ -1132,11 +1139,11 @@
//------------------------------------------------------------
#if OUTPUT_VERSION == 6
- check_totals(496);
+ check_totals(499);
#elif OUTPUT_VERSION == 7
- check_totals(501);
+ check_totals(505);
#elif OUTPUT_VERSION == 8
- check_totals(502);
+ check_totals(506);
#endif
#endif
=== modified file 'testsuite/misc-ming.all/ButtonPropertiesTest.c'
--- a/testsuite/misc-ming.all/ButtonPropertiesTest.c 2009-07-07 15:26:13
+0000
+++ b/testsuite/misc-ming.all/ButtonPropertiesTest.c 2009-10-07 05:35:15
+0000
@@ -135,6 +135,11 @@
SWFDisplayItem_setName(it, "square1");
SWFDisplayItem_setDepth(it, 2);
+ /* This button has one character per state. It shows that each state
+ * except HIT generates one new instance and deletes the old one.
+ * HIT deletes the old instance property and does not add a new one.
+ */
+
add_actions(mo, "note('This is a very simple test. Do anything you like "
"with the buttons and you should get no failures');");
=== modified file 'testsuite/swfdec/PASSING'
--- a/testsuite/swfdec/PASSING 2009-09-29 14:12:33 +0000
+++ b/testsuite/swfdec/PASSING 2009-10-07 07:16:45 +0000
@@ -621,6 +621,9 @@
jump-out-and-back-into-with-3.swf:928e6565eb17c5494831255f25ab26b2
jump-out-and-back-into-with-4.swf:a36aaf8d07d87af3d01ef6e23d30f5de
jump-out-and-back-into-with.swf:7e16afa6841a9b6833ef1057d9f9362f
+level-property-5.swf:b40bd83c1c30f61ae44c1da4edcb25a9
+level-property-6.swf:b9a04a1f681fb75e6870f749ac8cfe0c
+level-property-7.swf:18d9ebe3d39e3e618e4395c446d93f59
lifetime1.swf:d702dafeecc0e37a6425ce6d317c160f
load-4.swf:f3cbfe0e2ed88ad664c4aa5e1c0dabfb
load-5.swf:e2efd27e8813c647072fe7bbe5fecff3
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] /srv/bzr/gnash/trunk r11551: More cleanup of properties. Drop button::get_member.,
Benjamin Wolsey <=