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: Mon, 05 May 2008 14:39:05 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  08/05/05 14:39:05

Modified files:
        .              : ChangeLog 
        server         : Property.h PropertyList.cpp PropertyList.h 
                         as_object.cpp as_object.h 

Log message:
        Allow for native functions in destructive getter-setters, reduce scans
        on initialization.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.6502&r2=1.6503
http://cvs.savannah.gnu.org/viewcvs/gnash/server/Property.h?cvsroot=gnash&r1=1.25&r2=1.26
http://cvs.savannah.gnu.org/viewcvs/gnash/server/PropertyList.cpp?cvsroot=gnash&r1=1.34&r2=1.35
http://cvs.savannah.gnu.org/viewcvs/gnash/server/PropertyList.h?cvsroot=gnash&r1=1.30&r2=1.31
http://cvs.savannah.gnu.org/viewcvs/gnash/server/as_object.cpp?cvsroot=gnash&r1=1.119&r2=1.120
http://cvs.savannah.gnu.org/viewcvs/gnash/server/as_object.h?cvsroot=gnash&r1=1.108&r2=1.109

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.6502
retrieving revision 1.6503
diff -u -b -r1.6502 -r1.6503
--- ChangeLog   5 May 2008 13:36:24 -0000       1.6502
+++ ChangeLog   5 May 2008 14:39:04 -0000       1.6503
@@ -1,5 +1,13 @@
 2008-05-05 Sandro Santilli <address@hidden>
 
+       * server/Property.h, server/PropertyList.cpp,
+         server/PropertyList.h, server/as_object.cpp,
+         server/as_object.h: Allow for native functions
+         in destructive getter-setters, reduce scans
+         on initialization.
+
+2008-05-05 Sandro Santilli <address@hidden>
+
        * server/asobj/gen-asclass.pl: add support for stubbing
          properties as native getter-setters.
        * server/asobj/flash/: display/BitmapData_as.cpp,

Index: server/Property.h
===================================================================
RCS file: /sources/gnash/gnash/server/Property.h,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -b -r1.25 -r1.26
--- server/Property.h   7 Apr 2008 17:39:52 -0000       1.25
+++ server/Property.h   5 May 2008 14:39:04 -0000       1.26
@@ -327,8 +327,10 @@
        {/**/}
 
        Property(string_table::key name, string_table::key nsId,
-               as_c_function_ptr getter, as_c_function_ptr setter, bool 
destroy = false) :
-               _flags(), mBound(GetterSetter(getter, setter)), 
mDestructive(destroy),
+               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),
                mOrderId(0)
        {/**/}

Index: server/PropertyList.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/PropertyList.cpp,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -b -r1.34 -r1.35
--- server/PropertyList.cpp     5 May 2008 10:02:29 -0000       1.34
+++ server/PropertyList.cpp     5 May 2008 14:39:05 -0000       1.35
@@ -338,10 +338,10 @@
 
 bool
 PropertyList::addGetterSetter(string_table::key key, as_function& getter,
-       as_function* setter, const as_value& cacheVal, string_table::key nsId)
+       as_function* setter, const as_value& cacheVal,
+       const as_prop_flags& flagsIfMissing, string_table::key nsId)
 {
-       Property a(key, nsId, &getter, setter);
-       a.setCache(cacheVal);
+       Property a(key, nsId, &getter, setter, flagsIfMissing);
        a.setOrder(- ++mDefaultOrder - 1);
 
        container::iterator found = iterator_find(_props, key, nsId);
@@ -350,6 +350,7 @@
                // copy flags from previous member (even if it's a normal 
member ?)
                as_prop_flags& f = a.getFlags();
                f = found->getFlags();
+               a.setCache(found->getCache());
 
                _props.replace(found, a);
                assert ( iterator_find(_props, key, nsId) != _props.end() );
@@ -357,6 +358,7 @@
        }
        else
        {
+               a.setCache(cacheVal);
                _props.insert(a);
                assert ( iterator_find(_props, key, nsId) != _props.end() );
        }
