[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ChangeLog server/PropertyList.cpp server/...
From: |
Sandro Santilli |
Subject: |
[Gnash-commit] gnash ChangeLog server/PropertyList.cpp server/... |
Date: |
Sun, 10 Dec 2006 18:39:22 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Sandro Santilli <strk> 06/12/10 18:39:22
Modified files:
. : ChangeLog
server : PropertyList.cpp PropertyList.h
as_environment.cpp as_object.cpp as_object.h
server/vm : ASHandlers.cpp
testsuite/actionscript.all: delete.as
testsuite/server: PropertyListTest.cpp
Log message:
* server/PropertyList.{h,cpp} (delProperty):
changed return type to std::pair<bool,bool>
to let caller know wheter delete failed because
the property was not found OR because it was
protected from deletion.
* server/as_object.{h,cpp} (delProperty): same
as with PropertyList: return std::pair<bool,bool>
with same semantic.
* server/as_environment.cpp (del_variable_raw):
don't keep scanning the 'with' stack if any object
actually had the given property defined, even if
protected from deletion.
* server/vm/ASHandlers.cpp: updated calls to
as_object::delProperty().
* testsuite/server/PropertyListTest.cpp: updated
calls to PropertyList::delProperty.
* testsuite/actionscript.all/delete.as: added test for
protected member deletion.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.1908&r2=1.1909
http://cvs.savannah.gnu.org/viewcvs/gnash/server/PropertyList.cpp?cvsroot=gnash&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/gnash/server/PropertyList.h?cvsroot=gnash&r1=1.8&r2=1.9
http://cvs.savannah.gnu.org/viewcvs/gnash/server/as_environment.cpp?cvsroot=gnash&r1=1.38&r2=1.39
http://cvs.savannah.gnu.org/viewcvs/gnash/server/as_object.cpp?cvsroot=gnash&r1=1.20&r2=1.21
http://cvs.savannah.gnu.org/viewcvs/gnash/server/as_object.h?cvsroot=gnash&r1=1.25&r2=1.26
http://cvs.savannah.gnu.org/viewcvs/gnash/server/vm/ASHandlers.cpp?cvsroot=gnash&r1=1.15&r2=1.16
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/actionscript.all/delete.as?cvsroot=gnash&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/server/PropertyListTest.cpp?cvsroot=gnash&r1=1.9&r2=1.10
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.1908
retrieving revision 1.1909
diff -u -b -r1.1908 -r1.1909
--- ChangeLog 9 Dec 2006 23:14:49 -0000 1.1908
+++ ChangeLog 10 Dec 2006 18:39:22 -0000 1.1909
@@ -1,3 +1,24 @@
+2006-12-10 Sandro Santilli <address@hidden>
+
+ * server/PropertyList.{h,cpp} (delProperty):
+ changed return type to std::pair<bool,bool>
+ to let caller know wheter delete failed because
+ the property was not found OR because it was
+ protected from deletion.
+ * server/as_object.{h,cpp} (delProperty): same
+ as with PropertyList: return std::pair<bool,bool>
+ with same semantic.
+ * server/as_environment.cpp (del_variable_raw):
+ don't keep scanning the 'with' stack if any object
+ actually had the given property defined, even if
+ protected from deletion.
+ * server/vm/ASHandlers.cpp: updated calls to
+ as_object::delProperty().
+ * testsuite/server/PropertyListTest.cpp: updated
+ calls to PropertyList::delProperty.
+ * testsuite/actionscript.all/delete.as: added test for
+ protected member deletion.
+
2006-12-09 Sandro Santilli <address@hidden>
* server/button_character_instance.{cpp,h}: added missing
Index: server/PropertyList.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/PropertyList.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- server/PropertyList.cpp 8 Dec 2006 15:50:11 -0000 1.6
+++ server/PropertyList.cpp 10 Dec 2006 18:39:22 -0000 1.7
@@ -32,6 +32,8 @@
#include "as_environment.h" // for enumerateValues
#include "as_value.h" // for enumerateValues
+#include <utility> // for std::make_pair
+
namespace gnash {
PropertyList::PropertyList()
@@ -132,17 +134,20 @@
return it->second;
}
-bool
+std::pair<bool,bool>
PropertyList::delProperty(const std::string& key)
{
iterator it=find(key);
- if ( it == end() ) return false;
+ if ( it == end() ) return std::make_pair(false,false);
// check if member is protected from deletion
- if ( it->second->getFlags().get_dont_delete() ) return false;
+ if ( it->second->getFlags().get_dont_delete() )
+ {
+ return std::make_pair(true,false);
+ }
_props.erase(it);
- return true;
+ return std::make_pair(true,true);
}
std::pair<size_t,size_t>
Index: server/PropertyList.h
===================================================================
RCS file: /sources/gnash/gnash/server/PropertyList.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- server/PropertyList.h 8 Dec 2006 15:50:11 -0000 1.8
+++ server/PropertyList.h 10 Dec 2006 18:39:22 -0000 1.9
@@ -28,6 +28,7 @@
#include <string> // for use within map
#include <cassert> // for inlines
#include <cctype> // for toupper
+#include <utility> // for std::pair
// Forward declaration
namespace gnash {
@@ -177,11 +178,15 @@
/// @param key
/// Name of the property. Search is case-*sensitive*
///
- /// @return true if the property was deleted, false otherwise.
- /// A false return might mean either that the property
- /// was not found or that it was protected from deletion.
+ /// @return a pair of boolean values expressing whether the property
+ /// was found (first) and whether it was deleted (second).
+ /// Of course a pair(false, true) would be invalid (deleted
+ /// a non-found property!?). Valid returns are:
+ /// - (false, false) : property not found
+ /// - (true, false) : property protected from deletion
+ /// - (true, true) : property successfully deleted
///
- bool delProperty(const std::string& key);
+ std::pair<bool,bool> delProperty(const std::string& key);
/// \brief
/// Add a getter/setter property, if not already existing
Index: server/as_environment.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/as_environment.cpp,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -b -r1.38 -r1.39
--- server/as_environment.cpp 9 Dec 2006 19:46:42 -0000 1.38
+++ server/as_environment.cpp 10 Dec 2006 18:39:22 -0000 1.39
@@ -16,7 +16,7 @@
//
-/* $Id: as_environment.cpp,v 1.38 2006/12/09 19:46:42 strk Exp $ */
+/* $Id: as_environment.cpp,v 1.39 2006/12/10 18:39:22 strk Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -31,6 +31,7 @@
#include "VM.h"
#include <string>
+#include <utility> // for std::pair
namespace gnash {
@@ -141,13 +142,16 @@
as_value val;
// Check the with-stack.
- for (size_t i = with_stack.size(); i > 0; --i) {
+ for (size_t i = with_stack.size(); i > 0; --i)
+ {
as_object* obj = with_stack[i-1].m_object.get();
- if (obj && obj->delProperty(varname)) {
- // TODO: this is surely wrong, we don't want to keep seeking
- // if a property is found probably, even if it's flags forbid
deletion
- // var is deletable in this context
- return true;
+ if (obj)
+ {
+ std::pair<bool,bool> ret = obj->delProperty(varname);
+ if (ret.first)
+ {
+ return ret.second;
+ }
}
}
@@ -163,15 +167,14 @@
}
// Try target
- if ( m_target->delProperty(varname) ) {
- // TODO: this is surely wrong, we don't want to keep seeking
- // if a property is found probably, even if it's flags forbid deletion
- // var is deletable in this context
- return true;
+ std::pair<bool,bool> ret = m_target->delProperty(varname);
+ if ( ret.first )
+ {
+ return ret.second;
}
// Try _global
- return VM::get().getGlobal()->delProperty(varname);
+ return VM::get().getGlobal()->delProperty(varname).second;
}
// varname must be a plain variable name; no path parsing.
Index: server/as_object.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/as_object.cpp,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -b -r1.20 -r1.21
--- server/as_object.cpp 8 Dec 2006 16:10:34 -0000 1.20
+++ server/as_object.cpp 10 Dec 2006 18:39:22 -0000 1.21
@@ -33,6 +33,7 @@
#include <set>
#include <string>
#include <boost/algorithm/string/case_conv.hpp>
+#include <utility> // for std::pair
namespace gnash {
@@ -381,7 +382,7 @@
if (m_prototype) m_prototype->drop_ref();
}
-bool
+std::pair<bool,bool>
as_object::delProperty(const std::string& name)
{
if ( _vm.getSWFVersion() < 7 )
Index: server/as_object.h
===================================================================
RCS file: /sources/gnash/gnash/server/as_object.h,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -b -r1.25 -r1.26
--- server/as_object.h 8 Dec 2006 16:10:34 -0000 1.25
+++ server/as_object.h 10 Dec 2006 18:39:22 -0000 1.26
@@ -31,6 +31,8 @@
#include "ref_counted.h" // for inheritance
#include "PropertyList.h"
+#include <utility> // for std::pair
+
// Forward declarations
namespace gnash {
class as_function;
@@ -157,20 +159,24 @@
///
virtual bool get_member(const tu_stringi& name, as_value* val);
- /// Delete a property of this object.
+ /// Delete a property of this object, unless protected from deletion.
//
- /// This function does *not* recurse in this object's
- /// prototype.
+ /// This function does *not* recurse in this object's prototype.
///
/// @parame name
/// Name of the property.
/// Case insensitive up to SWF6,
/// case *sensitive* from SWF7 up.
///
- /// @return true on success, false on failure
- /// (non-existent or protected member)
+ /// @return a pair of boolean values expressing whether the property
+ /// was found (first) and whether it was deleted (second).
+ /// Of course a pair(false, true) would be invalid (deleted
+ /// a non-found property!?). Valid returns are:
+ /// - (false, false) : property not found
+ /// - (true, false) : property protected from deletion
+ /// - (true, true) : property successfully deleted
///
- bool delProperty(const std::string& name);
+ std::pair<bool,bool> delProperty(const std::string& name);
/// Set member flags (probably used by ASSetPropFlags)
//
Index: server/vm/ASHandlers.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/vm/ASHandlers.cpp,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -b -r1.15 -r1.16
--- server/vm/ASHandlers.cpp 9 Dec 2006 19:24:47 -0000 1.15
+++ server/vm/ASHandlers.cpp 10 Dec 2006 18:39:22 -0000 1.16
@@ -16,7 +16,7 @@
//
-/* $Id: ASHandlers.cpp,v 1.15 2006/12/09 19:24:47 strk Exp $ */
+/* $Id: ASHandlers.cpp,v 1.16 2006/12/10 18:39:22 strk Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -52,6 +52,7 @@
#include <map>
#include <set>
#include <vector>
+#include <utility> // for std::pair
using namespace std;
@@ -2040,7 +2041,7 @@
as_object* obj = (as_object*) object.to_object();
bool ret;
if (obj) {
- ret = obj->delProperty(var.to_std_string());
+ ret = obj->delProperty(var.to_std_string()).second;
} else {
ret = thread.delVariable(var.to_std_string());
}
Index: testsuite/actionscript.all/delete.as
===================================================================
RCS file: /sources/gnash/gnash/testsuite/actionscript.all/delete.as,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- testsuite/actionscript.all/delete.as 9 Dec 2006 19:46:42 -0000
1.6
+++ testsuite/actionscript.all/delete.as 10 Dec 2006 18:39:22 -0000
1.7
@@ -1,4 +1,4 @@
-rcsid="$Id: delete.as,v 1.6 2006/12/09 19:46:42 strk Exp $";
+rcsid="$Id: delete.as,v 1.7 2006/12/10 18:39:22 strk Exp $";
#include "check.as"
@@ -8,15 +8,24 @@
check(anObject == undefined);
check(!delete noObject);
+//
+// Scoped delete (see bug #18482)
+//
+
var anotherObject = new Object();
check(anotherObject);
anotherObject.a = "anotherObject.a";
a = "a";
+b = "b";
_global.a = "_global.a";
-
+anotherObject.b = "anotherObject.b (protected)";
+ASSetPropFlags(anotherObject, "b", 2); // protect b
with(anotherObject)
{
check_equals(a, "anotherObject.a");
+ check_equals(b, "anotherObject.b (protected)");
+ check(!delete b); // protected from deletion !
+ check_equals(b, "anotherObject.b (protected)");
check(delete a);
check_equals(a, "a");
check(delete a);
@@ -25,3 +34,4 @@
check_equals(a, undefined);
check(!delete a);
}
+
Index: testsuite/server/PropertyListTest.cpp
===================================================================
RCS file: /sources/gnash/gnash/testsuite/server/PropertyListTest.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- testsuite/server/PropertyListTest.cpp 8 Dec 2006 15:50:11 -0000
1.9
+++ testsuite/server/PropertyListTest.cpp 10 Dec 2006 18:39:22 -0000
1.10
@@ -32,6 +32,7 @@
#include <sstream>
#include <cassert>
#include <string>
+#include <utility> // for make_pair
using namespace std;
using namespace gnash;
@@ -89,17 +90,19 @@
// Test deletion of properties
// this succeeds
- check(props.delProperty("var3"));
+ check(props.delProperty("var3").second);
check_equals(props.size(), 4);
// this fails (non existent property)
- check(!props.delProperty("non-existent"));
+ check(!props.delProperty("non-existent").first);
check_equals(props.size(), 4);
// Set property var2 as protected from deletion!
check(props.setFlags("var2", as_prop_flags::dontDelete, 0));
// this fails (protected from deletion)
- check(!props.delProperty("var2"));
+ std::pair<bool, bool> delpair = props.delProperty("var2");
+ check_equals(delpair.first, true); // property was found
+ check_equals(delpair.second, false); // property was NOT deleted
check_equals(props.size(), 4);
}