Переглянути джерело

Changed methods in ScriptController to pass vectors by reference instead of by value.
Fixed some warnings found by the static code analyzer.

Darryl Gough 13 роки тому
батько
коміт
4e31ded1d5

+ 1 - 1
gameplay/src/Base.h

@@ -200,7 +200,7 @@ using std::va_list;
         #define USE_NEON
         #define USE_NEON
     #endif
     #endif
 #elif __ANDROID__
 #elif __ANDROID__
-	#include <EGL/egl.h>
+    #include <EGL/egl.h>
     #include <GLES2/gl2.h>
     #include <GLES2/gl2.h>
     #include <GLES2/gl2ext.h>
     #include <GLES2/gl2ext.h>
     extern PFNGLBINDVERTEXARRAYOESPROC glBindVertexArray;
     extern PFNGLBINDVERTEXARRAYOESPROC glBindVertexArray;

+ 5 - 8
gameplay/src/Font.cpp

@@ -139,11 +139,7 @@ Font* Font::create(const char* family, Style style, unsigned int size, Glyph* gl
 
 
     // Create batch for the font.
     // Create batch for the font.
     SpriteBatch* batch = SpriteBatch::create(texture, __fontEffect, 128);
     SpriteBatch* batch = SpriteBatch::create(texture, __fontEffect, 128);
-
-    // Add linear filtering for better font quality.
-    Texture::Sampler* sampler = batch->getSampler();
-    sampler->setFilterMode(Texture::LINEAR, Texture::LINEAR);
-
+	
     // Release __fontEffect since the SpriteBatch keeps a reference to it
     // Release __fontEffect since the SpriteBatch keeps a reference to it
     SAFE_RELEASE(__fontEffect);
     SAFE_RELEASE(__fontEffect);
 
 
@@ -153,6 +149,10 @@ Font* Font::create(const char* family, Style style, unsigned int size, Glyph* gl
         return NULL;
         return NULL;
     }
     }
 
 
+    // Add linear filtering for better font quality.
+    Texture::Sampler* sampler = batch->getSampler();
+    sampler->setFilterMode(Texture::LINEAR, Texture::LINEAR);
+
     // Increase the ref count of the texture to retain it.
     // Increase the ref count of the texture to retain it.
     texture->addRef();
     texture->addRef();
 
 
