gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] /srv/bzr/gnash/trunk r11546: clean-up typecasting


From: Markus Gothe
Subject: [Gnash-commit] /srv/bzr/gnash/trunk r11546: clean-up typecasting
Date: Sat, 03 Oct 2009 23:16:21 +0200
User-agent: Bazaar (1.16.1)

------------------------------------------------------------
revno: 11546
committer: Markus Gothe <address@hidden>
branch nick: trunk
timestamp: Sat 2009-10-03 23:16:21 +0200
message:
  clean-up typecasting
modified:
  cygnal/cygnal.cpp
  cygnal/http_server.cpp
  extensions/fileio/fileio.cpp
  gui/dump.cpp
  gui/fb.cpp
  libbase/GnashImageJpeg.cpp
  libcore/Geometry.h
  libcore/SWFMatrix.cpp
  libcore/TextField.cpp
  libcore/parser/action_buffer.cpp
  libcore/swf/DefineFontTag.cpp
  libmedia/ffmpeg/MediaParserFfmpeg.cpp
=== modified file 'cygnal/cygnal.cpp'
--- a/cygnal/cygnal.cpp 2009-10-02 12:41:25 +0000
+++ b/cygnal/cygnal.cpp 2009-10-03 21:16:21 +0000
@@ -713,7 +713,9 @@
                      clock_gettime (CLOCK_REALTIME, &now);
                      // Incoming que stats
                      CQue::que_stats_t *stats = hand->statsin();
-                     float diff = (float)((now.tv_sec - stats->start.tv_sec) + 
((now.tv_nsec - stats->start.tv_nsec)/1e9));
+                     float diff = static_cast<float>(((now.tv_sec -
+                     stats->start.tv_sec) + ((now.tv_nsec -
+                     stats->start.tv_nsec)/1e9)));
                      response << fd
                               << "," << stats->totalbytes
                               << "," << diff

=== modified file 'cygnal/http_server.cpp'
--- a/cygnal/http_server.cpp    2009-09-07 02:21:08 +0000
+++ b/cygnal/http_server.cpp    2009-10-03 21:16:21 +0000
@@ -1037,7 +1037,8 @@
        struct timespec end;
        clock_gettime (CLOCK_REALTIME, &end);
        log_debug("Processing time for GET request was %f seconds",
-                 (float)((end.tv_sec - start.tv_sec) + ((end.tv_nsec - 
start.tv_nsec)/1e9)));
+                 static_cast<float>(((end.tv_sec - start.tv_sec) +
+                 ((end.tv_nsec - start.tv_nsec)/1e9))));
 #endif
     } while(done != true);
     

=== modified file 'extensions/fileio/fileio.cpp'
--- a/extensions/fileio/fileio.cpp      2009-09-09 20:27:25 +0000
+++ b/extensions/fileio/fileio.cpp      2009-10-03 21:16:21 +0000
@@ -534,7 +534,7 @@
 //    GNASH_REPORT_FUNCTION;
     boost::intrusive_ptr<Fileio> ptr = ensureType<Fileio>(fn.this_ptr);
     assert(ptr);    
-    long c = (long) fn.arg(0).to_number();
+    long c = static_cast<long>(fn.arg(0).to_number());
     return as_value(ptr->fseek(c));
 }
 

