gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] /srv/bzr/gnash/trunk r12189: Coding style.


From: Benjamin Wolsey
Subject: [Gnash-commit] /srv/bzr/gnash/trunk r12189: Coding style.
Date: Wed, 19 May 2010 19:50:38 +0200
User-agent: Bazaar (2.0.3)

------------------------------------------------------------
revno: 12189 [merge]
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Wed 2010-05-19 19:50:38 +0200
message:
  Coding style.
modified:
  gui/Player.cpp
  gui/gui.cpp
  libcore/asobj/flash/display/Stage_as.cpp
  libcore/asobj/flash/external/ExternalInterface_as.cpp
  libcore/movie_root.cpp
  libcore/movie_root.h
  testsuite/MovieTester.cpp
=== modified file 'gui/Player.cpp'
--- a/gui/Player.cpp    2010-04-22 00:36:43 +0000
+++ b/gui/Player.cpp    2010-05-19 14:26:54 +0000
@@ -484,13 +484,17 @@
         StringNoCaseEqual noCaseCompare;
         const std::string& str = it->second;
                 
-        movie_root::AllowScriptAccessMode mode = movie_root::sameDomain;
+        movie_root::AllowScriptAccessMode mode = 
+            movie_root::SCRIPT_ACCESS_SAME_DOMAIN;
+        
         if (noCaseCompare(str, "never")) {
-            mode = movie_root::never;
-        } else if (noCaseCompare(str, "sameDomain")) {
-            mode = movie_root::sameDomain;
-        } else if (noCaseCompare(str, "always")) {
-            mode = movie_root::always;
+            mode = movie_root::SCRIPT_ACCESS_NEVER;
+        } 
+        else if (noCaseCompare(str, "sameDomain")) {
+            mode = movie_root::SCRIPT_ACCESS_SAME_DOMAIN;
+        } 
+        else if (noCaseCompare(str, "always")) {
+            mode = movie_root::SCRIPT_ACCESS_ALWAYS;
         }
         log_debug("Setting allowscriptaccess to %s", mode);
         root.setAllowScriptAccess(mode);
@@ -501,14 +505,16 @@
         StringNoCaseEqual noCaseCompare;
         const std::string& str = it->second;
                 
-        movie_root::ScaleMode mode = movie_root::showAll;
+        movie_root::ScaleMode mode = movie_root::SCALEMODE_SHOWALL;
         
         if (noCaseCompare(str, "noScale")) {
-            mode = movie_root::noScale;
-        } else if (noCaseCompare(str, "exactFit")) {
-            mode = movie_root::exactFit;
-        } else if (noCaseCompare(str, "noBorder")) {
-            mode = movie_root::noBorder;
+            mode = movie_root::SCALEMODE_NOSCALE;
+        } 
+        else if (noCaseCompare(str, "exactFit")) {
+            mode = movie_root::SCALEMODE_EXACTFIT;
+        }
+        else if (noCaseCompare(str, "noBorder")) {
+            mode = movie_root::SCALEMODE_NOBORDER;
         }
 
         log_debug("Setting scale mode");
@@ -530,7 +536,7 @@
                 const size_t frame = boost::lexical_cast<size_t>(arg);
                 v.push_back(frame);
             }
-            catch (boost::bad_lexical_cast&) {}
+            catch (const boost::bad_lexical_cast&) {}
         }
 
         // Use default if filename is empty.

=== modified file 'gui/gui.cpp'
--- a/gui/gui.cpp       2010-05-18 08:34:47 +0000
+++ b/gui/gui.cpp       2010-05-19 14:26:54 +0000
@@ -236,8 +236,8 @@
         return;
     }
     
-    if (allow) _stage->setStageScaleMode(movie_root::showAll);
-    else _stage->setStageScaleMode(movie_root::noScale);
+    if (allow) _stage->setStageScaleMode(movie_root::SCALEMODE_SHOWALL);
+    else _stage->setStageScaleMode(movie_root::SCALEMODE_NOSCALE);
 }
     
 void
@@ -277,14 +277,13 @@
     
     // Fetch scale mode
     movie_root::ScaleMode scaleMode = _stage->getStageScaleMode();
