gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] [SCM] Gnash branch, master, updated. ecbfb67ed6c1bfa97947


From: Benjamin Wolsey
Subject: [Gnash-commit] [SCM] Gnash branch, master, updated. ecbfb67ed6c1bfa97947c380a47fee74b553695f
Date: Thu, 30 Sep 2010 10:51:31 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Gnash".

The branch, master has been updated
       via  ecbfb67ed6c1bfa97947c380a47fee74b553695f (commit)
       via  7b27ff94e2e3938b3393f1d5a3600144224738e7 (commit)
       via  831039b032357f99a7d0be8432701b5b29739838 (commit)
       via  153fa2f69ff5284b525b1b62612f04bf9a490fad (commit)
       via  acd9177ee7921cc53b5a3b6bc43894ed6b943801 (commit)
       via  dcc68ce2ef87d60318d7d5392829e048c1b2b22e (commit)
       via  6fddfdc50510b26817c63d6e418fa3957383f3a4 (commit)
       via  d551a163946a3083e6470a4b25843ddb54cb2329 (commit)
       via  1663d7bef637c3b57ee9da7630993a58b3aadb3f (commit)
       via  1a287e7e081581be57c5a8b562aeef7d6fefaf66 (commit)
       via  dc495f27fb7673e5ae021af1fd53ef0d53c66cec (commit)
      from  e94ed673c3adb4f4db33e7ec690c49adbf169087 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit//commit/?id=ecbfb67ed6c1bfa97947c380a47fee74b553695f


commit ecbfb67ed6c1bfa97947c380a47fee74b553695f
Author: Benjamin Wolsey <address@hidden>
Date:   Thu Sep 30 12:04:56 2010 +0200

    Don't test things that aren't part of the interface. Const correct.

diff --git a/libcore/DisplayList.cpp b/libcore/DisplayList.cpp
index 7f7f1ec..ca02e8d 100644
--- a/libcore/DisplayList.cpp
+++ b/libcore/DisplayList.cpp
@@ -62,25 +62,25 @@ public:
 
     DepthEquals(int depth) : _depth(depth) {}
 
