[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] [SCM] Gnash branch, master, updated. 8b5b04887f20c423fcc7
From: |
Benjamin Wolsey |
Subject: |
[Gnash-commit] [SCM] Gnash branch, master, updated. 8b5b04887f20c423fcc741faac42505c9d05fe86 |
Date: |
Wed, 29 Sep 2010 12:03:53 +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 8b5b04887f20c423fcc741faac42505c9d05fe86 (commit)
via cf412c0c42fd3c00fab544015ccebd148cacfd30 (commit)
via d9139145f11474e83f4171d1556b9c44ba70761f (commit)
via 8a212f2f188c6bfdaced1a21ab6ff6d1635c3789 (commit)
via 40431ff0322f8eb614b4367bc7082f9ea416b06e (commit)
from 141f1452256abd9f10d02797f2f9a3d9a8d8da4d (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=8b5b04887f20c423fcc741faac42505c9d05fe86
commit 8b5b04887f20c423fcc741faac42505c9d05fe86
Author: Benjamin Wolsey <address@hidden>
Date: Wed Sep 29 13:53:27 2010 +0200
Use anonymous namespaces to prevent ODR violations.
diff --git a/libcore/ExternalInterface.cpp b/libcore/ExternalInterface.cpp
index ea6b1f6..450b9b4 100644
--- a/libcore/ExternalInterface.cpp
+++ b/libcore/ExternalInterface.cpp
@@ -50,6 +50,8 @@
namespace gnash {
+namespace {
+
/// Class used to serialize properties of an object to a buffer
class PropsSerializer : public AbstractPropertyVisitor
{
@@ -98,6 +100,8 @@ private:
std::vector<as_value> _noprops;
};
+}
+
#if 0
class ExternalExecutor: public movie_root::AbstractExternalCallback {
public:
diff --git a/libcore/asobj/flash/external/ExternalInterface_as.cpp
b/libcore/asobj/flash/external/ExternalInterface_as.cpp
index 8f99cbd..244acde 100644
--- a/libcore/asobj/flash/external/ExternalInterface_as.cpp
+++ b/libcore/asobj/flash/external/ExternalInterface_as.cpp
@@ -85,6 +85,8 @@ as_value externalinterface_ctor(const fn_call& fn);
void attachExternalInterfaceStaticInterface(as_object& o);
}
+namespace {
+
/// Class used to serialize properties of an object to a buffer
class PropsSerializer : public AbstractPropertyVisitor
{
@@ -133,6 +135,8 @@ private:
std::vector<as_value> _noprops;
};
+}
+
void
registerExternalInterfaceNative(as_object& global)
{
http://git.savannah.gnu.org/cgit//commit/?id=cf412c0c42fd3c00fab544015ccebd148cacfd30
commit cf412c0c42fd3c00fab544015ccebd148cacfd30
Author: Benjamin Wolsey <address@hidden>
Date: Wed Sep 29 11:58:12 2010 +0200
Use another static_visitor, store by ref-to-const.
diff --git a/libcore/Property.cpp b/libcore/Property.cpp
index 12a625e..82921ef 100644
--- a/libcore/Property.cpp
+++ b/libcore/Property.cpp
@@ -25,6 +25,21 @@
namespace gnash {
+namespace {
+
+struct GetCache : public boost::static_visitor<as_value>
+{
+ result_type operator()(as_value& val) const {
+ return val;
+ }
+ result_type operator()(GetterSetter& gs) const {
+ return gs.getCache();
+ }
+};
+
+}
+
+
void
GetterSetter::UserDefinedGetterSetter::markReachableResources() const
{
@@ -131,14 +146,7 @@ Property::getValue(const as_object& this_ptr) const
as_value
Property::getCache() const
{
- switch (_bound.which())
- {
- case TYPE_VALUE:
- return boost::get<as_value&>(_bound);
- case TYPE_GETTER_SETTER:
- return boost::get<GetterSetter&>(_bound).getCache();
- }
- return as_value();
+ return boost::apply_visitor(GetCache(), _bound);
}
void
diff --git a/libcore/as_object.cpp b/libcore/as_object.cpp
index 5d583d0..8bda519 100644
--- a/libcore/as_object.cpp
+++ b/libcore/as_object.cpp
@@ -334,7 +334,7 @@ as_object::add_property(const std::string& name,
as_function& getter,
Property* prop = _members.getProperty(uri);
if (prop) {
- as_value cacheVal = prop->getCache();
+ const as_value& cacheVal = prop->getCache();
// Used to return the return value of addGetterSetter, but this
// is always true.
_members.addGetterSetter(uri, getter, setter, cacheVal);
@@ -558,9 +558,8 @@ as_object::executeTriggers(Property* prop, const ObjectURI&
uri,
// WARNING: getValue might itself invoke a trigger
// (getter-setter)... ouch ?
// TODO: in this case, return the underlying value !
- as_value curVal = prop ? prop->getCache() : as_value();
-
- as_value newVal = trig.call(curVal, val, *this);
+ const as_value& curVal = prop ? prop->getCache() : as_value();
+ const as_value& newVal = trig.call(curVal, val, *this);
// This is a particularly clear and concise way of removing dead triggers.
EraseIf(*_trigs, boost::bind(boost::mem_fn(&Trigger::dead),
@@ -979,9 +978,9 @@ as_object::get_prototype() const
if (!prop) return 0;
if (!visible(*prop, swfVersion)) return 0;
- as_value tmp = prop->getValue(*this);
+ const as_value& proto = prop->getValue(*this);
- return tmp.to_object(getGlobal(*this));
+ return proto.to_object(getGlobal(*this));
}
as_value
diff --git a/testsuite/libcore.all/ClassSizes.cpp
b/testsuite/libcore.all/ClassSizes.cpp
index 2a7286b..2c7da69 100644
--- a/testsuite/libcore.all/ClassSizes.cpp
+++ b/testsuite/libcore.all/ClassSizes.cpp
@@ -82,7 +82,7 @@ using namespace gnash::SWF;
(as_object) \
(DisplayObject) (StaticText) (MorphShape) (Shape) \
(InteractiveObject) (MovieClip) (TextField) (Button) (Movie) \
-(movie_root) (PropFlags)
+(movie_root) (PropFlags) (ObjectURI)
int
main(int /*argc*/, char** /*argv*/)
http://git.savannah.gnu.org/cgit//commit/?id=d9139145f11474e83f4171d1556b9c44ba70761f
commit d9139145f11474e83f4171d1556b9c44ba70761f
Author: Benjamin Wolsey <address@hidden>
Date: Wed Sep 29 10:57:45 2010 +0200
Drop empty property.
diff --git a/libcore/Property.cpp b/libcore/Property.cpp
index 3414b49..12a625e 100644
--- a/libcore/Property.cpp
+++ b/libcore/Property.cpp
@@ -102,9 +102,6 @@ Property::setReachable() const
{
switch (_bound.which())
{
- case TYPE_EMPTY:
- break;
-
case TYPE_VALUE:
boost::get<as_value>(_bound).setReachable();
break;
@@ -123,8 +120,6 @@ Property::getValue(const as_object& this_ptr) const
{
switch (_bound.which())
{
- case TYPE_EMPTY:
- return as_value();
case TYPE_VALUE:
return boost::get<as_value>(_bound);
case TYPE_GETTER_SETTER:
@@ -138,8 +133,6 @@ Property::getCache() const
{
switch (_bound.which())
{
- case TYPE_EMPTY:
- return as_value();
case TYPE_VALUE:
return boost::get<as_value&>(_bound);
case TYPE_GETTER_SETTER:
@@ -153,7 +146,6 @@ Property::setValue(as_object& this_ptr, const as_value
&value) const
{
switch (_bound.which())
{
- case TYPE_EMPTY:
case TYPE_VALUE:
_bound = value;
return;
@@ -173,7 +165,6 @@ Property::setCache(const as_value& value)
{
switch (_bound.which())
{
- case TYPE_EMPTY:
case TYPE_VALUE:
_bound = value;
return;
diff --git a/libcore/Property.h b/libcore/Property.h
index b876df6..de26359 100644
--- a/libcore/Property.h
+++ b/libcore/Property.h
@@ -392,13 +392,12 @@ private:
void setDelayedValue(as_object& this_ptr, const as_value& value) const;
enum Type {
- TYPE_EMPTY,
TYPE_VALUE,
TYPE_GETTER_SETTER
};
// Store the various types of things that can be held.
- typedef boost::variant<boost::blank, as_value, GetterSetter> BoundType;
+ typedef boost::variant<as_value, GetterSetter> BoundType;
/// The value of the property.
mutable BoundType _bound;
http://git.savannah.gnu.org/cgit//commit/?id=8a212f2f188c6bfdaced1a21ab6ff6d1635c3789
commit 8a212f2f188c6bfdaced1a21ab6ff6d1635c3789
Author: Benjamin Wolsey <address@hidden>
Date: Wed Sep 29 10:49:43 2010 +0200
Use more static visitors.
diff --git a/libcore/Property.cpp b/libcore/Property.cpp
index 20f83d0..3414b49 100644
--- a/libcore/Property.cpp
+++ b/libcore/Property.cpp
@@ -17,6 +17,7 @@
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "Property.h"
+
#include "VM.h"
#include "as_function.h"
#include "as_environment.h"
@@ -168,7 +169,7 @@ Property::setValue(as_object& this_ptr, const as_value
&value) const
}
void
-Property::setCache(const as_value &value)
+Property::setCache(const as_value& value)
{
switch (_bound.which())
{
diff --git a/libcore/Property.h b/libcore/Property.h
index 7279a2a..b876df6 100644
--- a/libcore/Property.h
+++ b/libcore/Property.h
@@ -20,38 +20,37 @@
#ifndef GNASH_PROPERTY_H
#define GNASH_PROPERTY_H
+#include <boost/variant.hpp>
+#include <cassert>
+
#include "PropFlags.h"
#include "as_value.h"
#include "ObjectURI.h"
-#include <boost/variant.hpp>
-#include <cassert>
-
namespace gnash {
+ typedef as_value (*as_c_function_ptr)(const fn_call& fn);
+ class as_function;
+}
-typedef as_value (*as_c_function_ptr)(const fn_call& fn);
-
-class as_function;
-class PropertyList;
+namespace gnash {
/// Holder for getter/setter functions
//
/// Getter setter can be user-defined or native ones.
/// This class abstracts the two.
-///
class GetterSetter
{
+ class NativeGetterSetter;
+
template<typename Arg, typename S>
struct GetSetVisitor : public boost::static_visitor<typename
S::result_type>
{
- GetSetVisitor(Arg& arg) : _arg(arg) {}
-
- /// Called on each type.
+ GetSetVisitor(const Arg& arg) : _arg(arg) {}
template<typename T> typename S::result_type operator()(T& t) const {
return S()(t, _arg);
};
private:
- Arg& _arg;
+ const Arg& _arg;
};
struct Set
@@ -66,13 +65,40 @@ class GetterSetter
struct Get
{
typedef as_value result_type;
-
template<typename T, typename Arg>
result_type operator()(T& t, Arg& a) const {
return t.get(a);
}
};
+ struct SetUnderlying : public boost::static_visitor<>
+ {
+ template<typename T>
+ result_type operator()(T& gs, const as_value& val) const {
+ gs.setUnderlying(val);
+ }
+ result_type operator()(NativeGetterSetter&, const as_value&) const {}
+ };
+
+ struct GetUnderlying : public boost::static_visitor<as_value>
+ {
+ template<typename T>
+ result_type operator()(const T& gs) const {
+ return gs.getUnderlying();
+ }
+ result_type operator()(const NativeGetterSetter&) const {
+ return result_type();
+ }
+ };
+
+ struct MarkReachable : public boost::static_visitor<>
+ {
+ template<typename T>
+ result_type operator()(const T& gs) const {
+ gs.markReachableResources();
+ }
+ };
+
public:
/// Construct a user-defined getter-setter
@@ -88,49 +114,29 @@ public:
{}
/// Invoke the getter
- as_value get(const fn_call& fn) const {
+ as_value get(fn_call& fn) const {
GetSetVisitor<const fn_call, Get> s(fn);
return boost::apply_visitor(s, _getset);
}
/// Invoke the setter
void set(const fn_call& fn) {
- GetSetVisitor<const fn_call, Set> s(fn);
+ GetSetVisitor<fn_call, Set> s(fn);
boost::apply_visitor(s, _getset);
}
/// Set the cache value (for user-defined getter-setters)
- void setCache(const as_value& v)
- {
- switch ( _getset.which() )
- {
- case 0: // user-defined
-
boost::get<UserDefinedGetterSetter>(_getset).setUnderlying(v);
- break;
- case 1: // native
- // nothing to do for native
- break;
- }
- }
+ void setCache(const as_value& v) {
+ boost::apply_visitor(boost::bind(SetUnderlying(), _1, v), _getset);
+ }
/// Get the cache value (for user-defined getter-setters)
- as_value getCache() const
- {
- switch (_getset.which())
- {
- case 0: // user-defined
- return boost::get<UserDefinedGetterSetter>(
- _getset).getUnderlying();
- }
- return as_value();
+ as_value getCache() const {
+ return boost::apply_visitor(GetUnderlying(), _getset);
}
- void markReachableResources() const
- {
- if (_getset.which() == 0) {
- boost::get<UserDefinedGetterSetter>(
- _getset).markReachableResources();
- }
+ void markReachableResources() const {
+ boost::apply_visitor(MarkReachable(), _getset);
}
private:
@@ -174,7 +180,7 @@ private:
{
public:
- ScopedLock(const UserDefinedGetterSetter& na)
+ explicit ScopedLock(const UserDefinedGetterSetter& na)
:
_a(na),
_obtainedLock(_a._beingAccessed ? false : true)
@@ -208,7 +214,7 @@ private:
};
/// Native GetterSetter
- class NativeGetterSetter
+ class NativeGetterSetter
{
public:
@@ -226,6 +232,9 @@ private:
_setter(fn);
}
+ /// Nothing to do for native setters.
+ void markReachableResources() const {}
+
private:
as_c_function_ptr _getter;
as_c_function_ptr _setter;
@@ -244,7 +253,6 @@ private:
/// changed.
class Property
{
-
public:
/// Default constructor
@@ -395,7 +403,7 @@ private:
/// The value of the property.
mutable BoundType _bound;
- // TODO: this should be const, but the assignment operator is still needed
+ /// The property identifier (name).
ObjectURI _uri;
/// Properties flags
http://git.savannah.gnu.org/cgit//commit/?id=40431ff0322f8eb614b4367bc7082f9ea416b06e
commit 40431ff0322f8eb614b4367bc7082f9ea416b06e
Author: Benjamin Wolsey <address@hidden>
Date: Wed Sep 29 10:14:17 2010 +0200
Use static visitors for Properties.
diff --git a/libcore/Property.cpp b/libcore/Property.cpp
index be0d5b7..20f83d0 100644
--- a/libcore/Property.cpp
+++ b/libcore/Property.cpp
@@ -33,7 +33,7 @@
GetterSetter::UserDefinedGetterSetter::markReachableResources() const
}
as_value
-GetterSetter::UserDefinedGetterSetter::get(fn_call& fn) const
+GetterSetter::UserDefinedGetterSetter::get(const fn_call& fn) const
{
ScopedLock lock(*this);
if (!lock.obtainedLock()) {
@@ -47,7 +47,7 @@ GetterSetter::UserDefinedGetterSetter::get(fn_call& fn) const
}
void
-GetterSetter::UserDefinedGetterSetter::set(fn_call& fn)
+GetterSetter::UserDefinedGetterSetter::set(const fn_call& fn)
{
ScopedLock lock(*this);
if (!lock.obtainedLock() || ! _setter) {
@@ -132,21 +132,19 @@ Property::getValue(const as_object& this_ptr) const
return as_value();
}
-const as_value&
+as_value
Property::getCache() const
{
- static as_value undefVal;
-
switch (_bound.which())
{
case TYPE_EMPTY:
- return undefVal;
+ return as_value();
case TYPE_VALUE:
return boost::get<as_value&>(_bound);
case TYPE_GETTER_SETTER:
return boost::get<GetterSetter&>(_bound).getCache();
}
- return undefVal;
+ return as_value();
}
void
diff --git a/libcore/Property.h b/libcore/Property.h
index 3fad823..7279a2a 100644
--- a/libcore/Property.h
+++ b/libcore/Property.h
@@ -41,6 +41,38 @@ class PropertyList;
///
class GetterSetter
{
+ template<typename Arg, typename S>
+ struct GetSetVisitor : public boost::static_visitor<typename
S::result_type>
+ {
+ GetSetVisitor(Arg& arg) : _arg(arg) {}
+
+ /// Called on each type.
+ template<typename T> typename S::result_type operator()(T& t) const {
+ return S()(t, _arg);
+ };
+ private:
+ Arg& _arg;
+ };
+
+ struct Set
+ {
+ typedef void result_type;
+ template<typename T, typename Arg>
+ result_type operator()(T& t, Arg& a) const {
+ t.set(a);
+ }
+ };
+
+ struct Get
+ {
+ typedef as_value result_type;
+
+ template<typename T, typename Arg>
+ result_type operator()(T& t, Arg& a) const {
+ return t.get(a);
+ }
+ };
+
public:
/// Construct a user-defined getter-setter
@@ -56,32 +88,15 @@ public:
{}
/// Invoke the getter
- as_value get(fn_call& fn) const
- {
- switch ( _getset.which() )
- {
- case 0: // user-defined
- return
boost::get<UserDefinedGetterSetter>(_getset).get(fn);
- break;
- case 1: // native
- return
boost::get<NativeGetterSetter>(_getset).get(fn);
- break;
- }
- return as_value(); // not reached (TODO: log error ? assert ?)
+ as_value get(const fn_call& fn) const {
+ GetSetVisitor<const fn_call, Get> s(fn);
+ return boost::apply_visitor(s, _getset);
}
/// Invoke the setter
- void set(fn_call& fn)
- {
- switch ( _getset.which() )
- {
- case 0: // user-defined
-
boost::get<UserDefinedGetterSetter>(_getset).set(fn);
- break;
- case 1: // native
- boost::get<NativeGetterSetter>(_getset).set(fn);
- break;
- }
+ void set(const fn_call& fn) {
+ GetSetVisitor<const fn_call, Set> s(fn);
+ boost::apply_visitor(s, _getset);
}
/// Set the cache value (for user-defined getter-setters)
@@ -99,7 +114,7 @@ public:
}
/// Get the cache value (for user-defined getter-setters)
- const as_value& getCache() const
+ as_value getCache() const
{
switch (_getset.which())
{
@@ -107,8 +122,7 @@ public:
return boost::get<UserDefinedGetterSetter>(
_getset).getUnderlying();
}
- static as_value undefVal;
- return undefVal;
+ return as_value();
}
void markReachableResources() const
@@ -135,10 +149,10 @@ private:
{}
/// Invoke the getter
- as_value get(fn_call& fn) const;
+ as_value get(const fn_call& fn) const;
/// Invoke the setter
- void set(fn_call& fn);
+ void set(const fn_call& fn);
/// Get the underlying value
const as_value& getUnderlying() const { return
_underlyingValue; }
@@ -203,12 +217,12 @@ private:
_getter(get), _setter(set) {}
/// Invoke the getter
- as_value get(fn_call& fn) const {
+ as_value get(const fn_call& fn) const {
return _getter(fn);
}
/// Invoke the setter
- void set(fn_call& fn) {
+ void set(const fn_call& fn) {
_setter(fn);
}
@@ -230,7 +244,9 @@ private:
/// changed.
class Property
{
+
public:
+
/// Default constructor
Property(const ObjectURI& uri)
:
@@ -312,7 +328,7 @@ public:
/// to watch for infinitely recurse on calling the getter
/// or setter; Native getter-setter has no cache,
/// undefined will be returned for them.
- const as_value& getCache() const;
+ as_value getCache() const;
/// Set internal cached value of this property
//
-----------------------------------------------------------------------
Summary of changes:
libcore/ExternalInterface.cpp | 4 +
libcore/Property.cpp | 44 +++---
libcore/Property.h | 161 +++++++++++---------
libcore/as_object.cpp | 11 +-
.../asobj/flash/external/ExternalInterface_as.cpp | 4 +
testsuite/libcore.all/ClassSizes.cpp | 2 +-
6 files changed, 127 insertions(+), 99 deletions(-)
hooks/post-receive
--
Gnash
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] [SCM] Gnash branch, master, updated. 8b5b04887f20c423fcc741faac42505c9d05fe86,
Benjamin Wolsey <=