gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash ChangeLog server/as_value.cpp server/fill...


From: Benjamin Wolsey
Subject: [Gnash-commit] gnash ChangeLog server/as_value.cpp server/fill...
Date: Tue, 20 May 2008 11:40:41 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Benjamin Wolsey <bwy>   08/05/20 11:40:41

Modified files:
        .              : ChangeLog 
        server         : as_value.cpp fill_style.cpp 
        server/parser  : BitmapMovieDefinition.h movie_def_impl.h 

Log message:
                * server/fill_style.cpp: squash more non-standard functions (the
                  operations are on doubles anyway, so it doesn't involve any 
more
                  casts than before). Clean up logging.
                * server/parser/{BitmapMovieDefinition,movie_def_impl}.h: ditto.
                * server/as_value.cpp: use std::fmod, drop using namespace 
std;, 
                  drop c_str() for logging, replace snprintf with boost::format
                  (will be slightly slower for those cases), drop snprintf 
ifdef.
                  A slightly faster alternative to boost::format that also 
avoids
                  using non-standard functions would be stringstreams, but it is
                  not as clear. 

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.6655&r2=1.6656
http://cvs.savannah.gnu.org/viewcvs/gnash/server/as_value.cpp?cvsroot=gnash&r1=1.134&r2=1.135
http://cvs.savannah.gnu.org/viewcvs/gnash/server/fill_style.cpp?cvsroot=gnash&r1=1.28&r2=1.29
http://cvs.savannah.gnu.org/viewcvs/gnash/server/parser/BitmapMovieDefinition.h?cvsroot=gnash&r1=1.14&r2=1.15
http://cvs.savannah.gnu.org/viewcvs/gnash/server/parser/movie_def_impl.h?cvsroot=gnash&r1=1.73&r2=1.74

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.6655
retrieving revision 1.6656
diff -u -b -r1.6655 -r1.6656
--- ChangeLog   20 May 2008 09:54:24 -0000      1.6655
+++ ChangeLog   20 May 2008 11:40:39 -0000      1.6656
@@ -1,3 +1,16 @@
+2008-05-20 Benjamin Wolsey <address@hidden>
+
+       * server/fill_style.cpp: squash more non-standard functions (the
+         operations are on doubles anyway, so it doesn't involve any more
+         casts than before). Clean up logging.
+       * server/parser/{BitmapMovieDefinition,movie_def_impl}.h: ditto.
+       * server/as_value.cpp: use std::fmod, drop using namespace std;, 
+         drop c_str() for logging, replace snprintf with boost::format
+         (will be slightly slower for those cases), drop snprintf ifdef.
+         A slightly faster alternative to boost::format that also avoids
+         using non-standard functions would be stringstreams, but it is
+         not as clear. 
+
 2008-05-20 Zou Lunkai <address@hidden>
        
        * server/cxform.{h,cpp}: code refactory, using integral alrithmatic for 
cxform.

Index: server/as_value.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/as_value.cpp,v
retrieving revision 1.134
retrieving revision 1.135
diff -u -b -r1.134 -r1.135
--- server/as_value.cpp 17 May 2008 10:47:09 -0000      1.134
+++ server/as_value.cpp 20 May 2008 11:40:40 -0000      1.135
@@ -33,19 +33,14 @@
 #include "utility.h" // for typeName() and utility::isFinite
 #include "namedStrings.h"
 
-#include <cmath>
+#include <cmath> // std::fmod
 #include <boost/algorithm/string/case_conv.hpp>
 #include <boost/lexical_cast.hpp>
+#include <boost/format.hpp>
 #include <locale>
 #include <sstream>
 #include <iomanip>
 
-#ifdef WIN32
-#      define snprintf _snprintf
-#endif
-
-using namespace std;
-
 // Define the macro below to make abstract equality operator verbose
 //#define GNASH_DEBUG_EQUALITY 1
 
@@ -167,8 +162,8 @@
                                // reference player.
 #if GNASH_DEBUG_CONVERSION_TO_PRIMITIVE
                                log_debug(" %s.to_primitive(STRING) returned 
%s", 
-                                               to_debug_string().c_str(),
-                                               ret.to_debug_string().c_str());
+                                               to_debug_string(),
+                                               ret.to_debug_string());
 #endif
                                if ( ret.is_string() ) return ret.to_string();
                        }
@@ -176,7 +171,7 @@
                        {
 #if GNASH_DEBUG_CONVERSION_TO_PRIMITIVE
                                log_debug(_("to_primitive(%s, STRING) threw an 
ActionTypeError %s"),
-                                               to_debug_string().c_str(), 
e.what());
+                                               to_debug_string(), e.what());
 #endif
                        }
 
@@ -386,7 +381,7 @@
        as_environment env;
        as_value ret = call_method0(method, &env, obj);
 #if GNASH_DEBUG_CONVERSION_TO_PRIMITIVE