-    bool operator() (const DisplayObject* item) {
+    bool operator() (const DisplayObject* item) const {
         if (!item) return false;
         return item->get_depth() == _depth;
     }
 
 private:
-    int _depth;
+    const int _depth;
 };
 
 struct DepthGreaterThan
 {
-    bool operator()(const DisplayObject* a, const DisplayObject* b) {
+    bool operator()(const DisplayObject* a, const DisplayObject* b) const {
         return a->get_depth() > b->get_depth();
     }
 };
 
 struct DepthLessThan
 {
-    bool operator()(const DisplayObject* a, const DisplayObject* b) {
+    bool operator()(const DisplayObject* a, const DisplayObject* b) const {
         return a->get_depth() < b->get_depth();
     }
 };
@@ -91,12 +91,12 @@ public:
 
     DepthGreaterOrEqual(int depth) : _depth(depth) {}
 
-    bool operator() (const DisplayObject* item) {
+    bool operator() (const DisplayObject* item) const {
         if (!item) return false;
         return item->get_depth() >= _depth;
     }
 private:
-    int _depth;
+    const int _depth;
 };
 
 
@@ -140,7 +140,7 @@ DisplayList::getNextHighestDepth() const
 
         DisplayObject* ch = *it;
 
-        int chdepth = ch->get_depth();
+        const int chdepth = ch->get_depth();
         if (chdepth >= nexthighestdepth) {
             nexthighestdepth = chdepth+1;
         }
@@ -232,7 +232,7 @@ DisplayList::placeDisplayObject(DisplayObject* ch, int 
depth)
 void
 DisplayList::add(DisplayObject* ch, bool replace)
 {
-    int depth = ch->get_depth();
+    const int depth = ch->get_depth();
 
     container_type::iterator it =
         std::find_if(_charsByDepth.begin(), _charsByDepth.end(),
@@ -660,7 +660,7 @@ DisplayList::display(Renderer& renderer, const Transform& 
base)
             continue;
         }
     
-        int depth = ch->get_depth();
+        const int depth = ch->get_depth();
         // Discard useless masks
         while (!clipDepthStack.empty() && (depth > clipDepthStack.top())) {
             clipDepthStack.pop();
@@ -855,12 +855,6 @@ DisplayList::add_invalidated_bounds(InvalidatedRanges& 
ranges, bool force)
 }
 
 void
-DisplayList::sort()
-{
-    _charsByDepth.sort(DepthLessThan());
-}
-
-void
 DisplayList::mergeDisplayList(DisplayList& newList)
 {
     testInvariant();
@@ -1050,14 +1044,6 @@ DisplayList::removeUnloaded()
     testInvariant();
 }
 
-bool
-DisplayList::isSorted() const
-{
-    if (_charsByDepth.empty()) return true;
-    return std::adjacent_find(_charsByDepth.begin(), _charsByDepth.end(),
-            DepthGreaterThan()) == _charsByDepth.end();
-}
-
 
 #if GNASH_PARANOIA_LEVEL > 1 && !defined(NDEBUG)
 DisplayList::const_iterator
diff --git a/libcore/DisplayList.h b/libcore/DisplayList.h
index f4e2656..c006cb1 100644
--- a/libcore/DisplayList.h
+++ b/libcore/DisplayList.h
@@ -28,6 +28,7 @@
 #include <iosfwd>
 #if GNASH_PARANOIA_LEVEL > 1 && !defined(NDEBUG)
 #include <set>  // for testInvariant
+#include <algorithm>
 #include "log.h"
 #endif
 
@@ -262,19 +263,6 @@ public:
             const ObjectURI& uri, bool caseless) const;
 
        /// \brief 
-       /// Visit each DisplayObject in the list in depth order
-       /// (lower depth first).
-       //
-       /// The visitor functor will 
-       /// receive a DisplayObject pointer; must return true if
-       /// it wants next item or false to exit the loop.
-       ///
-       /// NOTE: all elements in the list are visited, even
-       ///       the removed ones (unloaded)
-       /// TODO: inspect if worth providing an arg to skip removed
-       template <class V> inline void visitForward(V& visitor);
-
-       /// \brief 
        /// Visit each DisplayObject in the list in reverse depth
        /// order (higher depth first).
        //
@@ -328,18 +316,6 @@ public:
        /// that is displayd above all others
        ///
        int getNextHighestDepth() const;
-
-       /// Sort list by depth (lower depths first)
-       //
-       /// You only need calling this method if depth
-       /// of DisplayObjects on the list has been externally
-       /// changed. Usually it is DisplayList itself
-       /// assigning depths, so won't need to call it.
-       ///
-       /// A notable use for this is backing up a specific
-       /// state and restoring it later. Restore step would
-       /// need reordering.
-       void sort();
        
        /// \brief
        /// merge the given display list
@@ -373,7 +349,10 @@ public:
                 std::abort();
                        }
                }
-               assert(isSorted()); // check we didn't screw up ordering
+        if (_charsByDepth.empty()) return;
+               // check we didn't screw up ordering
+        assert(std::adjacent_find(_charsByDepth.begin(), _charsByDepth.end(),
+            DepthGreaterThan()) == _charsByDepth.end());
        }
 #else
     void testInvariant() const {}
@@ -394,23 +373,10 @@ private:
        void reinsertRemovedCharacter(DisplayObject* ch);
 
        container_type _charsByDepth;
-
-       /// Check that the list is sorted by depth
-       bool isSorted() const;
 };
 
 template <class V>
 void