@@ -367,9 +369,10 @@
 
 bool
 PropertyList::addGetterSetter(string_table::key key, as_c_function_ptr getter,
-       as_c_function_ptr setter, string_table::key nsId)
+       as_c_function_ptr setter, const as_prop_flags& flagsIfMissing,
+       string_table::key nsId)
 {
-       Property a(key, nsId, getter, setter);
+       Property a(key, nsId, getter, setter, flagsIfMissing);
        a.setOrder(- ++mDefaultOrder - 1);
 
        container::iterator found = iterator_find(_props, key, nsId);
@@ -409,6 +412,22 @@
        return true;
 }
 
+bool
+PropertyList::addDestructiveGetter(string_table::key key,
+       as_c_function_ptr getter, string_table::key nsId,
+       const as_prop_flags& flagsIfMissing)
+{
+       container::iterator found = iterator_find(_props, key, nsId);
+       if (found != _props.end())
+               return false; // Already exists.
+
+       // destructive getter don't need a setter
+       Property a(key, nsId, getter, (as_c_function_ptr)0, flagsIfMissing, 
true);
+       a.setOrder(- ++mDefaultOrder - 1);
+       _props.insert(a);
+       return true;
+}
+
 void
 PropertyList::clear()
 {

Index: server/PropertyList.h
===================================================================
RCS file: /sources/gnash/gnash/server/PropertyList.h,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -b -r1.30 -r1.31
--- server/PropertyList.h       5 May 2008 10:02:30 -0000       1.30
+++ server/PropertyList.h       5 May 2008 14:39:05 -0000       1.31
@@ -283,11 +283,15 @@
        ///     The value to use as a cache. If null uses any cache
        ///     from pre-existing property with same name.
        ///
+       /// @param flagsIfMissing
+       ///     Flags to associate to the property if a new one is created.
+       ///
        /// @return true if the property was successfully added, false
        ///         otherwise (property already existent?)
        ///
        bool addGetterSetter(string_table::key key, as_function& getter,
-               as_function* setter, const as_value& cacheVal, 
string_table::key ns=0);
+               as_function* setter, const as_value& cacheVal,
+               const as_prop_flags& flagsIfMissing=0, string_table::key ns=0);
 
        /// \brief
        /// Add a getter/setter property, if not already existing
@@ -308,10 +312,11 @@
        ///         otherwise (property already existent?)
        ///
        bool addGetterSetter(string_table::key key, as_c_function_ptr getter,
-               as_c_function_ptr setter, string_table::key ns = 0);
+               as_c_function_ptr setter, const as_prop_flags& flagsIfMissing,
+               string_table::key ns = 0);
 
        /// \brief
-       /// Add a destructive getter/setter property, if not already extant.
+       /// Add a destructive getter property, if not already existant.
        ///
        /// @param key
        /// Name of the property. Case-sensitive search.
@@ -329,6 +334,25 @@
                as_function& getter, string_table::key ns = 0,
                const as_prop_flags& flagsIfMissing=0);
 
+       /// \brief
+       /// Add a destructive getter property, if not already existant.
+       ///
+       /// @param key
+       /// Name of the property. Case-sensitive search.
+       ///
+       /// @param getter
+       /// A function to invoke when this property value is requested.
+       ///
+       /// @param flagsIfMissing
+       ///     Flags to associate to the property if a new one is created.
+       ///
+       /// @return true if the property was successfully added, false
+       /// otherwise.
+       ///
+       bool addDestructiveGetter(string_table::key key,
+               as_c_function_ptr getter, string_table::key ns = 0,
+               const as_prop_flags& flagsIfMissing=0);
+
        /// Set the flags of a property.
        //
        /// @param key

Index: server/as_object.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/as_object.cpp,v
retrieving revision 1.119
retrieving revision 1.120
diff -u -b -r1.119 -r1.120
--- server/as_object.cpp        5 May 2008 10:02:30 -0000       1.119
+++ server/as_object.cpp        5 May 2008 14:39:05 -0000       1.120
@@ -207,14 +207,6 @@
        }
 }
 
