mirror of
https://github.com/CloverHackyColor/CloverBootloader.git
synced 2024-11-10 09:40:53 +01:00
MemLogf and MemLogfVA. Not used yet in Clover.
This commit is contained in:
parent
35e2eec3cc
commit
14cdfe29c7
3
.gitignore
vendored
3
.gitignore
vendored
@ -124,3 +124,6 @@ tools
|
||||
|
||||
#VC project
|
||||
/VC
|
||||
|
||||
#Eclipse build folder
|
||||
/DEBUG_*/
|
||||
|
@ -123,12 +123,12 @@
|
||||
|
||||
<Command.GCC, Command.RVCT>
|
||||
# For RVCTCYGWIN CC_FLAGS must be first to work around pathing issues
|
||||
@"$(CC)" $(CXX_FLAGS) -c -o ${dst} $(INC) ${src}
|
||||
@"echo" [CPP] ${s_base}
|
||||
"$(CC)" $(CXX_FLAGS) -c -o ${dst} $(INC) ${src}
|
||||
"echo" [CPP] ${s_base}
|
||||
|
||||
<Command.XCODE>
|
||||
@"$(CC)" $(CC_FLAGS) -o ${dst} $(INC) ${src}
|
||||
@"echo" [CPP] ${s_base}
|
||||
"$(CC)" $(CC_FLAGS) -o ${dst} $(INC) ${src}
|
||||
"echo" [CPP] ${s_base}
|
||||
|
||||
[C-Code-File]
|
||||
<InputFile>
|
||||
@ -148,12 +148,12 @@
|
||||
|
||||
<Command.GCC, Command.RVCT>
|
||||
# For RVCTCYGWIN CC_FLAGS must be first to work around pathing issues
|
||||
@"$(CC)" $(CC_FLAGS) -c -o ${dst} $(INC) ${src}
|
||||
@"echo" [CC] ${s_base}
|
||||
"$(CC)" $(CC_FLAGS) -c -o ${dst} $(INC) ${src}
|
||||
"echo" [CC] ${s_base}
|
||||
|
||||
<Command.XCODE>
|
||||
@"$(CC)" $(CC_FLAGS) -o ${dst} $(INC) ${src}
|
||||
@"echo" [CC] ${s_base}
|
||||
"$(CC)" $(CC_FLAGS) -o ${dst} $(INC) ${src}
|
||||
"echo" [CC] ${s_base}
|
||||
|
||||
[C-Code-File.BASE.AARCH64,C-Code-File.SEC.AARCH64,C-Code-File.PEI_CORE.AARCH64,C-Code-File.PEIM.AARCH64,C-Code-File.BASE.ARM,C-Code-File.SEC.ARM,C-Code-File.PEI_CORE.ARM,C-Code-File.PEIM.ARM]
|
||||
<InputFile>
|
||||
@ -195,12 +195,12 @@
|
||||
"$(ASM)" /Fo${dst} $(ASM_FLAGS) /I${s_path} $(INC) ${d_path}(+)${s_base}.iii
|
||||
|
||||
<Command.GCC, Command.RVCT>
|
||||
@"$(PP)" $(PP_FLAGS) $(INC) ${src} > ${d_path}(+)${s_base}.i
|
||||
"$(PP)" $(PP_FLAGS) $(INC) ${src} > ${d_path}(+)${s_base}.i
|
||||
@Trim --source-code -o ${d_path}(+)${s_base}.iii ${d_path}(+)${s_base}.i
|
||||
#--trim-long
|
||||
# For RVCTCYGWIN ASM_FLAGS must be first to work around pathing issues
|
||||
@"$(ASM)" $(ASM_FLAGS) -o ${dst} $(INC) ${d_path}(+)${s_base}.iii
|
||||
@"echo" [ASM] ${s_base}
|
||||
"$(ASM)" $(ASM_FLAGS) -o ${dst} $(INC) ${d_path}(+)${s_base}.iii
|
||||
"echo" [ASM] ${s_base}
|
||||
|
||||
[Assembly-Code-File.COMMON.ARM,Assembly-Code-File.COMMON.AARCH64]
|
||||
# Remove --convert-hex for ARM as it breaks MSFT assemblers
|
||||
@ -243,10 +243,10 @@
|
||||
$(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj
|
||||
|
||||
<Command>
|
||||
@"$(PP)" $(PP_FLAGS) $(INC) ${src} > ${d_path}(+)${s_base}.i
|
||||
"$(PP)" $(PP_FLAGS) $(INC) ${src} > ${d_path}(+)${s_base}.i
|
||||
@Trim --trim-long --source-code -o ${d_path}(+)${s_base}.iii ${d_path}(+)${s_base}.i
|
||||
@"$(NASM)" -I${s_path}(+) $(NASM_INC) $(NASM_FLAGS) -o $dst ${d_path}(+)${s_base}.iii
|
||||
@"echo" [NASM] ${s_base}
|
||||
"$(NASM)" -I${s_path}(+) $(NASM_INC) $(NASM_FLAGS) -o $dst ${d_path}(+)${s_base}.iii
|
||||
"echo" [NASM] ${s_base}
|
||||
|
||||
[Device-Tree-Source-File]
|
||||
<InputFile>
|
||||
@ -259,9 +259,9 @@
|
||||
$(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dtb
|
||||
|
||||
<Command.GCC>
|
||||
@"$(DTCPP)" $(DTCPP_FLAGS) $(INC) ${src} > ${d_path}(+)${s_base}.i
|
||||
@"$(DTC)" $(DTC_FLAGS) -I dts -O dtb -o ${dst} ${d_path}(+)${s_base}.i
|
||||
@"echo" [DTC] ${s_base}
|
||||
"$(DTCPP)" $(DTCPP_FLAGS) $(INC) ${src} > ${d_path}(+)${s_base}.i
|
||||
"$(DTC)" $(DTC_FLAGS) -I dts -O dtb -o ${dst} ${d_path}(+)${s_base}.i
|
||||
"echo" [DTC] ${s_base}
|
||||
|
||||
[Visual-Form-Representation-File]
|
||||
<InputFile>
|
||||
@ -276,9 +276,9 @@
|
||||
$(DEBUG_DIR)(+)${s_dir}(+)${s_base}.c
|
||||
|
||||
<Command>
|
||||
@"$(VFRPP)" $(VFRPP_FLAGS) $(INC) ${src} > $(OUTPUT_DIR)(+)${s_base}.i
|
||||
@"$(VFR)" $(VFR_FLAGS) --string-db $(OUTPUT_DIR)(+)$(MODULE_NAME)StrDefs.hpk --output-directory ${d_path} $(OUTPUT_DIR)(+)${s_base}.i
|
||||
@"echo" [VFR] $(MODULE_NAME)
|
||||
"$(VFRPP)" $(VFRPP_FLAGS) $(INC) ${src} > $(OUTPUT_DIR)(+)${s_base}.i
|
||||
"$(VFR)" $(VFR_FLAGS) --string-db $(OUTPUT_DIR)(+)$(MODULE_NAME)StrDefs.hpk --output-directory ${d_path} $(OUTPUT_DIR)(+)${s_base}.i
|
||||
"echo" [VFR] $(MODULE_NAME)
|
||||
|
||||
[Object-File]
|
||||
<InputFile>
|
||||
@ -293,8 +293,8 @@
|
||||
|
||||
<Command.GCC>
|
||||
@$(RM) ${dst}
|
||||
@"$(SLINK)" -cr ${dst} $(SLINK_FLAGS) @$(OBJECT_FILES_LIST)
|
||||
@"echo" [SLINK] $(MODULE_NAME)
|
||||
"$(SLINK)" -cr ${dst} $(SLINK_FLAGS) @$(OBJECT_FILES_LIST)
|
||||
"echo" [SLINK] $(MODULE_NAME)
|
||||
|
||||
<Command.RVCT>
|
||||
"$(SLINK)" $(SLINK_FLAGS) ${dst} --via $(OBJECT_FILES_LIST)
|
||||
@ -304,8 +304,8 @@
|
||||
"$(SLINK)" $(SLINK_FLAGS) ${dst} $(OBJECT_FILES)
|
||||
|
||||
<Command.XCODE>
|
||||
@"$(SLINK)" $(SLINK_FLAGS) ${dst} -filelist $(OBJECT_FILES_LIST)
|
||||
@"echo" [SLINK] $(MODULE_NAME)
|
||||
"$(SLINK)" $(SLINK_FLAGS) ${dst} -filelist $(OBJECT_FILES_LIST)
|
||||
"echo" [SLINK] $(MODULE_NAME)
|
||||
|
||||
[Static-Library-File]
|
||||
<InputFile>
|
||||
@ -322,9 +322,9 @@
|
||||
"$(DLINK)" /OUT:${dst} $(DLINK_FLAGS) $(DLINK_SPATH) @$(STATIC_LIBRARY_FILES_LIST)
|
||||
|
||||
<Command.GCC>
|
||||
@"$(DLINK)" -o ${dst} $(DLINK_FLAGS) $(GCCLINK_PREFIX)--start-group $(DLINK_SPATH) @$(STATIC_LIBRARY_FILES_LIST) $(GCCLINK_PREFIX)--end-group $(DLINK2_FLAGS)
|
||||
@"$(OBJCOPY)" $(OBJCOPY_FLAGS) ${dst}
|
||||
@"echo" [DLINK1] $(MODULE_NAME)
|
||||
"$(DLINK)" -o ${dst} $(DLINK_FLAGS) $(GCCLINK_PREFIX)--start-group $(DLINK_SPATH) @$(STATIC_LIBRARY_FILES_LIST) $(GCCLINK_PREFIX)--end-group $(DLINK2_FLAGS)
|
||||
"$(OBJCOPY)" $(OBJCOPY_FLAGS) ${dst}
|
||||
"echo" [DLINK1] $(MODULE_NAME)
|
||||
|
||||
<Command.RVCT>
|
||||
"$(DLINK)" $(DLINK_FLAGS) -o ${dst} $(DLINK_SPATH) --via $(STATIC_LIBRARY_FILES_LIST) $(DLINK2_FLAGS)
|
||||
@ -334,8 +334,8 @@
|
||||
"$(DLINK)" $(DLINK_FLAGS) -o ${dst} $(DLINK_SPATH) $(STATIC_LIBRARY_FILES) $(DLINK2_FLAGS)
|
||||
|
||||
<Command.XCODE>
|
||||
@"$(DLINK)" $(DLINK_FLAGS) -o ${dst} $(DLINK_SPATH) -filelist $(STATIC_LIBRARY_FILES_LIST) $(DLINK2_FLAGS)
|
||||
@"echo" [DLINK1] $(MODULE_NAME)
|
||||
"$(DLINK)" $(DLINK_FLAGS) -o ${dst} $(DLINK_SPATH) -filelist $(STATIC_LIBRARY_FILES_LIST) $(DLINK2_FLAGS)
|
||||
"echo" [DLINK1] $(MODULE_NAME)
|
||||
|
||||
|
||||
[Static-Library-File.SEC.AARCH64, Static-Library-File.PEI_CORE.AARCH64, Static-Library-File.PEIM.AARCH64,Static-Library-File.SEC.ARM, Static-Library-File.PEI_CORE.ARM, Static-Library-File.PEIM.ARM]
|
||||
@ -367,8 +367,8 @@
|
||||
"$(DLINK)" $(DLINK_FLAGS) $(DLINK_SPATH) @$(STATIC_LIBRARY_FILES_LIST)
|
||||
|
||||
<Command.GCC>
|
||||
@"$(DLINK)" $(DLINK_FLAGS) $(GCCLINK_PREFIX)--start-group $(DLINK_SPATH) @$(STATIC_LIBRARY_FILES_LIST) $(GCCLINK_PREFIX)--end-group $(DLINK2_FLAGS)
|
||||
@"echo" [DLINK2] $(MODULE_NAME)
|
||||
"$(DLINK)" $(DLINK_FLAGS) $(GCCLINK_PREFIX)--start-group $(DLINK_SPATH) @$(STATIC_LIBRARY_FILES_LIST) $(GCCLINK_PREFIX)--end-group $(DLINK2_FLAGS)
|
||||
"echo" [DLINK2] $(MODULE_NAME)
|
||||
|
||||
<Command.RVCT>
|
||||
"$(DLINK)" $(DLINK_FLAGS) -o ${dst} $(DLINK_SPATH) --via $(STATIC_LIBRARY_FILES_LIST) $(DLINK2_FLAGS)
|
||||
@ -378,8 +378,8 @@
|
||||
"$(DLINK)" $(DLINK_FLAGS) -o ${dst} $(DLINK_SPATH) $(STATIC_LIBRARY_FILES) $(DLINK2_FLAGS)
|
||||
|
||||
<Command.XCODE>
|
||||
@"$(DLINK)" -o ${dst} $(DLINK_FLAGS) $(DLINK_SPATH) -filelist $(STATIC_LIBRARY_FILES_LIST) $(DLINK2_FLAGS)
|
||||
@"echo" [DLINK2] $(MODULE_NAME)
|
||||
"$(DLINK)" -o ${dst} $(DLINK_FLAGS) $(DLINK_SPATH) -filelist $(STATIC_LIBRARY_FILES_LIST) $(DLINK2_FLAGS)
|
||||
"echo" [DLINK2] $(MODULE_NAME)
|
||||
|
||||
|
||||
[Dynamic-Library-File]
|
||||
@ -405,26 +405,26 @@
|
||||
#
|
||||
@-$(OBJCOPY) $(OBJCOPY_ADDDEBUGFLAG) ${src}
|
||||
$(CP) $(DEBUG_DIR)(+)$(MODULE_NAME).debug $(BIN_DIR)(+)$(MODULE_NAME_GUID).debug
|
||||
@"echo" [OBJCOPY] $(MODULE_NAME)
|
||||
"echo" [OBJCOPY] $(MODULE_NAME)
|
||||
|
||||
@"$(GENFW)" -e $(MODULE_TYPE) -o ${dst} ${src} $(GENFW_FLAGS)
|
||||
"$(GENFW)" -e $(MODULE_TYPE) -o ${dst} ${src} $(GENFW_FLAGS)
|
||||
@$(CP) ${dst} $(DEBUG_DIR)
|
||||
@$(CP) ${dst} $(BIN_DIR)(+)$(MODULE_NAME_GUID).efi
|
||||
@-$(CP) $(DEBUG_DIR)(+)*.map $(OUTPUT_DIR)
|
||||
@"echo" [GENFW] $(MODULE_NAME)
|
||||
"echo" [GENFW] $(MODULE_NAME)
|
||||
|
||||
<Command.XCODE>
|
||||
# tool to convert Mach-O to PE/COFF
|
||||
#@"$(STRIP)" ${src}
|
||||
@"$(MTOC)" -subsystem $(MODULE_TYPE) $(MTOC_FLAGS) ${src} $(DEBUG_DIR)(+)$(MODULE_NAME).pecoff
|
||||
@"echo" [MTOC] $(MODULE_NAME)
|
||||
#"$(STRIP)" ${src}
|
||||
"$(MTOC)" -subsystem $(MODULE_TYPE) $(MTOC_FLAGS) ${src} $(DEBUG_DIR)(+)$(MODULE_NAME).pecoff
|
||||
"echo" [MTOC] $(MODULE_NAME)
|
||||
# create symbol file for GDB debug
|
||||
#@-$(DSYMUTIL) ${src}
|
||||
@"$(GENFW)" -e $(MODULE_TYPE) -o ${dst} $(DEBUG_DIR)(+)$(MODULE_NAME).pecoff $(GENFW_FLAGS)
|
||||
"$(GENFW)" -e $(MODULE_TYPE) -o ${dst} $(DEBUG_DIR)(+)$(MODULE_NAME).pecoff $(GENFW_FLAGS)
|
||||
@$(CP) ${dst} $(DEBUG_DIR)
|
||||
@$(CP) ${dst} $(BIN_DIR)(+)$(MODULE_NAME_GUID).efi
|
||||
@-$(CP) $(DEBUG_DIR)(+)*.map $(OUTPUT_DIR)
|
||||
@"echo" [GENFW] $(MODULE_NAME)
|
||||
"echo" [GENFW] $(MODULE_NAME)
|
||||
|
||||
[Dependency-Expression-File]
|
||||
<InputFile>
|
||||
@ -437,10 +437,10 @@
|
||||
$(MAKE_FILE)
|
||||
|
||||
<Command>
|
||||
@"$(PP)" $(APP_FLAGS) $(INC) ${src} > $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.i
|
||||
"$(PP)" $(APP_FLAGS) $(INC) ${src} > $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.i
|
||||
@Trim --source-code -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.iii $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.i
|
||||
@GenDepex -t $(MODULE_TYPE) -o ${dst} $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.iii
|
||||
@"echo" [DEPEX] $(MODULE_NAME)
|
||||
"echo" [DEPEX] $(MODULE_NAME)
|
||||
|
||||
[Acpi-Source-Language-File]
|
||||
<InputFile>
|
||||
@ -460,11 +460,11 @@
|
||||
|
||||
<Command.GCC>
|
||||
@Trim --asl-file -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.i -i $(INC_LIST) ${src}
|
||||
@"$(ASLPP)" $(ASLPP_FLAGS) $(INC) -I${s_path} $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.i > $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.iii
|
||||
@"echo" [ASLPP] ${s_base}
|
||||
"$(ASLPP)" $(ASLPP_FLAGS) $(INC) -I${s_path} $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.i > $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.iii
|
||||
"echo" [ASLPP] ${s_base}
|
||||
@Trim --source-code -l -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.iiii $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.iii
|
||||
@"$(ASL)" $(ASL_FLAGS) $(ASL_OUTFLAGS)${dst} $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.iiii
|
||||
@"echo" [ASLBIN] ${s_base}
|
||||
"$(ASL)" $(ASL_FLAGS) $(ASL_OUTFLAGS)${dst} $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.iiii
|
||||
"echo" [ASLBIN] ${s_base}
|
||||
|
||||
[C-Code-File.AcpiTable]
|
||||
<InputFile>
|
||||
@ -482,11 +482,11 @@
|
||||
"$(GENFW)" -o ${dst} -c $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dll $(GENFW_FLAGS)
|
||||
|
||||
<Command.GCC>
|
||||
@"$(ASLCC)" -c -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj $(CC_FLAGS) $(ASLCC_FLAGS) $(INC) ${src}
|
||||
@"$(ASLDLINK)" -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dll $(ASLDLINK_FLAGS) $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj
|
||||
@"echo" [ASLDLINK] ${s_base}
|
||||
@"$(GENFW)" -o ${dst} -c $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dll $(GENFW_FLAGS)
|
||||
@"echo" [GENFW] ${s_base}
|
||||
"$(ASLCC)" -c -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj $(CC_FLAGS) $(ASLCC_FLAGS) $(INC) ${src}
|
||||
"$(ASLDLINK)" -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dll $(ASLDLINK_FLAGS) $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj
|
||||
"echo" [ASLDLINK] ${s_base}
|
||||
"$(GENFW)" -o ${dst} -c $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dll $(GENFW_FLAGS)
|
||||
"echo" [GENFW] ${s_base}
|
||||
|
||||
[Acpi-Table-Code-File]
|
||||
<InputFile>
|
||||
@ -504,22 +504,22 @@
|
||||
"$(GENFW)" -o ${dst} -c $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dll $(GENFW_FLAGS)
|
||||
|
||||
<Command.GCC>
|
||||
@"$(ASLCC)" -c -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj $(CC_FLAGS) $(ASLCC_FLAGS) $(INC) ${src}
|
||||
@"$(ASLDLINK)" -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dll $(ASLDLINK_FLAGS) $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj
|
||||
@"echo" [ASLDLINK-ACPI] ${s_base}
|
||||
@"$(GENFW)" -o ${dst} -c $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dll $(GENFW_FLAGS)
|
||||
@"echo" [GENFW-ACPI] ${s_base}
|
||||
"$(ASLCC)" -c -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj $(CC_FLAGS) $(ASLCC_FLAGS) $(INC) ${src}
|
||||
"$(ASLDLINK)" -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dll $(ASLDLINK_FLAGS) $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj
|
||||
"echo" [ASLDLINK-ACPI] ${s_base}
|
||||
"$(GENFW)" -o ${dst} -c $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dll $(GENFW_FLAGS)
|
||||
"echo" [GENFW-ACPI] ${s_base}
|
||||
|
||||
<Command.XCODE>
|
||||
@"echo" [ASLCC-ACPI] $(MODULE_NAME)
|
||||
@"$(ASLCC)" -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj $(ASLCC_FLAGS) $(INC) ${src}
|
||||
@"echo" [ASLDLINK-ACPI] $(MODULE_NAME)
|
||||
@"$(ASLDLINK)" -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dll $(ASLDLINK_FLAGS) $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj
|
||||
@"echo" [MTOC-ACPI] $(MODULE_NAME)
|
||||
#@"$(STRIP)" ${src}
|
||||
@"$(MTOC)" -subsystem $(MODULE_TYPE) $(MTOC_FLAGS) $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dll $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.efi
|
||||
@"$(GENFW)" -o ${dst} -c $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.pecoff $(GENFW_FLAGS)
|
||||
@"echo" [GENFW-ACPI] $(MODULE_NAME)
|
||||
"echo" [ASLCC-ACPI] $(MODULE_NAME)
|
||||
"$(ASLCC)" -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj $(ASLCC_FLAGS) $(INC) ${src}
|
||||
"echo" [ASLDLINK-ACPI] $(MODULE_NAME)
|
||||
"$(ASLDLINK)" -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dll $(ASLDLINK_FLAGS) $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj
|
||||
"echo" [MTOC-ACPI] $(MODULE_NAME)
|
||||
#"$(STRIP)" ${src}
|
||||
"$(MTOC)" -subsystem $(MODULE_TYPE) $(MTOC_FLAGS) $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dll $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.efi
|
||||
"$(GENFW)" -o ${dst} -c $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.pecoff $(GENFW_FLAGS)
|
||||
"echo" [GENFW-ACPI] $(MODULE_NAME)
|
||||
|
||||
|
||||
[Masm16-Code-File]
|
||||
@ -540,19 +540,19 @@
|
||||
"$(ASMLINK)" $(ASMLINK_FLAGS) $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj,${dst},,,,
|
||||
|
||||
<Command.GCC>
|
||||
@"$(PP)" $(PP_FLAGS) $(INC) ${src} > ${d_path}(+)${s_base}.i
|
||||
"$(PP)" $(PP_FLAGS) $(INC) ${src} > ${d_path}(+)${s_base}.i
|
||||
@Trim --source-code -o ${d_path}(+)${s_base}.iii ${d_path}(+)${s_base}.i
|
||||
@"$(ASM)" -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj $(ASM_FLAGS) $(INC) ${d_path}(+)${s_base}.iii
|
||||
@"$(DLINK)" -o ${dst} $(DLINK_FLAGS) --start-group $(DLINK_SPATH) $(LIBS) $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj --end-group
|
||||
@"echo" [MASM] $(s_base)
|
||||
"$(ASM)" -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj $(ASM_FLAGS) $(INC) ${d_path}(+)${s_base}.iii
|
||||
"$(DLINK)" -o ${dst} $(DLINK_FLAGS) --start-group $(DLINK_SPATH) $(LIBS) $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj --end-group
|
||||
"echo" [MASM] $(s_base)
|
||||
|
||||
<Command.XCODE>
|
||||
@"$(PP)" $(PP_FLAGS) $(INC) ${src} > ${d_path}(+)${s_base}.i
|
||||
"$(PP)" $(PP_FLAGS) $(INC) ${src} > ${d_path}(+)${s_base}.i
|
||||
@Trim --source-code -o ${d_path}(+)${s_base}.iii ${d_path}(+)${s_base}.i
|
||||
@"$(ASM)" -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj $(ASM_FLAGS) $(INC) ${d_path}(+)${s_base}.iii
|
||||
@"$(SLINK)" $(SLINK_FLAGS) $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.slib $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj
|
||||
"$(ASM)" -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj $(ASM_FLAGS) $(INC) ${d_path}(+)${s_base}.iii
|
||||
"$(SLINK)" $(SLINK_FLAGS) $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.slib $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj
|
||||
@otool -t $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.slib | hex2bin.py ${dst}
|
||||
@"echo" [OTOOL] ${s_base}
|
||||
"echo" [OTOOL] ${s_base}
|
||||
|
||||
|
||||
[Nasm-to-Binary-Code-File]
|
||||
@ -566,10 +566,10 @@
|
||||
$(OUTPUT_DIR)(+)${s_base}.bin
|
||||
|
||||
<Command>
|
||||
@"$(PP)" $(PP_FLAGS) $(INC) ${src} > ${d_path}(+)${s_base}.i
|
||||
"$(PP)" $(PP_FLAGS) $(INC) ${src} > ${d_path}(+)${s_base}.i
|
||||
@Trim --source-code --convert-hex -o ${d_path}(+)${s_base}.iii ${d_path}(+)${s_base}.i
|
||||
@"$(NASM)" -I${s_path}(+) -l ${d_path}(+)${s_base}.lst $(NASMB_FLAGS) -o $dst ${d_path}(+)${s_base}.iii
|
||||
@"echo" [NASMB] ${s_base}
|
||||
"$(NASM)" -I${s_path}(+) -l ${d_path}(+)${s_base}.lst $(NASMB_FLAGS) -o $dst ${d_path}(+)${s_base}.iii
|
||||
"echo" [NASMB] ${s_base}
|
||||
# copy the output file with .com postfix that be same to the output file of .asm16
|
||||
@$(CP) ${dst} $(OUTPUT_DIR)(+)${s_base}.com
|
||||
|
||||
@ -581,7 +581,7 @@
|
||||
$(OUTPUT_DIR)(+)${s_base}.mcb
|
||||
|
||||
<Command>
|
||||
@"$(GENFW)" -o ${dst} -m ${src} $(GENFW_FLAGS)
|
||||
"$(GENFW)" -o ${dst} -m ${src} $(GENFW_FLAGS)
|
||||
|
||||
[Microcode-Binary-File]
|
||||
<InputFile>
|
||||
@ -688,12 +688,12 @@
|
||||
"$(RC)" /Fo${dst} $(OUTPUT_DIR)(+)$(MODULE_NAME)hii.rc
|
||||
|
||||
<Command.GCC>
|
||||
@"$(GENFW)" -o $(OUTPUT_DIR)(+)$(MODULE_NAME)hii.rc -g $(MODULE_GUID) --hiibinpackage $(HII_BINARY_PACKAGES) $(GENFW_FLAGS)
|
||||
@"$(RC)" $(RC_FLAGS) $(OUTPUT_DIR)(+)$(MODULE_NAME)hii.rc ${dst}
|
||||
@"echo" [GENFW-HII] $(MODULE_NAME)
|
||||
"$(GENFW)" -o $(OUTPUT_DIR)(+)$(MODULE_NAME)hii.rc -g $(MODULE_GUID) --hiibinpackage $(HII_BINARY_PACKAGES) $(GENFW_FLAGS)
|
||||
"$(RC)" $(RC_FLAGS) $(OUTPUT_DIR)(+)$(MODULE_NAME)hii.rc ${dst}
|
||||
"echo" [GENFW-HII] $(MODULE_NAME)
|
||||
|
||||
<Command.XCODE, Command.RVCT>
|
||||
@GenFw -o $(OUTPUT_DIR)(+)$(MODULE_NAME)hii.rc -g $(MODULE_GUID) --hiibinpackage $(HII_BINARY_PACKAGES)
|
||||
@"echo" [GENFW-HII] $(MODULE_NAME)
|
||||
"echo" [GENFW-HII] $(MODULE_NAME)
|
||||
|
||||
|
||||
|
@ -96,4 +96,54 @@ EFIAPI
|
||||
GetMemLogTscTicksPerSecond (VOID);
|
||||
|
||||
|
||||
/* new function that use printf like format (%s and %ls for example). We need both because only Clover use the new one. Not the drivers and protocols */
|
||||
|
||||
/**
|
||||
Prints a log message to memory buffer.
|
||||
|
||||
@param Timing TRUE to prepend timing to log.
|
||||
@param DebugMode DebugMode will be passed to Callback function if it is set.
|
||||
@param Format The format string for the debug message to print.
|
||||
@param Marker VA_LIST with variable arguments for Format.
|
||||
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
MemLogfVA (
|
||||
IN CONST BOOLEAN Timing,
|
||||
IN CONST INTN DebugMode,
|
||||
IN CONST CHAR8 *Format,
|
||||
IN VA_LIST Marker
|
||||
);
|
||||
|
||||
/**
|
||||
Prints a log message to memory buffer.
|
||||
|
||||
If Format is NULL, then does nothing.
|
||||
|
||||
@param Timing TRUE to prepend timing to log.
|
||||
@param DebugMode DebugMode will be passed to Callback function if it is set.
|
||||
@param Format The format string for the debug message to print.
|
||||
@param ... The variable argument list whose contents are accessed
|
||||
based on the format string specified by Format.
|
||||
|
||||
**/
|
||||
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define __attribute__(x)
|
||||
#endif
|
||||
|
||||
VOID
|
||||
EFIAPI
|
||||
MemLogf (
|
||||
IN CONST BOOLEAN Timing,
|
||||
IN CONST INTN DebugMode,
|
||||
IN CONST CHAR8 *Format,
|
||||
...
|
||||
) __attribute__((format(printf, 3, 4)));
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // __MEMLOG_LIB_H__
|
||||
|
36
Include/Library/printf_lite-conf.h
Executable file
36
Include/Library/printf_lite-conf.h
Executable file
@ -0,0 +1,36 @@
|
||||
//
|
||||
// printf_lite.hpp
|
||||
//
|
||||
// Created by jief the 04 Apr 2019.
|
||||
// Imported in CLover the 24 Feb 2020
|
||||
//
|
||||
#ifndef __PRINTF_LITE_CONF_H__
|
||||
#define __PRINTF_LITE_CONF_H__
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h> // for size_t
|
||||
|
||||
#ifndef __cplusplus
|
||||
#ifdef _MSC_VER
|
||||
typedef UINT16 wchar_t;
|
||||
#endif
|
||||
typedef UINT32 char32_t;
|
||||
typedef UINT16 char16_t;
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# define __attribute__(x)
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
#define DEFINE_SECTIONS 0
|
||||
#endif
|
||||
|
||||
|
||||
#define PRINTF_CFUNCTION_PREFIX
|
||||
#define PRINTF_CFUNCTION_SUFFIX f
|
||||
#define PRINTF_EMIT_CR 1
|
||||
|
||||
|
||||
|
||||
#endif // __PRINTF_LITE_CONF_H__
|
199
Include/Library/printf_lite.h
Executable file
199
Include/Library/printf_lite.h
Executable file
@ -0,0 +1,199 @@
|
||||
//
|
||||
// printf_lite.hpp
|
||||
//
|
||||
// Created by jief the 04 Apr 2019.
|
||||
// Imported in CLover the 24 Feb 2020
|
||||
//
|
||||
#ifndef __PRINTF_LITE_H__
|
||||
#define __PRINTF_LITE_H__
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h> // for size_t
|
||||
|
||||
#include "printf_lite-conf.h"
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
#define DEFINE_SECTIONS 0
|
||||
#endif
|
||||
|
||||
// To be able to compile on a platform where there are already std function snprintf, we need to change the name
|
||||
#ifndef PRINTF_CFUNCTION_PREFIX
|
||||
#define PRINTF_CFUNCTION_PREFIX
|
||||
#endif
|
||||
#ifndef PRINTF_CFUNCTION_SUFFIX
|
||||
#define PRINTF_CFUNCTION_SUFFIX fl
|
||||
#endif
|
||||
|
||||
#define PRINTF_MAKE_FN_NAME(prefix, root, suffix) prefix##root##suffix
|
||||
#define PRINTF_FUNCTION_NAME(prefix, root, suffix) PRINTF_MAKE_FN_NAME(prefix, root, suffix)
|
||||
|
||||
#ifndef PRINTF_UTF8_INPUT_SUPPORT
|
||||
#define PRINTF_UTF8_INPUT_SUPPORT 1
|
||||
#endif
|
||||
#ifndef PRINTF_UNICODE_INPUT_SUPPORT
|
||||
#define PRINTF_UNICODE_INPUT_SUPPORT 1 // enable %ls. %ls = UTF16 or UTF32 string, depending of the size of wchar_t
|
||||
#endif
|
||||
|
||||
#ifndef PRINTF_UTF8_OUTPUT_SUPPORT
|
||||
#define PRINTF_UTF8_OUTPUT_SUPPORT 1
|
||||
#endif
|
||||
#ifndef PRINTF_UNICODE_OUTPUT_SUPPORT
|
||||
#define PRINTF_UNICODE_OUTPUT_SUPPORT 1 // UTF16 or UTF32 depending of the size of wchar_t
|
||||
#endif
|
||||
#if PRINTF_UTF8_OUTPUT_SUPPORT == 0 && PRINTF_UNICODE_OUTPUT_SUPPORT == 0
|
||||
#error no output format supported.
|
||||
#endif
|
||||
|
||||
#ifndef PRINTF_LITE_SNPRINTF_SUPPORT
|
||||
#define PRINTF_LITE_SNPRINTF_SUPPORT 1
|
||||
#endif
|
||||
#ifndef VSNWPRINTF_RETURN_MINUS1_ON_OVERFLOW
|
||||
#define VSNWPRINTF_RETURN_MINUS1_ON_OVERFLOW 0
|
||||
#endif
|
||||
|
||||
#ifndef PRINTF_CHECK_UNSUPPORTED_STRING_FORMAT
|
||||
#define PRINTF_CHECK_UNSUPPORTED_STRING_FORMAT 0
|
||||
#endif
|
||||
|
||||
/*
|
||||
* A buffer is not needed. On some case it could be faster. For example when using semihosting
|
||||
* It's 255 max, because of bufIdx of type uint8_t. It's possible to change it to int if bigger buffer needed.
|
||||
* This buffer isn't statically allocated so it won't use permanent RAM.
|
||||
* Not more than int because of cast in transmitBufXXX functions.
|
||||
* 2017/08/31 : Save 22 bytes + bufsize of my STM32F103
|
||||
*/
|
||||
#ifndef PRINTF_LITE_BUF_SIZE
|
||||
#define PRINTF_LITE_BUF_SIZE 200
|
||||
#endif
|
||||
/*
|
||||
* Fallback on something close if specifier isn't supported.
|
||||
* Unsupported specifier are ignored.
|
||||
* if 0, any unsupported modifier or specifier will be seen as unknown.
|
||||
*/
|
||||
#ifndef PRINTF_LITE_FALLBACK_FOR_UNSUPPORTED
|
||||
#define PRINTF_LITE_FALLBACK_FOR_UNSUPPORTED 0
|
||||
#endif
|
||||
|
||||
#ifndef PRINTF_LITE_FLOAT_SUPPORT
|
||||
#define PRINTF_LITE_FLOAT_SUPPORT 1
|
||||
#endif
|
||||
/*
|
||||
* The int part of the float (or double) will be printed if PRINTF_LITE_FLOAT_SUPPORT is enabled
|
||||
* June 2017, avr-gcc 4.9.2-atmel3.5.4-arduino2 :
|
||||
* Float support increase 828 bytes of text and 16 bytes of data
|
||||
*/
|
||||
#ifndef PRINTF_LITE_FLOAT_AS_INT_SUPPORT
|
||||
#define PRINTF_LITE_FLOAT_AS_INT_SUPPORT 1 // if float not supported, an int will be print instead.
|
||||
#endif
|
||||
/*
|
||||
* Disabling LONG LONG support has an effect on printing double. If long int is disabled, the int part of the double has to be < ULONG_MAX
|
||||
*/
|
||||
#ifndef PRINTF_LITE_LONGLONGINT_SUPPORT
|
||||
#define PRINTF_LITE_LONGLONGINT_SUPPORT 1 // 1712 bytes
|
||||
#endif
|
||||
/*
|
||||
* Disabling LONG support automatically disable LONG LONG support whatever the value of PRINTF_LITE_LONGLONGINT_SUPPORT.
|
||||
* Disabling LONG support has an effect on printing double. The int part of the double has to be < UINT_MAX max
|
||||
*/
|
||||
#ifndef PRINTF_LITE_LONGINT_SUPPORT
|
||||
#define PRINTF_LITE_LONGINT_SUPPORT 1 // 1712 bytes
|
||||
#endif
|
||||
#ifndef PRINTF_LITE_TIMESTAMP_SUPPORT
|
||||
#define PRINTF_LITE_TIMESTAMP_SUPPORT 0 // 240 bytes
|
||||
#endif
|
||||
#ifndef PRINTF_LITE_FIELDWIDTH_SUPPORT
|
||||
#define PRINTF_LITE_FIELDWIDTH_SUPPORT 1 // 107 bytes
|
||||
#endif
|
||||
#ifndef PRINTF_LITE_FIELDPRECISION_SUPPORT
|
||||
#define PRINTF_LITE_FIELDPRECISION_SUPPORT 1 // bytes
|
||||
#endif
|
||||
#ifndef PRINTF_LITE_PADCHAR_SUPPORT
|
||||
#define PRINTF_LITE_PADCHAR_SUPPORT 1 // bytes
|
||||
#endif
|
||||
#ifndef PRINTF_LITE_ZSPECIFIER_SUPPORT
|
||||
#define PRINTF_LITE_ZSPECIFIER_SUPPORT 1 // 230 bytes. If not supported, z modifier become llu
|
||||
#endif
|
||||
#ifndef PRINTF_LITE_XSPECIFIER_SUPPORT
|
||||
#define PRINTF_LITE_XSPECIFIER_SUPPORT 1 // 96 bytes. If not supported, x specifier become u
|
||||
#endif
|
||||
#ifndef PRINTF_LITE_USPECIFIER_SUPPORT
|
||||
#define PRINTF_LITE_USPECIFIER_SUPPORT 1 // 96 bytes. If not supported, u specifier become d
|
||||
#endif
|
||||
#ifndef PRINTF_EMIT_CR
|
||||
#define PRINTF_EMIT_CR 0
|
||||
#endif
|
||||
/*===================================================== Private definition ============================================*/
|
||||
#if PRINTF_UTF8_OUTPUT_SUPPORT == 1
|
||||
typedef void (*transmitBufCallBackType)(const char* buf, unsigned int nbchar, void* context);
|
||||
#endif
|
||||
#if PRINTF_UNICODE_OUTPUT_SUPPORT == 1
|
||||
typedef void (*transmitWBufCallBackType)(const wchar_t* buf, unsigned int nbchar, void* context);
|
||||
#endif
|
||||
|
||||
typedef union {
|
||||
#if PRINTF_UTF8_OUTPUT_SUPPORT == 1
|
||||
transmitBufCallBackType transmitBufCallBack;
|
||||
#endif
|
||||
#if PRINTF_UNICODE_OUTPUT_SUPPORT == 1
|
||||
transmitWBufCallBackType transmitWBufCallBack;
|
||||
#endif
|
||||
} printf_callback_t;
|
||||
|
||||
// I need to pass a va_list by reference, NOT value, because va_list is "incremented" in printf_handle_format_char
|
||||
// On macOS, the builtin va_list type seems to already be a pointer
|
||||
#ifdef __APPLE__
|
||||
#define VALIST_PARAM_TYPE va_list
|
||||
#define VALIST_PARAM(valist) valist
|
||||
#define VALIST_ACCESS(valist) valist
|
||||
#else
|
||||
#define VALIST_PARAM_TYPE va_list*
|
||||
#define VALIST_PARAM(valist) &valist
|
||||
#define VALIST_ACCESS(valist) (*valist)
|
||||
#endif
|
||||
|
||||
//void printf_handle_format_char(char c, VALIST_PARAM_TYPE valist, PrintfParams* printfParams);
|
||||
|
||||
|
||||
|
||||
/*===================================================== User function ============================================*/
|
||||
|
||||
void vprintf_with_callback(const char* format, va_list valist, transmitBufCallBackType transmitBufCallBack, void* context
|
||||
#if PRINTF_LITE_TIMESTAMP_SUPPORT == 1
|
||||
, int* newline, int timestamp
|
||||
#endif
|
||||
);
|
||||
|
||||
#if PRINTF_UNICODE_OUTPUT_SUPPORT == 1
|
||||
void vwprintf_with_callback(const char* format, va_list valist, transmitWBufCallBackType transmitBufCallBack, void* context
|
||||
#if PRINTF_LITE_TIMESTAMP_SUPPORT == 1
|
||||
, int* newline, int timestamp
|
||||
#endif
|
||||
);
|
||||
#endif
|
||||
|
||||
#if PRINTF_LITE_SNPRINTF_SUPPORT == 1
|
||||
#if PRINTF_UTF8_OUTPUT_SUPPORT == 1
|
||||
int PRINTF_FUNCTION_NAME(PRINTF_CFUNCTION_PREFIX, vsnprint, PRINTF_CFUNCTION_SUFFIX)(char*, size_t, const char *__restrict, va_list valist);
|
||||
// gcc-4.9.2-atmel3.5.4-arduino2 report snprintf to undefined. Change the name and it'll work. Strange isn't it ?
|
||||
int PRINTF_FUNCTION_NAME(PRINTF_CFUNCTION_PREFIX, snprint, PRINTF_CFUNCTION_SUFFIX)(char*, size_t len, const char *__restrict format, ...) __attribute__((__format__ (__printf__, 3, 4)));
|
||||
#endif
|
||||
#if PRINTF_UNICODE_OUTPUT_SUPPORT == 1
|
||||
// ATTENTION : len is the number of wchar_t, NOT the number of bytes.
|
||||
int PRINTF_FUNCTION_NAME(PRINTF_CFUNCTION_PREFIX, vsnwprint, PRINTF_CFUNCTION_SUFFIX)(wchar_t*, size_t len, const char *__restrict, va_list valist);
|
||||
int PRINTF_FUNCTION_NAME(PRINTF_CFUNCTION_PREFIX, snwprint, PRINTF_CFUNCTION_SUFFIX)(wchar_t*, size_t len, const char *__restrict format, ...) __attribute__((__format__ (__printf__, 3, 4)));
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif // __PRINTF_LITE_H__
|
@ -15,6 +15,7 @@
|
||||
#include <Library/PciLib.h>
|
||||
#include "GenericIch.h"
|
||||
|
||||
#include <Library/printf_lite.h>
|
||||
//
|
||||
// Struct for holding mem buffer.
|
||||
//
|
||||
@ -272,7 +273,7 @@ MemLogVA (
|
||||
LastMessage = mMemLog->Cursor;
|
||||
if (Timing) {
|
||||
//
|
||||
// Write timing only at the beginnign of a new line
|
||||
// Write timing only at the beginning of a new line
|
||||
//
|
||||
if ((mMemLog->Buffer[0] == '\0') || (mMemLog->Cursor[-1] == '\n')) {
|
||||
DataWritten = AsciiSPrint(
|
||||
@ -301,7 +302,7 @@ MemLogVA (
|
||||
//
|
||||
// Write to standard debug device also
|
||||
//
|
||||
DebugPrint(DEBUG_INFO, LastMessage);
|
||||
DebugPrint(DEBUG_INFO, "%a", LastMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -417,3 +418,143 @@ GetMemLogTscTicksPerSecond (VOID)
|
||||
}
|
||||
return mMemLog->TscFreqSec;
|
||||
}
|
||||
|
||||
|
||||
// Microsoft wants _fltused
|
||||
#ifdef _MSC_VER
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
int _fltused=0; // it should be a single underscore since the double one is the mangled name
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/**
|
||||
Prints a log message to memory buffer.
|
||||
|
||||
@param Timing TRUE to prepend timing to log.
|
||||
@param DebugMode DebugMode will be passed to Callback function if it is set.
|
||||
@param Format The format string for the debug message to print.
|
||||
@param Marker VA_LIST with variable arguments for Format.
|
||||
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
MemLogfVA (
|
||||
IN CONST BOOLEAN Timing,
|
||||
IN CONST INTN DebugMode,
|
||||
IN CONST CHAR8 *Format,
|
||||
IN VA_LIST Marker
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UINTN DataWritten;
|
||||
CHAR8 *LastMessage;
|
||||
|
||||
if (Format == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mMemLog == NULL) {
|
||||
Status = MemLogInit ();
|
||||
if (EFI_ERROR (Status)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Check if buffer can accept MEM_LOG_MAX_LINE_SIZE chars.
|
||||
// Increase buffer if not.
|
||||
//
|
||||
if ((UINTN)(mMemLog->Cursor - mMemLog->Buffer) + MEM_LOG_MAX_LINE_SIZE > mMemLog->BufferSize) {
|
||||
UINTN Offset;
|
||||
// not enough place for max line - make buffer bigger
|
||||
// but not too big (if something gets out of controll)
|
||||
if (mMemLog->BufferSize + MEM_LOG_INITIAL_SIZE > MEM_LOG_MAX_SIZE) {
|
||||
// Out of resources!
|
||||
return;
|
||||
}
|
||||
Offset = mMemLog->Cursor - mMemLog->Buffer;
|
||||
mMemLog->Buffer = ReallocatePool(mMemLog->BufferSize, mMemLog->BufferSize + MEM_LOG_INITIAL_SIZE, mMemLog->Buffer);
|
||||
mMemLog->BufferSize += MEM_LOG_INITIAL_SIZE;
|
||||
mMemLog->Cursor = mMemLog->Buffer + Offset;
|
||||
}
|
||||
|
||||
//
|
||||
// Add log to buffer
|
||||
//
|
||||
LastMessage = mMemLog->Cursor;
|
||||
if (Timing) {
|
||||
//
|
||||
// Write timing only at the beginning of a new line
|
||||
//
|
||||
if ((mMemLog->Buffer[0] == '\0') || (mMemLog->Cursor[-1] == '\n')) {
|
||||
DataWritten = AsciiSPrint(
|
||||
mMemLog->Cursor,
|
||||
mMemLog->BufferSize - (mMemLog->Cursor - mMemLog->Buffer),
|
||||
"%a ",
|
||||
GetTiming ());
|
||||
mMemLog->Cursor += DataWritten;
|
||||
}
|
||||
|
||||
}
|
||||
// DataWritten = AsciiVSPrint(
|
||||
// mMemLog->Cursor,
|
||||
// mMemLog->BufferSize - (mMemLog->Cursor - mMemLog->Buffer),
|
||||
// Format,
|
||||
// Marker);
|
||||
DataWritten = vsnprintf(
|
||||
mMemLog->Cursor,
|
||||
mMemLog->BufferSize - (mMemLog->Cursor - mMemLog->Buffer),
|
||||
Format,
|
||||
Marker);
|
||||
// mMemLog->Cursor += DataWritten;
|
||||
// vsnprintf doesn't return the number of char printed. TODO will do it soon in printf_lite
|
||||
mMemLog->Cursor += AsciiStrLen(mMemLog->Cursor);
|
||||
|
||||
//
|
||||
// Pass this last message to callback if defined
|
||||
//
|
||||
if (mMemLog->Callback != NULL) {
|
||||
mMemLog->Callback(DebugMode, LastMessage);
|
||||
}
|
||||
|
||||
//
|
||||
// Write to standard debug device also
|
||||
//
|
||||
DebugPrint(DEBUG_INFO, "%a", LastMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
Prints a log to message memory buffer.
|
||||
|
||||
If Format is NULL, then does nothing.
|
||||
|
||||
@param Timing TRUE to prepend timing to log.
|
||||
@param DebugMode DebugMode will be passed to Callback function if it is set.
|
||||
@param Format The format string for the debug message to print.
|
||||
@param ... The variable argument list whose contents are accessed
|
||||
based on the format string specified by Format.
|
||||
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
MemLogf (
|
||||
IN CONST BOOLEAN Timing,
|
||||
IN CONST INTN DebugMode,
|
||||
IN CONST CHAR8 *Format,
|
||||
...
|
||||
)
|
||||
{
|
||||
VA_LIST Marker;
|
||||
|
||||
if (Format == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
VA_START (Marker, Format);
|
||||
MemLogfVA (Timing, DebugMode, Format, Marker);
|
||||
VA_END (Marker);
|
||||
}
|
||||
|
@ -18,6 +18,7 @@
|
||||
[Sources]
|
||||
MemLogLib.c
|
||||
GenericIch.h
|
||||
printf_lite.c
|
||||
|
||||
[Packages]
|
||||
MdePkg/MdePkg.dec
|
||||
@ -34,5 +35,7 @@
|
||||
IoLib
|
||||
|
||||
[BuildOptions]
|
||||
XCODE:*_*_*_CC_FLAGS = -Os -fno-lto -UUSING_LTO -DMDEPKG_NDEBUG
|
||||
GCC:*_*_*_CC_FLAGS = -Os -fno-lto -DMDEPKG_NDEBUG
|
||||
XCODE:*_*_*_CC_FLAGS = -Os -fno-lto -UUSING_LTO -DMDEPKG_NDEBUG -DPRINTF_EMIT_CR=1
|
||||
GCC:*_*_*_CC_FLAGS = -Os -fno-lto -DMDEPKG_NDEBUG -DPRINTF_EMIT_CR=1
|
||||
MSFT:*_*_*_CC_FLAGS = /D PRINTF_EMIT_CR=1
|
||||
|
||||
|
1355
Library/MemLogLibDefault/printf_lite.c
Normal file
1355
Library/MemLogLibDefault/printf_lite.c
Normal file
File diff suppressed because it is too large
Load Diff
16
Library/MemLogLibDefault/printf_lite.h
Executable file
16
Library/MemLogLibDefault/printf_lite.h
Executable file
@ -0,0 +1,16 @@
|
||||
//
|
||||
// printf_lite.hpp
|
||||
//
|
||||
// Created by jief the 04 Apr 2019.
|
||||
// Imported in CLover the 24 Feb 2020
|
||||
//
|
||||
#ifndef __NEXT_PRINTF_LITE_H__
|
||||
#define __NEXT_PRINTF_LITE_H__
|
||||
|
||||
#ifdef CLOVER_BUILD
|
||||
#include <Base.h>
|
||||
#endif
|
||||
|
||||
#include "../../Include/Library/printf_lite.h"
|
||||
|
||||
#endif // __NEXT_PRINTF_LITE_H__
|
@ -208,9 +208,14 @@
|
||||
/// UTF-16 encoding format as defined by Unicode 2.1 and ISO/IEC 10646 standards.
|
||||
///
|
||||
#ifdef __cplusplus
|
||||
// So this MUST be compiled with short wchar
|
||||
// I am considering switching to char16_t, to be independant of sizeof wchar_t
|
||||
#define CHAR16 wchar_t
|
||||
#else
|
||||
typedef unsigned short CHAR16;
|
||||
typedef UINT16 wchar_t;
|
||||
typedef UINT16 char16_t;
|
||||
typedef UINT32 char32_t;
|
||||
#endif
|
||||
///
|
||||
/// 2-byte signed value
|
||||
|
@ -30,6 +30,15 @@
|
||||
9A57C25824192D650029A39F /* XUINTN.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A57C25624192D650029A39F /* XUINTN.h */; };
|
||||
9A57C25B24192D710029A39F /* XUINTN_test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A57C25924192D710029A39F /* XUINTN_test.cpp */; };
|
||||
9A57C25C24192D710029A39F /* XUINTN_test.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A57C25A24192D710029A39F /* XUINTN_test.h */; };
|
||||
9A9D3B2224221563006D8CD9 /* printf_lite_test.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A9D3B2024221562006D8CD9 /* printf_lite_test.h */; };
|
||||
9A9D3B2324221563006D8CD9 /* printf_lite-test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A9D3B2124221563006D8CD9 /* printf_lite-test.cpp */; };
|
||||
9A9D3B2624221570006D8CD9 /* unicode_conversions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A9D3B2424221570006D8CD9 /* unicode_conversions.cpp */; };
|
||||
9A9D3B2724221570006D8CD9 /* unicode_conversions.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A9D3B2524221570006D8CD9 /* unicode_conversions.h */; };
|
||||
9A9D3B2D242215A1006D8CD9 /* stdio.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A9D3B28242215A1006D8CD9 /* stdio.cpp */; };
|
||||
9A9D3B2E242215A1006D8CD9 /* stdio.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A9D3B29242215A1006D8CD9 /* stdio.h */; };
|
||||
9A9D3B2F242215A1006D8CD9 /* wchar.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A9D3B2A242215A1006D8CD9 /* wchar.h */; };
|
||||
9A9D3B30242215A1006D8CD9 /* string.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A9D3B2B242215A1006D8CD9 /* string.h */; };
|
||||
9A9D3B31242215A1006D8CD9 /* wchar.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A9D3B2C242215A1006D8CD9 /* wchar.cpp */; };
|
||||
9AC77FB924176C04005CDD5C /* XStringWArray_test.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AC77ECC24176C04005CDD5C /* XStringWArray_test.h */; };
|
||||
9AC77FBA24176C04005CDD5C /* XArray_tests.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AC77ECD24176C04005CDD5C /* XArray_tests.h */; };
|
||||
9AC77FBB24176C04005CDD5C /* XStringWArray_test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AC77ECE24176C04005CDD5C /* XStringWArray_test.cpp */; };
|
||||
@ -190,9 +199,7 @@
|
||||
9AC7809124176C04005CDD5C /* XStringW.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AC77FB024176C04005CDD5C /* XStringW.cpp */; };
|
||||
9AC7809224176C04005CDD5C /* utf8Conversion.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AC77FB124176C04005CDD5C /* utf8Conversion.cpp */; };
|
||||
9AC7809324176C04005CDD5C /* utf8Conversion.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AC77FB224176C04005CDD5C /* utf8Conversion.h */; };
|
||||
9AC7809424176C04005CDD5C /* printf_lite.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AC77FB324176C04005CDD5C /* printf_lite.cpp */; };
|
||||
9AC7809524176C04005CDD5C /* XToolsCommon.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AC77FB424176C04005CDD5C /* XToolsCommon.cpp */; };
|
||||
9AC7809624176C04005CDD5C /* printf_lite.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AC77FB524176C04005CDD5C /* printf_lite.h */; };
|
||||
9AC7809724176C04005CDD5C /* XArray.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AC77FB624176C04005CDD5C /* XArray.h */; };
|
||||
9AC7809824176C04005CDD5C /* XObjArray.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AC77FB724176C04005CDD5C /* XObjArray.h */; };
|
||||
9AC7809A24178F02005CDD5C /* menu_items.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AC7809924178F02005CDD5C /* menu_items.cpp */; };
|
||||
@ -226,6 +233,15 @@
|
||||
9A57C25624192D650029A39F /* XUINTN.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XUINTN.h; sourceTree = "<group>"; };
|
||||
9A57C25924192D710029A39F /* XUINTN_test.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XUINTN_test.cpp; sourceTree = "<group>"; };
|
||||
9A57C25A24192D710029A39F /* XUINTN_test.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XUINTN_test.h; sourceTree = "<group>"; };
|
||||
9A9D3B2024221562006D8CD9 /* printf_lite_test.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = printf_lite_test.h; sourceTree = "<group>"; };
|
||||
9A9D3B2124221563006D8CD9 /* printf_lite-test.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = "printf_lite-test.cpp"; sourceTree = "<group>"; };
|
||||
9A9D3B2424221570006D8CD9 /* unicode_conversions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = unicode_conversions.cpp; sourceTree = "<group>"; };
|
||||
9A9D3B2524221570006D8CD9 /* unicode_conversions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = unicode_conversions.h; sourceTree = "<group>"; };
|
||||
9A9D3B28242215A1006D8CD9 /* stdio.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = stdio.cpp; sourceTree = "<group>"; };
|
||||
9A9D3B29242215A1006D8CD9 /* stdio.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = stdio.h; sourceTree = "<group>"; };
|
||||
9A9D3B2A242215A1006D8CD9 /* wchar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = wchar.h; sourceTree = "<group>"; };
|
||||
9A9D3B2B242215A1006D8CD9 /* string.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = string.h; sourceTree = "<group>"; };
|
||||
9A9D3B2C242215A1006D8CD9 /* wchar.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = wchar.cpp; sourceTree = "<group>"; };
|
||||
9AC77EC424176BF2005CDD5C /* libCloverX64.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libCloverX64.a; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
9AC77ECC24176C04005CDD5C /* XStringWArray_test.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XStringWArray_test.h; sourceTree = "<group>"; };
|
||||
9AC77ECD24176C04005CDD5C /* XArray_tests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XArray_tests.h; sourceTree = "<group>"; };
|
||||
@ -387,9 +403,7 @@
|
||||
9AC77FB024176C04005CDD5C /* XStringW.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XStringW.cpp; sourceTree = "<group>"; };
|
||||
9AC77FB124176C04005CDD5C /* utf8Conversion.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = utf8Conversion.cpp; sourceTree = "<group>"; };
|
||||
9AC77FB224176C04005CDD5C /* utf8Conversion.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = utf8Conversion.h; sourceTree = "<group>"; };
|
||||
9AC77FB324176C04005CDD5C /* printf_lite.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = printf_lite.cpp; sourceTree = "<group>"; };
|
||||
9AC77FB424176C04005CDD5C /* XToolsCommon.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XToolsCommon.cpp; sourceTree = "<group>"; };
|
||||
9AC77FB524176C04005CDD5C /* printf_lite.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = printf_lite.h; sourceTree = "<group>"; };
|
||||
9AC77FB624176C04005CDD5C /* XArray.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XArray.h; sourceTree = "<group>"; };
|
||||
9AC77FB724176C04005CDD5C /* XObjArray.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XObjArray.h; sourceTree = "<group>"; };
|
||||
9AC7809924178F02005CDD5C /* menu_items.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = menu_items.cpp; sourceTree = "<group>"; };
|
||||
@ -414,14 +428,19 @@
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
9A28CD25241BC0C700F3D247 /* abort.cpp */,
|
||||
9A28CD26241BC0C700F3D247 /* strcmp.cpp */,
|
||||
9A28CD27241BC0C700F3D247 /* strlen.cpp */,
|
||||
9A28CC9A241B66EA00F3D247 /* stdlib.h */,
|
||||
9A28CC9B241B66EA00F3D247 /* limits.h */,
|
||||
9A28CC9C241B66EA00F3D247 /* stddef.h */,
|
||||
9A28CCA0241B66EA00F3D247 /* posix.h */,
|
||||
9A28CCA1241B66EA00F3D247 /* stdarg.h */,
|
||||
9A28CC9C241B66EA00F3D247 /* stddef.h */,
|
||||
9A28CCA2241B66EA00F3D247 /* stdint.h */,
|
||||
9A9D3B28242215A1006D8CD9 /* stdio.cpp */,
|
||||
9A9D3B29242215A1006D8CD9 /* stdio.h */,
|
||||
9A28CC9A241B66EA00F3D247 /* stdlib.h */,
|
||||
9A28CD26241BC0C700F3D247 /* strcmp.cpp */,
|
||||
9A9D3B2B242215A1006D8CD9 /* string.h */,
|
||||
9A28CD27241BC0C700F3D247 /* strlen.cpp */,
|
||||
9A9D3B2C242215A1006D8CD9 /* wchar.cpp */,
|
||||
9A9D3B2A242215A1006D8CD9 /* wchar.h */,
|
||||
);
|
||||
path = Posix;
|
||||
sourceTree = "<group>";
|
||||
@ -475,12 +494,16 @@
|
||||
9AC77ED724176C04005CDD5C /* all_tests.h */,
|
||||
9AC780B22417EE4A005CDD5C /* global_test.cpp */,
|
||||
9AC780B42417EE53005CDD5C /* global_test.h */,
|
||||
9A9D3B2024221562006D8CD9 /* printf_lite_test.h */,
|
||||
9A9D3B2124221563006D8CD9 /* printf_lite-test.cpp */,
|
||||
9A28CD2C241BC0DF00F3D247 /* strcmp_test.cpp */,
|
||||
9A28CD2D241BC0DF00F3D247 /* strcmp_test.h */,
|
||||
9A28CD2B241BC0DF00F3D247 /* strlen_test.cpp */,
|
||||
9A28CD2F241BC0DF00F3D247 /* strlen_test.h */,
|
||||
9A28CD2E241BC0DF00F3D247 /* strncmp_test.cpp */,
|
||||
9A28CD30241BC0DF00F3D247 /* strncmp_test.h */,
|
||||
9A9D3B2424221570006D8CD9 /* unicode_conversions.cpp */,
|
||||
9A9D3B2524221570006D8CD9 /* unicode_conversions.h */,
|
||||
9AC77ED624176C04005CDD5C /* XArray_tests.cpp */,
|
||||
9AC77ECD24176C04005CDD5C /* XArray_tests.h */,
|
||||
9AC77ED524176C04005CDD5C /* XObjArray_tests.cpp */,
|
||||
@ -701,8 +724,6 @@
|
||||
9AC77FAB24176C04005CDD5C /* cpp_foundation */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
9AC77FB324176C04005CDD5C /* printf_lite.cpp */,
|
||||
9AC77FB524176C04005CDD5C /* printf_lite.h */,
|
||||
9AC77FB124176C04005CDD5C /* utf8Conversion.cpp */,
|
||||
9AC77FB224176C04005CDD5C /* utf8Conversion.h */,
|
||||
9AC77FB624176C04005CDD5C /* XArray.h */,
|
||||
@ -741,13 +762,14 @@
|
||||
9AC77FFE24176C04005CDD5C /* syslinux_mbr.h in Headers */,
|
||||
9AC7804724176C04005CDD5C /* lodepng.h in Headers */,
|
||||
9AC7806824176C04005CDD5C /* loader.h in Headers */,
|
||||
9A9D3B2724221570006D8CD9 /* unicode_conversions.h in Headers */,
|
||||
9AC7806E24176C04005CDD5C /* CloverKEK.h in Headers */,
|
||||
9AC7800524176C04005CDD5C /* StateGenerator.h in Headers */,
|
||||
9AC7808C24176C04005CDD5C /* remove_ref.h in Headers */,
|
||||
9A9D3B2F242215A1006D8CD9 /* wchar.h in Headers */,
|
||||
9AC7803124176C04005CDD5C /* loader.h in Headers */,
|
||||
9AC7800724176C04005CDD5C /* AmlGenerator.h in Headers */,
|
||||
9AC7808F24176C04005CDD5C /* XStringW.h in Headers */,
|
||||
9AC7809624176C04005CDD5C /* printf_lite.h in Headers */,
|
||||
9AC7809324176C04005CDD5C /* utf8Conversion.h in Headers */,
|
||||
9A28CCAA241B66EA00F3D247 /* stdarg.h in Headers */,
|
||||
9A28CCA9241B66EA00F3D247 /* posix.h in Headers */,
|
||||
@ -786,10 +808,12 @@
|
||||
9A28CD36241BC0DF00F3D247 /* strncmp_test.h in Headers */,
|
||||
9AC7804A24176C04005CDD5C /* XPointer.h in Headers */,
|
||||
9AC7808E24176C04005CDD5C /* XToolsCommon.h in Headers */,
|
||||
9A9D3B2E242215A1006D8CD9 /* stdio.h in Headers */,
|
||||
9AC7806D24176C04005CDD5C /* bootscreen.h in Headers */,
|
||||
9A28CCA4241B66EA00F3D247 /* limits.h in Headers */,
|
||||
9AC7800E24176C04005CDD5C /* Settings.h in Headers */,
|
||||
9AC77FBF24176C04005CDD5C /* XStringW_test.h in Headers */,
|
||||
9A9D3B2224221563006D8CD9 /* printf_lite_test.h in Headers */,
|
||||
9AC7803824176C04005CDD5C /* ati_reg.h in Headers */,
|
||||
9AC7804824176C04005CDD5C /* libegint.h in Headers */,
|
||||
9AC7800624176C04005CDD5C /* memvendors.h in Headers */,
|
||||
@ -818,6 +842,7 @@
|
||||
9AC7808624176C04005CDD5C /* globals_ctor.h in Headers */,
|
||||
9A28CCA5241B66EA00F3D247 /* stddef.h in Headers */,
|
||||
9AC7806724176C04005CDD5C /* securebootkeys.h in Headers */,
|
||||
9A9D3B30242215A1006D8CD9 /* string.h in Headers */,
|
||||
9A28CC94241AB33700F3D247 /* XString.h in Headers */,
|
||||
9AC7805A24176C04005CDD5C /* FloatLib.h in Headers */,
|
||||
);
|
||||
@ -900,6 +925,7 @@
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
9AC7800824176C04005CDD5C /* Hibernate.cpp in Sources */,
|
||||
9A9D3B31242215A1006D8CD9 /* wchar.cpp in Sources */,
|
||||
9AC7801524176C04005CDD5C /* DataHubCpu.cpp in Sources */,
|
||||
9AC7802824176C04005CDD5C /* hda.cpp in Sources */,
|
||||
9AC7804524176C04005CDD5C /* egemb_icons_dark.cpp in Sources */,
|
||||
@ -909,6 +935,7 @@
|
||||
9AC7800224176C04005CDD5C /* HdaCodecDump.cpp in Sources */,
|
||||
9AC7801A24176C04005CDD5C /* Nvram.cpp in Sources */,
|
||||
9AC7802324176C04005CDD5C /* BootOptions.cpp in Sources */,
|
||||
9A9D3B2D242215A1006D8CD9 /* stdio.cpp in Sources */,
|
||||
9AC7808924176C04005CDD5C /* operatorNewDelete.cpp in Sources */,
|
||||
9AC7807124176C04005CDD5C /* securehash.cpp in Sources */,
|
||||
9AC7804B24176C04005CDD5C /* image.cpp in Sources */,
|
||||
@ -932,7 +959,6 @@
|
||||
9AC7805724176C04005CDD5C /* XPointer.cpp in Sources */,
|
||||
9A28CD34241BC0DF00F3D247 /* strncmp_test.cpp in Sources */,
|
||||
9AC7807E24176C04005CDD5C /* list.cpp in Sources */,
|
||||
9AC7809424176C04005CDD5C /* printf_lite.cpp in Sources */,
|
||||
9AC7807C24176C04005CDD5C /* IO.cpp in Sources */,
|
||||
9AC7803324176C04005CDD5C /* sound.cpp in Sources */,
|
||||
9AC7803F24176C04005CDD5C /* usbfix.cpp in Sources */,
|
||||
@ -965,6 +991,7 @@
|
||||
9AC7800924176C04005CDD5C /* AcpiPatcher.cpp in Sources */,
|
||||
9AC7800D24176C04005CDD5C /* BdsConnect.cpp in Sources */,
|
||||
9AC7802924176C04005CDD5C /* spd.cpp in Sources */,
|
||||
9A9D3B2324221563006D8CD9 /* printf_lite-test.cpp in Sources */,
|
||||
9AC7800424176C04005CDD5C /* kext_patcher.cpp in Sources */,
|
||||
9A28CD28241BC0C700F3D247 /* abort.cpp in Sources */,
|
||||
9AC7802624176C04005CDD5C /* gma.cpp in Sources */,
|
||||
@ -994,6 +1021,7 @@
|
||||
9A28CD2A241BC0C700F3D247 /* strlen.cpp in Sources */,
|
||||
9AC7801424176C04005CDD5C /* Console.cpp in Sources */,
|
||||
9AC7809224176C04005CDD5C /* utf8Conversion.cpp in Sources */,
|
||||
9A9D3B2624221570006D8CD9 /* unicode_conversions.cpp in Sources */,
|
||||
9AC7802E24176C04005CDD5C /* StartupSound.cpp in Sources */,
|
||||
9AC7808724176C04005CDD5C /* globals_ctor.cpp in Sources */,
|
||||
9AC7807724176C04005CDD5C /* screen.cpp in Sources */,
|
||||
@ -1037,6 +1065,7 @@
|
||||
$PROJECT_DIR/../../MdePkg/Include,
|
||||
$PROJECT_DIR/../../MdePkg/Include/X64,
|
||||
$PROJECT_DIR/../../MdeModulePkg/Include,
|
||||
$PROJECT_DIR/../../Library/MemLogLibDefault,
|
||||
);
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
OTHER_CFLAGS = (
|
||||
@ -1080,6 +1109,7 @@
|
||||
$PROJECT_DIR/../../MdePkg/Include,
|
||||
$PROJECT_DIR/../../MdePkg/Include/X64,
|
||||
$PROJECT_DIR/../../MdeModulePkg/Include,
|
||||
$PROJECT_DIR/../../Library/MemLogLibDefault,
|
||||
);
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
OTHER_CFLAGS = (
|
||||
@ -1142,7 +1172,7 @@
|
||||
ENABLE_STRICT_OBJC_MSGSEND = NO;
|
||||
ENABLE_TESTABILITY = YES;
|
||||
EXECUTABLE_PREFIX = lib;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu11;
|
||||
GCC_C_LANGUAGE_STANDARD = c11;
|
||||
GCC_DYNAMIC_NO_PIC = NO;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
@ -1202,7 +1232,7 @@
|
||||
ENABLE_NS_ASSERTIONS = NO;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = NO;
|
||||
EXECUTABLE_PREFIX = lib;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu11;
|
||||
GCC_C_LANGUAGE_STANDARD = c11;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||
|
@ -63,7 +63,7 @@
|
||||
|
||||
<option id="gnu.c.compiler.option.dialect.std.2030898710" name="Language standard" superClass="gnu.c.compiler.option.dialect.std" useByScannerDiscovery="true" value="gnu.c.compiler.dialect.default" valueType="enumerated"/>
|
||||
|
||||
<option id="gnu.c.compiler.option.include.paths.665288508" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" useByScannerDiscovery="false" valueType="includePath">
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.c.compiler.option.include.paths.665288508" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" useByScannerDiscovery="false" valueType="includePath">
|
||||
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/Build/Clover/DEBUG_XCODE5/X64/rEFIt_UEFI/refit/DEBUG}""/>
|
||||
|
||||
@ -71,7 +71,7 @@
|
||||
|
||||
<option id="gnu.c.compiler.option.misc.other.508814619" name="Other flags" superClass="gnu.c.compiler.option.misc.other" useByScannerDiscovery="false" value="-c -Wno-unused-variable" valueType="string"/>
|
||||
|
||||
<option id="gnu.c.compiler.option.preprocessor.def.symbols.2146121461" name="Defined symbols (-D)" superClass="gnu.c.compiler.option.preprocessor.def.symbols" useByScannerDiscovery="false" valueType="definedSymbols">
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.c.compiler.option.preprocessor.def.symbols.2146121461" name="Defined symbols (-D)" superClass="gnu.c.compiler.option.preprocessor.def.symbols" useByScannerDiscovery="false" valueType="definedSymbols">
|
||||
|
||||
<listOptionValue builtIn="false" value="JIEF_DEBUG"/>
|
||||
|
||||
@ -87,13 +87,13 @@
|
||||
|
||||
<option id="gnu.cpp.compiler.option.debugging.level.1607661350" name="Debug Level" superClass="gnu.cpp.compiler.option.debugging.level" useByScannerDiscovery="false" value="gnu.cpp.compiler.debugging.level.max" valueType="enumerated"/>
|
||||
|
||||
<option id="gnu.cpp.compiler.option.include.paths.49749" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" useByScannerDiscovery="false" valueType="includePath">
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.cpp.compiler.option.include.paths.49749" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" useByScannerDiscovery="false" valueType="includePath">
|
||||
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/Clover--CloverHackyColor--master/Xcode/cpp_tests/src}""/>
|
||||
|
||||
</option>
|
||||
|
||||
<option id="gnu.cpp.compiler.option.preprocessor.def.298278300" name="Defined symbols (-D)" superClass="gnu.cpp.compiler.option.preprocessor.def" useByScannerDiscovery="false" valueType="definedSymbols">
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.cpp.compiler.option.preprocessor.def.298278300" name="Defined symbols (-D)" superClass="gnu.cpp.compiler.option.preprocessor.def" useByScannerDiscovery="false" valueType="definedSymbols">
|
||||
|
||||
<listOptionValue builtIn="false" value="JIEF_DEBUG"/>
|
||||
|
||||
@ -289,15 +289,11 @@
|
||||
|
||||
<option id="gnu.c.compiler.option.dialect.std.1356007946" name="Language standard" superClass="gnu.c.compiler.option.dialect.std" useByScannerDiscovery="true" value="gnu.c.compiler.dialect.default" valueType="enumerated"/>
|
||||
|
||||
<option id="gnu.c.compiler.option.include.paths.1530618516" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" useByScannerDiscovery="false" valueType="includePath">
|
||||
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/Build/Clover/DEBUG_GCC53/X64/rEFIt_UEFI/refit/DEBUG}""/>
|
||||
|
||||
</option>
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="true" id="gnu.c.compiler.option.include.paths.1530618516" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" useByScannerDiscovery="false" valueType="includePath"/>
|
||||
|
||||
<option id="gnu.c.compiler.option.misc.other.60881614" name="Other flags" superClass="gnu.c.compiler.option.misc.other" useByScannerDiscovery="false" value="-c -Wno-unused-variable" valueType="string"/>
|
||||
|
||||
<option id="gnu.c.compiler.option.preprocessor.def.symbols.135632191" name="Defined symbols (-D)" superClass="gnu.c.compiler.option.preprocessor.def.symbols" useByScannerDiscovery="false" valueType="definedSymbols">
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.c.compiler.option.preprocessor.def.symbols.135632191" name="Defined symbols (-D)" superClass="gnu.c.compiler.option.preprocessor.def.symbols" useByScannerDiscovery="false" valueType="definedSymbols">
|
||||
|
||||
<listOptionValue builtIn="false" value="JIEF_DEBUG"/>
|
||||
|
||||
@ -315,13 +311,13 @@
|
||||
|
||||
<option id="gnu.cpp.compiler.option.debugging.level.404624924" name="Debug Level" superClass="gnu.cpp.compiler.option.debugging.level" useByScannerDiscovery="false" value="gnu.cpp.compiler.debugging.level.max" valueType="enumerated"/>
|
||||
|
||||
<option id="gnu.cpp.compiler.option.include.paths.1173256935" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" useByScannerDiscovery="false" valueType="includePath">
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.cpp.compiler.option.include.paths.1173256935" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" useByScannerDiscovery="false" valueType="includePath">
|
||||
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/Clover--CloverHackyColor--master/Xcode/cpp_tests/src}""/>
|
||||
<listOptionValue builtIn="false" value="${ProjDirPath}/src"/>
|
||||
|
||||
</option>
|
||||
|
||||
<option id="gnu.cpp.compiler.option.preprocessor.def.131113190" name="Defined symbols (-D)" superClass="gnu.cpp.compiler.option.preprocessor.def" useByScannerDiscovery="false" valueType="definedSymbols">
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.cpp.compiler.option.preprocessor.def.131113190" name="Defined symbols (-D)" superClass="gnu.cpp.compiler.option.preprocessor.def" useByScannerDiscovery="false" valueType="definedSymbols">
|
||||
|
||||
<listOptionValue builtIn="false" value="JIEF_DEBUG"/>
|
||||
|
||||
|
@ -15,3 +15,7 @@ environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.macosx.exe.debug
|
||||
environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.macosx.exe.debug.1043399644.573872575/C_INCLUDE_PATH/operation=remove
|
||||
environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.macosx.exe.debug.1043399644.573872575/append=true
|
||||
environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.macosx.exe.debug.1043399644.573872575/appendContributed=true
|
||||
environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.macosx.exe.debug.1043399644.1294514338/LIBRARY_PATH/delimiter=\:
|
||||
environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.macosx.exe.debug.1043399644.1294514338/LIBRARY_PATH/operation=remove
|
||||
environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.macosx.exe.debug.1043399644.1294514338/append=true
|
||||
environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.macosx.exe.debug.1043399644.1294514338/appendContributed=true
|
||||
|
@ -17,10 +17,8 @@
|
||||
9A0B085E240300E000E2B470 /* Platform.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A0B085D240300E000E2B470 /* Platform.cpp */; };
|
||||
9A0B085F240308E400E2B470 /* XStringW.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A0B08482402FE9300E2B470 /* XStringW.cpp */; };
|
||||
9A0B08662403144C00E2B470 /* global_test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A0B08642403144C00E2B470 /* global_test.cpp */; };
|
||||
9A0B086D24039FE700E2B470 /* printf_lite.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A0B086B24039FE700E2B470 /* printf_lite.cpp */; };
|
||||
9A0B08732403B08400E2B470 /* XObjArray_tests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A0B08522402FE9B00E2B470 /* XObjArray_tests.cpp */; };
|
||||
9A0B08742403B08400E2B470 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A9223302402FD1000483CBA /* main.cpp */; };
|
||||
9A0B08752403B08400E2B470 /* printf_lite.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A0B086B24039FE700E2B470 /* printf_lite.cpp */; };
|
||||
9A0B08772403B08400E2B470 /* XStringWArray.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A0B08472402FE9300E2B470 /* XStringWArray.cpp */; };
|
||||
9A0B08792403B08400E2B470 /* XStringW.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A0B08482402FE9300E2B470 /* XStringW.cpp */; };
|
||||
9A0B087A2403B08400E2B470 /* all_tests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A0B08512402FE9B00E2B470 /* all_tests.cpp */; };
|
||||
@ -48,6 +46,9 @@
|
||||
9A28CD22241BB61B00F3D247 /* strlen.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A28CD1E241BB61B00F3D247 /* strlen.cpp */; };
|
||||
9A28CD23241BB61B00F3D247 /* strlen.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A28CD1E241BB61B00F3D247 /* strlen.cpp */; };
|
||||
9A28CD24241BB61B00F3D247 /* strlen.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A28CD1E241BB61B00F3D247 /* strlen.cpp */; };
|
||||
9A28CD4B241F4CCE00F3D247 /* xcode_utf16.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A28CD4A241F4CCE00F3D247 /* xcode_utf16.cpp */; };
|
||||
9A28CD4C241F4CCE00F3D247 /* xcode_utf16.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A28CD4A241F4CCE00F3D247 /* xcode_utf16.cpp */; };
|
||||
9A28CD4D241F4CCE00F3D247 /* xcode_utf16.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A28CD4A241F4CCE00F3D247 /* xcode_utf16.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 */; };
|
||||
@ -57,7 +58,6 @@
|
||||
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 */; };
|
||||
@ -78,10 +78,19 @@
|
||||
9A57C269241A799B0029A39F /* XString.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A57C267241A799B0029A39F /* XString.cpp */; };
|
||||
9A57C26A241A799B0029A39F /* XString.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A57C267241A799B0029A39F /* XString.cpp */; };
|
||||
9A9223312402FD1000483CBA /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A9223302402FD1000483CBA /* main.cpp */; };
|
||||
9AA0458A2425F94D000D6970 /* printf_lite-test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AA045892425F94D000D6970 /* printf_lite-test.cpp */; };
|
||||
9AA0458B2425F94D000D6970 /* printf_lite-test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AA045892425F94D000D6970 /* printf_lite-test.cpp */; };
|
||||
9AA0458C2425F94D000D6970 /* printf_lite-test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AA045892425F94D000D6970 /* printf_lite-test.cpp */; };
|
||||
9AA0458F2425F979000D6970 /* unicode_conversions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AA0458D2425F979000D6970 /* unicode_conversions.cpp */; };
|
||||
9AA045902425F979000D6970 /* unicode_conversions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AA0458D2425F979000D6970 /* unicode_conversions.cpp */; };
|
||||
9AA045912425F979000D6970 /* unicode_conversions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AA0458D2425F979000D6970 /* unicode_conversions.cpp */; };
|
||||
9AA05BB7240FC78D008EA4F8 /* utf8Conversion.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AA05BB6240FC78D008EA4F8 /* utf8Conversion.cpp */; };
|
||||
9AA05BB8240FC78D008EA4F8 /* utf8Conversion.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AA05BB6240FC78D008EA4F8 /* utf8Conversion.cpp */; };
|
||||
9AC780AE2417DD2F005CDD5C /* panic.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AC780A32417DD2F005CDD5C /* panic.cpp */; };
|
||||
9AC780AF2417DD2F005CDD5C /* panic.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AC780A32417DD2F005CDD5C /* panic.cpp */; };
|
||||
9ACAB117242623EE00BDB3CF /* printf_lite.c in Sources */ = {isa = PBXBuildFile; fileRef = 9ACAB116242623EE00BDB3CF /* printf_lite.c */; };
|
||||
9ACAB1192426255C00BDB3CF /* printf_lite.c in Sources */ = {isa = PBXBuildFile; fileRef = 9ACAB116242623EE00BDB3CF /* printf_lite.c */; };
|
||||
9ACAB11A2426255C00BDB3CF /* printf_lite.c in Sources */ = {isa = PBXBuildFile; fileRef = 9ACAB116242623EE00BDB3CF /* printf_lite.c */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXCopyFilesBuildPhase section */
|
||||
@ -135,9 +144,9 @@
|
||||
9A0B085D240300E000E2B470 /* Platform.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Platform.cpp; sourceTree = "<group>"; };
|
||||
9A0B08632403132300E2B470 /* XStringW_test.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XStringW_test.h; sourceTree = "<group>"; };
|
||||
9A0B08642403144C00E2B470 /* global_test.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = global_test.cpp; sourceTree = "<group>"; };
|
||||
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; };
|
||||
9A1A3FDC2424BC22008C89EB /* printf_lite.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = printf_lite.h; sourceTree = "<group>"; };
|
||||
9A1A3FE52424BC51008C89EB /* printf_lite-test-cpp_conf.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "printf_lite-test-cpp_conf.h"; sourceTree = "<group>"; };
|
||||
9A28CD05241B8DD400F3D247 /* strncmp_test.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = strncmp_test.cpp; sourceTree = "<group>"; };
|
||||
9A28CD06241B8DD400F3D247 /* strcmp_test.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = strcmp_test.cpp; sourceTree = "<group>"; };
|
||||
9A28CD07241B8DD400F3D247 /* strcmp_test.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = strcmp_test.h; sourceTree = "<group>"; };
|
||||
@ -148,6 +157,8 @@
|
||||
9A28CD15241BACBB00F3D247 /* strlen_test.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = strlen_test.cpp; sourceTree = "<group>"; };
|
||||
9A28CD1D241BB61B00F3D247 /* abort.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = abort.cpp; sourceTree = "<group>"; };
|
||||
9A28CD1E241BB61B00F3D247 /* strlen.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = strlen.cpp; sourceTree = "<group>"; };
|
||||
9A28CD49241F437C00F3D247 /* xcode_utf16.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = xcode_utf16.h; sourceTree = "<group>"; };
|
||||
9A28CD4A241F4CCE00F3D247 /* xcode_utf16.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = xcode_utf16.cpp; sourceTree = "<group>"; };
|
||||
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>"; };
|
||||
@ -163,10 +174,18 @@
|
||||
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>"; };
|
||||
9AA045732425D200000D6970 /* IO.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IO.h; sourceTree = "<group>"; };
|
||||
9AA045742425D200000D6970 /* IO.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = IO.cpp; sourceTree = "<group>"; };
|
||||
9AA045882425F94D000D6970 /* printf_lite-test.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "printf_lite-test.h"; sourceTree = "<group>"; };
|
||||
9AA045892425F94D000D6970 /* printf_lite-test.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = "printf_lite-test.cpp"; sourceTree = "<group>"; };
|
||||
9AA0458D2425F979000D6970 /* unicode_conversions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = unicode_conversions.cpp; sourceTree = "<group>"; };
|
||||
9AA0458E2425F979000D6970 /* unicode_conversions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = unicode_conversions.h; sourceTree = "<group>"; };
|
||||
9AA05BB6240FC78D008EA4F8 /* utf8Conversion.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = utf8Conversion.cpp; sourceTree = "<group>"; };
|
||||
9AA05BB9240FC796008EA4F8 /* utf8Conversion.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = utf8Conversion.h; sourceTree = "<group>"; };
|
||||
9AC780A32417DD2F005CDD5C /* panic.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = panic.cpp; sourceTree = "<group>"; };
|
||||
9AC780A62417DD2F005CDD5C /* panic.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = panic.h; sourceTree = "<group>"; };
|
||||
9ACAB116242623EE00BDB3CF /* printf_lite.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = printf_lite.c; sourceTree = "<group>"; };
|
||||
9ACAB1182426240C00BDB3CF /* printf_lite.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = printf_lite.h; path = ../../Include/Library/printf_lite.h; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
@ -197,8 +216,6 @@
|
||||
9A0B08432402FE9300E2B470 /* cpp_foundation */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
9A0B086B24039FE700E2B470 /* printf_lite.cpp */,
|
||||
9A0B086C24039FE700E2B470 /* printf_lite.h */,
|
||||
9AA05BB6240FC78D008EA4F8 /* utf8Conversion.cpp */,
|
||||
9AA05BB9240FC796008EA4F8 /* utf8Conversion.h */,
|
||||
9A0B084A2402FE9300E2B470 /* XArray.h */,
|
||||
@ -227,20 +244,25 @@
|
||||
9A0B08542402FE9B00E2B470 /* all_tests.h */,
|
||||
9A0B08642403144C00E2B470 /* global_test.cpp */,
|
||||
9A57C20A2418A1FD0029A39F /* global_test.h */,
|
||||
9A1A3FE52424BC51008C89EB /* printf_lite-test-cpp_conf.h */,
|
||||
9AA045892425F94D000D6970 /* printf_lite-test.cpp */,
|
||||
9AA045882425F94D000D6970 /* printf_lite-test.h */,
|
||||
9A28CD06241B8DD400F3D247 /* strcmp_test.cpp */,
|
||||
9A28CD07241B8DD400F3D247 /* strcmp_test.h */,
|
||||
9A28CD05241B8DD400F3D247 /* strncmp_test.cpp */,
|
||||
9A28CD08241B8DD400F3D247 /* strncmp_test.h */,
|
||||
9A28CD15241BACBB00F3D247 /* strlen_test.cpp */,
|
||||
9A28CD14241BACBB00F3D247 /* strlen_test.h */,
|
||||
9A28CD05241B8DD400F3D247 /* strncmp_test.cpp */,
|
||||
9A28CD08241B8DD400F3D247 /* strncmp_test.h */,
|
||||
9AA0458D2425F979000D6970 /* unicode_conversions.cpp */,
|
||||
9AA0458E2425F979000D6970 /* unicode_conversions.h */,
|
||||
9A0B08532402FE9B00E2B470 /* XArray_tests.cpp */,
|
||||
9A0B084E2402FE9B00E2B470 /* XArray_tests.h */,
|
||||
9A0B08522402FE9B00E2B470 /* XObjArray_tests.cpp */,
|
||||
9A0B08502402FE9B00E2B470 /* XObjArray_tests.h */,
|
||||
9A0B08552402FE9B00E2B470 /* XStringW_test.cpp */,
|
||||
9A0B08632403132300E2B470 /* XStringW_test.h */,
|
||||
9A57C261241A752E0029A39F /* XString_test.cpp */,
|
||||
9A57C262241A752E0029A39F /* XString_test.h */,
|
||||
9A0B08552402FE9B00E2B470 /* XStringW_test.cpp */,
|
||||
9A0B08632403132300E2B470 /* XStringW_test.h */,
|
||||
9A0B084F2402FE9B00E2B470 /* XStringWArray_test.cpp */,
|
||||
9A0B084D2402FE9B00E2B470 /* XStringWArray_test.h */,
|
||||
9A57C20F2418A3550029A39F /* XUINTN_test.cpp */,
|
||||
@ -250,6 +272,17 @@
|
||||
path = ../../rEFIt_UEFI/cpp_unit_test;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
9A1A3FD82424BC22008C89EB /* MemLogLibDefault */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
9ACAB1182426240C00BDB3CF /* printf_lite.h */,
|
||||
9ACAB116242623EE00BDB3CF /* printf_lite.c */,
|
||||
9A1A3FDC2424BC22008C89EB /* printf_lite.h */,
|
||||
);
|
||||
name = MemLogLibDefault;
|
||||
path = ../../Library/MemLogLibDefault;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
9A28CCAC241B816400F3D247 /* Platform */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
@ -272,6 +305,7 @@
|
||||
9A9223242402FD1000483CBA = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
9A1A3FD82424BC22008C89EB /* MemLogLibDefault */,
|
||||
9A0B08432402FE9300E2B470 /* cpp_foundation */,
|
||||
9A0B084C2402FE9B00E2B470 /* cpp_unit_test */,
|
||||
9A92232F2402FD1000483CBA /* Main */,
|
||||
@ -294,15 +328,27 @@
|
||||
9A92232F2402FD1000483CBA /* Main */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
9AA045782425D44D000D6970 /* PoolPrint */,
|
||||
9A9223302402FD1000483CBA /* main.cpp */,
|
||||
9A92234D2402FD9500483CBA /* Platform.h */,
|
||||
9A0B085D240300E000E2B470 /* Platform.cpp */,
|
||||
9A28CD13241B9FEE00F3D247 /* posix.h */,
|
||||
9A28CD49241F437C00F3D247 /* xcode_utf16.h */,
|
||||
9A28CD4A241F4CCE00F3D247 /* xcode_utf16.cpp */,
|
||||
);
|
||||
name = Main;
|
||||
path = src;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
9AA045782425D44D000D6970 /* PoolPrint */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
9AA045742425D200000D6970 /* IO.cpp */,
|
||||
9AA045732425D200000D6970 /* IO.h */,
|
||||
);
|
||||
path = PoolPrint;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
9AC7809C2417DD2F005CDD5C /* cpp_util */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
@ -409,9 +455,9 @@
|
||||
9A0B08732403B08400E2B470 /* XObjArray_tests.cpp in Sources */,
|
||||
9A28CD20241BB61B00F3D247 /* abort.cpp in Sources */,
|
||||
9A28CD23241BB61B00F3D247 /* strlen.cpp in Sources */,
|
||||
9A28CD4C241F4CCE00F3D247 /* xcode_utf16.cpp in Sources */,
|
||||
9A0B08742403B08400E2B470 /* main.cpp in Sources */,
|
||||
9A57C264241A752E0029A39F /* XString_test.cpp in Sources */,
|
||||
9A0B08752403B08400E2B470 /* printf_lite.cpp in Sources */,
|
||||
9A28CD17241BACBB00F3D247 /* strlen_test.cpp in Sources */,
|
||||
9A0B08772403B08400E2B470 /* XStringWArray.cpp in Sources */,
|
||||
9A57C2122418A3560029A39F /* XUINTN_test.cpp in Sources */,
|
||||
@ -423,10 +469,13 @@
|
||||
9A0B087A2403B08400E2B470 /* all_tests.cpp in Sources */,
|
||||
9A0B087B2403B08400E2B470 /* global_test.cpp in Sources */,
|
||||
9A0B087C2403B08400E2B470 /* XToolsCommon.cpp in Sources */,
|
||||
9ACAB1192426255C00BDB3CF /* printf_lite.c in Sources */,
|
||||
9AA045902425F979000D6970 /* unicode_conversions.cpp in Sources */,
|
||||
9A0B087D2403B08400E2B470 /* XStringWArray_test.cpp in Sources */,
|
||||
9A28CD11241B9EF800F3D247 /* strcmp.cpp in Sources */,
|
||||
9A57C2162418A6EA0029A39F /* XStringWP.cpp in Sources */,
|
||||
9A0B087E2403B08400E2B470 /* XArray_tests.cpp in Sources */,
|
||||
9AA0458B2425F94D000D6970 /* printf_lite-test.cpp in Sources */,
|
||||
9A0B087F2403B08400E2B470 /* Platform.cpp in Sources */,
|
||||
9A0B08802403B08400E2B470 /* XStringW_test.cpp in Sources */,
|
||||
9A57C269241A799B0029A39F /* XString.cpp in Sources */,
|
||||
@ -441,9 +490,9 @@
|
||||
9A57C21A2418B9A00029A39F /* XObjArray_tests.cpp in Sources */,
|
||||
9A28CD21241BB61B00F3D247 /* abort.cpp in Sources */,
|
||||
9A28CD24241BB61B00F3D247 /* strlen.cpp in Sources */,
|
||||
9A28CD4D241F4CCE00F3D247 /* xcode_utf16.cpp in Sources */,
|
||||
9A57C21B2418B9A00029A39F /* main.cpp in Sources */,
|
||||
9A57C265241A752E0029A39F /* XString_test.cpp in Sources */,
|
||||
9A57C21C2418B9A00029A39F /* printf_lite.cpp in Sources */,
|
||||
9A28CD18241BACBB00F3D247 /* strlen_test.cpp in Sources */,
|
||||
9A57C21D2418B9A00029A39F /* XStringWArray.cpp in Sources */,
|
||||
9A57C21E2418B9A00029A39F /* XUINTN_test.cpp in Sources */,
|
||||
@ -455,10 +504,13 @@
|
||||
9A57C2222418B9A00029A39F /* all_tests.cpp in Sources */,
|
||||
9A57C2232418B9A00029A39F /* global_test.cpp in Sources */,
|
||||
9A57C2242418B9A00029A39F /* XToolsCommon.cpp in Sources */,
|
||||
9ACAB11A2426255C00BDB3CF /* printf_lite.c in Sources */,
|
||||
9AA045912425F979000D6970 /* unicode_conversions.cpp in Sources */,
|
||||
9A57C2252418B9A00029A39F /* XStringWArray_test.cpp in Sources */,
|
||||
9A28CD12241B9EF800F3D247 /* strcmp.cpp in Sources */,
|
||||
9A57C2262418B9A00029A39F /* XStringWP.cpp in Sources */,
|
||||
9A57C2272418B9A00029A39F /* XArray_tests.cpp in Sources */,
|
||||
9AA0458C2425F94D000D6970 /* printf_lite-test.cpp in Sources */,
|
||||
9A57C2282418B9A00029A39F /* Platform.cpp in Sources */,
|
||||
9A57C2292418B9A00029A39F /* XStringW_test.cpp in Sources */,
|
||||
9A57C26A241A799B0029A39F /* XString.cpp in Sources */,
|
||||
@ -473,9 +525,9 @@
|
||||
9A0B085A2402FF8400E2B470 /* XObjArray_tests.cpp in Sources */,
|
||||
9A28CD1F241BB61B00F3D247 /* abort.cpp in Sources */,
|
||||
9A28CD22241BB61B00F3D247 /* strlen.cpp in Sources */,
|
||||
9A28CD4B241F4CCE00F3D247 /* xcode_utf16.cpp in Sources */,
|
||||
9A9223312402FD1000483CBA /* main.cpp in Sources */,
|
||||
9A57C263241A752E0029A39F /* XString_test.cpp in Sources */,
|
||||
9A0B086D24039FE700E2B470 /* printf_lite.cpp in Sources */,
|
||||
9A28CD16241BACBB00F3D247 /* strlen_test.cpp in Sources */,
|
||||
9A0B08562402FF7700E2B470 /* XStringWArray.cpp in Sources */,
|
||||
9A57C2112418A3560029A39F /* XUINTN_test.cpp in Sources */,
|
||||
@ -487,10 +539,13 @@
|
||||
9A0B08592402FF8200E2B470 /* all_tests.cpp in Sources */,
|
||||
9A0B08662403144C00E2B470 /* global_test.cpp in Sources */,
|
||||
9A0B08572402FF7A00E2B470 /* XToolsCommon.cpp in Sources */,
|
||||
9ACAB117242623EE00BDB3CF /* printf_lite.c in Sources */,
|
||||
9AA0458F2425F979000D6970 /* unicode_conversions.cpp in Sources */,
|
||||
9A0B08582402FF7F00E2B470 /* XStringWArray_test.cpp in Sources */,
|
||||
9A28CD10241B9EF800F3D247 /* strcmp.cpp in Sources */,
|
||||
9A57C2152418A6EA0029A39F /* XStringWP.cpp in Sources */,
|
||||
9A0B085B2402FF8700E2B470 /* XArray_tests.cpp in Sources */,
|
||||
9AA0458A2425F94D000D6970 /* printf_lite-test.cpp in Sources */,
|
||||
9A0B085E240300E000E2B470 /* Platform.cpp in Sources */,
|
||||
9A0B085C2402FF8B00E2B470 /* XStringW_test.cpp in Sources */,
|
||||
9A57C268241A799B0029A39F /* XString.cpp in Sources */,
|
||||
@ -504,7 +559,7 @@
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = JIEF_DEBUG;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = "$(inherited)";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
};
|
||||
name = Debug;
|
||||
@ -522,7 +577,15 @@
|
||||
buildSettings = {
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
GCC_CHAR_IS_UNSIGNED_CHAR = YES;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = JIEF_DEBUG;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"$(inherited)",
|
||||
"wcslen=utf16_wcslen",
|
||||
"wcsncmp=utf16_wcsncmp",
|
||||
);
|
||||
OTHER_CFLAGS = (
|
||||
"$(inherited)",
|
||||
"-fshort-wchar",
|
||||
);
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
};
|
||||
name = Debug;
|
||||
@ -532,6 +595,10 @@
|
||||
buildSettings = {
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
GCC_CHAR_IS_UNSIGNED_CHAR = YES;
|
||||
OTHER_CFLAGS = (
|
||||
"$(inherited)",
|
||||
"-fshort-wchar",
|
||||
);
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
};
|
||||
name = Release;
|
||||
@ -563,6 +630,7 @@
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_EXPLICIT_OWNERSHIP_TYPE = YES;
|
||||
CLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES = YES;
|
||||
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||
CLANG_WARN_OBJC_INTERFACE_IVARS = YES;
|
||||
@ -588,7 +656,8 @@
|
||||
GCC_DYNAMIC_NO_PIC = NO;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = "";
|
||||
GCC_PREFIX_HEADER = src/Platform.h;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = JIEF_DEBUG;
|
||||
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;
|
||||
@ -616,11 +685,7 @@
|
||||
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
|
||||
MTL_FAST_MATH = YES;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
OTHER_CFLAGS = (
|
||||
"-fshort-wchar",
|
||||
"-include",
|
||||
Platform.h,
|
||||
);
|
||||
OTHER_CFLAGS = "";
|
||||
SDKROOT = macosx;
|
||||
USE_HEADERMAP = NO;
|
||||
};
|
||||
@ -653,6 +718,7 @@
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_EXPLICIT_OWNERSHIP_TYPE = YES;
|
||||
CLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES = YES;
|
||||
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||
CLANG_WARN_OBJC_INTERFACE_IVARS = YES;
|
||||
@ -676,6 +742,7 @@
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu11;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
GCC_PREFIX_HEADER = src/Platform.h;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = "";
|
||||
GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES;
|
||||
GCC_TREAT_INCOMPATIBLE_POINTER_TYPE_WARNINGS_AS_ERRORS = YES;
|
||||
@ -703,11 +770,7 @@
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.13;
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
MTL_FAST_MATH = YES;
|
||||
OTHER_CFLAGS = (
|
||||
"-fshort-wchar",
|
||||
"-include",
|
||||
Platform.h,
|
||||
);
|
||||
OTHER_CFLAGS = "";
|
||||
SDKROOT = macosx;
|
||||
USE_HEADERMAP = NO;
|
||||
};
|
||||
@ -717,7 +780,15 @@
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = JIEF_DEBUG;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"$(inherited)",
|
||||
"wcslen=utf16_wcslen",
|
||||
"wcsncmp=utf16_wcsncmp",
|
||||
);
|
||||
OTHER_CFLAGS = (
|
||||
"$(inherited)",
|
||||
"-fshort-wchar",
|
||||
);
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
};
|
||||
name = Debug;
|
||||
@ -726,6 +797,10 @@
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
OTHER_CFLAGS = (
|
||||
"$(inherited)",
|
||||
"-fshort-wchar",
|
||||
);
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
};
|
||||
name = Release;
|
||||
|
@ -11,7 +11,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <wchar.h>
|
||||
//#include <wchar.h>
|
||||
#include <locale.h>
|
||||
|
||||
#include <string>
|
||||
@ -57,10 +57,11 @@ static char *dull_replace(const char *in, const char *pattern, const char *by, c
|
||||
|
||||
return res;
|
||||
}
|
||||
void DebugLog(int DebugMode, const char *FormatString, ...)
|
||||
|
||||
void DebugLog(INTN DebugMode, const char *FormatString, ...)
|
||||
{
|
||||
(void)DebugMode;
|
||||
|
||||
|
||||
char* NewFormat = (char*)alloca(strlen(FormatString)+1);
|
||||
dull_replace(FormatString, "%a", "%s", NewFormat);
|
||||
|
||||
@ -70,12 +71,38 @@ void DebugLog(int DebugMode, const char *FormatString, ...)
|
||||
va_end(va);
|
||||
}
|
||||
|
||||
void PauseForKey(const wchar_t* msg)
|
||||
{
|
||||
printf("%ls", msg);
|
||||
getchar();
|
||||
}
|
||||
|
||||
|
||||
|
||||
UINTN StrLen(const wchar_t* String)
|
||||
{
|
||||
return wchar_len(String);
|
||||
}
|
||||
UINTN StrLen(const char16_t* String)
|
||||
{
|
||||
return char16_len(String);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void* AllocatePool(UINTN AllocationSize)
|
||||
{
|
||||
return (void*)malloc((size_t)AllocationSize);
|
||||
}
|
||||
|
||||
void* AllocateZeroPool(UINTN AllocationSize)
|
||||
{
|
||||
void* p = (void*)malloc((size_t)AllocationSize);
|
||||
memset(p, 0, AllocationSize);
|
||||
return p;
|
||||
}
|
||||
|
||||
void* ReallocatePool(UINTN OldSize, UINTN NewSize, void* OldBuffer)
|
||||
{
|
||||
(void)OldSize;
|
||||
@ -88,120 +115,71 @@ void FreePool(const void* Buffer)
|
||||
free((void*)Buffer);
|
||||
}
|
||||
|
||||
void ZeroMem(void *Destination, UINTN Length)
|
||||
{
|
||||
memset(Destination, 0, Length);
|
||||
}
|
||||
|
||||
void SetMem(void *Destination, UINTN Length, char c)
|
||||
{
|
||||
memset(Destination, c, Length);
|
||||
}
|
||||
|
||||
void CopyMem(void *Destination, void *Source, UINTN Length)
|
||||
{
|
||||
memmove(Destination, Source, (size_t)Length);
|
||||
}
|
||||
|
||||
void PauseForKey(const wchar_t* msg)
|
||||
{
|
||||
printf("%ls", msg);
|
||||
getchar();
|
||||
}
|
||||
|
||||
UINTN AsciiStrLen(const char* String)
|
||||
{
|
||||
return (UINTN)strlen(String);
|
||||
}
|
||||
|
||||
INTN AsciiStrCmp (const char *FirstString,const char *SecondString)
|
||||
{
|
||||
return (INTN)strcmp(FirstString, SecondString);
|
||||
}
|
||||
|
||||
#if __WCHAR_MAX__ <= 0xFFFFu
|
||||
|
||||
#ifndef _MSC_VER
|
||||
|
||||
std::string utf16_to_utf8(const wchar_t* ws)
|
||||
{
|
||||
std::u16string s((const char16_t*)ws);
|
||||
std::wstring_convert<std::codecvt_utf8_utf16<char16_t, 0x10ffff, std::codecvt_mode::little_endian>, char16_t> cnv;
|
||||
std::string utf8 = cnv.to_bytes(s);
|
||||
// if(cnv.converted() < s.size())
|
||||
// throw std::runtime_error("incomplete conversion");
|
||||
return utf8;
|
||||
}
|
||||
|
||||
int is_surrogate(char16_t uc) { return (uc - 0xd800u) < 2048u; }
|
||||
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 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)
|
||||
{
|
||||
const char16_t * const end = input + input_size;
|
||||
while (input < end) {
|
||||
const char16_t uc = *input++;
|
||||
if (!is_surrogate(uc)) {
|
||||
(*output).push_back(uc);
|
||||
} else {
|
||||
if (is_high_surrogate(uc) && input < end && is_low_surrogate(*input))
|
||||
(*output).push_back(surrogate_to_utf32(uc, *input++));
|
||||
else {
|
||||
// ERROR
|
||||
}
|
||||
}
|
||||
}
|
||||
(*output).push_back(0);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
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 (UINTN)(p-String);
|
||||
}
|
||||
|
||||
int StrCmp(const wchar_t* FirstString, const wchar_t* SecondString)
|
||||
{
|
||||
#if __WCHAR_MAX__ > 0xFFFFu || _MSC_VER
|
||||
int ret = wcscmp(FirstString, SecondString);
|
||||
return ret;
|
||||
#else
|
||||
// Looks like wcscmp doesn't work with Utf16, even if compiled with -fshort-wchar.
|
||||
// So conversion to Utf32 needed first.
|
||||
|
||||
std::vector<char32_t> FirstStringUtf32;
|
||||
std::vector<char32_t> SecondStringUtf32;
|
||||
|
||||
convert_utf16_to_utf32((const char16_t*)FirstString, StrLen(FirstString), &FirstStringUtf32);
|
||||
convert_utf16_to_utf32((const char16_t*)SecondString, StrLen(FirstString), &SecondStringUtf32);
|
||||
|
||||
int ret = wcscmp((const wchar_t*)FirstStringUtf32.data(), (const wchar_t*)SecondStringUtf32.data());
|
||||
return ret;
|
||||
#endif
|
||||
}
|
||||
|
||||
int StrnCmp(const wchar_t* FirstString, const wchar_t* SecondString, UINTN Length)
|
||||
{
|
||||
#if __WCHAR_MAX__ > 0xFFFFu
|
||||
return wcsncmp(FirstString, SecondString, Length);
|
||||
#else
|
||||
|
||||
#ifdef _MSC_VER
|
||||
return wcsncmp(FirstString, SecondString, (size_t)Length);
|
||||
#else
|
||||
// Looks like wcscmp doesn't work with Utf16, even if compiled with -fshort-wchar.
|
||||
// So conversion to Utf32 needed first.
|
||||
|
||||
std::vector<char32_t> FirstStringUtf32;
|
||||
std::vector<char32_t> SecondStringUtf32;
|
||||
|
||||
convert_utf16_to_utf32((const char16_t*)FirstString, StrLen(FirstString), &FirstStringUtf32);
|
||||
convert_utf16_to_utf32((const char16_t*)SecondString, StrLen(FirstString), &SecondStringUtf32);
|
||||
|
||||
int ret = wcsncmp((const wchar_t*)FirstStringUtf32.data(), (const wchar_t*)SecondStringUtf32.data(), Length);
|
||||
//printf("wcsncmp=%d\n", ret);
|
||||
return ret;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
//UINTN AsciiStrLen(const char* String)
|
||||
//{
|
||||
// return (UINTN)strlen(String);
|
||||
//}
|
||||
//
|
||||
//INTN AsciiStrCmp (const char *FirstString,const char *SecondString)
|
||||
//{
|
||||
// return (INTN)strcmp(FirstString, SecondString);
|
||||
//}
|
||||
//int StrCmp(const wchar_t* FirstString, const wchar_t* SecondString)
|
||||
//{
|
||||
//#if __WCHAR_MAX__ > 0xFFFFu || _MSC_VER
|
||||
// int ret = wcscmp(FirstString, SecondString);
|
||||
// return ret;
|
||||
//#else
|
||||
// // Looks like wcscmp doesn't work with Utf16, even if compiled with -fshort-wchar.
|
||||
// // So conversion to Utf32 needed first.
|
||||
//
|
||||
// std::vector<char32_t> FirstStringUtf32;
|
||||
// std::vector<char32_t> SecondStringUtf32;
|
||||
//
|
||||
// convert_utf16_to_utf32((const char16_t*)FirstString, StrLen(FirstString), &FirstStringUtf32);
|
||||
// convert_utf16_to_utf32((const char16_t*)SecondString, StrLen(SecondString), &SecondStringUtf32);
|
||||
//
|
||||
// int ret = wcscmp((const wchar_t*)FirstStringUtf32.data(), (const wchar_t*)SecondStringUtf32.data());
|
||||
// return ret;
|
||||
//#endif
|
||||
//}
|
||||
//
|
||||
//int StrnCmp(const wchar_t* FirstString, const wchar_t* SecondString, UINTN Length)
|
||||
//{
|
||||
//#if __WCHAR_MAX__ > 0xFFFFu
|
||||
// return wcsncmp(FirstString, SecondString, Length);
|
||||
//#else
|
||||
//
|
||||
//#ifdef _MSC_VER
|
||||
// return wcsncmp(FirstString, SecondString, (size_t)Length);
|
||||
//#else
|
||||
// // Looks like wcscmp doesn't work with Utf16, even if compiled with -fshort-wchar.
|
||||
// // So conversion to Utf32 needed first.
|
||||
//
|
||||
// std::vector<char32_t> FirstStringUtf32;
|
||||
// std::vector<char32_t> SecondStringUtf32;
|
||||
//
|
||||
// convert_utf16_to_utf32((const char16_t*)FirstString, StrLen(FirstString), &FirstStringUtf32);
|
||||
// convert_utf16_to_utf32((const char16_t*)SecondString, StrLen(FirstString), &SecondStringUtf32);
|
||||
//
|
||||
// int ret = wcsncmp((const wchar_t*)FirstStringUtf32.data(), (const wchar_t*)SecondStringUtf32.data(), Length);
|
||||
////printf("wcsncmp=%d\n", ret);
|
||||
// return ret;
|
||||
//#endif
|
||||
//#endif
|
||||
//}
|
||||
|
@ -13,56 +13,72 @@
|
||||
#include <stdarg.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <inttypes.h>
|
||||
#include <wchar.h>
|
||||
#include "../../../rEFIt_UEFI/cpp_unit_test/unicode_conversions.h"
|
||||
#include "posix.h"
|
||||
#include "xcode_utf16.h"
|
||||
|
||||
#define UINTN unsigned long long
|
||||
#define MAX_UINTN ULONG_MAX
|
||||
#define BOOLEAN bool
|
||||
#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)
|
||||
#ifndef __cplusplus
|
||||
//typedef uint16_t wchar_t;
|
||||
typedef uint32_t char32_t;
|
||||
typedef uint16_t char16_t;
|
||||
#endif
|
||||
|
||||
|
||||
#define IN
|
||||
#define OUT
|
||||
|
||||
#define TRUE true
|
||||
#define FALSE false
|
||||
|
||||
#define VA_LIST va_list
|
||||
#define VA_START va_start
|
||||
#define VA_END va_end
|
||||
#define VA_ARG va_arg
|
||||
#define VA_COPY va_copy
|
||||
|
||||
#define VOID void
|
||||
#define EFIAPI
|
||||
#define CONST const
|
||||
#define EFI_STATUS INT64
|
||||
|
||||
typedef UINTN RETURN_STATUS;
|
||||
#define MAX_BIT 0x8000000000000000ULL
|
||||
#define ENCODE_ERROR(StatusCode) ((RETURN_STATUS)(MAX_BIT | (StatusCode)))
|
||||
|
||||
#define RETURN_OUT_OF_RESOURCES ENCODE_ERROR (9)
|
||||
|
||||
#define EFI_SUCCESS 0
|
||||
#define EFI_OUT_OF_RESOURCES RETURN_OUT_OF_RESOURCES
|
||||
|
||||
#define OPTIONAL
|
||||
#define ASSERT(x)
|
||||
|
||||
void CpuDeadLoop(void);
|
||||
void DebugLog(int DebugMode, const char *FormatString, ...);
|
||||
void DebugLog(INTN DebugMode, const char *FormatString, ...);
|
||||
|
||||
void PauseForKey(const wchar_t* msg);
|
||||
|
||||
|
||||
void* AllocatePool(UINTN AllocationSize);
|
||||
void* AllocateZeroPool(UINTN AllocationSize);
|
||||
void* ReallocatePool(UINTN OldSize, UINTN NewSize, void* OldBuffer);
|
||||
void FreePool(const void* Buffer);
|
||||
|
||||
void ZeroMem(void *Destination, UINTN Length);
|
||||
void SetMem(void *Destination, UINTN Length, char c);
|
||||
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);
|
||||
|
||||
|
||||
//UINTN StrLen(const char16_t* String);
|
||||
UINTN StrLen(const wchar_t* String);
|
||||
UINTN AsciiStrLen(const char* String);
|
||||
INTN AsciiStrCmp (const char *FirstString,const char *SecondString);
|
||||
//int StrCmp(const wchar_t* FirstString, const wchar_t* SecondString);
|
||||
//int StrnCmp(const wchar_t* FirstString, const wchar_t* SecondString, UINTN Length);
|
||||
//UINTN StrLen(const wchar_t* String);
|
||||
//UINTN AsciiStrLen(const char* String);
|
||||
//INTN AsciiStrCmp (const char *FirstString,const char *SecondString);
|
||||
|
||||
|
||||
|
||||
|
38
Xcode/cpp_tests/src/panic.cpp
Normal file
38
Xcode/cpp_tests/src/panic.cpp
Normal file
@ -0,0 +1,38 @@
|
||||
#include "panic.h"
|
||||
#include <Platform.h>
|
||||
|
||||
//extern "C" {
|
||||
//#include <Library/BaseLib.h> // for CpuDeadLoop
|
||||
//}
|
||||
|
||||
bool stop_at_panic = true;
|
||||
bool i_have_panicked = false;
|
||||
|
||||
/*
|
||||
*
|
||||
* 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, "%a\n", s);
|
||||
DebugLog(2, "A fatal error happened. System halted\n");
|
||||
CpuDeadLoop();
|
||||
}else{
|
||||
// if ( s ) DebugLog(2, "%a\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)
|
||||
{
|
||||
panic_(nullptr);
|
||||
}
|
10
Xcode/cpp_tests/src/panic.h
Normal file
10
Xcode/cpp_tests/src/panic.h
Normal file
@ -0,0 +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
|
@ -2,8 +2,60 @@
|
||||
#define __POSIX_H__
|
||||
|
||||
|
||||
#include "stdint.h"
|
||||
#include "stddef.h"
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <inttypes.h>
|
||||
#include <limits.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#if defined(__APPLE__) && defined(__clang__) && __WCHAR_MAX__ <= 0xFFFFu
|
||||
// 2020-03 : w... function are broken under macOs and clang with short-wchar.
|
||||
// Currently with clang version Apple LLVM version 10.0.0 (clang-1000.11.45.5) with High Sierra
|
||||
// If it's fixed one day, a version number could added to this #ifdef
|
||||
|
||||
# include "xcode_utf16.h"
|
||||
#else
|
||||
# include <wchar.h>
|
||||
#endif
|
||||
|
||||
//
|
||||
//#define MAX_UINTN ULONG_MAX
|
||||
#define BOOLEAN bool
|
||||
|
||||
|
||||
#define CHAR8 char
|
||||
//#define CHAR16 char16_t
|
||||
#define CHAR16 wchar_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 UINTN uint64_t
|
||||
#define INTN int64_t
|
||||
|
||||
#define MAX_UINTN MAX_UINT64
|
||||
#define MAX_INTN MAX_UINT64
|
||||
|
||||
////
|
||||
//// Macros that directly map functions to BaseLib, BaseMemoryLib, and DebugLib functions
|
||||
//// originally from OpensslLib
|
||||
@ -18,8 +70,8 @@
|
||||
//#define strncmp(string1,string2,count) (int)(AsciiStrnCmp(string1,string2,(UINTN)(count)))
|
||||
|
||||
//// edkII Strcmp seens quite inefficient, even vs a naive implementation
|
||||
int strcmp(const char* s1, const char* s2);
|
||||
int strncmp( const char* s1, const char* s2, size_t n );
|
||||
//xint strcmp(const char* s1, const char* s2);
|
||||
//int strncmp( const char* s1, const char* s2, size_t n );
|
||||
//
|
||||
//#ifdef CLOVER_BUILD
|
||||
//#define strcpy(strDest,strSource) AsciiStrCpyS(strDest,AsciiStrLen(strDest)+1,strSource)
|
||||
@ -39,6 +91,12 @@ int strncmp( const char* s1, const char* s2, size_t n );
|
||||
//}
|
||||
//
|
||||
|
||||
//
|
||||
//inline void* realloc(void *ptr, size_t newsize, size_t oldsize) // not the posix realloc. For EFI we need oldsize
|
||||
//{
|
||||
// (void)oldsize;
|
||||
// return realloc(ptr, newsize);
|
||||
//}
|
||||
|
||||
|
||||
#endif
|
||||
|
81
Xcode/cpp_tests/src/xcode_utf16.cpp
Normal file
81
Xcode/cpp_tests/src/xcode_utf16.cpp
Normal file
@ -0,0 +1,81 @@
|
||||
//
|
||||
// wfunction.hpp
|
||||
// cpp_tests
|
||||
//
|
||||
// Created by jief on 15.03.20.
|
||||
// Copyright © 2020 JF Knudsen. All rights reserved.
|
||||
//
|
||||
|
||||
//#include <stdarg.h>
|
||||
//#include <stdint.h>
|
||||
//#include <limits.h>
|
||||
//#include <stdlib.h>
|
||||
|
||||
#if defined(__APPLE__) && defined(__clang__) && __WCHAR_MAX__ <= 0xFFFFu
|
||||
|
||||
/*
|
||||
* clang had poisoned identifier like wcslen.
|
||||
* It's not possible to define a function with that name, not even a macro... except on the command line.
|
||||
* So, for this to work, pass macro definition argument on command line : wcslen=utf16_wcslen wcsncmp=utf16_wcsncmp
|
||||
*/
|
||||
|
||||
#include <vector>
|
||||
|
||||
static int is_surrogate(char16_t uc) { return (uc - 0xd800u) < 2048u; }
|
||||
static int is_high_surrogate(char16_t uc) { return (uc & 0xfffffc00) == 0xd800; }
|
||||
static int is_low_surrogate(char16_t uc) { return (uc & 0xfffffc00) == 0xdc00; }
|
||||
|
||||
static char32_t surrogate_to_utf32(char16_t high, char16_t low) {
|
||||
return char32_t((high << 10) + low - 0x35fdc00); // Safe cast, it fits in 32 bits
|
||||
}
|
||||
|
||||
static void convert_utf16_to_utf32(const char16_t* input, size_t input_size, std::vector<char32_t>* output)
|
||||
{
|
||||
const char16_t * const end = input + input_size;
|
||||
while (input < end && *input) {
|
||||
const char16_t uc = *input++;
|
||||
if (!is_surrogate(uc)) {
|
||||
(*output).push_back(uc);
|
||||
} else {
|
||||
if (is_high_surrogate(uc) && input < end && is_low_surrogate(*input))
|
||||
(*output).push_back(surrogate_to_utf32(uc, *input++));
|
||||
else {
|
||||
// ERROR
|
||||
}
|
||||
}
|
||||
}
|
||||
(*output).push_back(0);
|
||||
}
|
||||
|
||||
|
||||
size_t utf16_wcslen(const wchar_t *s)
|
||||
{
|
||||
// wcslen seems not to work if sizeof(wchar_t) == 2
|
||||
const wchar_t* p;
|
||||
for ( p = s ; *p ; p++ );
|
||||
return (UINTN)(p-s);
|
||||
}
|
||||
|
||||
int utf16_wcsncmp(const wchar_t *s1, const wchar_t * s2, size_t n)
|
||||
{
|
||||
// Looks like wcscmp doesn't work with Utf16, even if compiled with -fshort-wchar.
|
||||
// So conversion to Utf32 needed first.
|
||||
|
||||
std::vector<char32_t> s1Utf32;
|
||||
std::vector<char32_t> s2Utf32;
|
||||
|
||||
convert_utf16_to_utf32((const char16_t*)s1, n, &s1Utf32);
|
||||
convert_utf16_to_utf32((const char16_t*)s2, n, &s2Utf32);
|
||||
|
||||
// we don't know the new value of n (x UTF16 chars is not x*2 UTF32 chars), so we can't call wcsncmp
|
||||
// but that's ok because we converted only n UTF16 chars in the call of convert_utf16_to_utf32
|
||||
int ret = wcscmp((const wchar_t*)s1Utf32.data(), (const wchar_t*)s2Utf32.data());
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // defined(__APPLE__) && defined(__clang__) && __WCHAR_MAX__ <= 0xFFFFu
|
||||
|
36
Xcode/cpp_tests/src/xcode_utf16.h
Normal file
36
Xcode/cpp_tests/src/xcode_utf16.h
Normal file
@ -0,0 +1,36 @@
|
||||
//
|
||||
// wfunction.hpp
|
||||
// cpp_tests
|
||||
//
|
||||
// Created by jief on 15.03.20.
|
||||
// Copyright © 2020 JF Knudsen. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef __xcode_utf16_h__
|
||||
#define __xcode_utf16_h__
|
||||
|
||||
|
||||
#if defined(__APPLE__) && defined(__clang__) && __WCHAR_MAX__ <= 0xFFFFu
|
||||
|
||||
//#define wcslen utf16_wcsleny
|
||||
//#define strlen utf16_wcslenx
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* all the functions w... seems to expect utf32 even when compiled with short-wchar
|
||||
*/
|
||||
|
||||
size_t utf16_wcslen(const wchar_t *s);
|
||||
int utf16_wcsncmp(const wchar_t *s1, const wchar_t * s2, size_t n);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#endif // defined(__APPLE__) && defined(__clang__) && __WCHAR_MAX__ <= 0xFFFFu
|
||||
#endif /* wfunction_hpp */
|
@ -21,5 +21,7 @@ extern "C" {
|
||||
void abort(void)
|
||||
{
|
||||
DebugLog(2, "A fatal error happened. System halted\n");
|
||||
while (1) { // tis will avoid warning : Function declared 'noreturn' should not return
|
||||
CpuDeadLoop();
|
||||
}
|
||||
}
|
||||
|
@ -1 +1,2 @@
|
||||
//#define UINT_MAX
|
||||
#define SIZE_T_MAX MAX_UINTN
|
||||
|
13
rEFIt_UEFI/Platform/Posix/posix.h
Normal file → Executable file
13
rEFIt_UEFI/Platform/Posix/posix.h
Normal file → Executable file
@ -1,5 +1,5 @@
|
||||
#ifndef __POSIX_H__
|
||||
#define __POSIX_H__
|
||||
#ifndef __CLOVER_POSIX_H__
|
||||
#define __CLOVER_POSIX_H__
|
||||
|
||||
//
|
||||
//#ifdef __cplusplus
|
||||
@ -8,8 +8,15 @@
|
||||
|
||||
|
||||
|
||||
#include "stdio.h"
|
||||
#include "stdint.h"
|
||||
#include "stddef.h"
|
||||
#include "limits.h"
|
||||
#include "stdarg.h"
|
||||
#include "stdlib.h"
|
||||
#include "string.h"
|
||||
#include "wchar.h"
|
||||
|
||||
//
|
||||
// Macros that directly map functions to BaseLib, BaseMemoryLib, and DebugLib functions
|
||||
// originally from OpensslLib
|
||||
@ -18,7 +25,7 @@
|
||||
#define memset(dest,ch,count) SetMem(dest,(UINTN)(count),(UINT8)(ch))
|
||||
#define memchr(buf,ch,count) ScanMem8(buf,(UINTN)(count),(UINT8)ch)
|
||||
#define memcmp(buf1,buf2,count) (int)(CompareMem(buf1,buf2,(UINTN)(count)))
|
||||
#define memmove(dest,source,count) CopyMem(dest,source,(UINTN)(count))
|
||||
//#define memmove(dest,source,count) CopyMem(dest,source,(UINTN)(count))
|
||||
//#define strcmp AsciiStrCmp
|
||||
//#define strncmp(string1,string2,count) (int)(AsciiStrnCmp(string1,string2,(UINTN)(count)))
|
||||
#define strcpy(strDest,strSource) AsciiStrCpyS(strDest,AsciiStrLen(strDest)+1,strSource)
|
||||
|
@ -1,6 +1,9 @@
|
||||
#ifndef __CLOVER_STDARG_H__
|
||||
#define __CLOVER_STDARG_H__
|
||||
|
||||
#define va_list VA_LIST
|
||||
#define va_arg VA_ARG
|
||||
#define va_start VA_START
|
||||
#define va_end VA_END
|
||||
|
||||
#endif
|
||||
|
@ -1,19 +1,22 @@
|
||||
#ifndef __CLOVER_STDDEF_H__
|
||||
#define __CLOVER_STDDEF_H__
|
||||
|
||||
#include "stdint.h"
|
||||
|
||||
// How can we prevent VC to define this ?
|
||||
#ifdef _MSC_VER
|
||||
|
||||
// VS define size_t, but can't find a macro for SIZE_T_MAX
|
||||
#define SIZE_T_MAX MAX_UINTN
|
||||
// VS define size_t
|
||||
|
||||
#else
|
||||
|
||||
#define SIZE_T_MAX MAX_UINTN
|
||||
typedef UINTN size_t;
|
||||
// 2020-03 : On Gcc 9.2 and Clang (Apple LLVM version 10.0.0), size_t is not builtin, but __SIZE_TYPE__ is
|
||||
typedef __SIZE_TYPE__ size_t;
|
||||
//typedef long int ssize_t; // no __SSIZE_TYPE__. We don't use ssize_t in CLover. Let's try to keep it that way.
|
||||
|
||||
#endif
|
||||
|
||||
typedef INTN ptrdiff_t;
|
||||
typedef UINTN uintptr_t;
|
||||
|
||||
#endif
|
||||
|
@ -1,3 +1,7 @@
|
||||
#ifndef __CLOVER_STDINT_H__
|
||||
#define __CLOVER_STDINT_H__
|
||||
|
||||
|
||||
#define INT8_MIN (-128)
|
||||
#define INT16_MIN (-32768)
|
||||
#define INT32_MIN (-2147483647 - 1)
|
||||
@ -19,3 +23,22 @@ typedef UINT16 uint16_t;
|
||||
typedef UINT32 uint32_t;
|
||||
typedef UINT64 uint64_t;
|
||||
|
||||
|
||||
typedef INT8 int8_t;
|
||||
typedef INT16 int16_t;
|
||||
typedef INT32 int32_t;
|
||||
typedef INT64 int64_t;
|
||||
|
||||
#define PRId8 "hhd"
|
||||
#define PRId16 "hd"
|
||||
#define PRId32 "d"
|
||||
#define PRId64 "lld"
|
||||
|
||||
|
||||
#define PRIud8 "hhu"
|
||||
#define PRIu16 "hu"
|
||||
#define PRIu32 "u"
|
||||
#define PRIu64 "llu"
|
||||
|
||||
#endif
|
||||
|
||||
|
51
rEFIt_UEFI/Platform/Posix/stdio.cpp
Executable file
51
rEFIt_UEFI/Platform/Posix/stdio.cpp
Executable file
@ -0,0 +1,51 @@
|
||||
|
||||
|
||||
#include "stdio.h"
|
||||
#include "stdarg.h"
|
||||
#include <Library/printf_lite.h>
|
||||
|
||||
extern "C" {
|
||||
#include <Library/UefiLib.h>
|
||||
#include <Library/PrintLib.h>
|
||||
}
|
||||
|
||||
#include "../../cpp_foundation/XString.h"
|
||||
|
||||
int printf(const char* format, ...)
|
||||
{
|
||||
va_list va;
|
||||
char buf[1024]; // that's quick and dirty !!!
|
||||
|
||||
va_start (va, format);
|
||||
vsnprintf(buf, sizeof(buf), format, va);
|
||||
buf[sizeof(buf)-1] = 0; // just in case
|
||||
int ret = (int)AsciiPrint("%a", buf);
|
||||
va_end(va);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
static XString stdio_static_buf;
|
||||
|
||||
char* strerror(EFI_STATUS Status)
|
||||
{
|
||||
UINTN n = 0;
|
||||
do {
|
||||
stdio_static_buf.CheckSize(stdio_static_buf.length()+10);
|
||||
n = AsciiSPrint(stdio_static_buf.data(), stdio_static_buf.m_allocatedSize, "%r", Status);
|
||||
} while ( n > stdio_static_buf.m_allocatedSize - 2 );
|
||||
|
||||
return stdio_static_buf.data();
|
||||
}
|
||||
|
||||
char* strguid(EFI_GUID* guid)
|
||||
{
|
||||
UINTN n = 0;
|
||||
do {
|
||||
stdio_static_buf.CheckSize(stdio_static_buf.length()+10);
|
||||
n = AsciiSPrint(stdio_static_buf.data(), stdio_static_buf.m_allocatedSize, "%g", guid);
|
||||
} while ( n > stdio_static_buf.m_allocatedSize - 2 );
|
||||
|
||||
return stdio_static_buf.data();
|
||||
}
|
||||
|
30
rEFIt_UEFI/Platform/Posix/stdio.h
Normal file
30
rEFIt_UEFI/Platform/Posix/stdio.h
Normal file
@ -0,0 +1,30 @@
|
||||
#ifndef __CLOVER_STDIO_H__
|
||||
#define __CLOVER_STDIO_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <Library/printf_lite.h>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define __attribute__(x)
|
||||
#endif
|
||||
|
||||
int printf(const char* format, ...) __attribute__((format(printf, 1, 2)));
|
||||
|
||||
|
||||
//int snprintf(char* str, size_t size, const char* format, ...) __attribute__((format(printf, 1, 2)));;
|
||||
|
||||
char* strerror(EFI_STATUS errnum);
|
||||
char* strguid(EFI_GUID* guid);
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
@ -1 +1,28 @@
|
||||
#ifndef __CLOVER_STDLIB_H__
|
||||
#define __CLOVER_STDLIB_H__
|
||||
|
||||
|
||||
extern "C" {
|
||||
#include <Library/MemoryAllocationLib.h>
|
||||
}
|
||||
|
||||
#include "stddef.h" // for size_t
|
||||
|
||||
void abort(void);
|
||||
|
||||
inline void* malloc(size_t size)
|
||||
{
|
||||
return AllocatePool(size);
|
||||
}
|
||||
|
||||
inline void* realloc(void *ptr, size_t newsize, size_t oldsize) // not the posix realloc. For EFI we need oldsize
|
||||
{
|
||||
return ReallocatePool(oldsize, newsize, ptr);
|
||||
}
|
||||
|
||||
inline void free(void *ptr)
|
||||
{
|
||||
FreePool(ptr);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
13
rEFIt_UEFI/Platform/Posix/string.h
Normal file
13
rEFIt_UEFI/Platform/Posix/string.h
Normal file
@ -0,0 +1,13 @@
|
||||
#ifndef __CLOVER_STRING_H__
|
||||
#define __CLOVER_STRING_H__
|
||||
|
||||
extern "C" {
|
||||
#include <Library/BaseMemoryLib.h>
|
||||
}
|
||||
|
||||
inline void* memmove(void *dst, const void *src, size_t len)
|
||||
{
|
||||
return CopyMem(dst, (void*)(src), len);
|
||||
}
|
||||
|
||||
#endif
|
@ -1,9 +1,9 @@
|
||||
|
||||
//#include <posix.h> // use angled, so posix.h will vary depending of the platform
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h> // for abort
|
||||
#include <stddef.h> // for size_t
|
||||
#include <limits.h> // for SIZE_T_MAX
|
||||
|
||||
#ifdef MAP_TO_EDK_STRLEN
|
||||
extern "C" UINTN EFIAPI AsciiStrLen (IN CONST CHAR8 *String);
|
||||
|
14
rEFIt_UEFI/Platform/Posix/wchar.cpp
Executable file
14
rEFIt_UEFI/Platform/Posix/wchar.cpp
Executable file
@ -0,0 +1,14 @@
|
||||
|
||||
//#include <posix.h> // use angled, so posix.h will vary depending of the platform
|
||||
|
||||
#include <wchar.h>
|
||||
|
||||
|
||||
size_t wcslen(const wchar_t *s)
|
||||
{
|
||||
const wchar_t* p = s;
|
||||
while ( *p++ );
|
||||
return (size_t)(p-s-1);
|
||||
}
|
||||
|
||||
//int wcsncmp(const wchar_t *s1, const wchar_t * s2, size_t n);
|
9
rEFIt_UEFI/Platform/Posix/wchar.h
Normal file
9
rEFIt_UEFI/Platform/Posix/wchar.h
Normal file
@ -0,0 +1,9 @@
|
||||
#ifndef __CLOVER_WCHAR_H__
|
||||
#define __CLOVER_WCHAR_H__
|
||||
|
||||
#include "stddef.h" // for size_t
|
||||
|
||||
size_t wcslen(const wchar_t *s);
|
||||
int wcsncmp(const wchar_t *s1, const wchar_t * s2, size_t n);
|
||||
|
||||
#endif
|
@ -156,7 +156,7 @@ template<class TYPE>
|
||||
XArray<TYPE>::~XArray()
|
||||
{
|
||||
//printf("XArray Destructor\n");
|
||||
if ( m_data ) Xfree(m_data);
|
||||
if ( m_data ) free(m_data);
|
||||
}
|
||||
|
||||
/* CheckSize() */
|
||||
@ -166,9 +166,9 @@ void XArray<TYPE>::CheckSize(xsize nNewSize, xsize nGrowBy)
|
||||
//XArray_DBG("CheckSize: m_len=%d, m_size=%d, nGrowBy=%d, nNewSize=%d\n", m_len, m_size, nGrowBy, nNewSize);
|
||||
if ( nNewSize > m_allocatedSize ) {
|
||||
nNewSize += nGrowBy;
|
||||
m_data = (TYPE *)Xrealloc( m_allocatedSize * sizeof(TYPE), nNewSize * sizeof(TYPE), (void *)m_data);
|
||||
m_data = (TYPE *)realloc((void *)m_data, nNewSize * sizeof(TYPE), m_allocatedSize * sizeof(TYPE) );
|
||||
if ( !m_data ) {
|
||||
DebugLog(2, "XArray<TYPE>::CheckSize(nNewSize=%llu, nGrowBy=%llu) : Xrealloc(%d, %d, %d) returned NULL. System halted\n", nNewSize, nGrowBy, m_allocatedSize, nNewSize*sizeof(TYPE), m_data);
|
||||
DebugLog(2, "XArray<TYPE>::CheckSize(nNewSize=%llu, nGrowBy=%llu) : Xrealloc(%llu, %llu, %llu) 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.
|
||||
@ -318,7 +318,7 @@ template<class TYPE>
|
||||
void XArray<TYPE>::RemoveAtIndex(xsize nIndex)
|
||||
{
|
||||
if ( nIndex < m_len ) {
|
||||
if ( nIndex<m_len-1 ) Xmemmove(&m_data[nIndex], &m_data[nIndex+1], (m_len-nIndex-1)*sizeof(TYPE));
|
||||
if ( nIndex<m_len-1 ) memmove(&m_data[nIndex], &m_data[nIndex+1], (m_len-nIndex-1)*sizeof(TYPE));
|
||||
m_len -= 1;
|
||||
return;
|
||||
}
|
||||
|
@ -172,7 +172,7 @@ XObjArrayNC<TYPE>::~XObjArrayNC()
|
||||
{
|
||||
//printf("XObjArray Destructor\n");
|
||||
Empty();
|
||||
if ( _Data ) Xfree(_Data);
|
||||
if ( _Data ) free(_Data);
|
||||
}
|
||||
|
||||
/* CheckSize() */
|
||||
@ -181,9 +181,9 @@ void XObjArrayNC<TYPE>::CheckSize(xsize nNewSize, xsize nGrowBy)
|
||||
{
|
||||
if ( m_allocatedSize < nNewSize ) {
|
||||
nNewSize += nGrowBy + 1;
|
||||
_Data = (XObjArrayEntry<TYPE> *)Xrealloc(sizeof(XObjArrayEntry<TYPE>) * m_allocatedSize, sizeof(XObjArrayEntry<TYPE>) * nNewSize, (void *)_Data );
|
||||
_Data = (XObjArrayEntry<TYPE> *)realloc((void *)_Data, sizeof(XObjArrayEntry<TYPE>) * nNewSize, sizeof(XObjArrayEntry<TYPE>) * m_allocatedSize);
|
||||
if ( !_Data ) {
|
||||
XObjArray_DBG("XObjArrayNC<TYPE>::CheckSize(nNewSize=%llu, nGrowBy=%llu) : Xrealloc(%d, %d, %d) returned NULL. System halted\n", nNewSize, nGrowBy, m_allocatedSize, sizeof(XObjArrayEntry<TYPE>) * nNewSize, _Data);
|
||||
XObjArray_DBG("XObjArrayNC<TYPE>::CheckSize(nNewSize=%llu, nGrowBy=%llu) : Xrealloc(%llu, %llu, %llu) returned NULL. System halted\n", nNewSize, nGrowBy, m_allocatedSize, sizeof(XObjArrayEntry<TYPE>) * nNewSize, (uintptr_t)_Data);
|
||||
}
|
||||
// memset(&_Data[m_allocatedSize], 0, (nNewSize-m_allocatedSize) * sizeof(XObjArrayEntry<TYPE>));
|
||||
m_allocatedSize = nNewSize;
|
||||
@ -195,7 +195,7 @@ template<class TYPE>
|
||||
TYPE &XObjArrayNC<TYPE>::ElementAt(xsize index)
|
||||
{
|
||||
if ( index >= _Len ) {
|
||||
DebugLog(2, "XObjArray<TYPE>::ElementAt(xsize) -> operator [] - index (%d) greater than length (%d)\n", index, _Len);
|
||||
DebugLog(2, "XObjArray<TYPE>::ElementAt(xsize) -> operator [] - index (%llu) greater than length (%llu)\n", index, _Len);
|
||||
panic();
|
||||
}
|
||||
return *((TYPE *)(_Data[index].Object));
|
||||
@ -206,7 +206,7 @@ template<class TYPE>
|
||||
const TYPE &XObjArrayNC<TYPE>::ElementAt(xsize index) const
|
||||
{
|
||||
if ( index >= _Len ) {
|
||||
DebugLog(2, "XObjArray<TYPE>::ElementAt(xsize) const -> operator [] - index (%d) greater than length (%d)\n", index, _Len);
|
||||
DebugLog(2, "XObjArray<TYPE>::ElementAt(xsize) const -> operator [] - index (%llu) greater than length (%llu)\n", index, _Len);
|
||||
panic();
|
||||
}
|
||||
return *((TYPE *)(_Data[index].Object));
|
||||
@ -426,7 +426,7 @@ void XObjArrayNC<TYPE>::RemoveAtIndex(xsize nIndex)
|
||||
if ( nIndex < XObjArrayNC<TYPE>::_Len )
|
||||
{
|
||||
if ( nIndex >= XObjArrayNC<TYPE>::_Len ) {
|
||||
DebugLog(2, "void XObjArrayNC<TYPE>::RemoveAtIndex(xsize nIndex) : BUG nIndex (%d) is > length(). System halted\n", nIndex);
|
||||
DebugLog(2, "void XObjArrayNC<TYPE>::RemoveAtIndex(xsize nIndex) : BUG nIndex (%llu) is > length(). System halted\n", nIndex);
|
||||
panic();
|
||||
}
|
||||
}
|
||||
@ -437,7 +437,7 @@ void XObjArrayNC<TYPE>::RemoveAtIndex(xsize nIndex)
|
||||
TmpObject = (TYPE *)(_Data[nIndex].Object);
|
||||
delete TmpObject;
|
||||
}
|
||||
if ( nIndex<XObjArrayNC<TYPE>::_Len-1 ) Xmemmove(&_Data[nIndex], &_Data[nIndex+1], (_Len-nIndex-1)*sizeof(XObjArrayEntry<TYPE>));
|
||||
if ( nIndex<XObjArrayNC<TYPE>::_Len-1 ) memmove(&_Data[nIndex], &_Data[nIndex+1], (_Len-nIndex-1)*sizeof(XObjArrayEntry<TYPE>));
|
||||
_Len -= 1;
|
||||
return;
|
||||
}
|
||||
|
@ -15,7 +15,7 @@
|
||||
#include "XString.h"
|
||||
#include "XStringW.h"
|
||||
|
||||
#include "printf_lite.h"
|
||||
#include "../../Include/Library/printf_lite.h"
|
||||
|
||||
//#ifndef memcpy
|
||||
//#define memcpy(dest,source,count) CopyMem(dest,(void*)(source),(UINTN)(count))
|
||||
@ -27,13 +27,13 @@
|
||||
//#define memmove(dest,source,count) CopyMem(dest,source,(UINTN)(count))
|
||||
//#endif
|
||||
|
||||
xsize XStringGrowByDefault = 1024;
|
||||
xsize XStringGrowByDefault = 2;
|
||||
const XString NullXString;
|
||||
|
||||
|
||||
void XString::Init(xsize aSize)
|
||||
{
|
||||
c = (char*)Xalloc( (aSize+1)*sizeof(char) ); /* le 0 terminal n'est pas compté dans mSize */
|
||||
c = (char*)malloc( (aSize+1)*sizeof(char) ); /* le 0 terminal n'est pas compté dans mSize */
|
||||
if ( !c ) {
|
||||
DebugLog(2, "XString::Init(%d) : Xalloc returned NULL. Cpu halted\n", (aSize+1)*sizeof(char));
|
||||
panic();
|
||||
@ -67,7 +67,7 @@ char *XString::CheckSize(xsize nNewSize, xsize nGrowBy)
|
||||
{
|
||||
|
||||
nNewSize += nGrowBy;
|
||||
c = (char*)Xrealloc(m_allocatedSize*sizeof(wchar_t), (nNewSize+1)*sizeof(char), c);
|
||||
c = (char*)realloc(c, (nNewSize+1)*sizeof(char), m_allocatedSize*sizeof(wchar_t));
|
||||
if ( !c ) {
|
||||
DBG("XString::CheckSize(%d, %d) : Xrealloc(%d, %d, %d) returned NULL. System halted\n", nNewSize, nGrowBy, m_size, (nNewSize+1)*sizeof(char), c);
|
||||
panic();
|
||||
@ -119,7 +119,7 @@ void XString::Cat(const XString &uneXString)
|
||||
SetLength(length() + uneXString.length());
|
||||
}
|
||||
|
||||
inline void XString::StrnCat(const char *buf)
|
||||
void XString::StrCat(const char *buf)
|
||||
{
|
||||
if ( buf && *buf ) {
|
||||
StrnCat(buf, (xsize)strlen(buf)); // overflow ?
|
||||
@ -147,136 +147,142 @@ void XString::Insert(xsize pos, const XString& Str)
|
||||
memmove(data()+pos+Str.length(), data()+pos, length()-pos+1); // +1 to copy the NULL terminator
|
||||
memcpy(data()+pos, Str.data(), Str.length());
|
||||
}else{
|
||||
StrnCat(Str);
|
||||
StrCat(Str);
|
||||
}
|
||||
}
|
||||
|
||||
void XString::Replace(char c1, char c2)
|
||||
{
|
||||
char* p;
|
||||
|
||||
p = data();
|
||||
while ( *p ) {
|
||||
if ( *p == c1 ) *p = c2;
|
||||
p += 1;
|
||||
}
|
||||
}
|
||||
|
||||
XString XString::SubStringReplace(char c1, char c2)
|
||||
{
|
||||
char* p;
|
||||
XString Result;
|
||||
|
||||
p = data();
|
||||
while ( *p ) {
|
||||
if ( *p == c1 ) Result += c2;
|
||||
else Result += *p;
|
||||
p++;
|
||||
}
|
||||
return Result;
|
||||
}
|
||||
//
|
||||
//void XString::vSPrintf(const char *Format, va_list va)
|
||||
// Deactivate assignment during refactoring to avoid confusion
|
||||
//void XString::Replace(char c1, char c2)
|
||||
//{
|
||||
// char buf[16384]; // faire mieux un jour...
|
||||
// int nb;
|
||||
// char* p;
|
||||
//
|
||||
// #if defined(__DEV_BORLANDC__) || defined(__DEV_UNIX__)
|
||||
// nb = vsprintf(buf, Format, va);
|
||||
// #elif defined(__DEV_WIN32__)
|
||||
// nb = _vsnprintf(buf, sizeof(buf), Format, va);
|
||||
// #else
|
||||
// #error Plateforme false supportee
|
||||
// #endif
|
||||
// if ( nb > 0 ) StrnCpy(buf, nb);
|
||||
// else SetNull();
|
||||
// p = data();
|
||||
// while ( *p ) {
|
||||
// if ( *p == c1 ) *p = c2;
|
||||
// p += 1;
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//XString XString::SubStringReplace(char c1, char c2)
|
||||
//{
|
||||
// char* p;
|
||||
// XString Result;
|
||||
//
|
||||
// p = data();
|
||||
// while ( *p ) {
|
||||
// if ( *p == c1 ) Result += c2;
|
||||
// else Result += *p;
|
||||
// p++;
|
||||
// }
|
||||
// return Result;
|
||||
//}
|
||||
|
||||
static XString* XString_sprintfBuf;
|
||||
static xsize XString_sprintfBuf_len;
|
||||
static wchar_t XString_char_wait;
|
||||
/* this is used when printf can only output unicode, so we need a conversion back to utf8 */
|
||||
//static XString* XString_sprintfBuf;
|
||||
//static xsize XString_sprintfBuf_len;
|
||||
//static wchar_t XString_char_wait;
|
||||
//
|
||||
//static unsigned int XString_transmitSPrintf_utf32(const wchar_t wchar1, const wchar_t wchar2)
|
||||
//{
|
||||
// unsigned int ret = 0;
|
||||
// UINTN utf32_char;
|
||||
//
|
||||
// if ((wchar1 & 0xFC00) == 0xD800) { /* surrogates */
|
||||
// if ((wchar2 & 0xFC00) == 0xDC00) {
|
||||
// utf32_char = wchar1;
|
||||
// utf32_char &= 0x03FF;
|
||||
// utf32_char <<= 10;
|
||||
// utf32_char |= ((UINTN)wchar2) & 0x03FF;
|
||||
// utf32_char += 0x10000;
|
||||
// ret = 2;
|
||||
// }else{
|
||||
// // error
|
||||
// return 1; // Ignore wchar1. Tell the caller we used wchar1
|
||||
// }
|
||||
// }else{
|
||||
// utf32_char = wchar1;
|
||||
// ret = 1;
|
||||
// }
|
||||
//
|
||||
// /* assertion: utf32_char is a single UTF-4 value */
|
||||
// int bits;
|
||||
//
|
||||
// if (utf32_char < 0x80) {
|
||||
// (*XString_sprintfBuf) += (char)utf32_char;
|
||||
// bits = -6;
|
||||
// }
|
||||
// else if (utf32_char < 0x800) {
|
||||
// (*XString_sprintfBuf) += (char)(((utf32_char >> 6) & 0x1F) | 0xC0);
|
||||
// bits = 0;
|
||||
// }
|
||||
// else if (utf32_char < 0x10000) {
|
||||
// (*XString_sprintfBuf) += (char)(((utf32_char >> 12) & 0x0F) | 0xE0);
|
||||
// bits = 6;
|
||||
// }
|
||||
// else {
|
||||
// (*XString_sprintfBuf) += (char)(((utf32_char >> 18) & 0x07) | 0xF0);
|
||||
// bits = 12;
|
||||
// }
|
||||
// for (; bits >= 0; bits -= 6) {
|
||||
// (*XString_sprintfBuf) += (char)(((utf32_char >> bits) & 0x3F) | 0x80);
|
||||
// }
|
||||
// return ret;
|
||||
//}
|
||||
//
|
||||
//
|
||||
//static void XString_transmitSPrintf(const wchar_t* buf, size_t nbchar)
|
||||
//{
|
||||
//
|
||||
// #if __WCHAR_MAX__ <= 0xFFFF
|
||||
// // wchar_t is UTF16
|
||||
//
|
||||
// unsigned int ret = 1;
|
||||
// if ( XString_char_wait ) {
|
||||
// ret = XString_transmitSPrintf_utf32(XString_char_wait, buf[0]);
|
||||
// XString_char_wait = 0;
|
||||
// }
|
||||
// xsize i;
|
||||
// for ( i = ret-1 ; i < nbchar-1 ; ) // cast ok, ret >
|
||||
// {
|
||||
// ret = XString_transmitSPrintf_utf32(buf[i], buf[i+1]);
|
||||
// i += ret;
|
||||
// }
|
||||
// if ( i < nbchar ) XString_char_wait = buf[i];
|
||||
// #else
|
||||
// #warning TODO
|
||||
// #endif
|
||||
//}
|
||||
//
|
||||
//void XString::vSPrintf(const char* format, va_list va)
|
||||
//{
|
||||
// SetLength(0);
|
||||
//
|
||||
// XString_sprintfBuf = this;
|
||||
// XString_sprintfBuf_len = 0;
|
||||
// XString_char_wait = 0;
|
||||
// vprintf_with_callback(format, va, XString_transmitSPrintf);
|
||||
// if ( XString_char_wait ) XString_transmitSPrintf_utf32(XString_char_wait, 0);
|
||||
//}
|
||||
|
||||
static unsigned int XString_transmitSPrintf_utf32(const wchar_t wchar1, const wchar_t wchar2)
|
||||
//static XString* XString_sprintfBuf;
|
||||
|
||||
static void XString_transmitSPrintf(const char* buf, unsigned int nbchar, void* context)
|
||||
{
|
||||
unsigned int ret = 0;
|
||||
UINTN utf32_char;
|
||||
|
||||
if ((wchar1 & 0xFC00) == 0xD800) { /* surrogates */
|
||||
if ((wchar2 & 0xFC00) == 0xDC00) {
|
||||
utf32_char = wchar1;
|
||||
utf32_char &= 0x03FF;
|
||||
utf32_char <<= 10;
|
||||
utf32_char |= ((UINTN)wchar2) & 0x03FF;
|
||||
utf32_char += 0x10000;
|
||||
ret = 2;
|
||||
}else{
|
||||
// error
|
||||
return 1; // Ignore wchar1. Tell the caller we used wchar1
|
||||
}
|
||||
}else{
|
||||
utf32_char = wchar1;
|
||||
ret = 1;
|
||||
}
|
||||
|
||||
/* assertion: utf32_char is a single UTF-4 value */
|
||||
int bits;
|
||||
|
||||
if (utf32_char < 0x80) {
|
||||
(*XString_sprintfBuf) += (char)utf32_char;
|
||||
bits = -6;
|
||||
}
|
||||
else if (utf32_char < 0x800) {
|
||||
(*XString_sprintfBuf) += (char)(((utf32_char >> 6) & 0x1F) | 0xC0);
|
||||
bits = 0;
|
||||
}
|
||||
else if (utf32_char < 0x10000) {
|
||||
(*XString_sprintfBuf) += (char)(((utf32_char >> 12) & 0x0F) | 0xE0);
|
||||
bits = 6;
|
||||
}
|
||||
else {
|
||||
(*XString_sprintfBuf) += (char)(((utf32_char >> 18) & 0x07) | 0xF0);
|
||||
bits = 12;
|
||||
}
|
||||
for (; bits >= 0; bits -= 6) {
|
||||
(*XString_sprintfBuf) += (char)(((utf32_char >> bits) & 0x3F) | 0x80);
|
||||
}
|
||||
return ret;
|
||||
// (*XString_sprintfBuf).StrnCat(buf, nbchar);
|
||||
((XString*)(context))->StrnCat(buf, (xsize)nbchar); // nbchar cannot be negative
|
||||
}
|
||||
|
||||
|
||||
static void XString_transmitSPrintf(const wchar_t* buf, size_t nbchar)
|
||||
{
|
||||
|
||||
#if __WCHAR_MAX__ <= 0xFFFF
|
||||
// wchar_t is UTF16
|
||||
|
||||
unsigned int ret = 1;
|
||||
if ( XString_char_wait ) {
|
||||
ret = XString_transmitSPrintf_utf32(XString_char_wait, buf[0]);
|
||||
XString_char_wait = 0;
|
||||
}
|
||||
xsize i;
|
||||
for ( i = ret-1 ; i < nbchar-1 ; ) // cast ok, ret >
|
||||
{
|
||||
ret = XString_transmitSPrintf_utf32(buf[i], buf[i+1]);
|
||||
i += ret;
|
||||
}
|
||||
if ( i < nbchar ) XString_char_wait = buf[i];
|
||||
#else
|
||||
#error TODO
|
||||
#endif
|
||||
}
|
||||
|
||||
void XString::vSPrintf(const char* format, VA_LIST va)
|
||||
XString& XString::vSPrintf(const char* format, va_list va)
|
||||
{
|
||||
SetLength(0);
|
||||
|
||||
XString_sprintfBuf = this;
|
||||
XString_sprintfBuf_len = 0;
|
||||
XString_char_wait = 0;
|
||||
vprintf_with_callback(format, va, XString_transmitSPrintf);
|
||||
if ( XString_char_wait ) XString_transmitSPrintf_utf32(XString_char_wait, 0);
|
||||
|
||||
// XString_sprintfBuf = this;
|
||||
vprintf_with_callback(format, va, XString_transmitSPrintf, this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
//void XString::vSPrintf(const char* format, va_list va)
|
||||
//{
|
||||
// This is an attempt to use _PPrint from IO.c. Problem is : you have to allocate the memory BEFORE calling it.
|
||||
// POOL_PRINT spc;
|
||||
// PRINT_STATE ps;
|
||||
@ -293,42 +299,35 @@ void XString::vSPrintf(const char* format, VA_LIST va)
|
||||
//
|
||||
// VA_COPY(ps.args, va);
|
||||
// _PPrint (&ps);
|
||||
// VA_END(ps.args);
|
||||
}
|
||||
// va_end(ps.args);
|
||||
//}
|
||||
|
||||
void XString::SPrintf(const char *Format, ...)
|
||||
XString& XString::SPrintf(const char *Format, ...)
|
||||
{
|
||||
va_list va;
|
||||
|
||||
va_start(va, Format);
|
||||
vSPrintf(Format, va);
|
||||
va_end(va);
|
||||
return *this;
|
||||
}
|
||||
|
||||
//
|
||||
//XStringW XString::wcs()
|
||||
//{
|
||||
// XBuffer xbuf;
|
||||
//// wchar_t buf[length() + 1];
|
||||
// size_t nbchar = mbstowcs((wchar_t *)xbuf.DataWithSizeMin(0, sizeof(wchar_t)*length()), c, length());
|
||||
// if ( nbchar == (size_t)-1 ) throw("XString::wcs() -> Conversion error");
|
||||
// return XStringW((wchar_t *)xbuf.data(), xsize(nbchar)); // safe cast : nbchar cannot be > than Length
|
||||
//}
|
||||
|
||||
// Deactivate assignment during refactoring to avoid confusion
|
||||
XString XString::basename() const
|
||||
{
|
||||
if ( LastChar() == PATH_SEPARATOR ) {
|
||||
DebugLog(2, "XString::basename() -> LastChar() == PATH_SEPARATOR");
|
||||
panic();
|
||||
}
|
||||
xsize idx = RIdxOf(PATH_SEPARATOR);
|
||||
xsize idx = RIdxOf(XString().SPrintf("%c",PATH_SEPARATOR)); // ctor char disabled during refactoring to avoid confusion
|
||||
if ( idx == MAX_XSIZE ) return NullXString;
|
||||
return SubString(idx+1, length()-idx-1);
|
||||
}
|
||||
|
||||
XString XString::dirname() const
|
||||
{
|
||||
xsize idx = RIdxOf(PATH_SEPARATOR);
|
||||
xsize idx = RIdxOf(XString().SPrintf("%c",PATH_SEPARATOR)); // ctor char disabled during refactoring to avoid confusion
|
||||
if ( idx == MAX_XSIZE ) return NullXString;
|
||||
#ifdef __DEV_WIN32__
|
||||
if ( idx == 1 && *data(0) == PATH_SEPARATOR ) {
|
||||
@ -350,11 +349,12 @@ XString::XString(const XString &aString)
|
||||
StrnCpy(aString.data(), aString.length());
|
||||
}
|
||||
|
||||
XString::XString(const wchar_t *S)
|
||||
{
|
||||
Init();
|
||||
SPrintf("%ls", S);
|
||||
}
|
||||
//// Deactivate assignment during refactoring to avoid confusion
|
||||
//XString::XString(const wchar_t *S)
|
||||
//{
|
||||
// Init();
|
||||
// SPrintf("%ls", S);
|
||||
//}
|
||||
|
||||
/*
|
||||
XString::XString(const NSString* const aNSString, NSStringEncoding encoding)
|
||||
@ -379,35 +379,37 @@ XString::XString(const NSString* const aNSString, NSStringEncoding encoding)
|
||||
// StrnCpy( aConstString.data() );
|
||||
//}
|
||||
|
||||
XString::XString(const char *S)
|
||||
{
|
||||
//Debugf("Construteur const char * : %s\n", S);
|
||||
Init((xsize)strlen(S)); // overflow ?
|
||||
if ( S ) StrCpy(S);
|
||||
}
|
||||
|
||||
XString::XString(const char *S, xsize count)
|
||||
{
|
||||
//Debugf("Construteur const char *, unsigned int :%s %d\n", S, count);
|
||||
Init(count);
|
||||
StrnCpy(S, count);
|
||||
}
|
||||
// Deactivate assignment during refactoring to avoid confusion
|
||||
//XString::XString(const char *S)
|
||||
//{
|
||||
////Debugf("Construteur const char * : %s\n", S);
|
||||
// Init((xsize)strlen(S)); // overflow ?
|
||||
// if ( S ) StrCpy(S);
|
||||
//}
|
||||
//
|
||||
//XString::XString(const char *S, xsize count)
|
||||
//{
|
||||
////Debugf("Construteur const char *, unsigned int :%s %d\n", S, count);
|
||||
// Init(count);
|
||||
// StrnCpy(S, count);
|
||||
//}
|
||||
|
||||
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
// Constructeurs CaractËres
|
||||
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
|
||||
XString::XString(char aChar)
|
||||
{
|
||||
//TRACE("Construteur char \n");
|
||||
Init(1);
|
||||
StrnCpy(&aChar, 1);
|
||||
}
|
||||
// Deactivate assignment during refactoring to avoid confusion
|
||||
//XString::XString(char aChar)
|
||||
//{
|
||||
////TRACE("Construteur char \n");
|
||||
// Init(1);
|
||||
// StrnCpy(&aChar, 1);
|
||||
//}
|
||||
|
||||
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
// Constructeurs numériques
|
||||
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
//
|
||||
|
||||
//XString::XString(int i)
|
||||
//{
|
||||
// char buf[1024];
|
||||
@ -418,7 +420,7 @@ XString::XString(char aChar)
|
||||
// Init(len);
|
||||
// StrnCpy(buf, len);
|
||||
//}
|
||||
//
|
||||
|
||||
//XString::XString(unsigned int ui)
|
||||
//{
|
||||
// char buf[1024];
|
||||
@ -465,7 +467,7 @@ XString::XString(char aChar)
|
||||
XString XString::SubString(xsize pos, xsize count) const
|
||||
{
|
||||
if ( count > length()-pos ) count = length()-pos;
|
||||
return XString( &(data()[pos]), count);
|
||||
return XString().takeValueFrom( &(data()[pos]), count);
|
||||
}
|
||||
|
||||
xsize XString::IdxOf(char aChar, xsize Pos) const
|
||||
@ -806,12 +808,13 @@ void XString::RemoveLastEspCtrl()
|
||||
// Opérateur = CaractËres
|
||||
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
|
||||
const XString &XString::operator =(char aChar)
|
||||
{
|
||||
//TRACE("Operator =char \n");
|
||||
StrnCpy(&aChar, 1);
|
||||
return *this;
|
||||
}
|
||||
// Deactivate assignment during refactoring to avoid confusion
|
||||
//const XString &XString::operator =(char aChar)
|
||||
//{
|
||||
////TRACE("Operator =char \n");
|
||||
// StrnCpy(&aChar, 1);
|
||||
// return *this;
|
||||
//}
|
||||
|
||||
|
||||
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
@ -850,12 +853,13 @@ const XString &XString::operator =(const wxString &awxString)
|
||||
// return *this;
|
||||
//}
|
||||
|
||||
const XString &XString::operator =(const char *S)
|
||||
{
|
||||
//TRACE("Operator =const char *\n");
|
||||
StrCpy(S);
|
||||
return *this;
|
||||
}
|
||||
// Deactivate assignment during refactoring to avoid confusion
|
||||
//const XString &XString::operator =(const char *S)
|
||||
//{
|
||||
////TRACE("Operator =const char *\n");
|
||||
// StrCpy(S);
|
||||
// return *this;
|
||||
//}
|
||||
|
||||
|
||||
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
@ -919,12 +923,13 @@ const XString &XString::operator =(const char *S)
|
||||
// Opérateur = CaractËres
|
||||
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
|
||||
const XString &XString::operator +=(char aChar)
|
||||
{
|
||||
//TRACE("Operator +=char \n");
|
||||
StrnCat(&aChar, 1);
|
||||
return *this;
|
||||
}
|
||||
// Deactivate assignment during refactoring to avoid confusion
|
||||
//const XString &XString::operator +=(char aChar)
|
||||
//{
|
||||
////TRACE("Operator +=char \n");
|
||||
// StrnCat(&aChar, 1);
|
||||
// return *this;
|
||||
//}
|
||||
|
||||
|
||||
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
@ -948,7 +953,7 @@ const XString &XString::operator +=(const XString &aString)
|
||||
const XString &XString::operator +=(const char *S)
|
||||
{
|
||||
//TRACE("operator +=const char *\n");
|
||||
StrnCat(S);
|
||||
StrCat(S);
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -1008,12 +1013,12 @@ const XString &XString::operator +=(const char *S)
|
||||
|
||||
XString SPrintf(const char *format, ...)
|
||||
{
|
||||
VA_LIST va;
|
||||
va_list va;
|
||||
XString str;
|
||||
|
||||
VA_START (va, format);
|
||||
va_start (va, format);
|
||||
str.vSPrintf(format, va);
|
||||
VA_END(va);
|
||||
va_end(va);
|
||||
|
||||
return str;
|
||||
}
|
||||
@ -1021,7 +1026,7 @@ XString SPrintf(const char *format, ...)
|
||||
XString SubString(const char *S, xsize pos, xsize count)
|
||||
{
|
||||
if ( strlen(S)-pos < count ) count = (xsize)(strlen(S)-pos); // overflow ?
|
||||
return ( XString(S+pos, count) );
|
||||
return XString().takeValueFrom( S+pos, count );
|
||||
}
|
||||
|
||||
#ifdef NOT_USED_ANYMORE_skqdjfhksqjhfksjqdf
|
||||
@ -1077,16 +1082,17 @@ XString ToUpper(const char *S)
|
||||
}
|
||||
#endif
|
||||
|
||||
XString CleanCtrl(const XString &S)
|
||||
{
|
||||
XString ReturnValue;
|
||||
xsize i;
|
||||
|
||||
for ( i=0 ; i<S.length() ; i+=1 ) {
|
||||
if ( S[i] >=0 && S[i] < ' ' ) ReturnValue += 'x'; /* Les char sont signés !!! */
|
||||
else ReturnValue += S[i];
|
||||
}
|
||||
return ReturnValue;
|
||||
}
|
||||
// Deactivate assignment during refactoring to avoid confusion
|
||||
//XString CleanCtrl(const XString &S)
|
||||
//{
|
||||
// XString ReturnValue;
|
||||
// xsize i;
|
||||
//
|
||||
// for ( i=0 ; i<S.length() ; i+=1 ) {
|
||||
// if ( S[i] >=0 && S[i] < ' ' ) ReturnValue += 'x'; /* Les char sont signés !!! */
|
||||
// else ReturnValue += S[i];
|
||||
// }
|
||||
// return ReturnValue;
|
||||
//}
|
||||
|
||||
#endif
|
||||
|
@ -33,15 +33,15 @@ class XString
|
||||
XString(const XString &aString);
|
||||
|
||||
// XString(const XConstString &aConstString);
|
||||
XString(const char *S);
|
||||
XString(const char* S, xsize count);
|
||||
// XString(const char *S);
|
||||
// XString(const char* S, xsize count);
|
||||
|
||||
XString(const wchar_t *S);
|
||||
// XString(const wchar_t *S);
|
||||
|
||||
// XString(uchar);
|
||||
XString(char);
|
||||
XString(int);
|
||||
XString(unsigned long long);
|
||||
// XString(char);
|
||||
// XString(int);
|
||||
// XString(unsigned long long);
|
||||
|
||||
~XString();
|
||||
|
||||
@ -50,11 +50,12 @@ class XString
|
||||
|
||||
public:
|
||||
const char *data(xsize ui=0) const { return c+ui; }
|
||||
const char *c_str() const { return c; } // same as std::string
|
||||
char *data(xsize ui=0) { return (char*)(c+ui); }
|
||||
char *data(int i) { if ( i<0 ) panic("const wchar_t *data(INTN i=0) const -> i < 0"); return c+i; }
|
||||
char *DataWithSizeMin(xsize ui, xsize size, xsize nGrowBy=XStringGrowByDefault) { CheckSize(size, nGrowBy); return data(ui); }
|
||||
|
||||
xsize length() const { return (xsize)AsciiStrLen(c); }
|
||||
xsize length() const { return strlen(c); }
|
||||
xsize Size() const { return m_allocatedSize; }
|
||||
void SetLength(xsize len);
|
||||
|
||||
@ -98,15 +99,15 @@ class XString
|
||||
void StrCpy(const char *buf);
|
||||
void StrnCpy(const char *buf, xsize len);
|
||||
void StrnCat(const char *buf, xsize len);
|
||||
void StrnCat(const char *buf);
|
||||
void StrCat(const char *buf);
|
||||
void Delete(xsize pos, xsize count=1);
|
||||
|
||||
void Insert(xsize pos, const XString& Str);
|
||||
|
||||
void Cat(const XString &uneXString);
|
||||
|
||||
void vSPrintf(const char *Format, VA_LIST va);
|
||||
void SPrintf(const char *format, ...)
|
||||
XString& vSPrintf(const char *Format, va_list va);
|
||||
XString& SPrintf(const char *format, ...)
|
||||
#ifndef _MSC_VER
|
||||
__attribute__((format (printf, 2, 3))) // 2 and 3 because of hidden parameter.
|
||||
#endif
|
||||
@ -114,25 +115,30 @@ class XString
|
||||
|
||||
|
||||
const XString& takeValueFrom(const char* S) { StrCpy(S); return *this; }
|
||||
const XString& takeValueFrom(const char* S, xsize count) { StrnCpy(S, count); return *this; }
|
||||
const XString& takeValueFrom(const wchar_t* S) { SPrintf("%ls", S); return *this; }
|
||||
|
||||
const XString &operator =(const XString &aString);
|
||||
// const XString &operator =(const XConstString &aConstString);
|
||||
const XString &operator =(const char* S);
|
||||
const XString &operator =(char);
|
||||
const XString &operator =(int);
|
||||
const XString &operator =(unsigned int);
|
||||
const XString &operator =(long);
|
||||
const XString &operator =(unsigned long long);
|
||||
|
||||
// Deactivate assignment during refactoring to avoid confusion
|
||||
// const XString &operator =(const char* S);
|
||||
// const XString &operator =(char);
|
||||
// const XString &operator =(int);
|
||||
// const XString &operator =(unsigned int);
|
||||
// const XString &operator =(long);
|
||||
// const XString &operator =(unsigned long long);
|
||||
|
||||
const XString &operator += (const XString &);
|
||||
// const XString &operator += (const XConstString &aConstString);
|
||||
const XString &operator += (const char* S);
|
||||
const XString &operator += (char);
|
||||
const XString &operator += (int);
|
||||
const XString &operator += (unsigned int);
|
||||
const XString &operator += (long);
|
||||
const XString &operator += (unsigned long long);
|
||||
// const XString &operator += (const XConstString &aConstString);
|
||||
|
||||
// Deactivate assignment during refactoring to avoid confusion
|
||||
// const XString &operator += (char);
|
||||
// const XString &operator += (int);
|
||||
// const XString &operator += (unsigned int);
|
||||
// const XString &operator += (long);
|
||||
// const XString &operator += (unsigned long long);
|
||||
|
||||
XString SubString(xsize pos, xsize count) const;
|
||||
xsize IdxOf(char c, xsize Pos = 0) const;
|
||||
@ -173,7 +179,7 @@ class XString
|
||||
*/
|
||||
#endif
|
||||
|
||||
bool Equal(const char* S) const { return AsciiStrCmp(data(), (S ? S : "")) == 0; };
|
||||
bool Equal(const char* S) const { return strcmp(data(), (S ? S : "")) == 0; };
|
||||
// bool BeginEqual(const char* S) const { return StringBeginEqual(data(), S); }
|
||||
// bool SubStringEqual(xsize Pos, const char* S) const { return StringBeginEqual(data(Pos), S); }
|
||||
#ifdef TODO_skqdjfhksqjhfksjqdf
|
||||
@ -215,24 +221,26 @@ class XString
|
||||
// Chaines
|
||||
friend XString operator + (const XString& p1, const XString& p2) { XString s; s=p1; s+=p2; return s; }
|
||||
friend XString operator + (const XString& p1, const char *p2 ) { XString s; s=p1; s+=p2; return s; }
|
||||
friend XString operator + (const char *p1, const XString& p2) { XString s; s=p1; s+=p2; return s; }
|
||||
friend XString operator + (const char *p1, const XString& p2) { XString s; s.takeValueFrom(p1); s+=p2; return s; }
|
||||
// friend XString operator + (const XConstString& p1, const XString& p2) { XString s; s=p1; s+=p2; return s; }
|
||||
// friend XString operator + (const XString& p1, const XConstString& p2) { XString s; s=p1; s+=p2; return s; }
|
||||
// friend XString operator + (const XConstString& p1, const XConstString& p2) { XString s; s=p1; s+=p2; return s; }
|
||||
// friend XString operator + (const XConstString &p1, const char *p2 ) { XString s; s=p1; s+=p2; return s; }
|
||||
// friend XString operator + (const char *p1, const XConstString &p2) { XString s; s=p1; s+=p2; return s; }
|
||||
// Char
|
||||
friend XString operator + (const XString& p1, char p2 ) { XString s; s=p1; s+=p2; return s; }
|
||||
friend XString operator + (char p1, const XString& p2 ) { XString s; s=p1; s+=p2; return s; }
|
||||
// NumÈrique
|
||||
friend XString operator + (const XString& p1, int p2 ) { XString s; s=p1; s+=p2; return s; }
|
||||
friend XString operator + (int p1, const XString& p2 ) { XString s; s=p1; s+=p2; return s; }
|
||||
friend XString operator + (const XString& p1, unsigned int p2 ) { XString s; s=p1; s+=p2; return s; }
|
||||
friend XString operator + (unsigned int p1, const XString& p2 ) { XString s; s=p1; s+=p2; return s; }
|
||||
friend XString operator + (const XString& p1, long p2 ) { XString s; s=p1; s+=p2; return s; }
|
||||
friend XString operator + (long p1, const XString& p2 ) { XString s; s=p1; s+=p2; return s; }
|
||||
friend XString operator + (const XString& p1, unsigned long long p2 ) { XString s; s=p1; s+=p2; return s; }
|
||||
friend XString operator + (unsigned long long p1, const XString& p2 ) { XString s; s=p1; s+=p2; return s; }
|
||||
|
||||
// deactivate during refactoring
|
||||
// // Char
|
||||
// friend XString operator + (const XString& p1, char p2 ) { XString s; s=p1; s+=p2; return s; }
|
||||
// friend XString operator + (char p1, const XString& p2 ) { XString s; s=p1; s+=p2; return s; }
|
||||
// // NumÈrique
|
||||
// friend XString operator + (const XString& p1, int p2 ) { XString s; s=p1; s+=p2; return s; }
|
||||
// friend XString operator + (int p1, const XString& p2 ) { XString s; s=p1; s+=p2; return s; }
|
||||
// friend XString operator + (const XString& p1, unsigned int p2 ) { XString s; s=p1; s+=p2; return s; }
|
||||
// friend XString operator + (unsigned int p1, const XString& p2 ) { XString s; s=p1; s+=p2; return s; }
|
||||
// friend XString operator + (const XString& p1, long p2 ) { XString s; s=p1; s+=p2; return s; }
|
||||
// friend XString operator + (long p1, const XString& p2 ) { XString s; s=p1; s+=p2; return s; }
|
||||
// friend XString operator + (const XString& p1, unsigned long long p2 ) { XString s; s=p1; s+=p2; return s; }
|
||||
// friend XString operator + (unsigned long long p1, const XString& p2 ) { XString s; s=p1; s+=p2; return s; }
|
||||
|
||||
// OpÈrateur ==
|
||||
// Chaines
|
||||
@ -282,6 +290,7 @@ XString ToAlpha(const XString &S);
|
||||
XString ToLower(const char *S, bool FirstCharIsCap = false);
|
||||
XString ToUpper(const char *S);
|
||||
#endif
|
||||
XString CleanCtrl(const XString &S);
|
||||
// Deactivate assignment during refactoring to avoid confusion
|
||||
//XString CleanCtrl(const XString &S);
|
||||
|
||||
#endif
|
||||
|
@ -21,7 +21,7 @@
|
||||
#include "XToolsCommon.h"
|
||||
#include "XStringW.h"
|
||||
|
||||
#include "printf_lite.h"
|
||||
#include "../../Include/Library/printf_lite.h"
|
||||
|
||||
UINTN XStringWGrowByDefault = 1024;
|
||||
const XStringW NullXStringW;
|
||||
@ -30,7 +30,7 @@ const XStringW NullXStringW;
|
||||
void XStringW::Init(UINTN aSize)
|
||||
{
|
||||
//DBG("Init aSize=%d\n", aSize);
|
||||
m_data = (wchar_t*)Xalloc( (aSize+1)*sizeof(wchar_t) ); /* le 0 terminal n'est pas compté dans mSize */
|
||||
m_data = (wchar_t*)malloc( (aSize+1)*sizeof(wchar_t) ); /* le 0 terminal n'est pas compté dans mSize */
|
||||
if ( !m_data ) {
|
||||
DebugLog(2, "XStringW::Init(%d) : Xalloc returned NULL. Cpu halted\n", (aSize+1)*sizeof(wchar_t));
|
||||
panic();
|
||||
@ -90,6 +90,12 @@ DBG("Constructor(const XStringW &aString) : %s\n", aString.data());
|
||||
// utf8ToWChar(m_data, m_allocatedSize+1, S, AsciiStrLen(S)); // m_size doesn't count the NULL terminator
|
||||
// SetLength(newLen);
|
||||
//}
|
||||
wchar_t * XStringW::forgetDataWithoutFreeing()
|
||||
{
|
||||
wchar_t* ret = m_data;
|
||||
Init();
|
||||
return ret;
|
||||
}
|
||||
|
||||
const XStringW& XStringW::takeValueFrom(const wchar_t* S)
|
||||
{
|
||||
@ -97,7 +103,7 @@ const XStringW& XStringW::takeValueFrom(const wchar_t* S)
|
||||
DebugLog(2, "takeValueFrom(const wchar_t* S) called with NULL. Use setEmpty()\n");
|
||||
panic();
|
||||
}
|
||||
Init(StrLen(S));
|
||||
Init(wcslen(S));
|
||||
StrCpy(S);
|
||||
return *this;
|
||||
}
|
||||
@ -119,7 +125,7 @@ const XStringW& XStringW::takeValueFrom(const char* S)
|
||||
XStringW::~XStringW()
|
||||
{
|
||||
DBG("Destructor :%s\n", data());
|
||||
FreePool((void*)m_data);
|
||||
free((void*)m_data);
|
||||
}
|
||||
|
||||
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
@ -134,7 +140,7 @@ void XStringW::SetLength(UINTN len)
|
||||
m_len = len;
|
||||
m_data[len] = 0;
|
||||
|
||||
if ( StrLen(data()) != len ) {
|
||||
if ( wcslen(data()) != len ) {
|
||||
DBG("XStringW::SetLength(UINTN len) : StrLen(data()) != len (%d != %d). System halted\n", StrLen(data()), len);
|
||||
panic();
|
||||
}
|
||||
@ -148,7 +154,7 @@ wchar_t *XStringW::CheckSize(UINTN nNewSize, UINTN nGrowBy)
|
||||
if ( m_allocatedSize < nNewSize )
|
||||
{
|
||||
nNewSize += nGrowBy;
|
||||
m_data = (wchar_t*)Xrealloc(m_allocatedSize*sizeof(wchar_t), (nNewSize+1)*sizeof(wchar_t), m_data);
|
||||
m_data = (wchar_t*)realloc(m_data, (nNewSize+1)*sizeof(wchar_t), m_allocatedSize*sizeof(wchar_t));
|
||||
if ( !m_data ) {
|
||||
DBG("XStringW::CheckSize(%d, %d) : Xrealloc(%d, %d, %d) returned NULL. System halted\n", nNewSize, nGrowBy, m_size, (nNewSize+1)*sizeof(wchar_t), m_data);
|
||||
panic();
|
||||
@ -166,7 +172,7 @@ void XStringW::StrnCpy(const wchar_t *buf, UINTN len)
|
||||
while ( *buf && newLen < len ) {
|
||||
m_data[newLen++] = *buf++;
|
||||
}
|
||||
// Xmemmove(data(), buf, len*sizeof(wchar_t));
|
||||
// memmove(data(), buf, len*sizeof(wchar_t));
|
||||
}
|
||||
SetLength(newLen); /* data()[len]=0 done in SetLength */
|
||||
}
|
||||
@ -174,7 +180,7 @@ void XStringW::StrnCpy(const wchar_t *buf, UINTN len)
|
||||
void XStringW::StrCpy(const wchar_t *buf)
|
||||
{
|
||||
if ( buf && *buf ) {
|
||||
StrnCpy(buf, StrLen(buf));
|
||||
StrnCpy(buf, wcslen(buf));
|
||||
}else{
|
||||
SetLength(0); /* data()[0]=0 done in SetLength */
|
||||
}
|
||||
@ -187,7 +193,7 @@ void XStringW::StrnCat(const wchar_t *buf, UINTN len)
|
||||
if ( buf && *buf && len > 0 ) {
|
||||
NewLen = length()+len;
|
||||
CheckSize(NewLen, 0);
|
||||
Xmemmove(data(length()), buf, len*sizeof(wchar_t));
|
||||
memmove(data(length()), buf, len*sizeof(wchar_t));
|
||||
SetLength(NewLen); /* data()[NewLen]=0 done in SetLength */
|
||||
}
|
||||
}
|
||||
@ -195,7 +201,7 @@ void XStringW::StrnCat(const wchar_t *buf, UINTN len)
|
||||
void XStringW::StrCat(const wchar_t *buf)
|
||||
{
|
||||
if ( buf && *buf ) {
|
||||
StrnCat(buf, StrLen(buf));
|
||||
StrnCat(buf, wcslen(buf));
|
||||
}
|
||||
}
|
||||
|
||||
@ -208,7 +214,7 @@ void XStringW::Delete(UINTN pos, UINTN count)
|
||||
{
|
||||
if ( pos < length() ) {
|
||||
if ( count != MAX_XSIZE && pos + count < length() ) {
|
||||
Xmemmove( data(pos), data(pos+count), (length()-pos-count)*sizeof(wchar_t)); // Xmemmove handles overlapping memory move
|
||||
memmove( data(pos), data(pos+count), (length()-pos-count)*sizeof(wchar_t)); // memmove handles overlapping memory move
|
||||
SetLength(length()-count);/* data()[length()-count]=0 done in SetLength */
|
||||
}else{
|
||||
SetLength(pos);/* data()[pos]=0 done in SetLength */
|
||||
@ -220,8 +226,8 @@ void XStringW::Insert(UINTN pos, const XStringW& Str)
|
||||
{
|
||||
if ( pos < length() ) {
|
||||
CheckSize(length()+Str.length());
|
||||
Xmemmove(data(pos + Str.length()), data(pos), (length()-pos)*sizeof(wchar_t));
|
||||
Xmemmove(data(pos), Str.data(), Str.length()*sizeof(wchar_t));
|
||||
memmove(data(pos + Str.length()), data(pos), (length()-pos)*sizeof(wchar_t));
|
||||
memmove(data(pos), Str.data(), Str.length()*sizeof(wchar_t));
|
||||
SetLength(length()+Str.length());
|
||||
}else{
|
||||
StrCat(Str);
|
||||
@ -253,21 +259,26 @@ XStringW XStringW::SubStringReplace(wchar_t c1, wchar_t c2)
|
||||
return Result;
|
||||
}
|
||||
|
||||
static XStringW* XStringW_sprintfBuf;
|
||||
//static XStringW* XStringW_sprintfBuf;
|
||||
|
||||
static void XStringW_transmitSPrintf(const wchar_t* buf, size_t nbyte)
|
||||
static void XStringW_transmitSPrintf(const wchar_t* buf, unsigned int nbchar, void* context)
|
||||
{
|
||||
(*XStringW_sprintfBuf).StrnCat(buf, nbyte);
|
||||
// (*XStringW_sprintfBuf).StrnCat(buf, nbchar);
|
||||
((XStringW*)(context))->StrnCat(buf, nbchar);
|
||||
}
|
||||
|
||||
void XStringW::vSPrintf(const char* format, VA_LIST va)
|
||||
void XStringW::vSPrintf(const char* format, va_list va)
|
||||
{
|
||||
SetLength(0);
|
||||
|
||||
XStringW_sprintfBuf = this;
|
||||
vprintf_with_callback(format, va, XStringW_transmitSPrintf);
|
||||
|
||||
// This is an attempt to use _PPrint from IO.c. Problem is : you have to allocate the memory BEFORE calling it.
|
||||
// XStringW_sprintfBuf = this;
|
||||
|
||||
vwprintf_with_callback(format, va, XStringW_transmitSPrintf, this);
|
||||
}
|
||||
|
||||
// This is an attempt to use _PPrint from IO.c. Problem is : you have to allocate the memory BEFORE calling it.
|
||||
//void XStringW::vSPrintf(const char* format, va_list va)
|
||||
//{
|
||||
// POOL_PRINT spc;
|
||||
// PRINT_STATE ps;
|
||||
//
|
||||
@ -283,16 +294,16 @@ void XStringW::vSPrintf(const char* format, VA_LIST va)
|
||||
//
|
||||
// VA_COPY(ps.args, va);
|
||||
// _PPrint (&ps);
|
||||
// VA_END(ps.args);
|
||||
}
|
||||
// va_end(ps.args);
|
||||
//}
|
||||
|
||||
void XStringW::SPrintf(const char* format, ...)
|
||||
{
|
||||
VA_LIST va;
|
||||
va_list va;
|
||||
|
||||
VA_START (va, format);
|
||||
va_start (va, format);
|
||||
vSPrintf(format, va);
|
||||
VA_END(va);
|
||||
va_end(va);
|
||||
}
|
||||
|
||||
XStringW XStringW::basename() const
|
||||
@ -519,19 +530,19 @@ const XStringW &XStringW::operator +=(const wchar_t *S)
|
||||
|
||||
XStringW WPrintf(const char* format, ...)
|
||||
{
|
||||
VA_LIST va;
|
||||
va_list va;
|
||||
XStringW str;
|
||||
|
||||
VA_START (va, format);
|
||||
va_start (va, format);
|
||||
str.vSPrintf(format, va);
|
||||
VA_END(va);
|
||||
va_end(va);
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
XStringW SubString(const wchar_t *S, UINTN pos, UINTN count)
|
||||
{
|
||||
if ( StrLen(S)-pos < count ) count = StrLen(S)-pos;
|
||||
if ( wcslen(S)-pos < count ) count = wcslen(S)-pos;
|
||||
XStringW ret;
|
||||
ret.StrnCpy(S+pos, count);
|
||||
// return ( XStringW(S+pos, count) );
|
||||
|
@ -24,6 +24,9 @@ protected:
|
||||
UINTN m_len;
|
||||
UINTN m_allocatedSize;
|
||||
|
||||
// convenience method. Did it this way to avoid #define in header. They can have an impact on other heade.rs
|
||||
xsize min(xsize x1, xsize x2) const { if ( x1 < x2 ) return x1; return x2; }
|
||||
|
||||
public:
|
||||
void Init(UINTN aSize=0);
|
||||
XStringW();
|
||||
@ -48,6 +51,8 @@ public:
|
||||
|
||||
wchar_t *dataWithSizeMin(UINTN pos, UINTN sizeMin, UINTN nGrowBy=XStringWGrowByDefault) { CheckSize(sizeMin, nGrowBy); return data(pos); }
|
||||
|
||||
wchar_t * forgetDataWithoutFreeing();
|
||||
|
||||
UINTN length() const { return m_len; }
|
||||
UINTN size() const { return m_len; }
|
||||
UINTN allocatedSize() const { return m_allocatedSize; }
|
||||
@ -94,7 +99,7 @@ public:
|
||||
void Insert(UINTN pos, const XStringW& Str);
|
||||
|
||||
|
||||
void vSPrintf(const char* format, VA_LIST va);
|
||||
void vSPrintf(const char* format, va_list va);
|
||||
#ifndef _MSC_VER
|
||||
void SPrintf(const char* format, ...) __attribute__((__format__(__printf__, 2, 3)));
|
||||
#else
|
||||
@ -129,11 +134,11 @@ public:
|
||||
void Replace(wchar_t c1, wchar_t c2);
|
||||
XStringW SubStringReplace(wchar_t c1, wchar_t c2);
|
||||
|
||||
int Compare(const wchar_t* S) const { return (int)StrCmp(data(), S) ; }
|
||||
int Compare(const wchar_t* S) const { return (int)memcmp(data(), S, min(wcslen(S), length())*sizeof(wchar_t)); }
|
||||
|
||||
bool Equal(const wchar_t* S) const { return Compare(S) == 0; };
|
||||
bool BeginingEqual(const wchar_t* S) const { return (StrnCmp(data(), S, StrLen(S)) == 0); }
|
||||
bool SubStringEqual(UINTN Pos, const wchar_t* S) const { return (StrCmp(data(Pos), S) == 0); }
|
||||
bool BeginingEqual(const wchar_t* S) const { return (memcmp(data(), S, wcslen(S)) == 0); }
|
||||
bool SubStringEqual(UINTN Pos, const wchar_t* S) const { return (memcmp(data(Pos), S, wcslen(S)) == 0); }
|
||||
|
||||
XStringW basename() const;
|
||||
XStringW dirname() const;
|
||||
@ -158,6 +163,7 @@ public:
|
||||
// friend XStringW operator + (const XStringW& p1, wchar_t p2 ) { XStringW s; s=p1; s+=p2; return s; }
|
||||
// friend XStringW operator + (wchar_t p1, const XStringW& p2 ) { XStringW s; s=p1; s+=p2; return s; }
|
||||
|
||||
|
||||
// == operator
|
||||
friend bool operator == (const XStringW& s1, const XStringW& s2) { return s1.Compare(s2) == 0; }
|
||||
friend bool operator == (const XStringW& s1, const wchar_t* s2 ) { return s1.Compare(s2) == 0; }
|
||||
|
@ -23,7 +23,7 @@ XStringWArray::XStringWArray() : XStringWArraySuper()
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
void XStringWArray::AddStrings(const wchar_t *Val1, ...)
|
||||
{
|
||||
VA_LIST va;
|
||||
va_list va;
|
||||
const wchar_t *p;
|
||||
|
||||
{
|
||||
@ -31,7 +31,7 @@ void XStringWArray::AddStrings(const wchar_t *Val1, ...)
|
||||
newS->takeValueFrom(Val1);
|
||||
AddReference(newS, true);
|
||||
}
|
||||
VA_START(va, Val1);
|
||||
va_start(va, Val1);
|
||||
p = VA_ARG(va, const wchar_t *);
|
||||
while ( p != nullptr ) {
|
||||
XStringW* newS = new XStringW;
|
||||
@ -39,7 +39,7 @@ void XStringWArray::AddStrings(const wchar_t *Val1, ...)
|
||||
AddReference(newS, true);
|
||||
p = VA_ARG(va, const wchar_t *);
|
||||
}
|
||||
VA_END(va);
|
||||
va_end(va);
|
||||
}
|
||||
|
||||
XStringW XStringWArray::ConcatAll(XStringW Separator, XStringW Prefix, XStringW Suffix) const
|
||||
|
@ -21,7 +21,7 @@
|
||||
#include "XToolsCommon.h"
|
||||
#include "XStringWP.h"
|
||||
|
||||
#include "printf_lite.h"
|
||||
#include "../../Include/Library/printf_lite.h"
|
||||
|
||||
|
||||
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
@ -36,7 +36,7 @@ XStringWP::XStringWP(const wchar_t *S)
|
||||
panic();
|
||||
}
|
||||
DBG("Constructor(const wchar_t *S) : %s, StrLen(S)=%d\n", S, StrLen(S));
|
||||
Init(StrLen(S));
|
||||
Init(wcslen(S));
|
||||
StrCpy(S);
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
#ifndef __XTOOLSCOMMON_H__
|
||||
#define __XTOOLSCOMMON_H__
|
||||
|
||||
#include <posix.h>
|
||||
|
||||
|
||||
#define xsize UINTN
|
||||
#define MAX_XSIZE MAX_UINTN
|
||||
@ -17,7 +19,6 @@ extern xsize XBufferGrowByDefault;
|
||||
|
||||
#ifdef CLOVER_BUILD
|
||||
|
||||
#include <posix.h>
|
||||
|
||||
extern "C" {
|
||||
#include <ProcessorBind.h>
|
||||
@ -28,11 +29,14 @@ extern "C" {
|
||||
|
||||
#endif
|
||||
|
||||
#define Xalloc(AllocationSize) AllocatePool(AllocationSize)
|
||||
#define Xrealloc(OldSize, NewSize, OldBuffer) ReallocatePool(OldSize, NewSize, OldBuffer)
|
||||
#define Xfree(Buffer) FreePool(Buffer)
|
||||
#define Xmemmove(dest,source,count) CopyMem(dest, (void*)(source), count) // that has to handle overlapping memory (prefer memmove to memcpy).
|
||||
//#define Xalloc(AllocationSize) AllocatePool(AllocationSize)
|
||||
//#define Xrealloc(OldSize, NewSize, OldBuffer) ReallocatePool(OldSize, NewSize, OldBuffer)
|
||||
//#define Xfree(Buffer) FreePool(Buffer)
|
||||
//#define Xmemmove(dest,source,count) CopyMem(dest, (void*)(source), count) // that has to handle overlapping memory (prefer memmove to memcpy).
|
||||
|
||||
#if !defined(CLOVER_BUILD)
|
||||
#define realloc(ptr, newsize, oldsize) realloc(ptr, newsize)
|
||||
#endif
|
||||
|
||||
|
||||
// Declare here instead of include to avoid circular dependency.
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,189 +0,0 @@
|
||||
//
|
||||
// printf_lite.hpp
|
||||
//
|
||||
// Created by jief the 04 Apr 2019.
|
||||
// Imported in CLover the 24 Feb 2020
|
||||
//
|
||||
#ifndef __PRINTF_LITE_H__ // do not include protect, printf-lite.cpp include that twice
|
||||
#define __PRINTF_LITE_H__
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h> // for size_t
|
||||
#ifdef ARDUINO
|
||||
#include <WString.h>
|
||||
#ifdef HAS_LIQUID_CRYSTAL
|
||||
#include <LiquidCrystal.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define PRINTF_OUTPUT_FORMAT_UNICODE 1
|
||||
#if PRINTF_OUTPUT_FORMAT_UNICODE == 1
|
||||
# define PRINTF_UTF8_SUPPORT 1
|
||||
#endif
|
||||
|
||||
/*
|
||||
* A buffer is not needed. On some case it could be faster. For example when using semihosting
|
||||
* It's 255 max, because of bufIdx of type uint8_t. It's possible to change it to int if bigger buffer needed.
|
||||
* This buffer isn't statically allocated so it won't use permanent RAM.
|
||||
* Not more than int because of cast in transmitBufXXX functions.
|
||||
* 2017/08/31 : Save 22 bytes + bufsize of my STM32F103
|
||||
*/
|
||||
#ifndef PRINTF_LITE_BUF_SIZE
|
||||
#define PRINTF_LITE_BUF_SIZE 0
|
||||
#endif
|
||||
/*
|
||||
* Fallback on something close if specifier is'nt supported.
|
||||
* Unsupported specifier are ignored.
|
||||
* if 0, any unsupported modifier or specifier will be seen as unknown.
|
||||
*/
|
||||
#ifndef PRINTF_LITE_FALLBACK_FOR_UNSUPPORTED
|
||||
#define PRINTF_LITE_FALLBACK_FOR_UNSUPPORTED 1
|
||||
#endif
|
||||
#ifndef PRINTF_LITE_FLOAT_SUPPORT
|
||||
#define PRINTF_LITE_FLOAT_SUPPORT 1
|
||||
#endif
|
||||
/*
|
||||
* The int part of the float (or double) will be printed if PRINTF_LITE_FLOAT_SUPPORT is enabled
|
||||
* June 2017, avr-gcc 4.9.2-atmel3.5.4-arduino2 :
|
||||
* Float support increase 828 bytes of text and 16 bytes of data
|
||||
*/
|
||||
#ifndef PRINTF_LITE_FLOAT_AS_INT_SUPPORT
|
||||
#define PRINTF_LITE_FLOAT_AS_INT_SUPPORT 1 // if float not supported, an int will be print instead.
|
||||
#endif
|
||||
/*
|
||||
* Disabling LONG LONG support has an effect on printing double. If long int is disabled, the int part of the double has to be < ULONG_MAX
|
||||
*/
|
||||
#ifndef PRINTF_LITE_LONGLONGINT_SUPPORT
|
||||
#define PRINTF_LITE_LONGLONGINT_SUPPORT 1 // 1712 bytes
|
||||
#endif
|
||||
/*
|
||||
* Disabling LONG support automatically disable LONG LONG support whatever the value of PRINTF_LITE_LONGLONGINT_SUPPORT.
|
||||
* Disabling LONG support has an effect on printing double. The int part of the double has to be < UINT_MAX max
|
||||
*/
|
||||
#ifndef PRINTF_LITE_LONGINT_SUPPORT
|
||||
#define PRINTF_LITE_LONGINT_SUPPORT 1 // 1712 bytes
|
||||
#endif
|
||||
#ifndef PRINTF_LITE_TIMESTAMP_SUPPORT
|
||||
#define PRINTF_LITE_TIMESTAMP_SUPPORT 0 // 240 bytes
|
||||
#endif
|
||||
#ifndef PRINTF_LITE_FIELDWIDTH_SUPPORT
|
||||
#define PRINTF_LITE_FIELDWIDTH_SUPPORT 1 // 107 bytes
|
||||
#endif
|
||||
#ifndef PRINTF_LITE_FIELDPRECISION_SUPPORT
|
||||
#define PRINTF_LITE_FIELDPRECISION_SUPPORT 1 // bytes
|
||||
#endif
|
||||
#ifndef PRINTF_LITE_PADCHAR_SUPPORT
|
||||
#define PRINTF_LITE_PADCHAR_SUPPORT 1 // bytes
|
||||
#endif
|
||||
#ifndef PRINTF_LITE_ZSPECIFIER_SUPPORT
|
||||
#define PRINTF_LITE_ZSPECIFIER_SUPPORT 1 // 230 bytes. If not supported, z modifier become llu
|
||||
#endif
|
||||
#ifndef PRINTF_LITE_XSPECIFIER_SUPPORT
|
||||
#define PRINTF_LITE_XSPECIFIER_SUPPORT 1 // 96 bytes. If not supported, x specifier become u
|
||||
#endif
|
||||
#ifndef PRINTF_LITE_USPECIFIER_SUPPORT
|
||||
#define PRINTF_LITE_USPECIFIER_SUPPORT 1 // 96 bytes. If not supported, u specifier become d
|
||||
#endif
|
||||
|
||||
#ifndef PRINTF_LITE_UART_SUPPORT
|
||||
#define PRINTF_LITE_UART_SUPPORT 0 //
|
||||
#endif
|
||||
#ifndef PRINTF_LITE_USB_SUPPORT
|
||||
#define PRINTF_LITE_USB_SUPPORT 0 //
|
||||
#endif
|
||||
#ifndef PRINTF_LITE_SNPRINTF_SUPPORT
|
||||
#define PRINTF_LITE_SNPRINTF_SUPPORT 0 //
|
||||
#endif
|
||||
#ifndef PRINTF_LITE_FLASHSTRING_SUPPORT
|
||||
#define PRINTF_LITE_FLASHSTRING_SUPPORT 0 //
|
||||
#endif
|
||||
|
||||
|
||||
#if PRINTF_OUTPUT_FORMAT_UNICODE == 1
|
||||
# define printf_char_type wchar_t
|
||||
#else
|
||||
# define printf_char_type char
|
||||
#endif
|
||||
|
||||
typedef void (*transmitBufCallBackType)(const printf_char_type* buf, size_t nbyte);
|
||||
void vprintf_with_callback(const char* format, va_list valist, transmitBufCallBackType transmitBufCallBack
|
||||
#if PRINTF_LITE_TIMESTAMP_SUPPORT == 1
|
||||
, int* newline, int timestamp
|
||||
#endif
|
||||
);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
#if PRINTF_LITE_SNPRINTF_SUPPORT == 1
|
||||
int vsnprintf(printf_char_type*, size_t, const char *__restrict, va_list valist)
|
||||
#ifndef _MSC_VER
|
||||
__attribute__ ((__format__ (__printf__, 3, 0)))
|
||||
#endif
|
||||
; // have to return int to conform stdio.h. Always return 1;
|
||||
|
||||
// gcc-4.9.2-atmel3.5.4-arduino2 report snprintf to undefined. Change the name and it'll work. String isn't it ?
|
||||
int snprintf(printf_char_type*, size_t len, const char *__restrict format, ...)
|
||||
#ifndef _MSC_VER
|
||||
__attribute__((__format__ (__printf__, 3, 4)))
|
||||
#endif
|
||||
; // have to return int to conform stdio.h. Always return 1;
|
||||
#endif
|
||||
|
||||
#if PRINTF_LITE_UART_SUPPORT == 1
|
||||
void vprintf_uart(const char* str, va_list valist);
|
||||
void printf_uart(const char *str, ...) __attribute__((format(printf, 1, 2)));
|
||||
void vlogf_uart(const char* str, va_list valist);
|
||||
void logf_uart(const char *str, ...) __attribute__((format(printf, 1, 2))); // same as printf_uart but print a timestamp at beginning of line.
|
||||
#endif
|
||||
|
||||
#ifdef LiquidCrystal_h
|
||||
void printf_lcd(int row, int col, const char *str, ...) __attribute__((format(printf, 3, 4)));
|
||||
#endif
|
||||
#if PRINTF_LITE_USB_SUPPORT == 1 && defined(__USBD_CDC_IF_H)
|
||||
void transmitBufUsb(const char* buf, size_t nbyte);
|
||||
void printf_usb(const char *str, ...) __attribute__((format(printf, 1, 2)));
|
||||
void vlogf_usb(const char* str, va_list valist);
|
||||
void logf_usb(const char *str, ...) __attribute__((format(printf, 1, 2)));
|
||||
#endif
|
||||
|
||||
#if defined(OS_USE_TRACE_ITM) || defined(OS_USE_TRACE_SEMIHOSTING_DEBUG) || defined(OS_USE_TRACE_SEMIHOSTING_STDOUT)
|
||||
void vprintf_semih(const char* str, va_list valist);
|
||||
void printf_semih(const char* format, ...) __attribute__ ((__format__ (__printf__, 1, 2)));
|
||||
#endif
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
#if defined(ARDUINO) && PRINTF_LITE_FLASHSTRING_SUPPORT == 1
|
||||
int vsnprintf(char *__restrict, size_t, const __FlashStringHelper *__restrict, va_list valist); // have to return int to conform stdio.h. Always return 1;
|
||||
// gcc-4.9.2-atmel3.5.4-arduino2 report snprintf to undefined. Change the name and it'll work. String isn't it ?
|
||||
int snprintf(char *__restrict buf, size_t len, const __FlashStringHelper * format, ...); // have to return int to conform stdio.h. Always return 1;
|
||||
|
||||
// C code can't access this because __FlashStringHelper is a class
|
||||
void vlogf_uart(const __FlashStringHelper* str, va_list valist);
|
||||
|
||||
#ifdef __JIEF_FLASHSTRING_PRINTFWARNING_HACK__
|
||||
void printf_uart(const __FlashStringHelper *str, ...) __attribute__((format(printf, 1, 2)));
|
||||
void logf_uart(const __FlashStringHelper *str, ...) __attribute__((format(printf, 1, 2))); // same as printf_uart but print a timestamp at beginning of line.
|
||||
#ifdef LiquidCrystal_h
|
||||
void printf_lcd(int row, int col, const __FlashStringHelper *str, ...) __attribute__((format(printf, 3, 4)));
|
||||
#endif
|
||||
#else
|
||||
// if __JIEF_FLASHSTRING_PRINTFWARNING_HACK isn't defined, it means you don't use my hacked version of GCC. "Normal" version can't handle const __FlashStringHelper* as format for warning
|
||||
void printf_uart(const __FlashStringHelper *str, ...);
|
||||
void logf_uart(const __FlashStringHelper *str, ...); // same as printf_uart but print a timestamp at beginning of line.
|
||||
#ifdef LiquidCrystal_h
|
||||
void printf_lcd(int row, int col, const __FlashStringHelper *str, ...);
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#endif // __PRINTF_LITE_H__
|
@ -161,7 +161,7 @@ size_t utf8ToWChar(wchar_t* dst, size_t dst_max_len, const char *s)
|
||||
s += 1;
|
||||
}
|
||||
#if __WCHAR_MAX__ > 0xFFFFu
|
||||
dst[dst_len++] = c;
|
||||
dst[dst_len++] = (wchar_t)c;
|
||||
if ( dst_len == dst_max_len ) goto exit;
|
||||
#else
|
||||
if ( c <= 0xFFFF) {
|
||||
|
@ -7,6 +7,7 @@
|
||||
#ifndef utf816Conversion_hpp
|
||||
#define utf816Conversion_hpp
|
||||
|
||||
#include <posix.h>
|
||||
|
||||
UINTN StrLenInWChar(const char *src);
|
||||
UINTN utf8ToWChar(wchar_t* dst, UINTN dst_max_len, const char *s);
|
||||
|
@ -9,105 +9,105 @@
|
||||
|
||||
int XStringW_tests()
|
||||
{
|
||||
|
||||
#ifdef JIEF_DEBUG
|
||||
// DebugLog(2, "XStringW_tests -> Enter\n");
|
||||
#endif
|
||||
|
||||
if ( global_str3 != L"global_str3" ) return 1;
|
||||
if ( global_str4 != L"global_str4" ) return 2;
|
||||
|
||||
#ifdef XSTRINGW_HAS_CTOR_LITTERAL
|
||||
XStringW str(L"1");
|
||||
if ( str != L"1" ) return 3;
|
||||
str.StrCat(L"2");
|
||||
if ( str != L"12" ) return 4;
|
||||
#endif
|
||||
|
||||
XStringW str;
|
||||
str.takeValueFrom(L"12");
|
||||
XStringW str2;
|
||||
if ( !str2.isEmpty() ) return 10;
|
||||
str2.StrnCpy(str.data(), 2);
|
||||
if ( str2 != L"12" ) return 11;
|
||||
str2.StrnCat(L"345", 2);
|
||||
if ( str2 != L"1234" ) return 12;
|
||||
str2.Insert(1, str);
|
||||
if ( str2 != L"112234" ) return 13;
|
||||
str2 += L"6";
|
||||
if ( str2 != L"1122346" ) return 14;
|
||||
|
||||
//wchar_t c2 = L'Ň';
|
||||
//printf("1=%lc\n", c2);
|
||||
//const char* s1 = "𐌾";
|
||||
|
||||
str2.SPrintf("%c", 'a'); // signle UTF8 ascii char
|
||||
if ( str2 != L"a" ) return 20;
|
||||
str2.takeValueFrom(L"ab"); // UTF16(32) string containing ascii char
|
||||
if ( str2 != L"ab" ) return 21;
|
||||
#ifdef _MSC_VER
|
||||
// IMPORTANT : you can't pass a litteral char in a vararg function with Visual Studio (Microsoft strikes again :-).
|
||||
// At least, you got a warning C4066
|
||||
// IMPORTANT2 : Litteral string containing UTF16 char are WRONG. And you don't get a warning !!! If litteral is only ascii, it's ok.
|
||||
// Maybe it's compilation option butI didn't find them.
|
||||
wchar_t c = 'Ň'; // using an imtermediary var for Microsoft.
|
||||
|
||||
|
||||
wchar_t s[2]; // wchar_t s2[] = L"Ň";
|
||||
s[0] = 'Ň';
|
||||
s[1] = 0;
|
||||
|
||||
str2.SPrintf("%lc", c); // UTF16(32) char. (2 bytes in total if UTF16)
|
||||
if (str2 != s) return 22;
|
||||
str2.takeValueFrom("");
|
||||
if (str2.length() != 0) return 221;
|
||||
str2.takeValueFrom(s); // this is a UTF8 string 2 bytes long
|
||||
if (str2 != s) return 23;
|
||||
#else
|
||||
str2.SPrintf("%lc", L'Ň'); // signe UTF16(32) char. (2 bytes in total if UTF16)
|
||||
if ( str2 != L"Ň" ) return 22;
|
||||
str2.takeValueFrom("");
|
||||
if (str2.length() != 0) return 221;
|
||||
#ifdef XSTRINGW_HAS_CTOR_LITTERAL
|
||||
str2.takeValueFrom("Ň"); // this is a UTF8 string 2 bytes long
|
||||
if (str2 != "Ň") return 23; // utf8 litteral are converted to an XStringW if ctor is available.
|
||||
#endif
|
||||
str2.takeValueFrom("");
|
||||
if (str2.length() != 0) return 231;
|
||||
#ifdef XSTRINGW_HAS_CTOR_LITTERAL
|
||||
str2.takeValueFrom(L"Ň"); // this is a UTF8 string 2 bytes long
|
||||
if (str2 != "Ň") return 24;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if __WCHAR_MAX__ > 0xFFFFu
|
||||
str2.SPrintf("%lc", L'𐌾'); // L'𐌾' // this char cannot convert to an UTF16 char. So it doesn't compile with -fshort-wchar
|
||||
if ( str2 != L'𐌾' ) return 30;
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef _MSC_VER
|
||||
// "𐌾" in UTF16 is 2 char : 0xd800, 0xdf3e
|
||||
|
||||
str2.takeValueFrom(L"𐌾"); // this is a UTF8 string 4 bytes long
|
||||
if ( str2 != L"𐌾" ) return 31;
|
||||
str2.takeValueFrom(L"𐌾"); // this is a UTF16 or UTF32 string (depending of -fshort-wchar)
|
||||
if ( str2 != L"𐌾" ) return 32;
|
||||
|
||||
#ifdef XSTRINGW_HAS_CTOR_LITTERAL
|
||||
{
|
||||
XStringW str3("a");
|
||||
if ( str3 != L"a" ) return 40;
|
||||
XStringW str4("aŇ𐌾");
|
||||
if ( str4 != L"aŇ𐌾" ) return 41;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// XStringW CommonName(L"EFI\\CLOVER\\misc\\screenshot");
|
||||
// for (UINTN Index = 0; Index < 20; Index++) {
|
||||
// XStringW Name = CommonName + SPrintf("%lld", Index) + L".png";
|
||||
// DebugLog(2, "XStringW_test shot: %s\n", Name.data());
|
||||
// }
|
||||
//
|
||||
//#ifdef JIEF_DEBUG
|
||||
//// DebugLog(2, "XStringW_tests -> Enter\n");
|
||||
//#endif
|
||||
//
|
||||
// if ( global_str3 != L"global_str3" ) return 1;
|
||||
// if ( global_str4 != L"global_str4" ) return 2;
|
||||
//
|
||||
//#ifdef XSTRINGW_HAS_CTOR_LITTERAL
|
||||
// XStringW str(L"1");
|
||||
// if ( str != L"1" ) return 3;
|
||||
// str.StrCat(L"2");
|
||||
// if ( str != L"12" ) return 4;
|
||||
//#endif
|
||||
//
|
||||
// XStringW str;
|
||||
// str.takeValueFrom(L"12");
|
||||
// XStringW str2;
|
||||
// if ( !str2.isEmpty() ) return 10;
|
||||
// str2.StrnCpy(str.data(), 2);
|
||||
// if ( str2 != L"12" ) return 11;
|
||||
// str2.StrnCat(L"345", 2);
|
||||
// if ( str2 != L"1234" ) return 12;
|
||||
// str2.Insert(1, str);
|
||||
// if ( str2 != L"112234" ) return 13;
|
||||
// str2 += L"6";
|
||||
// if ( str2 != L"1122346" ) return 14;
|
||||
//
|
||||
////wchar_t c2 = L'Ň';
|
||||
////printf("1=%lc\n", c2);
|
||||
////const char* s1 = "𐌾";
|
||||
//
|
||||
// str2.SPrintf("%c", 'a'); // signle UTF8 ascii char
|
||||
// if ( str2 != L"a" ) return 20;
|
||||
// str2.takeValueFrom(L"ab"); // UTF16(32) string containing ascii char
|
||||
// if ( str2 != L"ab" ) return 21;
|
||||
//#ifdef _MSC_VER
|
||||
// // IMPORTANT : you can't pass a litteral char in a vararg function with Visual Studio (Microsoft strikes again :-).
|
||||
// // At least, you got a warning C4066
|
||||
// // IMPORTANT2 : Litteral string containing UTF16 char are WRONG. And you don't get a warning !!! If litteral is only ascii, it's ok.
|
||||
// // Maybe it's compilation option butI didn't find them.
|
||||
// wchar_t c = 'Ň'; // using an imtermediary var for Microsoft.
|
||||
//
|
||||
//
|
||||
// wchar_t s[2]; // wchar_t s2[] = L"Ň";
|
||||
// s[0] = 'Ň';
|
||||
// s[1] = 0;
|
||||
//
|
||||
// str2.SPrintf("%lc", c); // UTF16(32) char. (2 bytes in total if UTF16)
|
||||
// if (str2 != s) return 22;
|
||||
// str2.takeValueFrom("");
|
||||
// if (str2.length() != 0) return 221;
|
||||
// str2.takeValueFrom(s); // this is a UTF8 string 2 bytes long
|
||||
// if (str2 != s) return 23;
|
||||
//#else
|
||||
// str2.SPrintf("%lc", L'Ň'); // signe UTF16(32) char. (2 bytes in total if UTF16)
|
||||
// if ( str2 != L"Ň" ) return 22;
|
||||
// str2.takeValueFrom("");
|
||||
// if (str2.length() != 0) return 221;
|
||||
//#ifdef XSTRINGW_HAS_CTOR_LITTERAL
|
||||
// str2.takeValueFrom("Ň"); // this is a UTF8 string 2 bytes long
|
||||
// if (str2 != "Ň") return 23; // utf8 litteral are converted to an XStringW if ctor is available.
|
||||
//#endif
|
||||
// str2.takeValueFrom("");
|
||||
// if (str2.length() != 0) return 231;
|
||||
//#ifdef XSTRINGW_HAS_CTOR_LITTERAL
|
||||
// str2.takeValueFrom(L"Ň"); // this is a UTF8 string 2 bytes long
|
||||
// if (str2 != "Ň") return 24;
|
||||
//#endif
|
||||
//#endif
|
||||
//
|
||||
//#if __WCHAR_MAX__ > 0xFFFFu
|
||||
// str2.SPrintf("%lc", L'𐌾'); // L'𐌾' // this char cannot convert to an UTF16 char. So it doesn't compile with -fshort-wchar
|
||||
// if ( str2 != L'𐌾' ) return 30;
|
||||
//#endif
|
||||
//
|
||||
//
|
||||
//#ifndef _MSC_VER
|
||||
// // "𐌾" in UTF16 is 2 char : 0xd800, 0xdf3e
|
||||
//
|
||||
// str2.takeValueFrom(L"𐌾"); // this is a UTF8 string 4 bytes long
|
||||
// if ( str2 != L"𐌾" ) return 31;
|
||||
// str2.takeValueFrom(L"𐌾"); // this is a UTF16 or UTF32 string (depending of -fshort-wchar)
|
||||
// if ( str2 != L"𐌾" ) return 32;
|
||||
//
|
||||
//#ifdef XSTRINGW_HAS_CTOR_LITTERAL
|
||||
// {
|
||||
// XStringW str3("a");
|
||||
// if ( str3 != L"a" ) return 40;
|
||||
// XStringW str4("aŇ𐌾");
|
||||
// if ( str4 != L"aŇ𐌾" ) return 41;
|
||||
// }
|
||||
//#endif
|
||||
//#endif
|
||||
//
|
||||
//// XStringW CommonName(L"EFI\\CLOVER\\misc\\screenshot");
|
||||
//// for (UINTN Index = 0; Index < 20; Index++) {
|
||||
//// XStringW Name = CommonName + SPrintf("%lld", Index) + L".png";
|
||||
//// DebugLog(2, "XStringW_test shot: %s\n", Name.data());
|
||||
//// }
|
||||
return 0;
|
||||
}
|
||||
|
@ -17,97 +17,96 @@ int XString_tests()
|
||||
if ( global_str1 != "global_str1" ) return 1;
|
||||
if ( global_str2 != "global_str2" ) return 2;
|
||||
|
||||
// Check default ctor
|
||||
{
|
||||
XString str;
|
||||
if (str.length() != 0) return 3;
|
||||
if (str.c_str() == NULL) return 4;
|
||||
}
|
||||
|
||||
// Check ctor with value (or check takeValueFrom while we are waiting to put back ctor(const char*)
|
||||
#ifdef XSTRINGW_HAS_CTOR_LITTERAL
|
||||
XStringW str("1");
|
||||
if ( str != "1" ) return 3;
|
||||
str.StrCat("2");
|
||||
if ( str != "12" ) return 4;
|
||||
{
|
||||
{
|
||||
XString str("");
|
||||
if ( str != "" ) return 10;
|
||||
}
|
||||
XString str("1");
|
||||
if ( str != "1" ) return 11;
|
||||
}
|
||||
#else
|
||||
{
|
||||
XString str;
|
||||
str.takeValueFrom("");
|
||||
if (str.length() != 0) return 10;
|
||||
str.takeValueFrom("1");
|
||||
if ( str != "1" ) return 11;
|
||||
str.StrCat("2");
|
||||
if ( str != "12" ) return 12;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Check StrCat. TODO more test, and test StrnCat
|
||||
{
|
||||
XString str;
|
||||
str.takeValueFrom("1");
|
||||
str.StrCat("2");
|
||||
if ( str != "12" ) return 20;
|
||||
}
|
||||
|
||||
// check takeValueFrom from utf8 string
|
||||
XString str;
|
||||
str.takeValueFrom("Ň"); // this is a UTF8 string 2 bytes long
|
||||
if (str != "Ň") return 30; // utf8 litteral are converted to an XStringW if ctor is available.
|
||||
str.takeValueFrom("𐌾"); // this is a UTF8 string 4 bytes long
|
||||
if ( str != "𐌾" ) return 31;
|
||||
str.takeValueFrom("𐌾"); // this is a UTF16 or UTF32 string (depending of -fshort-wchar)
|
||||
if ( str != "𐌾" ) return 32;
|
||||
|
||||
// check takeValueFrom from UTF16 or 32 string
|
||||
str.takeValueFrom(L"Ň"); // this is a UTF8 string 2 bytes long
|
||||
if (str != "Ň") return 33; // utf8 litteral are converted to an XStringW if ctor is available.
|
||||
str.takeValueFrom(L"𐌾"); // this is a UTF8 string 4 bytes long
|
||||
if ( str != "𐌾" ) return 34;
|
||||
str.takeValueFrom(L"𐌾"); // this is a UTF16 or UTF32 string (depending of -fshort-wchar)
|
||||
if ( str != "𐌾" ) return 35;
|
||||
|
||||
// Quick check of StrnCpy,StrnCat,Insert,+=
|
||||
str.takeValueFrom("12");
|
||||
XString str2;
|
||||
if ( !str2.isEmpty() ) return 10;
|
||||
if ( !str2.isEmpty() ) return 100;
|
||||
str2.StrnCpy(str.data(), 2);
|
||||
if ( str2 != "12" ) return 11;
|
||||
if ( str2 != "12" ) return 101;
|
||||
str2.StrnCat("345", 2);
|
||||
if ( str2 != "1234" ) return 12;
|
||||
if ( str2 != "1234" ) return 102;
|
||||
str2.Insert(1, str);
|
||||
if ( str2 != "112234" ) return 13;
|
||||
if ( str2 != "112234" ) return 103;
|
||||
str2 += "6";
|
||||
if ( str2 != "1122346" ) return 14;
|
||||
|
||||
str2 = "123";
|
||||
str2.Insert(0, "x");
|
||||
if ( str2 != "x123" ) return 15;
|
||||
str2.Insert(4, "y");
|
||||
if ( str2 != "x123y" ) return 16;
|
||||
if ( str2 != "1122346" ) return 104;
|
||||
// Check Insert at beginning and end
|
||||
str2.takeValueFrom("123");
|
||||
str2.Insert(0, XString().takeValueFrom("x"));
|
||||
if ( str2 != "x123" ) return 105;
|
||||
str2.Insert(4, XString().takeValueFrom("y"));
|
||||
if ( str2 != "x123y" ) return 106;
|
||||
|
||||
//wchar_t c2 = L'Ň';
|
||||
//printf("1=%lc\n", c2);
|
||||
//const char* s1 = "𐌾";
|
||||
|
||||
str2.SPrintf("%c", 'a'); // signle UTF8 ascii char
|
||||
if ( str2 != "a" ) return 20;
|
||||
str2.takeValueFrom("ab"); // UTF16(32) string containing ascii char
|
||||
if ( str2 != "ab" ) return 21;
|
||||
#ifdef _MSC_VER
|
||||
// IMPORTANT : you can't pass a litteral char in a vararg function with Visual Studio (Microsoft strikes again :-).
|
||||
// At least, you got a warning C4066
|
||||
// IMPORTANT2 : Litteral string containing UTF16 char are WRONG. And you don't get a warning !!! If litteral is only ascii, it's ok.
|
||||
// Maybe it's compilation option butI didn't find them.
|
||||
wchar_t c = 'Ň'; // using an imtermediary var for Microsoft.
|
||||
|
||||
|
||||
wchar_t s[2]; // wchar_t s2[] = "Ň";
|
||||
s[0] = 'Ň';
|
||||
s[1] = 0;
|
||||
|
||||
str2.SPrintf("%lc", c); // UTF16(32) char. (2 bytes in total if UTF16)
|
||||
if (str2 != s) return 22;
|
||||
str2.takeValueFrom("");
|
||||
if (str2.length() != 0) return 221;
|
||||
str2.takeValueFrom(s); // this is a UTF8 string 2 bytes long
|
||||
if (str2 != s) return 23;
|
||||
#else
|
||||
str2.SPrintf("%lc", L'Ň'); // signe UTF16(32) char. (2 bytes in total if UTF16)
|
||||
if ( str2 != "Ň" ) return 22;
|
||||
str2.takeValueFrom("");
|
||||
if (str2.length() != 0) return 221;
|
||||
#ifdef XSTRING_HAS_CTOR_LITTERAL
|
||||
str2.takeValueFrom("Ň"); // this is a UTF8 string 2 bytes long
|
||||
if (str2 != "Ň") return 23; // utf8 litteral are converted to an XStringW if ctor is available.
|
||||
#endif
|
||||
str2.takeValueFrom("");
|
||||
if (str2.length() != 0) return 231;
|
||||
#ifdef XSTRING_HAS_CTOR_LITTERAL
|
||||
str2.takeValueFrom("Ň"); // this is a UTF8 string 2 bytes long
|
||||
if (str2 != "Ň") return 24;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Check SPrintf
|
||||
str2.SPrintf("%c", 'a'); // single UTF8 ascii char
|
||||
if ( str2 != "a" ) return 200;
|
||||
#ifndef _MSC_VER
|
||||
str2.SPrintf("%lc", L'Ň'); // single UTF16(32) char. (2 bytes in total if UTF16)
|
||||
if ( str2 != "Ň" ) return 202;
|
||||
#endif
|
||||
str2.SPrintf("%s", "Ň"); // this is a UTF8 string 2 bytes long
|
||||
if (str2 != "Ň") return 203; // utf8 litteral are converted to an XStringW if ctor is available.
|
||||
str2.SPrintf("%ls", L"Ň"); // this is a UTF8 string 2 bytes long
|
||||
if (str2 != "Ň") return 204; // utf8 litteral are converted to an XStringW if ctor is available.
|
||||
#if __WCHAR_MAX__ > 0xFFFFu
|
||||
str2.SPrintf("%lc", L'𐌾'); // L'𐌾' // this char cannot convert to an UTF16 char. So it doesn't compile with -fshort-wchar
|
||||
if ( str2 != L'𐌾' ) return 30;
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef _MSC_VER
|
||||
// "𐌾" in UTF16 is 2 char : 0xd800, 0xdf3e
|
||||
|
||||
str2.takeValueFrom("𐌾"); // this is a UTF8 string 4 bytes long
|
||||
if ( str2 != "𐌾" ) return 31;
|
||||
str2.takeValueFrom("𐌾"); // this is a UTF16 or UTF32 string (depending of -fshort-wchar)
|
||||
if ( str2 != "𐌾" ) return 32;
|
||||
|
||||
#ifdef XSTRINGW_HAS_CTOR_LITTERAL
|
||||
{
|
||||
XStringW str3("a");
|
||||
if ( str3 != "a" ) return 40;
|
||||
XStringW str4("aŇ𐌾");
|
||||
if ( str4 != "aŇ𐌾" ) return 41;
|
||||
}
|
||||
#endif
|
||||
if ( str2 != "𐌾" ) return 205;
|
||||
#endif
|
||||
|
||||
/* Stil doesn't work as VS doesn't encode correctly litteral */
|
||||
@ -118,9 +117,21 @@ int XString_tests()
|
||||
// const wchar_t* ls = L"Выход";
|
||||
// const char16_t* us = u"Выход";
|
||||
// const char32_t* Us = U"Выход";
|
||||
XString str3(L"Выход");
|
||||
if ( str3 != "Выход" ) return 50;
|
||||
XString str3;
|
||||
str3.takeValueFrom(L"Выход");
|
||||
if ( str3 != "Выход" ) return 500;
|
||||
#endif
|
||||
//MsgLog("Test MsgLog ascii=%s ucs-2=%s\n", "a string", L"ascii char in ucs-2 string\n");
|
||||
//MsgLog("Test MsgLog ascii=%s ucs-2=%s\n", "a string", "ascii char in ucs-2 string\n");
|
||||
//MsgLog("Test MsgLog ascii=%s ucs-2=%s\n", "a string", "ascii char in ucs-2 string\n");
|
||||
//
|
||||
//MsgLog("Test MsgLog ascii=%s ucs-2=%s\n", "a string", L"Выход из подменю, обновление главного меню\n");
|
||||
//MsgLog("Test MsgLog ascii=%s ucs-2=%s\n", "a string", "Выход из подменю, обновление главного меню\n");
|
||||
//MsgLog("Test MsgLog ascii=%s ucs-2=%s\n", "a string", "Выход из подменю, обновление главного меню\n");
|
||||
//
|
||||
//DBG("Test ascii=%s ucs-2=%s\n", "a string", L"Выход из подменю, обновление главного меню\n");
|
||||
//DBG("Test ascii=%s ucs-2=%s\n", "a string", "Выход из подменю, обновление главного меню\n");
|
||||
//DBG("Test ascii=%s ucs-2=%s\n", "a string", "Выход из подменю, обновление главного меню\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -12,14 +12,22 @@
|
||||
#include "strcmp_test.h"
|
||||
#include "strncmp_test.h"
|
||||
#include "strlen_test.h"
|
||||
|
||||
#include <Platform.h> // Only use angled for Platform, else, xcode project won't compile
|
||||
#include "printf_lite-test.h"
|
||||
|
||||
bool all_tests()
|
||||
{
|
||||
bool all_ok = true;
|
||||
int ret;
|
||||
|
||||
ret = printf_lite_tests();
|
||||
if ( ret != 0 ) {
|
||||
DebugLog(2, "printf_lite_tests() failed at test %d\n", ret);
|
||||
all_ok = false;
|
||||
}
|
||||
#ifdef JIEF_DEBUG
|
||||
//return ret;
|
||||
#endif
|
||||
ret = strlen_tests();
|
||||
if ( ret != 0 ) {
|
||||
DebugLog(2, "posix_tests() failed at test %d\n", ret);
|
||||
|
13
rEFIt_UEFI/cpp_unit_test/printf_lite-test-cpp_conf.h
Normal file
13
rEFIt_UEFI/cpp_unit_test/printf_lite-test-cpp_conf.h
Normal file
@ -0,0 +1,13 @@
|
||||
|
||||
#include "../../Include/Library/printf_lite.h"
|
||||
#define F(x) x
|
||||
#define LF(x) L##x
|
||||
#define PRIF "%s"
|
||||
#define PRILF "%ls"
|
||||
|
||||
#define loggf(...) DebugLog(2, __VA_ARGS__)
|
||||
//#define loggf(...) printf(__VA_ARGS__)
|
||||
|
||||
#define DISPLAY_ONLY_FAILED
|
||||
//#define DISPLAY_START_INFO
|
||||
|
436
rEFIt_UEFI/cpp_unit_test/printf_lite-test.cpp
Normal file
436
rEFIt_UEFI/cpp_unit_test/printf_lite-test.cpp
Normal file
@ -0,0 +1,436 @@
|
||||
//
|
||||
// main.cpp
|
||||
// Printf-UnitTests
|
||||
//
|
||||
// Created by Jief on 29/08/17.
|
||||
// Copyright © 2017 Jief. All rights reserved.
|
||||
//
|
||||
|
||||
#include <Platform.h>
|
||||
#include <limits.h>
|
||||
#include "unicode_conversions.h"
|
||||
#include "printf_lite-test-cpp_conf.h"
|
||||
|
||||
int nbTestFailed = 0;
|
||||
#ifdef DISPLAY_ONLY_FAILED
|
||||
bool displayOnlyFailed = true;
|
||||
#else
|
||||
bool displayOnlyFailed = false;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Print wchar string as a utf8 string.
|
||||
* This eliminate all problems about wprintf and compilation with short-wchar or long-wchar I had on macOs (2020-03)
|
||||
*/
|
||||
static void print_wchar_string(const wchar_t* s)
|
||||
{
|
||||
// char utf8[wchar_len(s)*4+1];
|
||||
// some compiler doesn't like variable length array.
|
||||
// use a fixed length instead.
|
||||
char utf8[100];
|
||||
utf8_string_from_wchar_string(utf8, sizeof(utf8), s);
|
||||
if ( strlen(utf8) > sizeof(utf8)-2 ) {
|
||||
loggf("fixed size buf not big enough");
|
||||
abort();
|
||||
}
|
||||
loggf("%s", utf8);
|
||||
}
|
||||
|
||||
int testPrintf(const char* label, const char* expectResult, int expectedRet, const char* format, ...) __attribute__((format(printf, 4, 5)));
|
||||
|
||||
int testPrintf(const char* label, const char* expectResult, int expectedRet, const char* format, ...)
|
||||
{
|
||||
char buf[40];
|
||||
va_list valist;
|
||||
va_start(valist, format);
|
||||
// const char* c = #PRINTF_CFUNCTION_PREFIX;
|
||||
int vsnprintf_ret = PRINTF_FUNCTION_NAME(PRINTF_CFUNCTION_PREFIX, vsnprint, PRINTF_CFUNCTION_SUFFIX)(buf, sizeof(buf), format, valist);
|
||||
va_end(valist);
|
||||
if ( strcmp(buf, (char*)expectResult) != 0 ) {
|
||||
loggf(F("%s -> ERROR. Expect " PRIF " and get %s\n"), label, expectResult, buf);
|
||||
nbTestFailed += 1;
|
||||
}else if ( vsnprintf_ret != expectedRet ) {
|
||||
loggf(F("%s -> ERROR. Expect return value %d and get %d\n"), label, expectedRet, vsnprintf_ret);
|
||||
nbTestFailed += 1;
|
||||
}else if ( !displayOnlyFailed ) {
|
||||
loggf(F("%s : %s -> OK\n"), label, buf);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int testWPrintf(const char* label, const wchar_t* expectResult, int expectedRet, const char* format, ...) __attribute__((format(printf, 4, 5)));
|
||||
|
||||
int testWPrintf(const char* label, const wchar_t* expectResult, int expectedRet, const char* format, ...)
|
||||
{
|
||||
wchar_t wbuf[40];
|
||||
#if VSNWPRINTF_RETURN_MINUS1_ON_OVERFLOW == 1
|
||||
if ( expectedRet >= (int)(sizeof(wbuf)/sizeof(wchar_t)) ) expectedRet = -1;
|
||||
#endif
|
||||
va_list valist;
|
||||
va_start(valist, format);
|
||||
int vsnwprintf_ret = PRINTF_FUNCTION_NAME(PRINTF_CFUNCTION_PREFIX, vsnwprint, PRINTF_CFUNCTION_SUFFIX)(wbuf, sizeof(wbuf)/sizeof(wchar_t), format, valist);
|
||||
va_end(valist);
|
||||
//delay_ms(10);
|
||||
if ( memcmp(wbuf, expectResult, wchar_len(expectResult)*sizeof(expectResult[0])) != 0 ) {
|
||||
// loggf(F(" -> ERROR. Expect " PRILF " and get %ls\n"), expectResult, buf);
|
||||
// not using wprintf, it crashes sometimes, it doesn't work for short-wchar
|
||||
loggf(F("%s -> ERROR. Expect "), label);
|
||||
print_wchar_string(expectResult);
|
||||
loggf(F(" and get "));
|
||||
print_wchar_string(wbuf);
|
||||
loggf("\n");
|
||||
nbTestFailed += 1;
|
||||
va_start(valist, format);
|
||||
PRINTF_FUNCTION_NAME(PRINTF_CFUNCTION_PREFIX, vsnwprint, PRINTF_CFUNCTION_SUFFIX)(wbuf, sizeof(wbuf)/sizeof(wchar_t), format, valist); // for stepping with a debugger.
|
||||
va_end(valist);
|
||||
}else if ( vsnwprintf_ret != expectedRet ) {
|
||||
loggf(F("%s -> ERROR. Expect return value %d and get %d\n"), label, expectedRet, vsnwprintf_ret);
|
||||
nbTestFailed += 1;
|
||||
va_start(valist, format);
|
||||
PRINTF_FUNCTION_NAME(PRINTF_CFUNCTION_PREFIX, vsnwprint, PRINTF_CFUNCTION_SUFFIX)(wbuf, sizeof(wbuf)/sizeof(wchar_t), format, valist); // for stepping with a debugger.
|
||||
va_end(valist);
|
||||
}else if ( !displayOnlyFailed ) {
|
||||
loggf(F("%s : "), label);
|
||||
print_wchar_string(wbuf);
|
||||
loggf(F(" -> OK\n"));
|
||||
}
|
||||
//delay_ms(10);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#define Test1arg(expectResult,format,c) \
|
||||
{ \
|
||||
char label[1024]; \
|
||||
snprintf(label, sizeof(label), F("Test sprintf(" PRIF ", " PRIF ")"), F(#format), F(#c)); \
|
||||
testPrintf(label,expectResult,(int)strlen(expectResult),format,c); \
|
||||
snprintf(label, sizeof(label), F("Test swprintf(" PRIF ", " PRIF ")"), F(#format), F(#c)); \
|
||||
testWPrintf(label,L##expectResult,(int)wcslen(L##expectResult),format,c); \
|
||||
}
|
||||
|
||||
#define Test2arg(expectResult,format,c,d) \
|
||||
{ \
|
||||
char label[1024]; \
|
||||
snprintf(label, sizeof(label), F("Test sprintf(" PRIF ", " PRIF ", " PRIF ")"), F(#format), F(#c), F(#d)); \
|
||||
testPrintf(label,expectResult,(int)strlen(expectResult),format,c,d); \
|
||||
snprintf(label, sizeof(label), F("Test swprintf(" PRIF ", " PRIF ", " PRIF ")"), F(#format), F(#c), F(#d)); \
|
||||
testWPrintf(label,L##expectResult,(int)wcslen(L##expectResult),format,c,d); \
|
||||
}
|
||||
|
||||
#define Test5arg(expectResult,format,c,d,e,f,g) \
|
||||
{ \
|
||||
char label[1024]; \
|
||||
snprintf(label, sizeof(label), F("Test sprintf(" PRIF ", " PRIF ", " PRIF ", " PRIF ", " PRIF ", " PRIF ")"), F(#format), F(#c), F(#d), F(#e), F(#f), F(#g)); \
|
||||
testPrintf(label,expectResult,(int)strlen(expectResult),format,c,d,e,f,g); \
|
||||
snprintf(label, sizeof(label), F("Test swprintf(" PRIF ", " PRIF ", " PRIF ", " PRIF ", " PRIF ", " PRIF ")"), F(#format), F(#c), F(#d), F(#e), F(#f), F(#g)); \
|
||||
testWPrintf(label,L##expectResult,(int)wcslen(L##expectResult),format,c,d,e,f,g); \
|
||||
}
|
||||
|
||||
#define TestLen5arg(expectResult,expectedRet,format,c,d,e,f,g) \
|
||||
{ \
|
||||
char label[1024]; \
|
||||
snprintf(label, sizeof(label), F("Test sprintf(" PRIF ", " PRIF ", " PRIF ", " PRIF ", " PRIF ", " PRIF ")"), F(#format), F(#c), F(#d), F(#e), F(#f), F(#g)); \
|
||||
testPrintf(label,expectResult,expectedRet,format,c,d,e,f,g); \
|
||||
snprintf(label, sizeof(label), F("Test swprintf(" PRIF ", " PRIF ", " PRIF ", " PRIF ", " PRIF ", " PRIF ")"), F(#format), F(#c), F(#d), F(#e), F(#f), F(#g)); \
|
||||
testWPrintf(label,L##expectResult,expectedRet,format,c,d,e,f,g); \
|
||||
}
|
||||
|
||||
|
||||
int printf_lite_tests(void)
|
||||
{
|
||||
#ifdef DISPLAY_START_INFO
|
||||
loggf(F("\n"));
|
||||
loggf(F("Printf unit test\n"));
|
||||
loggf(F("\n"));
|
||||
loggf(F("\n"));
|
||||
|
||||
// These depends on the plateform. They are not printf unit test, but it's nice to check size of builtin type.
|
||||
loggf(F("sizeof(float)=%lu\n"), sizeof(float));
|
||||
loggf(F("sizeof(double)=%zu\n"), sizeof(double));
|
||||
loggf(F("sizeof(short int)=%zu\n"), sizeof(short int));
|
||||
loggf(F("sizeof(int)=%zu\n"), sizeof(int));
|
||||
loggf(F("sizeof(long int)=%zu\n"), sizeof(long int));// long is 64 bits
|
||||
loggf(F("sizeof(long long int)=%zu\n"), sizeof(long long int));
|
||||
loggf(F("sizeof(size_t)=%zu=%zu\n"), sizeof(size_t), sizeof(size_t));
|
||||
loggf(F("sizeof(size_t)=%zu=%zu\n"), sizeof(size_t), sizeof(size_t));
|
||||
loggf(F("sizeof(void*)=%zu\n"), sizeof(void*));
|
||||
loggf(F("UINT64_MAX=%llu\n"), UINT64_MAX);
|
||||
loggf(F("SIZE_T_MAX=%zu\n"), SIZE_T_MAX);
|
||||
loggf(F("\n"));
|
||||
|
||||
loggf(F("PRId16=%s\n"), PRId16);
|
||||
loggf(F("PRIu16=%s\n"), PRIu16);
|
||||
loggf(F("PRId32=%s\n"), PRId32);
|
||||
loggf(F("PRIu32=%s\n"), PRIu32);
|
||||
loggf(F("PRId32=%s\n"), PRId32);
|
||||
loggf(F("PRIu32=%s\n"), PRIu32);
|
||||
loggf(F("PRId64=%s\n"), PRId64);
|
||||
loggf(F("PRIu64=%s\n"), PRIu64);
|
||||
loggf(F("\n"));
|
||||
#endif
|
||||
|
||||
|
||||
// char buf[256];
|
||||
// snprintf(buf, sizeof(buf), "test %s", "ascii");
|
||||
|
||||
// wprintf(L"%llS", (int)4); doesn't check format
|
||||
// printf("%ls", (char32_t)4);
|
||||
|
||||
// in testPrintf functions, buffer is only 40 bytes, to be able to test vsnwprintf truncate correctly.
|
||||
//
|
||||
// const char* utf8 = "Āࠀ𐀀Выходиз";
|
||||
// const wchar_t* unicode = L"Āࠀ𐀀Выходиз";
|
||||
|
||||
//printf("%ls %r\n", "foo", 1);
|
||||
|
||||
//testWPrintf("", F(L"Āࠀ𐀀🧊Выход'utf16'из"), F("Āࠀ𐀀🧊Выход'%s'из"), "utf16");
|
||||
|
||||
Test1arg(F("'utf16-string'"), F("'%s'"), "utf16-string");
|
||||
Test1arg(F("'utf16-string'"), F("'%ls'"), L"utf16-string");
|
||||
Test1arg(F("Āࠀ𐀀🧊Выход'utf16'из"), F("Āࠀ𐀀🧊Выход'%s'из"), "utf16");
|
||||
Test1arg(F("Āࠀ𐀀🧊Выход'utf16'из"), F("Āࠀ𐀀🧊Выход'%ls'из"), L"utf16");
|
||||
Test1arg(F("Āࠀ𐀀🧊Выхо'ыход'из"), F("Āࠀ𐀀🧊Выхо'%s'из"), "ыход");
|
||||
Test1arg(F("Āࠀ𐀀🧊Выхо'ыход'из"), F("Āࠀ𐀀🧊Выхо'%ls'из"), L"ыход");
|
||||
|
||||
|
||||
// These must always works. It also test that integer type are well defined
|
||||
Test1arg(F("sizeof(uint8_t)=1"), F("sizeof(uint8_t)=%zu"), sizeof(uint8_t));
|
||||
Test1arg(F("sizeof(uint16_t)=2"), F("sizeof(uint16_t)=%zu"), sizeof(uint16_t));
|
||||
Test1arg(F("sizeof(uint32_t)=4"), F("sizeof(uint32_t)=%zu"), sizeof(uint32_t));
|
||||
Test1arg(F("sizeof(uint64_t)=8"), F("sizeof(uint64_t)=%zu"), sizeof(uint64_t));
|
||||
Test1arg(F("sizeof(int8_t)=1"), F("sizeof(int8_t)=%zu"), sizeof(int8_t));
|
||||
Test1arg(F("sizeof(int16_t)=2"), F("sizeof(int16_t)=%zu"), sizeof(int16_t));
|
||||
Test1arg(F("sizeof(int32_t)=4"), F("sizeof(int32_t)=%zu"), sizeof(int32_t));
|
||||
Test1arg(F("sizeof(int64_t)=8"), F("sizeof(int64_t)=%zu"), sizeof(int64_t));
|
||||
loggf(F("\n"));
|
||||
|
||||
|
||||
|
||||
Test5arg(F("12 34 56.67 hi X"), F("%d %u %.2lf %s %c"), 12, 34, 56.67, "hi", 'X');
|
||||
|
||||
// test format
|
||||
Test1arg(F("12"), F("%d"), 12);
|
||||
Test1arg(F("12"), F("%u"), 12);
|
||||
Test1arg(F("|abfe|"), F("|%x|"), 0xABFE);
|
||||
Test1arg(F("|ABFE|"), F("|%X|"), 0xABFE);
|
||||
Test1arg(F("12.987654"), F("%f"), 12.987654f);
|
||||
Test1arg(F("12.987654"), F("%lf"), 12.987654);
|
||||
|
||||
// Test rounding
|
||||
Test1arg(F("10"), F("%1.0lf"), 10.4999);
|
||||
Test1arg(F("11"), F("%1.0lf"), 10.5001);
|
||||
Test1arg(F("10.5"), F("%1.1lf"), 10.5499);
|
||||
Test1arg(F("10.6"), F("%1.1lf"), 10.5501);
|
||||
Test1arg(F("10.005"), F("%1.3lf"), 10.0054);
|
||||
Test1arg(F("10.006"), F("%1.3lf"), 10.0056);
|
||||
|
||||
|
||||
// Test big numbers
|
||||
#ifdef ARDUINO
|
||||
// #define LARGE_DOUBLE_TRESHOLD (9.1e18) in printf_lite
|
||||
Test1arg(F("1234567.000000"), F("%lf"), 1234567.0);
|
||||
Test1arg(F("-1234567.000000"), F("%lf"), -1234567.0);
|
||||
#else
|
||||
// #define LARGE_DOUBLE_TRESHOLD (9.1e18) in printf_lite
|
||||
Test1arg(F("123456789012345680.000000"), F("%lf"), 123456789012345678.0);
|
||||
Test1arg(F("-123456789012345680.000000"), F("%lf"), -123456789012345678.0);
|
||||
#endif
|
||||
|
||||
|
||||
// test with specifier, space as pad char
|
||||
Test1arg(F("| 0|"), F("|%5d|"), 0);
|
||||
Test1arg(F("| 0|"), F("|%5u|"), 0);
|
||||
Test1arg(F("| 0|"), F("|%5x|"), 0);
|
||||
Test1arg(F("| 0|"), F("|%5X|"), 0);
|
||||
Test1arg(F("| 0.000000|"), F("|%9lf|"), 0.0);
|
||||
|
||||
// test with specifier too small, space as pad char
|
||||
Test1arg(F("|1234|"), F("|%2d|"), 1234); // keep under 16 bit value, if not, on 16 bits CPU, the constant become long int and doesn't match %d
|
||||
Test1arg(F("|5678|"), F("|%2u|"), 5678); // keep under 16 bit value, if not, on 16 bits CPU, the constant become long int and doesn't match %u
|
||||
Test1arg(F("|abfe|"), F("|%2x|"), 0xABFE); // keep under 16 bit value, if not, on 16 bits CPU, the constant become long int and doesn't match %x
|
||||
|
||||
// test test with specifier, space as pad char
|
||||
Test1arg(F("| 12|"), F("|%5d|"), 12);
|
||||
Test1arg(F("| 12|"), F("|%5u|"), 12);
|
||||
Test1arg(F("| c|"), F("|%5x|"), 12);
|
||||
|
||||
// test with specifier, 0 as pad char
|
||||
Test1arg(F("|00012|"), F("|%05d|"), 12);
|
||||
Test1arg(F("|00012|"), F("|%05u|"), 12);
|
||||
Test1arg(F("|0000c|"), F("|%05x|"), 12);
|
||||
|
||||
// Test1arg float format
|
||||
Test1arg(F("|0.000000|"), F("|%0f|"), 0.0f);
|
||||
Test1arg(F("|0.000000|"), F("|%1f|"), 0.0f);
|
||||
Test1arg(F("|0.000000|"), F("|%8f|"), 0.0f);
|
||||
Test1arg(F("| 0.000000|"), F("|%9f|"), 0.0f);
|
||||
Test1arg(F("|1.789010|"), F("|%2f|"), 1.78901f);
|
||||
Test1arg(F("|1.7890|"), F("|%.4f|"), 1.78901f);
|
||||
Test1arg(F("|1.7890|"), F("|%1.4f|"), 1.78901f);
|
||||
Test1arg(F("| -1.7890|"), F("|%15.4f|"), -1.78901f);
|
||||
Test1arg(F("|-000000001.7890|"), F("|%015.4f|"), -1.78901f);
|
||||
Test1arg(F("| -2|"), F("|%7.0f|"), -1.78901f);
|
||||
Test1arg(F("|-000002|"), F("|%07.0f|"), -1.78901f);
|
||||
|
||||
|
||||
//testWPrintf(F(L"big printf (biiiiiiiiiiiiiiiiiiiiiiiiii"), F("big printf (biiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiigger than buffer!) %s %d %f %s %x"), "string1", 2, 2.3f, "string2", 0xBEEF);
|
||||
|
||||
|
||||
// Test that sprintf will properly truncate to sizeof(buf)-1
|
||||
TestLen5arg(F("big printf (biiiiiiiiiiiiiiiiiiiiiiiiii"), 100, F("big printf (biiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiigger than buffer!) %s %d %f %s %x"), "string1", 2, 2.3f, "string2", 0xBEEF);
|
||||
|
||||
// Test %F format
|
||||
Test2arg(F("Flash string |string1| |striiiing2|"), F("Flash string |" PRIF "| |" PRIF "|"), F("string1"), F("striiiing2"));
|
||||
|
||||
// test limits
|
||||
int16_t i;
|
||||
i = INT16_MAX; Test1arg(F("INT16_MAX=32767"), F("INT16_MAX=%d"), i);
|
||||
i = INT16_MIN; Test1arg(F("INT16_MIN=-32768"), F("INT16_MIN=%d"), i);
|
||||
|
||||
uint16_t ui16;
|
||||
ui16 = UINT16_MAX; Test1arg(F("UINT16_MAX=65535"), F("UINT16_MAX=%u"), ui16);
|
||||
|
||||
int32_t i32;
|
||||
i32 = INT32_MAX; Test1arg(F("INT32_MAX=2147483647"), F("INT32_MAX=%" PRId32), i32);
|
||||
i32 = INT32_MIN; Test1arg(F("INT32_MIN=-2147483648"), F("INT32_MIN=%" PRId32), i32);
|
||||
|
||||
uint32_t ui32;
|
||||
ui32 = UINT32_MAX; Test1arg(F("UINT32_MAX=4294967295"), F("UINT32_MAX=%" PRIu32), ui32);
|
||||
|
||||
int64_t i64;
|
||||
i64 = INT64_MAX; Test1arg(F("INT64_MAX=9223372036854775807"), F("INT64_MAX=%" PRId64), i64);
|
||||
i64 = INT64_MIN; Test1arg(F("INT64_MIN=-9223372036854775808"), F("INT64_MIN=%" PRId64), i64);
|
||||
|
||||
uint64_t ui64;
|
||||
ui64 = UINT64_MAX; Test1arg(F("UINT64_MAX=18446744073709551615"), F("UINT64_MAX=%" PRIu64), ui64);
|
||||
|
||||
#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);
|
||||
}else{
|
||||
// 16 bits size_t ? Does that exist ?
|
||||
}
|
||||
|
||||
#if PRINTF_LITE_PADCHAR_SUPPORT == 1 && PRINTF_LITE_FIELDWIDTH_SUPPORT == 1 && PRINTF_LITE_FIELDPRECISION_SUPPORT == 1
|
||||
// Nothing specified
|
||||
Test1arg(F("-1.789010"), F("%f"), -1.78901f);
|
||||
// Pad char
|
||||
Test1arg(F("-1.789010"), F("%0f"), -1.78901f); // libc printf ignore pad char if there is no width (it's not an error)
|
||||
// Width
|
||||
Test1arg(F(" -1.789010"), F("%15f"), -1.78901f);
|
||||
// Precision
|
||||
Test1arg(F("-1.79"), F("%.2f"), -1.78901f);
|
||||
// Pad char + width
|
||||
Test1arg(F("-0000001.789010"), F("%015f"), -1.78901f);
|
||||
// Pad char + precision
|
||||
Test1arg(F("-1.79"), F("%0.2f"), -1.78901f);
|
||||
// Pad char + width + precision
|
||||
Test1arg(F("-00000000001.79"), F("%015.2f"), -1.78901f);
|
||||
#endif
|
||||
#if PRINTF_LITE_PADCHAR_SUPPORT == 1 && PRINTF_LITE_FIELDWIDTH_SUPPORT == 1 && PRINTF_LITE_FIELDPRECISION_SUPPORT == 0
|
||||
// Nothing specified
|
||||
Test1arg(F("-1.789010"), F("%f"), -1.78901f);
|
||||
// Pad char
|
||||
Test1arg(F("-1.789010"), F("%0f"), -1.78901f); // libc printf ignore pad char if there is no width (it's not an error)
|
||||
// Width
|
||||
Test1arg(F(" -1.789010"), F("%15f"), -1.78901f);
|
||||
// Precision
|
||||
Test1arg(F("-1.789010"), F("%.2f"), -1.78901f);
|
||||
// Pad char + width
|
||||
Test1arg(F("-0000001.789010"), F("%015f"), -1.78901f);
|
||||
// Pad char + precision
|
||||
Test1arg(F("-1.789010"), F("%0.2f"), -1.78901f);
|
||||
// Pad char + width + precision
|
||||
Test1arg(F("-0000001.789010"), F("%015.2f"), -1.78901f);
|
||||
#endif
|
||||
#if PRINTF_LITE_PADCHAR_SUPPORT == 1 && PRINTF_LITE_FIELDWIDTH_SUPPORT == 0 && PRINTF_LITE_FIELDPRECISION_SUPPORT == 1
|
||||
// Nothing specified
|
||||
Test1arg(F("-1.789010"), F("%f"), -1.78901f);
|
||||
// Pad char
|
||||
Test1arg(F("-1.789010"), F("%0f"), -1.78901f); // libc printf ignore pad char if there is no width (it's not an error)
|
||||
// Width
|
||||
Test1arg(F("-1.789010"), F("%15f"), -1.78901f);
|
||||
// Precision
|
||||
Test1arg(F("-1.79"), F("%.2f"), -1.78901f);
|
||||
// Pad char + width
|
||||
Test1arg(F("-1.789010"), F("%015f"), -1.78901f);
|
||||
// Pad char + precision
|
||||
Test1arg(F("-1.79"), F("%0.2f"), -1.78901f);
|
||||
// Pad char + width + precision
|
||||
Test1arg(F("-1.79"), F("%015.2f"), -1.78901f);
|
||||
#endif
|
||||
#if PRINTF_LITE_PADCHAR_SUPPORT == 0 && PRINTF_LITE_FIELDWIDTH_SUPPORT == 1 && PRINTF_LITE_FIELDPRECISION_SUPPORT == 1
|
||||
// Nothing specified
|
||||
Test1arg(F("-1.789010"), F("%f"), -1.78901f);
|
||||
// Pad char
|
||||
Test1arg(F("-1.789010"), F("%0f"), -1.78901f); // libc printf ignore pad char if there is no width (it's not an error)
|
||||
// Width
|
||||
Test1arg(F(" -1.789010"), F("%15f"), -1.78901f);
|
||||
// Precision
|
||||
Test1arg(F("-1.79"), F("%.2f"), -1.78901f);
|
||||
// Pad char + width
|
||||
Test1arg(F(" -1.789010"), F("%015f"), -1.78901f);
|
||||
// Pad char + precision
|
||||
Test1arg(F("-1.79"), F("%0.2f"), -1.78901f);
|
||||
// Pad char + width + precision
|
||||
Test1arg(F(" -1.79"), F("%015.2f"), -1.78901f);
|
||||
#endif
|
||||
#if PRINTF_LITE_PADCHAR_SUPPORT == 0 && PRINTF_LITE_FIELDWIDTH_SUPPORT == 1 && PRINTF_LITE_FIELDPRECISION_SUPPORT == 0
|
||||
// Nothing specified
|
||||
Test1arg(F("-1.789010"), F("%f"), -1.78901f);
|
||||
// Pad char
|
||||
Test1arg(F("-1.789010"), F("%0f"), -1.78901f); // libc printf ignore pad char if there is no width (it's not an error)
|
||||
// Width
|
||||
Test1arg(F(" -1.789010"), F("%15f"), -1.78901f);
|
||||
// Precision
|
||||
Test1arg(F("-1.789010"), F("%.2f"), -1.78901f);
|
||||
// Pad char + width
|
||||
Test1arg(F(" -1.789010"), F("%015f"), -1.78901f);
|
||||
// Pad char + precision
|
||||
Test1arg(F("-1.789010"), F("%0.2f"), -1.78901f);
|
||||
// Pad char + width + precision
|
||||
Test1arg(F(" -1.789010"), F("%015.2f"), -1.78901f);
|
||||
#endif
|
||||
#if PRINTF_LITE_PADCHAR_SUPPORT == 0 && PRINTF_LITE_FIELDWIDTH_SUPPORT == 0 && PRINTF_LITE_FIELDPRECISION_SUPPORT == 1
|
||||
// Nothing specified
|
||||
Test1arg(F("-1.789010"), F("%f"), -1.78901f);
|
||||
// Pad char
|
||||
Test1arg(F("-1.789010"), F("%0f"), -1.78901f); // libc printf ignore pad char if there is no width (it's not an error)
|
||||
// Width
|
||||
Test1arg(F("-1.789010"), F("%15f"), -1.78901f);
|
||||
// Precision
|
||||
Test1arg(F("-1.79"), F("%.2f"), -1.78901f);
|
||||
// Pad char + width
|
||||
Test1arg(F("-1.789010"), F("%015f"), -1.78901f);
|
||||
// Pad char + precision
|
||||
Test1arg(F("-1.79"), F("%0.2f"), -1.78901f);
|
||||
// Pad char + width + precision
|
||||
Test1arg(F("-1.79"), F("%015.2f"), -1.78901f);
|
||||
#endif
|
||||
#if PRINTF_LITE_PADCHAR_SUPPORT == 0 && PRINTF_LITE_FIELDWIDTH_SUPPORT == 0 && PRINTF_LITE_FIELDPRECISION_SUPPORT == 0
|
||||
// Nothing specified
|
||||
Test1arg(F("-1.789010"), F("%f"), -1.78901f);
|
||||
// Pad char
|
||||
Test1arg(F("-1.789010"), F("%0f"), -1.78901f); // libc printf ignore pad char if there is no width (it's not an error)
|
||||
// Width
|
||||
Test1arg(F("-1.789010"), F("%15f"), -1.78901f);
|
||||
// Precision
|
||||
Test1arg(F("-1.789010"), F("%.2f"), -1.78901f);
|
||||
// Pad char + width
|
||||
Test1arg(F("-1.789010"), F("%015f"), -1.78901f);
|
||||
// Pad char + precision
|
||||
Test1arg(F("-1.789010"), F("%0.2f"), -1.78901f);
|
||||
// Pad char + width + precision
|
||||
Test1arg(F("-1.789010"), F("%015.2f"), -1.78901f);
|
||||
#endif
|
||||
|
||||
return nbTestFailed;
|
||||
}
|
||||
|
1
rEFIt_UEFI/cpp_unit_test/printf_lite-test.h
Normal file
1
rEFIt_UEFI/cpp_unit_test/printf_lite-test.h
Normal file
@ -0,0 +1 @@
|
||||
int printf_lite_tests();
|
@ -45,7 +45,7 @@ static int compare(const char*s1, const char*s2)
|
||||
int ret2 = strcmp_reference(s1, s2);;
|
||||
|
||||
if ( sign(ret1) != sign(ret2) ) {
|
||||
DebugLog(2, "Comparing '%a' and '%a' gives %d and should have given %d\n", s1, s2, ret1, ret2);
|
||||
DebugLog(2, "Comparing '%s' and '%s' gives %d and should have given %d\n", s1, s2, ret1, ret2);
|
||||
return 1; // whatever if not 0
|
||||
}
|
||||
return 0;
|
||||
@ -101,7 +101,7 @@ static int compare_s1_with_variable_sizes(const char* s1, int code)
|
||||
{
|
||||
size_t count = (size_t)(rndf()*sizeof(s2)-1);
|
||||
if ( count >= sizeof(s2) ) {
|
||||
DebugLog(2, "compare_s1_with_variable_sizes, BUG : sizeof=%d, count=%d\n", sizeof(s2), count);
|
||||
DebugLog(2, "compare_s1_with_variable_sizes, BUG : sizeof=%lu, count=%zu\n", sizeof(s2), count);
|
||||
continue;
|
||||
}
|
||||
fillRandom(s2, count);
|
||||
|
@ -7,12 +7,12 @@
|
||||
|
||||
static int len(const char* s1, size_t count, int code)
|
||||
{
|
||||
//DebugLog(2, "strlen of '%a'\n", s1);
|
||||
//DebugLog(2, "strlen of '%s'\n", s1);
|
||||
|
||||
size_t ret1 = strlen(s1);
|
||||
|
||||
if ( ret1 != count ) {
|
||||
DebugLog(2, "strlen of '%a' gives %d and should have given %d\n", s1, ret1, count);
|
||||
DebugLog(2, "strlen of '%s' gives %zu and should have given %zu\n", s1, ret1, count);
|
||||
return code;
|
||||
}
|
||||
return 0;
|
||||
|
@ -52,12 +52,12 @@ static int nb_compare = 0;
|
||||
static int compare(const char*s1, const char*s2, size_t count)
|
||||
{
|
||||
nb_compare ++;
|
||||
//DebugLog(2, "Comparing '%a' and '%a' with count %d\n", s1, s2, count);
|
||||
//DebugLog(2, "Comparing '%s' and '%s' with count %d\n", s1, s2, count);
|
||||
int ret1 = strncmp(s1, s2, count);
|
||||
int ret2 = strncmp_reference(s1, s2, count);
|
||||
|
||||
if ( sign(ret1) != sign(ret2) ) {
|
||||
DebugLog(2, "Comparing '%a' and '%a' with count %d gives %d and should have given %d\n", s1, s2, count, ret1, ret2);
|
||||
DebugLog(2, "Comparing '%s' and '%s' with count %zu gives %d and should have given %d\n", s1, s2, count, ret1, ret2);
|
||||
int ret3 = strncmp(s1, s2, count); // for live debugging
|
||||
(void)ret3;
|
||||
return 1; // whatever if not 0
|
||||
@ -141,7 +141,7 @@ static int compare_s1_with_variable_sizes(const char* s1, size_t s1count, int co
|
||||
{
|
||||
size_t s2count = (size_t)(rndf()*sizeof(s2)-1);
|
||||
if ( s2count >= sizeof(s2) ) {
|
||||
DebugLog(2, "compare_s1_with_variable_sizes, BUG : sizeof=%d, count=%d\n", sizeof(s2), s2count);
|
||||
DebugLog(2, "compare_s1_with_variable_sizes, BUG : sizeof=%lu, count=%zu\n", sizeof(s2), s2count);
|
||||
continue;
|
||||
}
|
||||
fillRandom(s2, s2count);
|
||||
|
401
rEFIt_UEFI/cpp_unit_test/unicode_conversions.cpp
Executable file
401
rEFIt_UEFI/cpp_unit_test/unicode_conversions.cpp
Executable file
@ -0,0 +1,401 @@
|
||||
//
|
||||
// utf8Conversion.hpp
|
||||
//
|
||||
// Created by jief the 24 Feb 2020.
|
||||
//
|
||||
|
||||
#include "unicode_conversions.h"
|
||||
|
||||
#ifndef MIN
|
||||
#define MIN(a, b) ((a) < (b) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
size_t char16_len(const char16_t* s)
|
||||
{
|
||||
const char16_t* p = s;
|
||||
while ( *p++ );
|
||||
return (size_t)(p-s-1);
|
||||
}
|
||||
|
||||
size_t char32_len(const char32_t* s)
|
||||
{
|
||||
const char32_t* p = s;
|
||||
while ( *p++ );
|
||||
return (size_t)(p-s-1);
|
||||
}
|
||||
|
||||
size_t wchar_len(const wchar_t* s)
|
||||
{
|
||||
#if __WCHAR_MAX__ <= 0xFFFFu
|
||||
return char16_len((const char16_t*)s);
|
||||
#else
|
||||
return char32_len((const char32_t*)s);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
static inline int is_surrogate(char16_t uc) { return (uc - 0xd800u) < 2048u; }
|
||||
static inline int is_high_surrogate(char16_t uc) { return (uc & 0xfffffc00) == 0xd800; }
|
||||
static inline int is_low_surrogate(char16_t uc) { return (uc & 0xfffffc00) == 0xdc00; }
|
||||
|
||||
static inline char32_t surrogate_to_utf32(char16_t high, char16_t low) {
|
||||
return char32_t((high << 10) + low - 0x35fdc00); // Safe cast, it fits in 32 bits
|
||||
}
|
||||
|
||||
|
||||
/************************************************************* Char conversion *********************************************************/
|
||||
|
||||
#define halfBase 0x0010000UL
|
||||
#define halfMask 0x3FFUL
|
||||
#define halfShift 10 /* used for shifting by 10 bits */
|
||||
#define UNI_SUR_HIGH_START 0xD800u
|
||||
#define UNI_SUR_LOW_START 0xDC00u
|
||||
|
||||
|
||||
|
||||
const char* get_char32_from_utf8_string(const char *s, char32_t* char32)
|
||||
{
|
||||
char32_t c;
|
||||
if (*s & 0x80) {
|
||||
if (*(s+1) == 0) {
|
||||
// Finished in the middle of an utf8 multibyte char
|
||||
return 0;
|
||||
}
|
||||
if ((*(s+1) & 0xc0) != 0x80) {
|
||||
s += 1;
|
||||
return 0;
|
||||
}
|
||||
if ((*s & 0xe0) == 0xe0) {
|
||||
if (*(s+2) == 0) {
|
||||
// Finished in the middle of an utf8 multibyte char
|
||||
return 0;
|
||||
}
|
||||
if ((*(s+2) & 0xc0) != 0x80) {
|
||||
s += 2;
|
||||
return 0;
|
||||
}
|
||||
if ((*s & 0xf0) == 0xf0) {
|
||||
if (*(s+3) == 0) {
|
||||
// Finished in the middle of an utf8 multibyte char
|
||||
return 0;
|
||||
}
|
||||
if ((*s & 0xf8) != 0xf0 || (*(s+3) & 0xc0) != 0x80) {
|
||||
s += 3;
|
||||
return 0;
|
||||
}
|
||||
/* 4-byte code */
|
||||
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 = char32_t((*s & 0xf) << 12);
|
||||
c |= char32_t((*(s+1) & 0x3f) << 6);
|
||||
c |= *(s+2) & 0x3f;
|
||||
s += 3;
|
||||
}
|
||||
} else {
|
||||
/* 2-byte code */
|
||||
c = char32_t((*s & 0x1f) << 6);
|
||||
c |= *(s+1) & 0x3f;
|
||||
s += 2;
|
||||
}
|
||||
} else {
|
||||
/* 1-byte code */
|
||||
c = (unsigned char)(*s); // in case we compiled with signed char
|
||||
s += 1;
|
||||
}
|
||||
*char32 = c;
|
||||
return s;
|
||||
}
|
||||
|
||||
void get_char16_from_char32(char32_t char32, char16_t* char16_1, char16_t* char16_2)
|
||||
{
|
||||
if ( char32 <= 0xFFFF) {
|
||||
*char16_1 = (char16_t)char32;
|
||||
*char16_2 = 0;
|
||||
} else {
|
||||
char32 -= halfBase;
|
||||
*char16_1 = (char16_t)((char32 >> halfShift) + UNI_SUR_HIGH_START);
|
||||
*char16_2 = (char16_t)((char32 & halfMask) + UNI_SUR_LOW_START);
|
||||
}
|
||||
}
|
||||
|
||||
char32_t get_char32_from_char16(char16_t char16_1, char16_t char16_2)
|
||||
{
|
||||
if (!is_surrogate(char16_1)) {
|
||||
return char16_1;
|
||||
} else {
|
||||
if (is_high_surrogate(char16_1) && is_low_surrogate(char16_2)) {
|
||||
return surrogate_to_utf32(char16_1, char16_2);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const char16_t* get_char32_from_char16_string(const char16_t* s, char32_t* char32)
|
||||
{
|
||||
const char16_t char16_1 = *s++;
|
||||
if (!is_surrogate(char16_1)) {
|
||||
*char32 = char16_1;
|
||||
return s;
|
||||
} else {
|
||||
if (is_high_surrogate(char16_1) && is_low_surrogate(*s)) {
|
||||
*char32 = surrogate_to_utf32(char16_1, *s++);
|
||||
return s;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* dst_max_len MUST be >= 1 when called
|
||||
*/
|
||||
char* get_utf8_from_char32(char* dst, size_t* dst_max_len, char32_t utf32_char)
|
||||
{
|
||||
#ifdef JIEF_DEBUG
|
||||
char* dst_debug = dst;
|
||||
(void)dst_debug;
|
||||
#endif
|
||||
/* assertion: utf32_char is a single UTF-4 value */
|
||||
/* assertion: dst_max_len >= 1 */
|
||||
int bits = 0; // just to silence the warning
|
||||
|
||||
if (utf32_char < 0x80) {
|
||||
*dst++ = (char)utf32_char;
|
||||
*dst_max_len -= 1;
|
||||
bits = -6;
|
||||
}
|
||||
else if (utf32_char < 0x800) {
|
||||
*dst++ = (char)(((utf32_char >> 6) & 0x1F) | 0xC0);
|
||||
*dst_max_len -= 1;
|
||||
bits = 0;
|
||||
}
|
||||
else if (utf32_char < 0x10000) {
|
||||
*dst++ = (char)(((utf32_char >> 12) & 0x0F) | 0xE0);
|
||||
*dst_max_len -= 1;
|
||||
bits = 6;
|
||||
}
|
||||
else {
|
||||
*dst++ = (char)(((utf32_char >> 18) & 0x07) | 0xF0);
|
||||
*dst_max_len -= 1;
|
||||
bits = 12;
|
||||
}
|
||||
for ( ; *dst_max_len > 0 && bits >= 0 ; bits -= 6 ) {
|
||||
*dst++ = (char)(((utf32_char >> bits) & 0x3F) | 0x80);
|
||||
*dst_max_len -= 1;
|
||||
}
|
||||
#ifdef JIEF_DEBUG
|
||||
*dst = 0;
|
||||
#endif
|
||||
return dst;
|
||||
}
|
||||
|
||||
|
||||
/************************************************************* utf8 - char16 *********************************************************/
|
||||
|
||||
|
||||
size_t utf8_string_char16_count(const char *s)
|
||||
{
|
||||
if ( !s ) return 0;
|
||||
size_t len = 0;
|
||||
|
||||
while ( *s ) {
|
||||
char32_t c;
|
||||
s = get_char32_from_utf8_string(s, &c);
|
||||
if ( c == 0 ) return len;
|
||||
if ( c <= 0xFFFF) {
|
||||
len += 1;
|
||||
}else{
|
||||
len += 2;
|
||||
}
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
size_t char16_string_from_utf8_string(char16_t* dst, size_t dst_max_len, const char *s)
|
||||
{
|
||||
if ( dst_max_len == 0 ) return 0;
|
||||
dst_max_len -= 1;
|
||||
|
||||
// size_t dst_len = 0;
|
||||
char16_t* p = dst;
|
||||
char16_t* p_max = dst + dst_max_len;
|
||||
|
||||
while ( *s && p < p_max ) {
|
||||
char32_t c;
|
||||
s = get_char32_from_utf8_string(s, &c);
|
||||
if ( c == 0 ) return (size_t)(p-dst);
|
||||
char16_t char16_1, char16_2;
|
||||
get_char16_from_char32(c, &char16_1, &char16_2);
|
||||
if ( char16_2 != 0 ) {
|
||||
if ( p < p_max-1 ) {
|
||||
*p++ = char16_1;
|
||||
*p++ = char16_2;
|
||||
}else{
|
||||
*p = 0;
|
||||
return (size_t)(p-dst);
|
||||
}
|
||||
}else{
|
||||
*p++ = char16_1;
|
||||
}
|
||||
}
|
||||
*p = 0;
|
||||
return (size_t)(p-dst);
|
||||
}
|
||||
|
||||
size_t utf8_string_from_char16_string(char* dst, size_t dst_max_len, const char16_t *s)
|
||||
{
|
||||
char* p = dst;
|
||||
while ( *s && dst_max_len > 0 ) {
|
||||
char32_t utf32_char;
|
||||
s = get_char32_from_char16_string(s, &utf32_char);
|
||||
p = get_utf8_from_char32(p, &dst_max_len, utf32_char);
|
||||
}
|
||||
*p = 0;
|
||||
return (size_t)(p-dst);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/************************************************************* utf8 - char32 *********************************************************/
|
||||
|
||||
|
||||
size_t utf8_string_char32_count(const char *s)
|
||||
{
|
||||
if ( !s ) return 0;
|
||||
size_t len = 0;
|
||||
|
||||
while ( *s ) {
|
||||
char32_t c;
|
||||
s = get_char32_from_utf8_string(s, &c);
|
||||
if ( c == 0 ) return len;
|
||||
len += 1;
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
|
||||
size_t char32_string_from_utf8_string(char32_t* dst, size_t dst_max_len, const char *s)
|
||||
{
|
||||
if ( dst_max_len == 0 ) return 0;
|
||||
char32_t* p = dst;
|
||||
char32_t* p_max = dst + dst_max_len - 1;
|
||||
|
||||
while ( *s && p < p_max ) {
|
||||
char32_t c;
|
||||
s = get_char32_from_utf8_string(s, &c);
|
||||
if ( c == 0 ) return (size_t)(p-dst);
|
||||
*p++ = c;
|
||||
}
|
||||
*p = 0;
|
||||
return (size_t)(p-dst);
|
||||
}
|
||||
|
||||
size_t utf8_string_from_char32_string(char* dst, size_t dst_max_len, const char32_t *s)
|
||||
{
|
||||
char* p = dst;
|
||||
while ( *s && dst_max_len > 0 ) {
|
||||
p = get_utf8_from_char32(p, &dst_max_len, *s++);
|
||||
}
|
||||
*p = 0;
|
||||
return (size_t)(p-dst);
|
||||
}
|
||||
|
||||
|
||||
/************************************************************* utf8 - wchar *********************************************************/
|
||||
|
||||
size_t utf8_string_wchar_count(const char *s)
|
||||
{
|
||||
#if __WCHAR_MAX__ <= 0xFFFFu
|
||||
return utf8_string_char16_count(s);
|
||||
#else
|
||||
return utf8_string_char32_count(s);
|
||||
#endif
|
||||
}
|
||||
|
||||
size_t wchar_string_from_utf8_string(wchar_t* dst, size_t dst_max_len, const char *s)
|
||||
{
|
||||
#if __WCHAR_MAX__ <= 0xFFFFu
|
||||
return char16_string_from_utf8_string((char16_t*)dst, dst_max_len, s);
|
||||
#else
|
||||
return char32_string_from_utf8_string((char32_t*)dst, dst_max_len, s);
|
||||
#endif
|
||||
}
|
||||
|
||||
size_t utf8_string_from_wchar_string(char* dst, size_t dst_max_len, const wchar_t* s)
|
||||
{
|
||||
#if __WCHAR_MAX__ <= 0xFFFFu
|
||||
return utf8_string_from_char16_string(dst, dst_max_len, (char16_t*)s);
|
||||
#else
|
||||
return utf8_string_from_char32_string(dst, dst_max_len, (char32_t*)s);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/************************************************************* char16 - char32 *********************************************************/
|
||||
|
||||
|
||||
size_t char16_string_char32_count(const char16_t *s)
|
||||
{
|
||||
if ( !s ) return 0;
|
||||
size_t len = 0;
|
||||
|
||||
while ( *s ) {
|
||||
char32_t c;
|
||||
s = get_char32_from_char16_string(s, &c);
|
||||
if ( c == 0 ) return len;
|
||||
len += 1;
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
|
||||
size_t utf32_string_to_char16_string(char32_t* dst, size_t dst_max_len, const char16_t *s)
|
||||
{
|
||||
if ( dst_max_len == 0 ) return 0;
|
||||
char32_t* p = dst;
|
||||
char32_t* p_max = dst + dst_max_len - 1;
|
||||
|
||||
while ( *s && p < p_max ) {
|
||||
char32_t c;
|
||||
s = get_char32_from_char16_string(s, &c);
|
||||
if ( c == 0 ) return (size_t)(p-dst);
|
||||
*p++ = c;
|
||||
}
|
||||
*p = 0;
|
||||
return (size_t)(p-dst);
|
||||
}
|
||||
|
||||
size_t utf16_string_to_char32_string(char16_t* dst, size_t dst_max_len, const char32_t *s)
|
||||
{
|
||||
if ( dst_max_len == 0 ) return 0;
|
||||
char16_t* p = dst;
|
||||
char16_t* p_max = dst + dst_max_len - 1;
|
||||
|
||||
while ( *s && p < p_max ) {
|
||||
char16_t char16_1, char16_2;
|
||||
get_char16_from_char32(*s++, &char16_1, &char16_2);
|
||||
if ( char16_2 != 0 ) {
|
||||
if ( p < p_max-1 ) {
|
||||
*p++ = char16_1;
|
||||
*p++ = char16_2;
|
||||
}else{
|
||||
*p = 0;
|
||||
return (size_t)(p-dst);
|
||||
}
|
||||
}else{
|
||||
*p++ = char16_1;
|
||||
}
|
||||
}
|
||||
*p = 0;
|
||||
return (size_t)(p-dst);
|
||||
}
|
49
rEFIt_UEFI/cpp_unit_test/unicode_conversions.h
Normal file
49
rEFIt_UEFI/cpp_unit_test/unicode_conversions.h
Normal file
@ -0,0 +1,49 @@
|
||||
//
|
||||
// utf8Conversion.hpp
|
||||
//
|
||||
// Created by jief the 24 Feb 2020.
|
||||
//
|
||||
|
||||
#ifndef __unicode_conversions_h__
|
||||
#define __unicode_conversions_h__
|
||||
|
||||
#include <stddef.h>
|
||||
#include <wchar.h>
|
||||
|
||||
#ifndef __cplusplus
|
||||
//typedef uint16_t wchar_t;
|
||||
typedef uint32_t char32_t;
|
||||
typedef uint16_t char16_t;
|
||||
#endif
|
||||
|
||||
|
||||
size_t char16_len(const char16_t* s);
|
||||
size_t char32_len(const char32_t* s);
|
||||
size_t wchar_len(const wchar_t* s);
|
||||
|
||||
|
||||
char32_t get_char32_from_utf8(const char *s);
|
||||
void get_char16_from_char32(char32_t char32, char16_t* char16_1, char16_t* char16_2);
|
||||
|
||||
size_t utf8_string_char16_count(const char *src);
|
||||
size_t char16_string_from_utf8_string(char16_t* dst, size_t dst_max_len, const char *s);
|
||||
size_t utf8_string_from_char16_string(char* dst, size_t dst_max_len, const char16_t *s);
|
||||
|
||||
size_t utf8_string_char32_count(const char *s);
|
||||
size_t char32_string_from_utf8_string(char32_t* dst, size_t dst_max_len, const char *s);
|
||||
size_t utf8_string_from_char32_string(char* dst, size_t dst_max_len, const char32_t *s);
|
||||
|
||||
|
||||
size_t utf8_string_wchar_count(const char *src);
|
||||
size_t wchar_string_from_utf8_string(wchar_t* dst, size_t dst_max_len, const char *s);
|
||||
size_t utf8_string_from_wchar_string(char* dst, size_t dst_max_len, const wchar_t* s);
|
||||
|
||||
|
||||
size_t char16_string_char32_count(const char16_t *s);
|
||||
size_t utf32_string_to_char16_string(char32_t* dst, size_t dst_max_len, const char16_t *s);
|
||||
size_t utf16_string_to_char32_string(char16_t* dst, size_t dst_max_len, const char32_t *s);
|
||||
|
||||
|
||||
|
||||
|
||||
#endif /* utf816Conversion_hpp */
|
@ -94,14 +94,16 @@
|
||||
libeg/XPointer.cpp
|
||||
libeg/XPointer.h
|
||||
libeg/XTheme.h
|
||||
Platform/Posix/limits.h
|
||||
Platform/Posix/posix.h
|
||||
Platform/Posix/limits.h
|
||||
Platform/Posix/stdarg.h
|
||||
Platform/Posix/stddef.h
|
||||
Platform/Posix/stdint.h
|
||||
Platform/Posix/stdlib.h
|
||||
Platform/Posix/stdio.cpp
|
||||
Platform/Posix/strcmp.cpp
|
||||
Platform/Posix/strlen.cpp
|
||||
Platform/Posix/wchar.cpp
|
||||
Platform/Posix/abort.cpp
|
||||
Platform/AcpiPatcher.cpp
|
||||
Platform/ati_reg.h
|
||||
@ -195,8 +197,6 @@
|
||||
cpp_util/operatorNewDelete.cpp
|
||||
cpp_util/operatorNewDelete.h
|
||||
cpp_util/remove_ref.h
|
||||
cpp_foundation/printf_lite.cpp
|
||||
cpp_foundation/printf_lite.h
|
||||
cpp_foundation/utf8Conversion.cpp
|
||||
cpp_foundation/utf8Conversion.h
|
||||
cpp_foundation/XArray.h
|
||||
@ -217,6 +217,11 @@
|
||||
cpp_unit_test/all_tests.cpp
|
||||
cpp_unit_test/global_test.cpp
|
||||
cpp_unit_test/global_test.h
|
||||
cpp_unit_test/unicode_conversions.cpp
|
||||
cpp_unit_test/unicode_conversions.h
|
||||
cpp_unit_test/printf_lite-test.cpp
|
||||
cpp_unit_test/printf_lite-test.h
|
||||
cpp_unit_test/printf_lite-test-cpp_conf.h
|
||||
cpp_unit_test/strlen_test.cpp
|
||||
cpp_unit_test/strlen_test.h
|
||||
cpp_unit_test/strcmp_test.cpp
|
||||
|
@ -1435,14 +1435,6 @@ VOID HelpRefit(VOID)
|
||||
} else {
|
||||
HelpMenu.TitleImage = NULL;
|
||||
}
|
||||
#ifdef JIEF_DEBUG
|
||||
wchar_t c = L'ы';
|
||||
XString s(L"ы");
|
||||
XString s2("ы");
|
||||
DBG("%a\n", XString(L"ы").c, c);
|
||||
HelpMenu.Entries.Empty();
|
||||
#endif
|
||||
|
||||
if (HelpMenu.Entries.size() == 0) {
|
||||
switch (gLanguage)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user