-DisplayList::visitForward(V& visitor)
-{
-       for (iterator it = _charsByDepth.begin(), itEnd = _charsByDepth.end();
-               it != itEnd; ++it) {
-               if (!visitor(*it)) break;
-       }
-}
-
-template <class V>
-void
 DisplayList::visitBackward(V& visitor)
 {
        for (reverse_iterator it = _charsByDepth.rbegin(),
diff --git a/testsuite/libcore.all/DisplayListTest.cpp 
b/testsuite/libcore.all/DisplayListTest.cpp
index bb883a7..322e920 100644
--- a/testsuite/libcore.all/DisplayListTest.cpp
+++ b/testsuite/libcore.all/DisplayListTest.cpp
@@ -89,11 +89,6 @@ main(int /*argc*/, char** /*argv*/)
     dlist2.placeDisplayObject( ch2.get(), 1);
     dlist2.placeDisplayObject( ch1.get(), 2);
     
-    // Resort dlist1 as depth of it's chars has been changed
-    // by placeDisplayObject calls above :/
-    dlist1.sort();
-    
-    check_equals(dlist1, dlist2);
     
 }
 

http://git.savannah.gnu.org/cgit//commit/?id=7b27ff94e2e3938b3393f1d5a3600144224738e7


commit 7b27ff94e2e3938b3393f1d5a3600144224738e7
Author: Benjamin Wolsey <address@hidden>
Date:   Thu Sep 30 12:03:58 2010 +0200

    Inline simple accessors

diff --git a/libcore/DisplayObject.cpp b/libcore/DisplayObject.cpp
index 6a396de..cbe4fb3 100644
--- a/libcore/DisplayObject.cpp
+++ b/libcore/DisplayObject.cpp
@@ -113,19 +113,7 @@ DisplayObject::DisplayObject(movie_root& mr, as_object* 
object,
     // This informs the core that the object is a DisplayObject.
     if (_object) _object->setDisplayObject(this);
 }
-
-as_object*
-DisplayObject::object() const
-{
-    return _object;
-}
     
-bool
-DisplayObject::unloaded() const
-{
-    return _unloaded;
-}
-
 void
 DisplayObject::getLoadedMovie(Movie* extern_movie)
 {
diff --git a/libcore/DisplayObject.h b/libcore/DisplayObject.h
index dea7682..2e939f2 100644
--- a/libcore/DisplayObject.h
+++ b/libcore/DisplayObject.h
@@ -793,7 +793,9 @@ public:
     virtual void getLoadedMovie(Movie* newMovie);
 
     /// Return true if this DisplayObject was unloaded from the stage
-    bool unloaded() const;
+    bool unloaded() const {
+        return _unloaded;
+    }
 
     /// Mark this DisplayObject as destroyed
     //
@@ -940,7 +942,9 @@ public:
         return _yscale;
     }
 
-    as_object* object() const;
+    as_object* object() const {
+        return _object;
+    }
 
     /// Getter-setter for blendMode.
     static as_value blendMode(const fn_call& fn);

http://git.savannah.gnu.org/cgit//commit/?id=831039b032357f99a7d0be8432701b5b29739838


commit 831039b032357f99a7d0be8432701b5b29739838
Author: Benjamin Wolsey <address@hidden>
Date:   Thu Sep 30 10:21:52 2010 +0200

    Move binary ops outside class and simplify.

diff --git a/libcore/event_id.h b/libcore/event_id.h
index 0603dbd..1d43b9a 100644
--- a/libcore/event_id.h
+++ b/libcore/event_id.h
@@ -124,25 +124,6 @@ public:
         else _keyCode = static_cast<key::code>(i);
     }
 
-    /// Return whether two event_ids are equal
-    //
-    /// event_ids are equal if both id and keycode match. Keycode is only
-    /// relevant for keyboard events, and must be key::INVALID for other
-    /// event types.
-    bool operator==(const event_id& id) const {
-        return _id == id._id && _keyCode == id._keyCode;
-    }
-
-    /// Comparator for use in stdlib containers.
-    bool operator< (const event_id& id) const {
-        if ( _id < id._id ) return true;
-        if ( _id > id._id ) return false;
-
-        // Same event, check key code
-        if (_keyCode < id._keyCode ) return true;
-        return false;
-    }
-
     /// Return the name of a method-handler function
     /// corresponding to this event.
     const std::string& functionName() const;
@@ -173,6 +154,25 @@ private:
 
 };
 