-       log_debug("to_primitive: method call returned %s", 
ret.to_debug_string().c_str());
+       log_debug("to_primitive: method call returned %s", 
ret.to_debug_string());
 #endif
        if ( ret.m_type == OBJECT || ret.m_type == AS_FUNCTION ) // not a 
primitive 
        {
@@ -488,7 +483,7 @@
        as_environment env;
        as_value ret = call_method0(method, &env, obj);
 #if GNASH_DEBUG_CONVERSION_TO_PRIMITIVE
-       log_debug("to_primitive: method call returned %s", 
ret.to_debug_string().c_str());
+       log_debug("to_primitive: method call returned %s", 
ret.to_debug_string());
 #endif
        if ( ret.m_type == OBJECT || ret.m_type == AS_FUNCTION ) // not a 
primitive 
        {
@@ -558,7 +553,7 @@
             // just like for any other non-numerical text. This is correct
             // behaviour.
             {
-               return (double)NAN;
+               return static_cast<double>(NAN);
             }
         }
 
@@ -597,7 +592,7 @@
             {
 #if GNASH_DEBUG_CONVERSION_TO_PRIMITIVE
                 log_debug(_("to_primitive(%s, NUMBER) threw an ActionTypeError 
%s"),
-                        to_debug_string().c_str(), e.what());
+                        to_debug_string(), e.what());
 #endif
                 if ( m_type == AS_FUNCTION && swfversion < 6 )
                 {
@@ -639,11 +634,11 @@
 
     if (d < 0)
     {   
-           i = - static_cast<boost::uint32_t>(fmod (-d, 4294967296.0));
+           i = - static_cast<boost::uint32_t>(std::fmod (-d, 4294967296.0));
     }
     else
     {
-           i = static_cast<boost::uint32_t>(fmod (d, 4294967296.0));
+           i = static_cast<boost::uint32_t>(std::fmod (d, 4294967296.0));
     }
     
     return i;
@@ -942,7 +937,7 @@
 
 #ifdef GNASH_DEBUG_EQUALITY
     static int count=0;
-    log_debug("equals(%s, %s) called [%d]", to_debug_string().c_str(), 
v.to_debug_string().c_str(), count++);
+    log_debug("equals(%s, %s) called [%d]", to_debug_string(), 
v.to_debug_string(), count++);
 #endif
 
     int SWFVersion = VM::get().getSWFVersion();
@@ -1019,7 +1014,7 @@
                if ( v.strictly_equals(v2) ) return false;
 
 #ifdef GNASH_DEBUG_EQUALITY
-               log_debug(" 20: convertion to primitive : %s -> %s", 
v.to_debug_string().c_str(), v2.to_debug_string().c_str());
+               log_debug(" 20: convertion to primitive : %s -> %s", 
v.to_debug_string(), v2.to_debug_string());
 #endif
 
                return equals(v2);
@@ -1027,7 +1022,7 @@
        catch (ActionTypeError& e)
        {
 #ifdef GNASH_DEBUG_EQUALITY
-               log_debug(" %s.to_primitive() threw an ActionTypeError %s", 
v.to_debug_string().c_str(), e.what());
+               log_debug(" %s.to_primitive() threw an ActionTypeError %s", 
v.to_debug_string(), e.what());
 #endif
                return false; // no valid conversion
        }
@@ -1045,7 +1040,7 @@
                if ( strictly_equals(v2) ) return false;
 
 #ifdef GNASH_DEBUG_EQUALITY
-               log_debug(" 21: convertion to primitive : %s -> %s", 
to_debug_string().c_str(), v2.to_debug_string().c_str());
+               log_debug(" 21: convertion to primitive : %s -> %s", 
to_debug_string(), v2.to_debug_string());
 #endif
 
                return v2.equals(v);
@@ -1054,7 +1049,7 @@
        {
 
 #ifdef GNASH_DEBUG_EQUALITY
-               log_debug(" %s.to_primitive() threw an ActionTypeError %s", 
to_debug_string().c_str(), e.what());
+               log_debug(" %s.to_primitive() threw an ActionTypeError %s", 
to_debug_string(), e.what());
 #endif
 
                return false; // no valid conversion
@@ -1067,7 +1062,7 @@
        // Both operands are objects (OBJECT,AS_FUNCTION,MOVIECLIP)
        if ( ! is_object() || ! v.is_object() )
        {
-               log_debug("Equals(%s,%s)", to_debug_string().c_str(), 
v.to_debug_string().c_str());
+               log_debug("Equals(%s,%s)", to_debug_string(), 
v.to_debug_string());
        }
 #endif
 
@@ -1082,14 +1077,14 @@
                p = to_primitive(); 
                if ( ! strictly_equals(p) ) ++converted;
 #ifdef GNASH_DEBUG_EQUALITY
-               log_debug(" convertion to primitive (this): %s -> %s", 
to_debug_string().c_str(), p.to_debug_string().c_str());
+               log_debug(" convertion to primitive (this): %s -> %s", 
to_debug_string(), p.to_debug_string());
 #endif
        }
        catch (ActionTypeError& e)
        {
 #ifdef GNASH_DEBUG_CONVERSION_TO_PRIMITIVE 
                log_debug(" %s.to_primitive() threw an ActionTypeError %s",
-                       to_debug_string().c_str(), e.what());
+                       to_debug_string(), e.what());
 #endif
        }
 
@@ -1098,14 +1093,14 @@
                vp = v.to_primitive(); 
                if ( ! v.strictly_equals(vp) ) ++converted;
 #ifdef GNASH_DEBUG_EQUALITY
-               log_debug(" convertion to primitive (that): %s -> %s", 
v.to_debug_string().c_str(), vp.to_debug_string().c_str());
+               log_debug(" convertion to primitive (that): %s -> %s", 
v.to_debug_string(), vp.to_debug_string());
 #endif
        }
        catch (ActionTypeError& e)
        {
 #ifdef GNASH_DEBUG_CONVERSION_TO_PRIMITIVE 
                log_debug(" %s.to_primitive() threw an ActionTypeError %s",
-                       v.to_debug_string().c_str(), e.what());
+                       v.to_debug_string(), e.what());
 #endif
        }
 
