gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] gnash ChangeLog server/Property.h server/Proper...


From: Sandro Santilli
Subject: [Gnash-commit] gnash ChangeLog server/Property.h server/Proper...
Date: Fri, 27 Oct 2006 11:01:35 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  06/10/27 11:01:35

Modified files:
        .              : ChangeLog 
        server         : Property.h PropertyList.cpp PropertyList.h 
                         as_object.cpp as_object.h 
        testsuite/actionscript.all: Object.as 
        testsuite/server: PropertyListTest.cpp 

Log message:
                * server/Property.h: improved documentation, added 
isGetterSetter,
                  modified other methods to take as_object by *reference* (not
                  pointer, as we dont' accept NULLs).
                * testsuite/server/PropertyListTest.cpp: updated to match new
                  interface.
                * server/PropertyList.{h,cpp}: added getProperty(key) method;
                  removed "as_object" member and accepted it as an argument of
                  setValue/getValue: this allow for inherited properties (the 
"owner"
                  is not the object containing the property list when this is 
just
                  a prototype); fixed copy constructor to clone container 
elements,
                  implemented assigment operator, fixed clear() method to delete
                  container elements; tried to handle some const-correcness.
                  Will need a final cleanup and simplification pass.
                * server/as_object.{h,cpp}: added private findProperty() and
                  findGetterSetter() methods, for crawling the inheritance 
chain;
                  fixed set_member_default() to look for getter/setters in
                  the inheritance chain before falling back to "override" mode;
                  added doxygen comments.
                * testsuite/actionscript.all/Object.as: added Property 
inheritance
                  tests.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.1413&r2=1.1414
http://cvs.savannah.gnu.org/viewcvs/gnash/server/Property.h?cvsroot=gnash&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/gnash/server/PropertyList.cpp?cvsroot=gnash&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/gnash/server/PropertyList.h?cvsroot=gnash&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/gnash/server/as_object.cpp?cvsroot=gnash&r1=1.13&r2=1.14
http://cvs.savannah.gnu.org/viewcvs/gnash/server/as_object.h?cvsroot=gnash&r1=1.16&r2=1.17
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/actionscript.all/Object.as?cvsroot=gnash&r1=1.12&r2=1.13
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/server/PropertyListTest.cpp?cvsroot=gnash&r1=1.2&r2=1.3

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.1413
retrieving revision 1.1414
diff -u -b -r1.1413 -r1.1414
--- ChangeLog   27 Oct 2006 10:16:00 -0000      1.1413
+++ ChangeLog   27 Oct 2006 11:01:35 -0000      1.1414
@@ -1,4 +1,28 @@
+2006-10-27 Sandro Santilli <address@hidden>
+
+       * server/Property.h: improved documentation, added isGetterSetter,
+         modified other methods to take as_object by *reference* (not
+         pointer, as we dont' accept NULLs).
+       * testsuite/server/PropertyListTest.cpp: updated to match new
+         interface.
+        * server/PropertyList.{h,cpp}: added getProperty(key) method;
+         removed "as_object" member and accepted it as an argument of
+         setValue/getValue: this allow for inherited properties (the "owner"
+         is not the object containing the property list when this is just
+         a prototype); fixed copy constructor to clone container elements,
+         implemented assigment operator, fixed clear() method to delete
+         container elements; tried to handle some const-correcness.
+         Will need a final cleanup and simplification pass.
+        * server/as_object.{h,cpp}: added private findProperty() and
+         findGetterSetter() methods, for crawling the inheritance chain;
+         fixed set_member_default() to look for getter/setters in
+         the inheritance chain before falling back to "override" mode;
+         added doxygen comments.
+       * testsuite/actionscript.all/Object.as: added Property inheritance
+         tests.
+
 2006-10-27 Hannes Mayr <address@hidden>
+
        * gtk_glue_agg.cpp: Fixed rendering for screens with 8-bit and
                16-bit color depth.
 

Index: server/Property.h
===================================================================
RCS file: /sources/gnash/gnash/server/Property.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- server/Property.h   26 Oct 2006 22:27:22 -0000      1.1
+++ server/Property.h   27 Oct 2006 11:01:35 -0000      1.2
@@ -91,17 +91,49 @@
        const as_prop_flags& getFlags() const { return _flags; }
        as_prop_flags& getFlags() { return _flags; }
 
-       /// accessor to the value
-       virtual as_value getValue(as_object* this_ptr) const=0;
-
-       /// set the value
-       virtual void setValue(as_object* this_ptr, const as_value &value)=0;
+       /// Get value of this property
+       //
+       /// @param this_ptr
+       ///     The as_object used to set the 'this' pointer.
+       ///     for calling getter function (GetterSetterProperty);
+       ///     it will be unused when getting or setting SimpleProperty
+       ///     properties.
+       ///     This parameter is non-const as nothing prevents an
+       ///     eventual "Setter" function from actually modifying it,
+       ///     so we can't promise constness.
+       ///
+       /// @return the value of this property
+       ///
+       virtual as_value getValue(as_object& this_ptr) const=0;
+
+       /// Set value of this property
+       //
+       /// @param this_ptr
+       ///     The as_object used to set the 'this' pointer.
+       ///     for calling getter/setter function (GetterSetterProperty);
+       ///     it will be unused when getting or setting SimpleProperty
+       ///     properties.
+       ///     This parameter is non-const as nothing prevents an
+       ///     eventual "Setter" function from actually modifying it,
+       ///     so we can't promise constness.
+       ///
+       /// @param value
+       ///     The new value for this property. It will be used as first
+       ///     argument of the 'setter' function if this is a Getter/Setter
+       ///     property. @see isGetterSetter().
+       ///
+       /// TODO: have this function check for readOnly property...
+       ///
+       virtual void setValue(as_object& this_ptr, const as_value &value)=0;
 
        // clone this property
        virtual Property* clone() const=0;
        
        /// is this a read-only member ?
        bool isReadOnly() const { return _flags.get_read_only(); }
+
+       /// is this a Getter/Setter property ?
+       virtual bool isGetterSetter() const { return false; }
 };
 
 /// A simple property, consisting only of an as_value
@@ -145,10 +177,9 @@
 
        Property* clone() const { return new SimpleProperty(*this); }
 
-       as_value getValue(as_object*) const { return _value; }
+       as_value getValue(as_object&) const { return _value; }
 
-       /// set the value
-       void setValue(as_object*, const as_value &value)  { _value = value; }
+       void setValue(as_object&, const as_value &value)  { _value = value; }
 
 };
 