+/// Return whether two event_ids are equal
+//
+/// event_ids are equal if both id and keycode match. Keycode is only
+/// relevant for keyboard events, and must be key::INVALID for other
+/// event types.
+inline bool
+operator==(const event_id& a, const event_id& b)
+{
+    return a.id() == b.id() && a.keyCode() == b.keyCode();
+}
+
+/// Comparator for use in stdlib containers.
+inline bool
+operator<(const event_id& a, const event_id& b)
+{
+    if (a.id() == b.id()) return a.keyCode() < b.keyCode();
+    return a.id() < b.id();
+}
+
 
 /// Check whether an event is a button-like event.
 //

http://git.savannah.gnu.org/cgit//commit/?id=153fa2f69ff5284b525b1b62612f04bf9a490fad


commit 153fa2f69ff5284b525b1b62612f04bf9a490fad
Author: Benjamin Wolsey <address@hidden>
Date:   Thu Sep 30 10:21:23 2010 +0200

    Use own struct for easier inlining.

diff --git a/libcore/PropertyList.h b/libcore/PropertyList.h
index a519803..61a78ad 100644
--- a/libcore/PropertyList.h
+++ b/libcore/PropertyList.h
@@ -72,8 +72,13 @@ public:
     typedef boost::multi_index::sequenced<
         boost::multi_index::tag<CreationOrder> > SequencedIndex;
     
-    typedef boost::multi_index::const_mem_fun<value_type, const ObjectURI&,
-            &value_type::uri> KeyExtractor;
+    struct KeyExtractor
+    {
+        typedef const ObjectURI& result_type;
+        result_type operator()(const Property& p) const {
+            return p.uri();
+        }
+    };
 
     /// Identifier for the case-sensitive index
     struct Case {};

http://git.savannah.gnu.org/cgit//commit/?id=acd9177ee7921cc53b5a3b6bc43894ed6b943801


commit acd9177ee7921cc53b5a3b6bc43894ed6b943801
Author: Benjamin Wolsey <address@hidden>
Date:   Thu Sep 30 09:02:49 2010 +0200

    Remove default args and casts.

diff --git a/libcore/Property.h b/libcore/Property.h
index a400536..43f76a5 100644
--- a/libcore/Property.h
+++ b/libcore/Property.h
@@ -276,7 +276,7 @@ class Property
 public:
 
        Property(const ObjectURI& uri, const as_value& value,
-            const PropFlags& flags = PropFlags())
+            const PropFlags& flags)
         :
         _bound(value),
                _uri(uri),
@@ -285,7 +285,7 @@ public:
        {}
 
        Property(const ObjectURI& uri,
-               as_function *getter, as_function *setter, 
+               as_function* getter, as_function* setter, 
                const PropFlags& flags, bool destroy = false)
         :
         _bound(GetterSetter(getter, setter)),
diff --git a/libcore/PropertyList.cpp b/libcore/PropertyList.cpp
index 508180f..95df428 100644
--- a/libcore/PropertyList.cpp
+++ b/libcore/PropertyList.cpp
@@ -299,8 +299,8 @@ PropertyList::addDestructiveGetter(const ObjectURI& uri, 
as_function& getter,
                return false; // Already exists.
        }
 
-       // destructive getter don't need a setter
-       Property a(uri, &getter, (as_function*)0, flagsIfMissing, true);
+       // destructive getter doesn't need a setter
+       Property a(uri, &getter, 0, flagsIfMissing, true);
 
        _props.push_back(a);
 
