From 05a00a8d9142d34c726271215c279b4febb3cc9c Mon Sep 17 00:00:00 2001 From: sfan5 Date: Fri, 23 Dec 2022 19:56:21 +0100 Subject: [PATCH] Completely remove irrAllocator --- include/IImage.h | 12 +- include/IVideoDriver.h | 2 +- include/SMaterialLayer.h | 17 +- include/irrAllocator.h | 113 -------- include/irrUString.h | 415 ++++++++++++--------------- source/Irrlicht/COpenGLCoreTexture.h | 2 +- 6 files changed, 189 insertions(+), 372 deletions(-) delete mode 100644 include/irrAllocator.h diff --git a/include/IImage.h b/include/IImage.h index 3d4d5fa0..20d3d54e 100644 --- a/include/IImage.h +++ b/include/IImage.h @@ -9,7 +9,6 @@ #include "position2d.h" #include "rect.h" #include "SColor.h" -#include "irrAllocator.h" #include namespace irr @@ -44,7 +43,7 @@ public: delete[] Data; if (DeleteMipMapsMemory) - Allocator.deallocate(MipMapsData); + delete[] MipMapsData; } //! Returns the color format @@ -275,13 +274,13 @@ public: will by copied internally. \param deleteMemory Whether the memory is deallocated upon destruction. */ - void setMipMapsData(void* data, bool ownForeignMemory, bool deleteMemory) + void setMipMapsData(void* data, bool ownForeignMemory) { if (data != MipMapsData) { if (DeleteMipMapsMemory) { - Allocator.deallocate(MipMapsData); + delete[] MipMapsData; DeleteMipMapsMemory = false; } @@ -292,7 +291,7 @@ public: { MipMapsData = static_cast(data); - DeleteMipMapsMemory = deleteMemory; + DeleteMipMapsMemory = false; } else { @@ -311,7 +310,7 @@ public: dataSize += getDataSizeFromFormat(Format, width, height); } while (width != 1 || height != 1); - MipMapsData = Allocator.allocate(dataSize); + MipMapsData = new u8[dataSize]; memcpy(MipMapsData, data, dataSize); DeleteMipMapsMemory = true; @@ -578,7 +577,6 @@ protected: bool DeleteMemory; bool DeleteMipMapsMemory; - core::irrAllocator Allocator; #if defined(IRRLICHT_sRGB) int Format_sRGB; #endif diff --git a/include/IVideoDriver.h b/include/IVideoDriver.h index 848a9b06..a8cea131 100644 --- a/include/IVideoDriver.h +++ b/include/IVideoDriver.h @@ -331,7 +331,7 @@ namespace video _IRR_DEPRECATED_ ITexture* addTexture(const io::path& name, IImage* image, void* mipmapData) { if (image) - image->setMipMapsData(mipmapData, false, true); + image->setMipMapsData(mipmapData, false); return addTexture(name, image); } diff --git a/include/SMaterialLayer.h b/include/SMaterialLayer.h index 2ef72c82..8f562deb 100644 --- a/include/SMaterialLayer.h +++ b/include/SMaterialLayer.h @@ -6,7 +6,6 @@ #define __S_MATERIAL_LAYER_H_INCLUDED__ #include "matrix4.h" -#include "irrAllocator.h" namespace irr { @@ -69,8 +68,7 @@ namespace video { if ( TextureMatrix ) { - MatrixAllocator.destruct(TextureMatrix); - MatrixAllocator.deallocate(TextureMatrix); + delete TextureMatrix; } } @@ -90,8 +88,7 @@ namespace video *TextureMatrix = *other.TextureMatrix; else { - MatrixAllocator.destruct(TextureMatrix); - MatrixAllocator.deallocate(TextureMatrix); + delete TextureMatrix; TextureMatrix = 0; } } @@ -99,8 +96,7 @@ namespace video { if (other.TextureMatrix) { - TextureMatrix = MatrixAllocator.allocate(1); - MatrixAllocator.construct(TextureMatrix,*other.TextureMatrix); + TextureMatrix = new core::matrix4(*other.TextureMatrix); } else TextureMatrix = 0; @@ -122,8 +118,7 @@ namespace video { if (!TextureMatrix) { - TextureMatrix = MatrixAllocator.allocate(1); - MatrixAllocator.construct(TextureMatrix,core::IdentityMatrix); + TextureMatrix = new core::matrix4(); } return *TextureMatrix; } @@ -146,8 +141,7 @@ namespace video { if (!TextureMatrix) { - TextureMatrix = MatrixAllocator.allocate(1); - MatrixAllocator.construct(TextureMatrix,mat); + TextureMatrix = new core::matrix4(mat); } else *TextureMatrix = mat; @@ -216,7 +210,6 @@ namespace video private: friend class SMaterial; - irr::core::irrAllocator MatrixAllocator; //! Texture Matrix /** Do not access this element directly as the internal diff --git a/include/irrAllocator.h b/include/irrAllocator.h deleted file mode 100644 index ff6624b8..00000000 --- a/include/irrAllocator.h +++ /dev/null @@ -1,113 +0,0 @@ -// Copyright (C) 2002-2012 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine" and the "irrXML" project. -// For conditions of distribution and use, see copyright notice in irrlicht.h and irrXML.h - -#ifndef __IRR_ALLOCATOR_H_INCLUDED__ -#define __IRR_ALLOCATOR_H_INCLUDED__ - -#include "irrTypes.h" -#include -// necessary for older compilers -#include - -namespace irr -{ -namespace core -{ - -//! Very simple allocator implementation, containers using it can be used across dll boundaries -template -class irrAllocator -{ -public: - - //! Destructor - virtual ~irrAllocator() {} - - //! Allocate memory for an array of objects - T* allocate(size_t cnt) - { - return (T*)internal_new(cnt* sizeof(T)); - } - - //! Deallocate memory for an array of objects - void deallocate(T* ptr) - { - internal_delete(ptr); - } - - //! Construct an element - void construct(T* ptr, const T&e) - { - new ((void*)ptr) T(e); - } - - //! Destruct an element - void destruct(T* ptr) - { - ptr->~T(); - } - -protected: - - virtual void* internal_new(size_t cnt) - { - return operator new(cnt); - } - - virtual void internal_delete(void* ptr) - { - operator delete(ptr); - } - -}; - - -//! Fast allocator, only to be used in containers inside the same memory heap. -/** Containers using it are NOT able to be used it across dll boundaries. Use this -when using in an internal class or function or when compiled into a static lib */ -template -class irrAllocatorFast -{ -public: - - //! Allocate memory for an array of objects - T* allocate(size_t cnt) - { - return (T*)operator new(cnt* sizeof(T)); - } - - //! Deallocate memory for an array of objects - void deallocate(T* ptr) - { - operator delete(ptr); - } - - //! Construct an element - void construct(T* ptr, const T&e) - { - new ((void*)ptr) T(e); - } - - //! Destruct an element - void destruct(T* ptr) - { - ptr->~T(); - } -}; - - -//! defines an allocation strategy (used only by irr::array so far) -enum eAllocStrategy -{ - ALLOC_STRATEGY_SAFE = 0, // increase size by 1 - ALLOC_STRATEGY_DOUBLE = 1, // double size when under 500 elements, beyond that increase by 1/4th size. Plus a small constant. - ALLOC_STRATEGY_SQRT = 2 // not implemented -}; - - -} // end namespace core -} // end namespace irr - -#endif - diff --git a/include/irrUString.h b/include/irrUString.h index 3e20ff8b..a50d497f 100644 --- a/include/irrUString.h +++ b/include/irrUString.h @@ -54,7 +54,6 @@ #include #include "irrTypes.h" -#include "irrAllocator.h" #include "irrArray.h" #include "irrMath.h" #include "irrString.h" @@ -227,7 +226,6 @@ inline EUTF_ENCODE determineUnicodeBOM(const char* data) //! UTF-16 string class. -template > class ustring16 { public: @@ -240,7 +238,7 @@ public: class _ustring16_iterator_access { public: - _ustring16_iterator_access(const ustring16* s, u32 p) : ref(s), pos(p) {} + _ustring16_iterator_access(const ustring16* s, u32 p) : ref(s), pos(p) {} //! Allow the class to be interpreted as a single UTF-32 character. operator uchar32_t() const @@ -395,7 +393,7 @@ public: //! Sets a uchar32_t at our current position. void _set(uchar32_t c) { - ustring16* ref2 = const_cast*>(ref); + ustring16* ref2 = const_cast(ref); const uchar16_t* a = ref2->c_str(); if (c > 0xFFFF) { @@ -424,10 +422,10 @@ public: } } - const ustring16* ref; + const ustring16* ref; u32 pos; }; - typedef typename ustring16::_ustring16_iterator_access access; + typedef typename ustring16::_ustring16_iterator_access access; //! Iterator to iterate through a UTF-16 string. @@ -453,8 +451,8 @@ public: //! Constructors. _ustring16_const_iterator(const _Iter& i) : ref(i.ref), pos(i.pos) {} - _ustring16_const_iterator(const ustring16& s) : ref(&s), pos(0) {} - _ustring16_const_iterator(const ustring16& s, const u32 p) : ref(&s), pos(0) + _ustring16_const_iterator(const ustring16& s) : ref(&s), pos(0) {} + _ustring16_const_iterator(const ustring16& s, const u32 p) : ref(&s), pos(0) { if (ref->size_raw() == 0 || p == 0) return; @@ -705,7 +703,7 @@ public: } protected: - const ustring16* ref; + const ustring16* ref; u32 pos; }; @@ -730,8 +728,8 @@ public: //! Constructors. _ustring16_iterator(const _Iter& i) : _ustring16_const_iterator(i) {} - _ustring16_iterator(const ustring16& s) : _ustring16_const_iterator(s) {} - _ustring16_iterator(const ustring16& s, const u32 p) : _ustring16_const_iterator(s, p) {} + _ustring16_iterator(const ustring16& s) : _ustring16_const_iterator(s) {} + _ustring16_iterator(const ustring16& s, const u32 p) : _ustring16_const_iterator(s, p) {} //! Accesses the full character at the iterator's position. reference operator*() const @@ -778,8 +776,8 @@ public: } }; - typedef typename ustring16::_ustring16_iterator iterator; - typedef typename ustring16::_ustring16_const_iterator const_iterator; + typedef typename ustring16::_ustring16_iterator iterator; + typedef typename ustring16::_ustring16_const_iterator const_iterator; ///----------------------/// /// end iterator classes /// @@ -794,13 +792,13 @@ public: #else encoding = unicode::EUTFE_UTF16_LE; #endif - array = allocator.allocate(1); // new u16[1]; + array = new uchar16_t[1]; array[0] = 0x0; } //! Constructor - ustring16(const ustring16& other) + ustring16(const ustring16& other) : array(0), allocated(0), used(0) { #if __BYTE_ORDER == __BIG_ENDIAN @@ -993,10 +991,9 @@ public: //! Constructor for moving a ustring16 - ustring16(ustring16&& other) + ustring16(ustring16&& other) : array(other.array), encoding(other.encoding), allocated(other.allocated), used(other.used) { - //std::cout << "MOVE constructor" << std::endl; other.array = 0; other.allocated = 0; other.used = 0; @@ -1005,12 +1002,12 @@ public: //! Destructor ~ustring16() { - allocator.deallocate(array); // delete [] array; + delete [] array; } //! Assignment operator - ustring16& operator=(const ustring16& other) + ustring16& operator=(const ustring16& other) { if (this == &other) return *this; @@ -1018,9 +1015,9 @@ public: used = other.size_raw(); if (used >= allocated) { - allocator.deallocate(array); // delete [] array; + delete [] array; allocated = used + 1; - array = allocator.allocate(used + 1); //new u16[used]; + array = new uchar16_t[used + 1]; } const uchar16_t* p = other.c_str(); @@ -1036,12 +1033,11 @@ public: } //! Move assignment operator - ustring16& operator=(ustring16&& other) + ustring16& operator=(ustring16&& other) { if (this != &other) { - //std::cout << "MOVE operator=" << std::endl; - allocator.deallocate(array); + delete [] array; array = other.array; allocated = other.allocated; @@ -1055,7 +1051,7 @@ public: //! Assignment operator for other string types template - ustring16& operator=(const string& other) + ustring16& operator=(const string& other) { *this = other.c_str(); return *this; @@ -1063,54 +1059,51 @@ public: //! Assignment operator for UTF-8 strings - ustring16& operator=(const uchar8_t* const c) + ustring16& operator=(const uchar8_t* const c) { if (!array) { - array = allocator.allocate(1); //new u16[1]; + array = new uchar16_t[1]; allocated = 1; } used = 0; array[used] = 0x0; if (!c) return *this; - //! Append our string now. append(c); return *this; } //! Assignment operator for UTF-16 strings - ustring16& operator=(const uchar16_t* const c) + ustring16& operator=(const uchar16_t* const c) { if (!array) { - array = allocator.allocate(1); //new u16[1]; + array = new uchar16_t[1]; allocated = 1; } used = 0; array[used] = 0x0; if (!c) return *this; - //! Append our string now. append(c); return *this; } //! Assignment operator for UTF-32 strings - ustring16& operator=(const uchar32_t* const c) + ustring16& operator=(const uchar32_t* const c) { if (!array) { - array = allocator.allocate(1); //new u16[1]; + array = new uchar16_t[1]; allocated = 1; } used = 0; array[used] = 0x0; if (!c) return *this; - //! Append our string now. append(c); return *this; } @@ -1120,7 +1113,7 @@ public: /** Note that this assumes that a correct unicode string is stored in the wchar_t string. Since wchar_t changes depending on its platform, it could either be a UTF-8, -16, or -32 string. This function assumes you are storing the correct unicode encoding inside the wchar_t string. **/ - ustring16& operator=(const wchar_t* const c) + ustring16& operator=(const wchar_t* const c) { if (sizeof(wchar_t) == 4) *this = reinterpret_cast(c); @@ -1136,7 +1129,7 @@ public: //! Assignment operator for other strings. /** Note that this assumes that a correct unicode string is stored in the string. **/ template - ustring16& operator=(const B* const c) + ustring16& operator=(const B* const c) { if (sizeof(B) == 4) *this = reinterpret_cast(c); @@ -1183,7 +1176,7 @@ public: //! Equality operator - bool operator ==(const ustring16& other) const + bool operator ==(const ustring16& other) const { for(u32 i=0; array[i] && other.array[i]; ++i) if (array[i] != other.array[i]) @@ -1194,7 +1187,7 @@ public: //! Is smaller comparator - bool operator <(const ustring16& other) const + bool operator <(const ustring16& other) const { for(u32 i=0; array[i] && other.array[i]; ++i) { @@ -1215,7 +1208,7 @@ public: //! Inequality operator - bool operator !=(const ustring16& other) const + bool operator !=(const ustring16& other) const { return !(*this == other); } @@ -1256,7 +1249,7 @@ public: //! \param other Other string to compare to. //! \param n Number of characters to compare. //! \return True if the n first characters of both strings are equal. - bool equalsn(const ustring16& other, u32 n) const + bool equalsn(const ustring16& other, u32 n) const { u32 i; const uchar16_t* oa = other.c_str(); @@ -1292,7 +1285,7 @@ public: //! Appends a character to this ustring16 //! \param character The character to append. //! \return A reference to our current string. - ustring16& append(uchar32_t character) + ustring16& append(uchar32_t character) { if (used + 2 >= allocated) reallocate(used + 2); @@ -1323,7 +1316,7 @@ public: //! \param other The UTF-8 string to append. //! \param length The length of the string to append. //! \return A reference to our current string. - ustring16& append(const uchar8_t* const other, u32 length=0xffffffff) + ustring16& append(const uchar8_t* const other, u32 length=0xffffffff) { if (!other) return *this; @@ -1499,7 +1492,7 @@ public: //! \param other The UTF-16 string to append. //! \param length The length of the string to append. //! \return A reference to our current string. - ustring16& append(const uchar16_t* const other, u32 length=0xffffffff) + ustring16& append(const uchar16_t* const other, u32 length=0xffffffff) { if (!other) return *this; @@ -1564,7 +1557,7 @@ public: //! \param other The UTF-32 string to append. //! \param length The length of the string to append. //! \return A reference to our current string. - ustring16& append(const uchar32_t* const other, u32 length=0xffffffff) + ustring16& append(const uchar32_t* const other, u32 length=0xffffffff) { if (!other) return *this; @@ -1640,7 +1633,7 @@ public: //! Appends a ustring16 to this ustring16 //! \param other The string to append to this one. //! \return A reference to our current string. - ustring16& append(const ustring16& other) + ustring16& append(const ustring16& other) { const uchar16_t* oa = other.c_str(); @@ -1663,7 +1656,7 @@ public: //! \param other The string to append to this one. //! \param length How many characters of the other string to add to this one. //! \return A reference to our current string. - ustring16& append(const ustring16& other, u32 length) + ustring16& append(const ustring16& other, u32 length) { if (other.size() == 0) return *this; @@ -1883,7 +1876,7 @@ public: //! \param str The string to find. //! \param start The start position of the search. //! \return Positions where the ustring16 has been found, or -1 if not found. - s32 find(const ustring16& str, const u32 start = 0) const + s32 find(const ustring16& str, const u32 start = 0) const { u32 my_size = size(); u32 their_size = str.size(); @@ -1921,7 +1914,7 @@ public: //! \param str The string to find. //! \param start The start position of the search. //! \return Positions where the string has been found, or -1 if not found. - s32 find_raw(const ustring16& str, const u32 start = 0) const + s32 find_raw(const ustring16& str, const u32 start = 0) const { const uchar16_t* data = str.c_str(); if (data && *data) @@ -1954,18 +1947,18 @@ public: //! \param begin: Start of substring. //! \param length: Length of substring. //! \return A reference to our current string. - ustring16 subString(u32 begin, s32 length) const + ustring16 subString(u32 begin, s32 length) const { u32 len = size(); // if start after ustring16 // or no proper substring length if ((length <= 0) || (begin>=len)) - return ustring16(""); + return ustring16(""); // clamp length to maximal value if ((length+begin) > len) length = len-begin; - ustring16 o; + ustring16 o; o.reserve((length+1) * 2); const_iterator i(*this, begin); @@ -1983,7 +1976,7 @@ public: //! Appends a character to this ustring16. //! \param c Character to append. //! \return A reference to our current string. - ustring16& operator += (char c) + ustring16& operator += (char c) { append((uchar32_t)c); return *this; @@ -1993,7 +1986,7 @@ public: //! Appends a character to this ustring16. //! \param c Character to append. //! \return A reference to our current string. - ustring16& operator += (uchar32_t c) + ustring16& operator += (uchar32_t c) { append(c); return *this; @@ -2003,7 +1996,7 @@ public: //! Appends a number to this ustring16. //! \param c Number to append. //! \return A reference to our current string. - ustring16& operator += (short c) + ustring16& operator += (short c) { append(core::stringc(c)); return *this; @@ -2013,7 +2006,7 @@ public: //! Appends a number to this ustring16. //! \param c Number to append. //! \return A reference to our current string. - ustring16& operator += (unsigned short c) + ustring16& operator += (unsigned short c) { append(core::stringc(c)); return *this; @@ -2023,7 +2016,7 @@ public: //! Appends a number to this ustring16. //! \param c Number to append. //! \return A reference to our current string. - ustring16& operator += (int c) + ustring16& operator += (int c) { append(core::stringc(c)); return *this; @@ -2033,7 +2026,7 @@ public: //! Appends a number to this ustring16. //! \param c Number to append. //! \return A reference to our current string. - ustring16& operator += (unsigned int c) + ustring16& operator += (unsigned int c) { append(core::stringc(c)); return *this; @@ -2043,7 +2036,7 @@ public: //! Appends a number to this ustring16. //! \param c Number to append. //! \return A reference to our current string. - ustring16& operator += (long c) + ustring16& operator += (long c) { append(core::stringc(c)); return *this; @@ -2053,7 +2046,7 @@ public: //! Appends a number to this ustring16. //! \param c Number to append. //! \return A reference to our current string. - ustring16& operator += (unsigned long c) + ustring16& operator += (unsigned long c) { append(core::stringc(c)); return *this; @@ -2063,7 +2056,7 @@ public: //! Appends a number to this ustring16. //! \param c Number to append. //! \return A reference to our current string. - ustring16& operator += (double c) + ustring16& operator += (double c) { append(core::stringc(c)); return *this; @@ -2073,7 +2066,7 @@ public: //! Appends a char ustring16 to this ustring16. //! \param c Char ustring16 to append. //! \return A reference to our current string. - ustring16& operator += (const uchar16_t* const c) + ustring16& operator += (const uchar16_t* const c) { append(c); return *this; @@ -2083,7 +2076,7 @@ public: //! Appends a ustring16 to this ustring16. //! \param other ustring16 to append. //! \return A reference to our current string. - ustring16& operator += (const ustring16& other) + ustring16& operator += (const ustring16& other) { append(other); return *this; @@ -2094,12 +2087,12 @@ public: //! \param toReplace Character to replace. //! \param replaceWith Character replacing the old one. //! \return A reference to our current string. - ustring16& replace(uchar32_t toReplace, uchar32_t replaceWith) + ustring16& replace(uchar32_t toReplace, uchar32_t replaceWith) { iterator i(*this, 0); while (!i.atEnd()) { - typename ustring16::access a = *i; + typename ustring16::access a = *i; if ((uchar32_t)a == toReplace) a = replaceWith; ++i; @@ -2112,7 +2105,7 @@ public: //! \param toReplace The string to replace. //! \param replaceWith The string replacing the old one. //! \return A reference to our current string. - ustring16& replace(const ustring16& toReplace, const ustring16& replaceWith) + ustring16& replace(const ustring16& toReplace, const ustring16& replaceWith) { if (toReplace.size() == 0) return *this; @@ -2223,7 +2216,7 @@ public: //! Removes characters from a ustring16.. //! \param c The character to remove. //! \return A reference to our current string. - ustring16& remove(uchar32_t c) + ustring16& remove(uchar32_t c) { u32 pos = 0; u32 found = 0; @@ -2259,7 +2252,7 @@ public: //! Removes a ustring16 from the ustring16. //! \param toRemove The string to remove. //! \return A reference to our current string. - ustring16& remove(const ustring16& toRemove) + ustring16& remove(const ustring16& toRemove) { u32 size = toRemove.size_raw(); if (size == 0) return *this; @@ -2294,7 +2287,7 @@ public: //! Removes characters from the ustring16. //! \param characters The characters to remove. //! \return A reference to our current string. - ustring16& removeChars(const ustring16& characters) + ustring16& removeChars(const ustring16& characters) { if (characters.size_raw() == 0) return *this; @@ -2344,7 +2337,7 @@ public: //! Removes the specified characters (by default, Latin-1 whitespace) from the begining and the end of the ustring16. //! \param whitespace The characters that are to be considered as whitespace. //! \return A reference to our current string. - ustring16& trim(const ustring16& whitespace = " \t\n\r") + ustring16& trim(const ustring16& whitespace = " \t\n\r") { core::array utf32white = whitespace.toUTF32(); @@ -2363,7 +2356,7 @@ public: //! May be slow, because all elements following after the erased element have to be copied. //! \param index Index of element to be erased. //! \return A reference to our current string. - ustring16& erase(u32 index) + ustring16& erase(u32 index) { _IRR_DEBUG_BREAK_IF(index>used) // access violation @@ -2384,7 +2377,7 @@ public: //! Validate the existing ustring16, checking for valid surrogate pairs and checking for proper termination. //! \return A reference to our current string. - ustring16& validate() + ustring16& validate() { // Validate all unicode characters. for (u32 i=0; i(&array[lastpospos], pos - lastpos)); + ret.push_back(ustring16(&array[lastpospos], pos - lastpos)); foundSeparator = true; lastpos = (keepSeparators ? pos : pos + 1); lastpospos = (keepSeparators ? i.getPos() : i.getPos() + 1); @@ -2498,7 +2491,7 @@ public: } u32 s = size() + 1; if (s > lastpos) - ret.push_back(ustring16(&array[lastpospos], s - lastpos)); + ret.push_back(ustring16(&array[lastpospos], s - lastpos)); return ret.size()-oldSize; } @@ -2521,7 +2514,7 @@ public: \return The number of resulting substrings */ template - u32 split(container& ret, const ustring16& c, bool ignoreEmptyTokens=true, bool keepSeparators=false) const + u32 split(container& ret, const ustring16& c, bool ignoreEmptyTokens=true, bool keepSeparators=false) const { core::array v = c.toUTF32(); return split(ret, v.pointer(), v.size(), ignoreEmptyTokens, keepSeparators); @@ -2548,7 +2541,7 @@ public: //! \param c The character to insert. //! \param pos The position to insert the character. //! \return A reference to our current string. - ustring16& insert(uchar32_t c, u32 pos) + ustring16& insert(uchar32_t c, u32 pos) { u8 len = (c > 0xFFFF ? 2 : 1); @@ -2583,7 +2576,7 @@ public: //! \param c The string to insert. //! \param pos The position to insert the string. //! \return A reference to our current string. - ustring16& insert(const ustring16& c, u32 pos) + ustring16& insert(const ustring16& c, u32 pos) { u32 len = c.size_raw(); if (len == 0) return *this; @@ -2613,7 +2606,7 @@ public: //! \param c The character to insert. //! \param pos The position to insert the character. //! \return A reference to our current string. - ustring16& insert_raw(uchar16_t c, u32 pos) + ustring16& insert_raw(uchar16_t c, u32 pos) { if (used + 1 >= allocated) reallocate(used + 1); @@ -2632,7 +2625,7 @@ public: //! Removes a character from string. //! \param pos Position of the character to remove. //! \return A reference to our current string. - ustring16& erase_raw(u32 pos) + ustring16& erase_raw(u32 pos) { for (u32 i=pos; i<=used; ++i) { @@ -2648,7 +2641,7 @@ public: //! \param c The new character. //! \param pos The position of the character to replace. //! \return A reference to our current string. - ustring16& replace_raw(uchar16_t c, u32 pos) + ustring16& replace_raw(uchar16_t c, u32 pos) { array[pos] = c; return *this; @@ -3023,7 +3016,7 @@ public: //! \param data The data stream to load from. //! \param data_size The length of the data string. //! \return A reference to our current string. - ustring16& loadDataStream(const char* data, size_t data_size) + ustring16& loadDataStream(const char* data, size_t data_size) { // Clear our string. *this = ""; @@ -3079,7 +3072,7 @@ private: { uchar16_t* old_array = array; - array = allocator.allocate(new_size + 1); //new u16[new_size]; + array = new uchar16_t[new_size + 1]; allocated = new_size + 1; if (old_array == 0) return; @@ -3092,7 +3085,7 @@ private: array[used] = 0; - allocator.deallocate(old_array); // delete [] old_array; + delete [] old_array; } //--- member variables @@ -3101,308 +3094,281 @@ private: unicode::EUTF_ENCODE encoding; u32 allocated; u32 used; - TAlloc allocator; - //irrAllocator allocator; }; -typedef ustring16 > ustring; +typedef ustring16 ustring; +/* these cause ambigous overloads errors and don't seem to be actually in use */ +#if 0 //! Appends two ustring16s. -template -inline ustring16 operator+(const ustring16& left, const ustring16& right) +inline ustring16 operator+(const ustring16& left, const ustring16& right) { - ustring16 ret(left); + ustring16 ret(left); ret += right; return ret; } //! Appends a ustring16 and a null-terminated unicode string. -template -inline ustring16 operator+(const ustring16& left, const B* const right) +template +inline ustring16 operator+(const ustring16& left, const B* const right) { - ustring16 ret(left); + ustring16 ret(left); ret += right; return ret; } //! Appends a ustring16 and a null-terminated unicode string. -template -inline ustring16 operator+(const B* const left, const ustring16& right) +template +inline ustring16 operator+(const B* const left, const ustring16& right) { - ustring16 ret(left); + ustring16 ret(left); ret += right; return ret; } //! Appends a ustring16 and an Irrlicht string. -template -inline ustring16 operator+(const ustring16& left, const string& right) +template +inline ustring16 operator+(const ustring16& left, const string& right) { - ustring16 ret(left); + ustring16 ret(left); ret += right; return ret; } //! Appends a ustring16 and an Irrlicht string. -template -inline ustring16 operator+(const string& left, const ustring16& right) +template +inline ustring16 operator+(const string& left, const ustring16& right) { - ustring16 ret(left); + ustring16 ret(left); ret += right; return ret; } //! Appends a ustring16 and a std::basic_string. -template -inline ustring16 operator+(const ustring16& left, const std::basic_string& right) +template +inline ustring16 operator+(const ustring16& left, const std::basic_string& right) { - ustring16 ret(left); + ustring16 ret(left); ret += right; return ret; } //! Appends a ustring16 and a std::basic_string. -template -inline ustring16 operator+(const std::basic_string& left, const ustring16& right) +template +inline ustring16 operator+(const std::basic_string& left, const ustring16& right) { - ustring16 ret(left); + ustring16 ret(left); ret += right; return ret; } //! Appends a ustring16 and a char. -template -inline ustring16 operator+(const ustring16& left, const char right) +inline ustring16 operator+(const ustring16& left, const char right) { - ustring16 ret(left); + ustring16 ret(left); ret += right; return ret; } //! Appends a ustring16 and a char. -template -inline ustring16 operator+(const char left, const ustring16& right) +inline ustring16 operator+(const char left, const ustring16& right) { - ustring16 ret(left); + ustring16 ret(left); ret += right; return ret; } //! Appends a ustring16 and a uchar32_t. -template -inline ustring16 operator+(const ustring16& left, const uchar32_t right) +inline ustring16 operator+(const ustring16& left, const uchar32_t right) { - ustring16 ret(left); + ustring16 ret(left); ret += right; return ret; } //! Appends a ustring16 and a uchar32_t. -template -inline ustring16 operator+(const uchar32_t left, const ustring16& right) +inline ustring16 operator+(const uchar32_t left, const ustring16& right) { - ustring16 ret(left); + ustring16 ret(left); ret += right; return ret; } //! Appends a ustring16 and a short. -template -inline ustring16 operator+(const ustring16& left, const short right) +inline ustring16 operator+(const ustring16& left, const short right) { - ustring16 ret(left); + ustring16 ret(left); ret += core::stringc(right); return ret; } //! Appends a ustring16 and a short. -template -inline ustring16 operator+(const short left, const ustring16& right) +inline ustring16 operator+(const short left, const ustring16& right) { - ustring16 ret((core::stringc(left))); + ustring16 ret((core::stringc(left))); ret += right; return ret; } //! Appends a ustring16 and an unsigned short. -template -inline ustring16 operator+(const ustring16& left, const unsigned short right) +inline ustring16 operator+(const ustring16& left, const unsigned short right) { - ustring16 ret(left); + ustring16 ret(left); ret += core::stringc(right); return ret; } //! Appends a ustring16 and an unsigned short. -template -inline ustring16 operator+(const unsigned short left, const ustring16& right) +inline ustring16 operator+(const unsigned short left, const ustring16& right) { - ustring16 ret((core::stringc(left))); + ustring16 ret((core::stringc(left))); ret += right; return ret; } //! Appends a ustring16 and an int. -template -inline ustring16 operator+(const ustring16& left, const int right) +inline ustring16 operator+(const ustring16& left, const int right) { - ustring16 ret(left); + ustring16 ret(left); ret += core::stringc(right); return ret; } //! Appends a ustring16 and an int. -template -inline ustring16 operator+(const int left, const ustring16& right) +inline ustring16 operator+(const int left, const ustring16& right) { - ustring16 ret((core::stringc(left))); + ustring16 ret((core::stringc(left))); ret += right; return ret; } //! Appends a ustring16 and an unsigned int. -template -inline ustring16 operator+(const ustring16& left, const unsigned int right) +inline ustring16 operator+(const ustring16& left, const unsigned int right) { - ustring16 ret(left); + ustring16 ret(left); ret += core::stringc(right); return ret; } //! Appends a ustring16 and an unsigned int. -template -inline ustring16 operator+(const unsigned int left, const ustring16& right) +inline ustring16 operator+(const unsigned int left, const ustring16& right) { - ustring16 ret((core::stringc(left))); + ustring16 ret((core::stringc(left))); ret += right; return ret; } //! Appends a ustring16 and a long. -template -inline ustring16 operator+(const ustring16& left, const long right) +inline ustring16 operator+(const ustring16& left, const long right) { - ustring16 ret(left); + ustring16 ret(left); ret += core::stringc(right); return ret; } //! Appends a ustring16 and a long. -template -inline ustring16 operator+(const long left, const ustring16& right) +inline ustring16 operator+(const long left, const ustring16& right) { - ustring16 ret((core::stringc(left))); + ustring16 ret((core::stringc(left))); ret += right; return ret; } //! Appends a ustring16 and an unsigned long. -template -inline ustring16 operator+(const ustring16& left, const unsigned long right) +inline ustring16 operator+(const ustring16& left, const unsigned long right) { - ustring16 ret(left); + ustring16 ret(left); ret += core::stringc(right); return ret; } //! Appends a ustring16 and an unsigned long. -template -inline ustring16 operator+(const unsigned long left, const ustring16& right) +inline ustring16 operator+(const unsigned long left, const ustring16& right) { - ustring16 ret((core::stringc(left))); + ustring16 ret((core::stringc(left))); ret += right; return ret; } //! Appends a ustring16 and a float. -template -inline ustring16 operator+(const ustring16& left, const float right) +inline ustring16 operator+(const ustring16& left, const float right) { - ustring16 ret(left); + ustring16 ret(left); ret += core::stringc(right); return ret; } //! Appends a ustring16 and a float. -template -inline ustring16 operator+(const float left, const ustring16& right) +inline ustring16 operator+(const float left, const ustring16& right) { - ustring16 ret((core::stringc(left))); + ustring16 ret((core::stringc(left))); ret += right; return ret; } //! Appends a ustring16 and a double. -template -inline ustring16 operator+(const ustring16& left, const double right) +inline ustring16 operator+(const ustring16& left, const double right) { - ustring16 ret(left); + ustring16 ret(left); ret += core::stringc(right); return ret; } //! Appends a ustring16 and a double. -template -inline ustring16 operator+(const double left, const ustring16& right) +inline ustring16 operator+(const double left, const ustring16& right) { - ustring16 ret((core::stringc(left))); + ustring16 ret((core::stringc(left))); ret += right; return ret; } //! Appends two ustring16s. -template -inline ustring16&& operator+(const ustring16& left, ustring16&& right) +inline ustring16&& operator+(const ustring16& left, ustring16&& right) { - //std::cout << "MOVE operator+(&, &&)" << std::endl; right.insert(left, 0); return std::move(right); } //! Appends two ustring16s. -template -inline ustring16&& operator+(ustring16&& left, const ustring16& right) +inline ustring16&& operator+(ustring16&& left, const ustring16& right) { - //std::cout << "MOVE operator+(&&, &)" << std::endl; left.append(right); return std::move(left); } //! Appends two ustring16s. -template -inline ustring16&& operator+(ustring16&& left, ustring16&& right) +inline ustring16&& operator+(ustring16&& left, ustring16&& right) { - //std::cout << "MOVE operator+(&&, &&)" << std::endl; if ((right.size_raw() <= left.capacity() - left.size_raw()) || (right.capacity() - right.size_raw() < left.size_raw())) { @@ -3418,68 +3384,61 @@ inline ustring16&& operator+(ustring16&& left, ustring16 //! Appends a ustring16 and a null-terminated unicode string. -template -inline ustring16&& operator+(ustring16&& left, const B* const right) +template +inline ustring16&& operator+(ustring16&& left, const B* const right) { - //std::cout << "MOVE operator+(&&, B*)" << std::endl; left.append(right); return std::move(left); } //! Appends a ustring16 and a null-terminated unicode string. -template -inline ustring16&& operator+(const B* const left, ustring16&& right) +template +inline ustring16&& operator+(const B* const left, ustring16&& right) { - //std::cout << "MOVE operator+(B*, &&)" << std::endl; right.insert(left, 0); return std::move(right); } //! Appends a ustring16 and an Irrlicht string. -template -inline ustring16&& operator+(const string& left, ustring16&& right) +template +inline ustring16&& operator+(const string& left, ustring16&& right) { - //std::cout << "MOVE operator+(&, &&)" << std::endl; right.insert(left, 0); return std::move(right); } //! Appends a ustring16 and an Irrlicht string. -template -inline ustring16&& operator+(ustring16&& left, const string& right) +template +inline ustring16&& operator+(ustring16&& left, const string& right) { - //std::cout << "MOVE operator+(&&, &)" << std::endl; left.append(right); return std::move(left); } //! Appends a ustring16 and a std::basic_string. -template -inline ustring16&& operator+(const std::basic_string& left, ustring16&& right) +template +inline ustring16&& operator+(const std::basic_string& left, ustring16&& right) { - //std::cout << "MOVE operator+(&, &&)" << std::endl; - right.insert(core::ustring16(left), 0); + right.insert(core::ustring16(left), 0); return std::move(right); } //! Appends a ustring16 and a std::basic_string. -template -inline ustring16&& operator+(ustring16&& left, const std::basic_string& right) +template +inline ustring16&& operator+(ustring16&& left, const std::basic_string& right) { - //std::cout << "MOVE operator+(&&, &)" << std::endl; left.append(right); return std::move(left); } //! Appends a ustring16 and a char. -template -inline ustring16 operator+(ustring16&& left, const char right) +inline ustring16 operator+(ustring16&& left, const char right) { left.append((uchar32_t)right); return std::move(left); @@ -3487,8 +3446,7 @@ inline ustring16 operator+(ustring16&& left, const char right) //! Appends a ustring16 and a char. -template -inline ustring16 operator+(const char left, ustring16&& right) +inline ustring16 operator+(const char left, ustring16&& right) { right.insert((uchar32_t)left, 0); return std::move(right); @@ -3496,8 +3454,7 @@ inline ustring16 operator+(const char left, ustring16&& right) //! Appends a ustring16 and a uchar32_t. -template -inline ustring16 operator+(ustring16&& left, const uchar32_t right) +inline ustring16 operator+(ustring16&& left, const uchar32_t right) { left.append(right); return std::move(left); @@ -3505,8 +3462,7 @@ inline ustring16 operator+(ustring16&& left, const uchar32_t rig //! Appends a ustring16 and a uchar32_t. -template -inline ustring16 operator+(const uchar32_t left, ustring16&& right) +inline ustring16 operator+(const uchar32_t left, ustring16&& right) { right.insert(left, 0); return std::move(right); @@ -3514,8 +3470,7 @@ inline ustring16 operator+(const uchar32_t left, ustring16&& rig //! Appends a ustring16 and a short. -template -inline ustring16 operator+(ustring16&& left, const short right) +inline ustring16 operator+(ustring16&& left, const short right) { left.append(core::stringc(right)); return std::move(left); @@ -3523,8 +3478,7 @@ inline ustring16 operator+(ustring16&& left, const short right) //! Appends a ustring16 and a short. -template -inline ustring16 operator+(const short left, ustring16&& right) +inline ustring16 operator+(const short left, ustring16&& right) { right.insert(core::stringc(left), 0); return std::move(right); @@ -3532,8 +3486,7 @@ inline ustring16 operator+(const short left, ustring16&& right) //! Appends a ustring16 and an unsigned short. -template -inline ustring16 operator+(ustring16&& left, const unsigned short right) +inline ustring16 operator+(ustring16&& left, const unsigned short right) { left.append(core::stringc(right)); return std::move(left); @@ -3541,8 +3494,7 @@ inline ustring16 operator+(ustring16&& left, const unsigned shor //! Appends a ustring16 and an unsigned short. -template -inline ustring16 operator+(const unsigned short left, ustring16&& right) +inline ustring16 operator+(const unsigned short left, ustring16&& right) { right.insert(core::stringc(left), 0); return std::move(right); @@ -3550,8 +3502,7 @@ inline ustring16 operator+(const unsigned short left, ustring16& //! Appends a ustring16 and an int. -template -inline ustring16 operator+(ustring16&& left, const int right) +inline ustring16 operator+(ustring16&& left, const int right) { left.append(core::stringc(right)); return std::move(left); @@ -3559,8 +3510,7 @@ inline ustring16 operator+(ustring16&& left, const int right) //! Appends a ustring16 and an int. -template -inline ustring16 operator+(const int left, ustring16&& right) +inline ustring16 operator+(const int left, ustring16&& right) { right.insert(core::stringc(left), 0); return std::move(right); @@ -3568,8 +3518,7 @@ inline ustring16 operator+(const int left, ustring16&& right) //! Appends a ustring16 and an unsigned int. -template -inline ustring16 operator+(ustring16&& left, const unsigned int right) +inline ustring16 operator+(ustring16&& left, const unsigned int right) { left.append(core::stringc(right)); return std::move(left); @@ -3577,8 +3526,7 @@ inline ustring16 operator+(ustring16&& left, const unsigned int //! Appends a ustring16 and an unsigned int. -template -inline ustring16 operator+(const unsigned int left, ustring16&& right) +inline ustring16 operator+(const unsigned int left, ustring16&& right) { right.insert(core::stringc(left), 0); return std::move(right); @@ -3586,8 +3534,7 @@ inline ustring16 operator+(const unsigned int left, ustring16&& //! Appends a ustring16 and a long. -template -inline ustring16 operator+(ustring16&& left, const long right) +inline ustring16 operator+(ustring16&& left, const long right) { left.append(core::stringc(right)); return std::move(left); @@ -3595,8 +3542,7 @@ inline ustring16 operator+(ustring16&& left, const long right) //! Appends a ustring16 and a long. -template -inline ustring16 operator+(const long left, ustring16&& right) +inline ustring16 operator+(const long left, ustring16&& right) { right.insert(core::stringc(left), 0); return std::move(right); @@ -3604,8 +3550,7 @@ inline ustring16 operator+(const long left, ustring16&& right) //! Appends a ustring16 and an unsigned long. -template -inline ustring16 operator+(ustring16&& left, const unsigned long right) +inline ustring16 operator+(ustring16&& left, const unsigned long right) { left.append(core::stringc(right)); return std::move(left); @@ -3613,8 +3558,7 @@ inline ustring16 operator+(ustring16&& left, const unsigned long //! Appends a ustring16 and an unsigned long. -template -inline ustring16 operator+(const unsigned long left, ustring16&& right) +inline ustring16 operator+(const unsigned long left, ustring16&& right) { right.insert(core::stringc(left), 0); return std::move(right); @@ -3622,8 +3566,7 @@ inline ustring16 operator+(const unsigned long left, ustring16&& //! Appends a ustring16 and a float. -template -inline ustring16 operator+(ustring16&& left, const float right) +inline ustring16 operator+(ustring16&& left, const float right) { left.append(core::stringc(right)); return std::move(left); @@ -3631,8 +3574,7 @@ inline ustring16 operator+(ustring16&& left, const float right) //! Appends a ustring16 and a float. -template -inline ustring16 operator+(const float left, ustring16&& right) +inline ustring16 operator+(const float left, ustring16&& right) { right.insert(core::stringc(left), 0); return std::move(right); @@ -3640,8 +3582,7 @@ inline ustring16 operator+(const float left, ustring16&& right) //! Appends a ustring16 and a double. -template -inline ustring16 operator+(ustring16&& left, const double right) +inline ustring16 operator+(ustring16&& left, const double right) { left.append(core::stringc(right)); return std::move(left); @@ -3649,25 +3590,23 @@ inline ustring16 operator+(ustring16&& left, const double right) //! Appends a ustring16 and a double. -template -inline ustring16 operator+(const double left, ustring16&& right) +inline ustring16 operator+(const double left, ustring16&& right) { right.insert(core::stringc(left), 0); return std::move(right); } +#endif //! Writes a ustring16 to an ostream. -template -inline std::ostream& operator<<(std::ostream& out, const ustring16& in) +inline std::ostream& operator<<(std::ostream& out, const ustring16& in) { out << in.toUTF8_s().c_str(); return out; } //! Writes a ustring16 to a wostream. -template -inline std::wostream& operator<<(std::wostream& out, const ustring16& in) +inline std::wostream& operator<<(std::wostream& out, const ustring16& in) { out << in.toWCHAR_s().c_str(); return out; diff --git a/source/Irrlicht/COpenGLCoreTexture.h b/source/Irrlicht/COpenGLCoreTexture.h index 19ab06b2..8897c585 100644 --- a/source/Irrlicht/COpenGLCoreTexture.h +++ b/source/Irrlicht/COpenGLCoreTexture.h @@ -82,7 +82,7 @@ public: { if ( OriginalSize == Size && OriginalColorFormat == ColorFormat ) { - Images[i]->setMipMapsData( images[i]->getMipMapsData(), false, true); + Images[i]->setMipMapsData( images[i]->getMipMapsData(), false); } else {