@@ -193,7 +193,6 @@ Font::Text* Font::createText(const char* text, const Rectangle& area, const Vect
         size = _size;
         size = _size;
     GP_ASSERT(_size);
     GP_ASSERT(_size);
     float scale = (float)size / _size;
     float scale = (float)size / _size;
-    const int length = strlen(text);
     int yPos = area.y;
     int yPos = area.y;
     const float areaHeight = area.height - size;
     const float areaHeight = area.height - size;
     std::vector<int> xPositions;
     std::vector<int> xPositions;
@@ -554,7 +553,6 @@ void Font::drawText(const char* text, const Rectangle& area, const Vector4& colo
         size = _size;
         size = _size;
     GP_ASSERT(_size);
     GP_ASSERT(_size);
     float scale = (float)size / _size;
     float scale = (float)size / _size;
-    const int length = strlen(text);
     int yPos = area.y;
     int yPos = area.y;
     const float areaHeight = area.height - size;
     const float areaHeight = area.height - size;
     std::vector<int> xPositions;
     std::vector<int> xPositions;
@@ -1327,7 +1325,6 @@ int Font::getIndexOrLocation(const char* text, const Rectangle& area, unsigned i
 
 
     // Essentially need to measure text until we reach inLocation.
     // Essentially need to measure text until we reach inLocation.
     float scale = (float)size / _size;
     float scale = (float)size / _size;
-    const int length = strlen(text);
     int yPos = area.y;
     int yPos = area.y;
     const float areaHeight = area.height - size;
     const float areaHeight = area.height - size;
     std::vector<int> xPositions;
     std::vector<int> xPositions;

+ 4 - 3
gameplay/src/Joystick.cpp

@@ -4,7 +4,7 @@
 namespace gameplay
 namespace gameplay
 {
 {
 
 
-Joystick::Joystick() : _relative(true), _innerSize(NULL), _outerSize(NULL)
+Joystick::Joystick() : _radius(1.0f), _relative(true), _innerSize(NULL), _outerSize(NULL)
 {
 {
 }
 }
 
 
@@ -47,6 +47,7 @@ void Joystick::initialize(Theme::Style* style, Properties* properties)
         return;
         return;
     }
     }
     _radius = properties->getFloat("radius");
     _radius = properties->getFloat("radius");
+    GP_ASSERT(_radius != 0.0f);
 
 
     if (properties->exists("relative"))
     if (properties->exists("relative"))
     {
     {
@@ -146,7 +147,7 @@ bool Joystick::touchEvent(Touch::TouchEvent touchEvent, int x, int y, unsigned i
 
 
                 // If the displacement is greater than the radius, then cap the displacement to the
                 // If the displacement is greater than the radius, then cap the displacement to the
                 // radius.
                 // radius.
-                
+                
                 Vector2 value;
                 Vector2 value;
                 if ((fabs(_displacement.x) > _radius) || (fabs(_displacement.y) > _radius))
                 if ((fabs(_displacement.x) > _radius) || (fabs(_displacement.y) > _radius))
                 {
                 {
@@ -182,7 +183,7 @@ bool Joystick::touchEvent(Touch::TouchEvent touchEvent, int x, int y, unsigned i
                 float dy = -(y - ((_relative) ? _screenRegion.y - _bounds.y : 0.0f) - _screenRegion.height * 0.5f);
                 float dy = -(y - ((_relative) ? _screenRegion.y - _bounds.y : 0.0f) - _screenRegion.height * 0.5f);
             
             
                 _displacement.set(dx, dy);
                 _displacement.set(dx, dy);
-            
+            
                 Vector2 value;
                 Vector2 value;
                 if ((fabs(_displacement.x) > _radius) || (fabs(_displacement.y) > _radius))
                 if ((fabs(_displacement.x) > _radius) || (fabs(_displacement.y) > _radius))
                 {
                 {

+ 7 - 11
gameplay/src/Properties.cpp

@@ -17,15 +17,11 @@ Properties::Properties()
 }
 }
 
 
 Properties::Properties(const Properties& copy)
 Properties::Properties(const Properties& copy)
+    : _namespace(copy._namespace), _id(copy._id), _parentID(copy._parentID), _properties(copy._properties)
 {
 {
-    _namespace = copy._namespace;
-    _id = copy._id;
-    _parentID = copy._parentID;
-    _properties = copy._properties;
-    
     _namespaces = std::vector<Properties*>();
     _namespaces = std::vector<Properties*>();
     std::vector<Properties*>::const_iterator it;
     std::vector<Properties*>::const_iterator it;
-    for (it = copy._namespaces.begin(); it < copy._namespaces.end(); it++)
+    for (it = copy._namespaces.begin(); it < copy._namespaces.end(); ++it)
     {
     {
         GP_ASSERT(*it);
         GP_ASSERT(*it);
         _namespaces.push_back(new Properties(**it));
         _namespaces.push_back(new Properties(**it));
@@ -327,7 +323,7 @@ void Properties::readProperties(FILE* file)
 Properties::~Properties()
 Properties::~Properties()
 {
 {
     unsigned int count = _namespaces.size();
     unsigned int count = _namespaces.size();
-    for (unsigned int i = 0; i < count; i++)
+    for (unsigned int i = 0; i < count; ++i)
     {
     {
         SAFE_DELETE(_namespaces[i]);
         SAFE_DELETE(_namespaces[i]);
     }
     }
@@ -423,7 +419,7 @@ void Properties::resolveInheritance(const char* id)
                 derived->_properties = parent->_properties;
                 derived->_properties = parent->_properties;
                 derived->_namespaces = std::vector<Properties*>();
                 derived->_namespaces = std::vector<Properties*>();
                 std::vector<Properties*>::const_iterator itt;
                 std::vector<Properties*>::const_iterator itt;
-                for (itt = parent->_namespaces.begin(); itt < parent->_namespaces.end(); itt++)
+                for (itt = parent->_namespaces.begin(); itt < parent->_namespaces.end(); ++itt)
                 {
                 {
                     GP_ASSERT(*itt);
                     GP_ASSERT(*itt);
                     derived->_namespaces.push_back(new Properties(**itt));
                     derived->_namespaces.push_back(new Properties(**itt));
@@ -512,7 +508,7 @@ const char* Properties::getNextProperty(char** value)
     else
     else
     {
     {
         // Move to the next property
         // Move to the next property
-        _propertiesItr++;
+        ++_propertiesItr;
     }
     }
 
 
     if (_propertiesItr != _properties.end())
     if (_propertiesItr != _properties.end())
@@ -540,7 +536,7 @@ Properties* Properties::getNextNamespace()
     }
     }
     else
     else
     {
     {
-        _namespacesItr++;
+        ++_namespacesItr;
     }
     }
 
 
     if (_namespacesItr != _namespaces.end())
     if (_namespacesItr != _namespaces.end())
@@ -565,7 +561,7 @@ Properties* Properties::getNamespace(const char* id, bool searchNames) const
     Properties* ret = NULL;
     Properties* ret = NULL;
     std::vector<Properties*>::const_iterator it;
     std::vector<Properties*>::const_iterator it;
     
     
-    for (it = _namespaces.begin(); it < _namespaces.end(); it++)
+    for (it = _namespaces.begin(); it < _namespaces.end(); ++it)
     {
     {
         ret = *it;
         ret = *it;
         if (strcmp(searchNames ? ret->_namespace.c_str() : ret->_id.c_str(), id) == 0)
         if (strcmp(searchNames ? ret->_namespace.c_str() : ret->_id.c_str(), id) == 0)

+ 2 - 2
gameplay/src/RadioButton.cpp

@@ -5,7 +5,7 @@ namespace gameplay
 {
 {
 static std::vector<RadioButton*> __radioButtons;
 static std::vector<RadioButton*> __radioButtons;
 
 
-RadioButton::RadioButton() : _selected(false)
+RadioButton::RadioButton() : _selected(false), _image(NULL)
 {
 {
 }
 }
 
 
@@ -123,7 +123,7 @@ bool RadioButton::touchEvent(Touch::TouchEvent evt, int x, int y, unsigned int c
 void RadioButton::clearSelected(const std::string& groupId)
 void RadioButton::clearSelected(const std::string& groupId)
 {
 {
     std::vector<RadioButton*>::const_iterator it;
     std::vector<RadioButton*>::const_iterator it;
-    for (it = __radioButtons.begin(); it < __radioButtons.end(); it++)
+    for (it = __radioButtons.begin(); it < __radioButtons.end(); ++it)
     {
     {
         RadioButton* radioButton = *it;
         RadioButton* radioButton = *it;
         GP_ASSERT(radioButton);
         GP_ASSERT(radioButton);

+ 1 - 1
gameplay/src/Rectangle.cpp

@@ -126,7 +126,7 @@ void Rectangle::inflate(float horizontalAmount, float verticalAmount)
     height += verticalAmount * 2;
     height += verticalAmount * 2;
 }
 }
 
 
-const Rectangle& Rectangle::operator = (const Rectangle& r)
+Rectangle& Rectangle::operator = (const Rectangle& r)
 {
 {
     x = r.x;
     x = r.x;
     y = r.y;
     y = r.y;

+ 1 - 1
gameplay/src/Rectangle.h

@@ -214,7 +214,7 @@ public:
     /**
     /**
      * operator =
      * operator =
      */
      */
-    const Rectangle& operator = (const Rectangle& r);
+    Rectangle& operator = (const Rectangle& r);
 
 
     /**
     /**
      * operator ==
      * operator ==

+ 1 - 1
gameplay/src/RenderState.cpp

@@ -193,7 +193,7 @@ void RenderState::setNodeBinding(Node* node)
         while (itr != _autoBindings.end())
         while (itr != _autoBindings.end())
         {
         {
             applyAutoBinding(itr->first.c_str(), itr->second);
             applyAutoBinding(itr->first.c_str(), itr->second);
-            itr++;
+            ++itr;
         }
         }
     }
     }
 }
 }

+ 1 - 1
gameplay/src/RenderTarget.cpp

@@ -47,7 +47,7 @@ RenderTarget* RenderTarget::getRenderTarget(const char* id)
 
 
     // Search the vector for a matching ID.
     // Search the vector for a matching ID.
     std::vector<RenderTarget*>::const_iterator it;
     std::vector<RenderTarget*>::const_iterator it;
-    for (it = __renderTargets.begin(); it < __renderTargets.end(); it++)
+    for (it = __renderTargets.begin(); it < __renderTargets.end(); ++it)
     {
     {
         RenderTarget* dst = *it;
         RenderTarget* dst = *it;
         GP_ASSERT(dst);
         GP_ASSERT(dst);

+ 3 - 3
gameplay/src/SceneLoader.cpp

@@ -105,7 +105,7 @@ Scene* SceneLoader::loadInternal(const char* url)
 
 
     // Clean up all loaded properties objects.
     // Clean up all loaded properties objects.
     std::map<std::string, Properties*>::iterator iter = _propertiesFromFile.begin();
     std::map<std::string, Properties*>::iterator iter = _propertiesFromFile.begin();
-    for (; iter != _propertiesFromFile.end(); iter++)
+    for (; iter != _propertiesFromFile.end(); ++iter)
     {
     {
         SAFE_DELETE(iter->second);
         SAFE_DELETE(iter->second);
     }
     }
@@ -910,7 +910,7 @@ void SceneLoader::loadReferencedFiles()
 {
 {
     // Load all referenced properties files.
     // Load all referenced properties files.
     std::map<std::string, Properties*>::iterator iter = _properties.begin();
     std::map<std::string, Properties*>::iterator iter = _properties.begin();
-    for (; iter != _properties.end(); iter++)
+    for (; iter != _properties.end(); ++iter)
     {
     {
         if (iter->second == NULL)
         if (iter->second == NULL)
         {
         {
@@ -1090,7 +1090,7 @@ SceneLoader::SceneNode::SceneNode()
 {
 {
 }
 }
 
 
-SceneLoader::SceneNodeProperty::SceneNodeProperty(Type type, std::string url, int index)
+SceneLoader::SceneNodeProperty::SceneNodeProperty(Type type, const std::string& url, int index)
     : _type(type), _url(url), _index(index)
     : _type(type), _url(url), _index(index)
 {
 {
 }
 }

+ 1 - 1
gameplay/src/SceneLoader.h

@@ -56,7 +56,7 @@ private:
             URL = 128
             URL = 128
         };
         };
 
 
-        SceneNodeProperty(Type type, std::string url, int index);
+        SceneNodeProperty(Type type, const std::string& url, int index);
 
 
         Type _type;
         Type _type;
         std::string _url;
         std::string _url;

+ 12 - 12
gameplay/src/ScriptController.cpp

@@ -59,13 +59,13 @@ void ScriptUtil::registerLibrary(const char* name, const luaL_Reg* functions)
     lua_setglobal(sc->_lua, name);
     lua_setglobal(sc->_lua, name);
 }
 }
 
 
-void ScriptUtil::registerConstantBool(std::string name, bool value, std::vector<std::string> scopePath)
+void ScriptUtil::registerConstantBool(const std::string& name, bool value, const std::vector<std::string>& scopePath)
 {
 {
     ScriptController* sc = Game::getInstance()->getScriptController();
     ScriptController* sc = Game::getInstance()->getScriptController();
 
 
     // If the constant is within a scope, get the correct parent 
     // If the constant is within a scope, get the correct parent 
     // table on the stack before setting its value.
     // table on the stack before setting its value.
-    if (scopePath.size() > 0)
+    if (!scopePath.empty())
     {
     {
         lua_getglobal(sc->_lua, scopePath[0].c_str());
         lua_getglobal(sc->_lua, scopePath[0].c_str());
         for (unsigned int i = 1; i < scopePath.size(); i++)
         for (unsigned int i = 1; i < scopePath.size(); i++)
@@ -92,13 +92,13 @@ void ScriptUtil::registerConstantBool(std::string name, bool value, std::vector<
     }
     }
 }
 }
 
 
-void ScriptUtil::registerConstantNumber(std::string name, double value, std::vector<std::string> scopePath)
+void ScriptUtil::registerConstantNumber(const std::string& name, double value, const std::vector<std::string>& scopePath)
 {
 {
     ScriptController* sc = Game::getInstance()->getScriptController();
     ScriptController* sc = Game::getInstance()->getScriptController();
 
 
     // If the constant is within a scope, get the correct parent 
     // If the constant is within a scope, get the correct parent 
     // table on the stack before setting its value.
     // table on the stack before setting its value.
-    if (scopePath.size() > 0)
+    if (!scopePath.empty())
     {
     {
         lua_getglobal(sc->_lua, scopePath[0].c_str());
         lua_getglobal(sc->_lua, scopePath[0].c_str());
         for (unsigned int i = 1; i < scopePath.size(); i++)
         for (unsigned int i = 1; i < scopePath.size(); i++)
@@ -125,13 +125,13 @@ void ScriptUtil::registerConstantNumber(std::string name, double value, std::vec
     }
     }
 }
 }
 
 
-void ScriptUtil::registerConstantString(std::string name, std::string value, std::vector<std::string> scopePath)
+void ScriptUtil::registerConstantString(const std::string& name, const std::string& value, const std::vector<std::string>& scopePath)
 {
 {
     ScriptController* sc = Game::getInstance()->getScriptController();
     ScriptController* sc = Game::getInstance()->getScriptController();
 
 
     // If the constant is within a scope, get the correct parent 
     // If the constant is within a scope, get the correct parent 
     // table on the stack before setting its value.
     // table on the stack before setting its value.
-    if (scopePath.size() > 0)
+    if (!scopePath.empty())
     {
     {
         lua_getglobal(sc->_lua, scopePath[0].c_str());
         lua_getglobal(sc->_lua, scopePath[0].c_str());
         for (unsigned int i = 1; i < scopePath.size(); i++)
         for (unsigned int i = 1; i < scopePath.size(); i++)
@@ -159,13 +159,13 @@ void ScriptUtil::registerConstantString(std::string name, std::string value, std
 }
 }
 
 
 void ScriptUtil::registerClass(const char* name, const luaL_Reg* members, lua_CFunction newFunction, 
 void ScriptUtil::registerClass(const char* name, const luaL_Reg* members, lua_CFunction newFunction, 
-    lua_CFunction deleteFunction, const luaL_Reg* statics,  std::vector<std::string> scopePath)
+    lua_CFunction deleteFunction, const luaL_Reg* statics,  const std::vector<std::string>& scopePath)
 {
 {
     ScriptController* sc = Game::getInstance()->getScriptController();
     ScriptController* sc = Game::getInstance()->getScriptController();
 
 
     // If the type is an inner type, get the correct parent 
     // If the type is an inner type, get the correct parent 
     // table on the stack before creating the table for the class.
     // table on the stack before creating the table for the class.
-    if (scopePath.size() > 0)
+    if (!scopePath.empty())
     {
     {
         std::string tablename = name;
         std::string tablename = name;
 
 
@@ -229,7 +229,7 @@ void ScriptUtil::registerClass(const char* name, const luaL_Reg* members, lua_CF
     }
     }
 
 
     // Set the table we just created within the correct parent table.
     // Set the table we just created within the correct parent table.
-    if (scopePath.size() > 0)
+    if (!scopePath.empty())
     {
     {
         lua_settable(sc->_lua, -3);
         lua_settable(sc->_lua, -3);
 
 
@@ -250,7 +250,7 @@ void ScriptUtil::registerFunction(const char* luaFunction, lua_CFunction cppFunc
     lua_setglobal(Game::getInstance()->getScriptController()->_lua, luaFunction);
     lua_setglobal(Game::getInstance()->getScriptController()->_lua, luaFunction);
 }
 }
 
 
-void ScriptUtil::setGlobalHierarchyPair(std::string base, std::string derived)
+void ScriptUtil::setGlobalHierarchyPair(const std::string& base, const std::string& derived)
 {
 {
     Game::getInstance()->getScriptController()->_hierarchy[base].push_back(derived);
     Game::getInstance()->getScriptController()->_hierarchy[base].push_back(derived);
 }
 }
@@ -784,7 +784,7 @@ void ScriptController::executeFunctionHelper(int resultCount, const char* func,
         GP_WARN("Failed to call function '%s' with error '%s'.", func, lua_tostring(_lua, -1));
         GP_WARN("Failed to call function '%s' with error '%s'.", func, lua_tostring(_lua, -1));
 }
 }
 
 
-void ScriptController::registerCallback(ScriptCallback callback, std::string function)
+void ScriptController::registerCallback(ScriptCallback callback, const std::string& function)
 {
 {
     SAFE_DELETE(_callbacks[callback]);
     SAFE_DELETE(_callbacks[callback]);
     _callbacks[callback] = new std::string(function);
     _callbacks[callback] = new std::string(function);
@@ -1058,4 +1058,4 @@ template<> std::string ScriptController::executeFunction<std::string>(const char
     SCRIPT_EXECUTE_FUNCTION_PARAM_LIST(std::string, luaL_checkstring);
     SCRIPT_EXECUTE_FUNCTION_PARAM_LIST(std::string, luaL_checkstring);
 }
 }
 
 
-}
+}

+ 11 - 11
gameplay/src/ScriptController.h

@@ -114,7 +114,7 @@ void registerLibrary(const char* name, const luaL_Reg* functions);
  * @param scopePath The list of containing classes, going inward from the most outer class.
  * @param scopePath The list of containing classes, going inward from the most outer class.
  * @script{ignore}
  * @script{ignore}
  */
  */
-void registerConstantBool(std::string name, bool value, std::vector<std::string> scopePath);
+void registerConstantBool(const std::string& name, bool value, const std::vector<std::string>& scopePath);
 
 
 /**
 /**
  * Registers the given number constant as valid for the given scope path.
  * Registers the given number constant as valid for the given scope path.
@@ -124,7 +124,7 @@ void registerConstantBool(std::string name, bool value, std::vector<std::string>
  * @param scopePath The list of containing classes, going inward from the most outer class.
  * @param scopePath The list of containing classes, going inward from the most outer class.
  * @script{ignore}
  * @script{ignore}
  */
  */
-void registerConstantNumber(std::string name, double value, std::vector<std::string> scopePath);
+void registerConstantNumber(const std::string& name, double value, const std::vector<std::string>& scopePath);
 
 
 /**
 /**
  * Registers the given string constant as valid for the given scope path.
  * Registers the given string constant as valid for the given scope path.
@@ -134,7 +134,7 @@ void registerConstantNumber(std::string name, double value, std::vector<std::str
  * @param scopePath The list of containing classes, going inward from the most outer class.
  * @param scopePath The list of containing classes, going inward from the most outer class.
  * @script{ignore}
  * @script{ignore}
  */
  */
-void registerConstantString(std::string name, std::string value, std::vector<std::string> scopePath);
+void registerConstantString(const std::string& name, const std::string& value, const std::vector<std::string>& scopePath);
 
 
 /**
 /**
  * Registers the given class type with Lua.
  * Registers the given class type with Lua.
@@ -148,7 +148,7 @@ void registerConstantString(std::string name, std::string value, std::vector<std
  * @script{ignore}
  * @script{ignore}
  */
  */
 void registerClass(const char* name, const luaL_Reg* members, lua_CFunction newFunction, lua_CFunction deleteFunction, const luaL_Reg* statics,
 void registerClass(const char* name, const luaL_Reg* members, lua_CFunction newFunction, lua_CFunction deleteFunction, const luaL_Reg* statics,
-    std::vector<std::string> scopePath = std::vector<std::string>());
+    const std::vector<std::string>& scopePath);
 
 
 /**
 /**
  * Register a function with Lua.
  * Register a function with Lua.
@@ -166,7 +166,7 @@ void registerFunction(const char* luaFunction, lua_CFunction cppFunction);
  * @param derived The derived class of the inheritance pair.
  * @param derived The derived class of the inheritance pair.
  * @script{ignore}
  * @script{ignore}
  */
  */
-void setGlobalHierarchyPair(std::string base, std::string derived);
+void setGlobalHierarchyPair(const std::string& base, const std::string& derived);
 
 
 /**
 /**
  * Adds the given function as a string-from-enumerated value conversion function.
  * Adds the given function as a string-from-enumerated value conversion function.
@@ -781,7 +781,7 @@ private:
      * @param callback The script callback to register for.
      * @param callback The script callback to register for.
      * @param function The name of the function within the Lua script to call.
      * @param function The name of the function within the Lua script to call.
      */
      */
-    void registerCallback(ScriptCallback callback, std::string function);
+    void registerCallback(ScriptCallback callback, const std::string& function);
 
 
     /**
     /**
      * Converts the given string to a valid script callback enumeration value
      * Converts the given string to a valid script callback enumeration value
@@ -794,13 +794,13 @@ private:
 
 
     // Friend functions (used by Lua script bindings).
     // Friend functions (used by Lua script bindings).
     friend void ScriptUtil::registerLibrary(const char* name, const luaL_Reg* functions);
     friend void ScriptUtil::registerLibrary(const char* name, const luaL_Reg* functions);
-    friend void ScriptUtil::registerConstantBool(std::string name, bool value, std::vector<std::string> scopePath);
-    friend void ScriptUtil::registerConstantNumber(std::string name, double value, std::vector<std::string> scopePath);
-    friend void ScriptUtil::registerConstantString(std::string name, std::string value, std::vector<std::string> scopePath);
+    friend void ScriptUtil::registerConstantBool(const std::string& name, bool value, const std::vector<std::string>& scopePath);
+    friend void ScriptUtil::registerConstantNumber(const std::string& name, double value, const std::vector<std::string>& scopePath);
+    friend void ScriptUtil::registerConstantString(const std::string& name, const std::string& value, const std::vector<std::string>& scopePath);
     friend void ScriptUtil::registerClass(const char* name, const luaL_Reg* members, lua_CFunction newFunction,
     friend void ScriptUtil::registerClass(const char* name, const luaL_Reg* members, lua_CFunction newFunction,
-        lua_CFunction deleteFunction, const luaL_Reg* statics, std::vector<std::string> scopePath);
+        lua_CFunction deleteFunction, const luaL_Reg* statics, const std::vector<std::string>& scopePath);
     friend void ScriptUtil::registerFunction(const char* luaFunction, lua_CFunction cppFunction);
     friend void ScriptUtil::registerFunction(const char* luaFunction, lua_CFunction cppFunction);
-    friend void ScriptUtil::setGlobalHierarchyPair(std::string base, std::string derived);
+    friend void ScriptUtil::setGlobalHierarchyPair(const std::string& base, const std::string& derived);
     friend void ScriptUtil::addStringFromEnumConversionFunction(luaStringEnumConversionFunction stringFromEnum);
     friend void ScriptUtil::addStringFromEnumConversionFunction(luaStringEnumConversionFunction stringFromEnum);
     friend ScriptUtil::LuaArray<bool> ScriptUtil::getBoolPointer(int index);
     friend ScriptUtil::LuaArray<bool> ScriptUtil::getBoolPointer(int index);
     friend ScriptUtil::LuaArray<short> ScriptUtil::getShortPointer(int index);
     friend ScriptUtil::LuaArray<short> ScriptUtil::getShortPointer(int index);

+ 1 - 4
gameplay/src/Slider.cpp

@@ -6,7 +6,7 @@ namespace gameplay
 // Fraction of slider to scroll when mouse scrollwheel is used.
 // Fraction of slider to scroll when mouse scrollwheel is used.
 static const float SCROLL_FRACTION = 0.1f;
 static const float SCROLL_FRACTION = 0.1f;
 
 
-Slider::Slider() : _minImage(NULL), _maxImage(NULL), _trackImage(NULL), _markerImage(NULL)
+Slider::Slider() : _min(0.0f), _max(0.0f), _step(0.0f), _value(0.0f), _minImage(NULL), _maxImage(NULL), _trackImage(NULL), _markerImage(NULL)
 {
 {
 }
 }
 
 
@@ -240,9 +240,6 @@ void Slider::drawImages(SpriteBatch* spriteBatch, const Rectangle& clip)
     // The slider is drawn in the center of the control (perpendicular to orientation).
     // The slider is drawn in the center of the control (perpendicular to orientation).
     // The track is stretched according to orientation.
     // The track is stretched according to orientation.
     // Caps and marker are not stretched.
     // Caps and marker are not stretched.
-    const Theme::Border& border = getBorder(_state);
-    const Theme::Padding& padding = getPadding();
-
     const Rectangle& minCapRegion = _minImage->getRegion();
     const Rectangle& minCapRegion = _minImage->getRegion();
     const Rectangle& maxCapRegion = _maxImage->getRegion();
     const Rectangle& maxCapRegion = _maxImage->getRegion();
     const Rectangle& markerRegion = _markerImage->getRegion();
     const Rectangle& markerRegion = _markerImage->getRegion();

+ 11 - 11
gameplay/src/TextBox.cpp

@@ -4,7 +4,7 @@
 namespace gameplay
 namespace gameplay
 {
 {
 
 
-TextBox::TextBox() : _lastKeypress(0)
+TextBox::TextBox() : _textIndex(0), _lastKeypress(0), _fontSize(0), _caretImage(NULL)
 {
 {
 }
 }
 
 
@@ -250,11 +250,11 @@ bool TextBox::keyEvent(Keyboard::KeyEvent evt, int key)
                 {
                 {
                     case Keyboard::KEY_BACKSPACE:
                     case Keyboard::KEY_BACKSPACE:
                     {
                     {
-                        if (textIndex > 0)
+                        if (_textIndex > 0)
                         {
                         {
-                            --textIndex;
-                            _text.erase(textIndex, 1);
-                            font->getLocationAtIndex(_text.c_str(), _textBounds, fontSize, &_caretLocation, textIndex,
+                            --_textIndex;
+                            _text.erase(_textIndex, 1);
+                            font->getLocationAtIndex(_text.c_str(), _textBounds, fontSize, &_caretLocation, _textIndex,
                                 textAlignment, true, rightToLeft);
                                 textAlignment, true, rightToLeft);
 
 
                             _dirty = true;
                             _dirty = true;
@@ -272,11 +272,11 @@ bool TextBox::keyEvent(Keyboard::KeyEvent evt, int key)
                     default:
                     default:
                     {
                     {
                         // Insert character into string.
                         // Insert character into string.
-                        _text.insert(textIndex, 1, (char)key);
+                        _text.insert(_textIndex, 1, (char)key);
                         consume = true;
                         consume = true;
 
 
                         // Get new location of caret.
                         // Get new location of caret.
-                        font->getLocationAtIndex(_text.c_str(), _textBounds, fontSize, &_caretLocation, textIndex + 1,
+                        font->getLocationAtIndex(_text.c_str(), _textBounds, fontSize, &_caretLocation, _textIndex + 1,
                             textAlignment, true, rightToLeft);
                             textAlignment, true, rightToLeft);
 
 
                         if (key == ' ')
                         if (key == ' ')
@@ -286,8 +286,8 @@ bool TextBox::keyEvent(Keyboard::KeyEvent evt, int key)
                                 _caretLocation.y >= _textBounds.y + _textBounds.height)
                                 _caretLocation.y >= _textBounds.y + _textBounds.height)
                             {
                             {
                                 // If not, undo the character insertion.
                                 // If not, undo the character insertion.
-                                _text.erase(textIndex, 1);
-                                font->getLocationAtIndex(_text.c_str(), _textBounds, fontSize, &_caretLocation, textIndex,
+                                _text.erase(_textIndex, 1);
+                                font->getLocationAtIndex(_text.c_str(), _textBounds, fontSize, &_caretLocation, _textIndex,
                                     textAlignment, true, rightToLeft);
                                     textAlignment, true, rightToLeft);
 
 
                                 // No need to check again.
                                 // No need to check again.
@@ -302,8 +302,8 @@ bool TextBox::keyEvent(Keyboard::KeyEvent evt, int key)
                             textBounds.width >= _textBounds.width || textBounds.height >= _textBounds.height)
                             textBounds.width >= _textBounds.width || textBounds.height >= _textBounds.height)
                         {
                         {
                             // If not, undo the character insertion.
                             // If not, undo the character insertion.
-                            _text.erase(textIndex, 1);
-                            font->getLocationAtIndex(_text.c_str(), _textBounds, fontSize, &_caretLocation, textIndex,
+                            _text.erase(_textIndex, 1);
+                            font->getLocationAtIndex(_text.c_str(), _textBounds, fontSize, &_caretLocation, _textIndex,
                                 textAlignment, true, rightToLeft);
                                 textAlignment, true, rightToLeft);
 
 
                             // TextBox is not dirty.
                             // TextBox is not dirty.

+ 1 - 1
gameplay/src/TextBox.h

@@ -152,7 +152,7 @@ protected:
     /**
     /**
      * The index into the TextBox's string that the caret is.
      * The index into the TextBox's string that the caret is.
      */
      */
-    unsigned int textIndex;
+    unsigned int _textIndex;
     
     
     /**
     /**
      * The last character that was entered into the TextBox.
      * The last character that was entered into the TextBox.

+ 5 - 7
gameplay/src/Theme.cpp

@@ -457,7 +457,7 @@ Theme::Style* Theme::getEmptyStyle()
         overlay->addRef();
         overlay->addRef();
         overlay->addRef();
         overlay->addRef();
         overlay->addRef();
         overlay->addRef();
-        emptyStyle = new Theme::Style((Theme*)this, "EMPTY_STYLE", 1.0f / _texture->getWidth(), 1.0f / _texture->getHeight(),
+        emptyStyle = new Theme::Style(const_cast<Theme*>(this), "EMPTY_STYLE", 1.0f / _texture->getWidth(), 1.0f / _texture->getHeight(),
             Theme::Margin::empty(), Theme::Border::empty(), overlay, overlay, overlay, overlay);
             Theme::Margin::empty(), Theme::Border::empty(), overlay, overlay, overlay, overlay);
 
 
         _styles.push_back(emptyStyle);
         _styles.push_back(emptyStyle);
@@ -584,12 +584,10 @@ Theme::ImageList::ImageList(const Vector4& color) : _color(color)
 }
 }
 
 
 Theme::ImageList::ImageList(const ImageList& copy)
 Theme::ImageList::ImageList(const ImageList& copy)
+    : _id(copy._id), _color(copy._color)
 {
 {
-    _id = copy._id;
-    _color = copy._color;
-
     std::vector<ThemeImage*>::const_iterator it;
     std::vector<ThemeImage*>::const_iterator it;
-    for (it = copy._images.begin(); it != copy._images.end(); it++)
+    for (it = copy._images.begin(); it != copy._images.end(); ++it)
     {
     {
         ThemeImage* image = *it;
         ThemeImage* image = *it;
         GP_ASSERT(image);
         GP_ASSERT(image);
@@ -600,7 +598,7 @@ Theme::ImageList::ImageList(const ImageList& copy)
 Theme::ImageList::~ImageList()
 Theme::ImageList::~ImageList()
 {
 {
     std::vector<ThemeImage*>::const_iterator it;
     std::vector<ThemeImage*>::const_iterator it;
-    for (it = _images.begin(); it != _images.end(); it++)
+    for (it = _images.begin(); it != _images.end(); ++it)
     {
     {
         ThemeImage* image = *it;
         ThemeImage* image = *it;
         SAFE_RELEASE(image);
         SAFE_RELEASE(image);
@@ -647,7 +645,7 @@ Theme::ThemeImage* Theme::ImageList::getImage(const char* imageId) const
     GP_ASSERT(imageId);
     GP_ASSERT(imageId);
 
 
     std::vector<ThemeImage*>::const_iterator it;
     std::vector<ThemeImage*>::const_iterator it;
-    for (it = _images.begin(); it != _images.end(); it++)
+    for (it = _images.begin(); it != _images.end(); ++it)
     {
     {
         ThemeImage* image = *it;
         ThemeImage* image = *it;
         GP_ASSERT(image);
         GP_ASSERT(image);

+ 2 - 2
gameplay/src/Transform.cpp

@@ -829,7 +829,7 @@ void Transform::removeListener(Transform::Listener* listener)
 
 
     if (_listeners)
     if (_listeners)
     {
     {
-        for (std::list<TransformListener>::iterator itr = _listeners->begin(); itr != _listeners->end(); itr++)
+        for (std::list<TransformListener>::iterator itr = _listeners->begin(); itr != _listeners->end(); ++itr)
         {
         {
             if ((*itr).listener == listener)
             if ((*itr).listener == listener)
             {
             {
@@ -844,7 +844,7 @@ void Transform::transformChanged()
 {
 {
     if (_listeners)
     if (_listeners)
     {
     {
-        for (std::list<TransformListener>::iterator itr = _listeners->begin(); itr != _listeners->end(); itr++)
+        for (std::list<TransformListener>::iterator itr = _listeners->begin(); itr != _listeners->end(); ++itr)
         {
         {
             TransformListener& l = *itr;
             TransformListener& l = *itr;
             GP_ASSERT(l.listener);
             GP_ASSERT(l.listener);