@@ -320,8 +320,8 @@ PropertyList::addDestructiveGetter(const ObjectURI& uri,
        iterator found = iterator_find(_props, uri, getVM(_owner));
        if (found != _props.end()) return false; 
 
-       // destructive getter don't need a setter
-       Property a(uri, getter, (as_c_function_ptr)0, flagsIfMissing, true);
+       // destructive getter doesn't need a setter
+       Property a(uri, getter, 0, flagsIfMissing, true);
        _props.push_back(a);
 
 #ifdef GNASH_DEBUG_PROPERTY

http://git.savannah.gnu.org/cgit//commit/?id=dcc68ce2ef87d60318d7d5392829e048c1b2b22e


commit dcc68ce2ef87d60318d7d5392829e048c1b2b22e
Author: Benjamin Wolsey <address@hidden>
Date:   Thu Sep 30 08:46:18 2010 +0200

    Drop default Property ctor.

diff --git a/libcore/Property.h b/libcore/Property.h
index da54d5f..a400536 100644
--- a/libcore/Property.h
+++ b/libcore/Property.h
@@ -275,14 +275,6 @@ class Property
 {
 public:
 
-       /// Default constructor
-       Property(const ObjectURI& uri)
-        : 
-               _bound(as_value()),
-        _uri(uri),
-        _destructive(false)
-       {}
-
        Property(const ObjectURI& uri, const as_value& value,
             const PropFlags& flags = PropFlags())
         :

http://git.savannah.gnu.org/cgit//commit/?id=6fddfdc50510b26817c63d6e418fa3957383f3a4


commit 6fddfdc50510b26817c63d6e418fa3957383f3a4
Author: Benjamin Wolsey <address@hidden>
Date:   Thu Sep 30 08:36:52 2010 +0200

    Documentation and cleanup.

diff --git a/libcore/Property.cpp b/libcore/Property.cpp
index fb9a960..e7b55e4 100644
--- a/libcore/Property.cpp
+++ b/libcore/Property.cpp
@@ -30,8 +30,14 @@ namespace gnash {
 
 namespace {
 
+// TODO: drop this.
+enum Type {
+    TYPE_VALUE,
+    TYPE_GETTER_SETTER
+};
+
 /// Get the cache of a variant member.
-struct GetCache : public boost::static_visitor<as_value>
+struct GetCache : boost::static_visitor<as_value>
 {
     result_type operator()(as_value& val) const {
         return val;
@@ -42,7 +48,7 @@ struct GetCache : public boost::static_visitor<as_value>
 };
 
 /// Set the cache of a variant member.
-struct SetCache : public boost::static_visitor<>
+struct SetCache : boost::static_visitor<>
 {
     result_type operator()(as_value& val, const as_value& n) const {
         val = n;
@@ -53,7 +59,7 @@ struct SetCache : public boost::static_visitor<>
 };
 
 /// Mark the stored value reachable.
-struct SetReachable : public boost::static_visitor<>
+struct SetReachable : boost::static_visitor<>
 {
     result_type operator()(const as_value& val) const {
         val.setReachable();
diff --git a/libcore/Property.h b/libcore/Property.h
index a840b4a..da54d5f 100644
--- a/libcore/Property.h
+++ b/libcore/Property.h
@@ -23,6 +23,7 @@
 #include <boost/variant.hpp>
 #include <cassert>
 #include <boost/bind.hpp>
+#include <typeinfo>
 
 #include "PropFlags.h"
 #include "as_value.h"
@@ -43,8 +44,17 @@ class GetterSetter
 {
     class NativeGetterSetter;
 
+    // The following helper structs define common operations on the 
+    // Two types of GetterSetter. Some operations are applicable only to
+    // one type.
+
+    /// Get or set a GetterSetter
+    //
+    /// @tparam S   A type that determines what operation to call on the
+    ///             GetterSetter
+    /// @param Arg  The type of the argument to the get or set function.
     template<typename Arg, typename S>
-    struct GetSetVisitor : public boost::static_visitor<typename 
S::result_type>
+    struct GetSetVisitor : boost::static_visitor<typename S::result_type>
     {
         GetSetVisitor(const Arg& arg) : _arg(arg) {}
         template<typename T> typename S::result_type operator()(T& t) const {
@@ -54,6 +64,7 @@ class GetterSetter
         const Arg& _arg;
     };
 
+    /// Set a GetterSetter
     struct Set
     {
         typedef void result_type;
@@ -63,6 +74,7 @@ class GetterSetter
         }
     };
                                
+    /// Get a GetterSetter
     struct Get
     {
         typedef as_value result_type;
@@ -72,7 +84,10 @@ class GetterSetter
         }
     };
 
-    struct SetUnderlying : public boost::static_visitor<>
+    /// Set the underlying value of a GetterSetter
+    //
+    /// This does not apply to NativeGetterSetters.
+    struct SetUnderlying : boost::static_visitor<>
     {
         template<typename T>
         result_type operator()(T& gs, const as_value& val) const {
@@ -81,7 +96,10 @@ class GetterSetter
         result_type operator()(NativeGetterSetter&, const as_value&) const {}
     };
     
-    struct GetUnderlying : public boost::static_visitor<as_value>
+    /// Get the underlying value of a GetterSetter
+    //
+    /// This does not apply to NativeGetterSetters.
+    struct GetUnderlying : boost::static_visitor<as_value>
     {
         template<typename T>
         result_type operator()(const T& gs) const {
@@ -92,7 +110,8 @@ class GetterSetter
         }
     };
     
-    struct MarkReachable : public boost::static_visitor<>
+    /// Mark a GetterSetter reachable
+    struct MarkReachable : boost::static_visitor<>
     {
         template<typename T>
         result_type operator()(const T& gs) const {
@@ -283,15 +302,6 @@ public:
                _destructive(destroy)
        {}
 
-       Property(const ObjectURI& uri, as_function *getter, as_function *setter,
-            bool destroy = false)
-        :
-        _bound(GetterSetter(getter, setter)),
-        _uri(uri),
-               _flags(),
-        _destructive(destroy)
-       {}
-
        Property(const ObjectURI& uri, as_c_function_ptr getter,
             as_c_function_ptr setter, const PropFlags& flags,
             bool destroy = false)
@@ -301,7 +311,7 @@ public:
                _flags(flags),
         _destructive(destroy)
        {}
-       
+
     /// Copy constructor
        Property(const Property& p)
         :
@@ -367,12 +377,9 @@ public:
 
        /// Is this a getter/setter property?
        bool isGetterSetter() const {
-        return _bound.which() == TYPE_GETTER_SETTER;
+        return _bound.type() == typeid(GetterSetter);
     }
 
-       /// is this a destructive property ?
-       bool isDestructive() const { return _destructive; }
-
        /// Clear visibility flags
        void clearVisible(int swfVersion) { _flags.clear_visible(swfVersion); }
 
@@ -386,11 +393,6 @@ public:
 
 private:
 
-    enum Type {
-        TYPE_VALUE,
-        TYPE_GETTER_SETTER
-    };
-
        // Store the various types of things that can be held.
        typedef boost::variant<as_value, GetterSetter> BoundType;
 
diff --git a/libcore/PropertyList.cpp b/libcore/PropertyList.cpp
index 9174863..508180f 100644
--- a/libcore/PropertyList.cpp
+++ b/libcore/PropertyList.cpp
@@ -110,8 +110,7 @@ PropertyList::setValue(const ObjectURI& uri, const 
as_value& val,
        }
 
        const Property& prop = *found;
-       if (readOnly(prop) && ! prop.isDestructive())
-       {
+       if (readOnly(prop)) {
         ObjectURI::Logger l(getStringTable(_owner));
                log_error(_("Property %s is read-only %s, not setting it to 
%s"), 
                        l(uri), prop.getFlags(), val);

http://git.savannah.gnu.org/cgit//commit/?id=d551a163946a3083e6470a4b25843ddb54cb2329


commit d551a163946a3083e6470a4b25843ddb54cb2329
Merge: 1663d7b e94ed67
Author: Benjamin Wolsey <address@hidden>
Date:   Thu Sep 30 08:30:01 2010 +0200

    Merge branch 'master' of git.sv.gnu.org:/srv/git/gnash


http://git.savannah.gnu.org/cgit//commit/?id=1663d7bef637c3b57ee9da7630993a58b3aadb3f


commit 1663d7bef637c3b57ee9da7630993a58b3aadb3f
Author: Benjamin Wolsey <address@hidden>
Date:   Wed Sep 29 15:43:36 2010 +0200

    Drop declarations.

diff --git a/libcore/Property.h b/libcore/Property.h
index 5825730..a840b4a 100644
--- a/libcore/Property.h
+++ b/libcore/Property.h
@@ -385,12 +385,6 @@ public:
        void setReachable() const;
 
 private:
-       
-    /// Get a value from a getter function.
-       as_value getDelayedValue(const as_object& this_ptr) const;
-
-       /// Set a value using a setter function.
-       void setDelayedValue(as_object& this_ptr, const as_value& value) const;
 
     enum Type {
         TYPE_VALUE,

http://git.savannah.gnu.org/cgit//commit/?id=1a287e7e081581be57c5a8b562aeef7d6fefaf66


commit 1a287e7e081581be57c5a8b562aeef7d6fefaf66
Author: Benjamin Wolsey <address@hidden>
Date:   Wed Sep 29 15:42:12 2010 +0200

    Remove member functions.

diff --git a/libcore/Property.cpp b/libcore/Property.cpp
index 7695746..fb9a960 100644
--- a/libcore/Property.cpp
+++ b/libcore/Property.cpp
@@ -30,6 +30,7 @@ namespace gnash {
 
 namespace {
 
+/// Get the cache of a variant member.
 struct GetCache : public boost::static_visitor<as_value>
 {
     result_type operator()(as_value& val) const {
@@ -40,6 +41,7 @@ struct GetCache : public boost::static_visitor<as_value>
     }
 };
 
+/// Set the cache of a variant member.
 struct SetCache : public boost::static_visitor<>
 {
     result_type operator()(as_value& val, const as_value& n) const {
@@ -50,6 +52,7 @@ struct SetCache : public boost::static_visitor<>
     }
 };
 
+/// Mark the stored value reachable.
 struct SetReachable : public boost::static_visitor<>
 {
     result_type operator()(const as_value& val) const {
@@ -62,7 +65,6 @@ struct SetReachable : public boost::static_visitor<>
 
 }
 
-
 void
 GetterSetter::UserDefinedGetterSetter::markReachableResources() const
 {
@@ -97,44 +99,6 @@ GetterSetter::UserDefinedGetterSetter::set(const fn_call& fn)
        _setter->call(fn);
 }
 
-as_value
-Property::getDelayedValue(const as_object& this_ptr) const
-{
-       const GetterSetter* a = boost::get<const GetterSetter>(&_bound);
-
-       as_environment env(getVM(this_ptr));
-       fn_call fn(const_cast<as_object*>(&this_ptr), env);
-       if (_destructive)
-       {
-               as_value ret = a->get(fn);
-               // The getter might have called the setter, and we should not 
override.
-               if (_destructive)
-               {
-                       _bound = ret;
-                       _destructive = false;
-               }
-               return ret;
-       }
-       return a->get(fn);
-
-}
-
-void
-Property::setDelayedValue(as_object& this_ptr, const as_value& value) const
-{
-       GetterSetter* a = boost::get<GetterSetter>(&_bound);
-
-       as_environment env(getVM(this_ptr));
-
-    fn_call::Args args;
-    args += value;
-
-       fn_call fn(&this_ptr, env, args);
-
-       a->set(fn);
-       a->setCache(value);
-}
-
 void
 Property::setReachable() const
 {
@@ -148,8 +112,25 @@ Property::getValue(const as_object& this_ptr) const
        {
         case TYPE_VALUE:
             return boost::get<as_value>(_bound);
-        case TYPE_GETTER_SETTER: 
-            return getDelayedValue(this_ptr);
+        case TYPE_GETTER_SETTER:
+        {
+            const GetterSetter* a = boost::get<const GetterSetter>(&_bound);
+
+            as_environment env(getVM(this_ptr));
+            fn_call fn(const_cast<as_object*>(&this_ptr), env);
+            if (_destructive)
+            {
+                as_value ret = a->get(fn);
+                // The getter might have called the setter, and we
+                // should not override.
+                if (_destructive) {
+                    _bound = ret;
+                    _destructive = false;
+                }
+                return ret;
+            }
+            return a->get(fn);
+        }
        } 
     return as_value();
 }
@@ -174,7 +155,19 @@ Property::setValue(as_object& this_ptr, const as_value 
&value) const
                 _destructive = false;
                 _bound = value;
             }
-            else setDelayedValue(this_ptr, value);
+            else {
+                GetterSetter* a = boost::get<GetterSetter>(&_bound);
+
+                as_environment env(getVM(this_ptr));
+
+                fn_call::Args args;
+                args += value;
+
+                fn_call fn(&this_ptr, env, args);
+
+                a->set(fn);
+                a->setCache(value);
+            }
             return;
         }
 }

http://git.savannah.gnu.org/cgit//commit/?id=dc495f27fb7673e5ae021af1fd53ef0d53c66cec


commit dc495f27fb7673e5ae021af1fd53ef0d53c66cec
Author: Benjamin Wolsey <address@hidden>
Date:   Wed Sep 29 15:36:24 2010 +0200

    More static_visitors.

diff --git a/libcore/Property.cpp b/libcore/Property.cpp
index 82921ef..7695746 100644
--- a/libcore/Property.cpp
+++ b/libcore/Property.cpp
@@ -18,6 +18,9 @@
 
 #include "Property.h"
 
+#include <boost/variant.hpp>
+#include <boost/bind.hpp>
+
 #include "VM.h"
 #include "as_function.h"
 #include "as_environment.h"
@@ -37,6 +40,26 @@ struct GetCache : public boost::static_visitor<as_value>
     }
 };
 
+struct SetCache : public boost::static_visitor<>
+{
+    result_type operator()(as_value& val, const as_value& n) const {
+        val = n;
+    }
+    result_type operator()(GetterSetter& gs, const as_value& n) const {
+        gs.setCache(n);
+    }
+};
+
+struct SetReachable : public boost::static_visitor<>
+{
+    result_type operator()(const as_value& val) const {
+        val.setReachable();
+    }
+    result_type operator()(const GetterSetter& gs) const {
+        return gs.markReachableResources();
+    }
+};
+
 }
 
 
@@ -115,19 +138,7 @@ Property::setDelayedValue(as_object& this_ptr, const 
as_value& value) const
 void
 Property::setReachable() const
 {
-       switch (_bound.which())
-       {
-        case TYPE_VALUE: 
-                   boost::get<as_value>(_bound).setReachable();
-                   break;
-
-           case TYPE_GETTER_SETTER: 
-           {
-                   const GetterSetter& a = boost::get<GetterSetter>(_bound);
-                   a.markReachableResources();
-                   break;
-           }
-       }
+    return boost::apply_visitor(SetReachable(), _bound);
 }
 
 as_value
@@ -171,15 +182,7 @@ Property::setValue(as_object& this_ptr, const as_value 
&value) const
 void
 Property::setCache(const as_value& value)
 {
-       switch (_bound.which())
-       {
-        case TYPE_VALUE: 
-            _bound = value;
-            return;
-        case TYPE_GETTER_SETTER: 
-            boost::get<GetterSetter&>(_bound).setCache(value);
-            return;
-       }
+    boost::apply_visitor(boost::bind(SetCache(), _1, value), _bound);
 }
 
 } // namespace gnash

-----------------------------------------------------------------------

Summary of changes:
 libcore/DisplayList.cpp                   |   32 ++-----
 libcore/DisplayList.h                     |   44 +---------
 libcore/DisplayObject.cpp                 |   12 ---
 libcore/DisplayObject.h                   |    8 ++-
 libcore/Property.cpp                      |  132 +++++++++++++++--------------
 libcore/Property.h                        |   66 ++++++---------
 libcore/PropertyList.cpp                  |   11 +--
 libcore/PropertyList.h                    |    9 ++-
 libcore/event_id.h                        |   38 ++++----
 testsuite/libcore.all/DisplayListTest.cpp |    5 -
 10 files changed, 145 insertions(+), 212 deletions(-)


hooks/post-receive
-- 
Gnash



reply via email to

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