Warning removal. New class XUINTN (not yet used).

This commit is contained in:
jief 2020-03-11 17:23:58 +03:00
parent e6509221b4
commit 19cfe2831a
31 changed files with 843 additions and 119 deletions

View File

@ -30,6 +30,29 @@
9A0B087E2403B08400E2B470 /* XArray_tests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A0B08532402FE9B00E2B470 /* XArray_tests.cpp */; };
9A0B087F2403B08400E2B470 /* Platform.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A0B085D240300E000E2B470 /* Platform.cpp */; };
9A0B08802403B08400E2B470 /* XStringW_test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A0B08552402FE9B00E2B470 /* XStringW_test.cpp */; };
9A57C20D2418A27B0029A39F /* XUINTN.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A57C20B2418A27B0029A39F /* XUINTN.cpp */; };
9A57C20E2418A27B0029A39F /* XUINTN.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A57C20B2418A27B0029A39F /* XUINTN.cpp */; };
9A57C2112418A3560029A39F /* XUINTN_test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A57C20F2418A3550029A39F /* XUINTN_test.cpp */; };
9A57C2122418A3560029A39F /* XUINTN_test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A57C20F2418A3550029A39F /* XUINTN_test.cpp */; };
9A57C2152418A6EA0029A39F /* XStringWP.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A57C2132418A6E90029A39F /* XStringWP.cpp */; };
9A57C2162418A6EA0029A39F /* XStringWP.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A57C2132418A6E90029A39F /* XStringWP.cpp */; };
9A57C2192418B9A00029A39F /* XUINTN.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A57C20B2418A27B0029A39F /* XUINTN.cpp */; };
9A57C21A2418B9A00029A39F /* XObjArray_tests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A0B08522402FE9B00E2B470 /* XObjArray_tests.cpp */; };
9A57C21B2418B9A00029A39F /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A9223302402FD1000483CBA /* main.cpp */; };
9A57C21C2418B9A00029A39F /* printf_lite.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A0B086B24039FE700E2B470 /* printf_lite.cpp */; };
9A57C21D2418B9A00029A39F /* XStringWArray.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A0B08472402FE9300E2B470 /* XStringWArray.cpp */; };
9A57C21E2418B9A00029A39F /* XUINTN_test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A57C20F2418A3550029A39F /* XUINTN_test.cpp */; };
9A57C21F2418B9A00029A39F /* utf8Conversion.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AA05BB6240FC78D008EA4F8 /* utf8Conversion.cpp */; };
9A57C2202418B9A00029A39F /* panic.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AC780A32417DD2F005CDD5C /* panic.cpp */; };
9A57C2212418B9A00029A39F /* XStringW.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A0B08482402FE9300E2B470 /* XStringW.cpp */; };
9A57C2222418B9A00029A39F /* all_tests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A0B08512402FE9B00E2B470 /* all_tests.cpp */; };
9A57C2232418B9A00029A39F /* global_test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A0B08642403144C00E2B470 /* global_test.cpp */; };
9A57C2242418B9A00029A39F /* XToolsCommon.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A0B08492402FE9300E2B470 /* XToolsCommon.cpp */; };
9A57C2252418B9A00029A39F /* XStringWArray_test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A0B084F2402FE9B00E2B470 /* XStringWArray_test.cpp */; };
9A57C2262418B9A00029A39F /* XStringWP.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A57C2132418A6E90029A39F /* XStringWP.cpp */; };
9A57C2272418B9A00029A39F /* XArray_tests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A0B08532402FE9B00E2B470 /* XArray_tests.cpp */; };
9A57C2282418B9A00029A39F /* Platform.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A0B085D240300E000E2B470 /* Platform.cpp */; };
9A57C2292418B9A00029A39F /* XStringW_test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A0B08552402FE9B00E2B470 /* XStringW_test.cpp */; };
9A9223312402FD1000483CBA /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A9223302402FD1000483CBA /* main.cpp */; };
9AA05BB7240FC78D008EA4F8 /* utf8Conversion.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AA05BB6240FC78D008EA4F8 /* utf8Conversion.cpp */; };
9AA05BB8240FC78D008EA4F8 /* utf8Conversion.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AA05BB6240FC78D008EA4F8 /* utf8Conversion.cpp */; };
@ -47,6 +70,15 @@
);
runOnlyForDeploymentPostprocessing = 1;
};
9A57C22B2418B9A00029A39F /* CopyFiles */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = /usr/share/man/man1/;
dstSubfolderSpec = 0;
files = (
);
runOnlyForDeploymentPostprocessing = 1;
};
9A92232B2402FD1000483CBA /* CopyFiles */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
@ -82,7 +114,15 @@
9A0B086B24039FE700E2B470 /* printf_lite.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = printf_lite.cpp; path = "../../../../../Embedded/Shared/printf_lite-master/printf_lite.cpp"; sourceTree = "<group>"; };
9A0B086C24039FE700E2B470 /* printf_lite.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = printf_lite.h; path = "../../../../../Embedded/Shared/printf_lite-master/printf_lite.h"; sourceTree = "<group>"; };
9A0B08862403B08400E2B470 /* cpp_tests UTF32 */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "cpp_tests UTF32"; sourceTree = BUILT_PRODUCTS_DIR; };
9A92232D2402FD1000483CBA /* cpp_tests UTF16 */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "cpp_tests UTF16"; sourceTree = BUILT_PRODUCTS_DIR; };
9A57C20A2418A1FD0029A39F /* global_test.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = global_test.h; sourceTree = "<group>"; };
9A57C20B2418A27B0029A39F /* XUINTN.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XUINTN.cpp; sourceTree = "<group>"; };
9A57C20C2418A27B0029A39F /* XUINTN.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XUINTN.h; sourceTree = "<group>"; };
9A57C20F2418A3550029A39F /* XUINTN_test.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XUINTN_test.cpp; sourceTree = "<group>"; };
9A57C2102418A3550029A39F /* XUINTN_test.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XUINTN_test.h; sourceTree = "<group>"; };
9A57C2132418A6E90029A39F /* XStringWP.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XStringWP.cpp; sourceTree = "<group>"; };
9A57C2142418A6EA0029A39F /* XStringWP.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XStringWP.h; sourceTree = "<group>"; };
9A57C22F2418B9A00029A39F /* cpp_tests UTF16 unsigned char */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "cpp_tests UTF16 unsigned char"; sourceTree = BUILT_PRODUCTS_DIR; };
9A92232D2402FD1000483CBA /* cpp_tests UTF16 signed char */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "cpp_tests UTF16 signed char"; sourceTree = BUILT_PRODUCTS_DIR; };
9A9223302402FD1000483CBA /* main.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = "<group>"; };
9A92234D2402FD9500483CBA /* Platform.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Platform.h; sourceTree = "<group>"; };
9AA05BB6240FC78D008EA4F8 /* utf8Conversion.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = utf8Conversion.cpp; sourceTree = "<group>"; };
@ -99,6 +139,13 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
9A57C22A2418B9A00029A39F /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
9A92232A2402FD1000483CBA /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
@ -112,18 +159,22 @@
9A0B08432402FE9300E2B470 /* cpp_foundation */ = {
isa = PBXGroup;
children = (
9A0B08452402FE9300E2B470 /* XToolsCommon.h */,
9A0B08492402FE9300E2B470 /* XToolsCommon.cpp */,
9A0B08442402FE9300E2B470 /* XStringWArray.h */,
9A0B08472402FE9300E2B470 /* XStringWArray.cpp */,
9A0B08462402FE9300E2B470 /* XStringW.h */,
9A0B08482402FE9300E2B470 /* XStringW.cpp */,
9A0B084A2402FE9300E2B470 /* XArray.h */,
9A0B084B2402FE9300E2B470 /* XObjArray.h */,
9A0B086B24039FE700E2B470 /* printf_lite.cpp */,
9A0B086C24039FE700E2B470 /* printf_lite.h */,
9AA05BB6240FC78D008EA4F8 /* utf8Conversion.cpp */,
9AA05BB9240FC796008EA4F8 /* utf8Conversion.h */,
9A0B084A2402FE9300E2B470 /* XArray.h */,
9A0B084B2402FE9300E2B470 /* XObjArray.h */,
9A0B08482402FE9300E2B470 /* XStringW.cpp */,
9A0B08462402FE9300E2B470 /* XStringW.h */,
9A0B08472402FE9300E2B470 /* XStringWArray.cpp */,
9A0B08442402FE9300E2B470 /* XStringWArray.h */,
9A57C2132418A6E90029A39F /* XStringWP.cpp */,
9A57C2142418A6EA0029A39F /* XStringWP.h */,
9A0B08492402FE9300E2B470 /* XToolsCommon.cpp */,
9A0B08452402FE9300E2B470 /* XToolsCommon.h */,
9A57C20B2418A27B0029A39F /* XUINTN.cpp */,
9A57C20C2418A27B0029A39F /* XUINTN.h */,
);
name = cpp_foundation;
path = ../../rEFIt_UEFI/cpp_foundation;
@ -132,17 +183,20 @@
9A0B084C2402FE9B00E2B470 /* cpp_unit_test */ = {
isa = PBXGroup;
children = (
9A0B08642403144C00E2B470 /* global_test.cpp */,
9A0B08542402FE9B00E2B470 /* all_tests.h */,
9A0B08512402FE9B00E2B470 /* all_tests.cpp */,
9A0B08632403132300E2B470 /* XStringW_test.h */,
9A0B08552402FE9B00E2B470 /* XStringW_test.cpp */,
9A0B084D2402FE9B00E2B470 /* XStringWArray_test.h */,
9A0B084F2402FE9B00E2B470 /* XStringWArray_test.cpp */,
9A0B084E2402FE9B00E2B470 /* XArray_tests.h */,
9A0B08542402FE9B00E2B470 /* all_tests.h */,
9A0B08642403144C00E2B470 /* global_test.cpp */,
9A57C20A2418A1FD0029A39F /* global_test.h */,
9A0B08532402FE9B00E2B470 /* XArray_tests.cpp */,
9A0B08502402FE9B00E2B470 /* XObjArray_tests.h */,
9A0B084E2402FE9B00E2B470 /* XArray_tests.h */,
9A0B08522402FE9B00E2B470 /* XObjArray_tests.cpp */,
9A0B08502402FE9B00E2B470 /* XObjArray_tests.h */,
9A0B08552402FE9B00E2B470 /* XStringW_test.cpp */,
9A0B08632403132300E2B470 /* XStringW_test.h */,
9A0B084F2402FE9B00E2B470 /* XStringWArray_test.cpp */,
9A0B084D2402FE9B00E2B470 /* XStringWArray_test.h */,
9A57C20F2418A3550029A39F /* XUINTN_test.cpp */,
9A57C2102418A3550029A39F /* XUINTN_test.h */,
);
name = cpp_unit_test;
path = ../../rEFIt_UEFI/cpp_unit_test;
@ -162,8 +216,9 @@
9A92232E2402FD1000483CBA /* Products */ = {
isa = PBXGroup;
children = (
9A92232D2402FD1000483CBA /* cpp_tests UTF16 */,
9A92232D2402FD1000483CBA /* cpp_tests UTF16 signed char */,
9A0B08862403B08400E2B470 /* cpp_tests UTF32 */,
9A57C22F2418B9A00029A39F /* cpp_tests UTF16 unsigned char */,
);
name = Products;
sourceTree = "<group>";
@ -209,9 +264,26 @@
productReference = 9A0B08862403B08400E2B470 /* cpp_tests UTF32 */;
productType = "com.apple.product-type.tool";
};
9A92232C2402FD1000483CBA /* cpp_tests UTF16 */ = {
9A57C2172418B9A00029A39F /* cpp_tests UTF16 unsigned char */ = {
isa = PBXNativeTarget;
buildConfigurationList = 9A9223342402FD1000483CBA /* Build configuration list for PBXNativeTarget "cpp_tests UTF16" */;
buildConfigurationList = 9A57C22C2418B9A00029A39F /* Build configuration list for PBXNativeTarget "cpp_tests UTF16 unsigned char" */;
buildPhases = (
9A57C2182418B9A00029A39F /* Sources */,
9A57C22A2418B9A00029A39F /* Frameworks */,
9A57C22B2418B9A00029A39F /* CopyFiles */,
);
buildRules = (
);
dependencies = (
);
name = "cpp_tests UTF16 unsigned char";
productName = cpp_tests;
productReference = 9A57C22F2418B9A00029A39F /* cpp_tests UTF16 unsigned char */;
productType = "com.apple.product-type.tool";
};
9A92232C2402FD1000483CBA /* cpp_tests UTF16 signed char */ = {
isa = PBXNativeTarget;
buildConfigurationList = 9A9223342402FD1000483CBA /* Build configuration list for PBXNativeTarget "cpp_tests UTF16 signed char" */;
buildPhases = (
9A9223292402FD1000483CBA /* Sources */,
9A92232A2402FD1000483CBA /* Frameworks */,
@ -221,9 +293,9 @@
);
dependencies = (
);
name = "cpp_tests UTF16";
name = "cpp_tests UTF16 signed char";
productName = cpp_tests;
productReference = 9A92232D2402FD1000483CBA /* cpp_tests UTF16 */;
productReference = 9A92232D2402FD1000483CBA /* cpp_tests UTF16 signed char */;
productType = "com.apple.product-type.tool";
};
/* End PBXNativeTarget section */
@ -252,8 +324,9 @@
projectDirPath = "";
projectRoot = "";
targets = (
9A92232C2402FD1000483CBA /* cpp_tests UTF16 */,
9A92232C2402FD1000483CBA /* cpp_tests UTF16 signed char */,
9A0B08712403B08400E2B470 /* cpp_tests UTF32 */,
9A57C2172418B9A00029A39F /* cpp_tests UTF16 unsigned char */,
);
};
/* End PBXProject section */
@ -263,10 +336,12 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
9A57C20E2418A27B0029A39F /* XUINTN.cpp in Sources */,
9A0B08732403B08400E2B470 /* XObjArray_tests.cpp in Sources */,
9A0B08742403B08400E2B470 /* main.cpp in Sources */,
9A0B08752403B08400E2B470 /* printf_lite.cpp in Sources */,
9A0B08772403B08400E2B470 /* XStringWArray.cpp in Sources */,
9A57C2122418A3560029A39F /* XUINTN_test.cpp in Sources */,
9AA05BB8240FC78D008EA4F8 /* utf8Conversion.cpp in Sources */,
9AC780AF2417DD2F005CDD5C /* panic.cpp in Sources */,
9A0B08792403B08400E2B470 /* XStringW.cpp in Sources */,
@ -274,20 +349,47 @@
9A0B087B2403B08400E2B470 /* global_test.cpp in Sources */,
9A0B087C2403B08400E2B470 /* XToolsCommon.cpp in Sources */,
9A0B087D2403B08400E2B470 /* XStringWArray_test.cpp in Sources */,
9A57C2162418A6EA0029A39F /* XStringWP.cpp in Sources */,
9A0B087E2403B08400E2B470 /* XArray_tests.cpp in Sources */,
9A0B087F2403B08400E2B470 /* Platform.cpp in Sources */,
9A0B08802403B08400E2B470 /* XStringW_test.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
9A57C2182418B9A00029A39F /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
9A57C2192418B9A00029A39F /* XUINTN.cpp in Sources */,
9A57C21A2418B9A00029A39F /* XObjArray_tests.cpp in Sources */,
9A57C21B2418B9A00029A39F /* main.cpp in Sources */,
9A57C21C2418B9A00029A39F /* printf_lite.cpp in Sources */,
9A57C21D2418B9A00029A39F /* XStringWArray.cpp in Sources */,
9A57C21E2418B9A00029A39F /* XUINTN_test.cpp in Sources */,
9A57C21F2418B9A00029A39F /* utf8Conversion.cpp in Sources */,
9A57C2202418B9A00029A39F /* panic.cpp in Sources */,
9A57C2212418B9A00029A39F /* XStringW.cpp in Sources */,
9A57C2222418B9A00029A39F /* all_tests.cpp in Sources */,
9A57C2232418B9A00029A39F /* global_test.cpp in Sources */,
9A57C2242418B9A00029A39F /* XToolsCommon.cpp in Sources */,
9A57C2252418B9A00029A39F /* XStringWArray_test.cpp in Sources */,
9A57C2262418B9A00029A39F /* XStringWP.cpp in Sources */,
9A57C2272418B9A00029A39F /* XArray_tests.cpp in Sources */,
9A57C2282418B9A00029A39F /* Platform.cpp in Sources */,
9A57C2292418B9A00029A39F /* XStringW_test.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
9A9223292402FD1000483CBA /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
9A57C20D2418A27B0029A39F /* XUINTN.cpp in Sources */,
9A0B085A2402FF8400E2B470 /* XObjArray_tests.cpp in Sources */,
9A9223312402FD1000483CBA /* main.cpp in Sources */,
9A0B086D24039FE700E2B470 /* printf_lite.cpp in Sources */,
9A0B08562402FF7700E2B470 /* XStringWArray.cpp in Sources */,
9A57C2112418A3560029A39F /* XUINTN_test.cpp in Sources */,
9AA05BB7240FC78D008EA4F8 /* utf8Conversion.cpp in Sources */,
9AC780AE2417DD2F005CDD5C /* panic.cpp in Sources */,
9A0B085F240308E400E2B470 /* XStringW.cpp in Sources */,
@ -295,6 +397,7 @@
9A0B08662403144C00E2B470 /* global_test.cpp in Sources */,
9A0B08572402FF7A00E2B470 /* XToolsCommon.cpp in Sources */,
9A0B08582402FF7F00E2B470 /* XStringWArray_test.cpp in Sources */,
9A57C2152418A6EA0029A39F /* XStringWP.cpp in Sources */,
9A0B085B2402FF8700E2B470 /* XArray_tests.cpp in Sources */,
9A0B085E240300E000E2B470 /* Platform.cpp in Sources */,
9A0B085C2402FF8B00E2B470 /* XStringW_test.cpp in Sources */,
@ -308,6 +411,7 @@
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
GCC_PREPROCESSOR_DEFINITIONS = JIEF_DEBUG;
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Debug;
@ -320,6 +424,25 @@
};
name = Release;
};
9A57C22D2418B9A00029A39F /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
GCC_CHAR_IS_UNSIGNED_CHAR = YES;
GCC_PREPROCESSOR_DEFINITIONS = JIEF_DEBUG;
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Debug;
};
9A57C22E2418B9A00029A39F /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
GCC_CHAR_IS_UNSIGNED_CHAR = YES;
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Release;
};
9A9223322402FD1000483CBA /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
@ -331,27 +454,38 @@
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_ENABLE_OBJC_WEAK = YES;
CLANG_WARN_ASSIGN_ENUM = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_CXX0X_EXTENSIONS = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_FLOAT_CONVERSION = YES;
CLANG_WARN_IMPLICIT_SIGN_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_INTERFACE_IVARS = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_MISSING_PROPERTY_SYNTHESIS = YES;
CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES_AGGRESSIVE;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_SEMICOLON_BEFORE_METHOD_BODY = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CLANG_WARN__EXIT_TIME_DESTRUCTORS = NO;
CODE_SIGN_IDENTITY = "-";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = dwarf;
@ -362,11 +496,27 @@
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = "";
GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES;
GCC_TREAT_INCOMPATIBLE_POINTER_TYPE_WARNINGS_AS_ERRORS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES;
GCC_WARN_ABOUT_MISSING_NEWLINE = YES;
GCC_WARN_ABOUT_MISSING_PROTOTYPES = NO;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_FOUR_CHARACTER_CONSTANTS = YES;
GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES;
GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES;
GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES;
GCC_WARN_PEDANTIC = YES;
GCC_WARN_SHADOW = YES;
GCC_WARN_SIGN_COMPARE = YES;
GCC_WARN_STRICT_SELECTOR_MATCH = YES;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNKNOWN_PRAGMAS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_LABEL = YES;
GCC_WARN_UNUSED_PARAMETER = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
HEADER_SEARCH_PATHS = "$(PROJECT_DIR)/src";
MACOSX_DEPLOYMENT_TARGET = 10.13;
@ -393,27 +543,38 @@
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_ENABLE_OBJC_WEAK = YES;
CLANG_WARN_ASSIGN_ENUM = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_CXX0X_EXTENSIONS = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_FLOAT_CONVERSION = YES;
CLANG_WARN_IMPLICIT_SIGN_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_INTERFACE_IVARS = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_MISSING_PROPERTY_SYNTHESIS = YES;
CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES_AGGRESSIVE;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_SEMICOLON_BEFORE_METHOD_BODY = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CLANG_WARN__EXIT_TIME_DESTRUCTORS = NO;
CODE_SIGN_IDENTITY = "-";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
@ -422,11 +583,27 @@
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_NO_COMMON_BLOCKS = YES;
GCC_PREPROCESSOR_DEFINITIONS = "";
GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES;
GCC_TREAT_INCOMPATIBLE_POINTER_TYPE_WARNINGS_AS_ERRORS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES;
GCC_WARN_ABOUT_MISSING_NEWLINE = YES;
GCC_WARN_ABOUT_MISSING_PROTOTYPES = NO;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_FOUR_CHARACTER_CONSTANTS = YES;
GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES;
GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES;
GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES;
GCC_WARN_PEDANTIC = YES;
GCC_WARN_SHADOW = YES;
GCC_WARN_SIGN_COMPARE = YES;
GCC_WARN_STRICT_SELECTOR_MATCH = YES;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNKNOWN_PRAGMAS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_LABEL = YES;
GCC_WARN_UNUSED_PARAMETER = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
HEADER_SEARCH_PATHS = "$(PROJECT_DIR)/src";
MACOSX_DEPLOYMENT_TARGET = 10.13;
@ -470,6 +647,15 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
9A57C22C2418B9A00029A39F /* Build configuration list for PBXNativeTarget "cpp_tests UTF16 unsigned char" */ = {
isa = XCConfigurationList;
buildConfigurations = (
9A57C22D2418B9A00029A39F /* Debug */,
9A57C22E2418B9A00029A39F /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
9A9223282402FD1000483CBA /* Build configuration list for PBXProject "cpp_tests" */ = {
isa = XCConfigurationList;
buildConfigurations = (
@ -479,7 +665,7 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
9A9223342402FD1000483CBA /* Build configuration list for PBXNativeTarget "cpp_tests UTF16" */ = {
9A9223342402FD1000483CBA /* Build configuration list for PBXNativeTarget "cpp_tests UTF16 signed char" */ = {
isa = XCConfigurationList;
buildConfigurations = (
9A9223352402FD1000483CBA /* Debug */,

View File

@ -15,8 +15,8 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "9A92232C2402FD1000483CBA"
BuildableName = "cpp_tests UTF16"
BlueprintName = "cpp_tests UTF16"
BuildableName = "cpp_tests UTF16 signed char"
BlueprintName = "cpp_tests UTF16 signed char"
ReferencedContainer = "container:cpp_tests.xcodeproj">
</BuildableReference>
</BuildActionEntry>
@ -33,8 +33,8 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "9A92232C2402FD1000483CBA"
BuildableName = "cpp_tests UTF16"
BlueprintName = "cpp_tests UTF16"
BuildableName = "cpp_tests UTF16 signed char"
BlueprintName = "cpp_tests UTF16 signed char"
ReferencedContainer = "container:cpp_tests.xcodeproj">
</BuildableReference>
</MacroExpansion>
@ -58,8 +58,8 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "9A92232C2402FD1000483CBA"
BuildableName = "cpp_tests UTF16"
BlueprintName = "cpp_tests UTF16"
BuildableName = "cpp_tests UTF16 signed char"
BlueprintName = "cpp_tests UTF16 signed char"
ReferencedContainer = "container:cpp_tests.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
@ -102,8 +102,8 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "9A92232C2402FD1000483CBA"
BuildableName = "cpp_tests UTF16"
BlueprintName = "cpp_tests UTF16"
BuildableName = "cpp_tests UTF16 signed char"
BlueprintName = "cpp_tests UTF16 signed char"
ReferencedContainer = "container:cpp_tests.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>

View File

@ -33,8 +33,8 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "9A92232C2402FD1000483CBA"
BuildableName = "cpp_tests UTF16"
BlueprintName = "cpp_tests UTF16"
BuildableName = "cpp_tests UTF16 signed char"
BlueprintName = "cpp_tests UTF16 signed char"
ReferencedContainer = "container:cpp_tests.xcodeproj">
</BuildableReference>
</MacroExpansion>

View File

@ -28,6 +28,7 @@ void CpuDeadLoop(void)
void DebugLog(int DebugMode, const char *FormatString, ...)
{
(void)DebugMode;
va_list va;
va_start(va, FormatString);
vprintf(FormatString, va);
@ -42,6 +43,7 @@ void* AllocatePool(UINTN AllocationSize)
}
void* ReallocatePool(UINTN OldSize, UINTN NewSize, void* OldBuffer)
{
(void)OldSize;
if ( !OldBuffer ) return AllocatePool(NewSize);
return realloc(OldBuffer, NewSize);
}
@ -62,9 +64,9 @@ void PauseForKey(const wchar_t* msg)
getchar();
}
int AsciiStrLen(const char* String)
UINTN AsciiStrLen(const char* String)
{
return (int)strlen(String);
return (UINTN)strlen(String);
}
#if __WCHAR_MAX__ <= 0xFFFFu
@ -86,7 +88,7 @@ int is_high_surrogate(char16_t uc) { return (uc & 0xfffffc00) == 0xd800; }
int is_low_surrogate(char16_t uc) { return (uc & 0xfffffc00) == 0xdc00; }
char32_t surrogate_to_utf32(char16_t high, char16_t low) {
return (high << 10) + low - 0x35fdc00;
return char32_t((high << 10) + low - 0x35fdc00); // Safe cast, it fits in 32 bits
}
void convert_utf16_to_utf32(const char16_t* input, size_t input_size, std::vector<char32_t>* output)
@ -111,12 +113,12 @@ void convert_utf16_to_utf32(const char16_t* input, size_t input_size, std::vecto
#endif
unsigned int StrLen(const wchar_t* String)
UINTN StrLen(const wchar_t* String)
{
// wcslen seems not to work if sizeof(wchar_t) == 2
const wchar_t* p;
for ( p = String ; *p ; p++ );
return (int)(p-String);
return (UINTN)(p-String);
}
int StrCmp(const wchar_t* FirstString, const wchar_t* SecondString)

View File

@ -11,14 +11,34 @@
#include <limits.h>
#include <stdarg.h>
#include <stdint.h>
#define UINTN unsigned long long
#define MAX_UINTN ULONG_MAX
#define BOOLEAN bool
#define INTN int
#define INTN int32_t
#define CHAR8 unsigned char
#define CHAR16 char16_t
#define UINT8 uint8_t
#define UINT16 uint16_t
#define UINT32 uint32_t
#define UINT64 uint64_t
#define INT8 int8_t
#define INT16 int16_t
#define INT32 int32_t
#define INT64 int64_t
#define MAX_INT8 ((INT8)0x7F)
#define MAX_UINT8 ((UINT8)0xFF)
#define MAX_INT16 ((INT16)0x7FFF)
#define MAX_UINT16 ((UINT16)0xFFFF)
#define MAX_INT32 ((INT32)0x7FFFFFFF)
#define MAX_UINT32 ((UINT32)0xFFFFFFFF)
#define MAX_INT64 ((INT64)0x7FFFFFFFFFFFFFFFULL)
#define MAX_UINT64 ((UINT64)0xFFFFFFFFFFFFFFFFULL)
#define IN
#define VA_LIST va_list
@ -39,8 +59,8 @@ void CopyMem(void *Destination, void *Source, UINTN Length);
void PauseForKey(const wchar_t* msg);
int StrCmp(const wchar_t* FirstString, const wchar_t* SecondString);
int StrnCmp(const wchar_t* FirstString, const wchar_t* SecondString, UINTN Length);
unsigned int StrLen(const wchar_t* String);
int AsciiStrLen(const char* String);
UINTN StrLen(const wchar_t* String);
UINTN AsciiStrLen(const char* String);

View File

@ -14,10 +14,18 @@
extern "C" int main(int argc, const char * argv[])
{
(void)argc;
(void)argv;
setlocale(LC_ALL, "en_US"); // to allow printf unicode char
printf("sizeof(wchar_t)=%lu\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("%zu\n", (size_t)MAX_UINT64);
printf("%zd\n", (size_t)MAX_UINT64);
return all_tests();
}

View File

@ -622,7 +622,9 @@ void PreCleanupRSDT()
// English: If the RSDT address of the XSDT address and the tail of the RSDT crawls onto the XSDT, then we
// trim the RSDT tail before the XSDT starts
if ((UINTN)Rsdt < (UINTN)Xsdt && (UINTN)Rsdt + Rsdt->Header.Length > (UINTN)Xsdt) {
Rsdt->Header.Length = ((UINTN)Xsdt - (UINTN)Rsdt) & ~3;
UINTN v = ((UINTN)Xsdt - (UINTN)Rsdt) & ~3;
if ( v > MAX_UINT32 ) panic("((UINTN)Xsdt - (UINTN)Rsdt) & ~3 > MAX_UINT32");
Rsdt->Header.Length = (UINT32)v;
DBG("Cropped Rsdt->Header.Length=%d\n", (UINT32)Rsdt->Header.Length);
}

View File

@ -5281,7 +5281,8 @@ VOID RenameDevices(UINT8* table)
CHAR8 *Replace;
CHAR8 *Find;
INTN i, k;
INTN i;
INTN k=0; // Cland complain about possible use uninitialised. Not true, but I don't like warnings.
UINTN index;
INTN size;
UINTN len = ((EFI_ACPI_DESCRIPTION_HEADER*)table)->Length;

View File

@ -101,7 +101,7 @@ UINT32 pci_config_read32(pci_dt_t *PciDt, UINT8 reg)
Status = PciIo->Pci.Read (
PciIo,
EfiPciIoWidthUint32,
(UINT64)(reg & ~3),
(UINT32)(reg & ~3),
1,
&res
);

View File

@ -591,12 +591,12 @@ EFI_STATUS LoadKexts(IN LOADER_ENTRY *Entry)
#define DO8(buf,i) DO4(buf,i); DO4(buf,i+4);
#define DO16(buf) DO8(buf,0); DO8(buf,8);
static unsigned long Adler32(unsigned char *buf, long len)
static UINT32 Adler32(unsigned char *buf, long len)
{
unsigned long s1 = 1; // adler & 0xffff;
unsigned long s2 = 0; // (adler >> 16) & 0xffff;
unsigned long result;
int k;
long k;
while (len > 0) {
k = len < NMAX ? len : NMAX;
@ -615,7 +615,7 @@ static unsigned long Adler32(unsigned char *buf, long len)
}
result = (s2 << 16) | s1;
// result is in big endian
return result;
return (UINT32)result;
}
typedef struct {

View File

@ -870,7 +870,7 @@ EFI_STATUS FixDataMatchingTag( CHAR8* buffer, CONST CHAR8* tag, UINT32* lenPtr)
buffer[start + stop] = '\0';
*lenPtr = start + length;
if (*lenPtr == (UINTN)-1) { // Why is this test. -1 is UINTN_MAX.
if (*lenPtr == (__typeof(*lenPtr))-1) { // Why is this test. -1 is UINTN_MAX.
return EFI_UNSUPPORTED;
}

View File

@ -59,6 +59,8 @@ class XArray
const TYPE& ElementAt(xsize nIndex) const;
TYPE& ElementAt(xsize nIndex);
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); }
@ -222,6 +224,38 @@ const TYPE& XArray<TYPE>::ElementAt(xsize index) const
return m_data[index];
}
/* ElementAt() */
template<class TYPE>
TYPE &XArray<TYPE>::ElementAt(int index)
{
// #ifdef _DEBUG
if ( index < 0 ) {
panic("XArray::ElementAt(int) -> Operator [] : index < 0");
}
if ( (unsigned int)index >= m_len ) { // cast safe, index > 0
DebugLog(2, "XArray::ElementAt(xsize) -> Operator [] : index > m_len");
panic();
}
// #endif
return m_data[index];
}
/* ElementAt() */
template<class TYPE>
const TYPE& XArray<TYPE>::ElementAt(int index) const
{
// #ifdef _DEBUG
if ( index < 0 ) {
panic("XArray::ElementAt(int) const -> Operator [] : index < 0");
}
if ( (unsigned int)index >= m_len ) { // cast ok as index > 0. Ideally cast would be like '(unsigned __typeof__(index))'
DebugLog(2, "XArray::ElementAt(xsize) const -> Operator [] : index > m_len");
panic();
}
// #endif
return m_data[index];
}
/* Add(xsize) */
template<class TYPE>
xsize XArray<TYPE>::AddUninitialized(xsize count)

View File

@ -44,8 +44,8 @@ class XObjArrayNC
virtual ~XObjArrayNC();
protected:
XObjArrayNC(const XObjArrayNC<TYPE> &anObjArrayNC) { DebugLog(2, "Intentionally not defined"); panic(); }
const XObjArrayNC<TYPE> &operator =(const XObjArrayNC<TYPE> &anObjArrayNC) { DebugLog(2, "Intentionally not defined"); panic(); }
XObjArrayNC(const XObjArrayNC<TYPE> &anObjArrayNC) { (void)anObjArrayNC; DebugLog(2, "Intentionally not defined"); panic(); }
const XObjArrayNC<TYPE> &operator =(const XObjArrayNC<TYPE> &anObjArrayNC) { (void)anObjArrayNC; DebugLog(2, "Intentionally not defined"); panic(); }
xsize _getLen() const { return _Len; }
public:

View File

@ -104,10 +104,9 @@ const XStringW& XStringW::takeValueFrom(const wchar_t* S)
const XStringW& XStringW::takeValueFrom(const char* S)
{
UINTN asciiStrLen = AsciiStrLen(S);
xsize newLen = StrLenInWChar(S, asciiStrLen);
xsize newLen = StrLenInWChar(S);
Init(newLen);
utf8ToWChar(m_data, m_allocatedSize+1, S, asciiStrLen); // m_size doesn't count the NULL terminator
utf8ToWChar(m_data, m_allocatedSize+1, S); // m_size doesn't count the NULL terminator
SetLength(newLen);
return *this;
}

View File

@ -40,7 +40,12 @@ protected:
public:
const wchar_t *data(UINTN ui=0) const { return m_data+ui; } // do not multiply by sizeof(wchar_t), it's done by the compiler.
const wchar_t *data(INTN i) const { if ( i<0 ) panic("const wchar_t *data(INTN i=0) const -> i < 0"); return m_data+i; } // do not multiply by sizeof(wchar_t), it's done by the compiler.
// const wchar_t *data(int i=0) const { if ( i<0 ) panic("const wchar_t *data(int i=0) const -> i < 0"); return m_data+i; } // do not multiply by sizeof(wchar_t), it's done by the compiler.
wchar_t *data(UINTN ui=0) { return m_data+ui; } // do not multiply by sizeof(wchar_t), it's done by the compiler.
wchar_t *data(INTN i) { if ( i<0 ) panic("wchar_t *data(INTN i=0) -> i < 0"); return m_data+i; } // do not multiply by sizeof(wchar_t), it's done by the compiler.
// wchar_t *data(int i) { if ( i<0 ) panic("wchar_t *data(int i=0) -> i < 0"); return m_data+i; } // do not multiply by sizeof(wchar_t), it's done by the compiler.
wchar_t *dataWithSizeMin(UINTN pos, UINTN sizeMin, UINTN nGrowBy=XStringWGrowByDefault) { CheckSize(sizeMin, nGrowBy); return data(pos); }
UINTN length() const { return m_len; }
@ -49,7 +54,7 @@ public:
void SetLength(UINTN len);
const wchar_t* s() { return m_data; }
/* IsNull ? */
/* Empty ? */
void setEmpty() { m_len = 0; }
bool isEmpty() const { return size() == 0; }
// bool IsNull() const { return size() == 0 ; }

View File

@ -40,26 +40,12 @@ DBG("Constructor(const wchar_t *S) : %s, StrLen(S)=%d\n", S, StrLen(S));
StrCpy(S);
}
//XStringW::XStringW(const wchar_t *S, UINTN count)
//{
//DBG("Constructor(const wchar_t *S, UINTN count) : %s, %d\n", S, count);
// Init(count);
// StrnCpy(S, count);
//}
//
//XStringW::XStringW(const wchar_t aChar)
//{
//DBG("Constructor(const wchar_t aChar)\n");
// Init(1);
// StrnCpy(&aChar, 1);
//}
XStringWP::XStringWP(const char* S)
{
DBG("Constructor(const char* S)\n");
xsize newLen = StrLenInWChar(S, AsciiStrLen(S));
xsize newLen = StrLenInWChar(S);
Init(newLen);
utf8ToWChar(m_data, m_allocatedSize+1, S, AsciiStrLen(S)); // m_size doesn't count the NULL terminator
utf8ToWChar(m_data, m_allocatedSize+1, S); // m_size doesn't count the NULL terminator
SetLength(newLen);
}

View File

@ -24,13 +24,8 @@ protected:
public:
XStringWP() : XStringWP_super() {};
XStringWP(const wchar_t *);
// XStringWP(const wchar_t* S, UINTN count);
// XStringWP(const wchar_t);
XStringWP(const char*);
// ~XStringWP();
public:
/* XStringWP(const char*, ...); // Cannot define this ctor although it would be handy. Problem is confusion with XStringWP(const char*) as ... can mean 0 arg. */
};

View File

@ -18,6 +18,7 @@ extern xsize XBufferGrowByDefault;
#ifdef CLOVER_BUILD
extern "C" {
#include <ProcessorBind.h>
#include <Library/BaseLib.h> // for StrCmp
#include <Library/MemoryAllocationLib.h>
#include <Library/BaseMemoryLib.h> // for CopyMen

View File

@ -0,0 +1,94 @@
////*************************************************************************************************
////*************************************************************************************************
////
//// STRING
////
//// Developed by jief666, from 1997.
////
////*************************************************************************************************
////*************************************************************************************************
//
//#if 0
//#define DBG(...) DebugLog(2, __VA_ARGS__)
//#else
//#define DBG(...)
//#endif
//
//#include "XToolsCommon.h"
//#include "XUINTN.h"
//
////xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
//// Constructor
////xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
//
//XStringW::XStringW()
//{
//DBG("Construteur\n");
// Init();
//}
//
//XStringW::XStringW(const XStringW &aString)
//{
//DBG("Constructor(const XStringW &aString) : %s\n", aString.data());
// Init(aString.length());
// StrnCpy(aString.data(), aString.length());
//}
////
////XStringW::XStringW(const wchar_t *S)
////{
//// if ( !S ) {
//// DebugLog(2, "XStringW(const wchar_t *S) called with NULL. Use setEmpty()\n");
//// panic();
//// }
////DBG("Constructor(const wchar_t *S) : %s, StrLen(S)=%d\n", S, StrLen(S));
//// Init(StrLen(S));
//// StrCpy(S);
////}
////
////XStringW::XStringW(const wchar_t *S, UINTN count)
////{
////DBG("Constructor(const wchar_t *S, UINTN count) : %s, %d\n", S, count);
//// Init(count);
//// StrnCpy(S, count);
////}
////
////XStringW::XStringW(const wchar_t aChar)
////{
////DBG("Constructor(const wchar_t aChar)\n");
//// Init(1);
//// StrnCpy(&aChar, 1);
////}
////
////XStringW::XStringW(const char* S)
////{
////DBG("Constructor(const char* S)\n");
//// xsize newLen = StrLenInWChar(S, AsciiStrLen(S));
//// Init(newLen);
//// utf8ToWChar(m_data, m_allocatedSize+1, S, AsciiStrLen(S)); // m_size doesn't count the NULL terminator
//// SetLength(newLen);
////}
//
//const XStringW& XStringW::takeValueFrom(const wchar_t* S)
//{
// if ( !S ) {
// DebugLog(2, "takeValueFrom(const wchar_t* S) called with NULL. Use setEmpty()\n");
// panic();
// }
// Init(StrLen(S));
// StrCpy(S);
// return *this;
//}
//
//const XStringW& XStringW::takeValueFrom(const char* S)
//{
// UINTN asciiStrLen = AsciiStrLen(S);
// xsize newLen = StrLenInWChar(S, asciiStrLen);
// Init(newLen);
// utf8ToWChar(m_data, m_allocatedSize+1, S, asciiStrLen); // m_size doesn't count the NULL terminator
// SetLength(newLen);
// return *this;
//}
//
////xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
////
////xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

View File

@ -0,0 +1,73 @@
//*************************************************************************************************
//*************************************************************************************************
//
// STRING
//
//*************************************************************************************************
//*************************************************************************************************
#if !defined(__XUINTN_H__)
#define __XUINTN_H__
#include "XToolsCommon.h"
class XUINTN
{
public:
UINTN m_value;
public:
XUINTN() : m_value(0) {};
XUINTN(UINT64 v) : m_value(v) {};
XUINTN(unsigned int v) : m_value(v) {};
XUINTN(INT64 v) { if ( v < 0 ) panic("XUINTN(INT64 v) -> value is < 0"); m_value=(UINT64)v; };
XUINTN(int v) { if ( v < 0 ) panic("XUINTN(int v) -> value is < 0"); m_value=(UINT64)v; };
bool operator != (UINT8 u) const { return m_value != u; };
bool operator != (UINT16 u) const { return m_value != u; };
bool operator != (UINT32 u) const { return m_value != u; };
bool operator != (UINT64 u) const { return m_value != u; };
bool operator != (INT8 i) const { if ( i < 0 ) return false; return m_value != (UINT8)i; };
bool operator != (INT16 i) const { if ( i < 0 ) return false; return m_value != (UINT16)i; };
bool operator != (INT32 i) const { if ( i < 0 ) return false; return m_value != (UINT32)i; };
bool operator != (INT64 i) const { if ( i < 0 ) return false; return m_value != (UINT64)i; };
bool operator == (UINT8 u) const { return m_value == u; };
bool operator == (UINT16 u) const { return m_value == u; };
bool operator == (UINT32 u) const { return m_value == u; };
bool operator == (UINT64 u) const { return m_value == u; };
bool operator == (INT8 i) const { if ( i < 0 ) return false; return m_value == (UINT8)i; };
bool operator == (INT16 i) const { if ( i < 0 ) return false; return m_value == (UINT16)i; };
bool operator == (INT32 i) const { if ( i < 0 ) return false; return m_value == (UINT32)i; };
bool operator == (INT64 i) const { if ( i < 0 ) return false; return m_value == (UINT64)i; };
/* seems not needed to define all type for operator + and -, contrary to the other operators. */
// UINTN operator + (int i) const { if ( (i>=0 && value + (unsigned int)i < value) || (i<0 && value + (unsigned int)i > value)) panic("UINTN operator + (int i) const -> overflow"); return (UINTN)(value + (unsigned int)i); };
// UINTN operator + (UINT8 u) const { if ( value + u < value ) panic("UINTN operator + (UINT8 u) -> overflow"); return value + u; };
// UINTN operator + (UINT16 u) const { if ( value + u < value ) panic("UINTN operator + (UINT16 u) -> overflow"); return value + u; };
// UINTN operator + (UINT32 u) const { if ( value + u < value ) panic("UINTN operator + (UINT32 u) -> overflow"); return value + u; };
UINTN operator + (UINT64 u) const { if ( m_value + u < m_value ) panic("UINTN operator + (UINT64 u) -> overflow"); return m_value + u; };
UINTN operator - (UINT64 u) const { if ( m_value - u > m_value ) panic("UINTN operator - (UINT64 u) -> overflow"); return m_value - u; };
UINTN operator > (UINT64 u) const { return m_value > u; };
UINTN operator >= (UINT64 u) const { return m_value >= u; };
UINTN operator < (UINT64 u) const { return m_value < u; };
UINTN operator <= (UINT64 u) const { return m_value <= u; };
explicit operator UINT8() const { if ( m_value > MAX_UINT8 ) panic("operator UINT8() const -> value too big to be casted as UINT8"); return (UINT8)m_value; };
explicit operator UINT16() const { if ( m_value > MAX_UINT16 ) panic("operator UINT16() const -> value too big to be casted as UINT16"); return (UINT16)m_value; };
explicit operator UINT32() const { if ( m_value > MAX_UINT32 ) panic("operator UINT32() const -> value too big to be casted as UINT32"); return (UINT32)m_value; };
explicit operator UINT64() const { return m_value; };
explicit operator INT8() const { if ( m_value > MAX_INT8 ) panic("operator INT8() const -> value too big to be casted as INT8"); return (INT8)m_value; };
explicit operator INT16() const { if ( m_value > MAX_INT16 ) panic("operator INT16() const -> value too big to be casted as INT16"); return (INT16)m_value; };
explicit operator INT32() const { if ( m_value > MAX_INT32 ) panic("operator INT32() const -> value too big to be casted as INT32"); return (INT32)m_value; };
explicit operator INT64() const { if ( m_value > MAX_INT64 ) panic("operator INT64() const -> value too big to be casted as INT64"); return (INT64)m_value; };
};
#endif

View File

@ -692,8 +692,8 @@ static void printf_handle_format_char(char c, VALIST_PARAM_TYPE valist, PrintfPa
case 'c':
#if PRINTF_OUTPUT_FORMAT_UNICODE == 1 && PRINTF_UTF8_SUPPORT == 1
if ( printfParams->l_modifier == 0 ) {
char c1 = (char)va_arg(VALIST_ACCESS(valist), int);
print_char((wchar_t)c1, printfParams); // 'char' is promoted to 'int' when passed through '...'
int c1 = (char)va_arg(VALIST_ACCESS(valist), int);
print_char((char)c1, printfParams); // 'char' is promoted to 'int' when passed through '...'
printfParams->inDirective = 0;
}else
#endif

View File

@ -15,7 +15,7 @@
#define size_t UINTN
size_t StrLenInWChar(const char *s, size_t src_len)
size_t StrLenInWChar(const char *s)
{
size_t dst_len = 0;
@ -49,27 +49,27 @@ size_t StrLenInWChar(const char *s, size_t src_len)
continue;
}
/* 4-byte code */
c = (*s & 0x7) << 18;
c |= (*(s+1) & 0x3f) << 12;
c |= (*(s+2) & 0x3f) << 6;
c = char32_t(((unsigned char)(*s) & 0x7) << 18); // & result type is int. We know it fits in 32 bits. Safe to cast to char32_t
c |= char32_t((*(s+1) & 0x3f) << 12);
c |= char32_t((*(s+2) & 0x3f) << 6);
c |= *(s+3) & 0x3f;
s += 4;
} else {
/* 3-byte code */
c = (*s & 0xf) << 12;
c |= (*(s+1) & 0x3f) << 6;
c = char32_t((*s & 0xf) << 12);
c |= char32_t((*(s+1) & 0x3f) << 6);
c |= *(s+2) & 0x3f;
s += 3;
}
} else {
/* 2-byte code */
c = (*s & 0x1f) << 6;
c = char32_t((*s & 0x1f) << 6);
c |= *(s+1) & 0x3f;
s += 2;
}
} else {
/* 1-byte code */
c = *s;
c = (unsigned char)(*s); // in case we compiled with signed char
s += 1;
}
#if __WCHAR_MAX__ > 0xFFFFu
@ -99,7 +99,7 @@ size_t StrLenInWChar(const char *s, size_t src_len)
size_t utf8ToWChar(wchar_t* dst, size_t dst_max_len, const char *s, size_t src_len)
size_t utf8ToWChar(wchar_t* dst, size_t dst_max_len, const char *s)
{
if ( dst_max_len == 0 ) return 0;
dst_max_len -= 1;
@ -136,27 +136,27 @@ size_t utf8ToWChar(wchar_t* dst, size_t dst_max_len, const char *s, size_t src_
continue;
}
/* 4-byte code */
c = (*s & 0x7) << 18;
c |= (*(s+1) & 0x3f) << 12;
c |= (*(s+2) & 0x3f) << 6;
c = char32_t((*s & 0x7) << 18); // & result type is int. We know it fits in 32 bits. Safe to cast to char32_t
c |= char32_t((*(s+1) & 0x3f) << 12);
c |= char32_t((*(s+2) & 0x3f) << 6);
c |= *(s+3) & 0x3f;
s += 4;
} else {
/* 3-byte code */
c = (*s & 0xf) << 12;
c |= (*(s+1) & 0x3f) << 6;
c = char32_t((*s & 0xf) << 12);
c |= char32_t((*(s+1) & 0x3f) << 6);
c |= *(s+2) & 0x3f;
s += 3;
}
} else {
/* 2-byte code */
c = (*s & 0x1f) << 6;
c = char32_t((*s & 0x1f) << 6);
c |= *(s+1) & 0x3f;
s += 2;
}
} else {
/* 1-byte code */
c = *s;
c = (unsigned char)(*s); // in case we compiled with signed char
s += 1;
}
#if __WCHAR_MAX__ > 0xFFFFu

View File

@ -8,7 +8,7 @@
#define utf816Conversion_hpp
UINTN StrLenInWChar(const char *src, UINTN src_len);
UINTN utf8ToWChar(wchar_t* dst, UINTN dst_max_len, const char *s, UINTN src_len);
UINTN StrLenInWChar(const char *src);
UINTN utf8ToWChar(wchar_t* dst, UINTN dst_max_len, const char *s);
#endif /* utf816Conversion_hpp */

View File

@ -0,0 +1,282 @@
#include <Platform.h>
#include "../cpp_foundation/XUINTN.h"
#include "../cpp_foundation/XStringWP.h"
#include <stdio.h>
#define CHECK_CTOR_FAIL(value, code) \
{ \
stop_at_panic = false; \
i_have_panicked = false; \
XUINTN xu(value); \
if ( !i_have_panicked ) return code; \
stop_at_panic = true; \
i_have_panicked = false; \
}
#define CHECK_CTOR_8_16_32_64_int_FAIL(code) \
{ \
CHECK_CTOR_FAIL((INT8)-10, code); \
CHECK_CTOR_FAIL((INT16)-10, code+1); \
CHECK_CTOR_FAIL((INT32)-10, code+2); \
CHECK_CTOR_FAIL((INT64)-10, code+3); \
CHECK_CTOR_FAIL((int)-10, code+4); \
}
// return code..code+3
#define CHECK_EQUAL_EQUAL_OPERATOR_OK_(xu, type, value, code) \
{ \
type u = (value); \
if ( !(xu == u) ) return code; \
if ( !(xu.operator ==(u)) ) return code+1; \
if ( xu != u ) return code+2; \
if ( xu.operator !=(u) ) return code+3; \
}
// return code..code+33
#define CHECK_EQUAL_EQUAL_OPERATOR_8_16_32_64(type_root, value, code) \
{ \
XUINTN xu(145); \
\
if ( (value) < MAX_##type_root##8 ) { xu = (type_root##8)(value); CHECK_EQUAL_EQUAL_OPERATOR_OK_(xu, type_root##8, (type_root##8)(value), code); } \
\
if ( (value) < MAX_##type_root##16 ) { xu = (type_root##16)(value); CHECK_EQUAL_EQUAL_OPERATOR_OK_(xu, type_root##16, (type_root##16)(value), code+10); } \
\
if ( (value) < MAX_##type_root##32 ) { xu = (type_root##32)(value); CHECK_EQUAL_EQUAL_OPERATOR_OK_(xu, type_root##32, (type_root##32)(value), code+20); } \
\
if ( (value) < MAX_##type_root##64 ) { xu = (type_root##64)(value); CHECK_EQUAL_EQUAL_OPERATOR_OK_(xu, type_root##64, (type_root##64)(value), code+30); } \
}
// return code..code+7
#define CHECK_EQUAL_EQUAL_OPERATOR_FAIL(xu, type, value, code) \
{ \
type u = (value); \
\
stop_at_panic = false; \
i_have_panicked = false; \
if ( xu == u ) ; \
if ( !i_have_panicked ) return code+1; \
i_have_panicked = false; \
if ( xu.operator ==(u) ) ; \
if ( !i_have_panicked ) return code+3; \
i_have_panicked = false; \
if ( xu != u ) ; \
if ( !i_have_panicked ) return code+5; \
i_have_panicked = false; \
if ( xu.operator !=(u) ) ; \
if ( !i_have_panicked ) return code+7; \
stop_at_panic = true; \
i_have_panicked = false; \
}
// return code..code+33
#define CHECK_PLUS_27_OPERATOR(type_root, type, value, code) \
{ \
XUINTN xu(27); \
XUINTN xu2(27); \
xu2 = xu + (type)(value)-1; \
if ( xu2.m_value != (UINTN)(value) + 27-1 ) return code; \
}
// return code..code+333
#define CHECK_ALL_PLUS_OPERATOR(type_root, code) \
{ \
CHECK_PLUS_27_OPERATOR(type_root, type_root##8, MAX_##type_root##8-27, code) \
CHECK_PLUS_27_OPERATOR(type_root, type_root##16, MAX_##type_root##16-27, code+100) \
CHECK_PLUS_27_OPERATOR(type_root, type_root##32, MAX_##type_root##32-27, code+200) \
CHECK_PLUS_27_OPERATOR(type_root, type_root##64, MAX_##type_root##64-27, code+300) \
}
// return code..code+33
#define CHECK_MINUS_OPERATOR(type_root, type, value, code) \
{ \
XUINTN xu(MAX_##type); \
XUINTN xu2(0); \
xu2 = xu - (type)(value); \
if ( xu2.m_value != (UINTN)MAX_##type - (value) ) return code; \
}
// return code..code+333
#define CHECK_ALL_MINUS_OPERATOR(type_root, code) \
{ \
CHECK_MINUS_OPERATOR(type_root, type_root##8, 45, code) \
CHECK_MINUS_OPERATOR(type_root, type_root##16, 45, code+100) \
CHECK_MINUS_OPERATOR(type_root, type_root##32, 45, code+200) \
CHECK_MINUS_OPERATOR(type_root, type_root##64, 45, code+300) \
CHECK_MINUS_OPERATOR(type_root, type_root##8, MAX_##type_root##8-1, code) \
CHECK_MINUS_OPERATOR(type_root, type_root##16, MAX_##type_root##16-1, code+100) \
CHECK_MINUS_OPERATOR(type_root, type_root##32, MAX_##type_root##32-1, code+200) \
CHECK_MINUS_OPERATOR(type_root, type_root##64, MAX_##type_root##64-1, code+300) \
}
// return code..code+33
#define CHECK_SUPERIOR_OPERATOR(value1, type, value, code) \
{ \
XUINTN xu(value1); \
if ( !(xu > (type)(value)) ) return code; \
if ( xu <= (type)(value) ) return code+1; \
xu = value; \
if ( !(xu < (type)(value1)) ) return code+2; \
if ( xu >= (type)(value1) ) return code+3; \
}
#define CHECK_ALL_SUPERIOR_OPERATOR(type_root, code) \
{ \
CHECK_SUPERIOR_OPERATOR(MAX_##type_root##8, type_root##8, MAX_##type_root##8-1, code) \
CHECK_SUPERIOR_OPERATOR(MAX_##type_root##16, type_root##16, MAX_##type_root##16-1, code+10) \
CHECK_SUPERIOR_OPERATOR(MAX_##type_root##32, type_root##32, MAX_##type_root##32-1, code+20) \
CHECK_SUPERIOR_OPERATOR(MAX_##type_root##64, type_root##64, MAX_##type_root##64-1, code+30) \
CHECK_SUPERIOR_OPERATOR(MAX_UINT32, unsigned int, MAX_UINT32-1, code+40) \
}
// return code..code+1
#define CHECK_CAST_TO_TYPE_OK(type, value, code) \
{ \
stop_at_panic = false; \
i_have_panicked = false; \
XUINTN xu(value); \
type u64; \
u64 = (type)xu; \
if ( i_have_panicked || u64 != (value) ) return code; \
u64 = xu.operator type(); \
if ( i_have_panicked || u64 != (value) ) return code+1; \
stop_at_panic = true; \
i_have_panicked = false; \
}
// return code..code+5
#define CHECK_CAST_TO_TYPE_8_16_32_64_OK(type_root, code) \
{ \
CHECK_CAST_TO_TYPE_OK(type_root##8, (UINTN)MAX_##type_root##8, code); \
CHECK_CAST_TO_TYPE_OK(type_root##16, (UINTN)MAX_##type_root##16, code+2); \
CHECK_CAST_TO_TYPE_OK(type_root##32, (UINTN)MAX_##type_root##32, code+4); \
CHECK_CAST_TO_TYPE_OK(type_root##64, (UINTN)MAX_##type_root##64, code+4); \
}
// return code..code+1
#define CHECK_CAST_TO_TYPE_PANIC(type, value, code) \
{ \
stop_at_panic = false; \
i_have_panicked = false; \
XUINTN xu(value); \
type u8; \
\
u8 = (type)xu; \
if ( !i_have_panicked ) return code; \
\
/* same test as before. be sure that the overloaded cast is really called. */ \
i_have_panicked = false; \
u8 = xu.operator type(); \
if ( !i_have_panicked ) return code+1; \
\
stop_at_panic = true; \
i_have_panicked = false; \
}
// return code..code+5
#define CHECK_CAST_TO_TYPE_8_16_32_PANIC(type_root, code) \
{ \
CHECK_CAST_TO_TYPE_PANIC(type_root##8, (UINTN)MAX_##type_root##8+1, code); \
CHECK_CAST_TO_TYPE_PANIC(type_root##16, (UINTN)MAX_##type_root##16+1, code+2); \
CHECK_CAST_TO_TYPE_PANIC(type_root##32, (UINTN)MAX_##type_root##32+1, code+4); \
}
int XUINTN_tests()
{
//#define value MAX_UINT64-27
//{ \
// XUINTN xu(27); \
// XUINTN xu2(27); \
// UINT64 v = (UINT64)(value)-1;
// xu2 = xu + (UINT64)(value)-1; \
// if ( xu2.m_value != (UINTN)value + 27-1 ) return 0; \
//}
{
XUINTN xu(72);
INT8 u = 72;
int code = 100000;
if ( !(xu == u) ) return code;
if ( !(xu.operator ==(u)) ) return code+1;
if ( xu != u ) return code+2;
if ( xu.operator !=(u) ) return code+3;
// xu = (INT8)-10;
}
CHECK_CTOR_8_16_32_64_int_FAIL(200);
CHECK_EQUAL_EQUAL_OPERATOR_8_16_32_64(UINT, MAX_UINT8, 300);
CHECK_EQUAL_EQUAL_OPERATOR_8_16_32_64(UINT, MAX_UINT16, 400);
CHECK_EQUAL_EQUAL_OPERATOR_8_16_32_64(UINT, MAX_UINT32, 500);
CHECK_EQUAL_EQUAL_OPERATOR_8_16_32_64(UINT, MAX_UINT64, 600);
{
unsigned int ui = MAX_UINT32;
XUINTN xu = ui;
CHECK_EQUAL_EQUAL_OPERATOR_OK_(xu, unsigned int, (unsigned int)(MAX_UINT32), 680);
}
CHECK_EQUAL_EQUAL_OPERATOR_8_16_32_64(INT, MAX_INT8, 700);
CHECK_EQUAL_EQUAL_OPERATOR_8_16_32_64(INT, MAX_INT16, 800);
CHECK_EQUAL_EQUAL_OPERATOR_8_16_32_64(INT, MAX_INT32, 900);
CHECK_EQUAL_EQUAL_OPERATOR_8_16_32_64(INT, MAX_INT64, 1000);
{
int i = MAX_INT32;
XUINTN xu = i;
CHECK_EQUAL_EQUAL_OPERATOR_OK_(xu, unsigned int, (unsigned int)(MAX_INT32), 690);
}
CHECK_ALL_PLUS_OPERATOR(UINT, 2000);
CHECK_ALL_PLUS_OPERATOR(INT, 3000);
CHECK_ALL_MINUS_OPERATOR(UINT, 2000);
CHECK_ALL_MINUS_OPERATOR(INT, 3000);
// Check + operation that fail
{
stop_at_panic = false;
i_have_panicked = false;
XUINTN xu1 = (UINT64)MAX_UINT64 - 1;
XUINTN xu2 = xu1 + 2;
if ( !i_have_panicked ) return 100;
(void)xu2;
stop_at_panic = true;
i_have_panicked = false;
}
CHECK_ALL_SUPERIOR_OPERATOR(UINT, 5000);
CHECK_CAST_TO_TYPE_8_16_32_64_OK(UINT, 210);
if ( sizeof(unsigned int) == 4 ) {
CHECK_CAST_TO_TYPE_OK(unsigned int, (UINTN)MAX_UINT32, 220);
}else{
panic("Please define unsigned int test in XUINTN_test.cpp");
}
CHECK_CAST_TO_TYPE_8_16_32_PANIC(UINT, 220);
if ( sizeof(unsigned int) == 4 ) {
CHECK_CAST_TO_TYPE_PANIC(unsigned int, (UINTN)MAX_UINT32+1, 230);
}else{
panic("Please define unsigned int test in XUINTN_test.cpp");
}
CHECK_CAST_TO_TYPE_8_16_32_64_OK(INT, 240);
if ( sizeof(unsigned int) == 4 ) {
CHECK_CAST_TO_TYPE_OK(unsigned int, (UINTN)MAX_UINT32, 250);
}else{
panic("Please define unsigned int test in XUINTN_test.cpp");
}
CHECK_CAST_TO_TYPE_8_16_32_PANIC(INT, 260);
if ( sizeof(unsigned int) == 4 ) {
CHECK_CAST_TO_TYPE_PANIC(int, (UINTN)MAX_INT32+1, 270);
}else{
panic("Please define unsigned int test in XUINTN_test.cpp");
}
return 0;
}

View File

@ -0,0 +1 @@
int XUINTN_tests();

View File

@ -7,6 +7,7 @@
#include "XObjArray_tests.h"
#include "XStringWArray_test.h"
#include "XStringW_test.h"
#include "XUINTN_test.h"
#include <Platform.h> // Only use angled for Platform, else, xcode project won't compile
@ -35,6 +36,11 @@ bool all_tests()
DebugLog(2, "XStringWArray_tests() failed at test %d\n", ret);
all_ok = false;
}
ret = XUINTN_tests();
if ( ret != 0 ) {
DebugLog(2, "XUINTN_tests() failed at test %d\n", ret);
all_ok = false;
}
if ( !all_ok ) {
DebugLog(2, "A test failed\n");

View File

@ -5,15 +5,34 @@
//#include <Library/BaseLib.h> // for CpuDeadLoop
//}
bool stop_at_panic = true;
bool i_have_panicked = false;
/*
*
* If this modified, you may have to change the Qemu/gdb_launch script to adjust the breakpoint line.
* gdb_launch put a breakpoint at CpuDeadLoop();
* Currently line 18
* Function panic_ seems useless. It's same as panic(). It's to be able to put a breakpoint in gdb with br panic_(). This is done in gdb_launch script in Qemu
*/
void panic_(const char* s)
{
if ( stop_at_panic ) {
if ( s ) DebugLog(2, "%s\n", s);
DebugLog(2, "A fatal error happened. System halted\n");
CpuDeadLoop();
}else{
if ( s ) DebugLog(2, "%s\n", s);
// DebugLog(2, "A fatal error happened. Continue for testing\n");
i_have_panicked = true;
}
}
void panic(const char* s)
{
panic_(s);
}
void panic(void)
{
DebugLog(2, "A fatal error happened. System halted\n");
CpuDeadLoop();
panic_(nullptr);
}

View File

@ -1,6 +1,10 @@
#ifndef __PANIC_H__
#define __PANIC_H__
extern bool stop_at_panic;
extern bool i_have_panicked;
void panic(void);
void panic(const char* s);
#endif

View File

@ -683,7 +683,7 @@ VOID egRawCopy(IN OUT EG_PIXEL *CompBasePtr, IN EG_PIXEL *TopBasePtr,
EG_PIXEL *CompPtr = CompBasePtr;
for (x = 0; x < Width; x++) {
*CompPtr = *TopPtr;
TopPtr++, CompPtr++;
TopPtr++; CompPtr++;
}
TopBasePtr += TopLineOffset;
CompBasePtr += CompLineOffset;
@ -736,7 +736,7 @@ VOID egRawCompose(IN OUT EG_PIXEL *CompBasePtr, IN EG_PIXEL *TopBasePtr,
CompPtr->r = (UINT8)((TopPtr->r * TopAlpha + CompPtr->r * TempAlpha) / Alpha);
CompPtr->a = (UINT8)(Alpha / 255);
}
TopPtr++, CompPtr++;
TopPtr++; CompPtr++;
}
TopBasePtr += TopLineOffset;
CompBasePtr += CompLineOffset;
@ -776,7 +776,7 @@ VOID egRawComposeOnFlat(IN OUT EG_PIXEL *CompBasePtr, IN EG_PIXEL *TopBasePtr,
CompPtr->a = (UINT8)(255);
TopPtr++, CompPtr++;
TopPtr++; CompPtr++;
}
TopBasePtr += TopLineOffset;
CompBasePtr += CompLineOffset;
@ -877,7 +877,7 @@ VOID egCopyPlane(IN UINT8 *SrcPlanePtr, IN UINT8 *DestPlanePtr, IN UINTN PixelCo
for (i = 0; i < PixelCount; i++) {
*DestPlanePtr = *SrcPlanePtr;
DestPlanePtr += 4, SrcPlanePtr += 4;
DestPlanePtr += 4; SrcPlanePtr += 4;
}
}

View File

@ -34,6 +34,7 @@ Rename this file to lodepng.cpp to use it for C++, or to lodepng.c to use it for
#include "libegint.h"
#include "lodepng.h"
#include "../cpp_util/panic.h"
#ifdef LODEPNG_COMPILE_DISK
#include <limits.h> /* LONG_MAX */
@ -3725,7 +3726,7 @@ static unsigned getValueRequiredBits(unsigned char value) {
unsigned lodepng_compute_color_stats(LodePNGColorStats* stats,
const unsigned char* in, unsigned w, unsigned h,
const LodePNGColorMode* mode_in) {
size_t i;
// size_t i;
ColorTree tree;
size_t numpixels = (size_t)w * (size_t)h;
unsigned error = 0;
@ -3756,7 +3757,7 @@ unsigned lodepng_compute_color_stats(LodePNGColorStats* stats,
if(stats->numcolors >= maxnumcolors) numcolors_done = 1;
if(!numcolors_done) {
for(i = 0; i < stats->numcolors; i++) {
for(__typeof__(stats->numcolors) i = 0; i < stats->numcolors; i++) {
const unsigned char* color = &stats->palette[i * 4];
error = color_tree_add(&tree, color[0], color[1], color[2], color[3], i);
if(error) goto cleanup;
@ -3766,7 +3767,7 @@ unsigned lodepng_compute_color_stats(LodePNGColorStats* stats,
/*Check if the 16-bit input is truly 16-bit*/
if(mode_in->bitdepth == 16 && !sixteen) {
unsigned short r, g, b, a;
for(i = 0; i != numpixels; ++i) {
for(__typeof__(stats->numpixels) i = 0; i != numpixels; ++i) {
getPixelColorRGBA16(&r, &g, &b, &a, in, i, mode_in);
if((r & 255) != ((r >> 8) & 255) || (g & 255) != ((g >> 8) & 255) ||
(b & 255) != ((b >> 8) & 255) || (a & 255) != ((a >> 8) & 255)) /*first and second byte differ*/ {
@ -3782,7 +3783,7 @@ unsigned lodepng_compute_color_stats(LodePNGColorStats* stats,
if(sixteen) {
unsigned short r = 0, g = 0, b = 0, a = 0;
for(i = 0; i != numpixels; ++i) {
for(__typeof__(numpixels) i = 0; i != numpixels; ++i) {
getPixelColorRGBA16(&r, &g, &b, &a, in, i, mode_in);
if(!colored_done && (r != g || r != b)) {
@ -3812,7 +3813,7 @@ unsigned lodepng_compute_color_stats(LodePNGColorStats* stats,
}
if(stats->key && !stats->alpha) {
for(i = 0; i != numpixels; ++i) {
for(__typeof__(numpixels) i = 0; i != numpixels; ++i) {
getPixelColorRGBA16(&r, &g, &b, &a, in, i, mode_in);
if(a != 0 && r == stats->key_r && g == stats->key_g && b == stats->key_b) {
/* Color key cannot be used if an opaque pixel also has that RGB color. */
@ -3824,7 +3825,7 @@ unsigned lodepng_compute_color_stats(LodePNGColorStats* stats,
}
} else /* < 16-bit */ {
unsigned char r = 0, g = 0, b = 0, a = 0;
for(i = 0; i != numpixels; ++i) {
for(__typeof__(numpixels) i = 0; i != numpixels; ++i) {
getPixelColorRGBA8(&r, &g, &b, &a, in, i, mode_in);
if(!bits_done && stats->bits < 8) {
@ -3882,7 +3883,7 @@ unsigned lodepng_compute_color_stats(LodePNGColorStats* stats,
}
if(stats->key && !stats->alpha) {
for(i = 0; i != numpixels; ++i) {
for(__typeof__(numpixels) i = 0; i != numpixels; ++i) {
getPixelColorRGBA8(&r, &g, &b, &a, in, i, mode_in);
if(a != 0 && r == stats->key_r && g == stats->key_g && b == stats->key_b) {
/* Color key cannot be used if an opaque pixel also has that RGB color. */
@ -4729,7 +4730,8 @@ static unsigned readChunk_iCCP(LodePNGInfo* info, const LodePNGDecompressSetting
length, zlibsettings);
if(!error) {
if(decoded.size) {
info->iccp_profile_size = decoded.size;
info->iccp_profile_size = (__typeof(info->iccp_profile_size))decoded.size; // Unsafe cast
if ( info->iccp_profile_size != decoded.size ) panic("info->iccp_profile_size != decoded.size"); // Check the cast
info->iccp_profile = (unsigned char*)lodepng_malloc(decoded.size);
if(info->iccp_profile) {
lodepng_memcpy(info->iccp_profile, decoded.data, decoded.size);
@ -4806,7 +4808,7 @@ static void decodeGeneric(unsigned char** out, unsigned* w, unsigned* h,
size_t i;
ucvector idat; /*the data from idat chunks*/
unsigned char* scanlines = 0;
size_t scanlines_size = 0, expected_size = 0;
size_t scanlines_size = 0;
size_t outsize = 0;
/*for unknown chunk order*/
@ -4952,14 +4954,14 @@ static void decodeGeneric(unsigned char** out, unsigned* w, unsigned* h,
if(state->info_png.color.colortype == LCT_PALETTE && !state->info_png.color.palette) {
state->error = 106; /* error: PNG file must have PLTE chunk if color type is palette */
}
size_t expected_size = 0;
/*predict output size, to allocate exact size for output buffer to avoid more dynamic allocation.
If the decompressed size does not match the prediction, the image must be corrupt.*/
if(state->info_png.interlace_method == 0) {
size_t bpp = lodepng_get_bpp(&state->info_png.color);
unsigned bpp = lodepng_get_bpp(&state->info_png.color);
expected_size = lodepng_get_raw_size_idat(*w, *h, bpp);
} else {
size_t bpp = lodepng_get_bpp(&state->info_png.color);
unsigned bpp = lodepng_get_bpp(&state->info_png.color);
/*Adam-7 interlaced: expected size is the sum of the 7 sub-images sizes*/
expected_size = 0;
expected_size += lodepng_get_raw_size_idat((*w + 7) >> 3, (*h + 7) >> 3, bpp);
@ -6502,4 +6504,4 @@ unsigned eglodepng_decode(unsigned char** out, size_t* w, size_t* h, const unsig
}
// EXPORT FOR CLOVER <==
#endif /*LODEPNG_COMPILE_DECODER*/
#endif /*LODEPNG_COMPILE_DECODER*/

View File

@ -198,6 +198,8 @@
cpp_foundation/XStringWArray.h
cpp_foundation/XToolsCommon.cpp
cpp_foundation/XToolsCommon.h
cpp_foundation/XUINTN.cpp
cpp_foundation/XUINTN.h
cpp_unit_test/all_tests.h
cpp_unit_test/all_tests.cpp
cpp_unit_test/global_test.cpp
@ -210,6 +212,8 @@
cpp_unit_test/XStringW_test.h
cpp_unit_test/XStringWArray_test.cpp
cpp_unit_test/XStringWArray_test.h
cpp_unit_test/XUINTN_test.cpp
cpp_unit_test/XUINTN_test.h
[Sources.IA32]
libeg/ftol.asm | MSFT