@@ -192,19 +223,21 @@
        Property* clone() const { return new GetterSetterProperty(*this); }
 
        /// Get the value (invokes the getter)
-       as_value getValue(as_object* this_ptr) const
+       as_value getValue(as_object& this_ptr) const
        {
                as_value ret;
-               _getset.getValue(this_ptr, ret);
+               _getset.getValue(&this_ptr, ret);
                return ret;
        }
 
        /// Set the value (invokes the setter)
-       void setValue(as_object* this_ptr, const as_value &value) 
+       void setValue(as_object& this_ptr, const as_value &value) 
        {
-               _getset.setValue(this_ptr, value);
+               _getset.setValue(&this_ptr, value);
        }
 
+       /// This *is* a Getter/Setter property !
+       virtual bool isGetterSetter() const { return true; }
 };
 
 

Index: server/PropertyList.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/PropertyList.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- server/PropertyList.cpp     26 Oct 2006 22:32:19 -0000      1.3
+++ server/PropertyList.cpp     27 Oct 2006 11:01:35 -0000      1.4
@@ -52,23 +52,27 @@
 
 namespace gnash {
 
-PropertyList::PropertyList(as_object& owner)
-       :
-       _owner(&owner)
+PropertyList::PropertyList()
 {
 }
 
-PropertyList::PropertyList(const PropertyList& pl, as_object& new_owner)
-       :
-       _props(pl._props),
-       _owner(&new_owner)
+PropertyList::PropertyList(const PropertyList& pl)
 {
+       import(pl);
+}
+
+PropertyList&
+PropertyList::operator==(const PropertyList& pl)
+{
+       if ( this != &pl ) import(pl);
+       return *this;
 }
 
 
 
 bool
-PropertyList::getValue(const std::string& key, as_value& val) const
+PropertyList::getValue(const std::string& key, as_value& val,
+               as_object& this_ptr) 
 {
        const_iterator found = _props.find( key );
        if ( found == _props.end() )
@@ -76,7 +80,7 @@
                return false;
        }
 
-       val=found->second->getValue(_owner);
+       val=found->second->getValue(this_ptr);
 
        //log_msg("Property %s found, assigning to return (%s)", key.c_str(), 
val.to_string());
 
