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. 146c5d78235f10cba0fe


From: Benjamin Wolsey
Subject: [Gnash-commit] [SCM] Gnash branch, master, updated. 146c5d78235f10cba0feec31f7fb5bf68edc6c41
Date: Tue, 07 Sep 2010 17:27: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  146c5d78235f10cba0feec31f7fb5bf68edc6c41 (commit)
      from  3e2d3669a2d2ffe97b8c6d8124526a15fe5a5f3a (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=146c5d78235f10cba0feec31f7fb5bf68edc6c41


commit 146c5d78235f10cba0feec31f7fb5bf68edc6c41
Author: Benjamin Wolsey <address@hidden>
Date:   Tue Sep 7 15:48:54 2010 +0200

    Use boost::optional instead of own version.

diff --git a/libcore/asobj/TextFormat_as.cpp b/libcore/asobj/TextFormat_as.cpp
index 0a55bff..2209592 100644
--- a/libcore/asobj/TextFormat_as.cpp
+++ b/libcore/asobj/TextFormat_as.cpp
@@ -18,8 +18,11 @@
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 // 
 
-#include "log.h"
 #include "TextFormat_as.h"
+
+#include <boost/optional.hpp>
+
+#include "log.h"
 #include "fn_call.h"
 #include "Global_as.h"
 #include "builtin_function.h" 
@@ -126,7 +129,7 @@ TwipsToPixels
 /// @tparam F       The function to call to store the value.
 /// @tparam P       A function object to be applied to the argument before
 ///                 storing the value.
-template<typename T, typename U, void(T::*F)(const Optional<U>&), typename P>
+template<typename T, typename U, void(T::*F)(const boost::optional<U>&), 
typename P>
 struct Set
 {
     static as_value set(const fn_call& fn) {
@@ -139,7 +142,7 @@ struct Set
         // Undefined doesn't do anything.
 
         if (arg.is_undefined() || arg.is_null()) {
-            (relay->*F)(Optional<U>());
+            (relay->*F)(boost::optional<U>());
             return as_value();
         }
 
@@ -159,13 +162,13 @@ struct Set
 /// @tparam F       The function to call to retrieve the value.
 /// @tparam P       A function object to be applied to the argument before
 ///                 returning the value.
-template<typename T, typename U, const Optional<U>&(T::*F)() const,
+template<typename T, typename U, const boost::optional<U>&(T::*F)() const,
     typename P = Nothing>
 struct Get
 {
     static as_value get(const fn_call& fn) {
         T* relay = ensure<ThisIsNative<T> >(fn);
-        const Optional<U>& opt = (relay->*F)();
+        const boost::optional<U>& opt = (relay->*F)();
                if (opt) return as_value(P()(*opt));
                
         as_value null;
diff --git a/libcore/asobj/TextFormat_as.h b/libcore/asobj/TextFormat_as.h
index b048df0..67c7e98 100644
--- a/libcore/asobj/TextFormat_as.h
+++ b/libcore/asobj/TextFormat_as.h
@@ -22,12 +22,13 @@
 #ifndef GNASH_TEXTFORMAT_H
 #define GNASH_TEXTFORMAT_H
 
-#include "TextField.h"
-#include "RGBA.h" 
-
 #include <vector>
 #include <boost/cstdint.hpp> 
 #include <string>
+#include <boost/optional.hpp>
+
+#include "TextField.h"
+#include "RGBA.h" 
 
 namespace gnash {
     class as_object;
@@ -35,68 +36,6 @@ namespace gnash {
 
 namespace gnash {  
 
-/// A type to hold a simple value but with an additional 'unset' state.
-//
-/// Most TextFormat values can be 'uninitialized', meaning they are not
-/// taken into account when applying formatting. These values return null
-/// in ActionScript.
-template<typename T>
-class
-Optional
-{
-public:
-
-    /// Construct an Optional<T> with no value set.
-    Optional()
-        :
-        _t(),
-        _set(false)
-    {}
-
-    /// Construct an Optional<T> with an initial value.
-    //
-    /// Implicit construction is allowed.
-    Optional(const T& t)
-        :
-        _t(t),
-        _set(true)
-    {}
-
-    /// Unset this value.
-    void unset() {
-        _set = false;
-    }
-
-    /// Relatively safe conversion to bool via void*.
-    operator const void*() const {
-        return _set ? this : 0;
-    }
-
-    /// Access to value using operator->().
-    const T* operator->() const {
-        assert(_set);
-        return &_t;
-    }
-
-    /// Assign a T to this Optional<T>.
-    Optional<T>& operator=(const T& t) {
-        _t = t;
-        _set = true;
-        return *this;
-    }
-
-    /// Retrieve type only if set (converts to true).
-    const T& operator*() const {
-        assert(_set);
-        return _t;
-    }
-
-private:
-    T _t;
-    bool _set;
-};
-
-
 /// The TextFormat_as Relay type stores text properties.
 //
 /// Most properties can either have a value or be null.
@@ -111,19 +50,19 @@ public:
     ~TextFormat_as() {}
 
     /// Return a Boolean value that indicates whether the text is underlined.
-    const Optional<bool>& underlined() const { return _underline; }
+    const boost::optional<bool>& underlined() const { return _underline; }
     
     /// Return a Boolean value that indicates whether the text is boldface.
-    const Optional<bool>& bold() const { return _bold; }
+    const boost::optional<bool>& bold() const { return _bold; }
 
     /// Return a Boolean value that indicates whether the text is italicized.
-    const Optional<bool>& italic() const { return _italic; }
+    const boost::optional<bool>& italic() const { return _italic; }
 
     /// Return the color of text using this text format.
-    const Optional<rgba>& color() const { return _color; }
+    const boost::optional<rgba>& color() const { return _color; }
 
     /// Whether the text should have a bullet.
-    const Optional<bool>& bullet() const { return _bullet; }
+    const boost::optional<bool>& bullet() const { return _bullet; }
 
     /// The display type (block or inline).
     //
@@ -132,82 +71,82 @@ public:
         return _display;
     }
 
-    const Optional<std::vector<int> >& tabStops() const {
+    const boost::optional<std::vector<int> >& tabStops() const {
         return _tabStops;
     }
 
     /// Indentation from left margin to the first character in the paragraph
-    const Optional<boost::uint16_t>& indent() const { return _indent; }
+    const boost::optional<boost::uint16_t>& indent() const { return _indent; }
     
     /// Paragraph alignment
-    const Optional<TextField::TextAlignment>& align() const { return _align; }
+    const boost::optional<TextField::TextAlignment>& align() const { return 
_align; }
 
     /// Font name.
-    const Optional<std::string>& font() const { return _font; }
+    const boost::optional<std::string>& font() const { return _font; }
 
     // See doc for _target member
-    const Optional<std::string>& target() const { return _target; }
+    const boost::optional<std::string>& target() const { return _target; }
 
     // See doc for _url member
-    const Optional<std::string>& url() const { return _url; }
+    const boost::optional<std::string>& url() const { return _url; }
 
     /// The block indent.
-    const Optional<boost::uint32_t>& blockIndent() const {
+    const boost::optional<boost::uint32_t>& blockIndent() const {
         return _blockIndent;
     }
 
     /// Return a number that indicates the amount of leading vertical
     /// space between lines.
-    const Optional<boost::uint16_t>& leading() const { return _leading; }
+    const boost::optional<boost::uint16_t>& leading() const { return _leading; 
}
 
     /// Indicates the left margin of the paragraph, in points.
-    const Optional<boost::uint16_t>& leftMargin() const { return _leftMargin; }
+    const boost::optional<boost::uint16_t>& leftMargin() const { return 
_leftMargin; }
 
     /// Indicates the right margin of the paragraph in twips
-    const Optional<boost::uint16_t>& rightMargin() const {
+    const boost::optional<boost::uint16_t>& rightMargin() const {
         return _rightMargin;
     }
 
     /// Return a float that indicates the point size in twips.
-    const Optional<boost::uint16_t>& size() const { return _pointSize; }
+    const boost::optional<boost::uint16_t>& size() const { return _pointSize; }
 
     /// Setters
 
-    void targetSet(const Optional<std::string>& s) { _target=s; }
+    void targetSet(const boost::optional<std::string>& s) { _target=s; }
 
-    void urlSet(const Optional<std::string>& s) { _url=s; }
+    void urlSet(const boost::optional<std::string>& s) { _url=s; }
 
-    void underlinedSet(const Optional<bool>& x) { _underline = x; }
+    void underlinedSet(const boost::optional<bool>& x) { _underline = x; }
 
-    void italicSet(const Optional<bool>& x) { _italic = x; }
+    void italicSet(const boost::optional<bool>& x) { _italic = x; }
 
-    void boldSet(const Optional<bool>& x) { _bold = x; }
+    void boldSet(const boost::optional<bool>& x) { _bold = x; }
 
-    void bulletSet(const Optional<bool>& x) { _bullet = x; }
+    void bulletSet(const boost::optional<bool>& x) { _bullet = x; }
 
-    void colorSet(const Optional<rgba>& x) { _color = x; }
+    void colorSet(const boost::optional<rgba>& x) { _color = x; }
 
-    void indentSet(const Optional<boost::uint16_t>& x) { _indent = x; }
+    void indentSet(const boost::optional<boost::uint16_t>& x) { _indent = x; }
 
-    void fontSet(const Optional<std::string>& font) { _font=font; }
+    void fontSet(const boost::optional<std::string>& font) { _font=font; }
     
-    void alignSet(const Optional<TextField::TextAlignment>& x) { _align = x; }
+    void alignSet(const boost::optional<TextField::TextAlignment>& x) { _align 
= x; }
     
     void alignSet(const std::string& align);
     
-    void blockIndentSet(const Optional<boost::uint32_t>& x) {
+    void blockIndentSet(const boost::optional<boost::uint32_t>& x) {
         _blockIndent = x;
     }
     
-    void leadingSet(const Optional<boost::uint16_t>& x) { _leading = x; }
+    void leadingSet(const boost::optional<boost::uint16_t>& x) { _leading = x; 
}
 
-    void leftMarginSet(const Optional<boost::uint16_t>& x) { _leftMargin = x; }
+    void leftMarginSet(const boost::optional<boost::uint16_t>& x) { 
_leftMargin = x; }
 
-    void rightMarginSet(const Optional<boost::uint16_t>& x) {
+    void rightMarginSet(const boost::optional<boost::uint16_t>& x) {
         _rightMargin = x;
     }
 
-    void sizeSet(const Optional<boost::uint16_t>& x) { _pointSize = x; }
+    void sizeSet(const boost::optional<boost::uint16_t>& x) { _pointSize = x; }
 
     void tabStopsSet(const std::vector<int>& tabStops) { _tabStops = tabStops; 
}
 
@@ -217,16 +156,16 @@ public:
 private:
 
     /// A Boolean value that indicates whether the text is underlined.
-    Optional<bool> _underline;
+    boost::optional<bool> _underline;
 
     /// A Boolean value that indicates whether the text is boldface.
-    Optional<bool> _bold;
+    boost::optional<bool> _bold;
 
     /// A Boolean value that indicates whether the text is italicized.
-    Optional<bool> _italic;
+    boost::optional<bool> _italic;
 
     // 
-    Optional<bool> _bullet;
+    boost::optional<bool> _bullet;
     
     TextField::TextFormatDisplay _display;
   
@@ -236,50 +175,50 @@ private:
     /// paragraph is centered. If "right", the paragraph is
     /// right-aligned. If "justify", the paragraph is justified.
     ///
-    Optional<TextField::TextAlignment> _align;
+    boost::optional<TextField::TextAlignment> _align;
 
     // 
-    Optional<boost::uint32_t> _blockIndent;
+    boost::optional<boost::uint32_t> _blockIndent;
 
     /// The color of text using this text format.
     //
     /// A number containing three 8-bit RGB components; for example,
         /// 0xFF0000 is red, 0x00FF00 is green.
-    Optional<rgba> _color;    
+    boost::optional<rgba> _color;    
 
     // The name of a font for text as a string.
-    Optional<std::string> _font;    
+    boost::optional<std::string> _font;    
 
     /// An integer that indicates the indentation from the left
     /// margin to the first DisplayObject in the paragraph (twips)
-    Optional<boost::uint16_t> _indent;
+    boost::optional<boost::uint16_t> _indent;
 
     /// A number that indicates the amount of leading vertical
     /// space between lines (twips)
-    Optional<boost::uint16_t> _leading;
+    boost::optional<boost::uint16_t> _leading;
 
     /// Indicates the left margin of the paragraph, in points (twips)
-    Optional<boost::uint16_t> _leftMargin;
+    boost::optional<boost::uint16_t> _leftMargin;
 
     /// Indicates the right margin of the paragraph, in points (twips).
-    Optional<boost::uint16_t> _rightMargin;
+    boost::optional<boost::uint16_t> _rightMargin;
 
     /// Point size in twips.
-    Optional<boost::uint16_t> _pointSize;
+    boost::optional<boost::uint16_t> _pointSize;
 
     ///
-    Optional<std::vector<int> > _tabStops;
+    boost::optional<std::vector<int> > _tabStops;
 
     /// The target window where the hyperlink is displayed. 
         /// If the target window is an empty string, the text is displayed in
         /// the default target window _self. If the url parameter is
         /// set to an empty string or to the value null, you can get
         /// or set this property, but the property will have no effect.
-    Optional<std::string> _target;
+    boost::optional<std::string> _target;
 
     /// The URL to which the text in this text format hyperlinks.
     /// If url is an empty string, the text does not have a hyperlink
-    Optional<std::string> _url;    
+    boost::optional<std::string> _url;    
 };
 
 void textformat_class_init(as_object& global, const ObjectURI& uri);

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

Summary of changes:
 libcore/asobj/TextFormat_as.cpp |   13 ++-
 libcore/asobj/TextFormat_as.h   |  163 ++++++++++++---------------------------
 2 files changed, 59 insertions(+), 117 deletions(-)


hooks/post-receive
-- 
Gnash



reply via email to

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