瀏覽代碼

Str: replace size and index types from unsigned to signed [cache clear] (#2941)

https://github.com/urho3d/Urho3D/issues/2940
1vanK 3 年之前
父節點
當前提交
bcbce74b20

+ 29 - 29
Docs/AngelScriptAPI.h

@@ -29509,7 +29509,7 @@ String(float);
 String(double);
 String(double);
 String(bool);
 String(bool);
 String(int8);
 String(int8);
-String(int8, uint);
+String(int8, int);
 String(const char*);
 String(const char*);
 // Methods:
 // Methods:
 String  operator+(bool) const;
 String  operator+(bool) const;
@@ -29537,15 +29537,15 @@ String&  operator=(float);
 String&  operator=(int);
 String&  operator=(int);
 String&  operator=(uint);
 String&  operator=(uint);
 bool  operator==(const String&) const;
 bool  operator==(const String&) const;
-int8&  operator[](uint);
+int8&  operator[](int);
 String& Append(const String&);
 String& Append(const String&);
 String& Append(int8);
 String& Append(int8);
 String& AppendUTF8(uint);
 String& AppendUTF8(uint);
-int8& At(uint);
-uint AtUTF8(uint) const;
+int8& At(int);
+uint AtUTF8(int) const;
 int8 Back() const;
 int8 Back() const;
-uint ByteOffsetUTF8(uint) const;
-uint Capacity() const;
+int ByteOffsetUTF8(int) const;
+int Capacity() const;
 void Clear();
 void Clear();
 void Compact();
 void Compact();
 int Compare(const String&, bool = true) const;
 int Compare(const String&, bool = true) const;
@@ -29553,33 +29553,33 @@ bool Contains(const String&, bool = true) const;
 bool Contains(int8, bool = true) const;
 bool Contains(int8, bool = true) const;
 bool Empty() const;
 bool Empty() const;
 bool EndsWith(const String&, bool = true) const;
 bool EndsWith(const String&, bool = true) const;
-void Erase(uint, uint = 1);
-uint Find(const String&, uint = 0, bool = true) const;
-uint Find(int8, uint = 0, bool = true) const;
-uint FindLast(const String&, uint = String :: NPOS, bool = true) const;
-uint FindLast(int8, uint = String :: NPOS, bool = true) const;
+void Erase(int, int = 1);
+int Find(const String&, int = 0, bool = true) const;
+int Find(int8, int = 0, bool = true) const;
+int FindLast(const String&, int = String :: NPOS, bool = true) const;
+int FindLast(int8, int = String :: NPOS, bool = true) const;
 int8 Front() const;
 int8 Front() const;
-void Insert(uint, const String&);
-void Insert(uint, int8);
+void Insert(int, const String&);
+void Insert(int, int8);
 bool IsShort() const;
 bool IsShort() const;
 void Join(Array<String>, const String&);
 void Join(Array<String>, const String&);
-uint Length() const;
-uint LengthUTF8() const;
-uint NextUTF8Char(uint&) const;
+int Length() const;
+int LengthUTF8() const;
+uint NextUTF8Char(int&) const;
 void Replace(const String&, const String&, bool = true);
 void Replace(const String&, const String&, bool = true);
+void Replace(int, int, const String&);
 void Replace(int8, int8, bool = true);
 void Replace(int8, int8, bool = true);
-void Replace(uint, uint, const String&);
-void ReplaceUTF8(uint, uint);
+void ReplaceUTF8(int, uint);
 String Replaced(const String&, const String&, bool = true) const;
 String Replaced(const String&, const String&, bool = true) const;
 String Replaced(int8, int8, bool = true) const;
 String Replaced(int8, int8, bool = true) const;
-void Reserve(uint);
-void Resize(uint);
+void Reserve(int);
+void Resize(int);
 Array<String> Split(int8, bool = false) const;
 Array<String> Split(int8, bool = false) const;
 bool StartsWith(const String&, bool = true) const;
 bool StartsWith(const String&, bool = true) const;
-String Substring(uint) const;
-String Substring(uint, uint) const;
-String SubstringUTF8(uint) const;
-String SubstringUTF8(uint, uint) const;
+String Substring(int) const;
+String Substring(int, int) const;
+String SubstringUTF8(int) const;
+String SubstringUTF8(int, int) const;
 void Swap(String&);
 void Swap(String&);
 bool ToBool() const;
 bool ToBool() const;
 Color ToColor() const;
 Color ToColor() const;
@@ -29604,20 +29604,20 @@ Vector3 ToVector3() const;
 Vector4 ToVector4(bool allowMissingCoords = false) const;
 Vector4 ToVector4(bool allowMissingCoords = false) const;
 Variant ToVectorVariant() const;
 Variant ToVectorVariant() const;
 String Trimmed() const;
 String Trimmed() const;
-const int8&  operator[](uint) const;
-const int8& At(uint) const;
+const int8&  operator[](int) const;
+const int8& At(int) const;
 
 
 // Properties:
 // Properties:
 /* readonly */
 /* readonly */
 bool empty;
 bool empty;
 /* readonly */
 /* readonly */
-uint length;
+int length;
 /* readonly */
 /* readonly */
-uint utf8Length;
+int utf8Length;
 
 
 // Constants:
 // Constants:
 static const String EMPTY;
 static const String EMPTY;
-static const uint NPOS;
+static const int NPOS;
 };
 };
 
 
 class StringHash
 class StringHash

+ 28 - 28
Docs/ScriptAPI.dox

@@ -30506,15 +30506,15 @@ Methods:
 - String&  operator=(int)
 - String&  operator=(int)
 - String&  operator=(uint)
 - String&  operator=(uint)
 - bool  operator==(const String&) const
 - bool  operator==(const String&) const
-- int8&  operator[ ](uint)
+- int8&  operator[ ](int)
 - String& Append(const String&)
 - String& Append(const String&)
 - String& Append(int8)
 - String& Append(int8)
 - String& AppendUTF8(uint)
 - String& AppendUTF8(uint)
-- int8& At(uint)
-- uint AtUTF8(uint) const
+- int8& At(int)
+- uint AtUTF8(int) const
 - int8 Back() const
 - int8 Back() const
-- uint ByteOffsetUTF8(uint) const
-- uint Capacity() const
+- int ByteOffsetUTF8(int) const
+- int Capacity() const
 - void Clear()
 - void Clear()
 - void Compact()
 - void Compact()
 - int Compare(const String&, bool = true) const
 - int Compare(const String&, bool = true) const
@@ -30522,33 +30522,33 @@ Methods:
 - bool Contains(int8, bool = true) const
 - bool Contains(int8, bool = true) const
 - bool Empty() const
 - bool Empty() const
 - bool EndsWith(const String&, bool = true) const
 - bool EndsWith(const String&, bool = true) const
-- void Erase(uint, uint = 1)
-- uint Find(const String&, uint = 0, bool = true) const
-- uint Find(int8, uint = 0, bool = true) const
-- uint FindLast(const String&, uint = String :: NPOS, bool = true) const
-- uint FindLast(int8, uint = String :: NPOS, bool = true) const
+- void Erase(int, int = 1)
+- int Find(const String&, int = 0, bool = true) const
+- int Find(int8, int = 0, bool = true) const
+- int FindLast(const String&, int = String :: NPOS, bool = true) const
+- int FindLast(int8, int = String :: NPOS, bool = true) const
 - int8 Front() const
 - int8 Front() const
-- void Insert(uint, const String&)
-- void Insert(uint, int8)
+- void Insert(int, const String&)
+- void Insert(int, int8)
 - bool IsShort() const
 - bool IsShort() const
 - void Join(String[]@, const String&)
 - void Join(String[]@, const String&)
-- uint Length() const
-- uint LengthUTF8() const
-- uint NextUTF8Char(uint&) const
+- int Length() const
+- int LengthUTF8() const
+- uint NextUTF8Char(int&) const
 - void Replace(const String&, const String&, bool = true)
 - void Replace(const String&, const String&, bool = true)
+- void Replace(int, int, const String&)
 - void Replace(int8, int8, bool = true)
 - void Replace(int8, int8, bool = true)
-- void Replace(uint, uint, const String&)
-- void ReplaceUTF8(uint, uint)
+- void ReplaceUTF8(int, uint)
 - String Replaced(const String&, const String&, bool = true) const
 - String Replaced(const String&, const String&, bool = true) const
 - String Replaced(int8, int8, bool = true) const
 - String Replaced(int8, int8, bool = true) const
-- void Reserve(uint)
-- void Resize(uint)
+- void Reserve(int)
+- void Resize(int)
 - String[]@ Split(int8, bool = false) const
 - String[]@ Split(int8, bool = false) const
 - bool StartsWith(const String&, bool = true) const
 - bool StartsWith(const String&, bool = true) const
-- String Substring(uint) const
-- String Substring(uint, uint) const
-- String SubstringUTF8(uint) const
-- String SubstringUTF8(uint, uint) const
+- String Substring(int) const
+- String Substring(int, int) const
+- String SubstringUTF8(int) const
+- String SubstringUTF8(int, int) const
 - void Swap(String&)
 - void Swap(String&)
 - bool ToBool() const
 - bool ToBool() const
 - Color ToColor() const
 - Color ToColor() const
@@ -30573,19 +30573,19 @@ Methods:
 - Vector4 ToVector4(bool allowMissingCoords = false) const
 - Vector4 ToVector4(bool allowMissingCoords = false) const
 - Variant ToVectorVariant() const
 - Variant ToVectorVariant() const
 - String Trimmed() const
 - String Trimmed() const
-- const int8&  operator[ ](uint) const
-- const int8& At(uint) const
+- const int8&  operator[ ](int) const
+- const int8& At(int) const
 
 
 Properties:
 Properties:
 
 
 - bool empty // readonly
 - bool empty // readonly
-- uint length // readonly
-- uint utf8Length // readonly
+- int length // readonly
+- int utf8Length // readonly
 
 
 Constants:
 Constants:
 
 
 - String EMPTY
 - String EMPTY
-- uint NPOS
+- int NPOS
 
 
 <a name="Class_StringHash"></a>
 <a name="Class_StringHash"></a>
 
 

+ 2 - 2
Source/Tools/AssetImporter/AssetImporter.cpp