+
     switch (scaleMode) {
-    case movie_root::noScale:
-        _xscale = _yscale = 1.0f;
-        break;
+        case movie_root::SCALEMODE_NOSCALE:
+            _xscale = _yscale = 1.0f;
+            break;
         
-    case movie_root::showAll:
-        {
-            
+        case movie_root::SCALEMODE_SHOWALL:
             // set new scale value ( user-pixel / pseudo-pixel ). Do
             // not divide by zero, or we end up with an invalid
             // stage matrix that returns nan values.                   
@@ -294,16 +293,13 @@
             // Scale proportionally, using smallest scale
             if (_xscale < _yscale) {
                 _yscale = _xscale;
-            } else if (_yscale < _xscale) {
+            } 
+            else if (_yscale < _xscale) {
                 _xscale = _yscale;
             }
-            
             break;
-        }
         
-    case movie_root::noBorder:
-        {
-            
+        case movie_root::SCALEMODE_NOBORDER:
             // set new scale value ( user-pixel / pseudo-pixel )
             _xscale = (swfwidth == 0.0f) ? 1.0f : _width / swfwidth;
             _yscale = (swfheight == 0.0f) ? 1.0f : _height / swfheight;
@@ -311,27 +307,21 @@
             // Scale proportionally, using biggest scale
             if (_xscale > _yscale) {
                 _yscale = _xscale;
-            } else if (_yscale > _xscale) {
+            } 
+            else if (_yscale > _xscale) {
                 _xscale = _yscale;
             }
-            
             break;
-        }
         
-    case movie_root::exactFit:
-        {
+        case movie_root::SCALEMODE_EXACTFIT:
             // NOTE: changing aspect ratio is valid!
             _xscale = (swfwidth == 0.0f) ? 1.0f : _width / swfwidth;
             _yscale = (swfheight == 0.0f) ? 1.0f : _height / swfheight;
-            //LOG_ONCE( log_unimpl("Stage.scaleMode=exactFit") );
             break;
-        }
         
-    default:
-        {
+        default:
             log_error("Invalid scaleMode %d", scaleMode);
             break;
-        }
     }
     
     _xoffset=0;

=== modified file 'libcore/asobj/flash/display/Stage_as.cpp'
--- a/libcore/asobj/flash/display/Stage_as.cpp  2010-01-25 18:52:20 +0000
+++ b/libcore/asobj/flash/display/Stage_as.cpp  2010-05-19 14:26:54 +0000
@@ -123,16 +123,20 @@
        }
 
     // Defaults to showAll if the string is invalid.
-    movie_root::ScaleMode mode = movie_root::showAll;
+    movie_root::ScaleMode mode = movie_root::SCALEMODE_SHOWALL;
 
     const int version = getSWFVersion(fn);
     const std::string& str = fn.arg(0).to_string(version);
     
     StringNoCaseEqual noCaseCompare;
     
-    if (noCaseCompare(str, "noScale")) mode = movie_root::noScale;
-    else if (noCaseCompare(str, "exactFit")) mode = movie_root::exactFit;
-    else if (noCaseCompare(str, "noBorder")) mode = movie_root::noBorder;
+    if (noCaseCompare(str, "noScale")) mode = movie_root::SCALEMODE_NOSCALE;
+    else if (noCaseCompare(str, "exactFit")) {
+        mode = movie_root::SCALEMODE_EXACTFIT;
+    }
+    else if (noCaseCompare(str, "noBorder")) {
+        mode = movie_root::SCALEMODE_NOBORDER;
+    }
 
     m.setStageScaleMode(mode);
     return as_value();

