[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: |
Thu, 26 Oct 2006 22:32:19 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Sandro Santilli <strk> 06/10/26 22:32:19
Modified files:
. : ChangeLog
server : PropertyList.cpp PropertyList.h as_object.h
testsuite/server: PropertyListTest.cpp
Removed files:
server : as_member.h
Log message:
* server/PropertyList.{cpp,h}: changed container to store
pointers to the new polymorphic Property class; added pointer
to as_object owner for calls to getter/setter properties.
* testsuite/server/PropertyListTest.cpp: fixed test to work
with new interface (requirement for an as_object in ctor)
* server/as_object.h: fix constructors to properly initialize
the PropertyList.
* server/as_member.h: removed, as obsoleted
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.1409&r2=1.1410
http://cvs.savannah.gnu.org/viewcvs/gnash/server/PropertyList.cpp?cvsroot=gnash&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/gnash/server/PropertyList.h?cvsroot=gnash&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/gnash/server/as_object.h?cvsroot=gnash&r1=1.14&r2=1.15
http://cvs.savannah.gnu.org/viewcvs/gnash/server/as_member.h?cvsroot=gnash&r1=1.2&r2=0
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/server/PropertyListTest.cpp?cvsroot=gnash&r1=1.1&r2=1.2
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.1409
retrieving revision 1.1410
diff -u -b -r1.1409 -r1.1410
--- ChangeLog 26 Oct 2006 22:29:15 -0000 1.1409
+++ ChangeLog 26 Oct 2006 22:32:19 -0000 1.1410
@@ -5,6 +5,14 @@
the implementation file with use of const_cast<>)
* server/: Makefile.am, Property.h: new class for properties,
obsoletes as_member.
+ * server/PropertyList.{cpp,h}: changed container to store
+ pointers to the new polymorphic Property class; added pointer
+ to as_object owner for calls to getter/setter properties.
+ * testsuite/server/PropertyListTest.cpp: fixed test to work
+ with new interface (requirement for an as_object in ctor)
+ * server/as_object.h: fix constructors to properly initialize
+ the PropertyList.
+ * server/as_member.h: removed, as obsoleted
2006-10-26 Markus Gothe <address@hidden>
Index: server/PropertyList.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/PropertyList.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- server/PropertyList.cpp 26 Oct 2006 20:49:28 -0000 1.2
+++ server/PropertyList.cpp 26 Oct 2006 22:32:19 -0000 1.3
@@ -41,6 +41,8 @@
#endif
#include "PropertyList.h"
+#include "Property.h"
+
#include "log.h"
@@ -50,11 +52,19 @@
namespace gnash {
-//PropertyList::PropertyList(as_object& owner)
-// :
-// _owner(owner)
-//{
-//}
+PropertyList::PropertyList(as_object& owner)
+ :
+ _owner(&owner)
+{
+}
+
+PropertyList::PropertyList(const PropertyList& pl, as_object& new_owner)
+ :
+ _props(pl._props),
+ _owner(&new_owner)
+{
+}
+
bool
@@ -66,7 +76,7 @@
return false;
}
- val=found->second.get_member_value();
+ val=found->second->getValue(_owner);
//log_msg("Property %s found, assigning to return (%s)", key.c_str(),
val.to_string());
@@ -80,20 +90,20 @@
if ( found == _props.end() )
{
// create a new member
- _props[key] = as_member(val);
+ _props[key] = new SimpleProperty(val);
return true;
}
- as_member& member = found->second;
+ Property* prop = found->second;
- if ( member.is_read_only() )
+ if ( prop->isReadOnly() )
{
log_warning("Property %s is read-only, not setting it",
key.c_str());
return false;
}
//log_msg("Property %s set to value %s", key.c_str(), val.to_string());
- member.set_member_value(val);
+ prop->setValue(_owner, val);
return true;
}
@@ -104,9 +114,9 @@
iterator found = _props.find( key );
if ( found == _props.end() ) return false;
- as_member& member = found->second;
+ Property* prop = found->second;
- as_prop_flags& f = member.get_member_flags();
+ as_prop_flags& f = prop->getFlags();
return f.set_flags(setFlags, clearFlags);
}
@@ -118,8 +128,8 @@
for ( iterator it=_props.begin(), far=_props.end(); it != far; ++it)
{
- as_member& member = it->second;
- as_prop_flags& f = member.get_member_flags();
+ Property* prop = it->second;
+ as_prop_flags& f = prop->getFlags();
if ( f.set_flags(setFlags, clearFlags) ) ++success;
else ++failure;
}
@@ -134,7 +144,7 @@
size_t success=0;
size_t failure=0;
- for (const_iterator it = begin(), itEnd = end(); it != itEnd; ++it )
+ for (const_iterator it = props.begin(), itEnd = props.end(); it !=
itEnd; ++it )
{
const std::string& name = it->first;
@@ -151,9 +161,9 @@
{
for ( const_iterator i=begin(), ie=end(); i != ie; ++i)
{
- const as_member& member = i->second;
+ const Property* prop = i->second;
- if ( member.get_member_flags().get_dont_enum() ) continue;
+ if ( prop->getFlags().get_dont_enum() ) continue;
env.push(as_value(i->first.c_str()));
}
@@ -165,7 +175,7 @@
for ( const_iterator it=begin(), itEnd=end(); it != itEnd; ++it )
{
log_msg(" %s: %s", it->first.c_str(),
- it->second.get_member_value().to_string());
+ it->second->getValue(_owner).to_string());
}
}
@@ -175,13 +185,39 @@
for (const_iterator it = o.begin(), itEnd = o.end(); it != itEnd; ++it)
{
const std::string& name = it->first;
- const as_member& member = it->second;
+ const Property* prop = it->second;
// TODO: don't call get_member_value, we
// must copy also 'getset' members ...
- setValue(name, member.get_member_value());
+ _props[name] = prop->clone();
+ //setValue(name, prop.getValue());
}
}
+bool
+PropertyList::addGetterSetter(const std::string& key, as_function& getter,
+ as_function& setter)
+{
+ iterator found = _props.find( key );
+ if ( found != _props.end() ) return false; // already exists !!
+
+ _props[key] = new GetterSetterProperty(GetterSetter(getter, setter));
+ return true;
+}
+
+void
+PropertyList::clear()
+{
+ for (iterator it = begin(), itEnd = end(); it != itEnd; ++it)
+ delete it->second;
+ _props.clear();
+}
+
+PropertyList::~PropertyList()
+{
+ for (iterator it = begin(), itEnd = end(); it != itEnd; ++it)
+ delete it->second;
+}
+
} // end of gnash namespace
Index: server/PropertyList.h
===================================================================
RCS file: /sources/gnash/gnash/server/PropertyList.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- server/PropertyList.h 26 Oct 2006 14:45:28 -0000 1.1
+++ server/PropertyList.h 26 Oct 2006 22:32:19 -0000 1.2
@@ -42,16 +42,18 @@
#include "config.h"
#endif
-#include "as_member.h" // for use within map
-
#include <map>
#include <string> // for use within map and for StringNoCaseLessThen
+#include <cassert> // for inlines
+
// Forward declaration
namespace gnash {
class as_object;
class as_environment;
class as_function;
+ class as_value;
+ class Property;
}
namespace gnash {
@@ -93,13 +95,19 @@
private:
+ /// The actual container
+ //
+ /// We store Property objects by pointer to allow polymorphism
+ /// so that we can store either SimpleProperty or GetterSetterProperty
+ /// the destructor will take care of deleting all elements.
+ ///
/// TODO: change this to a <boost/ptr_container/ptr_map.hpp>
/// so we can store as_member by pointer allowing polymorphism
/// of it (planning to add a getset_as_member) w/out much
/// overhead and with manager ownerhips. See:
/// http://www.boost.org/libs/ptr_container/doc/ptr_container.html
///
- typedef std::map<std::string, as_member, StringNoCaseLessThen>
container;
+ typedef std::map<std::string, Property*, StringNoCaseLessThen>
container;
typedef container::iterator iterator;
typedef container::const_iterator const_iterator;
typedef container::reverse_iterator reverse_iterator;
@@ -109,7 +117,7 @@
// this will be used to setup environemnt for
// getter-setter properties
- //as_object& _owner;
+ as_object* _owner;
iterator find(const std::string& key) {
return _props.find(key);
@@ -130,12 +138,51 @@
return _props.begin();
}
+ /// Implicit copy forbidden
+ //
+ /// Don't allow simple copy as we want to avoid
+ /// multiple PropertyLists having a reference to
+ /// the same as_object unless developer really
+ /// intends to do so.
+ /// Rather use the constructor taking a PropertyList
+ /// and a new as_object
+ PropertyList(const PropertyList&) {assert(0);}
+
+ /// Implicit copy forbidden
+ //
+ /// Don't allow simple copy as we want to avoid
+ /// multiple PropertyLists having a reference to
+ /// the same as_object unless developer really
+ /// intends to do so.
+ /// Rather use the constructor taking a PropertyList
+ /// and a new as_object
+ PropertyList& operator==(const PropertyList&) {assert(0); return *this;}
public:
- //PropertyList(as_object& owner);
+ /// Construct the PropertyList associated with an object
+ //
+ /// The as_object (owner) will be used to set the 'this' pointer
+ /// for calling getter/setter function (GetterSetterProperty);
+ /// it will be unused when getting or setting SimpleProperty
+ /// properties.
+ PropertyList(as_object& owner);
+
+ /// Construct a copy with a new owner
+ //
+ /// This is to make sure there's a single PropertyList
+ /// for each owner, which is the whole reason for this class
+ /// to exist (a single lookup table for object properties)
+ ///
+ PropertyList(const PropertyList& pl, as_object& new_owner);
+
+ /// Delete all Property objects in the container
+ ~PropertyList();
/// Get the as_value value of a named property
//
+ /// If the named property is a getter/setter one it's getter
+ /// will be invoked using this instance's _owner as 'this' pointer.
+ ///
/// @param key
/// name of the property. search will be case-insensitive
///
@@ -151,6 +198,10 @@
/// Set the value of a property, creating a new one if unexistent.
//
+ /// If the named property is a getter/setter one it's setter
+ /// will be invoked using this instance's _owner as 'this' pointer.
+ /// If the property is not found a SimpleProperty will be created.
+ ///
/// @param key
/// name of the property. search will be case-insensitive
///
@@ -182,7 +233,7 @@
/// otherwise (property already existent?)
///
bool addGetterSetter(const std::string& key, as_function& getter,
- as_function& setter) { assert(0); }
+ as_function& setter);
/// Set the flags of a property.
//
@@ -255,11 +306,9 @@
void enumerateValues(as_environment& env) const;
/// Remove all entries in the container
- void clear()
- {
- _props.clear();
- }
+ void clear();
+ /// Return number of properties in this list
size_t size() const
{
return _props.size();
Index: server/as_object.h
===================================================================
RCS file: /sources/gnash/gnash/server/as_object.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -b -r1.14 -r1.15
--- server/as_object.h 26 Oct 2006 14:45:28 -0000 1.14
+++ server/as_object.h 26 Oct 2006 22:32:19 -0000 1.15
@@ -69,6 +69,13 @@
/// Properties of this objects
PropertyList _members;
+ /// Don't allow implicit copy, must think about behaviour
+ as_object& operator==(const as_object&)
+ {
+ assert(0);
+ return *this;
+ }
+
public:
void dump_members() const;
@@ -80,7 +87,7 @@
/// Construct an ActionScript object with no prototype associated.
as_object()
:
- //_members(*this),
+ _members(*this),
m_prototype(NULL)
{
}
@@ -90,12 +97,21 @@
/// Adds a reference to the prototype, if any.
as_object(as_object* proto)
:
- //_members(*this),
+ _members(*this),
m_prototype(proto)
{
if (m_prototype) m_prototype->add_ref();
}
+ as_object(const as_object& other)
+ :
+ ref_counted(),
+ _members(other._members, *this),
+ m_prototype(other.m_prototype)
+ {
+ if (m_prototype) m_prototype->add_ref();
+ }
+
/// \brief
/// Default destructor for ActionScript objects.
/// Drops reference on prototype member, if any.
Index: testsuite/server/PropertyListTest.cpp
===================================================================
RCS file: /sources/gnash/gnash/testsuite/server/PropertyListTest.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- testsuite/server/PropertyListTest.cpp 26 Oct 2006 14:45:28 -0000
1.1
+++ testsuite/server/PropertyListTest.cpp 26 Oct 2006 22:32:19 -0000
1.2
@@ -35,6 +35,8 @@
//
#include "PropertyList.h"
+#include "as_object.h" // need to set as owner of PropertyList
+#include "as_value.h"
#include "dejagnu.h"
#include "log.h"
@@ -53,7 +55,8 @@
dbglogfile.setVerbosity();
- PropertyList props;
+ as_object obj;
+ PropertyList props(obj);
as_value val("value");
as_value val2("value2");
Index: server/as_member.h
===================================================================
RCS file: server/as_member.h
diff -N server/as_member.h
--- server/as_member.h 26 Oct 2006 10:32:07 -0000 1.2
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,91 +0,0 @@
-//
-// Copyright (C) 2005, 2006 Free Software Foundation, Inc.
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-// Linking Gnash statically or dynamically with other modules is making a
-// combined work based on Gnash. Thus, the terms and conditions of the GNU
-// General Public License cover the whole combination.
-//
-// As a special exception, the copyright holders of Gnash give you
-// permission to combine Gnash with free software programs or libraries
-// that are released under the GNU LGPL and with code included in any
-// release of Talkback distributed by the Mozilla Foundation. You may
-// copy and distribute such a system following the terms of the GNU GPL
-// for all but the LGPL-covered parts and Talkback, and following the
-// LGPL for the LGPL-covered parts.
-//
-// Note that people who make modified versions of Gnash are not obligated
-// to grant this special exception for their modified versions; it is their
-// choice whether to do so. The GNU General Public License gives permission
-// to release a modified version without this exception; this exception
-// also makes it possible to release a modified version which carries
-// forward this exception.
-//
-//
-
-#ifndef GNASH_AS_MEMBER_H
-#define GNASH_AS_MEMBER_H
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "as_value.h"
-#include "as_prop_flags.h"
-
-namespace gnash {
-
-
-/// Member for as_object: value + flags
-class as_member
-{
- /// value
- as_value m_value;
- /// Properties flags
- as_prop_flags m_flags;
-
-public:
- /// Default constructor
- as_member() {}
-
- /// Constructor
- as_member(const as_value &value,const as_prop_flags
flags=as_prop_flags())
- :
- m_value(value),
- m_flags(flags)
- {
- }
-
- /// accessor to the value
- as_value get_member_value() const { return m_value; }
-
- /// accessor to the properties flags
- const as_prop_flags& get_member_flags() const { return m_flags; }
- as_prop_flags& get_member_flags() { return m_flags; }
-
- /// set the value
- void set_member_value(const as_value &value) { m_value = value; }
-
- /// accessor to the properties flags
- void set_member_flags(const as_prop_flags &flags) { m_flags = flags; }
-
- /// is this a read-only member ?
- bool is_read_only() const { return m_flags.get_read_only(); }
-};
-
-
-} // namespace gnash
-
-#endif // GNASH_AS_MEMBER_H
- [Gnash-commit] gnash ChangeLog server/PropertyList.cpp server/...,
Sandro Santilli <=