@@ -1286,7 +1286,7 @@ void BuildAndSaveAnimations(OutModel* model)
             if (model)
             if (model)
             {
             {
                 unsigned boneIndex;
                 unsigned boneIndex;
-                unsigned pos = channelName.Find("_$AssimpFbx$");
+                i32 pos = channelName.Find("_$AssimpFbx$");
 
 
                 if (!suppressFbxPivotNodes_ || pos == String::NPOS)
                 if (!suppressFbxPivotNodes_ || pos == String::NPOS)
                 {
                 {
@@ -2783,7 +2783,7 @@ void ExtrapolatePivotlessAnimation(OutModel* model)
             {
             {
                 aiNodeAnim* channel = anim->mChannels[j];
                 aiNodeAnim* channel = anim->mChannels[j];
                 String channelName = FromAIString(channel->mNodeName);
                 String channelName = FromAIString(channel->mNodeName);
-                unsigned pos = channelName.Find("_$AssimpFbx$");
+                i32 pos = channelName.Find("_$AssimpFbx$");
 
 
                 if (pos != String::NPOS)
                 if (pos != String::NPOS)
                 {
                 {

+ 1 - 1
Source/Tools/PackageTool/PackageTool.cpp

@@ -164,7 +164,7 @@ void Unpack(const Vector<String>& arguments)
     {
     {
         HashMap<String, PackageEntry>::ConstIterator current = i++;
         HashMap<String, PackageEntry>::ConstIterator current = i++;
         String outFilePath(dirName + "/" + current->first_);
         String outFilePath(dirName + "/" + current->first_);
-        unsigned pos = outFilePath.FindLast('/');
+        i32 pos = outFilePath.FindLast('/');
         if (pos == String::NPOS)
         if (pos == String::NPOS)
             ErrorExit("pos == String::NPOS");
             ErrorExit("pos == String::NPOS");
 
 

+ 2 - 2
Source/Urho3D/AngelScript/Addons.cpp

@@ -2323,9 +2323,9 @@ static void ConstructStringCopy(const String& str, String* ptr)
     new(ptr) String(str);
     new(ptr) String(str);
 }
 }
 
 
-static char* StringCharAt(unsigned i, String& str)
+static char* StringCharAt(i32 i, String& str)
 {
 {
-    if (i >= str.Length())
+    if (i < 0 || i >= str.Length())
     {
     {
         asIScriptContext* context = asGetActiveContext();
         asIScriptContext* context = asGetActiveContext();
         if (context)
         if (context)

+ 5 - 5
Source/Urho3D/AngelScript/Generated_Classes.cpp

@@ -2484,8 +2484,8 @@ static void String__String_char(String* _ptr, char value)
     new(_ptr) String(value);
     new(_ptr) String(value);
 }
 }
 
 
-// explicit String::String(char value, unsigned length)
-static void String__String_char_unsigned(String* _ptr, char value, unsigned length)
+// explicit String::String(char value, i32 length)
+static void String__String_char_i32(String* _ptr, char value, i32 length)
 {
 {
     new(_ptr) String(value, length);
     new(_ptr) String(value, length);
 }
 }
@@ -2499,7 +2499,7 @@ static void Register_String(asIScriptEngine* engine)
     // Error: type "char*" can not automatically bind
     // Error: type "char*" can not automatically bind
     // String::String(const char* str)
     // String::String(const char* str)
     // Error: type "const char*" can not automatically bind
     // Error: type "const char*" can not automatically bind
-    // String::String(const char* str, unsigned length)
+    // String::String(const char* str, i32 length)
     // Error: type "const char*" can not automatically bind
     // Error: type "const char*" can not automatically bind
     // explicit String::String(const WString& str)
     // explicit String::String(const WString& str)
     // Error: type "WString" can not automatically bind bacause have @nobind mark
     // Error: type "WString" can not automatically bind bacause have @nobind mark
@@ -2536,8 +2536,8 @@ static void Register_String(asIScriptEngine* engine)
     engine->RegisterObjectBehaviour("String", asBEHAVE_CONSTRUCT, "void f(bool)", AS_FUNCTION_OBJFIRST(String__String_bool), AS_CALL_CDECL_OBJFIRST);
     engine->RegisterObjectBehaviour("String", asBEHAVE_CONSTRUCT, "void f(bool)", AS_FUNCTION_OBJFIRST(String__String_bool), AS_CALL_CDECL_OBJFIRST);
     // explicit String::String(char value)
     // explicit String::String(char value)
     engine->RegisterObjectBehaviour("String", asBEHAVE_CONSTRUCT, "void f(int8)", AS_FUNCTION_OBJFIRST(String__String_char), AS_CALL_CDECL_OBJFIRST);
     engine->RegisterObjectBehaviour("String", asBEHAVE_CONSTRUCT, "void f(int8)", AS_FUNCTION_OBJFIRST(String__String_char), AS_CALL_CDECL_OBJFIRST);
-    // explicit String::String(char value, unsigned length)
-    engine->RegisterObjectBehaviour("String", asBEHAVE_CONSTRUCT, "void f(int8, uint)", AS_FUNCTION_OBJFIRST(String__String_char_unsigned), AS_CALL_CDECL_OBJFIRST);
+    // explicit String::String(char value, i32 length)
+    engine->RegisterObjectBehaviour("String", asBEHAVE_CONSTRUCT, "void f(int8, int)", AS_FUNCTION_OBJFIRST(String__String_char_i32), AS_CALL_CDECL_OBJFIRST);
 
 
     // String::~String()
     // String::~String()
     engine->RegisterObjectBehaviour("String", asBEHAVE_DESTRUCT, "void f()", AS_DESTRUCTOR(String), AS_CALL_CDECL_OBJFIRST);
     engine->RegisterObjectBehaviour("String", asBEHAVE_DESTRUCT, "void f()", AS_DESTRUCTOR(String), AS_CALL_CDECL_OBJFIRST);

+ 65 - 65
Source/Urho3D/AngelScript/Generated_Members.h

@@ -4902,7 +4902,7 @@ template <class T> void RegisterMembers_String(asIScriptEngine* engine, const ch
 {
 {
     // String& String::Append(const char* str)
     // String& String::Append(const char* str)
     // Error: type "const char*" can not automatically bind
     // Error: type "const char*" can not automatically bind
-    // String& String::Append(const char* str, unsigned length)
+    // String& String::Append(const char* str, i32 length)
     // Error: type "const char*" can not automatically bind
     // Error: type "const char*" can not automatically bind
     // String& String::AppendWithFormat(const char* formatString,...)
     // String& String::AppendWithFormat(const char* formatString,...)
     // Error: type "const char*" can not automatically bind
     // Error: type "const char*" can not automatically bind
@@ -4960,7 +4960,7 @@ template <class T> void RegisterMembers_String(asIScriptEngine* engine, const ch
     // Registerd as opCmp separately
     // Registerd as opCmp separately
     // bool String::operator >(const char* rhs) const
     // bool String::operator >(const char* rhs) const
     // Error: type "const char*" can not automatically bind
     // Error: type "const char*" can not automatically bind
-    // void String::Replace(unsigned pos, unsigned length, const char* replaceWith)
+    // void String::Replace(i32 pos, i32 length, const char* replaceWith)
     // Error: type "const char*" can not automatically bind
     // Error: type "const char*" can not automatically bind
     // Iterator String::Replace(const Iterator& start, const Iterator& end, const String& replaceWith)
     // Iterator String::Replace(const Iterator& start, const Iterator& end, const String& replaceWith)
     // Error: type "const Iterator&" can not automatically bind
     // Error: type "const Iterator&" can not automatically bind
@@ -4978,23 +4978,23 @@ template <class T> void RegisterMembers_String(asIScriptEngine* engine, const ch
     // String& String::AppendUTF8(unsigned unicodeChar)
     // String& String::AppendUTF8(unsigned unicodeChar)
     engine->RegisterObjectMethod(className, "String& AppendUTF8(uint)", AS_METHODPR(T, AppendUTF8, (unsigned), String&), AS_CALL_THISCALL);
     engine->RegisterObjectMethod(className, "String& AppendUTF8(uint)", AS_METHODPR(T, AppendUTF8, (unsigned), String&), AS_CALL_THISCALL);
 
 
-    // char& String::At(unsigned index)
-    engine->RegisterObjectMethod(className, "int8& At(uint)", AS_METHODPR(T, At, (unsigned), char&), AS_CALL_THISCALL);
+    // char& String::At(i32 index)
+    engine->RegisterObjectMethod(className, "int8& At(int)", AS_METHODPR(T, At, (i32), char&), AS_CALL_THISCALL);
 
 
-    // const char& String::At(unsigned index) const
-    engine->RegisterObjectMethod(className, "const int8& At(uint) const", AS_METHODPR(T, At, (unsigned) const, const char&), AS_CALL_THISCALL);
+    // const char& String::At(i32 index) const
+    engine->RegisterObjectMethod(className, "const int8& At(int) const", AS_METHODPR(T, At, (i32) const, const char&), AS_CALL_THISCALL);
 
 
-    // unsigned String::AtUTF8(unsigned index) const
-    engine->RegisterObjectMethod(className, "uint AtUTF8(uint) const", AS_METHODPR(T, AtUTF8, (unsigned) const, unsigned), AS_CALL_THISCALL);
+    // unsigned String::AtUTF8(i32 index) const
+    engine->RegisterObjectMethod(className, "uint AtUTF8(int) const", AS_METHODPR(T, AtUTF8, (i32) const, unsigned), AS_CALL_THISCALL);
 
 
     // char String::Back() const
     // char String::Back() const
     engine->RegisterObjectMethod(className, "int8 Back() const", AS_METHODPR(T, Back, () const, char), AS_CALL_THISCALL);
     engine->RegisterObjectMethod(className, "int8 Back() const", AS_METHODPR(T, Back, () const, char), AS_CALL_THISCALL);
 
 
-    // unsigned String::ByteOffsetUTF8(unsigned index) const
-    engine->RegisterObjectMethod(className, "uint ByteOffsetUTF8(uint) const", AS_METHODPR(T, ByteOffsetUTF8, (unsigned) const, unsigned), AS_CALL_THISCALL);
+    // i32 String::ByteOffsetUTF8(i32 index) const
+    engine->RegisterObjectMethod(className, "int ByteOffsetUTF8(int) const", AS_METHODPR(T, ByteOffsetUTF8, (i32) const, i32), AS_CALL_THISCALL);
 
 
-    // unsigned String::Capacity() const
-    engine->RegisterObjectMethod(className, "uint Capacity() const", AS_METHODPR(T, Capacity, () const, unsigned), AS_CALL_THISCALL);
+    // i32 String::Capacity() const
+    engine->RegisterObjectMethod(className, "int Capacity() const", AS_METHODPR(T, Capacity, () const, i32), AS_CALL_THISCALL);
 
 
     // void String::Clear()
     // void String::Clear()
     engine->RegisterObjectMethod(className, "void Clear()", AS_METHODPR(T, Clear, (), void), AS_CALL_THISCALL);
     engine->RegisterObjectMethod(className, "void Clear()", AS_METHODPR(T, Clear, (), void), AS_CALL_THISCALL);
@@ -5018,29 +5018,29 @@ template <class T> void RegisterMembers_String(asIScriptEngine* engine, const ch
     // bool String::EndsWith(const String& str, bool caseSensitive = true) const
     // bool String::EndsWith(const String& str, bool caseSensitive = true) const
     engine->RegisterObjectMethod(className, "bool EndsWith(const String&in, bool = true) const", AS_METHODPR(T, EndsWith, (const String&, bool) const, bool), AS_CALL_THISCALL);
     engine->RegisterObjectMethod(className, "bool EndsWith(const String&in, bool = true) const", AS_METHODPR(T, EndsWith, (const String&, bool) const, bool), AS_CALL_THISCALL);
 
 
-    // void String::Erase(unsigned pos, unsigned length = 1)
-    engine->RegisterObjectMethod(className, "void Erase(uint, uint = 1)", AS_METHODPR(T, Erase, (unsigned, unsigned), void), AS_CALL_THISCALL);
+    // void String::Erase(i32 pos, i32 length = 1)
+    engine->RegisterObjectMethod(className, "void Erase(int, int = 1)", AS_METHODPR(T, Erase, (i32, i32), void), AS_CALL_THISCALL);
 
 
-    // unsigned String::Find(const String& str, unsigned startPos = 0, bool caseSensitive = true) const
-    engine->RegisterObjectMethod(className, "uint Find(const String&in, uint = 0, bool = true) const", AS_METHODPR(T, Find, (const String&, unsigned, bool) const, unsigned), AS_CALL_THISCALL);
+    // i32 String::Find(const String& str, i32 startPos = 0, bool caseSensitive = true) const
+    engine->RegisterObjectMethod(className, "int Find(const String&in, int = 0, bool = true) const", AS_METHODPR(T, Find, (const String&, i32, bool) const, i32), AS_CALL_THISCALL);
 
 
-    // unsigned String::Find(char c, unsigned startPos = 0, bool caseSensitive = true) const
-    engine->RegisterObjectMethod(className, "uint Find(int8, uint = 0, bool = true) const", AS_METHODPR(T, Find, (char, unsigned, bool) const, unsigned), AS_CALL_THISCALL);
+    // i32 String::Find(char c, i32 startPos = 0, bool caseSensitive = true) const
+    engine->RegisterObjectMethod(className, "int Find(int8, int = 0, bool = true) const", AS_METHODPR(T, Find, (char, i32, bool) const, i32), AS_CALL_THISCALL);
 
 
-    // unsigned String::FindLast(const String& str, unsigned startPos = NPOS, bool caseSensitive = true) const
-    engine->RegisterObjectMethod(className, "uint FindLast(const String&in, uint = String::NPOS, bool = true) const", AS_METHODPR(T, FindLast, (const String&, unsigned, bool) const, unsigned), AS_CALL_THISCALL);
+    // i32 String::FindLast(const String& str, i32 startPos = NPOS, bool caseSensitive = true) const
+    engine->RegisterObjectMethod(className, "int FindLast(const String&in, int = String::NPOS, bool = true) const", AS_METHODPR(T, FindLast, (const String&, i32, bool) const, i32), AS_CALL_THISCALL);
 
 
-    // unsigned String::FindLast(char c, unsigned startPos = NPOS, bool caseSensitive = true) const
-    engine->RegisterObjectMethod(className, "uint FindLast(int8, uint = String::NPOS, bool = true) const", AS_METHODPR(T, FindLast, (char, unsigned, bool) const, unsigned), AS_CALL_THISCALL);
+    // i32 String::FindLast(char c, i32 startPos = NPOS, bool caseSensitive = true) const
+    engine->RegisterObjectMethod(className, "int FindLast(int8, int = String::NPOS, bool = true) const", AS_METHODPR(T, FindLast, (char, i32, bool) const, i32), AS_CALL_THISCALL);
 
 
     // char String::Front() const
     // char String::Front() const
     engine->RegisterObjectMethod(className, "int8 Front() const", AS_METHODPR(T, Front, () const, char), AS_CALL_THISCALL);
     engine->RegisterObjectMethod(className, "int8 Front() const", AS_METHODPR(T, Front, () const, char), AS_CALL_THISCALL);
 
 
-    // void String::Insert(unsigned pos, const String& str)
-    engine->RegisterObjectMethod(className, "void Insert(uint, const String&in)", AS_METHODPR(T, Insert, (unsigned, const String&), void), AS_CALL_THISCALL);
+    // void String::Insert(i32 pos, const String& str)
+    engine->RegisterObjectMethod(className, "void Insert(int, const String&in)", AS_METHODPR(T, Insert, (i32, const String&), void), AS_CALL_THISCALL);
 
 
-    // void String::Insert(unsigned pos, char c)
-    engine->RegisterObjectMethod(className, "void Insert(uint, int8)", AS_METHODPR(T, Insert, (unsigned, char), void), AS_CALL_THISCALL);
+    // void String::Insert(i32 pos, char c)
+    engine->RegisterObjectMethod(className, "void Insert(int, int8)", AS_METHODPR(T, Insert, (i32, char), void), AS_CALL_THISCALL);
 
 
     // bool String::IsShort() const
     // bool String::IsShort() const
     engine->RegisterObjectMethod(className, "bool IsShort() const", AS_METHODPR(T, IsShort, () const, bool), AS_CALL_THISCALL);
     engine->RegisterObjectMethod(className, "bool IsShort() const", AS_METHODPR(T, IsShort, () const, bool), AS_CALL_THISCALL);
@@ -5048,16 +5048,16 @@ template <class T> void RegisterMembers_String(asIScriptEngine* engine, const ch
     // void String::Join(const Vector<String>& subStrings, const String& glue)
     // void String::Join(const Vector<String>& subStrings, const String& glue)
     engine->RegisterObjectMethod(className, "void Join(Array<String>@+, const String&in)", AS_FUNCTION_OBJFIRST(String_void_Join_constspVectorlesStringgreamp_constspStringamp_template<String>), AS_CALL_CDECL_OBJFIRST);
     engine->RegisterObjectMethod(className, "void Join(Array<String>@+, const String&in)", AS_FUNCTION_OBJFIRST(String_void_Join_constspVectorlesStringgreamp_constspStringamp_template<String>), AS_CALL_CDECL_OBJFIRST);
 
 
-    // unsigned String::Length() const
-    engine->RegisterObjectMethod(className, "uint Length() const", AS_METHODPR(T, Length, () const, unsigned), AS_CALL_THISCALL);
-    engine->RegisterObjectMethod(className, "uint get_length() const", AS_METHODPR(T, Length, () const, unsigned), AS_CALL_THISCALL);
+    // i32 String::Length() const
+    engine->RegisterObjectMethod(className, "int Length() const", AS_METHODPR(T, Length, () const, i32), AS_CALL_THISCALL);
+    engine->RegisterObjectMethod(className, "int get_length() const", AS_METHODPR(T, Length, () const, i32), AS_CALL_THISCALL);
 
 
-    // unsigned String::LengthUTF8() const
-    engine->RegisterObjectMethod(className, "uint LengthUTF8() const", AS_METHODPR(T, LengthUTF8, () const, unsigned), AS_CALL_THISCALL);
-    engine->RegisterObjectMethod(className, "uint get_utf8Length() const", AS_METHODPR(T, LengthUTF8, () const, unsigned), AS_CALL_THISCALL);
+    // i32 String::LengthUTF8() const
+    engine->RegisterObjectMethod(className, "int LengthUTF8() const", AS_METHODPR(T, LengthUTF8, () const, i32), AS_CALL_THISCALL);
+    engine->RegisterObjectMethod(className, "int get_utf8Length() const", AS_METHODPR(T, LengthUTF8, () const, i32), AS_CALL_THISCALL);
 
 
-    // unsigned String::NextUTF8Char(unsigned& byteOffset) const
-    engine->RegisterObjectMethod(className, "uint NextUTF8Char(uint&) const", AS_METHODPR(T, NextUTF8Char, (unsigned&) const, unsigned), AS_CALL_THISCALL);
+    // unsigned String::NextUTF8Char(i32& byteOffset) const
+    engine->RegisterObjectMethod(className, "uint NextUTF8Char(int&) const", AS_METHODPR(T, NextUTF8Char, (i32&) const, unsigned), AS_CALL_THISCALL);
 
 
     // String String::operator +(const String& rhs) const
     // String String::operator +(const String& rhs) const
     engine->RegisterObjectMethod(className, "String opAdd(const String&in) const", AS_METHODPR(T, operator+, (const String&) const, String), AS_CALL_THISCALL);
     engine->RegisterObjectMethod(className, "String opAdd(const String&in) const", AS_METHODPR(T, operator+, (const String&) const, String), AS_CALL_THISCALL);
@@ -5098,11 +5098,11 @@ template <class T> void RegisterMembers_String(asIScriptEngine* engine, const ch
     // bool String::operator ==(const String& rhs) const
     // bool String::operator ==(const String& rhs) const
     engine->RegisterObjectMethod(className, "bool opEquals(const String&in) const", AS_METHODPR(T, operator==, (const String&) const, bool), AS_CALL_THISCALL);
     engine->RegisterObjectMethod(className, "bool opEquals(const String&in) const", AS_METHODPR(T, operator==, (const String&) const, bool), AS_CALL_THISCALL);
 
 
-    // char& String::operator [](unsigned index)
-    engine->RegisterObjectMethod(className, "int8& opIndex(uint)", AS_METHODPR(T, operator[], (unsigned), char&), AS_CALL_THISCALL);
+    // char& String::operator [](i32 index)
+    engine->RegisterObjectMethod(className, "int8& opIndex(int)", AS_METHODPR(T, operator[], (i32), char&), AS_CALL_THISCALL);
 
 
-    // const char& String::operator [](unsigned index) const
-    engine->RegisterObjectMethod(className, "const int8& opIndex(uint) const", AS_METHODPR(T, operator[], (unsigned) const, const char&), AS_CALL_THISCALL);
+    // const char& String::operator [](i32 index) const
+    engine->RegisterObjectMethod(className, "const int8& opIndex(int) const", AS_METHODPR(T, operator[], (i32) const, const char&), AS_CALL_THISCALL);
 
 
     // void String::Replace(char replaceThis, char replaceWith, bool caseSensitive = true)
     // void String::Replace(char replaceThis, char replaceWith, bool caseSensitive = true)
     engine->RegisterObjectMethod(className, "void Replace(int8, int8, bool = true)", AS_METHODPR(T, Replace, (char, char, bool), void), AS_CALL_THISCALL);
     engine->RegisterObjectMethod(className, "void Replace(int8, int8, bool = true)", AS_METHODPR(T, Replace, (char, char, bool), void), AS_CALL_THISCALL);
@@ -5110,8 +5110,8 @@ template <class T> void RegisterMembers_String(asIScriptEngine* engine, const ch
     // void String::Replace(const String& replaceThis, const String& replaceWith, bool caseSensitive = true)
     // void String::Replace(const String& replaceThis, const String& replaceWith, bool caseSensitive = true)
     engine->RegisterObjectMethod(className, "void Replace(const String&in, const String&in, bool = true)", AS_METHODPR(T, Replace, (const String&, const String&, bool), void), AS_CALL_THISCALL);
     engine->RegisterObjectMethod(className, "void Replace(const String&in, const String&in, bool = true)", AS_METHODPR(T, Replace, (const String&, const String&, bool), void), AS_CALL_THISCALL);
 
 
-    // void String::Replace(unsigned pos, unsigned length, const String& replaceWith)
-    engine->RegisterObjectMethod(className, "void Replace(uint, uint, const String&in)", AS_METHODPR(T, Replace, (unsigned, unsigned, const String&), void), AS_CALL_THISCALL);
+    // void String::Replace(i32 pos, i32 length, const String& replaceWith)
+    engine->RegisterObjectMethod(className, "void Replace(int, int, const String&in)", AS_METHODPR(T, Replace, (i32, i32, const String&), void), AS_CALL_THISCALL);
 
 
     // String String::Replaced(char replaceThis, char replaceWith, bool caseSensitive = true) const
     // String String::Replaced(char replaceThis, char replaceWith, bool caseSensitive = true) const
     engine->RegisterObjectMethod(className, "String Replaced(int8, int8, bool = true) const", AS_METHODPR(T, Replaced, (char, char, bool) const, String), AS_CALL_THISCALL);
     engine->RegisterObjectMethod(className, "String Replaced(int8, int8, bool = true) const", AS_METHODPR(T, Replaced, (char, char, bool) const, String), AS_CALL_THISCALL);
@@ -5119,14 +5119,14 @@ template <class T> void RegisterMembers_String(asIScriptEngine* engine, const ch
     // String String::Replaced(const String& replaceThis, const String& replaceWith, bool caseSensitive = true) const
     // String String::Replaced(const String& replaceThis, const String& replaceWith, bool caseSensitive = true) const
     engine->RegisterObjectMethod(className, "String Replaced(const String&in, const String&in, bool = true) const", AS_METHODPR(T, Replaced, (const String&, const String&, bool) const, String), AS_CALL_THISCALL);
     engine->RegisterObjectMethod(className, "String Replaced(const String&in, const String&in, bool = true) const", AS_METHODPR(T, Replaced, (const String&, const String&, bool) const, String), AS_CALL_THISCALL);
 
 
-    // void String::ReplaceUTF8(unsigned index, unsigned unicodeChar)
-    engine->RegisterObjectMethod(className, "void ReplaceUTF8(uint, uint)", AS_METHODPR(T, ReplaceUTF8, (unsigned, unsigned), void), AS_CALL_THISCALL);
+    // void String::ReplaceUTF8(i32 index, unsigned unicodeChar)
+    engine->RegisterObjectMethod(className, "void ReplaceUTF8(int, uint)", AS_METHODPR(T, ReplaceUTF8, (i32, unsigned), void), AS_CALL_THISCALL);
 
 
-    // void String::Reserve(unsigned newCapacity)
-    engine->RegisterObjectMethod(className, "void Reserve(uint)", AS_METHODPR(T, Reserve, (unsigned), void), AS_CALL_THISCALL);
+    // void String::Reserve(i32 newCapacity)
+    engine->RegisterObjectMethod(className, "void Reserve(int)", AS_METHODPR(T, Reserve, (i32), void), AS_CALL_THISCALL);
 
 
-    // void String::Resize(unsigned newLength)
-    engine->RegisterObjectMethod(className, "void Resize(uint)", AS_METHODPR(T, Resize, (unsigned), void), AS_CALL_THISCALL);
+    // void String::Resize(i32 newLength)
+    engine->RegisterObjectMethod(className, "void Resize(int)", AS_METHODPR(T, Resize, (i32), void), AS_CALL_THISCALL);
 
 
     // Vector<String> String::Split(char separator, bool keepEmptyStrings = false) const
     // Vector<String> String::Split(char separator, bool keepEmptyStrings = false) const
     engine->RegisterObjectMethod(className, "Array<String>@ Split(int8, bool = false) const", AS_FUNCTION_OBJFIRST(String_VectorlesStringgre_Split_char_bool_template<String>), AS_CALL_CDECL_OBJFIRST);
     engine->RegisterObjectMethod(className, "Array<String>@ Split(int8, bool = false) const", AS_FUNCTION_OBJFIRST(String_VectorlesStringgre_Split_char_bool_template<String>), AS_CALL_CDECL_OBJFIRST);
@@ -5134,17 +5134,17 @@ template <class T> void RegisterMembers_String(asIScriptEngine* engine, const ch
     // bool String::StartsWith(const String& str, bool caseSensitive = true) const
     // bool String::StartsWith(const String& str, bool caseSensitive = true) const
     engine->RegisterObjectMethod(className, "bool StartsWith(const String&in, bool = true) const", AS_METHODPR(T, StartsWith, (const String&, bool) const, bool), AS_CALL_THISCALL);
     engine->RegisterObjectMethod(className, "bool StartsWith(const String&in, bool = true) const", AS_METHODPR(T, StartsWith, (const String&, bool) const, bool), AS_CALL_THISCALL);
 
 
-    // String String::Substring(unsigned pos) const
-    engine->RegisterObjectMethod(className, "String Substring(uint) const", AS_METHODPR(T, Substring, (unsigned) const, String), AS_CALL_THISCALL);
+    // String String::Substring(i32 pos) const
+    engine->RegisterObjectMethod(className, "String Substring(int) const", AS_METHODPR(T, Substring, (i32) const, String), AS_CALL_THISCALL);
 
 
-    // String String::Substring(unsigned pos, unsigned length) const
-    engine->RegisterObjectMethod(className, "String Substring(uint, uint) const", AS_METHODPR(T, Substring, (unsigned, unsigned) const, String), AS_CALL_THISCALL);
+    // String String::Substring(i32 pos, i32 length) const
+    engine->RegisterObjectMethod(className, "String Substring(int, int) const", AS_METHODPR(T, Substring, (i32, i32) const, String), AS_CALL_THISCALL);
 
 
-    // String String::SubstringUTF8(unsigned pos) const
-    engine->RegisterObjectMethod(className, "String SubstringUTF8(uint) const", AS_METHODPR(T, SubstringUTF8, (unsigned) const, String), AS_CALL_THISCALL);
+    // String String::SubstringUTF8(i32 pos) const
+    engine->RegisterObjectMethod(className, "String SubstringUTF8(int) const", AS_METHODPR(T, SubstringUTF8, (i32) const, String), AS_CALL_THISCALL);
 
 
-    // String String::SubstringUTF8(unsigned pos, unsigned length) const
-    engine->RegisterObjectMethod(className, "String SubstringUTF8(uint, uint) const", AS_METHODPR(T, SubstringUTF8, (unsigned, unsigned) const, String), AS_CALL_THISCALL);
+    // String String::SubstringUTF8(i32 pos, i32 length) const
+    engine->RegisterObjectMethod(className, "String SubstringUTF8(int, int) const", AS_METHODPR(T, SubstringUTF8, (i32, i32) const, String), AS_CALL_THISCALL);
 
 
     // void String::Swap(String& str)
     // void String::Swap(String& str)
     engine->RegisterObjectMethod(className, "void Swap(String&)", AS_METHODPR(T, Swap, (String&), void), AS_CALL_THISCALL);
     engine->RegisterObjectMethod(className, "void Swap(String&)", AS_METHODPR(T, Swap, (String&), void), AS_CALL_THISCALL);
@@ -5174,7 +5174,7 @@ template <class T> void RegisterMembers_String(asIScriptEngine* engine, const ch
     // Error: type "char*&" can not automatically bind
     // Error: type "char*&" can not automatically bind
     // static unsigned String::DecodeUTF8(const char*& src)
     // static unsigned String::DecodeUTF8(const char*& src)
     // Error: type "const char*&" can not automatically bind
     // Error: type "const char*&" can not automatically bind
-    // static unsigned String::CStringLength(const char* str)
+    // static i32 String::CStringLength(const char* str)
     // Error: type "const char*" can not automatically bind
     // Error: type "const char*" can not automatically bind
     // static int String::Compare(const char* lhs, const char* rhs, bool caseSensitive)
     // static int String::Compare(const char* lhs, const char* rhs, bool caseSensitive)
     // Error: type "const char*" can not automatically bind
     // Error: type "const char*" can not automatically bind
@@ -5184,8 +5184,8 @@ template <class T> void RegisterMembers_String(asIScriptEngine* engine, const ch
     // ShortString String::shortString_
     // ShortString String::shortString_
     // Not registered because have @nobind mark
     // Not registered because have @nobind mark
 
 
-    // static constexpr unsigned String::NPOS
-    engine->SetDefaultNamespace(className);engine->RegisterGlobalProperty("const uint NPOS", (void*)&T::NPOS);engine->SetDefaultNamespace("");
+    // static constexpr i32 String::NPOS
+    engine->SetDefaultNamespace(className);engine->RegisterGlobalProperty("const int NPOS", (void*)&T::NPOS);engine->SetDefaultNamespace("");
 
 
     // static const String String::EMPTY
     // static const String String::EMPTY
     engine->SetDefaultNamespace(className);engine->RegisterGlobalProperty("const String EMPTY", (void*)&T::EMPTY);engine->SetDefaultNamespace("");
     engine->SetDefaultNamespace(className);engine->RegisterGlobalProperty("const String EMPTY", (void*)&T::EMPTY);engine->SetDefaultNamespace("");
@@ -6582,25 +6582,25 @@ template <class T> void RegisterMembers_VertexElement(asIScriptEngine* engine, c
 // class WString | File: ../Container/Str.h
 // class WString | File: ../Container/Str.h
 template <class T> void RegisterMembers_WString(asIScriptEngine* engine, const char* className)
 template <class T> void RegisterMembers_WString(asIScriptEngine* engine, const char* className)
 {
 {
-    // wchar_t& WString::At(unsigned index)
+    // wchar_t& WString::At(i32 index)
     // Error: type "wchar_t&" can not automatically bind
     // Error: type "wchar_t&" can not automatically bind
-    // const wchar_t& WString::At(unsigned index) const
+    // const wchar_t& WString::At(i32 index) const
     // Error: type "const wchar_t&" can not automatically bind
     // Error: type "const wchar_t&" can not automatically bind
     // const wchar_t* WString::CString() const
     // const wchar_t* WString::CString() const
     // Error: type "const wchar_t*" can not automatically bind
     // Error: type "const wchar_t*" can not automatically bind
-    // wchar_t& WString::operator [](unsigned index)
+    // wchar_t& WString::operator [](i32 index)
     // Error: type "wchar_t&" can not automatically bind
     // Error: type "wchar_t&" can not automatically bind
-    // const wchar_t& WString::operator [](unsigned index) const
+    // const wchar_t& WString::operator [](i32 index) const
     // Error: type "const wchar_t&" can not automatically bind
     // Error: type "const wchar_t&" can not automatically bind
 
 
     // bool WString::Empty() const
     // bool WString::Empty() const
     engine->RegisterObjectMethod(className, "bool Empty() const", AS_METHODPR(T, Empty, () const, bool), AS_CALL_THISCALL);
     engine->RegisterObjectMethod(className, "bool Empty() const", AS_METHODPR(T, Empty, () const, bool), AS_CALL_THISCALL);
 
 
-    // unsigned WString::Length() const
-    engine->RegisterObjectMethod(className, "uint Length() const", AS_METHODPR(T, Length, () const, unsigned), AS_CALL_THISCALL);
+    // i32 WString::Length() const
+    engine->RegisterObjectMethod(className, "int Length() const", AS_METHODPR(T, Length, () const, i32), AS_CALL_THISCALL);
 
 
-    // void WString::Resize(unsigned newLength)
-    engine->RegisterObjectMethod(className, "void Resize(uint)", AS_METHODPR(T, Resize, (unsigned), void), AS_CALL_THISCALL);
+    // void WString::Resize(i32 newLength)
+    engine->RegisterObjectMethod(className, "void Resize(int)", AS_METHODPR(T, Resize, (i32), void), AS_CALL_THISCALL);
 
 
     #ifdef REGISTER_MEMBERS_MANUAL_PART_WString
     #ifdef REGISTER_MEMBERS_MANUAL_PART_WString
         REGISTER_MEMBERS_MANUAL_PART_WString();
         REGISTER_MEMBERS_MANUAL_PART_WString();

+ 12 - 12
Source/Urho3D/AngelScript/ScriptAPIDump.cpp

@@ -99,7 +99,7 @@ void ExtractPropertyInfo(const String& functionName, const String& declaration,
         if (info->type_.Empty())
         if (info->type_.Empty())
         {
         {
             // Extract type from parameters
             // Extract type from parameters
-            unsigned begin = declaration.Find(',');
+            i32 begin = declaration.Find(',');
             if (begin == String::NPOS)
             if (begin == String::NPOS)
                 begin = declaration.Find('(');
                 begin = declaration.Find('(');
             else
             else
@@ -108,7 +108,7 @@ void ExtractPropertyInfo(const String& functionName, const String& declaration,
             if (begin != String::NPOS)
             if (begin != String::NPOS)
             {
             {
                 ++begin;
                 ++begin;
-                unsigned end = declaration.Find(')');
+                i32 end = declaration.Find(')');
                 if (end != String::NPOS)
                 if (end != String::NPOS)
                 {
                 {
                     info->type_ = declaration.Substring(begin, end - begin);
                     info->type_ = declaration.Substring(begin, end - begin);
@@ -124,8 +124,8 @@ void ExtractPropertyInfo(const String& functionName, const String& declaration,
 
 
 bool ComparePropertyStrings(const String& lhs, const String& rhs)
 bool ComparePropertyStrings(const String& lhs, const String& rhs)
 {
 {
-    int spaceLhs = lhs.Find(' ');
-    int spaceRhs = rhs.Find(' ');
+    i32 spaceLhs = lhs.Find(' ');
+    i32 spaceRhs = rhs.Find(' ');
     if (spaceLhs != String::NPOS && spaceRhs != String::NPOS)
     if (spaceLhs != String::NPOS && spaceRhs != String::NPOS)
         return String::Compare(lhs.CString() + spaceLhs, rhs.CString() + spaceRhs, true) < 0;
         return String::Compare(lhs.CString() + spaceLhs, rhs.CString() + spaceRhs, true) < 0;
     else
     else
@@ -153,15 +153,15 @@ void Script::OutputAPIRow(DumpMode mode, const String& row, bool removeReference
         out.Replace("?&", "void*");
         out.Replace("?&", "void*");
 
 
         // s/(\w+)\[\]/Array<\1>/g
         // s/(\w+)\[\]/Array<\1>/g
-        unsigned posBegin = String::NPOS;
+        i32 posBegin = String::NPOS;
         while (true)   // Loop to cater for array of array of T
         while (true)   // Loop to cater for array of array of T
         {
         {
-            unsigned posEnd = out.Find("[]");
+            i32 posEnd = out.Find("[]");
             if (posEnd == String::NPOS)
             if (posEnd == String::NPOS)
                 break;
                 break;
-            if (posBegin > posEnd)
+            if (posBegin == String::NPOS)
                 posBegin = posEnd - 1;
                 posBegin = posEnd - 1;
-            while (posBegin < posEnd && isalnum(out[posBegin]))
+            while (posBegin >= 0 && isalnum(out[posBegin]))
                 --posBegin;
                 --posBegin;
             ++posBegin;
             ++posBegin;
             out.Replace(posBegin, posEnd - posBegin + 2, "Array<" + out.Substring(posBegin, posEnd - posBegin) + ">");
             out.Replace(posBegin, posEnd - posBegin + 2, "Array<" + out.Substring(posBegin, posEnd - posBegin) + ">");
@@ -217,8 +217,8 @@ void Script::DumpAPI(DumpMode mode, const String& sourceTree)
                     continue;
                     continue;
 
 
                 const String& sectionName = headerFiles[i].sectionName;
                 const String& sectionName = headerFiles[i].sectionName;
-                unsigned start = sectionName.Find('/') + 1;
-                unsigned end = sectionName.Find("Events.h");
+                i32 start = sectionName.Find('/') + 1;
+                i32 end = sectionName.Find("Events.h");
                 Log::WriteRaw("\n## %" + sectionName.Substring(start, end - start) + " events\n");
                 Log::WriteRaw("\n## %" + sectionName.Substring(start, end - start) + " events\n");
 
 
                 while (!file->IsEof())
                 while (!file->IsEof())
@@ -466,11 +466,11 @@ void Script::DumpAPI(DumpMode mode, const String& sourceTree)
                         String prefix(typeName + "::");
                         String prefix(typeName + "::");
                         declaration.Replace(prefix, "");
                         declaration.Replace(prefix, "");
                         ///\todo Is there a better way to mark deprecated API bindings for AngelScript?
                         ///\todo Is there a better way to mark deprecated API bindings for AngelScript?
-                        unsigned posBegin = declaration.FindLast("const String&in = \"deprecated:");
+                        i32 posBegin = declaration.FindLast("const String&in = \"deprecated:");
                         if (posBegin != String::NPOS)
                         if (posBegin != String::NPOS)
                         {
                         {
                             // Assume this 'mark' is added as the last parameter
                             // Assume this 'mark' is added as the last parameter
-                            unsigned posEnd = declaration.Find(')', posBegin);
+                            i32 posEnd = declaration.Find(')', posBegin);
                             if (posEnd != String::NPOS)
                             if (posEnd != String::NPOS)
                             {
                             {
                                 declaration.Replace(posBegin, posEnd - posBegin, "");
                                 declaration.Replace(posBegin, posEnd - posBegin, "");

+ 116 - 104
Source/Urho3D/Container/Str.cpp

@@ -120,12 +120,12 @@ String::String(char value)
     GetBuffer()[0] = value;
     GetBuffer()[0] = value;
 }
 }
 
 
-String::String(char value, unsigned length)
+String::String(char value, i32 length)
     : String()
     : String()
 {
 {
     Resize(length);
     Resize(length);
     char* buffer = GetBuffer();
     char* buffer = GetBuffer();
-    for (unsigned i = 0; i < length; ++i)
+    for (i32 i = 0; i < length; ++i)
         buffer[i] = value;
         buffer[i] = value;
 }
 }
 
 
@@ -181,12 +181,12 @@ String& String::operator +=(bool rhs)
 
 
 void String::Replace(char replaceThis, char replaceWith, bool caseSensitive)
 void String::Replace(char replaceThis, char replaceWith, bool caseSensitive)
 {
 {
-    unsigned length = Length();
+    i32 length = Length();
     char* buffer = GetBuffer();
     char* buffer = GetBuffer();
 
 
     if (caseSensitive)
     if (caseSensitive)
     {
     {
-        for (unsigned i = 0; i < length; ++i)
+        for (i32 i = 0; i < length; ++i)
         {
         {
             if (buffer[i] == replaceThis)
             if (buffer[i] == replaceThis)
                 buffer[i] = replaceWith;
                 buffer[i] = replaceWith;
@@ -195,7 +195,7 @@ void String::Replace(char replaceThis, char replaceWith, bool caseSensitive)
     else
     else
     {
     {
         replaceThis = (char)tolower(replaceThis);
         replaceThis = (char)tolower(replaceThis);
-        for (unsigned i = 0; i < length; ++i)
+        for (i32 i = 0; i < length; ++i)
         {
         {
             if (tolower(buffer[i]) == replaceThis)
             if (tolower(buffer[i]) == replaceThis)
                 buffer[i] = replaceWith;
                 buffer[i] = replaceWith;
@@ -205,15 +205,15 @@ void String::Replace(char replaceThis, char replaceWith, bool caseSensitive)
 
 
 void String::Replace(const String& replaceThis, const String& replaceWith, bool caseSensitive)
 void String::Replace(const String& replaceThis, const String& replaceWith, bool caseSensitive)
 {
 {
-    unsigned nextPos = 0;
+    i32 nextPos = 0;
 
 
-    unsigned length = Length();
-    unsigned replaceThisLength = replaceThis.Length();
-    unsigned replaceWithLength = replaceWith.Length();
+    i32 length = Length();
+    i32 replaceThisLength = replaceThis.Length();
+    i32 replaceWithLength = replaceWith.Length();
 
 
     while (nextPos < length)
     while (nextPos < length)
     {
     {
-        unsigned pos = Find(replaceThis, nextPos, caseSensitive);
+        i32 pos = Find(replaceThis, nextPos, caseSensitive);
         if (pos == NPOS)
         if (pos == NPOS)
             break;
             break;
         Replace(pos, replaceThisLength, replaceWith);
         Replace(pos, replaceThisLength, replaceWith);
@@ -221,7 +221,7 @@ void String::Replace(const String& replaceThis, const String& replaceWith, bool
     }
     }
 }
 }
 
 
-void String::Replace(unsigned pos, unsigned length, const String& replaceWith)
+void String::Replace(i32 pos, i32 length, const String& replaceWith)
 {
 {
     // If substring is illegal, do nothing
     // If substring is illegal, do nothing
     if (pos + length > Length())
     if (pos + length > Length())
@@ -230,7 +230,7 @@ void String::Replace(unsigned pos, unsigned length, const String& replaceWith)
     Replace(pos, length, replaceWith.GetBuffer(), replaceWith.Length());
     Replace(pos, length, replaceWith.GetBuffer(), replaceWith.Length());
 }
 }
 
 
-void String::Replace(unsigned pos, unsigned length, const char* replaceWith)
+void String::Replace(i32 pos, i32 length, const char* replaceWith)
 {
 {
     // If substring is illegal, do nothing
     // If substring is illegal, do nothing
     if (pos + length > Length())
     if (pos + length > Length())
@@ -241,10 +241,10 @@ void String::Replace(unsigned pos, unsigned length, const char* replaceWith)
 
 
 String::Iterator String::Replace(const String::Iterator& start, const String::Iterator& end, const String& replaceWith)
 String::Iterator String::Replace(const String::Iterator& start, const String::Iterator& end, const String& replaceWith)
 {
 {
-    unsigned pos = (unsigned)(start - Begin());
+    i32 pos = (i32)(start - Begin());
     if (pos >= Length())
     if (pos >= Length())
         return End();
         return End();
-    auto length = (unsigned)(end - start);
+    i32 length = (i32)(end - start);
     Replace(pos, length, replaceWith);
     Replace(pos, length, replaceWith);
 
 
     return Begin() + pos;
     return Begin() + pos;
@@ -279,20 +279,22 @@ String& String::Append(char c)
     return *this += c;
     return *this += c;
 }
 }
 
 
-String& String::Append(const char* str, unsigned length)
+String& String::Append(const char* str, i32 length)
 {
 {
     if (str)
     if (str)
     {
     {
-        unsigned oldLength = Length();
+        i32 oldLength = Length();
         Resize(oldLength + length);
         Resize(oldLength + length);
         CopyChars(&GetBuffer()[oldLength], str, length);
         CopyChars(&GetBuffer()[oldLength], str, length);
     }
     }
     return *this;
     return *this;
 }
 }
 
 
-void String::Insert(unsigned pos, const String& str)
+void String::Insert(i32 pos, const String& str)
 {
 {
-    unsigned length = Length();
+    assert(pos >= 0);
+    
+    i32 length = Length();
 
 
     if (pos > length)
     if (pos > length)
         pos = length;
         pos = length;
@@ -303,9 +305,11 @@ void String::Insert(unsigned pos, const String& str)
         Replace(pos, 0, str);
         Replace(pos, 0, str);
 }
 }
 
 
-void String::Insert(unsigned pos, char c)
+void String::Insert(i32 pos, char c)
 {
 {
-    unsigned length = Length();
+    assert(pos >= 0);
+
+    i32 length = Length();
 
 
     if (pos > length)
     if (pos > length)
         pos = length;
         pos = length;
@@ -316,7 +320,7 @@ void String::Insert(unsigned pos, char c)
     }
     }
     else
     else
     {
     {
-        unsigned oldLength = length;
+        i32 oldLength = length;
         Resize(length + 1);
         Resize(length + 1);
         MoveRange(pos + 1, pos, oldLength - pos);
         MoveRange(pos + 1, pos, oldLength - pos);
         GetBuffer()[pos] = c;
         GetBuffer()[pos] = c;
@@ -325,9 +329,9 @@ void String::Insert(unsigned pos, char c)
 
 
 String::Iterator String::Insert(const String::Iterator& dest, const String& str)
 String::Iterator String::Insert(const String::Iterator& dest, const String& str)
 {
 {
-    unsigned length = Length();
+    i32 length = Length();
 
 
-    unsigned pos = (unsigned)(dest - Begin());
+    i32 pos = (i32)(dest - Begin());
     if (pos > length)
     if (pos > length)
         pos = length;
         pos = length;
     Insert(pos, str);
     Insert(pos, str);
@@ -337,10 +341,10 @@ String::Iterator String::Insert(const String::Iterator& dest, const String& str)
 
 
 String::Iterator String::Insert(const String::Iterator& dest, const String::Iterator& start, const String::Iterator& end)
 String::Iterator String::Insert(const String::Iterator& dest, const String::Iterator& start, const String::Iterator& end)
 {
 {
-    unsigned pos = (unsigned)(dest - Begin());
+    i32 pos = (i32)(dest - Begin());
     if (pos > Length())
     if (pos > Length())
         pos = Length();
         pos = Length();
-    unsigned length = (unsigned)(end - start);
+    i32 length = (i32)(end - start);
     Replace(pos, 0, &(*start), length);
     Replace(pos, 0, &(*start), length);
 
 
     return Begin() + pos;
     return Begin() + pos;
@@ -348,9 +352,9 @@ String::Iterator String::Insert(const String::Iterator& dest, const String::Iter
 
 
 String::Iterator String::Insert(const String::Iterator& dest, char c)
 String::Iterator String::Insert(const String::Iterator& dest, char c)
 {
 {
-    unsigned length = Length();
+    i32 length = Length();
 
 
-    unsigned pos = (unsigned)(dest - Begin());
+    i32 pos = (i32)(dest - Begin());
     if (pos > length)
     if (pos > length)
         pos = length;
         pos = length;
     Insert(pos, c);
     Insert(pos, c);
@@ -358,14 +362,14 @@ String::Iterator String::Insert(const String::Iterator& dest, char c)
     return Begin() + pos;
     return Begin() + pos;
 }
 }
 
 
-void String::Erase(unsigned pos, unsigned length)
+void String::Erase(i32 pos, i32 length)
 {
 {
     Replace(pos, length, String::EMPTY);
     Replace(pos, length, String::EMPTY);
 }
 }
 
 
 String::Iterator String::Erase(const String::Iterator& it)
 String::Iterator String::Erase(const String::Iterator& it)
 {
 {
-    unsigned pos = (unsigned)(it - Begin());
+    i32 pos = (i32)(it - Begin());
     if (pos >= Length())
     if (pos >= Length())
         return End();
         return End();
     Erase(pos);
     Erase(pos);
@@ -375,18 +379,20 @@ String::Iterator String::Erase(const String::Iterator& it)
 
 
 String::Iterator String::Erase(const String::Iterator& start, const String::Iterator& end)
 String::Iterator String::Erase(const String::Iterator& start, const String::Iterator& end)
 {
 {
-    unsigned pos = (unsigned)(start - Begin());
+    i32 pos = (i32)(start - Begin());
     if (pos >= Length())
     if (pos >= Length())
         return End();
         return End();
-    unsigned length = (unsigned)(end - start);
+    i32 length = (i32)(end - start);
     Erase(pos, length);
     Erase(pos, length);
 
 
     return Begin() + pos;
     return Begin() + pos;
 }
 }
 
 
-void String::Resize(unsigned newLength)
+void String::Resize(i32 newLength)
 {
 {
-    unsigned capacity = Capacity();
+    assert(newLength >= 0);
+
+    i32 capacity = Capacity();
 
 
     if (newLength && capacity < newLength + 1) // Need to increase capacity
     if (newLength && capacity < newLength + 1) // Need to increase capacity
     {
     {
@@ -400,7 +406,7 @@ void String::Resize(unsigned newLength)
         char* newBuffer = new char[capacity];
         char* newBuffer = new char[capacity];
 
 
         // Move the existing data to the new buffer
         // Move the existing data to the new buffer
-        unsigned oldLength = Length();
+        i32 oldLength = Length();
         if (oldLength)
         if (oldLength)
             CopyChars(newBuffer, GetBuffer(), oldLength);
             CopyChars(newBuffer, GetBuffer(), oldLength);
 
 
@@ -428,9 +434,11 @@ void String::Resize(unsigned newLength)
     }
     }
 }
 }
 
 
-void String::Reserve(unsigned newCapacity)
+void String::Reserve(i32 newCapacity)
 {
 {
-    unsigned length = Length();
+    assert(newCapacity >= 0);
+
+    i32 length = Length();
 
 
     if (newCapacity < length + 1)
     if (newCapacity < length + 1)
         newCapacity = length + 1;
         newCapacity = length + 1;
@@ -489,9 +497,9 @@ void String::Swap(String& str)
     std::swap(data_, str.data_);
     std::swap(data_, str.data_);
 }
 }
 
 
-String String::Substring(unsigned pos) const
+String String::Substring(i32 pos) const
 {
 {
-    unsigned length = Length();
+    i32 length = Length();
 
 
     if (pos < length)
     if (pos < length)
     {
     {
@@ -505,9 +513,9 @@ String String::Substring(unsigned pos) const
         return String();
         return String();
 }
 }
 
 
-String String::Substring(unsigned pos, unsigned length) const
+String String::Substring(i32 pos, i32 length) const
 {
 {
-    unsigned thisLength = Length();
+    i32 thisLength = Length();
 
 
     if (pos < thisLength)
     if (pos < thisLength)
     {
     {
@@ -525,8 +533,8 @@ String String::Substring(unsigned pos, unsigned length) const
 
 
 String String::Trimmed() const
 String String::Trimmed() const
 {
 {
-    unsigned trimStart = 0;
-    unsigned trimEnd = Length();
+    i32 trimStart = 0;
+    i32 trimEnd = Length();
 
 
     const char* buffer = GetBuffer();
     const char* buffer = GetBuffer();
 
 
@@ -552,9 +560,9 @@ String String::ToLower() const
 {
 {
     String ret(*this);
     String ret(*this);
     const char* buffer = GetBuffer();
     const char* buffer = GetBuffer();
-    unsigned retLength = ret.Length();
+    i32 retLength = ret.Length();
     char* retBuffer = ret.GetBuffer();
     char* retBuffer = ret.GetBuffer();
-    for (unsigned i = 0; i < retLength; ++i)
+    for (i32 i = 0; i < retLength; ++i)
         retBuffer[i] = (char)tolower(buffer[i]);
         retBuffer[i] = (char)tolower(buffer[i]);
 
 
     return ret;
     return ret;
@@ -564,9 +572,9 @@ String String::ToUpper() const
 {
 {
     String ret(*this);
     String ret(*this);
     const char* buffer = GetBuffer();
     const char* buffer = GetBuffer();
-    unsigned retLength = ret.Length();
+    i32 retLength = ret.Length();
     char* retBuffer = ret.GetBuffer();
     char* retBuffer = ret.GetBuffer();
-    for (unsigned i = 0; i < retLength; ++i)
+    for (i32 i = 0; i < retLength; ++i)
         retBuffer[i] = (char)toupper(buffer[i]);
         retBuffer[i] = (char)toupper(buffer[i]);
 
 
     return ret;
     return ret;
@@ -582,14 +590,16 @@ void String::Join(const Vector<String>& subStrings, const String& glue)
     *this = Joined(subStrings, glue);
     *this = Joined(subStrings, glue);
 }
 }
 
 
-unsigned String::Find(char c, unsigned startPos, bool caseSensitive) const
+i32 String::Find(char c, i32 startPos, bool caseSensitive) const
 {
 {
+    assert(startPos >= 0);
+
     const char* buffer = GetBuffer();
     const char* buffer = GetBuffer();
-    unsigned length = Length();
+    i32 length = Length();
 
 
     if (caseSensitive)
     if (caseSensitive)
     {
     {
-        for (unsigned i = startPos; i < length; ++i)
+        for (i32 i = startPos; i < length; ++i)
         {
         {
             if (buffer[i] == c)
             if (buffer[i] == c)
                 return i;
                 return i;
@@ -598,7 +608,7 @@ unsigned String::Find(char c, unsigned startPos, bool caseSensitive) const
     else
     else
     {
     {
         c = (char)tolower(c);
         c = (char)tolower(c);
-        for (unsigned i = startPos; i < length; ++i)
+        for (i32 i = startPos; i < length; ++i)
         {
         {
             if (tolower(buffer[i]) == c)
             if (tolower(buffer[i]) == c)
                 return i;
                 return i;
@@ -608,10 +618,12 @@ unsigned String::Find(char c, unsigned startPos, bool caseSensitive) const
     return NPOS;
     return NPOS;
 }
 }
 
 
-unsigned String::Find(const String& str, unsigned startPos, bool caseSensitive) const
+i32 String::Find(const String& str, i32 startPos, bool caseSensitive) const
 {
 {
-    unsigned length = Length();
-    unsigned strLength = str.Length();
+    assert(startPos >= 0);
+
+    i32 length = Length();
+    i32 strLength = str.Length();
 
 
     if (!strLength || strLength > length)
     if (!strLength || strLength > length)
         return NPOS;
         return NPOS;
@@ -623,7 +635,7 @@ unsigned String::Find(const String& str, unsigned startPos, bool caseSensitive)
     if (!caseSensitive)
     if (!caseSensitive)
         first = (char)tolower(first);
         first = (char)tolower(first);
 
 
-    for (unsigned i = startPos; i <= length - strLength; ++i)
+    for (i32 i = startPos; i <= length - strLength; ++i)
     {
     {
         char c = buffer[i];
         char c = buffer[i];
         if (!caseSensitive)
         if (!caseSensitive)
@@ -631,9 +643,9 @@ unsigned String::Find(const String& str, unsigned startPos, bool caseSensitive)
 
 
         if (c == first)
         if (c == first)
         {
         {
-            unsigned skip = NPOS;
+            i32 skip = NPOS;
             bool found = true;
             bool found = true;
-            for (unsigned j = 1; j < strLength; ++j)
+            for (i32 j = 1; j < strLength; ++j)
             {
             {
                 c = buffer[i + j];
                 c = buffer[i + j];
                 char d = strBuffer[j];
                 char d = strBuffer[j];
@@ -662,17 +674,17 @@ unsigned String::Find(const String& str, unsigned startPos, bool caseSensitive)
     return NPOS;
     return NPOS;
 }
 }
 
 
-unsigned String::FindLast(char c, unsigned startPos, bool caseSensitive) const
+i32 String::FindLast(char c, i32 startPos, bool caseSensitive) const
 {
 {
-    unsigned length = Length();
+    i32 length = Length();
     const char* buffer = GetBuffer();
     const char* buffer = GetBuffer();
 
 
-    if (startPos >= length)
+    if (startPos == NPOS || startPos >= length)
         startPos = length - 1;
         startPos = length - 1;
 
 
     if (caseSensitive)
     if (caseSensitive)
     {
     {
-        for (unsigned i = startPos; i < length; --i)
+        for (i32 i = startPos; i >= 0; --i)
         {
         {
             if (buffer[i] == c)
             if (buffer[i] == c)
                 return i;
                 return i;
@@ -681,7 +693,7 @@ unsigned String::FindLast(char c, unsigned startPos, bool caseSensitive) const
     else
     else
     {
     {
         c = (char)tolower(c);
         c = (char)tolower(c);
-        for (unsigned i = startPos; i < length; --i)
+        for (i32 i = startPos; i >= 0; --i)
         {
         {
             if (tolower(buffer[i]) == c)
             if (tolower(buffer[i]) == c)
                 return i;
                 return i;
@@ -691,15 +703,15 @@ unsigned String::FindLast(char c, unsigned startPos, bool caseSensitive) const
     return NPOS;
     return NPOS;
 }
 }
 
 
-unsigned String::FindLast(const String& str, unsigned startPos, bool caseSensitive) const
+i32 String::FindLast(const String& str, i32 startPos, bool caseSensitive) const
 {
 {
-    unsigned length = Length();
-    unsigned strLength = str.Length();
+    i32 length = Length();
+    i32 strLength = str.Length();
 
 
     if (!strLength || strLength > length)
     if (!strLength || strLength > length)
         return NPOS;
         return NPOS;
 
 
-    if (startPos > length - strLength)
+    if (startPos == NPOS || startPos > length - strLength)
         startPos = length - strLength;
         startPos = length - strLength;
 
 
     const char* buffer = GetBuffer();
     const char* buffer = GetBuffer();
@@ -709,7 +721,7 @@ unsigned String::FindLast(const String& str, unsigned startPos, bool caseSensiti
     if (!caseSensitive)
     if (!caseSensitive)
         first = (char)tolower(first);
         first = (char)tolower(first);
 
 
-    for (unsigned i = startPos; i < length; --i)
+    for (i32 i = startPos; i >= 0; --i)
     {
     {
         char c = buffer[i];
         char c = buffer[i];
         if (!caseSensitive)
         if (!caseSensitive)
@@ -718,7 +730,7 @@ unsigned String::FindLast(const String& str, unsigned startPos, bool caseSensiti
         if (c == first)
         if (c == first)
         {
         {
             bool found = true;
             bool found = true;
-            for (unsigned j = 1; j < strLength; ++j)
+            for (i32 j = 1; j < strLength; ++j)
             {
             {
                 c = buffer[i + j];
                 c = buffer[i + j];
                 char d = strBuffer[j];
                 char d = strBuffer[j];
@@ -749,7 +761,7 @@ bool String::StartsWith(const String& str, bool caseSensitive) const
 
 
 bool String::EndsWith(const String& str, bool caseSensitive) const
 bool String::EndsWith(const String& str, bool caseSensitive) const
 {
 {
-    unsigned pos = FindLast(str, Length() - 1, caseSensitive);
+    i32 pos = FindLast(str, Length() - 1, caseSensitive);
     return pos != NPOS && pos == Length() - str.Length();
     return pos != NPOS && pos == Length() - str.Length();
 }
 }
 
 
@@ -810,9 +822,9 @@ void String::SetUTF8FromWChar(const wchar_t* str)
 #endif
 #endif
 }
 }
 
 
-unsigned String::LengthUTF8() const
+i32 String::LengthUTF8() const
 {
 {
-    unsigned ret = 0;
+    i32 ret = 0;
 
 
     const char* buffer = GetBuffer();
     const char* buffer = GetBuffer();
 
 
@@ -830,12 +842,12 @@ unsigned String::LengthUTF8() const
     return ret;
     return ret;
 }
 }
 
 
-unsigned String::ByteOffsetUTF8(unsigned index) const
+i32 String::ByteOffsetUTF8(i32 index) const
 {
 {
-    unsigned byteOffset = 0;
-    unsigned utfPos = 0;
+    i32 byteOffset = 0;
+    i32 utfPos = 0;
 
 
-    unsigned length = Length();
+    i32 length = Length();
 
 
     while (utfPos < index && byteOffset < length)
     while (utfPos < index && byteOffset < length)
     {
     {
@@ -846,28 +858,28 @@ unsigned String::ByteOffsetUTF8(unsigned index) const
     return byteOffset;
     return byteOffset;
 }
 }
 
 
-unsigned String::NextUTF8Char(unsigned& byteOffset) const
+unsigned String::NextUTF8Char(i32& byteOffset) const
 {
 {
     const char* buffer = GetBuffer();
     const char* buffer = GetBuffer();
 
 
     const char* src = buffer + byteOffset;
     const char* src = buffer + byteOffset;
     unsigned ret = DecodeUTF8(src);
     unsigned ret = DecodeUTF8(src);
-    byteOffset = (unsigned)(src - buffer);
+    byteOffset = (i32)(src - buffer);
 
 
     return ret;
     return ret;
 }
 }
 
 
-unsigned String::AtUTF8(unsigned index) const
+unsigned String::AtUTF8(i32 index) const
 {
 {
-    unsigned byteOffset = ByteOffsetUTF8(index);
+    i32 byteOffset = ByteOffsetUTF8(index);
     return NextUTF8Char(byteOffset);
     return NextUTF8Char(byteOffset);
 }
 }
 
 
-void String::ReplaceUTF8(unsigned index, unsigned unicodeChar)
+void String::ReplaceUTF8(i32 index, unsigned unicodeChar)
 {
 {
-    unsigned utfPos = 0;
-    unsigned byteOffset = 0;
-    unsigned length = Length();
+    i32 utfPos = 0;
+    i32 byteOffset = 0;
+    i32 length = Length();
 
 
     while (utfPos < index && byteOffset < length)
     while (utfPos < index && byteOffset < length)
     {
     {
@@ -878,7 +890,7 @@ void String::ReplaceUTF8(unsigned index, unsigned unicodeChar)
     if (utfPos < index)
     if (utfPos < index)
         return;
         return;
 
 
-    unsigned beginCharPos = byteOffset;
+    i32 beginCharPos = byteOffset;
     NextUTF8Char(byteOffset);
     NextUTF8Char(byteOffset);
 
 
     char temp[7];
     char temp[7];
@@ -886,7 +898,7 @@ void String::ReplaceUTF8(unsigned index, unsigned unicodeChar)
     EncodeUTF8(dest, unicodeChar);
     EncodeUTF8(dest, unicodeChar);
     *dest = 0;
     *dest = 0;
 
 
-    Replace(beginCharPos, byteOffset - beginCharPos, temp, (unsigned)(dest - temp));
+    Replace(beginCharPos, byteOffset - beginCharPos, temp, (i32)(dest - temp));
 }
 }
 
 
 String& String::AppendUTF8(unsigned unicodeChar)
 String& String::AppendUTF8(unsigned unicodeChar)
@@ -898,10 +910,10 @@ String& String::AppendUTF8(unsigned unicodeChar)
     return Append(temp);
     return Append(temp);
 }
 }
 
 
-String String::SubstringUTF8(unsigned pos) const
+String String::SubstringUTF8(i32 pos) const
 {
 {
-    unsigned utf8Length = LengthUTF8();
-    unsigned byteOffset = ByteOffsetUTF8(pos);
+    i32 utf8Length = LengthUTF8();
+    i32 byteOffset = ByteOffsetUTF8(pos);
     String ret;
     String ret;
 
 
     while (pos < utf8Length)
     while (pos < utf8Length)
@@ -913,11 +925,11 @@ String String::SubstringUTF8(unsigned pos) const
     return ret;
     return ret;
 }
 }
 
 
-String String::SubstringUTF8(unsigned pos, unsigned length) const
+String String::SubstringUTF8(i32 pos, i32 length) const
 {
 {
-    unsigned utf8Length = LengthUTF8();
-    unsigned byteOffset = ByteOffsetUTF8(pos);
-    unsigned endPos = pos + length;
+    i32 utf8Length = LengthUTF8();
+    i32 byteOffset = ByteOffsetUTF8(pos);
+    i32 endPos = pos + length;
     String ret;
     String ret;
 
 
     while (pos < endPos && pos < utf8Length)
     while (pos < endPos && pos < utf8Length)
@@ -1106,7 +1118,7 @@ String String::Joined(const Vector<String>& subStrings, const String& glue)
         return String();
         return String();
 
 
     String joinedString(subStrings[0]);
     String joinedString(subStrings[0]);
-    for (unsigned i = 1; i < subStrings.Size(); ++i)
+    for (i32 i = 1; i < subStrings.Size(); ++i)
         joinedString.Append(glue).Append(subStrings[i]);
         joinedString.Append(glue).Append(subStrings[i]);
 
 
     return joinedString;
     return joinedString;
@@ -1124,13 +1136,13 @@ String& String::AppendWithFormat(const char* formatString, ...)
 String& String::AppendWithFormatArgs(const char* formatString, va_list args)
 String& String::AppendWithFormatArgs(const char* formatString, va_list args)
 {
 {
     int pos = 0, lastPos = 0;
     int pos = 0, lastPos = 0;
-    auto length = (int)strlen(formatString);
+    i32 length = (i32)strlen(formatString);
 
 
     while (true)
     while (true)
     {
     {
         // Scan the format string and find %a argument where a is one of d, f, s ...
         // Scan the format string and find %a argument where a is one of d, f, s ...
         while (pos < length && formatString[pos] != '%') pos++;
         while (pos < length && formatString[pos] != '%') pos++;
-        Append(formatString + lastPos, (unsigned)(pos - lastPos));
+        Append(formatString + lastPos, (i32)(pos - lastPos));
         if (pos >= length)
         if (pos >= length)
             return *this;
             return *this;
 
 
@@ -1195,7 +1207,7 @@ String& String::AppendWithFormatArgs(const char* formatString, va_list args)
                 char buf[CONVERSION_BUFFER_LENGTH];
                 char buf[CONVERSION_BUFFER_LENGTH];
                 int arg = va_arg(args, int);
                 int arg = va_arg(args, int);
                 int arglen = ::sprintf(buf, "%x", arg);
                 int arglen = ::sprintf(buf, "%x", arg);
-                Append(buf, (unsigned)arglen);
+                Append(buf, arglen);
                 break;
                 break;
             }
             }
 
 
@@ -1205,7 +1217,7 @@ String& String::AppendWithFormatArgs(const char* formatString, va_list args)
                 char buf[CONVERSION_BUFFER_LENGTH];
                 char buf[CONVERSION_BUFFER_LENGTH];
                 int arg = va_arg(args, int);
                 int arg = va_arg(args, int);
                 int arglen = ::sprintf(buf, "%p", reinterpret_cast<void*>(arg));
                 int arglen = ::sprintf(buf, "%p", reinterpret_cast<void*>(arg));
-                Append(buf, (unsigned)arglen);
+                Append(buf, arglen);
                 break;
                 break;
             }
             }
 
 
@@ -1248,10 +1260,10 @@ int String::Compare(const char* lhs, const char* rhs, bool caseSensitive)
     }
     }
 }
 }
 
 
-void String::Replace(unsigned pos, unsigned length, const char* srcStart, unsigned srcLength)
+void String::Replace(i32 pos, i32 length, const char* srcStart, i32 srcLength)
 {
 {
-    int delta = (int)srcLength - (int)length;
-    unsigned thisLength = Length();
+    i32 delta = srcLength - length;
+    i32 thisLength = Length();
 
 
     if (pos + length < thisLength)
     if (pos + length < thisLength)
     {
     {
@@ -1286,10 +1298,10 @@ WString::WString(const String& str) :
     buffer_(nullptr)
     buffer_(nullptr)
 {
 {
 #ifdef _WIN32
 #ifdef _WIN32
-    unsigned neededSize = 0;
+    i32 neededSize = 0;
     wchar_t temp[3];
     wchar_t temp[3];
 
 
-    unsigned byteOffset = 0;
+    i32 byteOffset = 0;
     while (byteOffset < str.Length())
     while (byteOffset < str.Length())
     {
     {
         wchar_t* dest = temp;
         wchar_t* dest = temp;
@@ -1306,7 +1318,7 @@ WString::WString(const String& str) :
 #else
 #else
     Resize(str.LengthUTF8());
     Resize(str.LengthUTF8());
 
 
-    unsigned byteOffset = 0;
+    i32 byteOffset = 0;
     wchar_t* dest = buffer_;
     wchar_t* dest = buffer_;
     while (byteOffset < str.Length())
     while (byteOffset < str.Length())
         *dest++ = (wchar_t)str.NextUTF8Char(byteOffset);
         *dest++ = (wchar_t)str.NextUTF8Char(byteOffset);
@@ -1318,7 +1330,7 @@ WString::~WString()
     delete[] buffer_;
     delete[] buffer_;
 }
 }
 
 
-void WString::Resize(unsigned newLength)
+void WString::Resize(i32 newLength)
 {
 {
     if (!newLength)
     if (!newLength)
     {
     {
@@ -1331,7 +1343,7 @@ void WString::Resize(unsigned newLength)
         auto* newBuffer = new wchar_t[newLength + 1];
         auto* newBuffer = new wchar_t[newLength + 1];
         if (buffer_)
         if (buffer_)
         {
         {
-            unsigned copyLength = length_ < newLength ? length_ : newLength;
+            i32 copyLength = length_ < newLength ? length_ : newLength;
             memcpy(newBuffer, buffer_, copyLength * sizeof(wchar_t));
             memcpy(newBuffer, buffer_, copyLength * sizeof(wchar_t));
             delete[] buffer_;
             delete[] buffer_;
         }
         }

+ 64 - 64
Source/Urho3D/Container/Str.h

@@ -66,7 +66,7 @@ public:
     }
     }
 
 
     /// Construct from a char array and length.
     /// Construct from a char array and length.
-    String(const char* str, unsigned length)
+    String(const char* str, i32 length)
         : String()
         : String()
     {
     {
         Resize(length);
         Resize(length);
@@ -117,7 +117,7 @@ public:
     /// Construct from a character.
     /// Construct from a character.
     explicit String(char value);
     explicit String(char value);
     /// Construct from a character and fill length.
     /// Construct from a character and fill length.
-    explicit String(char value, unsigned length);
+    explicit String(char value, i32 length);
 
 
     /// Construct from a convertible value.
     /// Construct from a convertible value.
     template <class T> explicit String(const T& value)
     template <class T> explicit String(const T& value)
@@ -155,7 +155,7 @@ public:
     /// Assign a C string.
     /// Assign a C string.
     String& operator =(const char* rhs)
     String& operator =(const char* rhs)
     {
     {
-        unsigned rhsLength = CStringLength(rhs);
+        i32 rhsLength = CStringLength(rhs);
         Resize(rhsLength);
         Resize(rhsLength);
         CopyChars(GetBuffer(), rhs, rhsLength);
         CopyChars(GetBuffer(), rhs, rhsLength);
 
 
@@ -165,8 +165,8 @@ public:
     /// Add-assign a string.
     /// Add-assign a string.
     String& operator +=(const String& rhs)
     String& operator +=(const String& rhs)
     {
     {
-        unsigned oldLength = Length();
-        unsigned rhsLength = rhs.Length();
+        i32 oldLength = Length();
+        i32 rhsLength = rhs.Length();
         Resize(oldLength + rhsLength);
         Resize(oldLength + rhsLength);
         CopyChars(GetBuffer() + oldLength, rhs.GetBuffer(), rhsLength);
         CopyChars(GetBuffer() + oldLength, rhs.GetBuffer(), rhsLength);
 
 
@@ -176,8 +176,8 @@ public:
     /// Add-assign a C string.
     /// Add-assign a C string.
     String& operator +=(const char* rhs)
     String& operator +=(const char* rhs)
     {
     {
-        unsigned rhsLength = CStringLength(rhs);
-        unsigned oldLength = Length();
+        i32 rhsLength = CStringLength(rhs);
+        i32 oldLength = Length();
         Resize(oldLength + rhsLength);
         Resize(oldLength + rhsLength);
         CopyChars(GetBuffer() + oldLength, rhs, rhsLength);
         CopyChars(GetBuffer() + oldLength, rhs, rhsLength);
 
 
@@ -187,7 +187,7 @@ public:
     /// Add-assign a character.
     /// Add-assign a character.
     String& operator +=(char rhs)
     String& operator +=(char rhs)
     {
     {
-        unsigned oldLength = Length();
+        i32 oldLength = Length();
         Resize(oldLength + 1);
         Resize(oldLength + 1);
         GetBuffer()[oldLength] = rhs;
         GetBuffer()[oldLength] = rhs;
 
 
@@ -224,8 +224,8 @@ public:
     String operator +(const String& rhs) const
     String operator +(const String& rhs) const
     {
     {
         String ret;
         String ret;
-        unsigned length = Length();
-        unsigned rhsLength = rhs.Length();
+        i32 length = Length();
+        i32 rhsLength = rhs.Length();
         ret.Resize(length + rhsLength);
         ret.Resize(length + rhsLength);
         char* retBuffer = ret.GetBuffer();
         char* retBuffer = ret.GetBuffer();
         CopyChars(retBuffer, GetBuffer(), length);
         CopyChars(retBuffer, GetBuffer(), length);
@@ -237,8 +237,8 @@ public:
     /// Add a C string.
     /// Add a C string.
     String operator +(const char* rhs) const
     String operator +(const char* rhs) const
     {
     {
-        unsigned length = Length();
-        unsigned rhsLength = CStringLength(rhs);
+        i32 length = Length();
+        i32 rhsLength = CStringLength(rhs);
         String ret;
         String ret;
         ret.Resize(length + rhsLength);
         ret.Resize(length + rhsLength);
         char* retBuffer = ret.GetBuffer();
         char* retBuffer = ret.GetBuffer();
@@ -273,30 +273,30 @@ public:
     bool operator >(const char* rhs) const { return strcmp(CString(), rhs) > 0; }
     bool operator >(const char* rhs) const { return strcmp(CString(), rhs) > 0; }
 
 
     /// Return char at index.
     /// Return char at index.
-    char& operator [](unsigned index)
+    char& operator [](i32 index)
     {
     {
-        assert(index < Length());
+        assert(index >= 0 && index < Length());
         return GetBuffer()[index];
         return GetBuffer()[index];
     }
     }
 
 
     /// Return const char at index.
     /// Return const char at index.
-    const char& operator [](unsigned index) const
+    const char& operator [](i32 index) const
     {
     {
-        assert(index < Length());
+        assert(index >= 0 && index < Length());
         return GetBuffer()[index];
         return GetBuffer()[index];
     }
     }
 
 
     /// Return char at index.
     /// Return char at index.
-    char& At(unsigned index)
+    char& At(i32 index)
     {
     {
-        assert(index < Length());
+        assert(index >= 0 && index < Length());
         return GetBuffer()[index];
         return GetBuffer()[index];
     }
     }
 
 
     /// Return const char at index.
     /// Return const char at index.
-    const char& At(unsigned index) const
+    const char& At(i32 index) const
     {
     {
-        assert(index < Length());
+        assert(index >= 0 && index < Length());
         return GetBuffer()[index];
         return GetBuffer()[index];
     }
     }
 
 
@@ -305,9 +305,9 @@ public:
     /// Replace all occurrences of a string.
     /// Replace all occurrences of a string.
     void Replace(const String& replaceThis, const String& replaceWith, bool caseSensitive = true);
     void Replace(const String& replaceThis, const String& replaceWith, bool caseSensitive = true);
     /// Replace a substring.
     /// Replace a substring.
-    void Replace(unsigned pos, unsigned length, const String& replaceWith);
+    void Replace(i32 pos, i32 length, const String& replaceWith);
     /// Replace a substring with a C string.
     /// Replace a substring with a C string.
-    void Replace(unsigned pos, unsigned length, const char* replaceWith);
+    void Replace(i32 pos, i32 length, const char* replaceWith);
     /// Replace a substring by iterators.
     /// Replace a substring by iterators.
     Iterator Replace(const Iterator& start, const Iterator& end, const String& replaceWith);
     Iterator Replace(const Iterator& start, const Iterator& end, const String& replaceWith);
     /// Return a string with all occurrences of a character replaced.
     /// Return a string with all occurrences of a character replaced.
@@ -321,11 +321,11 @@ public:
     /// Append a character.
     /// Append a character.
     String& Append(char c);
     String& Append(char c);
     /// Append characters.
     /// Append characters.
-    String& Append(const char* str, unsigned length);
+    String& Append(const char* str, i32 length);
     /// Insert a string.
     /// Insert a string.
-    void Insert(unsigned pos, const String& str);
+    void Insert(i32 pos, const String& str);
     /// Insert a character.
     /// Insert a character.
-    void Insert(unsigned pos, char c);
+    void Insert(i32 pos, char c);
     /// Insert a string by iterator.
     /// Insert a string by iterator.
     Iterator Insert(const Iterator& dest, const String& str);
     Iterator Insert(const Iterator& dest, const String& str);
     /// Insert a string partially by iterators.
     /// Insert a string partially by iterators.
@@ -333,17 +333,17 @@ public:
     /// Insert a character by iterator.
     /// Insert a character by iterator.
     Iterator Insert(const Iterator& dest, char c);
     Iterator Insert(const Iterator& dest, char c);
     /// Erase a substring.
     /// Erase a substring.
-    void Erase(unsigned pos, unsigned length = 1);
+    void Erase(i32 pos, i32 length = 1);
     /// Erase a character by iterator.
     /// Erase a character by iterator.
     Iterator Erase(const Iterator& it);
     Iterator Erase(const Iterator& it);
     /// Erase a substring by iterators.
     /// Erase a substring by iterators.
     Iterator Erase(const Iterator& start, const Iterator& end);
     Iterator Erase(const Iterator& start, const Iterator& end);
 
 
     /// Resize the string. Can increase capacity, but never decrease.
     /// Resize the string. Can increase capacity, but never decrease.
-    void Resize(unsigned newLength);
+    void Resize(i32 newLength);
 
 
     /// Set new capacity. New capacity may differ from requested.
     /// Set new capacity. New capacity may differ from requested.
-    void Reserve(unsigned newCapacity);
+    void Reserve(i32 newCapacity);
 
 
     /// Reallocate so that no extra memory is used.
     /// Reallocate so that no extra memory is used.
     void Compact();
     void Compact();
@@ -370,14 +370,14 @@ public:
     /// Return last char, or 0 if empty.
     /// Return last char, or 0 if empty.
     char Back() const
     char Back() const
     {
     {
-        unsigned length = Length();
+        i32 length = Length();
         return length ? GetBuffer()[length - 1] : GetBuffer()[0];
         return length ? GetBuffer()[length - 1] : GetBuffer()[0];
     }
     }
 
 
     /// Return a substring from position to end.
     /// Return a substring from position to end.
-    String Substring(unsigned pos) const;
+    String Substring(i32 pos) const;
     /// Return a substring with length from position.
     /// Return a substring with length from position.
-    String Substring(unsigned pos, unsigned length) const;
+    String Substring(i32 pos, i32 length) const;
     /// Return string with whitespace trimmed from the beginning and the end.
     /// Return string with whitespace trimmed from the beginning and the end.
     String Trimmed() const;
     String Trimmed() const;
     /// Return string in uppercase.
     /// Return string in uppercase.
@@ -389,13 +389,13 @@ public:
     /// Join substrings with a 'glue' string.
     /// Join substrings with a 'glue' string.
     void Join(const Vector<String>& subStrings, const String& glue);
     void Join(const Vector<String>& subStrings, const String& glue);
     /// Return index to the first occurrence of a string, or NPOS if not found.
     /// Return index to the first occurrence of a string, or NPOS if not found.
-    unsigned Find(const String& str, unsigned startPos = 0, bool caseSensitive = true) const;
+    i32 Find(const String& str, i32 startPos = 0, bool caseSensitive = true) const;
     /// Return index to the first occurrence of a character, or NPOS if not found.
     /// Return index to the first occurrence of a character, or NPOS if not found.
-    unsigned Find(char c, unsigned startPos = 0, bool caseSensitive = true) const;
+    i32 Find(char c, i32 startPos = 0, bool caseSensitive = true) const;
     /// Return index to the last occurrence of a string, or NPOS if not found.
     /// Return index to the last occurrence of a string, or NPOS if not found.
-    unsigned FindLast(const String& str, unsigned startPos = NPOS, bool caseSensitive = true) const;
+    i32 FindLast(const String& str, i32 startPos = NPOS, bool caseSensitive = true) const;
     /// Return index to the last occurrence of a character, or NPOS if not found.
     /// Return index to the last occurrence of a character, or NPOS if not found.
-    unsigned FindLast(char c, unsigned startPos = NPOS, bool caseSensitive = true) const;
+    i32 FindLast(char c, i32 startPos = NPOS, bool caseSensitive = true) const;
     /// Return whether starts with a string.
     /// Return whether starts with a string.
     bool StartsWith(const String& str, bool caseSensitive = true) const;
     bool StartsWith(const String& str, bool caseSensitive = true) const;
     /// Return whether ends with a string.
     /// Return whether ends with a string.
@@ -412,10 +412,10 @@ public:
 
 
     /// Return length.
     /// Return length.
     /// @property
     /// @property
-    unsigned Length() const { return IsShort() ? GetShortStringLength() : data_.longString_.length_; }
+    i32 Length() const { return IsShort() ? GetShortStringLength() : data_.longString_.length_; }
 
 
     /// Return buffer capacity.
     /// Return buffer capacity.
-    unsigned Capacity() const { return IsShort() ? SHORT_STRING_CAPACITY : data_.longString_.capacity_; }
+    i32 Capacity() const { return IsShort() ? SHORT_STRING_CAPACITY : data_.longString_.capacity_; }
 
 
     /// Return whether the string is empty.
     /// Return whether the string is empty.
     /// @property
     /// @property
@@ -438,21 +438,21 @@ public:
     void SetUTF8FromWChar(const wchar_t* str);
     void SetUTF8FromWChar(const wchar_t* str);
     /// Calculate number of characters in UTF8 content.
     /// Calculate number of characters in UTF8 content.
     /// @property{get_utf8Length}
     /// @property{get_utf8Length}
-    unsigned LengthUTF8() const;
+    i32 LengthUTF8() const;
     /// Return byte offset to char in UTF8 content.
     /// Return byte offset to char in UTF8 content.
-    unsigned ByteOffsetUTF8(unsigned index) const;
+    i32 ByteOffsetUTF8(i32 index) const;
     /// Return next Unicode character from UTF8 content and increase byte offset.
     /// Return next Unicode character from UTF8 content and increase byte offset.
-    unsigned NextUTF8Char(unsigned& byteOffset) const;
+    unsigned NextUTF8Char(i32& byteOffset) const;
     /// Return Unicode character at index from UTF8 content.
     /// Return Unicode character at index from UTF8 content.
-    unsigned AtUTF8(unsigned index) const;
+    unsigned AtUTF8(i32 index) const;
     /// Replace Unicode character at index from UTF8 content.
     /// Replace Unicode character at index from UTF8 content.
-    void ReplaceUTF8(unsigned index, unsigned unicodeChar);
+    void ReplaceUTF8(i32 index, unsigned unicodeChar);
     /// Append Unicode character at the end as UTF8.
     /// Append Unicode character at the end as UTF8.
     String& AppendUTF8(unsigned unicodeChar);
     String& AppendUTF8(unsigned unicodeChar);
     /// Return a UTF8 substring from position to end.
     /// Return a UTF8 substring from position to end.
-    String SubstringUTF8(unsigned pos) const;
+    String SubstringUTF8(i32 pos) const;
     /// Return a UTF8 substring with length from position.
     /// Return a UTF8 substring with length from position.
-    String SubstringUTF8(unsigned pos, unsigned length) const;
+    String SubstringUTF8(i32 pos, i32 length) const;
 
 
     /// Return hash value for HashSet & HashMap.
     /// Return hash value for HashSet & HashMap.
     unsigned ToHash() const
     unsigned ToHash() const
@@ -485,7 +485,7 @@ public:
 #endif
 #endif
 
 
     /// Return length of a C string.
     /// Return length of a C string.
-    static unsigned CStringLength(const char* str) { return str ? (unsigned)strlen(str) : 0; }
+    static i32 CStringLength(const char* str) { return str ? (i32)strlen(str) : 0; }
 
 
     /// Append to string using formatting.
     /// Append to string using formatting.
     String& AppendWithFormat(const char* formatString, ...);
     String& AppendWithFormat(const char* formatString, ...);
@@ -496,7 +496,7 @@ public:
     static int Compare(const char* lhs, const char* rhs, bool caseSensitive);
     static int Compare(const char* lhs, const char* rhs, bool caseSensitive);
 
 
     /// Position for "not found".
     /// Position for "not found".
-    static inline constexpr unsigned NPOS = 0xffffffff;
+    static inline constexpr i32 NPOS = -1;
 
 
     /// Empty string.
     /// Empty string.
     static const String EMPTY;
     static const String EMPTY;
@@ -515,14 +515,14 @@ private:
         char* buffer_;
         char* buffer_;
 
 
         /// Number of bytes without null terminator.
         /// Number of bytes without null terminator.
-        u32 length_;
+        i32 length_;
 
 
         /// Size of buffer_.
         /// Size of buffer_.
-        u32 capacity_;
+        i32 capacity_;
     };
     };
 
 
     /// 11 bytes on 32-bit platform, 15 bytes on 64-bit platform
     /// 11 bytes on 32-bit platform, 15 bytes on 64-bit platform
-    inline static constexpr unsigned SHORT_STRING_CAPACITY = sizeof(LongString) - 1;
+    inline static constexpr i32 SHORT_STRING_CAPACITY = sizeof(LongString) - 1;
 
 
     struct ShortString
     struct ShortString
     {
     {
@@ -550,7 +550,7 @@ private:
 
 
     inline static constexpr u8 INVERTED_SSO_MASK = static_cast<u8>(~SSO_MASK);
     inline static constexpr u8 INVERTED_SSO_MASK = static_cast<u8>(~SSO_MASK);
 
 
-    unsigned GetShortStringLength() const
+    i32 GetShortStringLength() const
     {
     {
         return data_.shortString_.length_ & INVERTED_SSO_MASK;
         return data_.shortString_.length_ & INVERTED_SSO_MASK;
     }
     }
@@ -561,7 +561,7 @@ private:
     }
     }
 
 
     /// Move a range of characters within the string.
     /// Move a range of characters within the string.
-    void MoveRange(unsigned dest, unsigned src, unsigned count)
+    void MoveRange(i32 dest, i32 src, i32 count)
     {
     {
         if (count)
         if (count)
         {
         {
@@ -571,7 +571,7 @@ private:
     }
     }
 
 
     /// Copy chars from one buffer to another.
     /// Copy chars from one buffer to another.
-    static void CopyChars(char* dest, const char* src, unsigned count)
+    static void CopyChars(char* dest, const char* src, i32 count)
     {
     {
 #ifdef _MSC_VER
 #ifdef _MSC_VER
         if (count)
         if (count)
@@ -588,7 +588,7 @@ private:
     }
     }
 
 
     /// Replace a substring with another substring.
     /// Replace a substring with another substring.
-    void Replace(unsigned pos, unsigned length, const char* srcStart, unsigned srcLength);
+    void Replace(i32 pos, i32 length, const char* srcStart, i32 srcLength);
 };
 };
 
 
 /// Add a string to a C string.
 /// Add a string to a C string.
@@ -620,48 +620,48 @@ public:
     ~WString();
     ~WString();
 
 
     /// Return char at index.
     /// Return char at index.
-    wchar_t& operator [](unsigned index)
+    wchar_t& operator [](i32 index)
     {
     {
-        assert(index < length_);
+        assert(index >= 0 && index < length_);
         return buffer_[index];
         return buffer_[index];
     }
     }
 
 
     /// Return const char at index.
     /// Return const char at index.
-    const wchar_t& operator [](unsigned index) const
+    const wchar_t& operator [](i32 index) const
     {
     {
-        assert(index < length_);
+        assert(index >= 0 && index < length_);
         return buffer_[index];
         return buffer_[index];
     }
     }
 
 
     /// Return char at index.
     /// Return char at index.
-    wchar_t& At(unsigned index)
+    wchar_t& At(i32 index)
     {
     {
-        assert(index < length_);
+        assert(index >= 0 && index < length_);
         return buffer_[index];
         return buffer_[index];
     }
     }
 
 
     /// Return const char at index.
     /// Return const char at index.
-    const wchar_t& At(unsigned index) const
+    const wchar_t& At(i32 index) const
     {
     {
-        assert(index < length_);
+        assert(index >= 0 && index < length_);
         return buffer_[index];
         return buffer_[index];
     }
     }
 
 
     /// Resize the string.
     /// Resize the string.
-    void Resize(unsigned newLength);
+    void Resize(i32 newLength);
 
 
     /// Return whether the string is empty.
     /// Return whether the string is empty.
     bool Empty() const { return length_ == 0; }
     bool Empty() const { return length_ == 0; }
 
 
     /// Return length.
     /// Return length.
-    unsigned Length() const { return length_; }
+    i32 Length() const { return length_; }
 
 
     /// Return character data.
     /// Return character data.
     const wchar_t* CString() const { return buffer_; }
     const wchar_t* CString() const { return buffer_; }
 
 
 private:
 private:
     /// String length.
     /// String length.
-    unsigned length_;
+    i32 length_;
     /// String buffer, null if not allocated.
     /// String buffer, null if not allocated.
     wchar_t* buffer_;
     wchar_t* buffer_;
 };
 };

+ 1 - 1
Source/Urho3D/Engine/Application.cpp

@@ -110,7 +110,7 @@ void Application::HandleLogMessage(StringHash eventType, VariantMap& eventData)
     {
     {
         // Strip the timestamp if necessary
         // Strip the timestamp if necessary
         String error = eventData[P_MESSAGE].GetString();
         String error = eventData[P_MESSAGE].GetString();
-        unsigned bracketPos = error.Find(']');
+        i32 bracketPos = error.Find(']');
         if (bracketPos != String::NPOS)
         if (bracketPos != String::NPOS)
             error = error.Substring(bracketPos + 2);
             error = error.Substring(bracketPos + 2);
 
 

+ 1 - 1
Source/Urho3D/GraphicsAPI/Direct3D11/D3D11ShaderVariation.cpp

@@ -247,7 +247,7 @@ bool ShaderVariation::Compile_D3D11()
 
 
     for (unsigned i = 0; i < defines.Size(); ++i)
     for (unsigned i = 0; i < defines.Size(); ++i)
     {
     {
-        unsigned equalsPos = defines[i].Find('=');
+        i32 equalsPos = defines[i].Find('=');
         if (equalsPos != String::NPOS)
         if (equalsPos != String::NPOS)
         {
         {
             defineValues.Push(defines[i].Substring(equalsPos + 1));
             defineValues.Push(defines[i].Substring(equalsPos + 1));

+ 1 - 1
Source/Urho3D/GraphicsAPI/Direct3D9/D3D9ShaderVariation.cpp

@@ -245,7 +245,7 @@ bool ShaderVariation::Compile_D3D9()
 
 
     for (unsigned i = 0; i < defines.Size(); ++i)
     for (unsigned i = 0; i < defines.Size(); ++i)
     {
     {
-        unsigned equalsPos = defines[i].Find('=');
+        i32 equalsPos = defines[i].Find('=');
         if (equalsPos != String::NPOS)
         if (equalsPos != String::NPOS)
         {
         {
             defineValues.Push(defines[i].Substring(equalsPos + 1));
             defineValues.Push(defines[i].Substring(equalsPos + 1));

+ 1 - 1
Source/Urho3D/GraphicsAPI/OpenGL/OGLShaderProgram.cpp

@@ -243,7 +243,7 @@ bool ShaderProgram_OGL::Link()
 
 
         // Check for array index included in the name and strip it
         // Check for array index included in the name and strip it
         String name(nameBuffer);
         String name(nameBuffer);
-        unsigned index = name.Find('[');
+        i32 index = name.Find('[');
         if (index != String::NPOS)
         if (index != String::NPOS)
         {
         {
             // If not the first index, skip
             // If not the first index, skip

+ 2 - 2
Source/Urho3D/GraphicsAPI/OpenGL/OGLShaderVariation.cpp

@@ -89,8 +89,8 @@ bool ShaderVariation::Create_OGL()
     String shaderCode;
     String shaderCode;
 
 
     // Check if the shader code contains a version define
     // Check if the shader code contains a version define
-    unsigned verStart = originalShaderCode.Find('#');
-    unsigned verEnd = 0;
+    i32 verStart = originalShaderCode.Find('#');
+    i32 verEnd = 0;
     if (verStart != String::NPOS)
     if (verStart != String::NPOS)
     {
     {
         if (originalShaderCode.Substring(verStart + 1, 7) == "version")
         if (originalShaderCode.Substring(verStart + 1, 7) == "version")

+ 2 - 2
Source/Urho3D/GraphicsAPI/Shader.cpp

@@ -19,14 +19,14 @@ namespace Urho3D
 
 
 void CommentOutFunction(String& code, const String& signature)
 void CommentOutFunction(String& code, const String& signature)
 {
 {
-    unsigned startPos = code.Find(signature);
+    i32 startPos = code.Find(signature);
     unsigned braceLevel = 0;
     unsigned braceLevel = 0;
     if (startPos == String::NPOS)
     if (startPos == String::NPOS)
         return;
         return;
 
 
     code.Insert(startPos, "/*");
     code.Insert(startPos, "/*");
 
 
-    for (unsigned i = startPos + 2 + signature.Length(); i < code.Length(); ++i)
+    for (i32 i = startPos + 2 + signature.Length(); i < code.Length(); ++i)
     {
     {
         if (code[i] == '{')
         if (code[i] == '{')
             ++braceLevel;
             ++braceLevel;

+ 4 - 4
Source/Urho3D/IO/FileSystem.cpp

@@ -629,7 +629,7 @@ bool FileSystem::DirExists(const String& pathName) const
         // Split the pathname into two components: the longest parent directory path and the last name component
         // Split the pathname into two components: the longest parent directory path and the last name component
         String assetPath(URHO3D_ASSET((fixedName + "/")));
         String assetPath(URHO3D_ASSET((fixedName + "/")));
         String parentPath;
         String parentPath;
-        unsigned pos = assetPath.FindLast('/', assetPath.Length() - 2);
+        i32 pos = assetPath.FindLast('/', assetPath.Length() - 2);
         if (pos != String::NPOS)
         if (pos != String::NPOS)
         {
         {
             parentPath = assetPath.Substring(0, pos);
             parentPath = assetPath.Substring(0, pos);
@@ -921,8 +921,8 @@ void SplitPath(const String& fullPath, String& pathName, String& fileName, Strin
 {
 {
     String fullPathCopy = GetInternalPath(fullPath);
     String fullPathCopy = GetInternalPath(fullPath);
 
 
-    unsigned extPos = fullPathCopy.FindLast('.');
-    unsigned pathPos = fullPathCopy.FindLast('/');
+    i32 extPos = fullPathCopy.FindLast('.');
+    i32 pathPos = fullPathCopy.FindLast('/');
 
 
     if (extPos != String::NPOS && (pathPos == String::NPOS || extPos > pathPos))
     if (extPos != String::NPOS && (pathPos == String::NPOS || extPos > pathPos))
     {
     {
@@ -1002,7 +1002,7 @@ String RemoveTrailingSlash(const String& pathName)
 
 
 String GetParentPath(const String& path)
 String GetParentPath(const String& path)
 {
 {
-    unsigned pos = RemoveTrailingSlash(path).FindLast('/');
+    i32 pos = RemoveTrailingSlash(path).FindLast('/');
     if (pos != String::NPOS)
     if (pos != String::NPOS)
         return path.Substring(0, pos + 1);
         return path.Substring(0, pos + 1);
     else
     else

+ 1 - 1
Source/Urho3D/LuaScript/LuaFile.cpp

@@ -75,7 +75,7 @@ bool LuaFile::LoadChunk(lua_State* luaState)
 
 
     // Get file base name
     // Get file base name
     String name = GetName();
     String name = GetName();
-    unsigned extPos = name.FindLast('.');
+    i32 extPos = name.FindLast('.');
     if (extPos != String::NPOS)
     if (extPos != String::NPOS)
         name = name.Substring(0, extPos);
         name = name.Substring(0, extPos);
 
 

+ 3 - 3
Source/Urho3D/Network/HttpRequest.cpp

@@ -65,7 +65,7 @@ void HttpRequest::ThreadFunction()
     String path = "/";
     String path = "/";
     int port = 80;
     int port = 80;
 
 
-    unsigned protocolEnd = url_.Find("://");
+    i32 protocolEnd = url_.Find("://");
     if (protocolEnd != String::NPOS)
     if (protocolEnd != String::NPOS)
     {
     {
         protocol = url_.Substring(0, protocolEnd);
         protocol = url_.Substring(0, protocolEnd);
@@ -74,14 +74,14 @@ void HttpRequest::ThreadFunction()
     else
     else
         host = url_;
         host = url_;
 
 
-    unsigned pathStart = host.Find('/');
+    i32 pathStart = host.Find('/');
     if (pathStart != String::NPOS)
     if (pathStart != String::NPOS)
     {
     {
         path = host.Substring(pathStart);
         path = host.Substring(pathStart);
         host = host.Substring(0, pathStart);
         host = host.Substring(0, pathStart);
     }
     }
 
 
-    unsigned portStart = host.Find(':');
+    i32 portStart = host.Find(':');
     if (portStart != String::NPOS)
     if (portStart != String::NPOS)
     {
     {
         port = ToInt(host.Substring(portStart + 1));
         port = ToInt(host.Substring(portStart + 1));

+ 1 - 1
Source/Urho3D/UI/Text.cpp

@@ -267,7 +267,7 @@ bool Text::SetFontSize(float size)
 void Text::DecodeToUnicode()
 void Text::DecodeToUnicode()
 {
 {
     unicodeText_.Clear();
     unicodeText_.Clear();
-    for (unsigned i = 0; i < text_.Length();)
+    for (i32 i = 0; i < text_.Length();)
         unicodeText_.Push(text_.NextUTF8Char(i));
         unicodeText_.Push(text_.NextUTF8Char(i));
 }
 }