@@ -84,7 +88,8 @@
 }
 
 bool
-PropertyList::setValue(const std::string& key, const as_value& val) 
+PropertyList::setValue(const std::string& key, const as_value& val,
+               as_object& this_ptr)
 {
        iterator found = _props.find( key );
        if ( found == _props.end() )
@@ -103,7 +108,7 @@
        }
 
        //log_msg("Property %s set to value %s", key.c_str(), val.to_string());
-       prop->setValue(_owner, val);
+       prop->setValue(this_ptr, val);
        return true;
 }
 
@@ -137,6 +142,14 @@
        return std::make_pair(success,failure);
 }
 
+Property*
+PropertyList::getProperty(const std::string& key)
+{
+       iterator it=find(key);
+       if ( it == end() ) return NULL;
+       return it->second;
+}
+
 std::pair<size_t,size_t>
 PropertyList::setFlagsAll(const PropertyList& props,
                int flagsSet, int flagsClear)
@@ -170,12 +183,12 @@
 }
 
 void
-PropertyList::dump() const
+PropertyList::dump(as_object& this_ptr)
 {
        for ( const_iterator it=begin(), itEnd=end(); it != itEnd; ++it )
        {
                log_msg("  %s: %s", it->first.c_str(),
-                       it->second->getValue(_owner).to_string());
+                       it->second->getValue(this_ptr).to_string());
        }
 }
 
@@ -187,10 +200,7 @@
                const std::string& name = it->first;
                const Property* prop = it->second;
 
-               // TODO: don't call get_member_value, we
-               //       must copy also 'getset' members ...
                _props[name] = prop->clone();
-               //setValue(name, prop.getValue());
        }
 }
 

Index: server/PropertyList.h
===================================================================
RCS file: /sources/gnash/gnash/server/PropertyList.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- server/PropertyList.h       26 Oct 2006 22:32:19 -0000      1.2
+++ server/PropertyList.h       27 Oct 2006 11:01:35 -0000      1.3
@@ -115,10 +115,6 @@
 
        container _props;
 
-       // this will be used to setup environemnt for
-       // getter-setter properties
-       as_object* _owner;
-
        iterator find(const std::string& key) {
                return _props.find(key);
        }
@@ -138,42 +134,16 @@
                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:
 
-       /// 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 the PropertyList 
+       PropertyList();
 
-       /// 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);
+       /// Copy constructor
+       PropertyList(const PropertyList& pl);
+
+       /// Assignment operator
+       PropertyList& operator==(const PropertyList&);
 
        /// Delete all Property objects in the container
        ~PropertyList();
@@ -191,15 +161,28 @@
        ///     value will be copied (it will be left untouched if
        ///     no property was found)
        ///