@@ -1185,7 +1180,7 @@
 {
 #ifdef GNASH_DEBUG_EQUALITY
     static int count=0;
-    log_debug("equalsSameType(%s, %s) called [%d]", to_debug_string().c_str(), 
v.to_debug_string().c_str(), count++);
+    log_debug("equalsSameType(%s, %s) called [%d]", to_debug_string(), 
v.to_debug_string(), count++);
 #endif
        assert(m_type == v.m_type);
        switch (m_type)
@@ -1237,7 +1232,7 @@
 std::string
 as_value::to_debug_string() const
 {
-       char buf[512];
+    boost::format ret;
 
        switch (m_type)
        {
@@ -1246,19 +1241,19 @@
                case NULLTYPE:
                        return "[null]";
                case BOOLEAN:
-                       sprintf(buf, "[bool:%s]", getBool() ? "true" : "false");
-                       return buf;
+                   ret = boost::format("[bool:%s]") % (getBool() ? "true" : 
"false");
+            return ret.str();
                case OBJECT:
                {
                        as_object* obj = getObj().get();
-                       sprintf(buf, "[object(%s):%p]", typeName(*obj).c_str(), 
(void *)obj);
-                       return buf;
+                       ret = boost::format("[object(%s):%p]") % typeName(*obj) 
% static_cast<void*>(obj);
+                       return ret.str();
                }
                case AS_FUNCTION:
                {
                        as_function* obj = getFun().get();
-                       sprintf(buf, "[function(%s):%p]", 
typeName(*obj).c_str(), (void *)obj);
-                       return buf;
+                       ret = boost::format("[function(%s):%p]") % 
typeName(*obj) % static_cast<void*>(obj);
+                       return ret.str();
                }
                case STRING:
                        return "[string:" + getStr() + "]";
@@ -1276,24 +1271,23 @@
                                character* rebound = sp.get();
                                if ( rebound )
                                {
-                                       snprintf(buf, 511, "[rebound 
%s(%s):%p]",
-                                               typeName(*rebound).c_str(),
-                                               sp.getTarget().c_str(),
-                                               (void*)rebound);
+                                   ret = boost::format("[rebound %s(%s):%p]") 
% 
+                                               typeName(*rebound) % 
sp.getTarget() %
+                                               static_cast<void*>(rebound);
                                }
                                else
                                {
-                                       snprintf(buf, 511, "[dangling 
character:%s]",
-                                               sp.getTarget().c_str());
+                                   ret = boost::format("[dangling 
character:%s]") % 
+                                           sp.getTarget();
                                }
                        }
                        else
                        {
                                character* ch = sp.get();
-                               snprintf(buf, 511, "[%s(%s):%p]", 
typeName(*ch).c_str(), sp.getTarget().c_str(), (void *)ch);
+                               ret = boost::format("[%s(%s):%p]") % 
typeName(*ch) %
+                                               sp.getTarget() % 
static_cast<void*>(ch);
                        }
-                       buf[511] = '\0';
-                       return buf;
+                       return ret.str();
                }
                default:
                        if (is_exception())