-bool
-as_object::add_property(const std::string& name, as_c_function_ptr getter,
-               as_c_function_ptr setter)
-{
-       string_table &st = _vm.getStringTable();
-       return _members.addGetterSetter(st.find(PROPNAME(name)), getter, 
setter);
-}
-
 /*protected*/
 bool
 as_object::get_member_default(string_table::key name, as_value* val,
@@ -762,8 +754,10 @@
 as_object::init_property(string_table::key key, as_function& getter,
                as_function& setter, int flags, string_table::key nsname)
 {
+       as_value cacheValue;
+
        bool success;
-       success = _members.addGetterSetter(key, getter, &setter, nsname);
+       success = _members.addGetterSetter(key, getter, &setter, cacheValue, 
flags, nsname);
 
        // We shouldn't attempt to initialize a property twice, should we ?
        assert(success);
@@ -771,7 +765,7 @@
        //log_debug(_("Initialized property '%s'"), name.c_str());
 
        // TODO: optimize this, don't scan again !
-       _members.setFlags(key, flags, nsname);
+       //_members.setFlags(key, flags, nsname);
 
 }
 
@@ -811,6 +805,17 @@
        return success;
 }
 
+bool
+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);
+       return success;
+}
+
 void
 as_object::init_readonly_property(const std::string& key, as_function& getter,
        int initflags, string_table::key nsname)

Index: server/as_object.h
===================================================================
RCS file: /sources/gnash/gnash/server/as_object.h,v
retrieving revision 1.108
retrieving revision 1.109
diff -u -b -r1.108 -r1.109
--- server/as_object.h  5 May 2008 10:02:30 -0000       1.108
+++ server/as_object.h  5 May 2008 14:39:05 -0000       1.109
@@ -490,9 +490,9 @@
 
 
        /// \brief
-       /// Initialize a destructive getter/setter property
+       /// Initialize a destructive getter property
        ///
-       /// A destructive getter/setter can be used as a place holder for the 
real
+       /// A destructive getter can be used as a place holder for the real
        /// value of a property.  As soon as getValue is invoked on the getter,
        /// it destroys itself after setting its property to the return value of
        /// getValue.
@@ -518,6 +518,35 @@
                string_table::key nsname = 0);
 
        /// \brief
+       /// Initialize a destructive getter property
+       ///
+       /// A destructive getter can be used as a place holder for the real
+       /// value of a property.  As soon as getValue is invoked on the getter,
+       /// it destroys itself after setting its property to the return value of
+       /// getValue.
+       ///
+       /// @param key
+       ///     Name of the property.
+       ///     Will be converted to lowercase if VM is initialized for SWF6 or 
lower.
+       ///
+       /// @param getter
+       ///     A function to invoke when this property value is requested.
+       ///     add_ref will be called on the function.
+       ///
+       /// @param flags
+       ///     Flags for the new member. By default dontDelete and dontEnum.
+       ///     See as_prop_flags::Flags.
+       ///
+       /// @param nsname
+       /// The id of the namespace to which this member belongs. 0 is a 
wildcard
+       /// and will be matched by anything not asking for a specific namespace.
+       ///
+       bool init_destructive_property(string_table::key key, as_c_function_ptr 
getter,
+               int flags=as_prop_flags::dontEnum,
+               string_table::key nsname = 0);
+
+
+       /// \brief
        /// Use this method for read-only properties.
        //
        /// This method achieves the same as the above init_property method.
@@ -973,29 +1002,6 @@
        bool add_property(const std::string& key, as_function& getter,
                as_function* setter=NULL);
 
-       /// \brief
-       /// Add a getter/setter property, if no member already has
-       /// that name (or should we allow override ? TODO: check this)
-       //
-       /// @param key
-       ///     Name of the property.
-       ///     Case insensitive up to SWF6,
-       ///     case *sensitive* from SWF7 up.
-       ///
-       /// @param getter
-       ///     A function to invoke when this property value is requested.
-       ///     add_ref will be called on the function.
-       ///
-       /// @param setter
-       ///     A function to invoke when setting this property's value.
-       ///     add_ref will be called on the function.
-       ///
-       /// @return true if the property was successfully added, false
-       ///         otherwise (property already existent?)
-       ///
-       bool add_property(const std::string& key, as_c_function_ptr getter,
-               as_c_function_ptr setter);
-
        /// Return this object '__proto__' member.
        //
        /// The __proto__ member is the exported interface ('prototype')




reply via email to

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