+       /// @param this_ptr
+       ///     The as_object used to set the 'this' pointer
+       ///     for calling getter/setter function (GetterSetterProperty);
+       ///     it will be unused when getting or setting SimpleProperty
+       ///     properties.
+       ///     This parameter is non-const as nothing prevents an
+       ///     eventual "Getter" function from actually modifying it,
+       ///     so we can't promise constness.
+       ///     Note that the PropertyList itself might be changed
+       ///     from this call, accessed trough the 'this' pointer,
+       ///     so this method too is non-const.
+       ///
        /// @return true if the value was successfully retrived, false
        ///         otherwise (and value will be untouched)
        ///
-       bool getValue(const std::string& key, as_value& value) const;
+       bool getValue(const std::string& key, as_value& value,
+                       as_object& this_ptr);
 
        /// 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.
+       /// will be invoked using the given as_object as 'this' pointer.
        /// If the property is not found a SimpleProperty will be created.
        ///
        /// @param key
@@ -209,10 +192,31 @@
        ///     a const reference to the as_value to use for setting
        ///     or creating the property. 
        ///
+       /// @param this_ptr
+       ///     The as_object used to set the 'this' pointer
+       ///     for calling getter/setter function (GetterSetterProperty);
+       ///     it will be unused when getting or setting SimpleProperty
+       ///     properties.
+       ///     This parameter is non-const as nothing prevents an
+       ///     eventual "Setter" function from actually modifying it,
+       ///     so we can't promise constness.
+       ///
        /// @return true if the value was successfully set, false
        ///         otherwise (found a read-only property, most likely).
        ///
-       bool setValue(const std::string& key, const as_value& value);
+       bool setValue(const std::string& key, const as_value& value,
+                       as_object& this_ptr);
+
+       /// Get a property, if existing
+       //
+       /// @param key
+       ///     name of the property. search will be case-insensitive
+       ///
+       /// @return a Property or NULL, if no such property exists
+       ///     ownership of returned Propery is kept by the PropertyList,
+       ///     so plase *don't* delete it !
+       ///
+       Property* getProperty(const std::string& key);
 
        /// \brief
        /// Add a getter/setter property, if not already existing
@@ -315,7 +319,20 @@
        }
 
        /// Dump all members (using log_msg)
-       void dump() const;
+       //
+       /// @param this_ptr
+       ///     The as_object used to set the 'this' pointer
+       ///     for calling getter/setter function (GetterSetterProperty);
+       ///     it will be unused when getting or setting SimpleProperty
+       ///     properties.
+       ///     This parameter is non-const as nothing prevents an
+       ///     eventual "Getter" function from actually modifying it,
+       ///     so we can't promise constness.
+       ///     Note that the PropertyList itself might be changed
+       ///     from this call, accessed trough the 'this' pointer,
+       ///     so this method too is non-const.
+       ///
+       void dump(as_object& this_ptr);
 };
 
 

Index: server/as_object.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/as_object.cpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -b -r1.13 -r1.14
--- server/as_object.cpp        26 Oct 2006 14:45:28 -0000      1.13
+++ server/as_object.cpp        27 Oct 2006 11:01:35 -0000      1.14
@@ -45,6 +45,7 @@
 #include "as_object.h"
 #include "as_function.h"
 #include "as_environment.h" // for enumerateProperties
+#include "Property.h" // for findGetterSetter
 
 #include <set>
 
@@ -66,31 +67,73 @@
        // temp hack, should really update this method's interface instead
        std::string name = namei.c_str();
 
-       //log_action("  get member: %s (at %p) for object %p\n", name.c_str(), 
(void*)val, (void*)this);
+       // TODO: inspect wheter it is possible to make __proto__ a
+       //       getter/setter property instead, to take this into account
+       //
        if (namei == "__proto__")
        {
                if ( m_prototype == NULL )
                {
-                       //log_msg("as_object %p has no prototype\n", 
(void*)this);
+                       log_msg("as_object %p has no prototype\n", (void*)this);
                        return false;
                }
                val->set_as_object(m_prototype);
                return true;
        }
 
