From 73411bbc47bf5f372b60e7460a80ead72aadeded Mon Sep 17 00:00:00 2001 From: Jief L Date: Thu, 23 Apr 2020 23:43:35 +0300 Subject: [PATCH] Cleaning in XString. Some method renaming. --- .gitignore | 2 +- Xcode/CloverX64/.gitignore | 1 + .../CloverX64.xcodeproj/project.pbxproj | 10 +- Xcode/CloverX64/clang-slink | 2 +- .../cpp_tests.xcodeproj/project.pbxproj | 2 - Xcode/cpp_tests/src/Platform.cpp | 6 +- Xcode/cpp_tests/src/Platform.h | 4 + Xcode/cpp_tests/src/main.cpp | 10 +- ebuild.sh | 6 +- rEFIt_UEFI/Platform/Settings.cpp | 2 +- rEFIt_UEFI/cpp_foundation/XArray.h | 18 +- rEFIt_UEFI/cpp_foundation/XObjArray.h | 8 +- rEFIt_UEFI/cpp_foundation/XString.h | 5 + rEFIt_UEFI/cpp_foundation/XStringAbstract.h | 182 +++--------------- rEFIt_UEFI/cpp_foundation/XStringArray.cpp | 10 +- rEFIt_UEFI/cpp_foundation/XStringWArray.cpp | 4 +- rEFIt_UEFI/cpp_foundation/XToolsCommon.h | 8 +- rEFIt_UEFI/cpp_unit_test/LoadOptions_test.cpp | 6 +- rEFIt_UEFI/cpp_unit_test/XString_test.cpp | 180 +++++++++++------ rEFIt_UEFI/cpp_unit_test/XString_test.h | 2 +- rEFIt_UEFI/cpp_unit_test/all_tests.cpp | 13 +- rEFIt_UEFI/cpp_unit_test/printf_lite-test.cpp | 17 +- rEFIt_UEFI/entry_scan/common.cpp | 10 +- rEFIt_UEFI/entry_scan/loader.cpp | 14 +- rEFIt_UEFI/gui/shared_with_menu.cpp | 2 +- rEFIt_UEFI/libeg/VectorGraphics.cpp | 12 +- rEFIt_UEFI/libeg/XTheme.cpp | 12 +- rEFIt_UEFI/refit/main.cpp | 16 +- 28 files changed, 260 insertions(+), 304 deletions(-) create mode 100644 Xcode/CloverX64/.gitignore mode change 100644 => 100755 rEFIt_UEFI/cpp_unit_test/XString_test.h mode change 100644 => 100755 rEFIt_UEFI/cpp_unit_test/all_tests.cpp mode change 100644 => 100755 rEFIt_UEFI/cpp_unit_test/printf_lite-test.cpp diff --git a/.gitignore b/.gitignore index 7e55718fc..324cffda0 100644 --- a/.gitignore +++ b/.gitignore @@ -127,4 +127,4 @@ tools #Eclipse build folder /DEBUG_*/ -/rEFIt_UEFI copy/ +/rEFIt_UEFI copy*/ diff --git a/Xcode/CloverX64/.gitignore b/Xcode/CloverX64/.gitignore new file mode 100644 index 000000000..4d66f06ad --- /dev/null +++ b/Xcode/CloverX64/.gitignore @@ -0,0 +1 @@ +/mtoc_path.txt diff --git a/Xcode/CloverX64/CloverX64.xcodeproj/project.pbxproj b/Xcode/CloverX64/CloverX64.xcodeproj/project.pbxproj index d2ce2155c..31e0f826f 100644 --- a/Xcode/CloverX64/CloverX64.xcodeproj/project.pbxproj +++ b/Xcode/CloverX64/CloverX64.xcodeproj/project.pbxproj @@ -92,6 +92,7 @@ 9A28CD34241BC0DF00F3D247 /* strncmp_test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A28CD2E241BC0DF00F3D247 /* strncmp_test.cpp */; }; 9A28CD35241BC0DF00F3D247 /* strlen_test.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A28CD2F241BC0DF00F3D247 /* strlen_test.h */; }; 9A28CD36241BC0DF00F3D247 /* strncmp_test.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A28CD30241BC0DF00F3D247 /* strncmp_test.h */; }; + 9A35A6182451FE1600CAFF76 /* XStringAbstract.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A35A6172451FE1500CAFF76 /* XStringAbstract.h */; }; 9A4185B62439F29D00BEAFB8 /* LoadOptions_test.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A4185B42439F29D00BEAFB8 /* LoadOptions_test.h */; }; 9A4185B72439F29D00BEAFB8 /* LoadOptions_test.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A4185B42439F29D00BEAFB8 /* LoadOptions_test.h */; }; 9A4185B82439F29D00BEAFB8 /* LoadOptions_test.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A4185B42439F29D00BEAFB8 /* LoadOptions_test.h */; }; @@ -889,6 +890,7 @@ 9A28CD2E241BC0DF00F3D247 /* strncmp_test.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = strncmp_test.cpp; sourceTree = ""; }; 9A28CD2F241BC0DF00F3D247 /* strlen_test.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = strlen_test.h; sourceTree = ""; }; 9A28CD30241BC0DF00F3D247 /* strncmp_test.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = strncmp_test.h; sourceTree = ""; }; + 9A35A6172451FE1500CAFF76 /* XStringAbstract.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XStringAbstract.h; sourceTree = ""; }; 9A4185B42439F29D00BEAFB8 /* LoadOptions_test.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LoadOptions_test.h; sourceTree = ""; }; 9A4185B52439F29D00BEAFB8 /* LoadOptions_test.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LoadOptions_test.cpp; sourceTree = ""; }; 9A9AEB90243F7B5600FBD7D8 /* unicode_conversions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = unicode_conversions.cpp; sourceTree = ""; }; @@ -1445,12 +1447,13 @@ children = ( 9A9AEB90243F7B5600FBD7D8 /* unicode_conversions.cpp */, 9A9AEB93243F7B5600FBD7D8 /* unicode_conversions.h */, - 9A9AEB91243F7B5600FBD7D8 /* XStringArray.cpp */, - 9A9AEB92243F7B5600FBD7D8 /* XStringArray.h */, 9AC77FB624176C04005CDD5C /* XArray.h */, 9AC77FB724176C04005CDD5C /* XObjArray.h */, 9A28CC91241AB33700F3D247 /* XString.cpp */, 9A28CC92241AB33700F3D247 /* XString.h */, + 9A35A6172451FE1500CAFF76 /* XStringAbstract.h */, + 9A9AEB91243F7B5600FBD7D8 /* XStringArray.cpp */, + 9A9AEB92243F7B5600FBD7D8 /* XStringArray.h */, 9AC77FAF24176C04005CDD5C /* XStringWArray.cpp */, 9AC77FAC24176C04005CDD5C /* XStringWArray.h */, 9AC77FB424176C04005CDD5C /* XToolsCommon.cpp */, @@ -1536,6 +1539,7 @@ 9A28CD36241BC0DF00F3D247 /* strncmp_test.h in Headers */, 9A105B7124483AE40006DE06 /* wchar.h in Headers */, 9AC7804A24176C04005CDD5C /* XPointer.h in Headers */, + 9A35A6182451FE1600CAFF76 /* XStringAbstract.h in Headers */, 9AC7808E24176C04005CDD5C /* XToolsCommon.h in Headers */, 9AC7806D24176C04005CDD5C /* bootscreen.h in Headers */, 9AC7800E24176C04005CDD5C /* Settings.h in Headers */, @@ -2582,6 +2586,7 @@ "-fno-unwind-tables", "-Wno-incompatible-ms-struct", "-Wreorder", + "-Wchar-subscripts", ); SUPPORTED_PLATFORMS = macosx; USE_HEADERMAP = NO; @@ -2634,6 +2639,7 @@ "-fno-unwind-tables", "-Wno-incompatible-ms-struct", "-Wreorder", + "-Wchar-subscripts", ); SUPPORTED_PLATFORMS = macosx; USE_HEADERMAP = NO; diff --git a/Xcode/CloverX64/clang-slink b/Xcode/CloverX64/clang-slink index edc26c029..5e007c204 100755 --- a/Xcode/CloverX64/clang-slink +++ b/Xcode/CloverX64/clang-slink @@ -66,7 +66,7 @@ ld -arch x86_64 -u __ModuleEntryPoint -e __ModuleEntryPoint -preload -segalign -source "$edk2prefix"/Conf/mtoc_path.txt +source ./mtoc_path.txt [[ $? == 0 ]] && "$MTOC" -subsystem UEFI_APPLICATION -align 0x20 ./"$outputname".dll ./"$outputname".pecoff [[ $? == 0 ]] && dsymutil ./"$outputname".dll diff --git a/Xcode/cpp_tests/cpp_tests.xcodeproj/project.pbxproj b/Xcode/cpp_tests/cpp_tests.xcodeproj/project.pbxproj index da6385a66..2c91626a6 100644 --- a/Xcode/cpp_tests/cpp_tests.xcodeproj/project.pbxproj +++ b/Xcode/cpp_tests/cpp_tests.xcodeproj/project.pbxproj @@ -147,7 +147,6 @@ 9A4185BE2439F73A00BEAFB8 /* XStringArray.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XStringArray.cpp; sourceTree = ""; }; 9A4185BF2439F73A00BEAFB8 /* XStringArray.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XStringArray.h; sourceTree = ""; }; 9A4FFA7C2451C8330050B38B /* XString.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XString.cpp; sourceTree = ""; }; - 9A4FFA7D2451C8330050B38B /* XStringAbstract copy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "XStringAbstract copy.h"; sourceTree = ""; }; 9A4FFA7F2451C88C0050B38B /* XString_test.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XString_test.h; sourceTree = ""; }; 9A4FFA802451C88D0050B38B /* XString_test.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XString_test.cpp; sourceTree = ""; }; 9A57C20A2418A1FD0029A39F /* global_test.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = global_test.h; sourceTree = ""; }; @@ -210,7 +209,6 @@ isa = PBXGroup; children = ( 9A4FFA7C2451C8330050B38B /* XString.cpp */, - 9A4FFA7D2451C8330050B38B /* XStringAbstract copy.h */, 9A57C266241A799B0029A39F /* XString.h */, 9A6BA73C2449977300BDA52C /* XStringAbstract.h */, 9A9AEB8C243F73CE00FBD7D8 /* unicode_conversions.cpp */, diff --git a/Xcode/cpp_tests/src/Platform.cpp b/Xcode/cpp_tests/src/Platform.cpp index 0534e4689..ab37ed411 100755 --- a/Xcode/cpp_tests/src/Platform.cpp +++ b/Xcode/cpp_tests/src/Platform.cpp @@ -99,7 +99,7 @@ void* AllocatePool(UINTN AllocationSize) void* AllocateZeroPool(UINTN AllocationSize) { void* p = (void*)malloc((size_t)AllocationSize); - memset(p, 0, AllocationSize); + memset(p, 0, (size_t)AllocationSize); return p; } @@ -117,12 +117,12 @@ void FreePool(const void* Buffer) void ZeroMem(void *Destination, UINTN Length) { - memset(Destination, 0, Length); + memset(Destination, 0, (size_t)Length); } void SetMem(void *Destination, UINTN Length, char c) { - memset(Destination, c, Length); + memset(Destination, c, (size_t)Length); } void CopyMem(void *Destination, void *Source, UINTN Length) diff --git a/Xcode/cpp_tests/src/Platform.h b/Xcode/cpp_tests/src/Platform.h index 24f7416c5..2293036f1 100755 --- a/Xcode/cpp_tests/src/Platform.h +++ b/Xcode/cpp_tests/src/Platform.h @@ -55,6 +55,10 @@ typedef UINTN RETURN_STATUS; #define OPTIONAL #define ASSERT(x) + +#ifdef _MSC_VER +#define __typeof__(x) decltype(x) +#endif void CpuDeadLoop(void); void DebugLog(INTN DebugMode, const char *FormatString, ...); diff --git a/Xcode/cpp_tests/src/main.cpp b/Xcode/cpp_tests/src/main.cpp index 1fe95bba6..b96fdd918 100755 --- a/Xcode/cpp_tests/src/main.cpp +++ b/Xcode/cpp_tests/src/main.cpp @@ -18,12 +18,12 @@ extern "C" int main(int argc, const char * argv[]) (void)argv; setlocale(LC_ALL, "en_US"); // to allow printf unicode char -printf("sizeof(wchar_t)=%lu\n", sizeof(wchar_t)); +printf("sizeof(wchar_t)=%zu\n", sizeof(wchar_t)); printf("%lc\n", L'Ľ'); -printf("sizeof(size_t)=%lu\n", sizeof(size_t)); -printf("sizeof(long)=%lu\n", sizeof(long)); -printf("sizeof(long long)=%lu\n", sizeof(long long)); -printf("sizeof(size_t)=%lu\n", sizeof(size_t)); +printf("sizeof(size_t)=%zu\n", sizeof(size_t)); +printf("sizeof(long)=%zu\n", sizeof(long)); +printf("sizeof(long long)=%zu\n", sizeof(long long)); +printf("sizeof(size_t)=%zu\n", sizeof(size_t)); #ifndef _MSC_VER //printf("%zu\n", (size_t)MAX_UINT64); //printf("%zd\n", (size_t)MAX_UINT64); diff --git a/ebuild.sh b/ebuild.sh index 6a4d3bae5..1fa37971f 100755 --- a/ebuild.sh +++ b/ebuild.sh @@ -414,7 +414,7 @@ checkCmdlineArguments() { checkToolchain() { case "$TOOLCHAIN" in XCLANG|XCODE*) checkXcode ;; - *) export MTOC_PREFIX="${TOOLCHAIN_DIR}/bin/" ;; + *) ;; esac if [[ "$SYSNAME" == Linux ]]; then @@ -500,7 +500,9 @@ MainBuildScript() { set +u source ./edksetup.sh BaseTools set -u - echo "MTOC=$MTOC_PREFIX/mtoc.NEW_jief" > "$WORKSPACE"/Conf/mtoc_path.txt + if [ ! -z "${MTOC_PREFIX:-}" ]; then + echo "MTOC=$MTOC_PREFIX/mtoc.NEW_jief" > "$WORKSPACE"/Xcode/CloverX64/mtoc_path.txt + fi cd "$CLOVERROOT" # else # echo "Building from: $WORKSPACE" diff --git a/rEFIt_UEFI/Platform/Settings.cpp b/rEFIt_UEFI/Platform/Settings.cpp index 0939c727a..787af1742 100644 --- a/rEFIt_UEFI/Platform/Settings.cpp +++ b/rEFIt_UEFI/Platform/Settings.cpp @@ -8044,7 +8044,7 @@ SetFSInjection ( } // check if blocking of caches is needed - if ( OSFLAG_ISSET(Entry->Flags, OSFLAG_NOCACHES) || Entry->LoadOptions.ExistIn("-f") ) { + if ( OSFLAG_ISSET(Entry->Flags, OSFLAG_NOCACHES) || Entry->LoadOptions.contains("-f") ) { MsgLog ("Blocking kext caches\n"); // BlockCaches = TRUE; // add caches to blacklist diff --git a/rEFIt_UEFI/cpp_foundation/XArray.h b/rEFIt_UEFI/cpp_foundation/XArray.h index fb87115b9..5038b2257 100755 --- a/rEFIt_UEFI/cpp_foundation/XArray.h +++ b/rEFIt_UEFI/cpp_foundation/XArray.h @@ -63,10 +63,14 @@ class XArray const TYPE& ElementAt(int nIndex) const; TYPE& ElementAt(int nIndex); - const TYPE& operator[](xsize nIndex) const { return ElementAt(nIndex); } - TYPE& operator[](xsize nIndex) { return ElementAt(nIndex); } - const TYPE& operator[]( int nIndex) const { return ElementAt(nIndex); } +// const TYPE& operator[](xsize nIndex) const { return ElementAt(nIndex); } +// TYPE& operator[](xsize nIndex) { return ElementAt(nIndex); } +// const TYPE& operator[]( int nIndex) const { return ElementAt(nIndex); } TYPE& operator[]( int nIndex) { return ElementAt(nIndex); } +// const TYPE& operator[]( unsigned long long nIndex) const { return ElementAt((size_t)nIndex); } +// const TYPE& operator[]( long long nIndex) const { return ElementAt((size_t)nIndex); } + TYPE& operator[]( unsigned long long nIndex) { return ElementAt((size_t)nIndex); } + TYPE& operator[]( long long nIndex) { return ElementAt((size_t)nIndex); } operator const void *() const { return m_data; }; operator void *() { return m_data; }; @@ -102,8 +106,8 @@ class XArray void setEmpty(); bool isEmpty() const { return size() == 0; } - xsize IdxOf(TYPE& e) const; - bool ExistIn(TYPE& e) const { return IdxOf(e) != MAX_XSIZE; } //logically it should be named as Contains(e) + xsize indexOf(TYPE& e) const; + bool contains(TYPE& e) const { return indexOf(e) != MAX_XSIZE; } //logically it should be named as Contains(e) }; //xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx @@ -113,7 +117,7 @@ class XArray //xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx template -xsize XArray::IdxOf(TYPE& e) const +xsize XArray::indexOf(TYPE& e) const { xsize i; @@ -181,7 +185,7 @@ void XArray::CheckSize(xsize nNewSize, xsize nGrowBy) nNewSize += nGrowBy; m_data = (TYPE *)realloc((void *)m_data, nNewSize * sizeof(TYPE), m_allocatedSize * sizeof(TYPE) ); if ( !m_data ) { - DebugLog(2, "XArray::CheckSize(nNewSize=%llu, nGrowBy=%llu) : Xrealloc(%llu, %llu, %" PRIuPTR ") returned NULL. System halted\n", nNewSize, nGrowBy, m_allocatedSize, nNewSize*sizeof(TYPE), (uintptr_t)m_data); + DebugLog(2, "XArray::CheckSize(nNewSize=%zu, nGrowBy=%zu) : Xrealloc(%zu, %lu, %" PRIuPTR ") returned NULL. System halted\n", nNewSize, nGrowBy, m_allocatedSize, nNewSize*sizeof(TYPE), (uintptr_t)m_data); panic(); } // memset(&_Data[_Size], 0, (nNewSize-_Size) * sizeof(TYPE)); // Could help for debugging, but zeroing in not needed. diff --git a/rEFIt_UEFI/cpp_foundation/XObjArray.h b/rEFIt_UEFI/cpp_foundation/XObjArray.h index e279312a7..a471d962d 100755 --- a/rEFIt_UEFI/cpp_foundation/XObjArray.h +++ b/rEFIt_UEFI/cpp_foundation/XObjArray.h @@ -183,7 +183,7 @@ void XObjArrayNC::CheckSize(xsize nNewSize, xsize nGrowBy) nNewSize += nGrowBy + 1; _Data = (XObjArrayEntry *)realloc((void *)_Data, sizeof(XObjArrayEntry) * nNewSize, sizeof(XObjArrayEntry) * m_allocatedSize); if ( !_Data ) { - DebugLog(2, "XObjArrayNC::CheckSize(nNewSize=%llu, nGrowBy=%llu) : Xrealloc(%llu, %llu, %" PRIuPTR ") returned NULL. System halted\n", nNewSize, nGrowBy, m_allocatedSize, sizeof(XObjArrayEntry) * nNewSize, (uintptr_t)_Data); + DebugLog(2, "XObjArrayNC::CheckSize(nNewSize=%zu, nGrowBy=%zu) : Xrealloc(%zu, %zu, %" PRIuPTR ") returned NULL. System halted\n", nNewSize, nGrowBy, m_allocatedSize, sizeof(XObjArrayEntry) * nNewSize, (uintptr_t)_Data); panic(); } // memset(&_Data[m_allocatedSize], 0, (nNewSize-m_allocatedSize) * sizeof(XObjArrayEntry)); @@ -196,7 +196,7 @@ template TYPE &XObjArrayNC::ElementAt(xsize index) { if ( index >= _Len ) { - DebugLog(2, "XObjArray::ElementAt(xsize) -> operator [] - index (%llu) greater than length (%llu)\n", index, _Len); + DebugLog(2, "XObjArray::ElementAt(xsize) -> operator [] - index (%zu) greater than length (%zu)\n", index, _Len); panic(); } return *((TYPE *)(_Data[index].Object)); @@ -207,7 +207,7 @@ template const TYPE &XObjArrayNC::ElementAt(xsize index) const { if ( index >= _Len ) { - DebugLog(2, "XObjArray::ElementAt(xsize) const -> operator [] - index (%llu) greater than length (%llu)\n", index, _Len); + DebugLog(2, "XObjArray::ElementAt(xsize) const -> operator [] - index (%zu) greater than length (%zu)\n", index, _Len); panic(); } return *((TYPE *)(_Data[index].Object)); @@ -427,7 +427,7 @@ void XObjArrayNC::RemoveAtIndex(xsize nIndex) if ( nIndex < XObjArrayNC::_Len ) { if ( nIndex >= XObjArrayNC::_Len ) { - DebugLog(2, "void XObjArrayNC::RemoveAtIndex(xsize nIndex) : BUG nIndex (%llu) is > length(). System halted\n", nIndex); + DebugLog(2, "void XObjArrayNC::RemoveAtIndex(xsize nIndex) : BUG nIndex (%zu) is > length(). System halted\n", nIndex); panic(); } } diff --git a/rEFIt_UEFI/cpp_foundation/XString.h b/rEFIt_UEFI/cpp_foundation/XString.h index 68e7e3c14..a93bdcc1f 100755 --- a/rEFIt_UEFI/cpp_foundation/XString.h +++ b/rEFIt_UEFI/cpp_foundation/XString.h @@ -140,4 +140,9 @@ extern const XStringW NullXStringW; XString SPrintf(const char* format, ...) __attribute__((__format__ (__printf__, 1, 2))); XStringW SWPrintf(const char* format, ...) __attribute__((__format__ (__printf__, 1, 2))); + +// +//XStringAbstract SubString(const T *S, size_t pos, size_t count); +//XStringAbstract CleanCtrl(const XStringAbstract &S); + #endif diff --git a/rEFIt_UEFI/cpp_foundation/XStringAbstract.h b/rEFIt_UEFI/cpp_foundation/XStringAbstract.h index 764b3ccd6..98e644f7a 100755 --- a/rEFIt_UEFI/cpp_foundation/XStringAbstract.h +++ b/rEFIt_UEFI/cpp_foundation/XStringAbstract.h @@ -49,17 +49,18 @@ struct XStringAbstract__true_type { template struct XStringAbstract__make_unsigned {}; -//template <> struct __make_unsigned {}; -template <> struct XStringAbstract__make_unsigned< signed char> {typedef unsigned short type;}; -template <> struct XStringAbstract__make_unsigned {typedef unsigned short type;}; -template <> struct XStringAbstract__make_unsigned< signed short> {typedef unsigned short type;}; -template <> struct XStringAbstract__make_unsigned {typedef unsigned short type;}; -template <> struct XStringAbstract__make_unsigned< signed int> {typedef unsigned int type;}; -template <> struct XStringAbstract__make_unsigned {typedef unsigned int type;}; -template <> struct XStringAbstract__make_unsigned< signed long> {typedef unsigned long type;}; -template <> struct XStringAbstract__make_unsigned {typedef unsigned long type;}; +template <> struct XStringAbstract__make_unsigned< char> {typedef unsigned char type;}; +template <> struct XStringAbstract__make_unsigned< signed char> {typedef unsigned char type;}; +template <> struct XStringAbstract__make_unsigned {typedef unsigned char type;}; +template <> struct XStringAbstract__make_unsigned< signed short> {typedef unsigned short type;}; +template <> struct XStringAbstract__make_unsigned {typedef unsigned short type;}; +template <> struct XStringAbstract__make_unsigned< signed int> {typedef unsigned int type;}; +template <> struct XStringAbstract__make_unsigned {typedef unsigned int type;}; +template <> struct XStringAbstract__make_unsigned< signed long> {typedef unsigned long type;}; +template <> struct XStringAbstract__make_unsigned {typedef unsigned long type;}; template <> struct XStringAbstract__make_unsigned< signed long long> {typedef unsigned long long type;}; template <> struct XStringAbstract__make_unsigned {typedef unsigned long long type;}; +#define unsigned_type(x) typename XStringAbstract__make_unsigned::type /* enable_if */ template @@ -210,22 +211,7 @@ size_t XStringAbstract__rindexOf(const O* s, size_t Pos, const P* other, bool to return MAX_XSIZE; } -//template -//size_t XStringAbstract__rindexOf(const O* s, size_t Pos, const P* other, bool toLower) -//{ -// size_t index = XStringAbstract__indexOf(s, 0, other, toLower); -// size_t prev_index = index; // initialize to index in case of index is already == Pos -// while ( index < Pos ) { -// prev_index = index; -// index = XStringAbstract__indexOf(s, index+1, other, toLower); -// }; -// if ( index == Pos ) return index; -// if ( prev_index <= Pos ) return prev_index; -// return MAX_XSIZE; -//} - -//template template class XStringAbstract { @@ -233,13 +219,6 @@ public: // const SubType NullXString; static T nullChar; -//class XString16; -// XStringAbstract(const XStringAbstract &S) -// { -// Init(0); -// takeValueFrom(S); -// } - protected: T *m_data; size_t m_allocatedSize; @@ -255,7 +234,7 @@ protected: T* _data(IntegralType pos) const { if ( pos<0 ) panic("T* data(int i) -> i < 0"); - size_t offset = size_of_utf_string_len(m_data, (typename XStringAbstract__make_unsigned::type)pos); // If pos is too big, size_of_utf_string_len returns the end of the string + size_t offset = size_of_utf_string_len(m_data, (unsigned_type(IntegralType))pos); // If pos is too big, size_of_utf_string_len returns the end of the string return m_data + offset; } @@ -327,8 +306,9 @@ public: template T* dataSized(IntegralType size) { - if ( size<0 ) panic("T* dataSized(xisize i, size_t sizeMin, size_t nGrowBy) -> i < 0"); - CheckSize((typename XStringAbstract__make_unsigned::type)size); + if ( size<0 ) panic("T* dataSized() -> i < 0"); + if ( (unsigned_type(IntegralType))size > MAX_XSIZE ) panic("T* dataSized() -> i > MAX_XSIZE"); + CheckSize((size_t)size); return _data(0); } // @@ -343,17 +323,6 @@ public: // return _data(pos); // } -// const T* data(unsigned int ui) const { return _data(ui); } -// const T* data(int i) const { return _data(i); } -// const T* data(size_t ui) const { return _data(ui); } -// const T* data(xisize i) const { return _data(i); } -// -// T* dataSized(unsigned int ui, size_t sizeMin, size_t nGrowBy=16) { CheckSize(ui+sizeMin, nGrowBy); return _data(ui); } -// T* dataSized(unsigned long ui, size_t sizeMin, size_t nGrowBy=16) { CheckSize(ui+sizeMin, nGrowBy); return _data(ui); } -// T* dataSized(unsigned long long ui, size_t sizeMin, size_t nGrowBy=16) { CheckSize(ui+sizeMin, nGrowBy); return _data(ui); } -// T* dataSized(int i, size_t sizeMin, size_t nGrowBy=16) { if ( i<0 ) panic("T* dataSized(xisize i, size_t sizeMin, size_t nGrowBy) -> i < 0"); CheckSize((unsigned int)i+sizeMin, nGrowBy); return _data(i); } -// T* dataSized(long i, size_t sizeMin, size_t nGrowBy=16) { if ( i<0 ) panic("T* dataSized(xisize i, size_t sizeMin, size_t nGrowBy) -> i < 0"); CheckSize((unsigned long)i+sizeMin, nGrowBy); return _data(i); } -// T* dataSized(long long i, size_t sizeMin, size_t nGrowBy=16) { if ( i<0 ) panic("T* dataSized(xisize i, size_t sizeMin, size_t nGrowBy) -> i < 0"); CheckSize((unsigned long long)i+sizeMin, nGrowBy); return _data(i); } T* forgetDataWithoutFreeing() { @@ -403,7 +372,7 @@ public: panic("XStringAbstract::char32At(size_t i) : i >= length(). System halted\n"); } nb += 1; - } while (nb <= (typename XStringAbstract__make_unsigned::type)i ); + } while (nb <= (unsigned_type(IntegralType))i); return char32; } @@ -496,16 +465,16 @@ public: /* ctor */ template explicit XStringAbstract(const XStringAbstract& S) { Init(0); takeValueFrom(S); } - template - explicit XStringAbstract(const O* S) { Init(0); takeValueFrom(S); } +// template +// explicit XStringAbstract(const O* S) { Init(0); takeValueFrom(S); } /* Copy Assign */ // Only other XString, no litteral at the moment. XStringAbstract& operator =(const XStringAbstract& S) { strcpy(S.s()); return *this; } /* Assign */ template ThisXStringClass& operator =(const XStringAbstract& S) { strcpy(S.s()); return *((ThisXStringClass*)this); } - template - ThisXStringClass& operator =(const O* S) { strcpy(S); return *this; } +// template +// ThisXStringClass& operator =(const O* S) { strcpy(S); return *this; } /* += */ template @@ -513,13 +482,6 @@ public: template ThisXStringClass& operator += (const O* S) { strcat(S); return *((ThisXStringClass*)this); } - // + operator -// template -// friend ThisXStringClass operator + (const XStringClass& p1, const XStringAbstract& p2) { XStringAbstract s; s=p1; s+=p2; return s; } -// template -// friend ThisXStringClass operator + (const XStringAbstract& p1, const O* p2 ) { XStringAbstract s; s=p1; s+=p2; return s; } -// template -// friend ThisXStringClass operator + (const O *p1, const XStringAbstract& p2) { XStringAbstract s; s.strcat(p1); s.strcat(p2.s()); return s; } template ThisXStringClass operator + (const XStringAbstract& p2) const { XStringAbstract s; s=*this; s+=p2; return s; } @@ -541,10 +503,6 @@ public: size_t indexOf(const O* S, size_t Pos = 0) const { return XStringAbstract__indexOf(m_data, Pos, S, false); } template size_t indexOf(const XStringAbstract& S, size_t Pos = 0) const { return indexOf(S.s(), Pos); } - // old name : todo remove - size_t IdxOf(char c, size_t Pos = 0) const { return indexOf((char32_t)c, Pos); } - template - size_t IdxOf(const XStringAbstract& S, size_t Pos = 0) const { return indexOf(S, Pos); } /* IC */ size_t indexOfIC(char32_t char32Searched, size_t Pos = 0) const { @@ -614,7 +572,7 @@ public: // } //} - XStringAbstract SubString(size_t pos, size_t count) const + XStringAbstract subString(size_t pos, size_t count) const { if ( count > length()-pos ) count = length()-pos; XStringAbstract ret; @@ -631,13 +589,13 @@ public: // todo rename to contains template - bool ExistIn(const XStringAbstract& S) const { return indexOf(S) != MAX_XSIZE; } + bool contains(const XStringAbstract& S) const { return indexOf(S) != MAX_XSIZE; } template - bool ExistIn(const O* S) const { return indexOf(S) != MAX_XSIZE; } + bool contains(const O* S) const { return indexOf(S) != MAX_XSIZE; } template - size_t ExistInIC(const XStringAbstract& S) const { return indexOfIC(S) != MAX_XSIZE; } + size_t containsIC(const XStringAbstract& S) const { return indexOfIC(S) != MAX_XSIZE; } template - size_t ExistInIC(const O* S) const { return indexOfIC(S) != MAX_XSIZE; } + size_t containsIC(const O* S) const { return indexOfIC(S) != MAX_XSIZE; } // void ToLower(bool FirstCharIsCap = false); @@ -723,12 +681,10 @@ public: // int Compare(const wchar_t* S) const { return ::Compare(m_data, S); }; // template - bool Equal(const O* S) const { return XStringAbstract__compare(m_data, S, false); } - template - bool EqualIC(const XStringAbstract& S) const { return XStringAbstract__compare(m_data, S.s(), true); } + bool equalIC(const XStringAbstract& S) const { return XStringAbstract__compare(m_data, S.s(), true) == 0; } template - bool EqualIC(const O* S) const { return XStringAbstract__compare(m_data, S, true); } -// bool BeginingEqual(const T* S) const { return (memcmp(data(), S, wcslen(S)) == 0); } + bool equalIC(const O* S) const { return XStringAbstract__compare(m_data, S, true) == 0; } +// bool startWith(const T* S) const { return (memcmp(data(), S, wcslen(S)) == 0); } // bool SubStringEqual(size_t Pos, const T* S) const { return (memcmp(data(Pos), S, wcslen(S)) == 0); } public: @@ -784,18 +740,6 @@ T XStringAbstract::nullChar = 0; //xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx -// Constructor -//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx - - -// -//template -//XStringAbstract::XStringAbstract(const XStringAbstract &aString) -//{ -//DBG_XSTRING("Constructor(const XStringAbstract &aString) : %ls\n", aString.data()); -// Init(aString.size()); -// memcpy(m_data, aString.m_data, aString.sizeInBytes()); -//} // @@ -838,57 +782,6 @@ T XStringAbstract::nullChar = 0; -//----------------------------------------------------------------------------- -// Functions -//----------------------------------------------------------------------------- - -//XStringAbstract operator"" _XSW ( const T* s, size_t len) -//{ -// XStringAbstract returnValue; -// if ( len > MAX_XSIZE ) len = MAX_XSIZE; -// returnValue.takeValueFrom(s, len); -// return returnValue; // don't do "return returnValue.takeValueFrom(s, len)" because it break the return value optimization. -//} -// -//XStringAbstract SWPrintf(const char* format, ...) -//{ -// va_list va; -// XStringAbstract str; -// -// va_start (va, format); -// str.vSWPrintf(format, va); -// va_end(va); -// -// return str; -//} -// -//XStringAbstract SubString(const T *S, size_t pos, size_t count) -//{ -// if ( wcslen(S)-pos < count ) count = wcslen(S)-pos; -// XStringAbstract ret; -// ret.StrnCpy(S+pos, count); -//// return ( XStringAbstract(S+pos, count) ); -// return ret; -//} -// -// -//XStringAbstract CleanCtrl(const XStringAbstract &S) -//{ -// XStringAbstract ReturnValue; -// size_t i; -// -// for ( i=0 ; i=0 && S.wc_str()[i] < ' ' ) ReturnValue += 'x'; /* T are signed */ -//#else -// if ( S.wc_str()[i] < ' ' ) ReturnValue += 'x'; /* T are unsigned */ -//#endif -// else ReturnValue += S.wc_str()[i]; -// } -// return ReturnValue; -//} - - @@ -897,24 +790,11 @@ T XStringAbstract::nullChar = 0; #undef DBG_XSTRING -#undef is_integral -//#undef enable_if #undef asciiToLower - - - - - - - -// -//extern const XStringAbstract NullXStringAbstract; -// -//XStringAbstract operator"" _XSW ( const T* s, size_t len); -// -//XStringAbstract SWPrintf(const char* format, ...) __attribute__((__format__(__printf__, 1, 2))); -//XStringAbstract SubString(const T *S, size_t pos, size_t count); -//XStringAbstract CleanCtrl(const XStringAbstract &S); +#undef unsigned_type +#undef is_integral +#undef is_char +#undef enable_if diff --git a/rEFIt_UEFI/cpp_foundation/XStringArray.cpp b/rEFIt_UEFI/cpp_foundation/XStringArray.cpp index 600db69a4..ada2a7d01 100755 --- a/rEFIt_UEFI/cpp_foundation/XStringArray.cpp +++ b/rEFIt_UEFI/cpp_foundation/XStringArray.cpp @@ -124,16 +124,16 @@ void XStringArray::AddID(const XStringArray &aStrings) XStringArray Split(const XString &S, const XString &Separator) { XStringArray Ss; - xsize idxB, idxE; + size_t idxB, idxE; idxB = 0; - idxE = S.IdxOf(Separator, idxB); + idxE = S.indexOf(Separator, idxB); while ( idxE != MAX_XSIZE ) { - Ss.AddCopy(S.SubString(idxB, idxE-idxB)); + Ss.AddCopy(S.subString(idxB, idxE-idxB)); idxB = idxE + Separator.length(); - idxE = S.IdxOf(Separator, idxB); + idxE = S.indexOf(Separator, idxB); } - if ( idxB < S.length() ) Ss.AddCopy(S.SubString(idxB, S.length()-idxB)); + if ( idxB < S.length() ) Ss.AddCopy(S.subString(idxB, S.length()-idxB)); return Ss; } diff --git a/rEFIt_UEFI/cpp_foundation/XStringWArray.cpp b/rEFIt_UEFI/cpp_foundation/XStringWArray.cpp index e70eab5da..60d359e87 100755 --- a/rEFIt_UEFI/cpp_foundation/XStringWArray.cpp +++ b/rEFIt_UEFI/cpp_foundation/XStringWArray.cpp @@ -132,11 +132,11 @@ XStringWArray Split(const XStringW &S, const XStringW &Separator) idxB = 0; idxE = S.indexOf(Separator, idxB); while ( idxE != MAX_XSIZE ) { - Ss.AddCopy(S.SubString(idxB, idxE-idxB)); + Ss.AddCopy(S.subString(idxB, idxE-idxB)); idxB = idxE + Separator.length(); idxE = S.indexOf(Separator, idxB); } - if ( idxB < S.length() ) Ss.AddCopy(S.SubString(idxB, S.length()-idxB)); + if ( idxB < S.length() ) Ss.AddCopy(S.subString(idxB, S.length()-idxB)); return Ss; } diff --git a/rEFIt_UEFI/cpp_foundation/XToolsCommon.h b/rEFIt_UEFI/cpp_foundation/XToolsCommon.h index e8978f08c..7e329e39e 100755 --- a/rEFIt_UEFI/cpp_foundation/XToolsCommon.h +++ b/rEFIt_UEFI/cpp_foundation/XToolsCommon.h @@ -4,10 +4,10 @@ #include -#define xsize UINTN -#define xisize INTN -#define MAX_XSIZE MAX_UINTN -#define MAX_XISIZE MAX_INTN +#define xsize size_t +//#define xisize INTN +#define MAX_XSIZE SIZE_T_MAX +//#define MAX_XISIZE MAX_INTN extern xsize XArrayGrowByDefault; extern xsize XBufferGrowByDefault; diff --git a/rEFIt_UEFI/cpp_unit_test/LoadOptions_test.cpp b/rEFIt_UEFI/cpp_unit_test/LoadOptions_test.cpp index e2bee8f6b..5a327d695 100755 --- a/rEFIt_UEFI/cpp_unit_test/LoadOptions_test.cpp +++ b/rEFIt_UEFI/cpp_unit_test/LoadOptions_test.cpp @@ -15,7 +15,7 @@ CHAR16 *Old1_AddLoadOption(IN CONST CHAR16 *LoadOptions, IN CONST CHAR16 *LoadOp return EfiStrDuplicate(LoadOption); } // If there is no option or it is already present duplicate original - // with XStringW it will be replaced by if (LoadOptions.ExistIn(LoadOption)) + // with XStringW it will be replaced by if (LoadOptions.contains(LoadOption)) else if ((LoadOption == NULL) || StrStr(LoadOptions, LoadOption)) return EfiStrDuplicate(LoadOptions); // Otherwise add option @@ -97,7 +97,7 @@ CHAR16 *Old1_RemoveLoadOption(IN CONST CHAR16 *LoadOptions, IN CONST CHAR16 *Loa // } // // If there is no option or it is already present duplicate original // else { -// if ( LoadOptions.ExistIn(LoadOption) ) return LoadOptions; +// if ( LoadOptions.contains(LoadOption) ) return LoadOptions; // // Otherwise add option // return SPrintf("%s %s", LoadOptions.c_str(), LoadOption.c_str()); //LoadOptions + LoadOption // } @@ -115,7 +115,7 @@ CHAR16 *Old1_RemoveLoadOption(IN CONST CHAR16 *LoadOptions, IN CONST CHAR16 *Loa // // If there is no option to remove then duplicate original // if (LoadOption.isEmpty()) return LoadOptions; // // If not present duplicate original -// xsize Offset = LoadOptions.IdxOf(LoadOption); +// xsize Offset = LoadOptions.indexOf(LoadOption); // if ( Offset == MAX_XSIZE ) return LoadOptions; // // // Get placement of option in original options diff --git a/rEFIt_UEFI/cpp_unit_test/XString_test.cpp b/rEFIt_UEFI/cpp_unit_test/XString_test.cpp index 32e366f58..c955b05fc 100755 --- a/rEFIt_UEFI/cpp_unit_test/XString_test.cpp +++ b/rEFIt_UEFI/cpp_unit_test/XString_test.cpp @@ -24,15 +24,15 @@ struct make_unsigned { }; -//template <> struct __make_unsigned {}; -template <> struct make_unsigned< signed char> {typedef unsigned short type;}; -template <> struct make_unsigned {typedef unsigned short type;}; -template <> struct make_unsigned< signed short> {typedef unsigned short type;}; -template <> struct make_unsigned {typedef unsigned short type;}; -template <> struct make_unsigned< signed int> {typedef unsigned int type;}; -template <> struct make_unsigned {typedef unsigned int type;}; -template <> struct make_unsigned< signed long> {typedef unsigned long type;}; -template <> struct make_unsigned {typedef unsigned long type;}; +template <> struct make_unsigned< char> {typedef unsigned char type;}; +template <> struct make_unsigned< signed char> {typedef unsigned char type;}; +template <> struct make_unsigned {typedef unsigned char type;}; +template <> struct make_unsigned< signed short> {typedef unsigned short type;}; +template <> struct make_unsigned {typedef unsigned short type;}; +template <> struct make_unsigned< signed int> {typedef unsigned int type;}; +template <> struct make_unsigned {typedef unsigned int type;}; +template <> struct make_unsigned< signed long> {typedef unsigned long type;}; +template <> struct make_unsigned {typedef unsigned long type;}; template <> struct make_unsigned< signed long long> {typedef unsigned long long type;}; template <> struct make_unsigned {typedef unsigned long long type;}; @@ -197,6 +197,7 @@ struct TestStringMultiCoded const TestStringMultiCoded testStringMultiCodedArray[] = { testStringArray_LINE(""), testStringArray_LINE("a"), +#ifndef _MSC_VER testStringArray_LINE(utf8_1), testStringArray_LINE(utf8_2), testStringArray_LINE(utf8_3), @@ -208,6 +209,7 @@ const TestStringMultiCoded testStringMultiCodedArray[] = { // testStringArray_LINE(utf8_9), // testStringArray_LINE(utf8_10), // testStringArray_LINE(utf8_11), +#endif }; size_t nbTestStringMultiCoded = *(&testStringMultiCodedArray + 1) - testStringMultiCodedArray; @@ -400,12 +402,24 @@ bool displayOnlyIfFailed_tmp; __TEST2(test, XStringClass, classEncoding, encoding1, utf32); \ __TEST2(test, XStringClass, classEncoding, encoding1, wchar); \ - +/* Warning about array indexes of char type is on, so don't test it + TODO disable warning with pragma and uncomment to test with char */ #define TEST_ALL_INTEGRAL(test, XStringClass, classEncoding) \ - __TEST1(test, XStringClass, classEncoding, signed char); \ - __TEST1(test, XStringClass, classEncoding, unsigned char); \ + /*__TEST1(test, XStringClass, classEncoding, char);*/ \ + /*__TEST1(test, XStringClass, classEncoding, signed char);*/ \ + /*__TEST1(test, XStringClass, classEncoding, unsigned char);*/ \ + __TEST1(test, XStringClass, classEncoding, short); \ __TEST1(test, XStringClass, classEncoding, signed short); \ __TEST1(test, XStringClass, classEncoding, unsigned short); \ + __TEST1(test, XStringClass, classEncoding, int); \ + __TEST1(test, XStringClass, classEncoding, signed int); \ + __TEST1(test, XStringClass, classEncoding, unsigned int); \ + __TEST1(test, XStringClass, classEncoding, long); \ + __TEST1(test, XStringClass, classEncoding, signed long); \ + __TEST1(test, XStringClass, classEncoding, unsigned long); \ + __TEST1(test, XStringClass, classEncoding, long long); \ + __TEST1(test, XStringClass, classEncoding, signed long long); \ + __TEST1(test, XStringClass, classEncoding, unsigned long long); \ #define TEST_ALL_UTF(test, XStringClass, classEncoding) \ @@ -585,9 +599,9 @@ SimpleString testEmpty_() testEmpty_(); \ -/***************************** char32At_u *****************************/ +/***************************** char32At *****************************/ template -SimpleString testchar32At_u_(const InitialValue& initialValue) +SimpleString testchar32At_(const InitialValue& initialValue) { TEST_TITLE(displayOnlyFailed, sprintf("Test %s::char32At_u()", XStringClassInfo::xStringClassName)); @@ -603,13 +617,35 @@ SimpleString testchar32At_u_(const InitialValue& initialValue) return SimpleString(); } -#define testchar32At_u(XStringClass, classEncoding, integralType) \ - printf("Test %s::testchar32At_u\n", STRINGIFY(XStringClass)); \ +#define testchar32At(XStringClass, classEncoding, integralType) \ + printf("Test %s::testchar32At\n", STRINGIFY(XStringClass)); \ for ( size_t i = 0 ; i < nbTestStringMultiCoded ; i++ ) { \ - testchar32At_u_(testStringMultiCodedArray[i].classEncoding); \ + testchar32At_(testStringMultiCodedArray[i].classEncoding); \ } +/***************************** dataSized *****************************/ +template +SimpleString testdataSized_() +{ + TEST_TITLE(displayOnlyFailed, sprintf("Test %s::dataSized()", XStringClassInfo::xStringClassName)); + + XStringClass xstr; + integralType i = 10; + typename XStringClassInfo::ch_t* s = xstr.dataSized(i); + (void)s; + CHECK_RESULT(xstr.allocatedSize() >= 10, + sprintf("xstr[i] == dst.cha[i] (%d)", 10), + sprintf("xstr[i] != dst.cha[i] (%zu!=%d)", xstr.allocatedSize(), 10) + ); + return SimpleString(); +} + +#define testdataSized(XStringClass, classEncoding, integralType) \ + printf("Test %s::testdataSized\n", STRINGIFY(XStringClass)); \ + testdataSized_(); \ + + /***************************** strcpy *****************************/ @@ -800,15 +836,15 @@ SimpleString teststrncat_(const InitialValue& initialValue, const ValueToCat& va //xstr.takeValueFrom(initialValue.cha); //xstr.strncat(valueToCat.cha, i); - size_t expectedSize = (utf_size_of_utf_string(&c, initialValue.cha) + utf_size_of_utf_string_len(&c, valueToCat.cha, i))*sizeof(ch_t); - CHECK_RESULT(xstr.sizeInBytes() == expectedSize, - sprintf("xstr.sizeInBytes() == expectedSize (%zu)", expectedSize), - sprintf("xstr.sizeInBytes() != expectedSize (%zu!=%zu)", xstr.sizeInBytes(), expectedSize) + size_t expectedSize = (utf_size_of_utf_string(&c, initialValue.cha) + utf_size_of_utf_string_len(&c, valueToCat.cha, i)); + CHECK_RESULT(xstr.sizeInBytes() == expectedSize * sizeof(ch_t), + sprintf("xstr.sizeInBytes() == expectedSize (%zu)", expectedSize * sizeof(ch_t)), + sprintf("xstr.sizeInBytes() != expectedSize (%zu!=%zu)", xstr.sizeInBytes(), expectedSize * sizeof(ch_t)) ); - ch_t* expectedString = (ch_t*)malloc(expectedSize*sizeof(ch_t)*sizeof(ch_t) + 1); - utf_string_from_utf_string(expectedString, expectedSize*sizeof(ch_t) + 1, initialValue.cha); - utf_string_from_utf_string_len(expectedString + utf_size_of_utf_string(&c, initialValue.cha), expectedSize*sizeof(ch_t) + 1 - size_of_utf_string(expectedString), valueToCat.cha, i); + ch_t* expectedString = (ch_t*)malloc((expectedSize+1)*sizeof(ch_t)); + utf_string_from_utf_string(expectedString, expectedSize + 1, initialValue.cha); + utf_string_from_utf_string_len(expectedString + utf_size_of_utf_string(&c, initialValue.cha), expectedSize + 1 - size_of_utf_string(expectedString), valueToCat.cha, i); CHECK_RESULT(memcmp(xstr.s(), expectedString, expectedSize+sizeof(ch_t)) == 0, sprintf("memcmp(xstr.s(), expectedString, dst.size) == 0"), sprintf("memcmp(xstr.s(), expectedString, dst.size) != 0") @@ -858,7 +894,7 @@ SimpleString testSubString_(const InitialValue& initialValue) if ( pos < initialValue.utf32_length ) offset = utf_size_of_utf_string_len(&c, initialValue.cha, pos); else offset = utf_size_of_utf_string(&c, initialValue.cha); - XStringClass subStr = str.SubString(pos, count); + XStringClass subStr = str.subString(pos, count); CHECK_RESULT(subStr.length() == expectedLength, sprintf("subStr.length() == expectedLength (%zu)", expectedLength), @@ -1091,7 +1127,7 @@ SimpleString testCompare_(const InitialValue& initialValue) /***************************** indexOf, rindexOf *****************************/ template -static void testIdxOf__(XStringClass subStr, bool ignoreCase, +static void testindexOf__(XStringClass subStr, bool ignoreCase, size_t (XStringClass::*indexOfChar)(char32_t, size_t) const, size_t (XStringClass::*indexOfString)(const ch_t*, size_t) const, size_t (XStringClass::*rindexOfChar)(char32_t, size_t) const, @@ -1103,14 +1139,14 @@ static void testIdxOf__(XStringClass subStr, bool ignoreCase, testStr = subStr; if ( ignoreCase ) testStr.lowerAscii(); CHECK_RESULT((testStr.*indexOfString)(subStr.s(), 0) == 0, - sprintf("testStr.IdxOf(subStr.s(), 0) == 0"), - sprintf("testStr.IdxOf(subStr.s(), 0) != 0 (%zu)", (testStr.*indexOfString)(subStr.s(), 0)) + sprintf("testStr.indexOf(subStr.s(), 0) == 0"), + sprintf("testStr.indexOf(subStr.s(), 0) != 0 (%zu)", (testStr.*indexOfString)(subStr.s(), 0)) ); (testStr.*indexOfString)(subStr.s(), 0); size_t expectedPos = subStr.length()==0 ? testStr.length() : 0; CHECK_RESULT((testStr.*rindexOfString)(subStr.s(), MAX_XSIZE-1) == expectedPos, - sprintf("testStr.IdxOf(subStr.s(), 0) == expectedPos (%zu)", expectedPos), - sprintf("testStr.IdxOf(subStr.s(), 0) != 0 (%zu!=%zu)", (testStr.*rindexOfString)(subStr.s(), MAX_XSIZE-1), expectedPos) + sprintf("testStr.indexOf(subStr.s(), 0) == expectedPos (%zu)", expectedPos), + sprintf("testStr.indexOf(subStr.s(), 0) != 0 (%zu!=%zu)", (testStr.*rindexOfString)(subStr.s(), MAX_XSIZE-1), expectedPos) ); (testStr.*rindexOfString)(subStr.s(), MAX_XSIZE-1); @@ -1132,8 +1168,8 @@ static void testIdxOf__(XStringClass subStr, bool ignoreCase, testStr.strcat(subStr.s()); if ( ignoreCase ) testStr.lowerAscii(); CHECK_RESULT((testStr.*indexOfString)(subStr.s(), 0) == 3, - sprintf("testStr.IdxOf(subStr.s(), 0) == 3"), - sprintf("testStr.IdxOf(subStr.s(), 0) != 3 (%zu)", (testStr.*indexOfString)(subStr.s(), 0)) + sprintf("testStr.indexOf(subStr.s(), 0) == 3"), + sprintf("testStr.indexOf(subStr.s(), 0) != 3 (%zu)", (testStr.*indexOfString)(subStr.s(), 0)) ); (testStr.*indexOfString)(subStr.s(), 0); CHECK_RESULT((testStr.*indexOfString)(subStr.s(), 0) == 3, @@ -1145,8 +1181,8 @@ static void testIdxOf__(XStringClass subStr, bool ignoreCase, sprintf("(testStr.*indexOfString)(subStr[0]) != 3 (%zu)", (testStr.*indexOfChar)(subStr[0], 0)) ); CHECK_RESULT((testStr.*rindexOfString)(subStr.s(), MAX_XSIZE-1) == 3, - sprintf("testStr.IdxOf(subStr.s(), MAX_XSIZE-1) == 3"), - sprintf("testStr.IdxOf(subStr.s(), MAX_XSIZE-1) != 3 (%zu)", (testStr.*rindexOfString)(subStr.s(), MAX_XSIZE-1)) + sprintf("testStr.indexOf(subStr.s(), MAX_XSIZE-1) == 3"), + sprintf("testStr.indexOf(subStr.s(), MAX_XSIZE-1) != 3 (%zu)", (testStr.*rindexOfString)(subStr.s(), MAX_XSIZE-1)) ); (testStr.*rindexOfString)(subStr.s(), MAX_XSIZE-1); CHECK_RESULT((testStr.*rindexOfString)(subStr.s(), MAX_XSIZE-1) == 3, @@ -1163,8 +1199,8 @@ static void testIdxOf__(XStringClass subStr, bool ignoreCase, testStr.strcat(""); if ( ignoreCase ) testStr.lowerAscii(); CHECK_RESULT((testStr.*indexOfString)(subStr.s(), 0) == 4, - sprintf("testStr.IdxOf(subStr.s(), 0) == 4"), - sprintf("testStr.IdxOf(subStr.s(), 0) != 4 (%zu)", (testStr.*indexOfString)(subStr.s(), 0)) + sprintf("testStr.indexOf(subStr.s(), 0) == 4"), + sprintf("testStr.indexOf(subStr.s(), 0) != 4 (%zu)", (testStr.*indexOfString)(subStr.s(), 0)) ); (testStr.*indexOfString)(subStr.s(), 0); CHECK_RESULT((testStr.*indexOfString)(subStr.s(), 0) == 4, @@ -1176,8 +1212,8 @@ static void testIdxOf__(XStringClass subStr, bool ignoreCase, sprintf("(testStr.*indexOfString)(subStr[0]) != 4 (%zu)", (testStr.*indexOfChar)(subStr[0], 0)) ); CHECK_RESULT((testStr.*rindexOfString)(subStr.s(), MAX_XSIZE-1) == 4, - sprintf("testStr.IdxOf(subStr.s(), 0) == 4"), - sprintf("testStr.IdxOf(subStr.s(), 0) != 4 (%zu)", (testStr.*rindexOfString)(subStr.s(), MAX_XSIZE-1)) + sprintf("testStr.indexOf(subStr.s(), 0) == 4"), + sprintf("testStr.indexOf(subStr.s(), 0) != 4 (%zu)", (testStr.*rindexOfString)(subStr.s(), MAX_XSIZE-1)) ); CHECK_RESULT((testStr.*rindexOfString)(subStr.s(), MAX_XSIZE-1) == 4, sprintf("(testStr.*rindexOfString)(subStr.s(), 0) == 4"), @@ -1195,8 +1231,8 @@ static void testIdxOf__(XStringClass subStr, bool ignoreCase, testStr.strcat(""); if ( ignoreCase ) testStr.lowerAscii(); CHECK_RESULT((testStr.*indexOfString)(subStr.s(), 0) == 5, - sprintf("testStr.IdxOf(subStr.s(), 0) == 5"), - sprintf("testStr.IdxOf(subStr.s(), 0) != 5 (%zu)", (testStr.*indexOfString)(subStr.s(), 0)) + sprintf("testStr.indexOf(subStr.s(), 0) == 5"), + sprintf("testStr.indexOf(subStr.s(), 0) != 5 (%zu)", (testStr.*indexOfString)(subStr.s(), 0)) ); CHECK_RESULT((testStr.*indexOfString)(subStr.s(), 0) == 5, sprintf("(testStr.*indexOfString)(subStr.s(), 0) == 5"), @@ -1207,8 +1243,8 @@ static void testIdxOf__(XStringClass subStr, bool ignoreCase, sprintf("(testStr.*indexOfString)(subStr[0]) != 5 (%zu)", (testStr.*indexOfChar)(subStr[0], 0)) ); CHECK_RESULT((testStr.*rindexOfString)(subStr.s(), MAX_XSIZE-1) == 5 + subStr.length() + 6, - sprintf("testStr.IdxOf(subStr.s(), 0) == 5 + subStr.length() + 6"), - sprintf("testStr.IdxOf(subStr.s(), 0) != 5 + subStr.length() + 6 (%zu!=%zu)", (testStr.*rindexOfString)(subStr.s(), MAX_XSIZE-1), 5 + subStr.length() + 6) + sprintf("testStr.indexOf(subStr.s(), 0) == 5 + subStr.length() + 6"), + sprintf("testStr.indexOf(subStr.s(), 0) != 5 + subStr.length() + 6 (%zu!=%zu)", (testStr.*rindexOfString)(subStr.s(), MAX_XSIZE-1), 5 + subStr.length() + 6) ); (testStr.*rindexOfString)(subStr.s(), MAX_XSIZE-1); CHECK_RESULT((testStr.*rindexOfString)(subStr.s(), MAX_XSIZE-1) == 5 + subStr.length() + 6, @@ -1223,7 +1259,7 @@ static void testIdxOf__(XStringClass subStr, bool ignoreCase, } template -SimpleString testIdxOf_(const InitialValue& initialValue) +SimpleString testindexOf_(const InitialValue& initialValue) { TEST_TITLE(displayOnlyFailed, sprintf("Test %s::idxOf", XStringClassInfo::xStringClassName)); @@ -1237,13 +1273,13 @@ SimpleString testIdxOf_(const InitialValue& initialValue) for ( size_t pos = 0 ; pos < initialValue.utf32_length+3 ; pos+=1 ) { for ( size_t count = 0 ; count < initialValue.utf32_length-pos+3 ; count+=1 ) { - ixs_t subStr = str.SubString(pos, count); + ixs_t subStr = str.subString(pos, count); // size_t (ixs_t::*p)(const ich_t* S, size_t Pos) const = &ixs_t::template indexOf; - testIdxOf__(subStr, false, &ixs_t::indexOf, &ixs_t::template indexOf, &ixs_t::rindexOf, &ixs_t::template rindexOf); + testindexOf__(subStr, false, &ixs_t::indexOf, &ixs_t::template indexOf, &ixs_t::rindexOf, &ixs_t::template rindexOf); ixs_t subStrLower = subStr; - testIdxOf__(subStrLower, true, &ixs_t::indexOfIC, &ixs_t::template indexOfIC, &ixs_t::rindexOfIC, &ixs_t::template rindexOfIC); + testindexOf__(subStrLower, true, &ixs_t::indexOfIC, &ixs_t::template indexOfIC, &ixs_t::rindexOfIC, &ixs_t::template rindexOfIC); // if ( subStrLower != subStr ) { // } } @@ -1252,13 +1288,13 @@ SimpleString testIdxOf_(const InitialValue& initialValue) return SimpleString(); } -#define testIdxOf(XStringClass, classEncoding, encoding) \ - printf("Test %s::testIdxOf(%s)\n", STRINGIFY(XStringClass), STRINGIFY(encoding)); \ +#define testindexOf(XStringClass, classEncoding, encoding) \ + printf("Test %s::testindexOf(%s)\n", STRINGIFY(XStringClass), STRINGIFY(encoding)); \ for ( size_t i = 0 ; i < nbTestStringMultiCoded ; i++ ) { \ - testIdxOf_(testStringMultiCodedArray[i].encoding); \ + testindexOf_(testStringMultiCodedArray[i].encoding); \ } \ for ( size_t i = 0 ; i < nbTestStringMultiCoded4CaseArray ; i++ ) { \ - testIdxOf_(testStringMultiCoded4CaseArray[i].encoding); \ + testindexOf_(testStringMultiCoded4CaseArray[i].encoding); \ } \ @@ -1278,7 +1314,7 @@ void func_test(XStringW& xsw) (void)xsw; } -int XStringx_tests() +int XString_tests() { #ifdef JIEF_DEBUG // DebugLog(2, "XString16_tests -> Enter\n"); @@ -1288,15 +1324,21 @@ int XStringx_tests() //const char* cc = " "; //char buf[64]; //char16_t* buf16 = (char16_t*)u"foo16"; -XString x1; -x1.takeValueFrom("a"); -XString x2; -x2.takeValueFrom("b"); +XString x1("a"_XS); +XString x2("b"_XS); +XStringW xw1("c"_XS); -XStringW xw1; xw1.takeValueFrom("c"); +char c = 1; +int ii = sizeof(size_t); +unsigned long long ull = SIZE_T_MAX; +unsigned long long ll = 3; +xw1.dataSized(c); +xw1.dataSized(ii); +xw1.dataSized(ull); +xw1.dataSized(ll); -auto x3 = xw1 = x1; -func_test(x3); +//auto x3 = xw1 = x1; +//func_test(x3); // //XStringAbstract__is_char_st a; //printf("a.v()=%d\n", a.v()); @@ -1313,22 +1355,34 @@ func_test(x3); // testDefaultCtor("XString"); // XString16 a = u"toto"_XS16; // teststrncpy_("utf8", testStringMultiCodedArray[1].utf8, testStringMultiCodedArray[1].wchar); -//testIdxOf(XString, utf8, utf16); +//testindexOf(XString, utf8, utf16); //testCompare(XString, utf8, utf8); - testIdxOf_(testStringMultiCoded4CaseArray[0].utf8); \ +//testindexOf_(testStringMultiCoded4CaseArray[0].utf8); -//size_t size = sizeof("ギ")-1; // this char is 6 bytes long ! +const char* utf8 = "ギ"; (void)utf8; +size_t utf8_size = sizeof("ギ") - 1; (void)utf8_size; // this char is 6 bytes long ! +const wchar_t* utfw = L"ギ"; (void)utfw; +size_t utfw_size = sizeof(L"ギ") - 1; (void)utfw_size; // this char is 6 bytes long ! +const char16_t* utf16 = u"ギ"; (void)utf16; +size_t utf16_size = sizeof(u"ギ") - 1; (void)utf16_size; // this char is 6 bytes long ! +const char32_t* utf32 = U"ギ"; (void)utf32; +size_t utf32_size = sizeof(U"ギ") - 1; (void)utf32_size; // this char is 6 bytes long ! //size_t size = sizeof("ꇉ")-1; // this char is 3 bytes long //size_t size = sizeof("伽")-1; // this char is 3 bytes long //size_t size = sizeof("楘")-1; // this char is 3 bytes long //XString str = "ギꇉ伽楘"_XS; //char* s = str.data(42); +TEST_ALL_CLASSES(testchar32At, TEST_ALL_INTEGRAL); + + + TEST_ALL_CLASSES(testDefaultCtor, __TEST0); TEST_ALL_CLASSES(testEmpty, __TEST0); TEST_ALL_CLASSES(testTakeValueFrom, TEST_ALL_UTF); TEST_ALL_CLASSES(testTakeValueFromXString, TEST_ALL_UTF); - TEST_ALL_CLASSES(testchar32At_u, TEST_ALL_INTEGRAL); + TEST_ALL_CLASSES(testchar32At, TEST_ALL_INTEGRAL); + TEST_ALL_CLASSES(testdataSized, TEST_ALL_INTEGRAL); TEST_ALL_CLASSES(teststrcpy, TEST_ALL_UTF); TEST_ALL_CLASSES(teststrncpy, TEST_ALL_UTF); // 26944 tests @@ -1337,7 +1391,7 @@ func_test(x3); TEST_ALL_CLASSES(testSubString, __TEST0); TEST_ALL_CLASSES(testCompare, TEST_ALL_UTF); - TEST_ALL_CLASSES(testIdxOf, TEST_ALL_UTF); + TEST_ALL_CLASSES(testindexOf, TEST_ALL_UTF); diff --git a/rEFIt_UEFI/cpp_unit_test/XString_test.h b/rEFIt_UEFI/cpp_unit_test/XString_test.h old mode 100644 new mode 100755 index a26f39311..1e172548c --- a/rEFIt_UEFI/cpp_unit_test/XString_test.h +++ b/rEFIt_UEFI/cpp_unit_test/XString_test.h @@ -1 +1 @@ -int XStringx_tests(); +int XString_tests(); diff --git a/rEFIt_UEFI/cpp_unit_test/all_tests.cpp b/rEFIt_UEFI/cpp_unit_test/all_tests.cpp old mode 100644 new mode 100755 index 8deddc5b7..1cf19a0c7 --- a/rEFIt_UEFI/cpp_unit_test/all_tests.cpp +++ b/rEFIt_UEFI/cpp_unit_test/all_tests.cpp @@ -31,20 +31,19 @@ bool all_tests() bool all_ok = true; int ret; -#ifdef XSTRING16_DEV - ret = XStringx_tests(); + ret = XString_tests(); if ( ret != 0 ) { DebugLog(2, "XString16_tests() failed at test %d\n", ret); all_ok = false; } -return ret; +//return ret; // ret = XUINTN_tests(); // if ( ret != 0 ) { // DebugLog(2, "XUINTN_tests() failed at test %d\n", ret); // all_ok = false; // } - #if defined(CLOVER_BUILD) - ret = printlib_tests(); +#if defined(JIEF_DEBUG) && defined(CLOVER_BUILD) + ret = printlib_tests(); if ( ret != 0 ) { DebugLog(2, "printlib_tests() failed at test %d\n", ret); all_ok = false; @@ -55,16 +54,12 @@ return ret; all_ok = false; } #endif -#endif #ifndef _MSC_VER ret = printf_lite_tests(); if ( ret != 0 ) { DebugLog(2, "printf_lite_tests() failed at test %d\n", ret); all_ok = false; } -#endif -#ifdef JIEF_DEBUG -//return ret; #endif ret = strlen_tests(); if ( ret != 0 ) { diff --git a/rEFIt_UEFI/cpp_unit_test/printf_lite-test.cpp b/rEFIt_UEFI/cpp_unit_test/printf_lite-test.cpp old mode 100644 new mode 100755 index 964e605a2..8a5f0d9f0 --- a/rEFIt_UEFI/cpp_unit_test/printf_lite-test.cpp +++ b/rEFIt_UEFI/cpp_unit_test/printf_lite-test.cpp @@ -395,11 +395,18 @@ int printf_lite_tests(void) #if __x86_64__ #endif - size_t size; - if ( SIZE_T_MAX == UINT64_MAX ) { - size = SIZE_T_MAX; Test1arg(F("SIZE_MAX=18446744073709551615"), F("SIZE_MAX=%zu"), size); - }else if ( SIZE_T_MAX == UINT32_MAX ) { - size = SIZE_T_MAX; Test1arg(F("SIZE_MAX=4294967295"), F("SIZE_MAX=%zu"), size); +#ifdef SIZE_MAX +# define MY_SIZE_T_MAX SIZE_MAX +#elif defined(SIZE_T_MAX) +# define MY_SIZE_T_MAX SIZE_T_MAX +#elif +#warning No size_t max +#endif + size_t size; + if (MY_SIZE_T_MAX == UINT64_MAX ) { + size = MY_SIZE_T_MAX; Test1arg(F("SIZE_MAX=18446744073709551615"), F("SIZE_MAX=%zu"), size); + }else if (MY_SIZE_T_MAX == UINT32_MAX ) { + size = MY_SIZE_T_MAX; Test1arg(F("SIZE_MAX=4294967295"), F("SIZE_MAX=%zu"), size); }else{ // 16 bits size_t ? Does that exist ? } diff --git a/rEFIt_UEFI/entry_scan/common.cpp b/rEFIt_UEFI/entry_scan/common.cpp index b5544f4a3..51ee27b00 100644 --- a/rEFIt_UEFI/entry_scan/common.cpp +++ b/rEFIt_UEFI/entry_scan/common.cpp @@ -131,7 +131,7 @@ XString AddLoadOption(IN CONST XString& LoadOptions, IN CONST XString& LoadOptio } // If there is no option or it is already present duplicate original else { - if ( LoadOptions.ExistIn(LoadOption) ) return LoadOptions; //good + if ( LoadOptions.contains(LoadOption) ) return LoadOptions; //good // Otherwise add option // return SPrintf("%s %s", LoadOptions.c_str(), LoadOption.c_str()); //LoadOptions + LoadOption return LoadOptions + " "_XS + LoadOption; //why not? @@ -150,7 +150,7 @@ XString RemoveLoadOption(IN const XString& LoadOptions, IN const XString& LoadOp // If there is no option to remove then duplicate original if (LoadOption.isEmpty()) return LoadOptions; // If not present duplicate original - xsize Offset = LoadOptions.IdxOf(LoadOption); + xsize Offset = LoadOptions.indexOf(LoadOption); if ( Offset == MAX_XSIZE ) return LoadOptions; // Get placement of option in original options @@ -181,15 +181,15 @@ XString RemoveLoadOption(IN const XString& LoadOptions, IN const XString& LoadOp XString NewLoadOptions; if (Offset == 0) { // Simple case - we just need substring after OptionLength position - NewLoadOptions = LoadOptions.SubString(OptionLength, MAX_XSIZE); + NewLoadOptions = LoadOptions.subString(OptionLength, MAX_XSIZE); } else { // Copy preceeding substring - NewLoadOptions = LoadOptions.SubString(0, Offset); + NewLoadOptions = LoadOptions.subString(0, Offset); // CopyMem(NewLoadOptions, LoadOptions, Offset * sizeof(CHAR16)); if ((Offset + OptionLength) < Length) { // Copy following substring, but include one space also OptionLength--; - NewLoadOptions += LoadOptions.SubString(Offset + OptionLength, MAX_XSIZE); + NewLoadOptions += LoadOptions.subString(Offset + OptionLength, MAX_XSIZE); // CopyMem(NewLoadOptions + Offset, LoadOptions + Offset + OptionLength, (Length - OptionLength - Offset) * sizeof(CHAR16)); } } diff --git a/rEFIt_UEFI/entry_scan/loader.cpp b/rEFIt_UEFI/entry_scan/loader.cpp index 2c1632ca5..101d93e04 100644 --- a/rEFIt_UEFI/entry_scan/loader.cpp +++ b/rEFIt_UEFI/entry_scan/loader.cpp @@ -251,7 +251,7 @@ UINT8 GetOSTypeFromPath(IN CONST CHAR16 *Path) // (StriCmp(Path, L"\\bootmgr.efi") == 0) || //never worked, just extra icon in menu (StriCmp(Path, L"\\EFI\\MICROSOFT\\BOOT\\cdboot.efi") == 0)) { return OSTYPE_WINEFI; - } else if (LINUX_FULL_LOADER_PATH.EqualIC(Path)) { + } else if (LINUX_FULL_LOADER_PATH.equalIC(Path)) { return OSTYPE_LINEFI; } else if (StriStr(Path, L"grubx64.efi") != NULL) { return OSTYPE_LINEFI; @@ -301,7 +301,7 @@ STATIC CONST CHAR16 *LinuxIconNameFromPath(IN CONST CHAR16 *Path, } // Try to open the linux issue - if ((RootDir != NULL) && LINUX_FULL_LOADER_PATH.EqualIC(Path)) { + if ((RootDir != NULL) && LINUX_FULL_LOADER_PATH.equalIC(Path)) { CHAR8 *Issue = NULL; UINTN IssueLen = 0; if (!EFI_ERROR(egLoadFile(RootDir, LINUX_ISSUE_PATH.wc_str(), (UINT8 **)&Issue, &IssueLen)) && (Issue != NULL)) { @@ -605,7 +605,7 @@ STATIC LOADER_ENTRY *CreateLoaderEntry(IN CONST CHAR16 *LoaderPath, case OSTYPE_OSX_INSTALLER: OSIconName = GetOSIconName(Entry->OSVersion);// Sothor - Get OSIcon name using OSVersion // apianti - force custom logo even when verbose - if ( Entry->LoadOptions.ExistInIC("-v") ) { + if ( Entry->LoadOptions.containsIC("-v") ) { // OSX is not booting verbose, so we can set console to graphics mode Entry->Flags = OSFLAG_UNSET(Entry->Flags, OSFLAG_USEGRAPHICS); } @@ -891,8 +891,8 @@ STATIC VOID AddDefaultMenu(IN LOADER_ENTRY *Entry) } } else if (Entry->LoaderType == OSTYPE_LINEFI) { - BOOLEAN Quiet = Entry->LoadOptions.ExistIn("quiet"); - BOOLEAN WithSplash = Entry->LoadOptions.ExistIn("splash"); + BOOLEAN Quiet = Entry->LoadOptions.contains("quiet"); + BOOLEAN WithSplash = Entry->LoadOptions.contains("splash"); // default entry SubEntry = Entry->getPartiallyDuplicatedEntry(); @@ -1233,7 +1233,7 @@ VOID ScanLoader(VOID) if (aFound && (aFound == aIndex)) { XImage ImageX; XStringW IconXSW = XStringW().takeValueFrom(AndroidEntryData[Index].Icon); - ImageX.LoadXImage(ThemeX.ThemeDir, (L"os_"_XSW + IconXSW.SubString(0, IconXSW.IdxOf(','))).wc_str()); + ImageX.LoadXImage(ThemeX.ThemeDir, (L"os_"_XSW + IconXSW.subString(0, IconXSW.indexOf(','))).wc_str()); AddLoaderEntry(AndroidEntryData[Index].Path, ""_XS, XStringW().takeValueFrom(AndroidEntryData[Index].Title), Volume, (ImageX.isEmpty() ? NULL : &ImageX), OSTYPE_LIN, OSFLAG_NODEFAULTARGS); } @@ -1273,7 +1273,7 @@ VOID ScanLoader(VOID) if (FileExists(Volume->RootDir, LinuxEntryData[Index].Path)) { XImage ImageX; XStringW IconXSW = XStringW().takeValueFrom(LinuxEntryData[Index].Icon); - ImageX.LoadXImage(ThemeX.ThemeDir, (L"os_"_XSW + IconXSW.SubString(0, IconXSW.IdxOf(','))).wc_str()); + ImageX.LoadXImage(ThemeX.ThemeDir, (L"os_"_XSW + IconXSW.subString(0, IconXSW.indexOf(','))).wc_str()); AddLoaderEntry(LinuxEntryData[Index].Path, ""_XS, XStringW().takeValueFrom(LinuxEntryData[Index].Title), Volume, (ImageX.isEmpty() ? NULL : &ImageX), OSTYPE_LIN, OSFLAG_NODEFAULTARGS); } diff --git a/rEFIt_UEFI/gui/shared_with_menu.cpp b/rEFIt_UEFI/gui/shared_with_menu.cpp index b668f4024..501eb0ddd 100644 --- a/rEFIt_UEFI/gui/shared_with_menu.cpp +++ b/rEFIt_UEFI/gui/shared_with_menu.cpp @@ -79,7 +79,7 @@ UINT32 EncodeOptions(const XString& Options) return 0; } for (Index = 0; Index < NUM_OPT; Index++) { - if ( Options.ExistIn(ArgOptional[Index]) ) { + if ( Options.contains(ArgOptional[Index]) ) { OptionsBits |= (1 << Index); if (Index == 1) { OptionsBits &= ~1; diff --git a/rEFIt_UEFI/libeg/VectorGraphics.cpp b/rEFIt_UEFI/libeg/VectorGraphics.cpp index ccc43365f..021482d81 100755 --- a/rEFIt_UEFI/libeg/VectorGraphics.cpp +++ b/rEFIt_UEFI/libeg/VectorGraphics.cpp @@ -91,11 +91,11 @@ EFI_STATUS XTheme::ParseSVGXIcon(INTN Id, const XString& IconNameX, XImage* Imag // if (BootCampStyle && (strstr(IconName, "selection_big") != NULL)) { // shape->opacity = 0.f; // } - if (BootCampStyle && IconNameX.ExistIn("selection_big")) { + if (BootCampStyle && IconNameX.contains("selection_big")) { shape->opacity = 0.f; } // if (strstr(shape->id, "BoundingRect") != NULL) { - if (XString().takeValueFrom(shape->id).ExistIn("BoundingRect")) { + if (XString().takeValueFrom(shape->id).contains("BoundingRect")) { //there is bounds after nsvgParse() IconImage->width = shape->bounds[2] - shape->bounds[0]; IconImage->height = shape->bounds[3] - shape->bounds[1]; @@ -103,12 +103,12 @@ EFI_STATUS XTheme::ParseSVGXIcon(INTN Id, const XString& IconNameX, XImage* Imag if ( IconImage->height < 1.f ) { IconImage->height = 200.f; } - if (IconNameX.ExistIn("selection_big") && (!SelectionOnTop)) { + if (IconNameX.contains("selection_big") && (!SelectionOnTop)) { MainEntriesSize = (int)(IconImage->width * Scale); //xxx row0TileSize = MainEntriesSize + (int)(16.f * Scale); DBG("main entry size = %lld\n", MainEntriesSize); } - if (IconNameX.ExistIn("selection_small") && (!SelectionOnTop)) { + if (IconNameX.contains("selection_small") && (!SelectionOnTop)) { row1TileSize = (int)(IconImage->width * Scale); } @@ -185,7 +185,7 @@ EFI_STATUS XTheme::ParseSVGXIcon(INTN Id, const XString& IconNameX, XImage* Imag bounds[3] = -FLT_MAX; nsvg__imageBounds(p2, bounds); CopyMem(IconImage->realBounds, bounds, 4 * sizeof(float)); - if ((Id == BUILTIN_ICON_BANNER) && IconNameX.ExistIn("Banner")) { + if ((Id == BUILTIN_ICON_BANNER) && IconNameX.contains("Banner")) { BannerPosX = (int)(bounds[0] * Scale - CentreShift); if (BannerPosX < 0) { BannerPosX = 1; //one pixel @@ -211,7 +211,7 @@ EFI_STATUS XTheme::ParseSVGXIcon(INTN Id, const XString& IconNameX, XImage* Imag float tx = 0.f, ty = 0.f; if ((Id != BUILTIN_ICON_BACKGROUND) && (Id != BUILTIN_ICON_ANIME) && - !IconNameX.ExistIn("Banner")) { + !IconNameX.contains("Banner")) { float realWidth = (bounds[2] - bounds[0]) * Scale; float realHeight = (bounds[3] - bounds[1]) * Scale; // DBG("icon=%s width=%f realwidth=%f\n", IconNameX.c_str(), Width, realWidth); diff --git a/rEFIt_UEFI/libeg/XTheme.cpp b/rEFIt_UEFI/libeg/XTheme.cpp index 8b951481c..8980cfdbc 100644 --- a/rEFIt_UEFI/libeg/XTheme.cpp +++ b/rEFIt_UEFI/libeg/XTheme.cpp @@ -395,26 +395,26 @@ const XImage& XTheme::LoadOSIcon(const XString& Full) XString Second; XString Third; const XImage *ReturnImage; - UINTN Comma = Full.IdxOf(','); + UINTN Comma = Full.indexOf(','); UINTN Size = Full.length(); // DBG("IconName=%ls comma=%lld size=%lld\n", OSIconName, Comma, Size); if (Comma != MAX_XSIZE) { //Comma - First = "os_"_XS + Full.SubString(0, Comma); + First = "os_"_XS + Full.subString(0, Comma); ReturnImage = &GetIcon(First); // DBG(" first=%s\n", First.c_str()); if (!ReturnImage->isEmpty()) return *ReturnImage; //else search second name - Second = "os_"_XS + Full.SubString(Comma + 1, Size - Comma - 1); + Second = "os_"_XS + Full.subString(Comma + 1, Size - Comma - 1); //moreover names can be triple L"chrome,grub,linux" - UINTN SecondComma = Second.IdxOf(','); + UINTN SecondComma = Second.indexOf(','); if (Comma == MAX_XSIZE) { ReturnImage = &GetIcon(Second); if (!ReturnImage->isEmpty()) return *ReturnImage; } else { - First = Second.SubString(0, SecondComma); + First = Second.subString(0, SecondComma); ReturnImage = &GetIcon(First); if (!ReturnImage->isEmpty()) return *ReturnImage; - Third = "os_"_XS + Second.SubString(SecondComma + 1, Size - SecondComma - 1); + Third = "os_"_XS + Second.subString(SecondComma + 1, Size - SecondComma - 1); ReturnImage = &GetIcon(Third); if (!ReturnImage->isEmpty()) return *ReturnImage; } diff --git a/rEFIt_UEFI/refit/main.cpp b/rEFIt_UEFI/refit/main.cpp index 8174ed5bc..06f3c16f9 100644 --- a/rEFIt_UEFI/refit/main.cpp +++ b/rEFIt_UEFI/refit/main.cpp @@ -749,7 +749,7 @@ static VOID StartLoader(IN LOADER_ENTRY *Entry) } // Set boot argument for kernel if no caches, this should force kernel loading - if ( OSFLAG_ISSET(Entry->Flags, OSFLAG_NOCACHES) && !Entry->LoadOptions.ExistInIC("Kernel="_XS) ) { + if ( OSFLAG_ISSET(Entry->Flags, OSFLAG_NOCACHES) && !Entry->LoadOptions.containsIC("Kernel="_XS) ) { XString KernelLocation; if (Entry->OSVersion && AsciiOSVersionToUint64(Entry->OSVersion) <= AsciiOSVersionToUint64("10.9")) { @@ -802,7 +802,7 @@ static VOID StartLoader(IN LOADER_ENTRY *Entry) if ( gDriversFlags.AptioFixLoaded && !DoHibernateWake && - !Entry->LoadOptions.ExistIn("slide=") ) { + !Entry->LoadOptions.contains("slide=") ) { // Add slide=0 argument for ML+ if not present Entry->LoadOptions = AddLoadOption(Entry->LoadOptions, "slide=0"_XS); } @@ -816,7 +816,7 @@ static VOID StartLoader(IN LOADER_ENTRY *Entry) (AsciiStrStr(gCPUStructure.BrandString, "Celeron") || AsciiStrStr(gCPUStructure.BrandString, "Pentium")) && (AsciiOSVersionToUint64(Entry->OSVersion) >= AsciiOSVersionToUint64("10.8.5")) && (AsciiOSVersionToUint64(Entry->OSVersion) < AsciiOSVersionToUint64("10.12")) && - (!Entry->LoadOptions.ExistIn("-xcpm"_XS))) { + (!Entry->LoadOptions.contains("-xcpm"_XS))) { // add "-xcpm" argv if not present on Haswell+ Celeron/Pentium Entry->LoadOptions = AddLoadOption(Entry->LoadOptions, "-xcpm"_XS); } @@ -826,7 +826,7 @@ static VOID StartLoader(IN LOADER_ENTRY *Entry) gCPUStructure.Model == CPU_MODEL_IVY_BRIDGE && (AsciiOSVersionToUint64(Entry->OSVersion) >= AsciiOSVersionToUint64("10.8.5")) && (AsciiOSVersionToUint64(Entry->OSVersion) < AsciiOSVersionToUint64("10.12")) && - (!Entry->LoadOptions.ExistIn("-xcpm"))) { + (!Entry->LoadOptions.contains("-xcpm"))) { // add "-xcpm" argv if not present on Ivy Bridge Entry->LoadOptions = AddLoadOption(Entry->LoadOptions, "-xcpm"_XS); } @@ -848,7 +848,7 @@ static VOID StartLoader(IN LOADER_ENTRY *Entry) // which is wrong // apianti - only block console output if using graphics // but don't block custom boot logo - if ( Entry->LoadOptions.ExistInIC("-v"_XS) ) { + if ( Entry->LoadOptions.containsIC("-v"_XS) ) { Entry->Flags = OSFLAG_UNSET(Entry->Flags, OSFLAG_USEGRAPHICS); } else if ( Entry->LoadOptions.isEmpty() ) { Entry->LoadOptions = AddLoadOption(Entry->LoadOptions, " "_XS); @@ -2718,7 +2718,7 @@ RefitMain (IN EFI_HANDLE ImageHandle, gEmuVariableControl->UninstallEmulation(gEmuVariableControl); } */ - if ( LoaderEntry->LoadOptions.ExistIn("BO-ADD") ) { + if ( LoaderEntry->LoadOptions.contains("BO-ADD") ) { CHAR16 *Description; CONST CHAR16 *VolName; CONST CHAR16 *LoaderName; @@ -2787,13 +2787,13 @@ RefitMain (IN EFI_HANDLE ImageHandle, PrintBootOptions(FALSE); - } else if ( LoaderEntry->LoadOptions.ExistIn("BO-REMOVE") ) { + } else if ( LoaderEntry->LoadOptions.contains("BO-REMOVE") ) { PrintBootOptions(FALSE); Status = DeleteBootOptionForFile (LoaderEntry->Volume->DeviceHandle, LoaderEntry->LoaderPath ); PrintBootOptions(FALSE); - } else if ( LoaderEntry->LoadOptions.ExistIn("BO-PRINT") ) { + } else if ( LoaderEntry->LoadOptions.contains("BO-PRINT") ) { PrintBootOptions(TRUE); }