[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ChangeLog server/as_environment.cpp serve...
From: |
Sandro Santilli |
Subject: |
[Gnash-commit] gnash ChangeLog server/as_environment.cpp serve... |
Date: |
Wed, 24 Oct 2007 07:58:14 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Sandro Santilli <strk> 07/10/24 07:58:14
Modified files:
. : ChangeLog
server : as_environment.cpp as_object.cpp as_object.h
testsuite/actionscript.all: Object.as with.as
Log message:
* server/as_object.{cpp,h}: add update_member to only
update pre-existing members (including getter-setter
in the inheritance chain).
* server/as_environment.cpp (set_variable_raw): only
set members of elements in the scope stack if
pre-existing.
* testsuite/actionscript.all/: Object.as, with.as:
success for the new failing tests.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.4680&r2=1.4681
http://cvs.savannah.gnu.org/viewcvs/gnash/server/as_environment.cpp?cvsroot=gnash&r1=1.99&r2=1.100
http://cvs.savannah.gnu.org/viewcvs/gnash/server/as_object.cpp?cvsroot=gnash&r1=1.69&r2=1.70
http://cvs.savannah.gnu.org/viewcvs/gnash/server/as_object.h?cvsroot=gnash&r1=1.75&r2=1.76
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/actionscript.all/Object.as?cvsroot=gnash&r1=1.36&r2=1.37
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/actionscript.all/with.as?cvsroot=gnash&r1=1.32&r2=1.33
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.4680
retrieving revision 1.4681
diff -u -b -r1.4680 -r1.4681
--- ChangeLog 23 Oct 2007 21:53:10 -0000 1.4680
+++ ChangeLog 24 Oct 2007 07:58:13 -0000 1.4681
@@ -1,3 +1,14 @@
+2007-10-24 Sandro Santilli <address@hidden>
+
+ * server/as_object.{cpp,h}: add update_member to only
+ update pre-existing members (including getter-setter
+ in the inheritance chain).
+ * server/as_environment.cpp (set_variable_raw): only
+ set members of elements in the scope stack if
+ pre-existing.
+ * testsuite/actionscript.all/: Object.as, with.as:
+ success for the new failing tests.
+
2007-10-23 Sandro Santilli <address@hidden>
* configure.ac: abort if no supported GUI are selected.
Index: server/as_environment.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/as_environment.cpp,v
retrieving revision 1.99
retrieving revision 1.100
diff -u -b -r1.99 -r1.100
--- server/as_environment.cpp 17 Oct 2007 21:09:55 -0000 1.99
+++ server/as_environment.cpp 24 Oct 2007 07:58:14 -0000 1.100
@@ -17,7 +17,7 @@
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
-/* $Id: as_environment.cpp,v 1.99 2007/10/17 21:09:55 strk Exp $ */
+/* $Id: as_environment.cpp,v 1.100 2007/10/24 07:58:14 strk Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -310,13 +310,19 @@
{
// const_cast needed due to non-const as_object::get_member
as_object* obj = const_cast<as_object*>(scopeStack[i-1].get());
- as_value dummy;
- if (obj && obj->get_member(varkey, &dummy))
+ if (obj && obj->update_member(varkey, val).first )
{
- // This object has the member; so set it here.
+ return;
+#if 0
+ Property* prop = obj->findUpdatableProperty(varkey);
+ if ( prop )
+ {
+ //prop->setValue(*obj, val);
obj->set_member(varkey, val);
return;
}
+#endif
+ }
}
// Check locals for setting them
@@ -332,13 +338,19 @@
{
// const_cast needed due to non-const as_object::get_member
as_object* obj = const_cast<as_object*>(scopeStack[i-1].get());
- as_value dummy;
- if (obj && obj->get_member(varkey, &dummy))
+ if (obj && obj->update_member(varkey, val).first )
{
- // This object has the member; so set it here.
+ return;
+#if 0
+ Property* prop = obj->findUpdatableProperty(varkey);
+ if ( prop )
+ {
+ //prop->setValue(*obj, val);
obj->set_member(varkey, val);
return;
}
+#endif
+ }
}
}
Index: server/as_object.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/as_object.cpp,v
retrieving revision 1.69
retrieving revision 1.70
diff -u -b -r1.69 -r1.70
--- server/as_object.cpp 18 Oct 2007 11:47:54 -0000 1.69
+++ server/as_object.cpp 24 Oct 2007 07:58:14 -0000 1.70
@@ -207,6 +207,7 @@
return NULL;
}
+#if 0
/*private*/
Property*
as_object::findGetterSetter(string_table::key key, string_table::key nsname)
@@ -240,6 +241,42 @@
// No Getter/Setter property found
return NULL;
}
+#endif
+
+Property*
+as_object::findUpdatableProperty(string_table::key key, string_table::key
nsname)
+{
+ Property* prop = _members.getProperty(key, nsname);
+ if ( prop ) return prop;
+
+ // don't enter an infinite loop looking for __proto__ ...
+ if (key == NSV::PROP_uuPROTOuu)
+ {
+ Property* prop = _members.getProperty(key, nsname);
+ if ( prop ) return prop;
+ }
+
+ // this set will keep track of visited objects,
+ // to avoid infinite loops
+ std::set< as_object* > visited;
+ visited.insert(this);
+
+ boost::intrusive_ptr<as_object> obj = get_prototype();
+ while ( obj && visited.insert(obj.get()).second )
+ {
+ Property* prop = obj->_members.getProperty(key, nsname);
+ if ( prop && prop->isGetterSetter() )
+ {
+ // what if a property is found which is
+ // NOT a getter/setter ?
+ return prop;
+ }
+ obj = obj->get_prototype();
+ }
+
+ // No Getter/Setter property found in inheritance chain
+ return NULL;
+}
/*protected*/
void
@@ -268,7 +305,7 @@
string_table::key nsname)
{
//log_msg(_("set_member_default(%s)"), key.c_str());
- Property* prop = findProperty(key, nsname);
+ Property* prop = findUpdatableProperty(key, nsname);
if (prop)
{
if (prop->isReadOnly())
@@ -279,8 +316,8 @@
return;
}
- if (prop->isGetterSetter() || prop->isStatic())
- {
+ // TODO: add isStatic() check in findUpdatableProperty ?
+ //if (prop->isGetterSetter() || prop->isStatic()) {
try
{
prop->setValue(*this, val);
@@ -291,9 +328,13 @@
log_msg(_("%s: Exception %s. Will create a new
member"),
_vm.getStringTable().value(key).c_str(), exc.what());
}
- }
+ //}
+
+ return;
}
+ // Else, add new property...
+
// Property does not exist, so it won't be read-only. Set it.
if (!_members.setValue(key, const_cast<as_value&>(val), *this, nsname))
{
@@ -304,6 +345,42 @@
}
}
+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_msg(_("set_member_default(%s)"), key.c_str());
+ 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).c_str()););
+ return make_pair(true, false);
+ }
+
+ try
+ {
+ prop->setValue(*this, val);
+ return make_pair(true, true);
+ }
+ catch (ActionException& exc)
+ {
+ log_msg(_("%s: Exception %s. Will create a new member"),
+ _vm.getStringTable().value(key).c_str(),
exc.what());
+ }
+
+ return make_pair(true, false);
+ }
+
+ return make_pair(false, false);
+
+}
+
void
as_object::init_member(const std::string& key1, const as_value& val, int flags,
string_table::key nsname)
@@ -434,7 +511,6 @@
as_object::set_member_flags(string_table::key name,
int setTrue, int setFalse, string_table::key nsname)
{
- // TODO: accept a std::string directly
return _members.setFlags(name, setTrue, setFalse, nsname);
}
Index: server/as_object.h
===================================================================
RCS file: /sources/gnash/gnash/server/as_object.h,v
retrieving revision 1.75
retrieving revision 1.76
diff -u -b -r1.75 -r1.76
--- server/as_object.h 18 Oct 2007 11:47:54 -0000 1.75
+++ server/as_object.h 24 Oct 2007 07:58:14 -0000 1.76
@@ -90,12 +90,27 @@
return *this;
}
+#if 0
/// Look for a Getter/setter property scanning the inheritance chain
//
/// @returns a Getter/Setter propery if found, NULL if not found
///
+ /// TODO: drop this function, is unused
Property* findGetterSetter(string_table::key name,
string_table::key nsname = 0);
+#endif
+
+ /// Find an existing property for update, only scaning the inheritance
chain for getter/setters
+ /// or statics.
+ //
+ /// NOTE: updatable here doesn't mean the property isn't protected from
update
+ /// but only that a set_member will NOT create a new property
(either
+ /// completely new or as an override).
+ ///
+ /// @returns a propery if found, NULL if not found
+ ///
+ Property* findUpdatableProperty(string_table::key name,
+ string_table::key nsname = 0);
/// Find a property scanning the inheritance chain
///
@@ -199,20 +214,45 @@
/// NOTE: This might change in the near future trough use of
/// getter/setter properties instead..
///
- /// @param name
- /// Name of the property. Must be all lowercase
- /// if the current VM is initialized for a target
- /// up to SWF6.
+ /// @param key
+ /// Id of the property.
///
/// @param val
/// Value to assign to the named property.
///
- virtual void set_member(string_table::key name, const as_value& val,
+ /// @param nsname
+ /// Id of the namespace.
+ ///
+ virtual void set_member(string_table::key key, const as_value& val,
string_table::key nsname = 0)
{
- return set_member_default(name, val, nsname);
+ return set_member_default(key, val, nsname);
}
+ /// Update an existing member value
+ //
+ /// NOTE that getter-setter in the inheritance chaing are
+ /// considered as existing members. See with.as and Object.as
+ /// testcases under actionscript.all.
+ /// Also be aware that 'special' (non-proper) properties
+ /// are considered non-existing, this is surely true for
+ /// childs of MovieClips, also tested in with.as.
+ ///
+ /// @param key
+ /// Id of the property.
+ ///
+ /// @param val
+ /// Value to assign to the named property.
+ ///
+ /// @param nsname
+ /// Id of the namespace.
+ ///
+ /// @return a pair in which first element express wheter the
property01apl0mb
+ /// was found and the second wheter it was set (won't set if
read-only).
+ ///
+ std::pair<bool,bool> update_member(string_table::key key, const
as_value& val,
+ string_table::key nsname = 0);
+
#ifdef NEW_KEY_LISTENER_LIST_DESIGN
virtual bool on_event(const event_id& id );
#endif
Index: testsuite/actionscript.all/Object.as
===================================================================
RCS file: /sources/gnash/gnash/testsuite/actionscript.all/Object.as,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -b -r1.36 -r1.37
--- testsuite/actionscript.all/Object.as 23 Oct 2007 17:33:42 -0000
1.36
+++ testsuite/actionscript.all/Object.as 24 Oct 2007 07:58:14 -0000
1.37
@@ -20,7 +20,7 @@
// compile this test case with Ming makeswf, and then
// execute it like this gnash -1 -r 0 -v out.swf
-rcsid="$Id: Object.as,v 1.36 2007/10/23 17:33:42 strk Exp $";
+rcsid="$Id: Object.as,v 1.37 2007/10/24 07:58:14 strk Exp $";
#include "check.as"
@@ -299,8 +299,8 @@
check_equals(inh2.ogs, 5); // find inh2.ogs
check_equals(inh2.__proto__.ogs, 14); // find proto.ogs
inh2d.ogs = 54; // sets what ?
-xcheck_equals(inh2d._len, 54); // this._len ! So the getter-setter takes
precedence
-xcheck_equals(inh2d.ogs, 5); // does NOT override inh2.ogs normal member
+check_equals(inh2d._len, 54); // this._len ! So the getter-setter takes
precedence
+check_equals(inh2d.ogs, 5); // does NOT override inh2.ogs normal member
check_equals(inh2.ogs, 5); // find inh2.ogs
check_equals(inh2.__proto__.ogs, 14); // find proto.ogs
Index: testsuite/actionscript.all/with.as
===================================================================
RCS file: /sources/gnash/gnash/testsuite/actionscript.all/with.as,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -b -r1.32 -r1.33
--- testsuite/actionscript.all/with.as 23 Oct 2007 16:58:16 -0000 1.32
+++ testsuite/actionscript.all/with.as 24 Oct 2007 07:58:14 -0000 1.33
@@ -21,7 +21,7 @@
// compile this test case with Ming makeswf, and then
// execute it like this gnash -1 -r 0 -v out.swf
-rcsid="$Id: with.as,v 1.32 2007/10/23 16:58:16 strk Exp $";
+rcsid="$Id: with.as,v 1.33 2007/10/24 07:58:14 strk Exp $";
#include "check.as"
@@ -452,32 +452,32 @@
createEmptyMovieClip("mc", 1);
mc.createEmptyMovieClip("child", 1);
mc.mem = "mcMember";
-mc.hidden = "hidden";
-ASSetPropFlags(mc, "hidden", 4, 1);
+mc.nooverride = "nooverride";
+ASSetPropFlags(mc, "nooverride", 4, 1);
MovieClip.prototype.inheritedMem = "McProto";
with (mc)
{
child = "rootChild"; // non-proper in mc, will be set in root
mem = "mcMemberUpdated"; // overridable in mc, will be updated
- hidden = "hiddenUpdated"; // protected from override in mc, but
existing. Will NOT be set in _root
+ nooverride = "nooverrideUpdated"; // protected from override in mc, but
existing. Will NOT be set in _root
nonexistent = "nonExistent"; // non-existing in mc, will be set in root
inheritedMem = "McProtoOverridden"; // non own-property of mc, will be
set in root
check_equals(inheritedMem, "McProto");
check_equals(nonexistent, "nonExistent");
- check_equals(hidden, "hidden");
+ check_equals(nooverride, "nooverride");
check_equals(mem, "mcMemberUpdated");
check_equals(child._target, "/mc/child");
}
-xcheck_equals(inheritedMem, "McProtoOverridden");
-xcheck_equals(mc.inheritedMem, "McProto");
+check_equals(inheritedMem, "McProtoOverridden");
+check_equals(mc.inheritedMem, "McProto");
check_equals(nonexistent, 'nonExistent');
-check_equals(typeof(hidden), 'undefined');
-check_equals(mc.hidden, 'hidden');
+check_equals(typeof(nooverride), 'undefined');
+check_equals(mc.nooverride, 'nooverride');
check_equals(typeof(mem), 'undefined');
check_equals(mc.mem, "mcMemberUpdated");
-xcheck_equals(typeof(mc.child), 'movieclip');
-xcheck_equals(child, "rootChild");
+check_equals(typeof(mc.child), 'movieclip');
+check_equals(child, "rootChild");
#endif // OUTPUT_VERSION > 5
//---------------------------------------------------------