-       if ( _members.getValue(name, *val) ) return true;
+       Property* prop = findProperty(name);
+       if ( ! prop ) return false;
+
+       *val = prop->getValue(*this);
+       return true;
+       
+}
+
+/*private*/
+Property*
+as_object::findProperty(const std::string& key)
+{
+       // this set will keep track of visited objects,
+       // to avoid infinite loops
+       std::set<const as_object*> visited;
 
-       //log_action("  not found on first level\n");
-       if (m_prototype == NULL)
+       as_object* obj = this;
+       while ( obj && visited.insert(obj).second )
        {
-               //log_action("  no __proto__ (m_prototype) defined\n");
-               return false;
+               Property* prop = obj->_members.getProperty(key);
+               if ( prop ) return prop;
+               else obj = obj->m_prototype;
        }
 
-       //log_action("  checkin in __proto__ (m_prototype) %p\n", 
(void*)m_prototype);
-       // tmp hack (passing namei), see comment above 'name' declaration
-       // at start of function
-       return m_prototype->get_member(namei, val);
+       // No Property found
+       return NULL;
+
+}
+
+/*private*/
+Property*
+as_object::findGetterSetter(const std::string& key)
+{
+       // this set will keep track of visited objects,
+       // to avoid infinite loops
+       std::set<const as_object*> visited;
+
+       as_object* obj = this;
+       while ( obj && visited.insert(obj).second )
+       {
+               Property* prop = obj->_members.getProperty(key);
+               if ( prop && prop->isGetterSetter() )
+               {
+                       // what if a property is found which is
+                       // NOT a getter/setter ?
+                       return prop;
+               }
+               obj = obj->m_prototype;
+       }
+
+       // No Getter/Setter property found
+       return NULL;
+
 }
 
 void
@@ -110,7 +153,7 @@
 void
 as_object::set_member_default(const tu_stringi& name, const as_value& val )
 {
-       //printf("SET MEMBER: %s = %s for object %p\n", name.c_str(), 
val.to_string(), this);
+       // TODO: make __proto__ a getter/setter ?
        if (name == "__proto__") 
        {
                set_prototype(val.to_object());
@@ -118,10 +161,30 @@
        }
 
        std::string key = name.c_str();
-       if ( ! _members.setValue(key, val) )
-       {
-               log_warning("Attempt to set Read-Only property ``%s'' on object 
``%p''", key.c_str(), (void*)this);
+
+       // found a getter/setter property in the inheritance chain
+       // so set that and return
+       Property* prop = findGetterSetter(key);
+       if ( prop )
+       {
+               //log_msg("Found a getter/setter property for key %s", 
key.c_str());
+               // TODO: have setValue check for read-only property 
+               //       and warn if failed
+               prop->setValue(*this, val);
+               return;
        }
+
+       //log_msg("Found NO getter/setter property for key %s", key.c_str());
+
+       // No getter/setter property found, so set (or create) a
+       // SimpleProperty (if possible)
+       if ( ! _members.setValue(key, val, *this) )
+       {
+               log_warning("Attempt to set Read-Only property ``%s''"
+                       " on object ``%p''",
+                       key.c_str(), (void*)this);
+       }
+
 }
 
 bool
@@ -155,11 +218,11 @@
 }
 
 void
-as_object::dump_members() const
+as_object::dump_members() 
 {
        log_msg("%d Members of object %p follow",
-               _members.size(), (void*)this);
-       _members.dump();
+               _members.size(), (const void*)this);
+       _members.dump(*this);
 }
 
 void

Index: server/as_object.h
===================================================================
RCS file: /sources/gnash/gnash/server/as_object.h,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -b -r1.16 -r1.17
--- server/as_object.h  26 Oct 2006 23:05:41 -0000      1.16
+++ server/as_object.h  27 Oct 2006 11:01:35 -0000      1.17
@@ -76,9 +76,28 @@
                return *this;
        }
 