@@ -1678,8 +1672,8 @@
        {
                _tgt = _ptr->getOrigTarget();
 #ifdef GNASH_DEBUG_SOFT_REFERENCES
-               log_debug("char %s (%s) was destroyed, stored it's orig target 
(%s) for later rebinding", _ptr->getTarget().c_str(),
-                       typeName(*_ptr).c_str(), _tgt.c_str());
+               log_debug("char %s (%s) was destroyed, stored it's orig target 
(%s) for later rebinding", _ptr->getTarget(),
+                       typeName(*_ptr), _tgt);
 #endif
                _ptr = 0;
        }
@@ -1709,20 +1703,20 @@
        catch (ActionTypeError& e)
        {
                log_debug("%s.to_primitive() threw an error during as_value 
operator+",
-                       to_debug_string().c_str());
+                       to_debug_string());
        }
 
        try { v2 = v2.to_primitive(); }
        catch (ActionTypeError& e)
        {
                log_debug("%s.to_primitive() threw an error during as_value 
operator+",
-                       op2.to_debug_string().c_str());
+                       op2.to_debug_string());
        }
 
 #if GNASH_DEBUG
        log_debug(_("(%s + %s) [primitive conversion done]"),
-                       to_debug_string().c_str(),
-                       v2.to_debug_string().c_str());
+                       to_debug_string(),
+                       v2.to_debug_string());
 #endif
 
        if (is_string() || v2.is_string() )

Index: server/fill_style.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/fill_style.cpp,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -b -r1.28 -r1.29
--- server/fill_style.cpp       18 May 2008 20:36:12 -0000      1.28
+++ server/fill_style.cpp       20 May 2008 11:40:40 -0000      1.29
@@ -28,6 +28,7 @@
 #include "movie_definition.h"
 #include "swf.h"
 #include "GnashException.h"
+#include <cmath> // sqrt, floor
 
 namespace gnash {
 
@@ -96,7 +97,7 @@
 
                IF_VERBOSE_PARSE
                (
-        log_parse("  color: %s", m_color.toString().c_str());
+        log_parse("  color: %s", m_color.toString());
                );
     }
     else if (m_type == SWF::FILL_LINEAR_GRADIENT
@@ -419,7 +420,7 @@
                 float  radius = (im->height() - 1) / 2.0f;
                 float  y = (j - radius) / radius;
                 float  x = (i - radius) / radius;
-                int    ratio = (int) floorf(255.5f * sqrt(x * x + y * y));
+                int    ratio = static_cast<int>(std::floor(255.5f * 
std::sqrt(x * x + y * y)));
                 if (ratio > 255) {
                     ratio = 255;
                 }
@@ -441,7 +442,7 @@
                                float radiusx = radiusy + std::abs(radiusy * 
m_focal_point);
                                float y = (j - radiusy) / radiusy;
                                float x = (i - radiusx) / radiusx;
-                               int ratio = (int) floorf(255.5f * sqrt(x*x + 
y*y));
+                               int ratio = static_cast<int>(std::floor(255.5f 
* std::sqrt(x*x + y*y)));
                                if (ratio > 255)
                                {
                                        ratio = 255;

Index: server/parser/BitmapMovieDefinition.h
===================================================================
RCS file: /sources/gnash/gnash/server/parser/BitmapMovieDefinition.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -b -r1.14 -r1.15
--- server/parser/BitmapMovieDefinition.h       21 Apr 2008 11:27:45 -0000      
1.14
+++ server/parser/BitmapMovieDefinition.h       20 May 2008 11:40:40 -0000      
1.15
@@ -101,11 +101,11 @@
        }
 
        virtual float   get_width_pixels() const {
-               return ceilf(TWIPS_TO_PIXELS(_framesize.width()));
+               return std::ceil(TWIPS_TO_PIXELS(_framesize.width()));
        }
 
        virtual float   get_height_pixels() const {
-               return ceilf(TWIPS_TO_PIXELS(_framesize.height()));
+               return std::ceil(TWIPS_TO_PIXELS(_framesize.height()));
        }
 
        virtual size_t  get_frame_count() const {

Index: server/parser/movie_def_impl.h
===================================================================
RCS file: /sources/gnash/gnash/server/parser/movie_def_impl.h,v
retrieving revision 1.73
retrieving revision 1.74
diff -u -b -r1.73 -r1.74
--- server/parser/movie_def_impl.h      13 May 2008 07:55:00 -0000      1.73
+++ server/parser/movie_def_impl.h      20 May 2008 11:40:41 -0000      1.74
@@ -341,12 +341,12 @@
 
        float   get_width_pixels() const
        {
-               return ceilf(TWIPS_TO_PIXELS(m_frame_size.width()));
+               return std::ceil(TWIPS_TO_PIXELS(m_frame_size.width()));
        }
 
        float   get_height_pixels() const
        {
-               return ceilf(TWIPS_TO_PIXELS(m_frame_size.height()));
+               return std::ceil(TWIPS_TO_PIXELS(m_frame_size.height()));
        }
 
        virtual int     get_version() const { return m_version; }




reply via email to

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