=== modified file 'libcore/asobj/flash/external/ExternalInterface_as.cpp'
--- a/libcore/asobj/flash/external/ExternalInterface_as.cpp     2010-05-06 
10:19:43 +0000
+++ b/libcore/asobj/flash/external/ExternalInterface_as.cpp     2010-05-19 
14:26:54 +0000
@@ -45,33 +45,33 @@
 namespace gnash {
 
 namespace {
-as_value externalinterface_addCallback(const fn_call& fn);
-as_value externalinterface_call(const fn_call& fn);
-as_value externalInterfaceConstructor(const fn_call& fn);
-as_value externalinterface_available(const fn_call& fn);
-as_value externalinterface_marshallExceptions(const fn_call& fn);
-as_value externalinterface_objectID(const fn_call& fn);
+    as_value externalinterface_addCallback(const fn_call& fn);
+    as_value externalinterface_call(const fn_call& fn);
+    as_value externalInterfaceConstructor(const fn_call& fn);
+    as_value externalinterface_available(const fn_call& fn);
+    as_value externalinterface_marshallExceptions(const fn_call& fn);
+    as_value externalinterface_objectID(const fn_call& fn);
 
-as_value externalinterface_uArgumentsToXML(const fn_call& fn);
-as_value externalinterface_uArgumentsToAS(const fn_call& fn);
-as_value externalinterface_uAddCallback(const fn_call& fn);
-as_value externalinterface_uArrayToAS(const fn_call& fn);
-as_value externalinterface_uArrayToJS(const fn_call& fn);
-as_value externalinterface_uArrayToXML(const fn_call& fn);
-as_value externalinterface_uCallIn(const fn_call& fn);
-as_value externalinterface_uCallOut(const fn_call& fn);
-as_value externalinterface_uEscapeXML(const fn_call& fn);
-as_value externalinterface_uEvalJS(const fn_call& fn);
-as_value externalinterface_uInitJS(const fn_call& fn);
-as_value externalinterface_uJsQuoteString(const fn_call& fn);
-as_value externalinterface_uObjectID(const fn_call& fn);
-as_value externalinterface_uObjectToAS(const fn_call& fn);
-as_value externalinterface_uObjectToJS(const fn_call& fn);
-as_value externalinterface_uObjectToXML(const fn_call& fn);
-as_value externalinterface_uToAS(const fn_call& fn);
-as_value externalinterface_uToJS(const fn_call& fn);
-as_value externalinterface_uToXML(const fn_call& fn);
-as_value externalinterface_uUnescapeXML(const fn_call& fn);
+    as_value externalinterface_uArgumentsToXML(const fn_call& fn);
+    as_value externalinterface_uArgumentsToAS(const fn_call& fn);
+    as_value externalinterface_uAddCallback(const fn_call& fn);
+    as_value externalinterface_uArrayToAS(const fn_call& fn);
+    as_value externalinterface_uArrayToJS(const fn_call& fn);
+    as_value externalinterface_uArrayToXML(const fn_call& fn);
+    as_value externalinterface_uCallIn(const fn_call& fn);
+    as_value externalinterface_uCallOut(const fn_call& fn);
+    as_value externalinterface_uEscapeXML(const fn_call& fn);
+    as_value externalinterface_uEvalJS(const fn_call& fn);
+    as_value externalinterface_uInitJS(const fn_call& fn);
+    as_value externalinterface_uJsQuoteString(const fn_call& fn);
+    as_value externalinterface_uObjectID(const fn_call& fn);
+    as_value externalinterface_uObjectToAS(const fn_call& fn);
+    as_value externalinterface_uObjectToJS(const fn_call& fn);
+    as_value externalinterface_uObjectToXML(const fn_call& fn);
+    as_value externalinterface_uToAS(const fn_call& fn);
+    as_value externalinterface_uToJS(const fn_call& fn);
+    as_value externalinterface_uToXML(const fn_call& fn);
+    as_value externalinterface_uUnescapeXML(const fn_call& fn);
 }
 
 /// Class used to serialize properties of an object to a buffer
@@ -255,42 +255,48 @@
 as_value
 externalinterface_available(const fn_call& fn)
 {
-//    GNASH_REPORT_FUNCTION;
     movie_root& m = getRoot(fn);
     bool mode = false;
     
     switch (m.getAllowScriptAccess()) {
-      case movie_root::never:
-          mode = false;
-          break;
-      case movie_root::sameDomain:
-      {
-          const std::string& baseurl = m.getOriginalURL();
-          const int MAXHOSTNAMELEN = 128;
-          char hostname[MAXHOSTNAMELEN];
-          if (gethostname(hostname, MAXHOSTNAMELEN) != 0) {
-              mode = false;
-          }
-          // The hostname is empty if running the standalone Gnash from
-          // a terminal, so we can assume the default of sameDomain applies.
-          URL localPath(hostname, baseurl);
-          if (localPath.hostname().empty()) {
-              mode = true;
-          } else {
-              StringNoCaseEqual noCaseCompare;
-              if (!noCaseCompare(localPath.hostname(), hostname)) {
-                  log_security(_("ExternalInterface path %s is outside the SWF 
domain "
-                                 "%s. Cannot access this object."), localPath, 
-                               hostname);
-                  mode = false;
-              }
-          }
-          break;
-      }
-      case movie_root::always:
-          mode = true;
-          break;
-    };
+        case movie_root::SCRIPT_ACCESS_NEVER:
+            mode = false;
+            break;
+      
+        case movie_root::SCRIPT_ACCESS_SAME_DOMAIN:
+        {
+         
+            const std::string& baseurl = m.getOriginalURL();
+            const int MAXHOSTNAMELEN = 128;
+            char hostname[MAXHOSTNAMELEN];
+          
+            if (gethostname(hostname, MAXHOSTNAMELEN) != 0) {
+                mode = false;
+            }
+          
+            // The hostname is empty if running the standalone Gnash from
+            // a terminal, so we can assume the default of sameDomain applies.
+            URL localPath(hostname, baseurl);
+            if (localPath.hostname().empty()) {
+                mode = true;
+            } 
+            else {
+                StringNoCaseEqual noCaseCompare;
+              
+                if (!noCaseCompare(localPath.hostname(), hostname)) {
+                    log_security(_("ExternalInterface path %s is outside "
+                                "the SWF domain %s. Cannot access this "
+                                "object."), localPath, hostname);
+                    mode = false;
+                }
+            }
+            break;
+        }
+      
+        case movie_root::SCRIPT_ACCESS_ALWAYS:
+            mode = true;
+            break;
+    }
     
     return as_value(mode);
 }

