[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] /srv/bzr/gnash/trunk r10398: Drop some return values, n
From: |
Benjamin Wolsey |
Subject: |
[Gnash-commit] /srv/bzr/gnash/trunk r10398: Drop some return values, note why others are useless. |
Date: |
Mon, 08 Dec 2008 17:12:45 +0100 |
User-agent: |
Bazaar (1.5) |
------------------------------------------------------------
revno: 10398
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Mon 2008-12-08 17:12:45 +0100
message:
Drop some return values, note why others are useless.
Minor corrections to AS correctness, swfdec testsuite passes.
General clean up.
modified:
libcore/Property.cpp
libcore/Property.h
libcore/PropertyList.cpp
libcore/as_object.cpp
libcore/as_object.h
libcore/asobj/Object.cpp
libcore/asobj/String_as.cpp
libcore/asobj/String_as.h
libcore/asobj/XMLNode_as.h
testsuite/actionscript.all/Object.as
testsuite/swfdec/PASSING
------------------------------------------------------------
revno: 10397.1.1
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Mon 2008-12-08 14:22:29 +0100
message:
Make XMLNode_as non-copyable, except by using the non-standard copy
constructor (called by cloneNode). Document and const-correct class.
modified:
libcore/asobj/XMLNode_as.h
------------------------------------------------------------
revno: 10397.1.2
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Mon 2008-12-08 15:05:33 +0100
message:
Rearrange String_as. String.concat doesn't have to be applied to a
String_as, despite what my comment from a while ago claims. Now passes
swfdec's string-fake and doesn't fail any actionscript.all tests, so the
earlier conclusion must have been based on a bogus test.
modified:
libcore/asobj/String_as.cpp
libcore/asobj/String_as.h
testsuite/swfdec/PASSING
------------------------------------------------------------
revno: 10397.1.3
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Mon 2008-12-08 16:13:08 +0100
message:
Remove unused methods. Ignore the return value from
PropertyList::addGetterSetter, add comments explaining why, and what it
did before. Don't pass namespace as an as_prop_flags argument.
modified:
libcore/Property.cpp
libcore/Property.h
libcore/PropertyList.cpp
libcore/as_object.cpp
libcore/as_object.h
------------------------------------------------------------
revno: 10397.1.4
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Mon 2008-12-08 16:29:32 +0100
message:
Drop old code.
modified:
libcore/as_object.cpp
------------------------------------------------------------
revno: 10397.1.5
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Mon 2008-12-08 16:58:46 +0100
message:
Test Object.addProperty() return, confirming that we don't care about
the result of as_object::add_property. Make as_object::add_property
void (instead of always returning true).
modified:
libcore/as_object.cpp
libcore/as_object.h
libcore/asobj/Object.cpp
testsuite/actionscript.all/Object.as
=== modified file 'libcore/Property.cpp'
--- a/libcore/Property.cpp 2008-09-01 18:11:06 +0000
+++ b/libcore/Property.cpp 2008-12-08 15:13:08 +0000
@@ -80,8 +80,7 @@
GetterSetter* a = boost::get<GetterSetter>(&mBound);
a->setGetter(func);
}
- else
- mBound = GetterSetter(func, NULL);
+ else mBound = GetterSetter(func, 0);
}
void
@@ -89,22 +88,22 @@
{
switch (mBound.which())
{
- case 0: // Blank, nothing to do.
- break;
- case 1: // Simple property, value
- {
- boost::get<as_value>(mBound).setReachable();
- break;
- }
- case 2: // Getter/setter
- {
- const GetterSetter& a = boost::get<GetterSetter>(mBound);
- a.markReachableResources();
- break;
- }
- default:
- abort(); // Not here.
- break;
+ case 0: // Blank, nothing to do.
+ break;
+ case 1: // Simple property, value
+ {
+ boost::get<as_value>(mBound).setReachable();
+ break;
+ }
+ case 2: // Getter/setter
+ {
+ const GetterSetter& a = boost::get<GetterSetter>(mBound);
+ a.markReachableResources();
+ break;
+ }
+ default:
+ abort(); // Not here.
+ break;
}
}
@@ -190,8 +189,7 @@
mDestructive = false;
mBound = value;
}
- else
- setDelayedValue(this_ptr, value);
+ else setDelayedValue(this_ptr, value);
return;
}
}
=== modified file 'libcore/Property.h'
--- a/libcore/Property.h 2008-09-19 09:50:15 +0000
+++ b/libcore/Property.h 2008-12-08 15:13:08 +0000
@@ -280,60 +280,93 @@
public:
/// Default constructor
- Property(string_table::key name = 0, string_table::key nsId = 0) :
- mBound(as_value()), mDestructive(false), mName(name),
mNamespace(nsId),
+ Property(string_table::key name = 0, string_table::key nsId = 0)
+ :
+ mBound(as_value()),
+ mDestructive(false),
+ mName(name),
+ mNamespace(nsId),
mOrderId(0)
- {/**/}
+ {}
/// Copy constructor
- Property(const Property& p) :
- _flags(p._flags), mBound(p.mBound),
mDestructive(p.mDestructive),
- mName(p.mName), mNamespace(p.mNamespace), mOrderId(p.mOrderId)
- {/**/}
+ Property(const Property& p)
+ :
+ _flags(p._flags),
+ mBound(p.mBound),
+ mDestructive(p.mDestructive),
+ mName(p.mName),
+ mNamespace(p.mNamespace),
+ mOrderId(p.mOrderId)
+ {}
/// Constructor taking initial flags
Property(string_table::key name, string_table::key nsId,
- const as_prop_flags& flags) : _flags(flags),
- mBound(as_value()), mDestructive(false), mName(name),
mNamespace(nsId),
+ const as_prop_flags& flags)
+ :
+ _flags(flags),
+ mBound(as_value()),
+ mDestructive(false),
+ mName(name),
+ mNamespace(nsId),
mOrderId(0)
- {/**/}
+ {}
Property(string_table::key name, string_table::key nsId,
- const as_value& value) : mBound(value), mDestructive(false),
- mName(name), mNamespace(nsId),
+ const as_value& value)
+ :
+ mBound(value),
+ mDestructive(false),
+ mName(name),
+ mNamespace(nsId),
mOrderId(0)
- {/**/}
+ {}
Property(string_table::key name, string_table::key nsId,
- const as_value& value, const as_prop_flags& flags) :
- _flags(flags), mBound(value), mDestructive(false),
- mName(name), mNamespace(nsId),
+ const as_value& value, const as_prop_flags& flags)
+ :
+ _flags(flags),
+ mBound(value),
+ mDestructive(false),
+ mName(name),
+ mNamespace(nsId),
mOrderId(0)
- {/**/}
+ {}
Property(string_table::key name, string_table::key nsId,
as_function *getter, as_function *setter,
- const as_prop_flags& flags, bool destroy = false) :
- _flags(flags), mBound(GetterSetter(getter, setter)),
- mDestructive(destroy), mName(name), mNamespace(nsId),
+ const as_prop_flags& flags, bool destroy = false)
+ :
+ _flags(flags),
+ mBound(GetterSetter(getter, setter)),
+ mDestructive(destroy),
+ mName(name),
+ mNamespace(nsId),
mOrderId(0)
- {/**/}
+ {}
Property(string_table::key name, string_table::key nsId,
- as_function *getter, as_function *setter, bool destroy = false)
:
- _flags(), mBound(GetterSetter(getter, setter)),
mDestructive(destroy),
- mName(name), mNamespace(nsId),
+ as_function *getter, as_function *setter, bool destroy = false)
+ :
+ _flags(),
+ mBound(GetterSetter(getter, setter)),
+ mDestructive(destroy),
+ mName(name),
+ mNamespace(nsId),
mOrderId(0)
- {/**/}
+ {}
Property(string_table::key name, string_table::key nsId,
as_c_function_ptr getter, as_c_function_ptr setter,
const as_prop_flags& flags, bool destroy = false)
:
- _flags(flags), mBound(GetterSetter(getter, setter)),
mDestructive(destroy),
- mName(name), mNamespace(nsId),
+ _flags(flags),
+ mBound(GetterSetter(getter, setter)),
+ mDestructive(destroy),
+ mName(name),
+ mNamespace(nsId),
mOrderId(0)
- {/**/}
+ {}
/// Set a user-defined setter
void setSetter(as_function* fun);
@@ -421,7 +454,9 @@
bool isStatic() const { return _flags.get_static(); }
/// Is this member supposed to be visible by a VM of given version ?
- bool isVisible(int swfVersion) const { return
_flags.get_visible(swfVersion); }
+ bool isVisible(int swfVersion) const {
+ return _flags.get_visible(swfVersion);
+ }
/// Clear visibility flags
void clearVisible(int swfVersion) { _flags.clear_visible(swfVersion); }
=== modified file 'libcore/PropertyList.cpp'
--- a/libcore/PropertyList.cpp 2008-10-25 18:51:18 +0000
+++ b/libcore/PropertyList.cpp 2008-12-08 15:13:08 +0000
@@ -422,11 +422,10 @@
a.setCache(found->getCache());
_props.replace(found, a);
- //assert ( iterator_find(_props, key, nsId) != _props.end() );
#ifdef GNASH_DEBUG_PROPERTY
string_table& st = VM::get().getStringTable();
- log_debug("AS GetterSetter %s in namespace %s replaced copying
flags %s",
- st.value(key), st.value(nsId), a.getFlags());
+ log_debug("AS GetterSetter %s in namespace %s replaced copying "
+ "flags %s", st.value(key), st.value(nsId), a.getFlags());
#endif
}
@@ -434,7 +433,6 @@
{
a.setCache(cacheVal);
_props.insert(a);
- //assert ( iterator_find(_props, key, nsId) != _props.end() );
#ifdef GNASH_DEBUG_PROPERTY
string_table& st = VM::get().getStringTable();
log_debug("AS GetterSetter %s in namespace %s inserted with
flags %s",
@@ -442,7 +440,6 @@
#endif
}
-
return true;
}
@@ -465,8 +462,9 @@
//assert ( iterator_find(_props, key, nsId) != _props.end() );
#ifdef GNASH_DEBUG_PROPERTY
string_table& st = VM::get().getStringTable();
- log_debug("Native GetterSetter %s in namespace %s replaced
copying flags %s",
- st.value(key), st.value(nsId), a.getFlags());
+ log_debug("Native GetterSetter %s in namespace %s replaced "
+ "copying flags %s", st.value(key), st.value(nsId),
+ a.getFlags());
#endif
}
@@ -476,12 +474,11 @@
//assert ( iterator_find(_props, key, nsId) != _props.end() );
#ifdef GNASH_DEBUG_PROPERTY
string_table& st = VM::get().getStringTable();
- log_debug("Native GetterSetter %s in namespace %s inserted with
flags %s",
- st.value(key), st.value(nsId), a.getFlags());
+ log_debug("Native GetterSetter %s in namespace %s inserted with
"
+ "flags %s", st.value(key), st.value(nsId), a.getFlags());
#endif
}
-
return true;
}
@@ -494,8 +491,8 @@
if (found != _props.end())
{
string_table& st = VM::get().getStringTable();
- log_error("Property %s in namespace %s already exists, can't
addDestructiveGetter",
- st.value(key), st.value(nsId));
+ log_error("Property %s in namespace %s already exists, "
+ "can't addDestructiveGetter", st.value(key), st.value(nsId));
return false; // Already exists.
}
@@ -506,8 +503,9 @@
#ifdef GNASH_DEBUG_PROPERTY
string_table& st = VM::get().getStringTable();
- log_debug("Destructive AS property %s (key %d) in namespace %s (key %d)
inserted with flags %s",
- st.value(key), key, st.value(nsId), nsId, a.getFlags());
+ log_debug("Destructive AS property %s (key %d) in namespace %s "
+ "(key %d) inserted with flags %s",
+ st.value(key), key, st.value(nsId), nsId, a.getFlags());
#endif
return true;
@@ -519,8 +517,7 @@
const as_prop_flags& flagsIfMissing)
{
container::iterator found = iterator_find(_props, key, nsId);
- if (found != _props.end())
- return false; // Already exists.
+ if (found != _props.end()) return false;
// destructive getter don't need a setter
Property a(key, nsId, getter, (as_c_function_ptr)0, flagsIfMissing,
true);
@@ -528,8 +525,8 @@
_props.insert(a);
#ifdef GNASH_DEBUG_PROPERTY
string_table& st = VM::get().getStringTable();
- log_debug("Destructive native property %s in namespace %s inserted with
flags %s",
- st.value(key), st.value(nsId), a.getFlags());
+ log_debug("Destructive native property %s in namespace %s inserted "
+ "with flags %s", st.value(key), st.value(nsId), a.getFlags());
#endif
return true;
}
=== modified file 'libcore/as_object.cpp'
--- a/libcore/as_object.cpp 2008-10-31 12:04:41 +0000
+++ b/libcore/as_object.cpp 2008-12-08 15:58:46 +0000
@@ -248,7 +248,7 @@
namespace gnash {
-bool
+void
as_object::add_property(const std::string& name, as_function& getter,
as_function* setter)
{
@@ -261,25 +261,30 @@
if ( prop )
{
cacheVal = prop->getCache();
- return _members.addGetterSetter(k, getter, setter, cacheVal);
-
- // NOTE: watch triggers not called when adding a new
getter-setter property
+
+ // Used to return the return value of addGetterSetter, but this
+ // is always true.
+ _members.addGetterSetter(k, getter, setter, cacheVal);
+
+ return;
+ // NOTE: watch triggers not called when adding a new
+ // getter-setter property
}
else
{
- bool ret = _members.addGetterSetter(k, getter, setter,
cacheVal);
- if (!ret) return false;
+ _members.addGetterSetter(k, getter, setter, cacheVal);
#if 1
// check if we have a trigger, if so, invoke it
- // and set val to it's return
+ // and set val to its return
TriggerContainer::iterator trigIter =
_trigs.find(std::make_pair(k, 0));
if ( trigIter != _trigs.end() )
{
Trigger& trig = trigIter->second;
- log_debug("add_property: property %s is being watched,
current val: %s", name, cacheVal);
+ log_debug("add_property: property %s is being watched, "
+ "current val: %s", name, cacheVal);
cacheVal = trig.call(cacheVal, as_value(), *this);
// The trigger call could have deleted the property,
@@ -288,15 +293,14 @@
prop = _members.getProperty(k);
if ( ! prop )
{
- log_debug("Property %s deleted by trigger on
create (getter-setter)", name);
- return false; // or true ?
+ log_debug("Property %s deleted by trigger on
create "
+ "(getter-setter)", name);
+ return;
}
prop->setCache(cacheVal);
- //prop->setValue(*this, cacheVal);
}
#endif
-
- return ret;
+ return;
}
}
@@ -661,66 +665,6 @@
return false;
}
-#if 0
-std::pair<bool,bool>
-as_object::update_member(string_table::key key, const as_value& val,
- string_table::key nsname)
-{
- std::pair<bool,bool> ret; // first is found, second is updated
-
- //log_debug(_("set_member_default(%s)"), key);
- Property* prop = findUpdatableProperty(key, nsname);
- if (prop)
- {
- if (prop->isReadOnly())
- {
- IF_VERBOSE_ASCODING_ERRORS(log_aserror(_(""
- "Attempt to set read-only property '%s'"),
- _vm.getStringTable().value(key)););
- return std::make_pair(true, false);
- }
-
- try
- {
- as_value newVal = val;
-
- // check if we have a trigger, if so, invoke it
- // and set val to it's return
- TriggerContainer::iterator trigIter =
_trigs.find(std::make_pair(key, nsname));
- if ( trigIter != _trigs.end() )
- {
- Trigger& trig = trigIter->second;
- // WARNING: getValue might itself invoke a
trigger (getter-setter)... ouch ?
- as_value curVal = prop->getCache(); //
Value(*this);
- log_debug("Property %s is being watched: firing
trigger on update (current val:%s, new val:%s",
- _vm.getStringTable().value(key),
- curVal, val);
- newVal = trig.call(curVal, val, *this);
- // The trigger call could have deleted the
property,
- // so we check for its existance again, and do
NOT put
- // it back in if it was deleted
- prop = findUpdatableProperty(key, nsname);
- if ( ! prop )
- {
- return std::make_pair(true, true);
- }
- }
-
- prop->setValue(*this, newVal);
- return std::make_pair(true, true);
- }
- catch (ActionTypeError& exc)
- {
- log_debug(_("%s: Exception %s. Will create a new
member"),
- _vm.getStringTable().value(key), exc.what());
- }
-
- return std::make_pair(true, false);
- }
-
- return std::make_pair(false, false);
-}
-#endif
void
as_object::init_member(const std::string& key1, const as_value& val, int flags,
@@ -768,17 +712,9 @@
{
as_value cacheValue;
- bool success;
- success = _members.addGetterSetter(key, getter, &setter, cacheValue,
flags, nsname);
-
- // We shouldn't attempt to initialize a property twice, should we ?
- assert(success);
-
- //log_debug(_("Initialized property '%s'"), name);
-
- // TODO: optimize this, don't scan again !
- //_members.setFlags(key, flags, nsname);
-
+ // PropertyList::addGetterSetter always returns true (used to be
+ // an assert).
+ _members.addGetterSetter(key, getter, &setter, cacheValue, flags,
nsname);
}
void
@@ -793,38 +729,26 @@
as_object::init_property(string_table::key key, as_c_function_ptr getter,
as_c_function_ptr setter, int flags, string_table::key nsname)
{
- bool success;
- success = _members.addGetterSetter(key, getter, setter, nsname);
-
- // We shouldn't attempt to initialize a property twice, should we ?
- assert(success);
-
- //log_debug(_("Initialized property '%s'"), name);
-
- // TODO: optimize this, don't scan again !
- _members.setFlags(key, flags, nsname);
-
+ // PropertyList::addGetterSetter always returns true (used to be
+ // an assert).
+ _members.addGetterSetter(key, getter, setter, flags, nsname);
}
bool
as_object::init_destructive_property(string_table::key key, as_function&
getter,
int flags, string_table::key nsname)
{
- bool success;
-
// No case check, since we've already got the key.
- success = _members.addDestructiveGetter(key, getter, nsname, flags);
+ bool success = _members.addDestructiveGetter(key, getter, nsname,
flags);
return success;
}
bool
-as_object::init_destructive_property(string_table::key key, as_c_function_ptr
getter,
- int flags, string_table::key nsname)
+as_object::init_destructive_property(string_table::key key,
+ as_c_function_ptr getter, int flags, string_table::key nsname)
{
- bool success;
-
// No case check, since we've already got the key.
- success = _members.addDestructiveGetter(key, getter, nsname, flags);
+ bool success = _members.addDestructiveGetter(key, getter, nsname,
flags);
return success;
}
@@ -840,8 +764,8 @@
}
void
-as_object::init_readonly_property(const string_table::key& k, as_function&
getter,
- int initflags, string_table::key nsname)
+as_object::init_readonly_property(const string_table::key& k,
+ as_function& getter, int initflags, string_table::key nsname)
{
init_property(k, getter, getter, initflags | as_prop_flags::readOnly
| as_prop_flags::isProtected, nsname);
@@ -849,8 +773,8 @@
}
void
-as_object::init_readonly_property(const std::string& key, as_c_function_ptr
getter,
- int initflags, string_table::key nsname)
+as_object::init_readonly_property(const std::string& key,
+ as_c_function_ptr getter, int initflags, string_table::key nsname)
{
string_table::key k = _vm.getStringTable().find(PROPNAME(key));
@@ -860,22 +784,14 @@
}
void
-as_object::init_readonly_property(const string_table::key& k,
as_c_function_ptr getter,
- int initflags, string_table::key nsname)
+as_object::init_readonly_property(const string_table::key& k,
+ as_c_function_ptr getter, int initflags, string_table::key nsname)
{
init_property(k, getter, getter, initflags | as_prop_flags::readOnly
| as_prop_flags::isProtected, nsname);
assert(_members.getProperty(k, nsname));
}
-std::string
-as_object::asPropName(string_table::key name)
-{
- std::string orig = _vm.getStringTable().value(name);
-
- return PROPNAME(orig); // why is PROPNAME needed here ?
-}
-
bool
as_object::set_member_flags(string_table::key name,
=== modified file 'libcore/as_object.h'
--- a/libcore/as_object.h 2008-12-02 13:28:29 +0000
+++ b/libcore/as_object.h 2008-12-08 15:58:46 +0000
@@ -1006,15 +1006,10 @@
///
/// @param setter
/// A function to invoke when setting this property's value.
- /// add_ref will be called on the function.
/// By passing NULL, the property will have no setter
/// (valid ActionScript - see actionscript.all/Object.as)
- ///
- /// @return true if the property was successfully added, false
- /// otherwise (property already existent?)
- ///
- bool add_property(const std::string& key, as_function& getter,
- as_function* setter=NULL);
+ void add_property(const std::string& key, as_function& getter,
+ as_function* setter);
/// Return this object '__proto__' member.
//
@@ -1040,8 +1035,6 @@
void set_prototype(boost::intrusive_ptr<as_object> proto,
int flags=as_prop_flags::dontDelete | as_prop_flags::dontEnum);
- std::string asPropName(string_table::key name);
-
/// @{ Common ActionScript methods for characters
/// TODO: make protected
=== modified file 'libcore/asobj/Object.cpp'
--- a/libcore/asobj/Object.cpp 2008-12-08 11:11:44 +0000
+++ b/libcore/asobj/Object.cpp 2008-12-08 15:58:46 +0000
@@ -188,13 +188,17 @@
}
+
+/// The return value is not dependent on the result of add_property (though
+/// this is always true anyway), but rather on the validity of the arguments.
static as_value
object_addproperty(const fn_call& fn)
{
assert(fn.this_ptr);
boost::intrusive_ptr<as_object> obj = fn.this_ptr;
- if ( fn.nargs != 3 )
+ /// Extra arguments are just ignored.
+ if ( fn.nargs < 3 )
{
IF_VERBOSE_ASCODING_ERRORS(
std::stringstream ss;
@@ -213,7 +217,7 @@
}
const std::string& propname = fn.arg(0).to_string();
- if ( propname.empty() )
+ if (propname.empty())
{
IF_VERBOSE_ASCODING_ERRORS(
log_aserror(_("Invalid call to Object.addProperty() - "
@@ -223,7 +227,7 @@
}
as_function* getter = fn.arg(1).to_as_function();
- if ( ! getter )
+ if (!getter)
{
IF_VERBOSE_ASCODING_ERRORS(
log_aserror(_("Invalid call to Object.addProperty() - "
@@ -234,10 +238,10 @@
as_function* setter = NULL;
const as_value& setterval = fn.arg(2);
- if ( ! setterval.is_null() )
+ if (!setterval.is_null())
{
setter = setterval.to_as_function();
- if ( ! setter )
+ if (!setter)
{
IF_VERBOSE_ASCODING_ERRORS(
log_aserror(_("Invalid call to Object.addProperty() - "
@@ -248,14 +252,11 @@
}
}
-
// Now that we checked everything, let's call the as_object
// interface for getter/setter properties :)
-
- bool result = obj->add_property(propname, *getter, setter);
+ obj->add_property(propname, *getter, setter);
- //log_debug("Object.addProperty(): testing");
- return as_value(result);
+ return as_value(true);
}
static as_value
=== modified file 'libcore/asobj/String_as.cpp'
--- a/libcore/asobj/String_as.cpp 2008-11-20 15:22:13 +0000
+++ b/libcore/asobj/String_as.cpp 2008-12-08 14:05:33 +0000
@@ -29,7 +29,7 @@
#include "array.h"
#include "as_value.h"
#include "GnashException.h"
-#include "VM.h" // for registering static GcResources (constructor and
prototype)
+#include "VM.h"
#include "Object.h" // for getObjectInterface
#include "namedStrings.h"
#include "utf8.h"
@@ -42,86 +42,162 @@
namespace gnash {
-/// Check the number of arguments, returning false if there
-/// aren't enough, or true if there are either enough or too many.
-/// Logs an error if the number isn't between min and max.
-inline bool checkArgs(const fn_call& fn, size_t min, size_t max,
- const std::string& function)
-{
-
- if (fn.nargs < min) {
- IF_VERBOSE_ASCODING_ERRORS(
- std::ostringstream os;
- fn.dump_args(os);
- log_aserror(_("%1%(%2%) needs %3% argument(s)"),
- function, os.str(), min);
- )
- return false;
- }
- IF_VERBOSE_ASCODING_ERRORS(
- if (fn.nargs > max)
- {
- std::ostringstream os;
- fn.dump_args(os);
- log_aserror(_("%1%(%2%) has more than %3% argument(s)"),
- function, os.str(), max);
- }
- );
- return true;
-}
-
// Forward declarations
-
-static as_value string_concat(const fn_call& fn);
-static as_value string_slice(const fn_call& fn);
-static as_value string_split(const fn_call& fn);
-static as_value string_last_index_of(const fn_call& fn);
-static as_value string_sub_str(const fn_call& fn);
-static as_value string_sub_string(const fn_call& fn);
-static as_value string_index_of(const fn_call& fn);
-static as_value string_from_char_code(const fn_call& fn);
-static as_value string_char_code_at(const fn_call& fn);
-static as_value string_char_at(const fn_call& fn);
-static as_value string_to_upper_case(const fn_call& fn);
-static as_value string_to_lower_case(const fn_call& fn);
-static as_value string_to_string(const fn_call& fn);
-static as_value string_oldToLower(const fn_call& fn);
-static as_value string_oldToUpper(const fn_call& fn);
-static as_value string_ctor(const fn_call& fn);
-
-static void
+namespace {
+
+ as_value string_concat(const fn_call& fn);
+ as_value string_slice(const fn_call& fn);
+ as_value string_split(const fn_call& fn);
+ as_value string_lastIndexOf(const fn_call& fn);
+ as_value string_substr(const fn_call& fn);
+ as_value string_substring(const fn_call& fn);
+ as_value string_indexOf(const fn_call& fn);
+ as_value string_fromCharCode(const fn_call& fn);
+ as_value string_charCodeAt(const fn_call& fn);
+ as_value string_charAt(const fn_call& fn);
+ as_value string_toUpperCase(const fn_call& fn);
+ as_value string_toLowerCase(const fn_call& fn);
+ as_value string_toString(const fn_call& fn);
+ as_value string_oldToLower(const fn_call& fn);
+ as_value string_oldToUpper(const fn_call& fn);
+ as_value string_ctor(const fn_call& fn);
+
+ size_t validIndex(const std::wstring& subject, int index);
+ void attachStringInterface(as_object& o);
+ as_object* getStringInterface();
+ boost::intrusive_ptr<builtin_function> getStringConstructor();
+
+ inline bool checkArgs(const fn_call& fn, size_t min, size_t max,
+ const std::string& function);
+}
+
+class String_as : public as_object
+{
+
+public:
+
+ String_as(const std::string& s)
+ :
+ as_object(getStringInterface()),
+ _string(s)
+ {
+ std::wstring wstr = utf8::decodeCanonicalString(
+ _string, _vm.getSWFVersion());
+ init_member(NSV::PROP_LENGTH, wstr.size(),
+ as_prop_flags::dontDelete | as_prop_flags::dontEnum);
+ }
+
+
+ bool useCustomToString() const { return false; }
+
+ std::string get_text_value() const {
+ return _string;
+ }
+
+ as_value get_primitive_value() const {
+ return as_value(_string);
+ }
+
+ const std::string& str() {
+ return _string;
+ }
+
+private:
+ std::string _string;
+};
+
+boost::intrusive_ptr<as_object>
+init_string_instance(const std::string& val)
+{
+ // TODO: get VM from the environment ?
+ VM& vm = VM::get();
+
+ // TODO: get the environment passed in !!
+ as_environment env(vm);
+
+ int swfVersion = vm.getSWFVersion();
+
+ boost::intrusive_ptr<as_function> cl;
+
+ if ( swfVersion < 6 ) {
+ cl = getStringConstructor();
+ }
+ else {
+ as_object* global = vm.getGlobal();
+ as_value clval;
+ if ( ! global->get_member(NSV::CLASS_STRING, &clval) ) {
+ log_debug("UNTESTED: String instantiation requested but
"
+ "_global doesn't contain a 'String' symbol. Returning "
+ "the NULL object.");
+ return cl;
+ }
+ else if ( ! clval.is_function() ) {
+ log_debug("UNTESTED: String instantiation requested but
"
+ "_global.String is not a function (%s). Returning "
+ "the NULL object.", clval);
+ return cl;
+ }
+ else {
+ cl = clval.to_as_function();
+ assert(cl);
+ }
+ }
+
+ std::auto_ptr< std::vector<as_value> > args ( new std::vector<as_value>
);
+ args->push_back(val);
+ boost::intrusive_ptr<as_object> ret = cl->constructInstance(env, args);
+
+ return ret;
+}
+
+// extern (used by Global.cpp)
+void string_class_init(as_object& global)
+{
+ // This is going to be the global String "class"/"function"
+ boost::intrusive_ptr<builtin_function> cl = getStringConstructor();
+
+ // Register _global.String (should be only visible from SWF5 up)
+ // TODO: register as ASnative(251, 0)
+ // TODO: register as ASnative(3, 0) for SWF5 ?
+ int flags = as_prop_flags::dontEnum;
+ global.init_member("String", cl.get(), flags);
+}
+
+
+/// String class interface
+namespace {
+
+void
attachStringInterface(as_object& o)
{
VM& vm = o.getVM();
- // TODO fill in the rest
-
// ASnative(251, 1) - [String.prototype] valueOf
vm.registerNative(as_object::tostring_method, 251, 1);
o.init_member("valueOf", vm.getNative(251, 1));
// ASnative(251, 2) - [String.prototype] toString
- vm.registerNative(string_to_string, 251, 2);
+ vm.registerNative(string_toString, 251, 2);
o.init_member("toString", vm.getNative(251, 2));
// ASnative(251, 3) - [String.prototype] toUpperCase
// ASnative(102, 0) - SWF5 to upper.
vm.registerNative(string_oldToUpper, 102, 0);
- vm.registerNative(string_to_upper_case, 251, 3);
+ vm.registerNative(string_toUpperCase, 251, 3);
o.init_member("toUpperCase", vm.getNative(251, 3));
// ASnative(251, 4) - [String.prototype] toLowerCase
// ASnative(102, 1) - SWF5 to lower.
vm.registerNative(string_oldToLower, 102, 1);
- vm.registerNative(string_to_lower_case, 251, 4);
+ vm.registerNative(string_toLowerCase, 251, 4);
o.init_member("toLowerCase", vm.getNative(251, 4));
// ASnative(251, 5) - [String.prototype] charAt
- vm.registerNative(string_char_at, 251, 5);
+ vm.registerNative(string_charAt, 251, 5);
o.init_member("charAt", vm.getNative(251, 5));
// ASnative(251, 6) - [String.prototype] charCodeAt
- vm.registerNative(string_char_code_at, 251, 6);
+ vm.registerNative(string_charCodeAt, 251, 6);
o.init_member("charCodeAt", vm.getNative(251, 6));
// ASnative(251, 7) - [String.prototype] concat
@@ -129,11 +205,11 @@
o.init_member("concat", vm.getNative(251, 7));
// ASnative(251, 8) - [String.prototype] indexOf
- vm.registerNative(string_index_of, 251, 8);
+ vm.registerNative(string_indexOf, 251, 8);
o.init_member("indexOf", vm.getNative(251, 8));
// ASnative(251, 9) - [String.prototype] lastIndexOf
- vm.registerNative(string_last_index_of, 251, 9);
+ vm.registerNative(string_lastIndexOf, 251, 9);
o.init_member("lastIndexOf", vm.getNative(251, 9));
// ASnative(251, 10) - [String.prototype] slice
@@ -141,7 +217,7 @@
o.init_member("slice", vm.getNative(251, 10));
// ASnative(251, 11) - [String.prototype] substring
- vm.registerNative(string_sub_string, 251, 11);
+ vm.registerNative(string_substring, 251, 11);
o.init_member("substring", vm.getNative(251, 11));
// ASnative(251, 12) - [String.prototype] split
@@ -149,11 +225,11 @@
o.init_member("split", vm.getNative(251, 12));
// ASnative(251, 13) - [String.prototype] substr
- vm.registerNative(string_sub_str, 251, 13);
+ vm.registerNative(string_substr, 251, 13);
o.init_member("substr", vm.getNative(251, 13));
}
-static as_object*
+as_object*
getStringInterface()
{
static boost::intrusive_ptr<as_object> o;
@@ -169,51 +245,14 @@
return o.get();
}
-class String_as : public as_object
-{
-
-public:
- String_as(const std::string& s)
- :
- as_object(getStringInterface()),
- _string(s)
- {
- std::wstring wstr = utf8::decodeCanonicalString(_string,
_vm.getSWFVersion());
- init_member(NSV::PROP_LENGTH, wstr.size(),
as_prop_flags::dontDelete|as_prop_flags::dontEnum); // can override though
- }
-
-
- bool useCustomToString() const { return false; }
-
- std::string get_text_value() const
- {
- return _string;
- }
-
- as_value get_primitive_value() const
-
- {
- return as_value(_string);
- }
-
- const std::string& str()
- {
- return _string;
- }
-
-private:
- std::string _string;
-};
-
// all the arguments will be converted to string and concatenated.
-// This can only be applied to String objects, unlike other methods.
-static as_value
+as_value
string_concat(const fn_call& fn)
{
- boost::intrusive_ptr<String_as> obj = ensureType<String_as>(fn.this_ptr);
-
- // Make a copy of our string.
- std::string str = obj->str();
+ boost::intrusive_ptr<as_object> obj = ensureType<as_object>(fn.this_ptr);
+ as_value val(fn.this_ptr);
+
+ std::string str = val.to_string();
for (unsigned int i = 0; i < fn.nargs; i++) {
str += fn.arg(i).to_string();
@@ -223,21 +262,8 @@
}
-static size_t
-validIndex(const std::wstring& subject, int index)
-{
-
- if (index < 0) {
- index = subject.size() + index;
- }
-
- index = utility::clamp<int>(index, 0, subject.size());
-
- return index;
-}
-
// 1st param: start_index, 2nd param: end_index
-static as_value
+as_value
string_slice(const fn_call& fn)
{
boost::intrusive_ptr<as_object> obj = ensureType<as_object>(fn.this_ptr);
@@ -247,16 +273,17 @@
/// version to use is the one of the SWF containing caller code.
/// If callerDef is null, this calls is spontaneous (system-event?)
- /// in which case we should research on which version should drive
behaviour.
+ /// in which case we should research on which version should drive
+ /// behaviour.
/// NOTE: it is unlikely that a system event triggers string_split so
/// in most cases a null callerDef means the caller forgot to
/// set the field (ie: a programmatic error)
if ( ! fn.callerDef )
{
log_error("No fn_call::callerDef in string_slice call");
- //abort();
}
- const int version = fn.callerDef ? fn.callerDef->get_version() :
obj->getVM().getSWFVersion();
+ const int version = fn.callerDef ? fn.callerDef->get_version() :
+ obj->getVM().getSWFVersion();
std::wstring wstr = utf8::decodeCanonicalString(str, version);
@@ -281,7 +308,8 @@
log_debug("start: %d, end: %d, retlen: %d", start, end, retlen);
- return as_value(utf8::encodeCanonicalString(wstr.substr(start, retlen),
version));
+ return as_value(utf8::encodeCanonicalString(
+ wstr.substr(start, retlen), version));
}
// String.split(delimiter[, limit])
@@ -304,7 +332,7 @@
// Empty array returned:
// 4. string and delimiter are empty but defined.
// 5. non-empty string, non-empty delimiter; 0 or less elements required.
-static as_value
+as_value
string_split(const fn_call& fn)
{
boost::intrusive_ptr<as_object> obj = ensureType<as_object>(fn.this_ptr);
@@ -314,12 +342,17 @@
/// version to use is the one of the SWF containing caller code.
/// If callerDef is null, this calls is spontaneous (system-event?)
- /// in which case we should research on which version should drive
behaviour.
+ /// in which case we should research on which version should drive
+ /// behaviour.
/// NOTE: it is unlikely that a system event triggers string_split so
/// in most cases a null callerDef means the caller forgot to
/// set the field (ie: a programmatic error)
- if ( ! fn.callerDef ) log_error("No fn_call::callerDef in string_split
call");
- const int version = fn.callerDef ? fn.callerDef->get_version() :
obj->getVM().getSWFVersion();
+ if (!fn.callerDef ) {
+ log_error("No fn_call::callerDef in string_split call");
+ }
+
+ const int version = fn.callerDef ? fn.callerDef->get_version() :
+ obj->getVM().getSWFVersion();
std::wstring wstr = utf8::decodeCanonicalString(str, version);
@@ -332,7 +365,8 @@
return as_value(array.get());
}
- const std::wstring& delim =
utf8::decodeCanonicalString(fn.arg(0).to_string(), version);
+ const std::wstring& delim = utf8::decodeCanonicalString(
+ fn.arg(0).to_string(), version);
const size_t delimiterSize = delim.size();
if ((version < 6 && delimiterSize == 0) ||
@@ -424,8 +458,8 @@
//
/// Performs a reverse search for the complete search string, optionally
/// starting from pos. Returns -1 if not found.
-static as_value
-string_last_index_of(const fn_call& fn)
+as_value
+string_lastIndexOf(const fn_call& fn)
{
boost::intrusive_ptr<as_object> obj = ensureType<as_object>(fn.this_ptr);
as_value val(fn.this_ptr);
@@ -460,8 +494,8 @@
// <start> is returned.
// If start is more than string length or length is 0, empty string is
returned.
// If length is negative, the substring is taken from the *end* of the string.
-static as_value
-string_sub_str(const fn_call& fn)
+as_value
+string_substr(const fn_call& fn)
{
boost::intrusive_ptr<as_object> obj = ensureType<as_object>(fn.this_ptr);
as_value val(fn.this_ptr);
@@ -500,8 +534,8 @@
// The values are *then* swapped if end is before start.
// Valid values for the start position are up to string
// length - 1.
-static as_value
-string_sub_string(const fn_call& fn)
+as_value
+string_substring(const fn_call& fn)
{
boost::intrusive_ptr<as_object> obj = ensureType<as_object>(fn.this_ptr);
as_value val(fn.this_ptr);
@@ -552,8 +586,8 @@
return as_value(utf8::encodeCanonicalString(wstr.substr(start, end),
version));
}
-static as_value
-string_index_of(const fn_call& fn)
+as_value
+string_indexOf(const fn_call& fn)
{
boost::intrusive_ptr<as_object> obj = ensureType<as_object>(fn.this_ptr);
as_value val(fn.this_ptr);
@@ -602,8 +636,8 @@
// String.fromCharCode(code1[, code2[, code3[, code4[, ...]]]])
// Makes a string out of any number of char codes.
// The string is always UTF8, so SWF5 mangles it.
-static as_value
-string_from_char_code(const fn_call& fn)
+as_value
+string_fromCharCode(const fn_call& fn)
{
boost::intrusive_ptr<as_object> obj = ensureType<as_object>(fn.this_ptr);
@@ -644,8 +678,8 @@
}
-static as_value
-string_char_code_at(const fn_call& fn)
+as_value
+string_charCodeAt(const fn_call& fn)
{
boost::intrusive_ptr<as_object> obj = ensureType<as_object>(fn.this_ptr);
as_value val(fn.this_ptr);
@@ -682,8 +716,8 @@
return as_value(wstr.at(index));
}
-static as_value
-string_char_at(const fn_call& fn)
+as_value
+string_charAt(const fn_call& fn)
{
boost::intrusive_ptr<as_object> obj = ensureType<as_object>(fn.this_ptr);
as_value val(fn.this_ptr);
@@ -718,8 +752,8 @@
return as_value("");
}
-static as_value
-string_to_upper_case(const fn_call& fn)
+as_value
+string_toUpperCase(const fn_call& fn)
{
boost::intrusive_ptr<as_object> obj = ensureType<as_object>(fn.this_ptr);
as_value val(fn.this_ptr);
@@ -756,8 +790,8 @@
}
-static as_value
-string_to_lower_case(const fn_call& fn)
+as_value
+string_toLowerCase(const fn_call& fn)
{
boost::intrusive_ptr<as_object> obj = ensureType<as_object>(fn.this_ptr);
as_value val(fn.this_ptr);
@@ -793,7 +827,7 @@
return as_value(utf8::encodeCanonicalString(wstr, version));
}
-static as_value
+as_value
string_oldToLower(const fn_call& fn)
{
boost::intrusive_ptr<as_object> obj = ensureType<as_object>(fn.this_ptr);
@@ -806,7 +840,7 @@
}
-static as_value
+as_value
string_oldToUpper(const fn_call& fn)
{
boost::intrusive_ptr<as_object> obj = ensureType<as_object>(fn.this_ptr);
@@ -819,8 +853,8 @@
}
-static as_value
-string_to_string(const fn_call& fn)
+as_value
+string_toString(const fn_call& fn)
{
boost::intrusive_ptr<String_as> obj
= ensureType<String_as>(fn.this_ptr);
@@ -828,7 +862,7 @@
}
-static as_value
+as_value
string_ctor(const fn_call& fn)
{
std::string str;
@@ -848,7 +882,7 @@
return as_value(obj.get());
}
-static boost::intrusive_ptr<builtin_function>
+boost::intrusive_ptr<builtin_function>
getStringConstructor()
{
// This is going to be the global String "class"/"function"
@@ -857,79 +891,62 @@
if ( cl == NULL )
{
- VM& vm = VM::get();
+ VM& vm = VM::get();
cl=new builtin_function(&string_ctor, getStringInterface());
- vm.addStatic(cl.get());
+ vm.addStatic(cl.get());
- // ASnative(251, 14) - [String] fromCharCode
- vm.registerNative(string_from_char_code, 251, 14);
- cl->init_member("fromCharCode", vm.getNative(251, 14));
+ // ASnative(251, 14) - [String] fromCharCode
+ vm.registerNative(string_fromCharCode, 251, 14);
+ cl->init_member("fromCharCode", vm.getNative(251, 14));
}
return cl;
}
-// extern (used by Global.cpp)
-void string_class_init(as_object& global)
-{
- // This is going to be the global String "class"/"function"
- boost::intrusive_ptr<builtin_function> cl = getStringConstructor();
-
- // Register _global.String (should be only visible from SWF5 up)
- // TODO: register as ASnative(251, 0)
- // TODO: register as ASnative(3, 0) for SWF5 ?
- int flags = as_prop_flags::dontEnum; // |as_prop_flags::onlySWF5Up;
- global.init_member("String", cl.get(), flags);
-}
-
-boost::intrusive_ptr<as_object>
-init_string_instance(const std::string& val)
-{
- // TODO: get VM from the environment ?
- VM& vm = VM::get();
-
- // TODO: get the environment passed in !!
- as_environment env(vm);
-
- int swfVersion = vm.getSWFVersion();
-
- boost::intrusive_ptr<as_function> cl;
-
- if ( swfVersion < 6 )
- {
- cl = getStringConstructor();
- }
- else
- {
- as_object* global = vm.getGlobal();
- as_value clval;
- if ( ! global->get_member(NSV::CLASS_STRING, &clval) )
- {
- log_debug("UNTESTED: String instantiation requested but
_global doesn't contain a 'String' symbol. Returning the NULL object.");
- return cl;
- //cl = getStringConstructor();
- }
- else if ( ! clval.is_function() )
- {
- log_debug("UNTESTED: String instantiation requested but
_global.String is not a function (%s). Returning the NULL object.",
- clval);
- return cl;
- //cl = getStringConstructor();
- }
- else
- {
- cl = clval.to_as_function();
- assert(cl);
- }
- }
-
- std::auto_ptr< std::vector<as_value> > args ( new std::vector<as_value>
);
- args->push_back(val);
- boost::intrusive_ptr<as_object> ret = cl->constructInstance(env, args);
-
- return ret;
-}
-
+
+/// Check the number of arguments, returning false if there
+/// aren't enough, or true if there are either enough or too many.
+/// Logs an error if the number isn't between min and max.
+inline bool checkArgs(const fn_call& fn, size_t min, size_t max,
+ const std::string& function)
+{
+
+ if (fn.nargs < min) {
+ IF_VERBOSE_ASCODING_ERRORS(
+ std::ostringstream os;
+ fn.dump_args(os);
+ log_aserror(_("%1%(%2%) needs %3% argument(s)"),
+ function, os.str(), min);
+ )
+ return false;
+ }
+
+ IF_VERBOSE_ASCODING_ERRORS(
+ if (fn.nargs > max)
+ {
+ std::ostringstream os;
+ fn.dump_args(os);
+ log_aserror(_("%1%(%2%) has more than %3% argument(s)"),
+ function, os.str(), max);
+ }
+ );
+ return true;
+}
+
+size_t
+validIndex(const std::wstring& subject, int index)
+{
+
+ if (index < 0) {
+ index = subject.size() + index;
+ }
+
+ index = utility::clamp<int>(index, 0, subject.size());
+
+ return index;
+}
+
+} // anonymous namespace
} // namespace gnash
=== modified file 'libcore/asobj/String_as.h'
--- a/libcore/asobj/String_as.h 2008-07-21 09:56:09 +0000
+++ b/libcore/asobj/String_as.h 2008-12-08 14:05:33 +0000
@@ -20,9 +20,7 @@
#ifndef GNASH_STRING_H
#define GNASH_STRING_H
-#include "smart_ptr.h"
-
-#include <memory> // for auto_ptr
+#include <string>
namespace gnash {
=== modified file 'libcore/asobj/XMLNode_as.h'
--- a/libcore/asobj/XMLNode_as.h 2008-12-08 08:30:13 +0000
+++ b/libcore/asobj/XMLNode_as.h 2008-12-08 13:22:29 +0000
@@ -37,53 +37,29 @@
/// This is also the base class for the XML actionscript class (see
/// XML_as.cpp, XML_as.h). Because XML_as also inherits from LoadableObject,
/// this is a virtual base class.
-class XMLNode_as : public virtual as_object
+//
+/// Trivial copying and assignment are forbidden
+class XMLNode_as : public virtual as_object, boost::noncopyable
{
public:
enum NodeType {
-
- /// Element
Element = 1,
-
- /// Attribute
Attribute = 2,
-
- /// Text
Text = 3,
-
- /// CDATA section
Cdata = 4,
-
- /// Entity reference
EntityRef = 5,
-
- /// Entity
Entity = 6,
-
- /// Processing instruction
ProcInstr = 7,
-
- /// Comment
Comment = 8,
-
- /// Document
Document = 9,
-
- /// Document type
DocType = 10,
-
- /// Document fragment
DocFragment = 11,
-
- /// Notation
Notation = 12
-
};
XMLNode_as();
- XMLNode_as(const XMLNode_as &node, bool deep);
virtual ~XMLNode_as();
// Initialize the global XMLNode class
@@ -148,22 +124,6 @@
Children& childNodes() { return _children; }
- XMLNode_as& operator = (XMLNode_as &node) {
- log_debug("%s: \n", __PRETTY_FUNCTION__);
- if (this == &node) return *this;
- _name = node._name;
- _value = node._value;
- _children = node._children;
- _attributes = node._attributes;
- return *this;
- }
-
- XMLNode_as& operator = (XMLNode_as *node)
- {
- assert(node);
- return (*this = *node);
- }
-
XMLNode_as* previousSibling();
XMLNode_as* nextSibling();
@@ -187,13 +147,18 @@
/// node is placed in the new tree structure after it is removed from
/// its existing parent node.
///
- /// @param childNode
- /// same as XMLNode_as::obj ?
- ///
+ /// @param childNode The XMLNode_as object to append as a child.
void appendChild(boost::intrusive_ptr<XMLNode_as> childNode);
- void setParent(XMLNode_as *node) { _parent = node; };
- XMLNode_as *getParent() { return _parent.get(); };
+ /// Set the parent XMLNode_as of this node.
+ //
+ /// @param node The new parent of this node. May be 0.
+ void setParent(XMLNode_as* node) { _parent = node; }
+
+ /// Get the parent XMLNode_as of this node. Can be 0.
+ XMLNode_as *getParent() const {
+ return _parent.get();
+ }
/// Insert a node before a node
//
@@ -216,10 +181,6 @@
/// Removes the specified XML object from its parent.
//
/// Also deletes all descendants of the node.
- /// Make sure to keep an intrusive_ptr against
- /// this instance during operation or the ref-counting
- /// management might destroy it.
- ///
void removeNode();
/// Convert the XMLNode to a string
@@ -230,10 +191,18 @@
/// for XML.sendAndLoad.
virtual void toString(std::ostream& str, bool encode = false) const;
+ /// Return the attributes object associated with this node.
as_object* getAttributes() { return _attributes; }
+ /// Return a read-only version of this node's attributes object.
const as_object* getAttributes() const { return _attributes; }
+ /// Set a named attribute to a value.
+ //
+ /// @param name The name of the attribute to set. If already present,
+ /// the value is changed. If not present, the attribute is
+ /// added.
+ /// @param value The value to set the named attribute to.
void setAttribute(const std::string& name, const std::string& value);
protected:
@@ -253,6 +222,9 @@
private:
+ /// A non-trivial copy-constructor for cloning nodes.
+ XMLNode_as(const XMLNode_as &node, bool deep);
+
boost::intrusive_ptr<XMLNode_as> _parent;
as_object* _attributes;
=== modified file 'testsuite/actionscript.all/Object.as'
--- a/testsuite/actionscript.all/Object.as 2008-10-31 12:04:41 +0000
+++ b/testsuite/actionscript.all/Object.as 2008-12-08 15:58:46 +0000
@@ -341,11 +341,37 @@
function target_get() { _root.target_get_calls++; return this._target; }
function target_set(v) { this._target=v; _root.target_set_calls++; }
target_get_calls=target_set_calls=0;
-o.addProperty("_target", target_get, target_set);
+ret = o.addProperty("_target", target_get, target_set);
+check_equals(ret, true);
check_equals(_root.target_get_calls, 0);
check_equals(_root.target_set_calls, 0);
check_equals(typeof(o._target), "undefined"); // native getter-setter don't
get initialized with underlying value
+// Check return value.
+ret = o.addProperty("", target_get, target_get);
+check_equals(ret, false);
+
+ret = o.addProperty("frog", 7, target_get);
+check_equals(ret, false);
+
+ret = o.addProperty("frog", "string", target_get);
+check_equals(ret, false);
+
+ret = o.addProperty("frog", target_get, target_get);
+check_equals(ret, true);
+
+ret = o.addProperty("frog", target_get, target_get);
+check_equals(ret, true);
+
+ret = o.addProperty("frog", target_get, undefined);
+check_equals(ret, false);
+
+ret = o.addProperty("frog", target_get, null);
+check_equals(ret, true);
+
+ret = o.addProperty("frog", target_get, null, "extra arg");
+check_equals(ret, true);
+
// Try property inheritance
var proto = new Object();
@@ -880,6 +906,6 @@
#endif
#if OUTPUT_VERSION >= 6
-totals(276);
+totals(285);
#endif
=== modified file 'testsuite/swfdec/PASSING'
--- a/testsuite/swfdec/PASSING 2008-12-08 07:35:55 +0000
+++ b/testsuite/swfdec/PASSING 2008-12-08 14:05:33 +0000
@@ -1015,6 +1015,9 @@
string-equals-old-6.swf:844e29987eed887d1544e1fbe6f60fa7
string-equals-old-7.swf:bdcdb87e9b4458b6935e97f4f2714bf3
string-equals-old-8.swf:3d1bb9216c301b464060f39b2be1eb41
+string-fake-5.swf:bb9f63e0726197e7ed3fc318f30acd1c
+string-fake-6.swf:586770ef07ba221bf025ba2dc182d352
+string-fake-7.swf:905bc581e468d939900f55564f82a8fc
string-greater-5.swf:65006df9c02e79df2da9cc21307b7438
string-greater-6.swf:7be0cfe46fbe3cb5275a2291b7606d8d
string-greater-7.swf:939e14e917b0f0cce6bd7b2dd69c1c7f
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] /srv/bzr/gnash/trunk r10398: Drop some return values, note why others are useless.,
Benjamin Wolsey <=