+       /// Look for a Getter/setter property scanning the inheritance chain
+       //
+       /// @returns a Getter/Setter propery if found, NULL if not found
+       ///
+       Property* findGetterSetter(const std::string& name);
+
+       /// Find a property scanning the inheritance chain
+       //
+       /// @returns a Propery if found, NULL if not found
+       ///
+       Property* findProperty(const std::string& name);
+
 public:
 
-       void dump_members() const;
+       /// Dump all properties using log_msg
+       //
+       /// Note that this method is non-const
+       /// as some properties might be getter/setter
+       /// ones, thus simple read of them might execute
+       /// user code actually changing the object itsef.
+       ///
+       void dump_members();
 
        /// Reference to this object's '__proto__'
        // TODO: make private (or protected)
@@ -87,7 +106,7 @@
        /// Construct an ActionScript object with no prototype associated.
        as_object()
                :
-               _members(*this),
+               _members(),
                m_prototype(NULL)
        {
        }
@@ -97,7 +116,7 @@
        /// Adds a reference to the prototype, if any.
        as_object(as_object* proto)
                :
-               _members(*this),
+               _members(),
                m_prototype(proto)
        {
                if (m_prototype) m_prototype->add_ref();
@@ -106,7 +125,7 @@
        as_object(const as_object& other)
                :
                ref_counted(),
-               _members(other._members, *this),
+               _members(other._members),
                m_prototype(other.m_prototype)
        {
                if (m_prototype) m_prototype->add_ref();
@@ -133,13 +152,32 @@
        }
 
        /// Set a member value
+       //
+       /// The default behaviour is to call set_member_default,
+       /// but this function is kept virtual to allow special
+       /// handling of property assignment in derivate class.
+       /// NOTE: This might change in the near future trough use of
+       ///       getter/setter properties instead..
+       ///
+       /// TODO: take a std::string rather then a tu_stringi
+       ///
        virtual void set_member(const tu_stringi& name,
                        const as_value& val );
 
        /// Get a member as_value by name
        //
-       /// This is the one to be overridden if you need special
-       /// handling of some values.
+       /// The default behaviour is to call set_member_default,
+       /// but this function is kept virtual to allow special
+       /// handling of property fetching in derivate class.
+       /// NOTE: This might change in the near future trough use of
+       ///       getter/setter properties instead..
+       ///
+       /// NOTE that this method is non-const becase a property
+       ///      could also be a getter/setter and we can't promise
+       ///      that the 'getter' won't change this object trough
+       ///      use of the 'this' reference.
+       ///
+       /// TODO: take a std::string rather then a tu_stringi
        ///
        virtual bool get_member(const tu_stringi& name, as_value* val);
        
@@ -219,10 +257,37 @@
 
 protected:
 
-       /// Get a member as_value by name
+       /// Get a property value by name
+       //
+       /// This is the default implementation, taking care of
+       /// the inheritance chain and getter/setter functions.
+       ///
+       /// If a derivate class needs special handling of get member
+       /// request it should override the get_member() method instead.
+       /// NOTE: This might change in the near future trough use of
+       ///       getter/setter properties instead..
+       ///
+       /// NOTE that this method is non-const becase a property
+       ///      could also be a getter/setter and we can't promise
+       ///      that the 'getter' won't change this object trough
+       ///      use of the 'this' reference.
+       ///
+       /// TODO: take a std::string rather then a tu_stringi
+       ///
        bool get_member_default(const tu_stringi& name, as_value* val);
 
        /// Set a member value
+       //
+       /// This is the default implementation, taking care of
+       /// the inheritance chain and getter/setter functions.
+       ///
+       /// If a derivate class needs special handling of get member
+       /// request it should override the get_member() method instead.
+       /// NOTE: This might change in the near future trough use of
+       ///       getter/setter properties instead..
+       ///
+       /// TODO: take a std::string rather then a tu_stringi
+       ///
        void set_member_default(const tu_stringi& name, const as_value& val);
 
 private:

Index: testsuite/actionscript.all/Object.as
===================================================================
RCS file: /sources/gnash/gnash/testsuite/actionscript.all/Object.as,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- testsuite/actionscript.all/Object.as        26 Oct 2006 23:05:41 -0000      
1.12
+++ testsuite/actionscript.all/Object.as        27 Oct 2006 11:01:35 -0000      
1.13
@@ -40,7 +40,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.12 2006/10/26 23:05:41 strk Exp $";
+rcsid="$Id: Object.as,v 1.13 2006/10/27 11:01:35 strk Exp $";
 
 #include "check.as"
 
@@ -117,6 +117,28 @@
 
 // TODO: try using the name of an existing property
 
+// Try property inheritance
+
+var proto = new Object();
+check(proto.addProperty("len", getLen, setLen));
+var inh1 = new Object();
+inh1.__proto__ = proto;
+var inh2 = new Object();
+inh2.__proto__ = proto;
+check_equals (inh1._len, undefined);
+check_equals (inh2._len, undefined);
+inh1.len = 4; 
+inh2.len = 9;
+check_equals (inh1._len, 4);
+check_equals (inh2._len, 9);
+check_equals (proto._len, undefined);
+inh1._len = 5;
+inh2._len = 7;
+check_equals (inh1.len, 5);
+check_equals (inh2.len, 7);
+check_equals (proto.len, undefined);
+
+
 //----------------------
 // Test enumeration
 //----------------------

Index: testsuite/server/PropertyListTest.cpp
===================================================================
RCS file: /sources/gnash/gnash/testsuite/server/PropertyListTest.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- testsuite/server/PropertyListTest.cpp       26 Oct 2006 22:32:19 -0000      
1.2
+++ testsuite/server/PropertyListTest.cpp       27 Oct 2006 11:01:35 -0000      
1.3
@@ -56,7 +56,7 @@
        dbglogfile.setVerbosity();
 
        as_object obj;
-       PropertyList props(obj);
+       PropertyList props;
 
        as_value val("value");
        as_value val2("value2");
@@ -64,34 +64,34 @@
        as_value ret;
 
        check_equals(props.size(), 0);
-       check ( props.setValue("Var0", val) );
+       check ( props.setValue("Var0", val, obj) );
        check_equals(props.size(), 1);
 
-       check ( props.getValue("Var0", ret) );
+       check ( props.getValue("Var0", ret, obj) );
        check_equals ( ret, val );
 
        // search should be case-insensitive
-       check ( props.getValue("var0", ret) );
+       check ( props.getValue("var0", ret, obj) );
        check_equals ( ret, val );
 
        // new value overrides existing value
-       check ( props.setValue("Var0", val2) );
+       check ( props.setValue("Var0", val2, obj) );
        check_equals(props.size(), 1);
-       check ( props.getValue("Var0", ret) );
+       check ( props.getValue("Var0", ret, obj) );
        check_equals ( ret, val2 );
 
        // case-insensitive setting value overrides existing value
-       check ( props.setValue("var0", val3) );
+       check ( props.setValue("var0", val3, obj) );
        check_equals(props.size(), 1);
-       check ( props.getValue("vAr0", ret) );
+       check ( props.getValue("vAr0", ret, obj) );
        check_equals ( ret, val3 );
 
        // Now add some new labels
-       check ( props.setValue("var1", val) );
+       check ( props.setValue("var1", val, obj) );
        check_equals(props.size(), 2);
-       check ( props.setValue("var2", val) );
+       check ( props.setValue("var2", val, obj) );
        check_equals(props.size(), 3);
-       check ( props.setValue("var3", val) );
+       check ( props.setValue("var3", val, obj) );
        check_equals(props.size(), 4);
 
 }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]