=== modified file 'gui/dump.cpp'
--- a/gui/dump.cpp      2009-09-21 02:49:55 +0000
+++ b/gui/dump.cpp      2009-10-03 21:16:21 +0000
@@ -164,7 +164,8 @@
     unsigned int sleep_usecs;
 
     if (gettimeofday(&tv, NULL) == 0) {
-        timer_start = (double)tv.tv_sec + (double)tv.tv_usec / 1000000.0;
+        timer_start = static_cast<double>(tv.tv_sec) +
+       static_cast<double>(tv.tv_usec) / 1000000.0;
     }
     else {
         log_error(_("Unable to call gettimeofday."));
@@ -179,8 +180,8 @@
 
     double timer_current = timer_start;
     double timer_nextframe = timer_start;
-    double interval_s = (double)_interval / 1000.0;
-    double timer_exit = timer_start + ((double)_timeout / 1000.0);
+    double interval_s = static_cast<double>(_interval) / 1000.0;
+    double timer_exit = timer_start + (static_cast<double>(_timeout) / 1000.0);
 
     while (!_terminate_request) {
   
@@ -189,10 +190,11 @@
         // polling loop
         while (timer_current < timer_nextframe) {
             // sleep for 95% of remaining usecs, floored at 50
-            sleep_usecs = (int)((timer_nextframe - timer_current) * 950000.0);
+            sleep_usecs = static_cast<int>(((timer_nextframe - timer_current) 
* 950000.0));
             gnashSleep((sleep_usecs < 50) ? 50 : sleep_usecs);
             if (gettimeofday(&tv, NULL) == 0) {
-                timer_current = (double)tv.tv_sec + (double)tv.tv_usec / 
1000000.0;
+                timer_current = static_cast<double>(tv.tv_sec) +
+               static_cast<double>(tv.tv_usec) / 1000000.0;
             } else {
                 log_error(_("Unable to call gettimeofday."));
                 return false;
@@ -212,7 +214,7 @@
     if ((timer_current - timer_start) != 0.0) {
         std::cout << "TIME=" << (timer_current - timer_start) << std::endl;
         std::cout << "FPS_ACTUAL=" << 
-            ((double)(_framecount-1) / (timer_current - timer_start)) << 
std::endl;
+            (static_cast<double>((_framecount-1)) / (timer_current - 
timer_start)) << std::endl;
     }
     return true;
 }
@@ -227,7 +229,7 @@
 DumpGui::setInterval(unsigned int interval)
 {
     std::cout << "INTERVAL=" << interval << std::endl;
-    std::cout << "FPS_DESIRED=" << (1000.0 / (double)interval) << std::endl;
+    std::cout << "FPS_DESIRED=" << (1000.0 / static_cast<double>(interval)) << 
std::endl;
     _interval = interval;
 }
 

=== modified file 'gui/fb.cpp'
--- a/gui/fb.cpp        2009-10-01 13:38:19 +0000
+++ b/gui/fb.cpp        2009-10-03 21:16:21 +0000
@@ -360,7 +360,8 @@
   double start_timer;
   
   if (!gettimeofday(&tv, NULL))
-    start_timer = (double)tv.tv_sec + (double)tv.tv_usec / 1000000.0;
+    start_timer = static_cast<double>(tv.tv_sec) +
+    static_cast<double>(tv.tv_usec) / 1000000.0;
   else
     start_timer = 0.0;
     
@@ -983,8 +984,10 @@
     */
     
     
-    new_x = (int)(((double)new_x - 355) / (1702 - 355) * 1536 + 256);
-    new_y = (int)(((double)new_y - 482) / (1771 - 482) * 1536 + 256);
+    new_x = static_cast<int>(((static_cast<double>(new_x )- 355) / (1702 - 355)
+    * 1536 + 256));
+    new_y = static_cast<int>(((static_cast<double>(new_y) - 482) / (1771 - 482)
+    * 1536 + 256));
     
     
     new_x = new_x * m_stage_width / 2048;

=== modified file 'libbase/GnashImageJpeg.cpp'
--- a/libbase/GnashImageJpeg.cpp        2009-04-20 18:58:59 +0000
+++ b/libbase/GnashImageJpeg.cpp        2009-10-03 21:16:21 +0000
@@ -153,8 +153,8 @@
                // infrequent.  So let's just do it the simple
                // way.
                if (num_bytes > 0) {
-                       while (num_bytes > (long) src->m_pub.bytes_in_buffer) {
-                               num_bytes -= (long) src->m_pub.bytes_in_buffer;
+                       while (num_bytes > 
static_cast<long>(src->m_pub.bytes_in_buffer)) {
+                               num_bytes -= 
static_cast<long>(src->m_pub.bytes_in_buffer);
                                fill_input_buffer(cinfo);
                        }
                        // Handle remainder.
@@ -234,7 +234,7 @@
 {
        finishImage();
 
-       rw_source_IOChannel* src = (rw_source_IOChannel*) m_cinfo.src;
+       rw_source_IOChannel* src = 
reinterpret_cast<rw_source_IOChannel*>(m_cinfo.src);
        delete src;
        m_cinfo.src = NULL;
 

=== modified file 'libcore/Geometry.h'
--- a/libcore/Geometry.h        2009-04-07 12:34:43 +0000
+++ b/libcore/Geometry.h        2009-10-03 21:16:21 +0000
@@ -99,8 +99,8 @@
         boost::int32_t pdx = p.x - A.x;
         boost::int32_t pdy = p.y - A.y;
 
-        double u = ( (double)(pdx) * dx + (double)(pdy) * dy ) /
-            ( (double)(dx)*dx + (double)(dy)*dy );
+        double u = (static_cast<double>(pdx) * dx + static_cast<double>(pdy) * 
dy ) /
+            (static_cast<double>(dx)*dx + static_cast<double>(dy)*dy );
 
         if (u <= 0)
         {
@@ -436,7 +436,7 @@
                 point p0(A.x, A.y);
                 for (int i=1; i<=segCount; ++i)
                 {
-                    float t1 = (float)(i) / segCount;
+                    float t1 = static_cast<float>(i) / segCount;
                     point p1 = Edge::pointOnCurve(A, C, B, t1);
 
                     // distance from point and segment being an approximation 

=== modified file 'libcore/SWFMatrix.cpp'
--- a/libcore/SWFMatrix.cpp     2009-04-08 07:08:06 +0000
+++ b/libcore/SWFMatrix.cpp     2009-10-03 21:16:21 +0000
@@ -203,15 +203,15 @@
 void
 SWFMatrix::set_x_scale(double xscale)
 {
-    double rot_x = atan2((double)shx, (double)sx);
-    sx  =  DoubleToFixed16(xscale * cos(rot_x));
-    shx =  DoubleToFixed16(xscale * sin(rot_x)); 
+    double rot_x = std::atan2(static_cast<double>(shx), 
static_cast<double>(sx));
+    sx  =  DoubleToFixed16(xscale * std::cos(rot_x));
+    shx =  DoubleToFixed16(xscale * std::sin(rot_x)); 
 }
 
 void
 SWFMatrix::set_y_scale(double yscale)
 {
-    double rot_y = std::atan2((double)(-shy), (double)(sy));
+    double rot_y = std::atan2(static_cast<double>(-shy), 
static_cast<double>(sy));
 
     shy = -DoubleToFixed16(yscale * std::sin(rot_y));
     sy  =  DoubleToFixed16(yscale * std::cos(rot_y));
@@ -227,8 +227,9 @@
 void
 SWFMatrix::set_rotation(double rotation)
 {   
-    double rot_x = atan2((double)shx,    (double)sx);
-    double rot_y = atan2((double)(-shy), (double)sy);
+    double rot_x = std::atan2(static_cast<double>(shx), 
static_cast<double>(sx));
+    double rot_y = std::atan2(static_cast<double>(-shy),
+    static_cast<double>(sy));
     double scale_x = get_x_scale();
     double scale_y = get_y_scale();
  
@@ -334,20 +335,20 @@
 double
 SWFMatrix::get_x_scale() const
 {
-    return sqrt(((double)sx * sx + (double)shx * shx)) / 65536.0;
+    return std::sqrt((static_cast<double>(sx) * sx + static_cast<double>(shx) 
* shx)) / 65536.0;
 }
 
 double
 SWFMatrix::get_y_scale() const
 {
-    return sqrt(((double)sy * sy + (double)shy * shy)) / 65536.0;
+    return std::sqrt((static_cast<double>(sy) * sy + static_cast<double>(shy) 
* shy)) / 65536.0;
 }
 
 double
 SWFMatrix::get_rotation() const
 {
     // more successes in misc-ming.all/SWFMatrix_test.c
-    return atan2(static_cast<double>(shx), sx); 
+    return std::atan2(static_cast<double>(shx), sx); 
 }
 
 // private

=== modified file 'libcore/TextField.cpp'
--- a/libcore/TextField.cpp     2009-10-01 17:32:24 +0000
+++ b/libcore/TextField.cpp     2009-10-03 21:16:21 +0000
@@ -410,7 +410,8 @@
     }
 
     _displayRecords.clear();
-    float scale = getFontHeight() / (float)_font->unitsPerEM(_embedFonts);
+    float scale = getFontHeight() /
+    static_cast<float>(_font->unitsPerEM(_embedFonts));
     float fontLeading = _font->leading() * scale;
 
     //offset the lines
@@ -1187,7 +1188,8 @@
     }
 
     boost::uint16_t fontHeight = getFontHeight();
-    float scale = fontHeight / (float)_font->unitsPerEM(_embedFonts); 
+    float scale = fontHeight /
+    static_cast<float>(_font->unitsPerEM(_embedFonts)); 
     float fontDescent = _font->descent() * scale; 
     float fontLeading = _font->leading() * scale;
     boost::uint16_t leftMargin = getLeftMargin();
@@ -1290,7 +1292,8 @@
 TextField::scrollLines()
 {
     boost::uint16_t fontHeight = getFontHeight();
-    float scale = fontHeight / (float)_font->unitsPerEM(_embedFonts);
+    float scale = fontHeight /
+    static_cast<float>(_font->unitsPerEM(_embedFonts));
     float fontLeading = _font->leading() * scale;
     _linesindisplay = _bounds.height() / (fontHeight + fontLeading + 
PADDING_TWIPS);
     if (_linesindisplay > 0) { //no need to place lines if we can't fit any
@@ -1337,7 +1340,8 @@
     LineStarts::iterator linestartit = _line_starts.begin();
     LineStarts::const_iterator linestartend = _line_starts.end();
     
-    float scale = _fontHeight / (float)_font->unitsPerEM(_embedFonts); 
+    float scale = _fontHeight /
+    static_cast<float>(_font->unitsPerEM(_embedFonts)); 
     float fontLeading = _font->leading() * scale;
     float leading = getLeading();
     leading += fontLeading * scale; // not sure this is correct...
@@ -1422,7 +1426,8 @@
     LineStarts::iterator linestartit = _line_starts.begin();
     LineStarts::const_iterator linestartend = _line_starts.end();
     
-    float scale = _fontHeight / (float)_font->unitsPerEM(_embedFonts); 
+    float scale = _fontHeight /
+    static_cast<float>(_font->unitsPerEM(_embedFonts)); 
     float fontDescent = _font->descent() * scale; 
     float fontLeading = _font->leading() * scale;
     float leading = getLeading();

=== modified file 'libcore/parser/action_buffer.cpp'
--- a/libcore/parser/action_buffer.cpp  2009-06-15 11:32:49 +0000
+++ b/libcore/parser/action_buffer.cpp  2009-10-03 21:16:21 +0000
@@ -139,7 +139,7 @@
     // Index the strings.
     for (int ct = 0; ct < count; ct++) {
         // Point into the current action buffer.
-        m_dictionary[ct] = (const char*) &m_buffer[3 + i];
+        m_dictionary[ct] = reinterpret_cast<const char*>(&m_buffer[3 + i]);
 
         while (m_buffer[3 + i]) {
             // safety check.
@@ -512,7 +512,7 @@
         break;
     case 0x3f80:    // big-endian host
         {
-        const boost::uint8_t *cp = (const boost::uint8_t *) p;
+        const boost::uint8_t *cp = static_cast<const boost::uint8_t *>(p);
         u.c.c0 = cp[3];
         u.c.c1 = cp[2];
         u.c.c2 = cp[1];
@@ -533,7 +533,7 @@
 double
 convert_double_wacky(const void *p)
 {
-    const boost::uint8_t *cp = (const boost::uint8_t *)p;    // Handy uchar 
version
+    const boost::uint8_t *cp = static_cast<const boost::uint8_t *>(p);    // 
Handy uchar version
     union {
         double    d;
         boost::uint64_t    i;
@@ -565,7 +565,7 @@
     // exactly representable and that has different values in the
     // four 16-bit words.
     // 0x11223344 is represented as 0x41b1 2233 4400 0000 (bigendian)
-    u.d = (double) 0x11223344;
+    u.d = static_cast<double>(0x11223344);
     switch (u.s.s0) {
     case 0x0000:    // pure little-endian host: swap words only.
         memcpy(&u.l.l1, cp, 4);

=== modified file 'libcore/swf/DefineFontTag.cpp'
--- a/libcore/swf/DefineFontTag.cpp     2009-07-13 08:06:09 +0000
+++ b/libcore/swf/DefineFontTag.cpp     2009-10-03 21:16:21 +0000
@@ -316,7 +316,7 @@
         in.ensureBytes(nGlyphs*2);
         for (size_t i = 0; i < nGlyphs; i++)
         {
-            _glyphTable[i].advance = (float) in.read_s16();
+            _glyphTable[i].advance = static_cast<float>(in.read_s16());
         }
 
         // Bounds table.
@@ -351,9 +351,9 @@
                 char0 = in.read_u8();
                 char1 = in.read_u8();
             }
-            float      adjustment = (float) in.read_s16();
+            float adjustment =  static_cast<float>(in.read_s16());
 
-            kerning_pair       k;
+            kerning_pair k;
             k.m_char0 = char0;
             k.m_char1 = char1;
 

=== modified file 'libmedia/ffmpeg/MediaParserFfmpeg.cpp'
--- a/libmedia/ffmpeg/MediaParserFfmpeg.cpp     2009-06-29 18:02:42 +0000
+++ b/libmedia/ffmpeg/MediaParserFfmpeg.cpp     2009-10-03 21:16:21 +0000
@@ -39,7 +39,7 @@
        // Used to calculate a decimal value from a ffmpeg fraction
        inline double as_double(AVRational time)
        {
-               return time.num / (double) time.den;
+               return time.num / static_cast<double>(time.den);
        }
 
 } // anonymous namespace
@@ -122,7 +122,7 @@
                        return 0; // ??
                }
 
-               newtime = timebase * 
(double)_formatCtx->streams[_videoStreamIndex]->cur_dts;
+               newtime = timebase * 
static_cast<double>(_formatCtx->streams[_videoStreamIndex]->cur_dts);
        }
 
        //av_free_packet( &Packet );
@@ -383,7 +383,7 @@
        if ( _formatCtx->album[0] )     log_debug(_("  Album:'%s'"), 
_formatCtx->album);
 
        // Find first audio and video stream
-       for (unsigned int i = 0; i < (unsigned)_formatCtx->nb_streams; i++)
+       for (unsigned int i = 0; i < static_cast<unsigned 
int>(_formatCtx->nb_streams); i++)
        {
                AVStream* stream = _formatCtx->streams[i];
                if ( ! stream ) 


reply via email to

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