=== modified file 'libcore/movie_root.cpp'
--- a/libcore/movie_root.cpp    2010-05-07 08:31:47 +0000
+++ b/libcore/movie_root.cpp    2010-05-19 14:26:54 +0000
@@ -130,13 +130,13 @@
     _rootMovie(0),
     _invalidated(true),
     _disableScripts(false),
-    _processingActionLevel(movie_root::PRIORITY_SIZE),
+    _processingActionLevel(PRIORITY_SIZE),
     _hostfd(-1),
     _quality(QUALITY_HIGH),
     _alignMode(0),
-    _allowScriptAccess(sameDomain),
+    _allowScriptAccess(SCRIPT_ACCESS_SAME_DOMAIN),
     _showMenu(true),
-    _scaleMode(showAll),
+    _scaleMode(SCALEMODE_SHOWALL),
     _displayState(DISPLAYSTATE_NORMAL),
     _recursionLimit(256),
     _timeoutLimit(15),
@@ -544,7 +544,7 @@
     m_viewport_width = w;
     m_viewport_height = h;
 
-    if (_scaleMode == noScale) {
+    if (_scaleMode == SCALEMODE_NOSCALE) {
         //log_debug("Rescaling disabled");
         as_object* stage = getBuiltinObject(*this, NSV::PROP_iSTAGE);
         if (stage) {
@@ -1229,8 +1229,7 @@
 unsigned int
 movie_root::getStageWidth() const
 {
-    if (_scaleMode == noScale)
-    {
+    if (_scaleMode == SCALEMODE_NOSCALE) {
         return m_viewport_width;    
     }
 
@@ -1243,8 +1242,7 @@
 unsigned int
 movie_root::getStageHeight() const
 {
-    if (_scaleMode == noScale)
-    {
+    if (_scaleMode == SCALEMODE_NOSCALE) {
         return m_viewport_height;    
     }
 
@@ -1340,7 +1338,8 @@
     // movie size. If there is not yet a _rootMovie (when scaleMode
     // is passed as a parameter to the player), we also don't notify a 
     // resize.
-    if (_rootMovie && (sm == noScale || _scaleMode == noScale)) {
+    if (_rootMovie && 
+            (sm == SCALEMODE_NOSCALE || _scaleMode == SCALEMODE_NOSCALE)) {
 
         const movie_definition* md = _rootMovie->definition();
         log_debug("Going to or from scaleMode=noScale. Viewport:%dx%d "

=== modified file 'libcore/movie_root.h'
--- a/libcore/movie_root.h      2010-05-07 08:31:47 +0000
+++ b/libcore/movie_root.h      2010-05-19 14:26:54 +0000
@@ -536,10 +536,10 @@
 
     /// The possibile values of Stage.scaleMode
     enum ScaleMode {
-        showAll,
-        noScale,
-        exactFit,
-        noBorder
+        SCALEMODE_SHOWALL,
+        SCALEMODE_NOSCALE,
+        SCALEMODE_EXACTFIT,
+        SCALEMODE_NOBORDER
     };
 
     /// The possible horizonal positions of the Stage
@@ -566,9 +566,9 @@
 
     /// The possibile values of AllowScriptAccess
     enum AllowScriptAccessMode {
-       never,
-       sameDomain,
-       always
+        SCRIPT_ACCESS_NEVER,
+        SCRIPT_ACCESS_SAME_DOMAIN,
+        SCRIPT_ACCESS_ALWAYS
     };
 
     /// Set the current display quality of the entire SWF.

=== modified file 'testsuite/MovieTester.cpp'
--- a/testsuite/MovieTester.cpp 2010-01-01 17:48:26 +0000
+++ b/testsuite/MovieTester.cpp 2010-05-19 14:27:41 +0000
@@ -303,7 +303,7 @@
 {
        _movie_root->set_display_viewport(0, 0, x, y);
 
-       if (_movie_root->getStageScaleMode() != movie_root::noScale )
+       if (_movie_root->getStageScaleMode() != movie_root::SCALEMODE_NOSCALE)
        {
                // TODO: fix to deal with all scale modes
                //       and alignments ?


reply via email to

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