mirror of
https://github.com/libAthena/athena.git
synced 2025-12-08 21:18:02 +00:00
Compare commits
60 Commits
a87e8bb39f
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 1109491cd1 | |||
| b37c3d3dcb | |||
| 4f3531dd1f | |||
| 304135f38a | |||
| 9e0486c1f6 | |||
| d2d54fe6ef | |||
| 7d7d0e0891 | |||
| 5a416eec41 | |||
| e0fbcfee7e | |||
| af3580fbb3 | |||
| a681cef0a4 | |||
| e1cac75d80 | |||
| b8a46a5ee6 | |||
| f7c1cd8f59 | |||
| fa346ace47 | |||
| c6046d9150 | |||
| 01970c7249 | |||
| f27a63f312 | |||
|
e13b498266
|
|||
|
066e3ae109
|
|||
|
644070d5f3
|
|||
| 2aa9a573a0 | |||
| 4bd9dfac61 | |||
| bc2ebaab88 | |||
| 6eec5760b3 | |||
| 96fa2d24ef | |||
| b0daee99fc | |||
| daf8bf0595 | |||
| 2aa5b76732 | |||
| 064839bad6 | |||
| 37206e5301 | |||
| 37c56eec07 | |||
| a4074e1a57 | |||
| da92db7356 | |||
| f02251ebf3 | |||
| 14e4d4e2ea | |||
| 11b86d7634 | |||
| 7a2a8a79ca | |||
| 991ffede79 | |||
| 4fa2335258 | |||
| ec43f653a7 | |||
| 2604243293 | |||
| 8558ca1b51 | |||
| b67f6dc231 | |||
| b3a274fcd8 | |||
| a36e589129 | |||
| 42d777bc1c | |||
| bbf8923a09 | |||
| 3ca375d030 | |||
| e2af6e5c79 | |||
| c53c9560fd | |||
| ec2675f130 | |||
| 79515ed6db | |||
| 144e14f2f5 | |||
| 85a16c7f45 | |||
| 5358d195bb | |||
| 608d675d9c | |||
| 666dea48ae | |||
|
|
25d3ed0f33 | ||
|
|
f5ad22ecf4 |
29
.clang-format
Normal file
29
.clang-format
Normal file
@@ -0,0 +1,29 @@
|
||||
---
|
||||
BasedOnStyle: LLVM
|
||||
ColumnLimit: 120
|
||||
UseTab: Never
|
||||
TabWidth: 2
|
||||
---
|
||||
Language: Cpp
|
||||
DerivePointerAlignment: false
|
||||
PointerAlignment: Left
|
||||
AlignAfterOpenBracket: Align
|
||||
AlignConsecutiveAssignments: false
|
||||
IndentCaseLabels: false
|
||||
AllowShortBlocksOnASingleLine: Always
|
||||
AlignOperands: true
|
||||
AlignTrailingComments: true
|
||||
AlwaysBreakBeforeMultilineStrings: true
|
||||
AlwaysBreakTemplateDeclarations: Yes
|
||||
BreakConstructorInitializersBeforeComma: true
|
||||
AlwaysBreakAfterReturnType: None
|
||||
AlwaysBreakAfterDefinitionReturnType: None
|
||||
AllowShortFunctionsOnASingleLine: All
|
||||
Cpp11BracedListStyle: true
|
||||
NamespaceIndentation: None
|
||||
BinPackArguments: true
|
||||
BinPackParameters: true
|
||||
SortIncludes: false
|
||||
AccessModifierOffset: -2
|
||||
ConstructorInitializerIndentWidth: 0
|
||||
ConstructorInitializerAllOnOneLineOrOnePerLine: true
|
||||
1
.clang-tidy
Normal file
1
.clang-tidy
Normal file
@@ -0,0 +1 @@
|
||||
Checks: '*,-misc-unused-parameters,-modernize-use-trailing-return-type,-readability-named-parameter,-readability-convert-member-functions-to-static,-readability-uppercase-literal-suffix,-readability-magic-numbers,-hicpp-uppercase-literal-suffix,-hicpp-signed-bitwise,-cppcoreguidelines-avoid-magic-numbers,-cppcoreguidelines-pro-type-static-cast-downcast,-cppcoreguidelines-pro-bounds-constant-array-index,-cppcoreguidelines-owning-memory,-cppcoreguidelines-pro-type-union-access,-cppcoreguidelines-pro-bounds-pointer-arithmetic,-cppcoreguidelines-non-private-member-variables-in-classes,-fuchsia-*,-google-runtime-references,-llvmlibc-*'
|
||||
6
.gitignore
vendored
6
.gitignore
vendored
@@ -18,4 +18,8 @@ PKGBUILD
|
||||
**/doc
|
||||
**/obj
|
||||
**/Makefile
|
||||
|
||||
/build
|
||||
/out
|
||||
/cmake-build-*
|
||||
/.idea
|
||||
/.buildcache
|
||||
|
||||
6
.gitmodules
vendored
6
.gitmodules
vendored
@@ -1,8 +1,4 @@
|
||||
[submodule "extern/lzokay"]
|
||||
path = extern/lzokay
|
||||
url = https://github.com/jackoalan/lzokay.git
|
||||
branch = master
|
||||
[submodule "extern/fmt"]
|
||||
path = extern/fmt
|
||||
url = https://github.com/fmtlib/fmt
|
||||
url = https://github.com/AxioDL/lzokay.git
|
||||
branch = master
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
set(PACKAGE_VERSION "@ATHENA_VERSION@")
|
||||
set(PACKAGE_VERSION "@ATHENA_VERSION_STRING@")
|
||||
|
||||
# Check whether the requested PACKAGE_FIND_VERSION is compatible
|
||||
if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}")
|
||||
|
||||
242
CMakeLists.txt
242
CMakeLists.txt
@@ -1,21 +1,138 @@
|
||||
cmake_minimum_required(VERSION 3.10 FATAL_ERROR) # because of c++17
|
||||
# Set MSVC runtime library flags from CMAKE_MSVC_RUNTIME_LIBRARY
|
||||
cmake_policy(SET CMP0091 NEW)
|
||||
project(athena)
|
||||
if (NOT MSVC)
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
endif()
|
||||
|
||||
##################
|
||||
# Athena Version #
|
||||
##################
|
||||
find_package(Git)
|
||||
if (GIT_FOUND)
|
||||
# make sure version information gets re-run when the current Git HEAD changes
|
||||
execute_process(WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMMAND ${GIT_EXECUTABLE} rev-parse --git-path HEAD
|
||||
OUTPUT_VARIABLE athena_git_head_filename
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${athena_git_head_filename}")
|
||||
|
||||
set(ATHENA_MAJOR_VERSION 2)
|
||||
set(ATHENA_MINOR_VERSION 3)
|
||||
set(ATHENA_PATCH_VERSION 0)
|
||||
set(ATHENA_VERSION
|
||||
${ATHENA_MAJOR_VERSION}.${ATHENA_MINOR_VERSION}.${ATHENA_PATCH_VERSION})
|
||||
execute_process(WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMMAND ${GIT_EXECUTABLE} rev-parse --symbolic-full-name HEAD
|
||||
OUTPUT_VARIABLE athena_git_head_symbolic
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
execute_process(WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
COMMAND ${GIT_EXECUTABLE} rev-parse --git-path ${athena_git_head_symbolic}
|
||||
OUTPUT_VARIABLE athena_git_head_symbolic_filename
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${athena_git_head_symbolic_filename}")
|
||||
|
||||
# defines ATHENA_WC_REVISION
|
||||
execute_process(WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMMAND ${GIT_EXECUTABLE} rev-parse HEAD
|
||||
OUTPUT_VARIABLE ATHENA_WC_REVISION
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
# defines ATHENA_WC_DESCRIBE
|
||||
execute_process(WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMMAND ${GIT_EXECUTABLE} describe --tag --long --dirty --exclude latest
|
||||
OUTPUT_VARIABLE ATHENA_WC_DESCRIBE
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
# remove hash (and trailing "-0" if needed) from description
|
||||
string(REGEX REPLACE "(-0)?-[^-]+((-dirty)?)$" "\\2" ATHENA_WC_DESCRIBE "${ATHENA_WC_DESCRIBE}")
|
||||
|
||||
# defines ATHENA_WC_BRANCH
|
||||
execute_process(WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD
|
||||
OUTPUT_VARIABLE ATHENA_WC_BRANCH
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
# defines ATHENA_WC_DATE
|
||||
execute_process(WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMMAND ${GIT_EXECUTABLE} log -1 --format=%ad
|
||||
OUTPUT_VARIABLE ATHENA_WC_DATE
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
else ()
|
||||
message(STATUS "Unable to find git, commit information will not be available")
|
||||
endif ()
|
||||
|
||||
if (ATHENA_WC_DESCRIBE)
|
||||
string(REGEX REPLACE "v?([0-9]+)\.([0-9]+)\.([0-9]+)\-([0-9]+).*" "\\1.\\2.\\3.\\4" ATHENA_VERSION_STRING "${ATHENA_WC_DESCRIBE}")
|
||||
string(REGEX REPLACE "v?([0-9]+)\.([0-9]+)\.([0-9]+).*" "\\1.\\2.\\3" ATHENA_VERSION "${ATHENA_VERSION_STRING}")
|
||||
string(REGEX REPLACE "v?([0-9]+)\.([0-9]+)\.([0-9]+).*" "\\1" ATHENA_MAJOR_VERSION "${ATHENA_VERSION_STRING}")
|
||||
string(REGEX REPLACE "v?([0-9]+)\.([0-9]+)\.([0-9]+).*" "\\2" ATHENA_MINOR_VERSION "${ATHENA_VERSION_STRING}")
|
||||
string(REGEX REPLACE "v?([0-9]+)\.([0-9]+)\.([0-9]+).*" "\\3" ATHENA_PATCH_VERSION "${ATHENA_VERSION_STRING}")
|
||||
else ()
|
||||
set(ATHENA_WC_DESCRIBE "UNKNOWN-VERSION")
|
||||
set(ATHENA_VERSION "0.0.0")
|
||||
set(ATHENA_MAJOR_VERSION "0")
|
||||
set(ATHENA_MINOR_VERSION "0")
|
||||
set(ATHENA_PATCH_VERSION "0")
|
||||
endif ()
|
||||
|
||||
# Add version information to CI environment variables
|
||||
if(DEFINED ENV{GITHUB_ENV} AND CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
|
||||
file(APPEND "$ENV{GITHUB_ENV}" "ATHENA_VERSION=${ATHENA_WC_DESCRIBE}\n")
|
||||
endif()
|
||||
|
||||
project(athena VERSION ${ATHENA_VERSION} LANGUAGES C CXX)
|
||||
|
||||
if (MSVC)
|
||||
# Shaddup MSVC
|
||||
add_compile_definitions(UNICODE=1 _UNICODE=1 __SSE__=1
|
||||
_CRT_SECURE_NO_WARNINGS=1 D_SCL_SECURE_NO_WARNINGS=1
|
||||
_SCL_SECURE_NO_DEPRECATE=1 _CRT_NONSTDC_NO_WARNINGS=1
|
||||
_ENABLE_EXTENDED_ALIGNED_STORAGE=1 NOMINMAX=1)
|
||||
add_compile_options(/IGNORE:4221
|
||||
$<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:/wd4018>
|
||||
$<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:/wd4800>
|
||||
$<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:/wd4005>
|
||||
$<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:/wd4311>
|
||||
$<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:/wd4068>
|
||||
$<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:/wd4267>
|
||||
$<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:/wd4244>
|
||||
$<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:/wd4200>
|
||||
$<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:/wd4305>
|
||||
$<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:/wd4067>
|
||||
$<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:/wd4146>
|
||||
$<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:/wd4309>
|
||||
$<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:/wd4805>
|
||||
${VS_OPTIONS})
|
||||
|
||||
string(REPLACE "/GR " "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
string(REPLACE " /EHsc" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
add_compile_options(
|
||||
# Disable exceptions
|
||||
$<$<COMPILE_LANGUAGE:CXX>:/EHsc->
|
||||
|
||||
# Disable RTTI
|
||||
$<$<COMPILE_LANGUAGE:CXX>:/GR->
|
||||
|
||||
# Enforce various standards compliant behavior.
|
||||
$<$<COMPILE_LANGUAGE:CXX>:/permissive->
|
||||
|
||||
# Enable standard volatile semantics.
|
||||
$<$<COMPILE_LANGUAGE:CXX>:/volatile:iso>
|
||||
|
||||
# Reports the proper value for the __cplusplus preprocessor macro.
|
||||
$<$<COMPILE_LANGUAGE:CXX>:/Zc:__cplusplus>
|
||||
|
||||
# Use latest C++ standard.
|
||||
$<$<COMPILE_LANGUAGE:CXX>:/std:c++latest>
|
||||
)
|
||||
|
||||
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
|
||||
# Flags for MSVC (not clang-cl)
|
||||
add_compile_options(
|
||||
# Allow constexpr variables to have explicit external linkage.
|
||||
$<$<COMPILE_LANGUAGE:CXX>:/Zc:externConstexpr>
|
||||
|
||||
# Assume that new throws exceptions, allowing better code generation.
|
||||
$<$<COMPILE_LANGUAGE:CXX>:/Zc:throwingNew>
|
||||
|
||||
# Link-time Code Generation for Release builds
|
||||
$<$<CONFIG:Release>:/GL>
|
||||
)
|
||||
|
||||
# Link-time Code Generation for Release builds
|
||||
set(CMAKE_STATIC_LINKER_FLAGS_RELEASE "/LTCG")
|
||||
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/RELEASE /LTCG /OPT:REF /OPT:ICF /INCREMENTAL:NO")
|
||||
set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "/DEBUG /RELEASE /OPT:REF /OPT:ICF /INCREMENTAL:NO /DEBUGTYPE:cv,fixup")
|
||||
endif ()
|
||||
else ()
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
endif ()
|
||||
|
||||
################
|
||||
# Athena Build #
|
||||
@@ -23,7 +140,7 @@ set(ATHENA_VERSION
|
||||
|
||||
add_subdirectory(extern)
|
||||
|
||||
add_library(athena-core
|
||||
add_library(athena-core STATIC
|
||||
src/athena/Utility.cpp
|
||||
src/athena/MemoryReader.cpp
|
||||
src/athena/MemoryWriter.cpp
|
||||
@@ -39,7 +156,7 @@ add_library(athena-core
|
||||
src/LZ77/LZBase.cpp
|
||||
src/athena/FileInfo.cpp
|
||||
src/athena/Dir.cpp
|
||||
src/athena/DNAYaml.cpp
|
||||
src/sha1.cpp
|
||||
|
||||
include/athena/IStream.hpp
|
||||
include/athena/IStreamReader.hpp
|
||||
@@ -62,14 +179,12 @@ add_library(athena-core
|
||||
include/LZ77/LZType11.hpp
|
||||
include/athena/FileInfo.hpp
|
||||
include/athena/Dir.hpp
|
||||
include/athena/DNA.hpp
|
||||
include/athena/DNAYaml.hpp
|
||||
include/athena/DNAOp.hpp
|
||||
include/athena/YAMLCommon.hpp
|
||||
include/athena/YAMLDocReader.hpp
|
||||
include/athena/YAMLDocWriter.hpp
|
||||
include/yaml.h
|
||||
include/utf8proc.h
|
||||
include/athena/yaml.h
|
||||
include/athena/utf8proc.h
|
||||
include/sha1.h
|
||||
)
|
||||
if(WIN32)
|
||||
target_sources(athena-core PRIVATE
|
||||
@@ -97,7 +212,7 @@ else()
|
||||
if(GEKKO OR NX)
|
||||
target_sources(athena-core PRIVATE
|
||||
src/gekko_support.c
|
||||
include/gekko_support.h
|
||||
include/athena/gekko_support.h
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
@@ -105,14 +220,13 @@ endif()
|
||||
|
||||
target_include_directories(athena-core PUBLIC
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||
$<BUILD_INTERFACE:${ZLIB_INCLUDE_DIR}>
|
||||
)
|
||||
target_link_libraries(athena-core PUBLIC
|
||||
athena-libyaml
|
||||
fmt
|
||||
$<BUILD_INTERFACE:${ZLIB_LIBRARIES}>
|
||||
)
|
||||
|
||||
add_library(athena-sakura EXCLUDE_FROM_ALL
|
||||
add_library(athena-sakura STATIC EXCLUDE_FROM_ALL
|
||||
src/athena/Sprite.cpp
|
||||
src/athena/SpriteFile.cpp
|
||||
src/athena/SpriteFileReader.cpp
|
||||
@@ -128,8 +242,11 @@ add_library(athena-sakura EXCLUDE_FROM_ALL
|
||||
include/athena/SpriteFrame.hpp
|
||||
include/athena/SpritePart.hpp
|
||||
)
|
||||
target_include_directories(athena-sakura PUBLIC
|
||||
include
|
||||
)
|
||||
|
||||
add_library(athena-wiisave EXCLUDE_FROM_ALL
|
||||
add_library(athena-wiisave STATIC EXCLUDE_FROM_ALL
|
||||
src/athena/WiiBanner.cpp
|
||||
src/athena/WiiFile.cpp
|
||||
src/athena/WiiImage.cpp
|
||||
@@ -139,7 +256,6 @@ add_library(athena-wiisave EXCLUDE_FROM_ALL
|
||||
src/bn.cpp
|
||||
src/ec.cpp
|
||||
src/md5.cpp
|
||||
src/sha1.cpp
|
||||
src/aes.cpp
|
||||
|
||||
include/athena/WiiBanner.hpp
|
||||
@@ -152,14 +268,16 @@ add_library(athena-wiisave EXCLUDE_FROM_ALL
|
||||
include/bn.hpp
|
||||
include/ec.hpp
|
||||
include/md5.h
|
||||
include/sha1.h
|
||||
)
|
||||
target_include_directories(athena-wiisave PUBLIC
|
||||
include
|
||||
)
|
||||
if(NOT MSVC AND ${CMAKE_SYSTEM_PROCESSOR} STREQUAL x86_64)
|
||||
set_source_files_properties(src/aes.cpp PROPERTIES COMPILE_FLAGS -maes)
|
||||
endif()
|
||||
|
||||
|
||||
add_library(athena-zelda EXCLUDE_FROM_ALL
|
||||
add_library(athena-zelda STATIC EXCLUDE_FROM_ALL
|
||||
src/athena/ALTTPFile.cpp
|
||||
src/athena/ALTTPFileReader.cpp
|
||||
src/athena/ALTTPFileWriter.cpp
|
||||
@@ -193,18 +311,16 @@ add_library(athena-zelda EXCLUDE_FROM_ALL
|
||||
include/athena/ZQuestFileReader.hpp
|
||||
include/athena/ZQuestFileWriter.hpp
|
||||
)
|
||||
|
||||
target_include_directories(athena-zelda PUBLIC
|
||||
include
|
||||
)
|
||||
# Icon
|
||||
set(ATHENA_ICO ${CMAKE_CURRENT_SOURCE_DIR}/Athena.ico)
|
||||
|
||||
# Offer the user the choice of overriding the installation directories
|
||||
set(INSTALL_LIB_DIR lib CACHE PATH "Installation directory for libraries")
|
||||
set(INSTALL_INCLUDE_DIR include CACHE PATH "Installation directory for header files")
|
||||
if(WIN32 AND NOT CYGWIN)
|
||||
set(INSTALL_CMAKE_DIR cmake)
|
||||
else()
|
||||
set(INSTALL_CMAKE_DIR lib/cmake/athena)
|
||||
endif()
|
||||
|
||||
# Make relative paths absolute (needed later on)
|
||||
foreach(p LIB INCLUDE CMAKE)
|
||||
@@ -217,10 +333,10 @@ foreach(p LIB INCLUDE CMAKE)
|
||||
endforeach()
|
||||
|
||||
# Define installs
|
||||
install(DIRECTORY include DESTINATION ${INSTALL_INCLUDE_DIR}/athena COMPONENT athena)
|
||||
install(DIRECTORY extern/fmt/include DESTINATION ${INSTALL_INCLUDE_DIR}/fmt COMPONENT athena)
|
||||
install(TARGETS athena-core fmt
|
||||
DESTINATION ${INSTALL_LIB_DIR} EXPORT AthenaTargets COMPONENT athena)
|
||||
install(DIRECTORY include/athena DESTINATION ${INSTALL_INCLUDE_DIR} COMPONENT athena)
|
||||
if (ATHENA_ZLIB)
|
||||
set(ZLIB_INSTALL ${ZLIB_LIBRARIES})
|
||||
endif ()
|
||||
if(WIN32 AND NOT CYGWIN)
|
||||
install(FILES Athena.ico DESTINATION ${INSTALL_LIB_DIR} COMPONENT athena)
|
||||
elseif(UNIX)
|
||||
@@ -234,9 +350,6 @@ endif()
|
||||
# Package Export #
|
||||
##################
|
||||
|
||||
# Add all targets to the build-tree export set
|
||||
export(TARGETS athena-core athena-libyaml fmt FILE "${CMAKE_CURRENT_BINARY_DIR}/AthenaTargets.cmake")
|
||||
|
||||
# Export the package for use from the build-tree
|
||||
# (this registers the build-tree with a global CMake-registry)
|
||||
export(PACKAGE athena)
|
||||
@@ -264,48 +377,43 @@ install(FILES
|
||||
# Install the export set for use with the install-tree
|
||||
install(EXPORT AthenaTargets DESTINATION ${INSTALL_CMAKE_DIR} COMPONENT athena)
|
||||
|
||||
################
|
||||
# atdna import #
|
||||
################
|
||||
|
||||
add_subdirectory(atdna)
|
||||
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
|
||||
# Test target
|
||||
add_executable(atdna-test atdna/test.cpp atdna/test.hpp)
|
||||
target_atdna(atdna-test atdna_test.cpp atdna/test.hpp)
|
||||
if (CMAKE_SYSTEM_NAME STREQUAL "Switch")
|
||||
set_target_properties(atdna-test PROPERTIES SUFFIX ".elf")
|
||||
target_link_libraries(atdna-test athena-core nx)
|
||||
else()
|
||||
target_link_libraries(atdna-test athena-core)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
#########
|
||||
# CPack #
|
||||
#########
|
||||
|
||||
include(InstallRequiredSystemLibraries)
|
||||
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Athena")
|
||||
set(CPACK_PACKAGE_VENDOR "Antidote / Jackoalan")
|
||||
set(CPACK_PACKAGE_VENDOR "AxioDL Team")
|
||||
set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
|
||||
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
|
||||
set(CPACK_PACKAGE_VERSION_MAJOR ${ATHENA_MAJOR_VERSION})
|
||||
set(CPACK_PACKAGE_VERSION_MINOR ${ATHENA_MINOR_VERSION})
|
||||
set(CPACK_PACKAGE_VERSION_PATCH ${ATHENA_PATCH_VERSION})
|
||||
set(CPACK_PACKAGE_INSTALL_DIRECTORY "athena")
|
||||
if(WIN32 AND NOT UNIX)
|
||||
# There is a bug in NSI that does not handle full unix paths properly. Make
|
||||
# sure there is at least one set of four (4) backlasshes.
|
||||
set(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "athena")
|
||||
set(CPACK_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}\\\\AthenaNSIS.bmp")
|
||||
set(CPACK_NSIS_MODIFY_PATH ON)
|
||||
set(CPACK_NSIS_MUI_ICON "${CMAKE_CURRENT_SOURCE_DIR}\\\\Athena.ico")
|
||||
set(CPACK_NSIS_MUI_UNIICON "${CMAKE_CURRENT_SOURCE_DIR}\\\\Athena.ico")
|
||||
set(CPACK_NSIS_INSTALLED_ICON_NAME "Uninstall.exe")
|
||||
set(CPACK_NSIS_DISPLAY_NAME "Athena")
|
||||
set(CPACK_NSIS_URL_INFO_ABOUT "http://libathena.github.io")
|
||||
set(CPACK_NSIS_CONTACT "antidote.crk@gmail.com")
|
||||
set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY 0)
|
||||
|
||||
string(TOLOWER "${CMAKE_SYSTEM_PROCESSOR}" ARCHITECTURE_NAME)
|
||||
if (CMAKE_SYSTEM_NAME STREQUAL Windows)
|
||||
set(SYSTEM_NAME win32)
|
||||
elseif (CMAKE_SYSTEM_NAME STREQUAL Darwin)
|
||||
set(SYSTEM_NAME macos)
|
||||
list(LENGTH CMAKE_OSX_ARCHITECTURES num_archs)
|
||||
if (num_archs GREATER 1)
|
||||
set(ARCHITECTURE_NAME universal)
|
||||
elseif(num_archs EQUAL 1)
|
||||
set(ARCHITECTURE_NAME ${CMAKE_OSX_ARCHITECTURES})
|
||||
endif()
|
||||
elseif (CMAKE_SYSTEM_NAME STREQUAL Linux)
|
||||
set(SYSTEM_NAME linux)
|
||||
else ()
|
||||
set(SYSTEM_NAME "${CMAKE_SYSTEM_NAME}")
|
||||
endif ()
|
||||
set(CPACK_PACKAGE_FILE_NAME "athena-${SYSTEM_NAME}-${ARCHITECTURE_NAME}")
|
||||
|
||||
if (WIN32)
|
||||
set(CPACK_GENERATOR 7Z)
|
||||
else ()
|
||||
set(CPACK_GENERATOR TGZ)
|
||||
endif ()
|
||||
include(CPack)
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# PKGBUILD for libAthena
|
||||
_pkgname=libathena
|
||||
pkgname=$_pkgname-git
|
||||
pkgver=@ATHENA_VERSION@
|
||||
pkgver=@ATHENA_VERSION_STRING@
|
||||
pkgrel=1
|
||||
pkgdesc="Basic cross platform IO library"
|
||||
arch=('i686' 'x86_64')
|
||||
|
||||
@@ -1,202 +0,0 @@
|
||||
###############
|
||||
# ATDNA Build #
|
||||
###############
|
||||
|
||||
if(NOT CMAKE_CROSSCOMPILING)
|
||||
|
||||
string(REPLACE -stdlib=libc++ "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
|
||||
get_directory_property(ATDNA_DEFINES COMPILE_DEFINITIONS)
|
||||
list(REMOVE_ITEM ATDNA_DEFINES _GLIBCXX_DEBUG=1)
|
||||
set_directory_properties(PROPERTIES COMPILE_DEFINITIONS "${ATDNA_DEFINES}")
|
||||
|
||||
# Find dependencies
|
||||
include(FindLLVM.cmake)
|
||||
if(NOT LLVM_FOUND)
|
||||
message(STATUS "Unable to locate LLVM installation; skipping atdna")
|
||||
else()
|
||||
|
||||
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
|
||||
option(ATDNA_DYNAMIC_LLVM "Use dynamic library targets when linking LLVM" ON)
|
||||
else()
|
||||
option(ATDNA_DYNAMIC_LLVM "Use dynamic library targets when linking LLVM" OFF)
|
||||
endif()
|
||||
|
||||
if(ATDNA_DYNAMIC_LLVM)
|
||||
find_library(CLANGCPP_LIB clang-cpp HINTS "${LLVM_ROOT_DIR}/lib")
|
||||
if (NOT CLANGCPP_LIB)
|
||||
list(APPEND LLVM_LIBS
|
||||
clangFrontend
|
||||
clangTooling
|
||||
clangDriver
|
||||
clangSerialization
|
||||
clangParse
|
||||
clangSema
|
||||
clangAnalysis
|
||||
clangEdit
|
||||
clangAST
|
||||
clangLex
|
||||
clangBasic
|
||||
LLVM)
|
||||
else()
|
||||
list(APPEND LLVM_LIBS
|
||||
clang-cpp
|
||||
LLVM)
|
||||
endif()
|
||||
else()
|
||||
find_library(LLVMDEMANGLE_LIB LLVMDemangle HINTS "${LLVM_ROOT_DIR}/lib")
|
||||
find_library(LLVMBINARYFORMAT_LIB LLVMBinaryFormat HINTS "${LLVM_ROOT_DIR}/lib")
|
||||
if (NOT LLVMDEMANGLE_LIB)
|
||||
set(LLVMDEMANGLE_LIB "")
|
||||
endif()
|
||||
if (NOT LLVMBINARYFORMAT_LIB)
|
||||
set(LLVMBINARYFORMAT_LIB "")
|
||||
endif()
|
||||
find_library(CLANG_CPP_LIB clang-cpp HINTS "${LLVM_ROOT_DIR}/lib")
|
||||
if (NOT CLANG_CPP_LIB)
|
||||
list(APPEND CLANG_LIBS
|
||||
clangFrontend
|
||||
clangTooling
|
||||
clangDriver
|
||||
clangSerialization
|
||||
clangParse
|
||||
clangSema
|
||||
clangAnalysis
|
||||
clangEdit
|
||||
clangAST
|
||||
clangLex
|
||||
clangBasic)
|
||||
else()
|
||||
list(APPEND CLANG_LIBS
|
||||
clang-cpp)
|
||||
endif()
|
||||
|
||||
list(APPEND LLVM_LIBS
|
||||
${CLANG_LIBS}
|
||||
LLVMCore
|
||||
LLVMOption
|
||||
LLVMMCParser
|
||||
LLVMBitReader
|
||||
${LLVMBINARYFORMAT_LIB}
|
||||
LLVMMC
|
||||
LLVMProfileData
|
||||
LLVMSupport
|
||||
LLVMRemarks
|
||||
LLVMBitStreamReader
|
||||
${LLVMDEMANGLE_LIB}
|
||||
LLVMFrontendOpenMP)
|
||||
endif()
|
||||
|
||||
string(FIND ${LLVM_VERSION_STRING} "svn" SVN_FILTER_IDX)
|
||||
if(NOT SVN_FILTER_IDX EQUAL -1)
|
||||
string(SUBSTRING ${LLVM_VERSION_STRING} 0 ${SVN_FILTER_IDX} LLVM_VERSION_BASE)
|
||||
else()
|
||||
set(LLVM_VERSION_BASE ${LLVM_VERSION_STRING})
|
||||
endif()
|
||||
|
||||
set(CLANG_INCLUDE_DIR ${LLVM_LIBRARY_DIRS}/clang/${LLVM_VERSION_BASE}/include
|
||||
CACHE PATH "Clang include dir" FORCE)
|
||||
|
||||
if(UNIX)
|
||||
list(APPEND PLAT_LIBS z pthread curses)
|
||||
if (APPLE)
|
||||
list(APPEND PLAT_LIBS dl)
|
||||
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||
list(APPEND PLAT_LIBS dl tinfo)
|
||||
endif()
|
||||
elseif(WIN32)
|
||||
list(APPEND PLAT_LIBS Version)
|
||||
endif()
|
||||
|
||||
# Offer the user the choice of overriding the installation directories
|
||||
set(INSTALL_INCLUDE_DIR include CACHE PATH "Installation directory for header files")
|
||||
set(INSTALL_BIN_DIR bin CACHE PATH "Installation directory for executables")
|
||||
if(WIN32 AND NOT CYGWIN)
|
||||
set(INSTALL_CMAKE_DIR cmake)
|
||||
else()
|
||||
set(INSTALL_CMAKE_DIR lib/cmake/atdna)
|
||||
endif()
|
||||
|
||||
# Make relative paths absolute (needed later on)
|
||||
foreach(p BIN INCLUDE CMAKE)
|
||||
set(var INSTALL_${p}_DIR)
|
||||
if(NOT IS_ABSOLUTE "${${var}}")
|
||||
set(ABS_${var} "${CMAKE_INSTALL_PREFIX}/${${var}}")
|
||||
else()
|
||||
set(ABS_${var} "${${var}}")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
# Windows resource
|
||||
if(WIN32)
|
||||
configure_file(main.rc.in main.rc @ONLY)
|
||||
set(PLAT_SRCS ${CMAKE_CURRENT_BINARY_DIR}/main.rc)
|
||||
endif()
|
||||
|
||||
# ATDNA target
|
||||
add_executable(atdna main.cpp test.hpp ${PLAT_SRCS})
|
||||
target_link_libraries(atdna ${LLVM_LIBS} ${PLAT_LIBS})
|
||||
target_compile_definitions(atdna PRIVATE
|
||||
INSTALL_PREFIX=${ABS_INSTALL_BIN_DIR}
|
||||
__STDC_LIMIT_MACROS=1
|
||||
__STDC_CONSTANT_MACROS=1
|
||||
ATDNA_ARGV0=${LLVM_ROOT_DIR}/bin/clang-tool)
|
||||
target_include_directories(atdna PRIVATE ${LLVM_INCLUDE_DIRS})
|
||||
target_link_directories(atdna PRIVATE ${LLVM_LIBRARY_DIRS})
|
||||
# Clang 10.0.x headers currently broken with C++20
|
||||
set_property(TARGET atdna PROPERTY CXX_STANDARD 17)
|
||||
if(MSVC)
|
||||
# Allow linking against release-built LLVM libraries
|
||||
target_compile_options(atdna PRIVATE /GR- /D_ITERATOR_DEBUG_LEVEL=0)
|
||||
set_property(TARGET atdna PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreadedDLL")
|
||||
else()
|
||||
target_compile_options(atdna PRIVATE -fno-rtti -Wno-error)
|
||||
endif()
|
||||
|
||||
# Define installs
|
||||
install(TARGETS atdna DESTINATION ${INSTALL_BIN_DIR} EXPORT atdnaTargets COMPONENT atdna)
|
||||
install(DIRECTORY ${CLANG_INCLUDE_DIR}/ DESTINATION ${INSTALL_INCLUDE_DIR}/athena/clang COMPONENT atdna)
|
||||
|
||||
##################
|
||||
# Package Export #
|
||||
##################
|
||||
|
||||
# Add all targets to the build-tree export set
|
||||
export(TARGETS atdna FILE "${CMAKE_CURRENT_BINARY_DIR}/atdnaTargets.cmake")
|
||||
|
||||
# Export the package for use from the build-tree
|
||||
# (this registers the build-tree with a global CMake-registry)
|
||||
export(PACKAGE atdna)
|
||||
|
||||
# Create the atdnaConfig.cmake
|
||||
# ... for the build tree
|
||||
configure_file(atdnaConfig.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/atdnaConfig.cmake" @ONLY)
|
||||
# ... for the install tree
|
||||
configure_file(atdnaConfig.cmake.in "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/atdnaConfig.cmake" @ONLY)
|
||||
# ... for both
|
||||
configure_file(atdnaConfigVersion.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/atdnaConfigVersion.cmake" @ONLY)
|
||||
|
||||
# Install atdnaConfig.cmake
|
||||
install(FILES
|
||||
"${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/atdnaConfig.cmake"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/atdnaConfigVersion.cmake"
|
||||
DESTINATION ${INSTALL_CMAKE_DIR} COMPONENT atdna)
|
||||
|
||||
# Install the export set for use with the install-tree
|
||||
install(EXPORT atdnaTargets DESTINATION ${INSTALL_CMAKE_DIR} COMPONENT atdna)
|
||||
|
||||
#########
|
||||
# CTest #
|
||||
#########
|
||||
|
||||
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
|
||||
enable_testing()
|
||||
add_test(NAME test-dna COMMAND $<TARGET_FILE:atdna> -o test.cpp
|
||||
"-I${ATHENA_INCLUDE_DIR}" ${CMAKE_SOURCE_DIR}/test.hpp)
|
||||
endif()
|
||||
|
||||
endif()
|
||||
|
||||
include(atdnaHelpers.cmake)
|
||||
|
||||
endif()
|
||||
@@ -1,216 +0,0 @@
|
||||
# - Find LLVM headers and libraries.
|
||||
# This module locates LLVM and adapts the llvm-config output for use with
|
||||
# CMake.
|
||||
#
|
||||
# A given list of COMPONENTS is passed to llvm-config.
|
||||
#
|
||||
# The following variables are defined:
|
||||
# LLVM_FOUND - true if LLVM was found
|
||||
# LLVM_CXXFLAGS - C++ compiler flags for files that include LLVM headers.
|
||||
# LLVM_HOST_TARGET - Target triple used to configure LLVM.
|
||||
# LLVM_INCLUDE_DIRS - Directory containing LLVM include files.
|
||||
# LLVM_LDFLAGS - Linker flags to add when linking against LLVM
|
||||
# (includes -LLLVM_LIBRARY_DIRS).
|
||||
# LLVM_LIBRARIES - Full paths to the library files to link against.
|
||||
# LLVM_LIBRARY_DIRS - Directory containing LLVM libraries.
|
||||
# LLVM_ROOT_DIR - The root directory of the LLVM installation.
|
||||
# llvm-config is searched for in ${LLVM_ROOT_DIR}/bin.
|
||||
# LLVM_VERSION_MAJOR - Major version of LLVM.
|
||||
# LLVM_VERSION_MINOR - Minor version of LLVM.
|
||||
# LLVM_VERSION_STRING - Full LLVM version string (e.g. 2.9).
|
||||
#
|
||||
# Note: The variable names were chosen in conformance with the offical CMake
|
||||
# guidelines, see ${CMAKE_ROOT}/Modules/readme.txt.
|
||||
|
||||
# Try suffixed versions to pick up the newest LLVM install available on Debian
|
||||
# derivatives.
|
||||
# We also want an user-specified LLVM_ROOT_DIR to take precedence over the
|
||||
# system default locations such as /usr/local/bin. Executing find_program()
|
||||
# multiples times is the approach recommended in the docs.
|
||||
set(LLVM_ROOT_DIR "" CACHE PATH "Location of LLVM development root")
|
||||
set(LLVM_FIND_COMPONENTS "")
|
||||
if(WIN32)
|
||||
get_filename_component(LLVM_ROOT_DIR [HKEY_LOCAL_MACHINE\\Software\\LLVM\\LLVM] ABSOLUTE)
|
||||
endif()
|
||||
|
||||
set(llvm_config_names llvm-config-3.9 llvm-config39
|
||||
llvm-config-3.8 llvm-config38
|
||||
llvm-config-3.7 llvm-config37
|
||||
llvm-config-3.6 llvm-config36
|
||||
llvm-config-3.5 llvm-config35
|
||||
llvm-config-3.4 llvm-config34
|
||||
llvm-config-3.3 llvm-config33
|
||||
llvm-config-3.2 llvm-config32
|
||||
llvm-config-3.1 llvm-config31 llvm-config)
|
||||
if(APPLE AND CMAKE_SYSTEM_PROCESSOR STREQUAL x86_64)
|
||||
set(LLVM_HOMEBREW_PATH /usr/local/opt/llvm/bin)
|
||||
elseif(APPLE AND CMAKE_SYSTEM_PROCESSOR STREQUAL arm64)
|
||||
set(LLVM_HOMEBREW_PATH /opt/homebrew/opt/llvm/bin)
|
||||
else()
|
||||
set(LLVM_HOMEBREW_PATH "")
|
||||
endif()
|
||||
find_program(LLVM_CONFIG
|
||||
NAMES ${llvm_config_names}
|
||||
PATHS ${LLVM_ROOT_DIR}/bin ${LLVM_HOMEBREW_PATH} NO_DEFAULT_PATH
|
||||
DOC "Path to llvm-config tool.")
|
||||
find_program(LLVM_CONFIG NAMES ${llvm_config_names})
|
||||
|
||||
if ((WIN32 AND NOT(MINGW OR CYGWIN)) OR NOT LLVM_CONFIG)
|
||||
if (WIN32)
|
||||
# A bit of a sanity check:
|
||||
if( NOT EXISTS ${LLVM_ROOT_DIR}/include/llvm )
|
||||
message(FATAL_ERROR "LLVM_ROOT_DIR (${LLVM_ROOT_DIR}) is not a valid LLVM install")
|
||||
endif()
|
||||
# We incorporate the CMake features provided by LLVM:
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}
|
||||
"${LLVM_ROOT_DIR}/share/llvm/cmake"
|
||||
"${LLVM_ROOT_DIR}/lib/cmake/llvm")
|
||||
include(LLVMConfig)
|
||||
# Set properties
|
||||
set(LLVM_HOST_TARGET ${TARGET_TRIPLE})
|
||||
set(LLVM_VERSION_STRING ${LLVM_PACKAGE_VERSION})
|
||||
set(LLVM_CXXFLAGS ${LLVM_DEFINITIONS})
|
||||
set(LLVM_LDFLAGS "")
|
||||
list(REMOVE_ITEM LLVM_FIND_COMPONENTS "all-targets" index)
|
||||
list(APPEND LLVM_FIND_COMPONENTS ${LLVM_TARGETS_TO_BUILD})
|
||||
# Work around LLVM bug 21016
|
||||
list(FIND LLVM_TARGETS_TO_BUILD "X86" TARGET_X86)
|
||||
if(TARGET_X86 GREATER -1)
|
||||
list(APPEND LLVM_FIND_COMPONENTS x86utils)
|
||||
endif()
|
||||
# Similar to the work around above, but for AArch64
|
||||
list(FIND LLVM_TARGETS_TO_BUILD "AArch64" TARGET_AArch64)
|
||||
if(TARGET_AArch64 GREATER -1)
|
||||
list(APPEND LLVM_FIND_COMPONENTS AArch64Utils)
|
||||
endif()
|
||||
list(REMOVE_ITEM LLVM_FIND_COMPONENTS "backend" index)
|
||||
if(${LLVM_VERSION_STRING} MATCHES "^3\\.[0-2][\\.0-9A-Za-z]*")
|
||||
# Versions below 3.3 do not support components objcarcopts, option
|
||||
list(REMOVE_ITEM LLVM_FIND_COMPONENTS "objcarcopts" index)
|
||||
list(REMOVE_ITEM LLVM_FIND_COMPONENTS "option" index)
|
||||
endif()
|
||||
if(${LLVM_VERSION_STRING} MATCHES "^3\\.[0-4][\\.0-9A-Za-z]*")
|
||||
# Versions below 3.5 do not support components lto, profiledata
|
||||
list(REMOVE_ITEM LLVM_FIND_COMPONENTS "lto" index)
|
||||
list(REMOVE_ITEM LLVM_FIND_COMPONENTS "profiledata" index)
|
||||
endif()
|
||||
if(${LLVM_VERSION_STRING} MATCHES "^3\\.[0-6][\\.0-9A-Za-z]*")
|
||||
# Versions below 3.7 do not support components debuginfodwarf
|
||||
# Only debuginfo is available
|
||||
list(REMOVE_ITEM LLVM_FIND_COMPONENTS "debuginfodwarf" index)
|
||||
list(APPEND LLVM_FIND_COMPONENTS "debuginfo")
|
||||
endif()
|
||||
|
||||
if(${LLVM_VERSION_STRING} MATCHES "^3\\.[0-4][\\.0-9A-Za-z]*")
|
||||
llvm_map_components_to_libraries(tmplibs ${LLVM_FIND_COMPONENTS})
|
||||
else()
|
||||
llvm_map_components_to_libnames(tmplibs ${LLVM_FIND_COMPONENTS})
|
||||
endif()
|
||||
if(MSVC)
|
||||
foreach(lib ${tmplibs})
|
||||
list(APPEND LLVM_LIBRARIES "${LLVM_LIBRARY_DIRS}/${CMAKE_STATIC_LIBRARY_PREFIX}${lib}${CMAKE_STATIC_LIBRARY_SUFFIX}")
|
||||
endforeach()
|
||||
else()
|
||||
# Rely on the library search path being set correctly via -L on
|
||||
# MinGW and others, as the library list returned by
|
||||
# llvm_map_components_to_libraries also includes imagehlp and psapi.
|
||||
set(LLVM_LDFLAGS "-L${LLVM_LIBRARY_DIRS}")
|
||||
set(LLVM_LIBRARIES ${tmplibs})
|
||||
endif()
|
||||
|
||||
# When using the CMake LLVM module, LLVM_DEFINITIONS is a list
|
||||
# instead of a string. Later, the list seperators would entirely
|
||||
# disappear, replace them by spaces instead. A better fix would be
|
||||
# to switch to add_definitions() instead of throwing strings around.
|
||||
string(REPLACE ";" " " LLVM_CXXFLAGS "${LLVM_CXXFLAGS}")
|
||||
else()
|
||||
if (NOT FIND_LLVM_QUIETLY)
|
||||
message(WARNING "Could not find llvm-config. Try manually setting LLVM_ROOT_DIR to the prebuilt LLVM prefix to use.")
|
||||
endif()
|
||||
endif()
|
||||
else()
|
||||
macro(llvm_set var flag)
|
||||
if(LLVM_FIND_QUIETLY)
|
||||
set(_quiet_arg ERROR_QUIET)
|
||||
endif()
|
||||
execute_process(
|
||||
COMMAND ${LLVM_CONFIG} --${flag}
|
||||
OUTPUT_VARIABLE LLVM_${var}
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
${_quiet_arg}
|
||||
)
|
||||
if(${ARGV2})
|
||||
file(TO_CMAKE_PATH "${LLVM_${var}}" LLVM_${var})
|
||||
endif()
|
||||
endmacro()
|
||||
macro(llvm_set_libs var flag prefix)
|
||||
if(LLVM_FIND_QUIETLY)
|
||||
set(_quiet_arg ERROR_QUIET)
|
||||
endif()
|
||||
execute_process(
|
||||
COMMAND ${LLVM_CONFIG} --${flag} ${LLVM_FIND_COMPONENTS}
|
||||
OUTPUT_VARIABLE tmplibs
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
${_quiet_arg}
|
||||
)
|
||||
file(TO_CMAKE_PATH "${tmplibs}" tmplibs)
|
||||
string(REGEX REPLACE "([$^.[|*+?()]|])" "\\\\\\1" pattern "${prefix}/")
|
||||
string(REGEX MATCHALL "${pattern}[^ ]+" "LLVM_${var}" "${tmplibs}")
|
||||
endmacro()
|
||||
|
||||
llvm_set(VERSION_STRING version)
|
||||
llvm_set(CXXFLAGS cxxflags)
|
||||
llvm_set(HOST_TARGET host-target)
|
||||
llvm_set(INCLUDE_DIRS includedir true)
|
||||
llvm_set(ROOT_DIR prefix true)
|
||||
|
||||
if(${LLVM_VERSION_STRING} MATCHES "^3\\.[0-2][\\.0-9A-Za-z]*")
|
||||
# Versions below 3.3 do not support components objcarcopts, option
|
||||
list(REMOVE_ITEM LLVM_FIND_COMPONENTS "objcarcopts" index)
|
||||
list(REMOVE_ITEM LLVM_FIND_COMPONENTS "option" index)
|
||||
endif()
|
||||
if(${LLVM_VERSION_STRING} MATCHES "^3\\.[0-4][\\.0-9A-Za-z]*")
|
||||
# Versions below 3.5 do not support components lto, profiledata
|
||||
list(REMOVE_ITEM LLVM_FIND_COMPONENTS "lto" index)
|
||||
list(REMOVE_ITEM LLVM_FIND_COMPONENTS "profiledata" index)
|
||||
endif()
|
||||
if(${LLVM_VERSION_STRING} MATCHES "^3\\.[0-6][\\.0-9A-Za-z]*")
|
||||
# Versions below 3.7 do not support components debuginfodwarf
|
||||
# Only debuginfo is available
|
||||
list(REMOVE_ITEM LLVM_FIND_COMPONENTS "debuginfodwarf" index)
|
||||
list(APPEND LLVM_FIND_COMPONENTS "debuginfo")
|
||||
endif()
|
||||
|
||||
llvm_set(LDFLAGS ldflags)
|
||||
if(NOT ${LLVM_VERSION_STRING} MATCHES "^3\\.[0-4][\\.0-9A-Za-z]*")
|
||||
# In LLVM 3.5+, the system library dependencies (e.g. "-lz") are accessed
|
||||
# using the separate "--system-libs" flag.
|
||||
llvm_set(SYSTEM_LIBS system-libs)
|
||||
string(REPLACE "\n" " " LLVM_LDFLAGS "${LLVM_LDFLAGS} ${LLVM_SYSTEM_LIBS}")
|
||||
endif()
|
||||
llvm_set(LIBRARY_DIRS libdir true)
|
||||
llvm_set_libs(LIBRARIES libfiles "${LLVM_LIBRARY_DIRS}")
|
||||
endif()
|
||||
|
||||
# On CMake builds of LLVM, the output of llvm-config --cxxflags does not
|
||||
# include -fno-rtti, leading to linker errors. Be sure to add it.
|
||||
if(CMAKE_COMPILER_IS_GNUCXX OR (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang"))
|
||||
if(NOT ${LLVM_CXXFLAGS} MATCHES "-fno-rtti")
|
||||
set(LLVM_CXXFLAGS "${LLVM_CXXFLAGS} -fno-rtti")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
string(REGEX REPLACE "([0-9]+).*" "\\1" LLVM_VERSION_MAJOR "${LLVM_VERSION_STRING}" )
|
||||
string(REGEX REPLACE "[0-9]+\\.([0-9]+).*[A-Za-z]*" "\\1" LLVM_VERSION_MINOR "${LLVM_VERSION_STRING}" )
|
||||
|
||||
# Use the default CMake facilities for handling QUIET/REQUIRED.
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
if(${CMAKE_VERSION} VERSION_LESS "2.8.4")
|
||||
# The VERSION_VAR argument is not supported on pre-2.8.4, work around this.
|
||||
set(VERSION_VAR dummy)
|
||||
endif()
|
||||
|
||||
find_package_handle_standard_args(LLVM
|
||||
REQUIRED_VARS LLVM_ROOT_DIR LLVM_HOST_TARGET
|
||||
VERSION_VAR LLVM_VERSION_STRING)
|
||||
@@ -1,3 +0,0 @@
|
||||
# atdna
|
||||
[User Overview](http://libAthena.github.io/doc/atdna.html)
|
||||
[DNA Record Reference](http://libAthena.github.io/doc/atdna-ref.html)
|
||||
@@ -1,84 +0,0 @@
|
||||
# - Config file for the atdna package
|
||||
|
||||
# Compute paths
|
||||
get_filename_component(ATDNA_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
|
||||
|
||||
# Our library dependencies (contains definitions for IMPORTED targets)
|
||||
if(NOT TARGET atdna AND NOT atdna_BINARY_DIR)
|
||||
include("${ATDNA_CMAKE_DIR}/atdnaTargets.cmake")
|
||||
endif()
|
||||
|
||||
# Super handy macro for adding atdna target
|
||||
function(atdna out)
|
||||
# Ninja wants invocations in root binary dir for DEPFILE application
|
||||
file(RELATIVE_PATH out_rel ${CMAKE_BINARY_DIR} "${CMAKE_CURRENT_BINARY_DIR}/${out}")
|
||||
|
||||
# Make input files source-relative
|
||||
set(ins "")
|
||||
set(ins_impdeps "")
|
||||
foreach(arg ${ARGN})
|
||||
list(APPEND ins ${CMAKE_CURRENT_SOURCE_DIR}/${arg})
|
||||
list(APPEND ins_impdeps CXX)
|
||||
list(APPEND ins_impdeps ${CMAKE_CURRENT_SOURCE_DIR}/${arg})
|
||||
endforeach()
|
||||
|
||||
# Get local include directories for atdna
|
||||
get_property(incdirs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES)
|
||||
set(inccli "")
|
||||
foreach(dir ${incdirs})
|
||||
list(APPEND inccli "-I${dir}")
|
||||
endforeach()
|
||||
|
||||
# Get local defines for atdna
|
||||
get_property(cdefs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY COMPILE_DEFINITIONS)
|
||||
set(cdefcli "")
|
||||
foreach(def ${cdefs})
|
||||
list(APPEND cdefcli "-D${def}")
|
||||
endforeach()
|
||||
|
||||
# MS extra
|
||||
unset(extraargs)
|
||||
if(MSVC)
|
||||
list(APPEND extraargs -fms-compatibility -fexceptions)
|
||||
if(MSVC_VERSION EQUAL 1800)
|
||||
list(APPEND extraargs -fms-compatibility-version=18.00)
|
||||
elseif(MSVC_VERSION EQUAL 1900)
|
||||
list(APPEND extraargs -fms-compatibility-version=19.00)
|
||||
elseif(MSVC_VERSION EQUAL 1910)
|
||||
list(APPEND extraargs -fms-compatibility-version=19.10)
|
||||
elseif(MSVC_VERSION EQUAL 1911)
|
||||
list(APPEND extraargs -fms-compatibility-version=19.11)
|
||||
endif()
|
||||
|
||||
# OSX Extra
|
||||
elseif(APPLE)
|
||||
get_filename_component(COMPILER_DIR "${CMAKE_CXX_COMPILER}" DIRECTORY)
|
||||
if (NOT EXISTS "${CMAKE_OSX_SYSROOT}")
|
||||
message(FATAL_ERROR "CMAKE_OSX_SYSROOT not set")
|
||||
endif()
|
||||
list(APPEND extraargs
|
||||
-isysroot ${CMAKE_OSX_SYSROOT}
|
||||
-stdlib++-isystem "${COMPILER_DIR}/../include/c++/v1")
|
||||
endif()
|
||||
|
||||
# Make target
|
||||
if(${CMAKE_GENERATOR} STREQUAL "Ninja")
|
||||
# Use Ninja's DEPFILE parser in cooperation with atdna
|
||||
add_custom_command(OUTPUT ${out} COMMAND $<TARGET_FILE:atdna>
|
||||
ARGS ${extraargs} -o ${out_rel} -MD -MT ${out_rel} -MF ${out_rel}.d ${cdefcli} ${inccli}
|
||||
"-I${ATHENA_INCLUDE_DIR}" ${ins}
|
||||
DEPENDS atdna ${ins} IMPLICIT_DEPENDS ${ins_impdeps}
|
||||
DEPFILE "${CMAKE_CURRENT_BINARY_DIR}/${out}.d"
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||
COMMENT "Generating DNA ${out_rel}")
|
||||
else()
|
||||
# Use CMake's built-in dependency scanner for makefile targets
|
||||
add_custom_command(OUTPUT ${out} COMMAND $<TARGET_FILE:atdna>
|
||||
ARGS ${extraargs} -o ${out_rel} ${cdefcli} ${inccli}
|
||||
"-I${ATHENA_INCLUDE_DIR}" ${ins}
|
||||
DEPENDS atdna ${ins} IMPLICIT_DEPENDS ${ins_impdeps}
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||
COMMENT "Generating DNA ${out_rel}")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
set(PACKAGE_VERSION "@ATHENA_VERSION@")
|
||||
|
||||
# Check whether the requested PACKAGE_FIND_VERSION is compatible
|
||||
if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}")
|
||||
set(PACKAGE_VERSION_COMPATIBLE FALSE)
|
||||
else()
|
||||
set(PACKAGE_VERSION_COMPATIBLE TRUE)
|
||||
if ("${PACKAGE_VERSION}" VERSION_EQUAL "${PACKAGE_FIND_VERSION}")
|
||||
set(PACKAGE_VERSION_EXACT TRUE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@@ -1,152 +0,0 @@
|
||||
#
|
||||
# gather_include_directories recursively builds a list of include directories
|
||||
# across all dependencies.
|
||||
#
|
||||
|
||||
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.20")
|
||||
# Don't transform add_custom_command DEPFILE for Ninja
|
||||
cmake_policy(SET CMP0116 OLD)
|
||||
endif ()
|
||||
|
||||
function(_atdna_gather_include_directories_impl target_name)
|
||||
get_target_property(target_dependencies ${target_name} INTERFACE_LINK_LIBRARIES)
|
||||
foreach(dep ${target_dependencies})
|
||||
if(TARGET ${dep})
|
||||
get_target_property(dep_includes ${dep} INTERFACE_INCLUDE_DIRECTORIES)
|
||||
if(dep_includes)
|
||||
list(APPEND target_includes ${dep_includes})
|
||||
endif()
|
||||
_atdna_gather_include_directories_impl(${dep})
|
||||
endif()
|
||||
endforeach()
|
||||
set(target_includes ${target_includes} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(atdna_gather_include_directories var target_name)
|
||||
unset(target_includes)
|
||||
get_directory_property(dir_includes INCLUDE_DIRECTORIES)
|
||||
if(dir_includes)
|
||||
list(APPEND target_includes ${dir_includes})
|
||||
endif()
|
||||
get_target_property(target_includes1 ${target_name} INCLUDE_DIRECTORIES)
|
||||
if(target_includes1)
|
||||
list(APPEND target_includes ${target_includes1})
|
||||
endif()
|
||||
get_target_property(target_includes2 ${target_name} INTERFACE_INCLUDE_DIRECTORIES)
|
||||
if(target_includes2)
|
||||
list(APPEND target_includes ${target_includes2})
|
||||
endif()
|
||||
_atdna_gather_include_directories_impl(${target_name})
|
||||
list(REMOVE_DUPLICATES target_includes)
|
||||
set(${var} ${target_includes} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(_atdna_gather_compile_definitions_impl target_name)
|
||||
get_target_property(target_dependencies ${target_name} INTERFACE_LINK_LIBRARIES)
|
||||
foreach(dep ${target_dependencies})
|
||||
if(TARGET ${dep})
|
||||
get_target_property(dep_defines ${dep} INTERFACE_COMPILE_DEFINITIONS)
|
||||
if(dep_defines)
|
||||
list(APPEND target_defines ${dep_defines})
|
||||
endif()
|
||||
_atdna_gather_compile_definitions_impl(${dep})
|
||||
endif()
|
||||
endforeach()
|
||||
set(target_defines ${target_defines} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(atdna_gather_compile_definitions var target_name)
|
||||
unset(target_defines)
|
||||
get_directory_property(dir_defines COMPILE_DEFINITIONS)
|
||||
if(dir_defines)
|
||||
list(APPEND target_defines ${dir_defines})
|
||||
endif()
|
||||
get_target_property(target_defines1 ${target_name} COMPILE_DEFINITIONS)
|
||||
if(target_defines1)
|
||||
list(APPEND target_defines ${target_defines1})
|
||||
endif()
|
||||
get_target_property(target_defines2 ${target_name} INTERFACE_COMPILE_DEFINITIONS)
|
||||
if(target_defines2)
|
||||
list(APPEND target_defines ${target_defines2})
|
||||
endif()
|
||||
_atdna_gather_compile_definitions_impl(${target_name})
|
||||
list(REMOVE_DUPLICATES target_defines)
|
||||
set(${var} ${target_defines} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
#######################
|
||||
# In-tree atdna macro #
|
||||
#######################
|
||||
|
||||
# Super handy macro for adding atdna target
|
||||
function(atdna out incdirs cdefs)
|
||||
# Ninja wants invocations in root binary dir for DEPFILE application
|
||||
file(RELATIVE_PATH out_rel ${CMAKE_BINARY_DIR} "${CMAKE_CURRENT_BINARY_DIR}/${out}")
|
||||
|
||||
# Make input files source-relative
|
||||
unset(ins)
|
||||
unset(ins_impdeps)
|
||||
foreach(arg ${ARGN})
|
||||
list(APPEND ins ${CMAKE_CURRENT_SOURCE_DIR}/${arg})
|
||||
list(APPEND ins_impdeps CXX)
|
||||
list(APPEND ins_impdeps ${CMAKE_CURRENT_SOURCE_DIR}/${arg})
|
||||
endforeach()
|
||||
|
||||
# MS extra
|
||||
unset(extraargs)
|
||||
if(MSVC)
|
||||
list(APPEND extraargs -fms-compatibility -fexceptions)
|
||||
if(MSVC_VERSION EQUAL 1800)
|
||||
list(APPEND extraargs -fms-compatibility-version=18.00)
|
||||
elseif(MSVC_VERSION EQUAL 1900)
|
||||
list(APPEND extraargs -fms-compatibility-version=19.00)
|
||||
elseif(MSVC_VERSION EQUAL 1910)
|
||||
list(APPEND extraargs -fms-compatibility-version=19.10)
|
||||
elseif(MSVC_VERSION EQUAL 1911)
|
||||
list(APPEND extraargs -fms-compatibility-version=19.11)
|
||||
endif()
|
||||
|
||||
# OSX Extra
|
||||
elseif(APPLE)
|
||||
get_filename_component(COMPILER_DIR "${CMAKE_CXX_COMPILER}" DIRECTORY)
|
||||
if (NOT EXISTS "${CMAKE_OSX_SYSROOT}")
|
||||
message(FATAL_ERROR "CMAKE_OSX_SYSROOT not set")
|
||||
endif()
|
||||
list(APPEND extraargs
|
||||
-isysroot ${CMAKE_OSX_SYSROOT}
|
||||
-stdlib++-isystem "${COMPILER_DIR}/../include/c++/v1")
|
||||
endif()
|
||||
|
||||
# Make target
|
||||
if(${CMAKE_GENERATOR} STREQUAL "Ninja")
|
||||
# Use Ninja's DEPFILE parser in cooperation with atdna
|
||||
add_custom_command(OUTPUT ${out} COMMAND $<TARGET_FILE:atdna>
|
||||
ARGS ${extraargs} -o ${out_rel} -MD -MT ${out_rel} -MF ${out_rel}.d
|
||||
"$<$<BOOL:${incdirs}>:-I$<JOIN:${incdirs},;-I>>"
|
||||
"$<$<BOOL:${cdefs}>:-D$<JOIN:${cdefs},;-D>>"
|
||||
"-I${athena_SOURCE_DIR}/include" ${ins}
|
||||
DEPENDS atdna ${ins} IMPLICIT_DEPENDS ${ins_impdeps}
|
||||
DEPFILE "${CMAKE_CURRENT_BINARY_DIR}/${out}.d"
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||
COMMENT "Generating DNA ${out_rel}"
|
||||
COMMAND_EXPAND_LISTS)
|
||||
else()
|
||||
# Use CMake's built-in dependency scanner for makefile targets
|
||||
add_custom_command(OUTPUT ${out} COMMAND $<TARGET_FILE:atdna>
|
||||
ARGS ${extraargs} -o ${out_rel}
|
||||
"$<$<BOOL:${incdirs}>:-I$<JOIN:${incdirs},;-I>>"
|
||||
"$<$<BOOL:${cdefs}>:-D$<JOIN:${cdefs},;-D>>"
|
||||
"-I${athena_SOURCE_DIR}/include" ${ins}
|
||||
DEPENDS atdna ${ins} IMPLICIT_DEPENDS ${ins_impdeps}
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||
COMMENT "Generating DNA ${out_rel}"
|
||||
COMMAND_EXPAND_LISTS)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
function(target_atdna target out)
|
||||
atdna_gather_include_directories(include_list ${target})
|
||||
atdna_gather_compile_definitions(define_list ${target})
|
||||
atdna(${out} "${include_list}" "${define_list}" ${ARGN})
|
||||
target_sources(${target} PRIVATE ${out} ${ARGN})
|
||||
endfunction()
|
||||
1273
atdna/main.cpp
1273
atdna/main.cpp
File diff suppressed because it is too large
Load Diff
@@ -1,32 +0,0 @@
|
||||
#include "winver.h"
|
||||
|
||||
IDI_ICON1 ICON DISCARDABLE "@ATHENA_ICO@"
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION @ATHENA_MAJOR_VERSION@,@ATHENA_MINOR_VERSION@,@ATHENA_PATCH_VERSION@,0
|
||||
PRODUCTVERSION @ATHENA_MAJOR_VERSION@,@ATHENA_MINOR_VERSION@,@ATHENA_PATCH_VERSION@,0
|
||||
FILEFLAGS 0x0L
|
||||
FILEFLAGSMASK 0x3fL
|
||||
FILEOS 0x00040004L
|
||||
FILETYPE 0x1L
|
||||
FILESUBTYPE 0x0L
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "000004b0"
|
||||
BEGIN
|
||||
VALUE "CompanyName", "Jackoalan / Antidote"
|
||||
VALUE "FileDescription", "ATDNA"
|
||||
VALUE "FileVersion", "@ATHENA_MAJOR_VERSION@.@ATHENA_MINOR_VERSION@.@ATHENA_PATCH_VERSION@"
|
||||
VALUE "LegalCopyright", "Copyright (C) 2016 Jackoalan / Antidote"
|
||||
VALUE "InternalName", "atdna"
|
||||
VALUE "OriginalFilename", "atdna.exe"
|
||||
VALUE "ProductName", "ATDNA"
|
||||
VALUE "ProductVersion", "@ATHENA_MAJOR_VERSION@.@ATHENA_MINOR_VERSION@.@ATHENA_PATCH_VERSION@"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x0, 1200
|
||||
END
|
||||
END
|
||||
@@ -1,28 +0,0 @@
|
||||
#include "test.hpp"
|
||||
|
||||
#include <athena/MemoryWriter.hpp>
|
||||
#include <fmt/format.h>
|
||||
|
||||
#define EXPECTED_BYTES 281
|
||||
|
||||
int main(int argc, const char** argv) {
|
||||
TESTFile<atUint32, 2> file = {};
|
||||
file.arrCount[0] = 2;
|
||||
file.array.push_back(42);
|
||||
file.array.push_back(64);
|
||||
size_t binSize = 0;
|
||||
file.binarySize(binSize);
|
||||
athena::io::MemoryCopyWriter w(nullptr, binSize);
|
||||
atInt64 pos = w.position();
|
||||
file.write(w);
|
||||
|
||||
const bool pass = !w.hasError() && w.position() - pos == binSize && binSize == EXPECTED_BYTES;
|
||||
if (pass) {
|
||||
fmt::print(FMT_STRING("[PASS] {} bytes written\n"), size_t(w.position() - pos));
|
||||
} else {
|
||||
fmt::print(FMT_STRING("[FAIL] {} bytes written; {} bytes sized; {} bytes expected\n"), size_t(w.position() - pos), binSize,
|
||||
EXPECTED_BYTES);
|
||||
}
|
||||
|
||||
return pass ? 0 : 1;
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
#include <athena/DNAYaml.hpp>
|
||||
|
||||
using namespace athena;
|
||||
typedef io::DNA<Endian::Big> BigDNA;
|
||||
|
||||
enum ETest : atUint8 { ZERO, ONE, TWO, THREE };
|
||||
|
||||
template <ETest EVal>
|
||||
struct AT_SPECIALIZE_PARMS(ETest::ZERO, ETest::ONE, ETest::TWO, ETest::THREE) TESTSubFile : public BigDNA {
|
||||
AT_DECL_DNA
|
||||
Value<ETest> varE = EVal;
|
||||
Value<atUint32> sub1;
|
||||
Value<atUint32> sub2;
|
||||
};
|
||||
|
||||
struct TESTSubClassFile : public TESTSubFile<ETest::ONE> {
|
||||
AT_DECL_DNA
|
||||
Value<atUint32> sub3;
|
||||
Value<atUint16> sub4;
|
||||
};
|
||||
|
||||
struct TESTSubSubClassFile : public TESTSubClassFile {
|
||||
AT_DECL_DNA
|
||||
Value<atUint32> sub5;
|
||||
Value<atUint32> sub6;
|
||||
};
|
||||
|
||||
template <class Var32Tp, int Var32Val>
|
||||
struct AT_SPECIALIZE_PARMS(atUint16, 42, atUint32, 87, atUint32, 2) TESTFile : public BigDNA {
|
||||
AT_DECL_DNA
|
||||
Value<bool> varBool;
|
||||
AT_OVERRIDE_RCRC32(12345678) Value<Var32Tp> x4_var32 = Var32Val;
|
||||
AT_OVERRIDE_RCRC32(deadbabe) Value<atUint16> x8_var16;
|
||||
Value<atVec3f> vec3;
|
||||
Value<atVec4f> vec4;
|
||||
|
||||
struct TESTNestedSubFile : public BigDNA {
|
||||
AT_DECL_DNA
|
||||
Value<atUint32> nestSub1;
|
||||
Value<atUint32> nestSub2;
|
||||
} nestedSubFile;
|
||||
|
||||
using TESTSubFileUsing = TESTSubFile<ETest::TWO>;
|
||||
TESTSubFileUsing subFile;
|
||||
|
||||
Align<4> align;
|
||||
|
||||
template <class NestedTp, int NestedVal>
|
||||
struct AT_SPECIALIZE_PARMS(atInt32, 36, atInt64, 96) TESTTemplateSubFile : public BigDNA {
|
||||
AT_DECL_DNA
|
||||
Value<NestedTp> explSub1 = NestedVal;
|
||||
Value<Var32Tp> explSub2 = Var32Val;
|
||||
};
|
||||
Value<TESTTemplateSubFile<atInt32, 36>> nestedTemplate1;
|
||||
Value<TESTTemplateSubFile<atInt64, 96>> nestedTemplate2;
|
||||
|
||||
Value<atUint32, Endian::Little> arrCount[2];
|
||||
Vector<atUint32, AT_DNA_COUNT(arrCount[0])> array;
|
||||
|
||||
Value<atUint32> arrAltCount;
|
||||
Vector<atUint32, AT_DNA_COUNT(arrAltCount)> arrayAlt;
|
||||
|
||||
Seek<21, SeekOrigin::Current> seek;
|
||||
|
||||
Value<atUint32> arrCount2;
|
||||
Vector<TESTSubFile<ETest::ZERO>, AT_DNA_COUNT(arrCount[1] + arrCount2)> array2;
|
||||
|
||||
Value<atUint32> bufSz;
|
||||
Buffer<AT_DNA_COUNT(bufSz)> buf;
|
||||
|
||||
String<32> str;
|
||||
WString<64> wstr;
|
||||
};
|
||||
11
extern/CMakeLists.txt
vendored
11
extern/CMakeLists.txt
vendored
@@ -1,15 +1,8 @@
|
||||
if (EXISTS ${CMAKE_SOURCE_DIR}/extern/lzokay)
|
||||
add_subdirectory(lzokay)
|
||||
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
target_compile_options(lzokay PRIVATE -Wno-maybe-uninitialized)
|
||||
endif ()
|
||||
endif ()
|
||||
add_subdirectory(zlib)
|
||||
add_subdirectory(yaml)
|
||||
if(NOT TARGET fmt)
|
||||
add_subdirectory(fmt)
|
||||
target_compile_definitions(fmt PUBLIC
|
||||
FMT_STRING_ALIAS=1
|
||||
FMT_ARM_ABI_COMPATIBILITY=1
|
||||
FMT_EXCEPTIONS=0)
|
||||
target_compile_definitions(fmt INTERFACE
|
||||
FMT_ENFORCE_COMPILE_STRING=1)
|
||||
endif()
|
||||
1
extern/fmt
vendored
1
extern/fmt
vendored
Submodule extern/fmt deleted from 95da484727
2
extern/lzokay
vendored
2
extern/lzokay
vendored
Submodule extern/lzokay updated: 546a969527...db2df1fcbe
2
extern/yaml/src/yaml_private.h
vendored
2
extern/yaml/src/yaml_private.h
vendored
@@ -1,7 +1,7 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <yaml.h>
|
||||
#include <athena/yaml.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <limits.h>
|
||||
|
||||
48
extern/zlib/CMakeLists.txt
vendored
48
extern/zlib/CMakeLists.txt
vendored
@@ -1,7 +1,15 @@
|
||||
if(NOT WIN32 AND NOT NX) # remove when specter/freetype is gone
|
||||
find_library(ZLIB_LIB NAMES zlib z)
|
||||
if (APPLE)
|
||||
# always use toolchain zlib
|
||||
set(ZLIB_REQUIRED REQUIRED)
|
||||
endif ()
|
||||
if(NOT ZLIB_LIB)
|
||||
find_package(ZLIB ${ZLIB_REQUIRED})
|
||||
if (ZLIB_FOUND)
|
||||
add_library(z INTERFACE)
|
||||
target_link_libraries(z INTERFACE ${ZLIB_LIBRARIES})
|
||||
target_include_directories(z INTERFACE ${ZLIB_INCLUDE_DIRS})
|
||||
set(ZLIB_LIBRARIES z CACHE STRING "zlib libraries" FORCE)
|
||||
set(ATHENA_ZLIB NO CACHE BOOL "Using built-in zlib" FORCE)
|
||||
else ()
|
||||
message(STATUS "Using Athena's built-in zlib")
|
||||
add_library(z
|
||||
adler32.c
|
||||
@@ -15,26 +23,26 @@ add_library(z
|
||||
trees.c
|
||||
uncompr.c
|
||||
zutil.c
|
||||
crc32.h
|
||||
deflate.h
|
||||
gzguts.h
|
||||
inffast.h
|
||||
inffixed.h
|
||||
inflate.h
|
||||
inftrees.h
|
||||
trees.h
|
||||
zconf.h
|
||||
zlib.h
|
||||
zutil.h)
|
||||
include/crc32.h
|
||||
include/deflate.h
|
||||
include/gzguts.h
|
||||
include/inffast.h
|
||||
include/inffixed.h
|
||||
include/inflate.h
|
||||
include/inftrees.h
|
||||
include/trees.h
|
||||
include/zconf.h
|
||||
include/zlib.h
|
||||
include/zutil.h)
|
||||
if (WIN32 AND NOT UNIX)
|
||||
install(FILES zconf.h zlib.h DESTINATION include COMPONENT zlib)
|
||||
install(FILES include/zconf.h include/zlib.h DESTINATION include COMPONENT zlib)
|
||||
install(TARGETS z DESTINATION lib COMPONENT zlib)
|
||||
else ()
|
||||
target_compile_options(z PRIVATE -Wno-implicit-fallthrough)
|
||||
endif ()
|
||||
set(ZLIB_LIBRARIES z CACHE PATH "Zlib libraries" FORCE)
|
||||
set(ZLIB_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR} CACHE PATH "Zlib include path" FORCE)
|
||||
else()
|
||||
set(ZLIB_LIBRARIES ${ZLIB_LIB} CACHE PATH "Zlib libraries" FORCE)
|
||||
find_path(ZLIB_INCLUDE_DIR zlib.h)
|
||||
target_include_directories(z PUBLIC
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||
$<INSTALL_INTERFACE:include>)
|
||||
set(ZLIB_LIBRARIES z CACHE STRING "zlib libraries" FORCE)
|
||||
set(ATHENA_ZLIB YES CACHE BOOL "Using built-in zlib" FORCE)
|
||||
endif ()
|
||||
|
||||
@@ -4,31 +4,31 @@
|
||||
|
||||
class LZBase {
|
||||
public:
|
||||
explicit LZBase(atInt32 minimumOffset = 1, atInt32 slidingWindow = 4096, atInt32 minimumMatch = 3,
|
||||
atInt32 blockSize = 8);
|
||||
explicit LZBase(int32_t minimumOffset = 1, int32_t slidingWindow = 4096, int32_t minimumMatch = 3,
|
||||
int32_t blockSize = 8);
|
||||
virtual ~LZBase();
|
||||
|
||||
virtual atUint32 compress(const atUint8* src, atUint8** dest, atUint32 srcLength) = 0;
|
||||
virtual atUint32 decompress(const atUint8* src, atUint8** dest, atUint32 srcLength) = 0;
|
||||
virtual uint32_t compress(const uint8_t* src, uint8_t** dest, uint32_t srcLength) = 0;
|
||||
virtual uint32_t decompress(const uint8_t* src, uint8_t** dest, uint32_t srcLength) = 0;
|
||||
|
||||
void setSlidingWindow(atInt32 SlidingWindow);
|
||||
atInt32 slidingWindow() const;
|
||||
void setReadAheadBuffer(atInt32 ReadAheadBuffer);
|
||||
atInt32 readAheadBuffer() const;
|
||||
void setMinMatch(atInt32 minimumMatch);
|
||||
atInt32 minMatch() const;
|
||||
void setBlockSize(atInt32 BlockSize);
|
||||
atInt32 blockSize() const;
|
||||
void setMinimumOffset(atUint32 minimumOffset);
|
||||
atUint32 minimumOffset() const;
|
||||
void setSlidingWindow(int32_t SlidingWindow);
|
||||
int32_t slidingWindow() const;
|
||||
void setReadAheadBuffer(int32_t ReadAheadBuffer);
|
||||
int32_t readAheadBuffer() const;
|
||||
void setMinMatch(int32_t minimumMatch);
|
||||
int32_t minMatch() const;
|
||||
void setBlockSize(int32_t BlockSize);
|
||||
int32_t blockSize() const;
|
||||
void setMinimumOffset(uint32_t minimumOffset);
|
||||
uint32_t minimumOffset() const;
|
||||
|
||||
protected:
|
||||
LZLengthOffset search(const atUint8* posPtr, const atUint8* dataBegin, const atUint8* dataEnd) const;
|
||||
LZLengthOffset search(const uint8_t* posPtr, const uint8_t* dataBegin, const uint8_t* dataEnd) const;
|
||||
|
||||
atInt32 m_slidingWindow;
|
||||
atInt32 m_readAheadBuffer;
|
||||
atInt32 m_minMatch; // Minimum number of bytes that have to matched to go through with compression
|
||||
atInt32 m_blockSize;
|
||||
atUint32 m_minOffset;
|
||||
int32_t m_slidingWindow;
|
||||
int32_t m_readAheadBuffer;
|
||||
int32_t m_minMatch; // Minimum number of bytes that have to matched to go through with compression
|
||||
int32_t m_blockSize;
|
||||
uint32_t m_minOffset;
|
||||
LZLookupTable m_lookupTable;
|
||||
};
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
#include <athena/Types.hpp>
|
||||
|
||||
struct LZLengthOffset {
|
||||
atUint32 length; // The number of bytes compressed
|
||||
atUint16 offset; // How far back in sliding window where bytes that match the lookAheadBuffer is located
|
||||
uint32_t length; // The number of bytes compressed
|
||||
uint16_t offset; // How far back in sliding window where bytes that match the lookAheadBuffer is located
|
||||
bool operator==(const LZLengthOffset& lo_pair) const { return length == lo_pair.length && offset == lo_pair.offset; }
|
||||
bool operator!=(const LZLengthOffset& lo_pair) const { return !operator==(lo_pair); }
|
||||
};
|
||||
@@ -15,16 +15,16 @@ struct LZLengthOffset {
|
||||
class LZLookupTable {
|
||||
public:
|
||||
LZLookupTable();
|
||||
explicit LZLookupTable(atInt32 minimumMatch, atInt32 slidingWindow = 4096, atInt32 lookAheadWindow = 18);
|
||||
explicit LZLookupTable(int32_t minimumMatch, int32_t slidingWindow = 4096, int32_t lookAheadWindow = 18);
|
||||
~LZLookupTable();
|
||||
LZLengthOffset search(const atUint8* curPos, const atUint8* dataBegin, const atUint8* dataEnd);
|
||||
void setLookAheadWindow(atInt32 lookAheadWindow);
|
||||
LZLengthOffset search(const uint8_t* curPos, const uint8_t* dataBegin, const uint8_t* dataEnd);
|
||||
void setLookAheadWindow(int32_t lookAheadWindow);
|
||||
|
||||
private:
|
||||
using LookupTable = std::multimap<std::vector<uint8_t>, int32_t>;
|
||||
LookupTable table;
|
||||
atInt32 m_minimumMatch = 3;
|
||||
atInt32 m_slidingWindow = 4096;
|
||||
atInt32 m_lookAheadWindow = 18;
|
||||
int32_t m_minimumMatch = 3;
|
||||
int32_t m_slidingWindow = 4096;
|
||||
int32_t m_lookAheadWindow = 18;
|
||||
std::vector<uint8_t> m_buffer;
|
||||
};
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
class LZType10 : public LZBase {
|
||||
public:
|
||||
explicit LZType10(atInt32 minimumOffset = 1, atInt32 SlidingWindow = 4096, atInt32 MinimumMatch = 3,
|
||||
atInt32 BlockSize = 8);
|
||||
atUint32 compress(const atUint8* src, atUint8** dstBuf, atUint32 srcLength) override;
|
||||
atUint32 decompress(const atUint8* src, atUint8** dst, atUint32 srcLen) override;
|
||||
explicit LZType10(int32_t minimumOffset = 1, int32_t SlidingWindow = 4096, int32_t MinimumMatch = 3,
|
||||
int32_t BlockSize = 8);
|
||||
uint32_t compress(const uint8_t* src, uint8_t** dstBuf, uint32_t srcLength) override;
|
||||
uint32_t decompress(const uint8_t* src, uint8_t** dst, uint32_t srcLen) override;
|
||||
};
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
class LZType11 : public LZBase {
|
||||
public:
|
||||
explicit LZType11(atInt32 MinimumOffset = 1, atInt32 SlidingWindow = 4096, atInt32 MinimumMatch = 3,
|
||||
atInt32 BlockSize = 8);
|
||||
atUint32 compress(const atUint8* src, atUint8** dst, atUint32 srcLength) override;
|
||||
atUint32 decompress(const atUint8* src, atUint8** dst, atUint32 srcLength) override;
|
||||
explicit LZType11(int32_t MinimumOffset = 1, int32_t SlidingWindow = 4096, int32_t MinimumMatch = 3,
|
||||
int32_t BlockSize = 8);
|
||||
uint32_t compress(const uint8_t* src, uint8_t** dst, uint32_t srcLength) override;
|
||||
uint32_t decompress(const uint8_t* src, uint8_t** dst, uint32_t srcLength) override;
|
||||
};
|
||||
|
||||
@@ -40,7 +40,7 @@ public:
|
||||
* \param val The new quest to assign to the given index
|
||||
* \throw InvalidOperationException on index out of range
|
||||
*/
|
||||
void setQuest(atUint32 id, ALTTPQuest* val);
|
||||
void setQuest(uint32_t id, ALTTPQuest* val);
|
||||
/*! \brief Returns the primary quest list
|
||||
*
|
||||
* \return The primary quest list
|
||||
@@ -54,13 +54,13 @@ public:
|
||||
* \return ALTTPQuest*
|
||||
* \throw InvalidOperationException on index out of range
|
||||
*/
|
||||
ALTTPQuest* quest(atUint32 id) const;
|
||||
ALTTPQuest* quest(uint32_t id) const;
|
||||
|
||||
/*! \brief Returns the number of primary quests
|
||||
*
|
||||
* \return The number of quests
|
||||
*/
|
||||
atUint32 questCount() const;
|
||||
uint32_t questCount() const;
|
||||
|
||||
private:
|
||||
std::vector<ALTTPQuest*> m_quests;
|
||||
|
||||
@@ -23,7 +23,7 @@ public:
|
||||
* \param data The existing buffer
|
||||
* \param length The length of the existing buffer
|
||||
*/
|
||||
ALTTPFileReader(atUint8*, atUint64);
|
||||
ALTTPFileReader(uint8_t*, uint64_t);
|
||||
|
||||
/*! \brief This constructor creates an instance from a file on disk.
|
||||
*
|
||||
|
||||
@@ -22,7 +22,7 @@ public:
|
||||
* \param data The existing buffer
|
||||
* \param length The length of the existing buffer
|
||||
*/
|
||||
ALTTPFileWriter(atUint8*, atUint64);
|
||||
ALTTPFileWriter(uint8_t*, uint64_t);
|
||||
|
||||
/*! \brief This constructor creates an instance from a file on disk.
|
||||
*
|
||||
@@ -40,7 +40,7 @@ private:
|
||||
void writeRoomFlags(ALTTPRoomFlags*);
|
||||
void writeOverworldEvent(ALTTPOverworldEvent*);
|
||||
void writeDungeonItems(ALTTPDungeonItemFlags);
|
||||
atUint16 calculateChecksum(atUint32 game);
|
||||
uint16_t calculateChecksum(uint32_t game);
|
||||
};
|
||||
|
||||
} // namespace io
|
||||
|
||||
@@ -33,7 +33,7 @@ public:
|
||||
* \param rf
|
||||
* \param id
|
||||
*/
|
||||
void setRoomFlags(ALTTPRoomFlags* rf, atUint32 id);
|
||||
void setRoomFlags(ALTTPRoomFlags* rf, uint32_t id);
|
||||
|
||||
/*!
|
||||
* \brief roomFlags
|
||||
@@ -46,7 +46,7 @@ public:
|
||||
* \param id
|
||||
* \return
|
||||
*/
|
||||
ALTTPRoomFlags* roomFlags(atUint32 id);
|
||||
ALTTPRoomFlags* roomFlags(uint32_t id);
|
||||
|
||||
/*!
|
||||
* \brief setOverworldEvents
|
||||
@@ -59,7 +59,7 @@ public:
|
||||
* \param ow
|
||||
* \param id
|
||||
*/
|
||||
void setOverworldEvents(ALTTPOverworldEvent* ow, atUint32 id);
|
||||
void setOverworldEvents(ALTTPOverworldEvent* ow, uint32_t id);
|
||||
|
||||
/*!
|
||||
* \brief overworldEvents
|
||||
@@ -72,7 +72,7 @@ public:
|
||||
* \param id
|
||||
* \return
|
||||
*/
|
||||
ALTTPOverworldEvent* overworldEvent(atUint32 id) const;
|
||||
ALTTPOverworldEvent* overworldEvent(uint32_t id) const;
|
||||
|
||||
/*!
|
||||
* \brief setInventory
|
||||
@@ -90,25 +90,25 @@ public:
|
||||
* \brief setRupeeMax
|
||||
* \param val
|
||||
*/
|
||||
void setRupeeMax(atUint16 val);
|
||||
void setRupeeMax(uint16_t val);
|
||||
|
||||
/*!
|
||||
* \brief rupeeMax
|
||||
* \return
|
||||
*/
|
||||
atUint16 rupeeMax() const;
|
||||
uint16_t rupeeMax() const;
|
||||
|
||||
/*!
|
||||
* \brief setRupeeCurrent
|
||||
* \param val
|
||||
*/
|
||||
void setRupeeCurrent(atUint16 val);
|
||||
void setRupeeCurrent(uint16_t val);
|
||||
|
||||
/*!
|
||||
* \brief rupeeCurrent
|
||||
* \return
|
||||
*/
|
||||
atUint16 rupeeCurrent() const;
|
||||
uint16_t rupeeCurrent() const;
|
||||
|
||||
/*!
|
||||
* \brief setCompasses
|
||||
@@ -150,109 +150,109 @@ public:
|
||||
* \brief setWishingPond
|
||||
* \param val
|
||||
*/
|
||||
void setWishingPond(atUint16 val);
|
||||
void setWishingPond(uint16_t val);
|
||||
|
||||
/*!
|
||||
* \brief wishingPond
|
||||
* \return
|
||||
*/
|
||||
atUint16 wishingPond() const;
|
||||
uint16_t wishingPond() const;
|
||||
|
||||
/*!
|
||||
* \brief setHealthMax
|
||||
* \param val
|
||||
*/
|
||||
void setHealthMax(atUint8 val);
|
||||
void setHealthMax(uint8_t val);
|
||||
|
||||
/*!
|
||||
* \brief healthMax
|
||||
* \return
|
||||
*/
|
||||
atUint8 healthMax() const;
|
||||
uint8_t healthMax() const;
|
||||
|
||||
/*!
|
||||
* \brief setHealth
|
||||
* \param val
|
||||
*/
|
||||
void setHealth(atUint8 val);
|
||||
void setHealth(uint8_t val);
|
||||
|
||||
/*!
|
||||
* \brief health
|
||||
* \return
|
||||
*/
|
||||
atUint8 health() const;
|
||||
uint8_t health() const;
|
||||
|
||||
/*!
|
||||
* \brief setMagicPower
|
||||
* \param val
|
||||
*/
|
||||
void setMagicPower(atUint8 val);
|
||||
void setMagicPower(uint8_t val);
|
||||
|
||||
/*!
|
||||
* \brief magicPower
|
||||
* \return
|
||||
*/
|
||||
atUint8 magicPower() const;
|
||||
uint8_t magicPower() const;
|
||||
|
||||
/*!
|
||||
* \brief setKeys
|
||||
* \param val
|
||||
*/
|
||||
void setKeys(atUint8 val);
|
||||
void setKeys(uint8_t val);
|
||||
|
||||
/*!
|
||||
* \brief keys
|
||||
* \return
|
||||
*/
|
||||
atUint8 keys() const;
|
||||
uint8_t keys() const;
|
||||
|
||||
/*!
|
||||
* \brief setBombUpgrades
|
||||
* \param val
|
||||
*/
|
||||
void setBombUpgrades(atUint8 val);
|
||||
void setBombUpgrades(uint8_t val);
|
||||
|
||||
/*!
|
||||
* \brief bombUpgrades
|
||||
* \return
|
||||
*/
|
||||
atUint8 bombUpgrades() const;
|
||||
uint8_t bombUpgrades() const;
|
||||
|
||||
/*!
|
||||
* \brief setArrowUpgrades
|
||||
* \param val
|
||||
*/
|
||||
void setArrowUpgrades(atUint8 val);
|
||||
void setArrowUpgrades(uint8_t val);
|
||||
|
||||
/*!
|
||||
* \brief arrowUpgrades
|
||||
* \return
|
||||
*/
|
||||
atUint8 arrowUpgrades() const;
|
||||
uint8_t arrowUpgrades() const;
|
||||
|
||||
/*!
|
||||
* \brief setHealthFiller
|
||||
* \param val
|
||||
*/
|
||||
void setHealthFiller(atUint8 val);
|
||||
void setHealthFiller(uint8_t val);
|
||||
|
||||
/*!
|
||||
* \brief healthFiller
|
||||
* \return
|
||||
*/
|
||||
atUint8 healthFiller() const;
|
||||
uint8_t healthFiller() const;
|
||||
|
||||
/*!
|
||||
* \brief setMagicFiller
|
||||
* \param val
|
||||
*/
|
||||
void setMagicFiller(atUint8 val);
|
||||
void setMagicFiller(uint8_t val);
|
||||
|
||||
/*!
|
||||
* \brief magicFiller
|
||||
* \return
|
||||
*/
|
||||
atUint8 magicFiller() const;
|
||||
uint8_t magicFiller() const;
|
||||
|
||||
/*!
|
||||
* \brief setPendants
|
||||
@@ -270,37 +270,37 @@ public:
|
||||
* \brief setBombFiller
|
||||
* \param val
|
||||
*/
|
||||
void setBombFiller(atUint8 val);
|
||||
void setBombFiller(uint8_t val);
|
||||
|
||||
/*!
|
||||
* \brief bombFiller
|
||||
* \return
|
||||
*/
|
||||
atUint8 bombFiller() const;
|
||||
uint8_t bombFiller() const;
|
||||
|
||||
/*!
|
||||
* \brief setArrowFiller
|
||||
* \param val
|
||||
*/
|
||||
void setArrowFiller(atUint8 val);
|
||||
void setArrowFiller(uint8_t val);
|
||||
|
||||
/*!
|
||||
* \brief arrowFiller
|
||||
* \return
|
||||
*/
|
||||
atUint8 arrowFiller() const;
|
||||
uint8_t arrowFiller() const;
|
||||
|
||||
/*!
|
||||
* \brief setArrows
|
||||
* \param val
|
||||
*/
|
||||
void setArrows(atUint8 val);
|
||||
void setArrows(uint8_t val);
|
||||
|
||||
/*!
|
||||
* \brief arrows
|
||||
* \return
|
||||
*/
|
||||
atUint8 arrows() const;
|
||||
uint8_t arrows() const;
|
||||
|
||||
/*!
|
||||
* \brief setAbilityFlags
|
||||
@@ -342,27 +342,27 @@ public:
|
||||
* \brief setDungeonKeys
|
||||
* \param val
|
||||
*/
|
||||
void setDungeonKeys(std::vector<atUint8> val);
|
||||
void setDungeonKeys(std::vector<uint8_t> val);
|
||||
|
||||
/*!
|
||||
* \brief setDungeonKeys
|
||||
* \param id
|
||||
* \param val
|
||||
*/
|
||||
void setDungeonKeys(atUint32 id, atUint8 val);
|
||||
void setDungeonKeys(uint32_t id, uint8_t val);
|
||||
|
||||
/*!
|
||||
* \brief dungeonKeys
|
||||
* \param id
|
||||
* \return
|
||||
*/
|
||||
atUint8 dungeonKeys(atUint32 id) const;
|
||||
uint8_t dungeonKeys(uint32_t id) const;
|
||||
|
||||
/*!
|
||||
* \brief dungeonCount
|
||||
* \return
|
||||
*/
|
||||
atUint32 dungeonCount() const;
|
||||
uint32_t dungeonCount() const;
|
||||
|
||||
/*!
|
||||
* \brief setProgressIndicator
|
||||
@@ -452,71 +452,71 @@ public:
|
||||
* \brief setOldManFlags
|
||||
* \param flags
|
||||
*/
|
||||
void setOldManFlags(std::vector<atUint8> flags);
|
||||
void setOldManFlags(std::vector<uint8_t> flags);
|
||||
|
||||
/*!
|
||||
* \brief setOldManFlag
|
||||
* \param id
|
||||
* \param val
|
||||
*/
|
||||
void setOldManFlag(atUint32 id, atUint8 val);
|
||||
void setOldManFlag(uint32_t id, uint8_t val);
|
||||
|
||||
/*!
|
||||
* \brief oldManFlag
|
||||
* \param id
|
||||
* \return
|
||||
*/
|
||||
atUint8 oldManFlag(atUint32 id);
|
||||
uint8_t oldManFlag(uint32_t id);
|
||||
|
||||
/*!
|
||||
* \brief oldManFlagCount
|
||||
* \return
|
||||
*/
|
||||
atUint32 oldManFlagCount() const;
|
||||
uint32_t oldManFlagCount() const;
|
||||
|
||||
/*!
|
||||
* \brief setBombFlag
|
||||
* \param flag
|
||||
*/
|
||||
void setBombFlag(atUint8 flag);
|
||||
void setBombFlag(uint8_t flag);
|
||||
|
||||
/*!
|
||||
* \brief bombFlag
|
||||
* \return
|
||||
*/
|
||||
atUint8 bombFlag() const;
|
||||
uint8_t bombFlag() const;
|
||||
|
||||
/*!
|
||||
* \brief setUnknown1
|
||||
* \param flags
|
||||
*/
|
||||
void setUnknown1(std::vector<atUint8> flags);
|
||||
void setUnknown1(std::vector<uint8_t> flags);
|
||||
|
||||
/*!
|
||||
* \brief setUnknown1
|
||||
* \param id
|
||||
* \param val
|
||||
*/
|
||||
void setUnknown1(atUint32 id, atUint8 val);
|
||||
void setUnknown1(uint32_t id, uint8_t val);
|
||||
|
||||
/*!
|
||||
* \brief unknown1
|
||||
* \param id
|
||||
* \return
|
||||
*/
|
||||
atUint8 unknown1(atUint32 id);
|
||||
uint8_t unknown1(uint32_t id);
|
||||
|
||||
/*!
|
||||
* \brief unknown1Count
|
||||
* \return
|
||||
*/
|
||||
atUint32 unknown1Count() const;
|
||||
uint32_t unknown1Count() const;
|
||||
|
||||
/*!
|
||||
* \brief setPlayerName
|
||||
* \param playerName
|
||||
*/
|
||||
void setPlayerName(std::vector<atUint16> playerName);
|
||||
void setPlayerName(std::vector<uint16_t> playerName);
|
||||
/*!
|
||||
* \brief setPlayerName
|
||||
* \param playerName
|
||||
@@ -526,7 +526,7 @@ public:
|
||||
* \brief playerName
|
||||
* \return
|
||||
*/
|
||||
std::vector<atUint16> playerName() const;
|
||||
std::vector<uint16_t> playerName() const;
|
||||
/*!
|
||||
* \brief playerNameToString
|
||||
* \return
|
||||
@@ -549,102 +549,102 @@ public:
|
||||
* \brief setDungeonDeathTotals
|
||||
* \param val
|
||||
*/
|
||||
void setDungeonDeathTotals(std::vector<atUint16> val);
|
||||
void setDungeonDeathTotals(std::vector<uint16_t> val);
|
||||
|
||||
/*!
|
||||
* \brief setDungeonDeathTotal
|
||||
* \param id
|
||||
* \param val
|
||||
*/
|
||||
void setDungeonDeathTotal(atUint32 id, atUint16 val);
|
||||
void setDungeonDeathTotal(uint32_t id, uint16_t val);
|
||||
|
||||
/*!
|
||||
* \brief dungeonDeathTotal
|
||||
* \param id
|
||||
* \return
|
||||
*/
|
||||
atUint16 dungeonDeathTotal(atUint32 id) const;
|
||||
uint16_t dungeonDeathTotal(uint32_t id) const;
|
||||
|
||||
/*!
|
||||
* \brief dungeonDeathTotalCount
|
||||
* \return
|
||||
*/
|
||||
atUint16 dungeonDeathTotalCount() const;
|
||||
uint16_t dungeonDeathTotalCount() const;
|
||||
|
||||
/*!
|
||||
* \brief setUnknown2
|
||||
* \param val
|
||||
*/
|
||||
void setUnknown2(atUint16 val);
|
||||
void setUnknown2(uint16_t val);
|
||||
|
||||
/*!
|
||||
* \brief unknown2
|
||||
* \return
|
||||
*/
|
||||
atUint16 unknown2() const;
|
||||
uint16_t unknown2() const;
|
||||
|
||||
/*!
|
||||
* \brief setDeathSaveCount
|
||||
* \param val
|
||||
*/
|
||||
void setDeathSaveCount(atUint16 val);
|
||||
void setDeathSaveCount(uint16_t val);
|
||||
|
||||
/*!
|
||||
* \brief deathSaveCount
|
||||
* \return
|
||||
*/
|
||||
atUint16 deathSaveCount() const;
|
||||
uint16_t deathSaveCount() const;
|
||||
|
||||
/*!
|
||||
* \brief setPostGameDeathCounter
|
||||
* \param val
|
||||
*/
|
||||
void setPostGameDeathCounter(atInt16 val);
|
||||
void setPostGameDeathCounter(int16_t val);
|
||||
|
||||
/*!
|
||||
* \brief postGameDeathCounter
|
||||
* \return
|
||||
*/
|
||||
atInt16 postGameDeathCounter() const;
|
||||
int16_t postGameDeathCounter() const;
|
||||
|
||||
/*!
|
||||
* \brief setChecksum
|
||||
* \param checksum
|
||||
*/
|
||||
void setChecksum(atUint16 checksum);
|
||||
void setChecksum(uint16_t checksum);
|
||||
|
||||
/*!
|
||||
* \brief checksum
|
||||
* \return
|
||||
*/
|
||||
atUint16 checksum() const;
|
||||
uint16_t checksum() const;
|
||||
|
||||
private:
|
||||
std::vector<ALTTPRoomFlags*> m_roomFlags;
|
||||
std::vector<ALTTPOverworldEvent*> m_overworldEvents;
|
||||
ALTTPInventory m_inventory;
|
||||
atUint16 m_rupeeMax;
|
||||
atUint16 m_rupeeCurrent;
|
||||
uint16_t m_rupeeMax;
|
||||
uint16_t m_rupeeCurrent;
|
||||
ALTTPDungeonItemFlags m_compasses;
|
||||
ALTTPDungeonItemFlags m_bigKeys;
|
||||
ALTTPDungeonItemFlags m_dungeonMaps;
|
||||
atUint16 m_wishingPond;
|
||||
atUint8 m_healthMax;
|
||||
atUint8 m_health;
|
||||
atUint8 m_magicPower;
|
||||
atUint8 m_keys;
|
||||
atUint8 m_bombUpgrades;
|
||||
atUint8 m_arrowUpgrades;
|
||||
atUint8 m_heartFiller;
|
||||
atUint8 m_magicFiller;
|
||||
uint16_t m_wishingPond;
|
||||
uint8_t m_healthMax;
|
||||
uint8_t m_health;
|
||||
uint8_t m_magicPower;
|
||||
uint8_t m_keys;
|
||||
uint8_t m_bombUpgrades;
|
||||
uint8_t m_arrowUpgrades;
|
||||
uint8_t m_heartFiller;
|
||||
uint8_t m_magicFiller;
|
||||
ALTTPPendants m_pendants;
|
||||
atUint8 m_bombFiller;
|
||||
atUint8 m_arrowFiller;
|
||||
atUint8 m_arrows;
|
||||
uint8_t m_bombFiller;
|
||||
uint8_t m_arrowFiller;
|
||||
uint8_t m_arrows;
|
||||
ALTTPAbilities m_abilityFlags;
|
||||
ALTTPCrystals m_crystals;
|
||||
ALTTPMagicUsage m_magicUsage;
|
||||
std::vector<atUint8> m_dungeonKeys;
|
||||
std::vector<uint8_t> m_dungeonKeys;
|
||||
ALTTPProgressIndicator m_progressIndicator;
|
||||
ALTTPProgressFlags1 m_progressFlags1;
|
||||
ALTTPMapIcon m_mapIcon;
|
||||
@@ -652,16 +652,16 @@ private:
|
||||
ALTTPProgressFlags2 m_progressFlags2;
|
||||
ALTTPLightDarkWorldIndicator m_lightDarkWorldIndicator;
|
||||
ALTTPTagAlong m_tagAlong;
|
||||
std::vector<atUint8> m_oldManFlags;
|
||||
atUint8 m_bombFlag;
|
||||
std::vector<atUint8> m_unknown1;
|
||||
std::vector<atUint16> m_playerName;
|
||||
std::vector<uint8_t> m_oldManFlags;
|
||||
uint8_t m_bombFlag;
|
||||
std::vector<uint8_t> m_unknown1;
|
||||
std::vector<uint16_t> m_playerName;
|
||||
bool m_valid;
|
||||
std::vector<atUint16> m_dungeonDeathTotals;
|
||||
atUint16 m_unknown2;
|
||||
atUint16 m_deathSaveCount;
|
||||
atInt16 m_postGameDeathCounter;
|
||||
atUint16 m_checksum;
|
||||
std::vector<uint16_t> m_dungeonDeathTotals;
|
||||
uint16_t m_unknown2;
|
||||
uint16_t m_deathSaveCount;
|
||||
int16_t m_postGameDeathCounter;
|
||||
uint16_t m_checksum;
|
||||
};
|
||||
|
||||
} // namespace athena
|
||||
|
||||
@@ -92,7 +92,7 @@ struct ALTTPDungeonItemFlags {
|
||||
bool IcePalace : 1;
|
||||
bool SkullWoods : 1;
|
||||
};
|
||||
atUint8 flags1;
|
||||
uint8_t flags1;
|
||||
};
|
||||
|
||||
union {
|
||||
@@ -106,7 +106,7 @@ struct ALTTPDungeonItemFlags {
|
||||
bool HyruleCastle : 1; // unused exist in original game
|
||||
bool SewerPassage : 1; // unused exist in original game
|
||||
};
|
||||
atUint8 flags2;
|
||||
uint8_t flags2;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
#include "athena/Types.hpp"
|
||||
|
||||
namespace athena::checksums {
|
||||
atUint64 crc64(const atUint8* data, atUint64 length, atUint64 seed = 0xFFFFFFFFFFFFFFFF,
|
||||
atUint64 final = 0xFFFFFFFFFFFFFFFF);
|
||||
atUint32 crc32(const atUint8* data, atUint64 length, atUint32 seed = 0xFFFFFFFF, atUint32 final = 0xFFFFFFFF);
|
||||
atUint16 crc16CCITT(const atUint8* data, atUint64 length, atUint16 seed = 0xFFFF, atUint16 final = 0);
|
||||
atUint16 crc16(const atUint8* data, atUint64 length, atUint16 seed = 0, atUint16 final = 0);
|
||||
uint64_t crc64(const uint8_t* data, uint64_t length, uint64_t seed = 0xFFFFFFFFFFFFFFFF,
|
||||
uint64_t final = 0xFFFFFFFFFFFFFFFF);
|
||||
uint32_t crc32(const uint8_t* data, uint64_t length, uint32_t seed = 0xFFFFFFFF, uint32_t final = 0xFFFFFFFF);
|
||||
uint16_t crc16CCITT(const uint8_t* data, uint64_t length, uint16_t seed = 0xFFFF, uint16_t final = 0);
|
||||
uint16_t crc16(const uint8_t* data, uint64_t length, uint16_t seed = 0, uint16_t final = 0);
|
||||
} // namespace athena::checksums
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
namespace athena::io::Compression {
|
||||
// Zlib compression
|
||||
atInt32 decompressZlib(const atUint8* src, atUint32 srcLen, atUint8* dst, atUint32 dstLen);
|
||||
atInt32 compressZlib(const atUint8* src, atUint32 srcLen, atUint8* dst, atUint32 dstLen);
|
||||
int32_t decompressZlib(const uint8_t* src, uint32_t srcLen, uint8_t* dst, uint32_t dstLen);
|
||||
int32_t compressZlib(const uint8_t* src, uint32_t srcLen, uint8_t* dst, uint32_t dstLen);
|
||||
|
||||
#if AT_LZOKAY
|
||||
// lzo compression
|
||||
@@ -13,9 +13,9 @@ atInt32 decompressLZO(const atUint8* source, atInt32 sourceSize, atUint8* dst, a
|
||||
#endif
|
||||
|
||||
// Yaz0 encoding
|
||||
atUint32 yaz0Decode(const atUint8* src, atUint8* dst, atUint32 uncompressedSize);
|
||||
atUint32 yaz0Encode(const atUint8* src, atUint32 srcSize, atUint8* data);
|
||||
uint32_t yaz0Decode(const uint8_t* src, uint8_t* dst, uint32_t uncompressedSize);
|
||||
uint32_t yaz0Encode(const uint8_t* src, uint32_t srcSize, uint8_t* data);
|
||||
|
||||
atUint32 decompressLZ77(const atUint8* src, atUint32 srcLen, atUint8** dst);
|
||||
atUint32 compressLZ77(const atUint8* src, atUint32 srcLen, atUint8** dst, bool extended = false);
|
||||
uint32_t decompressLZ77(const uint8_t* src, uint32_t srcLen, uint8_t** dst);
|
||||
uint32_t compressLZ77(const uint8_t* src, uint32_t srcLen, uint8_t** dst, bool extended = false);
|
||||
} // namespace athena::io::Compression
|
||||
|
||||
@@ -1,152 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
/* BIG FAT WARNING!!!
|
||||
*
|
||||
* The type-structure of this file is expected to remain consistent for 'atdna'
|
||||
* Any changes to the types or namespacing must be reflected in 'atdna/main.cpp'
|
||||
*/
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "athena/DNAOp.hpp"
|
||||
#include "athena/Global.hpp"
|
||||
#include "athena/IStreamReader.hpp"
|
||||
#include "athena/IStreamWriter.hpp"
|
||||
|
||||
using namespace std::literals;
|
||||
|
||||
namespace athena::io {
|
||||
|
||||
/**
|
||||
* @brief Base DNA class used against 'atdna'
|
||||
* @tparam DNAE Default-endianness for contained DNA values
|
||||
*
|
||||
* Athena bundles a build-tool called 'atdna'. This tool functions
|
||||
* just like the 'clang' compiler, except it emits a full .cpp implementation
|
||||
* with all read/write calls necessary to marshal the DNA structure to/from
|
||||
* a streamed medium
|
||||
*/
|
||||
template <Endian DNAE>
|
||||
struct DNA {
|
||||
/**
|
||||
* @brief Designated byte-order used for serializing fields
|
||||
*/
|
||||
static constexpr Endian DNAEndian = DNAE;
|
||||
|
||||
/**
|
||||
* @brief Template type signaling atdna to capture the value where it's used
|
||||
* @tparam T The type of the value. Can be any numeric type or atVec* type
|
||||
* @tparam VE Endianness of the value
|
||||
*/
|
||||
template <typename T, Endian VE = DNAE>
|
||||
using Value = T;
|
||||
|
||||
/**
|
||||
* @brief Template type wrapping std::vector and signaling atdna to manipulate it where it's used
|
||||
* @tparam T The type of contained elements. Can be any numeric type, atVec* type, or another DNA subclass
|
||||
* @tparam cntVar C++ expression wrapped in DNA_COUNT macro to determine number of elements for vector
|
||||
* @tparam VE Endianness of the contained values
|
||||
*/
|
||||
template <typename T, size_t cntVar, Endian VE = DNAE>
|
||||
using Vector = std::vector<T>;
|
||||
|
||||
/**
|
||||
* @brief Template type wrapping std::unique_ptr<atUint8[]> and signaling atdna to read a
|
||||
* raw byte-buffer where it's used
|
||||
* @tparam sizeVar C++ expression wrapped in DNA_COUNT macro to determine number of bytes for buffer
|
||||
*/
|
||||
template <size_t sizeVar>
|
||||
using Buffer = std::unique_ptr<atUint8[]>;
|
||||
|
||||
/**
|
||||
* @brief Template type wrapping std::string and signaling atdna to read string data where it's used
|
||||
* @tparam sizeVar C++ expression wrapped in DNA_COUNT macro to determine number of characters for string
|
||||
* -1 literal indicates null-terminated string
|
||||
*/
|
||||
template <atInt32 sizeVar = -1>
|
||||
using String = std::string;
|
||||
|
||||
/**
|
||||
* @brief Template type wrapping std::wstring and signaling atdna to read wstring data where it's used
|
||||
* @tparam sizeVar C++ expression wrapped in DNA_COUNT macro to determine number of characters for wstring
|
||||
* -1 literal indicates null-terminated wstring
|
||||
*/
|
||||
template <atInt32 sizeVar = -1, Endian VE = DNAE>
|
||||
using WString = std::wstring;
|
||||
|
||||
/**
|
||||
* @brief Meta Template signaling atdna to insert a stream seek where it's used
|
||||
* @tparam offset C++ expression wrapped in DNA_COUNT macro to determine number of bytes to seek
|
||||
* @tparam direction SeekOrigin to seek relative to
|
||||
*/
|
||||
template <off_t offset, SeekOrigin direction>
|
||||
struct Seek {};
|
||||
|
||||
/**
|
||||
* @brief Meta Template signaling atdna to insert an aligning stream seek where it's used
|
||||
* @tparam align Number of bytes to align to
|
||||
*/
|
||||
template <size_t align>
|
||||
struct Align {};
|
||||
|
||||
/**
|
||||
* @brief Meta Template preventing atdna from emitting read/write implementations
|
||||
*/
|
||||
struct Delete {};
|
||||
|
||||
/* Bring fundamental operations into DNA subclasses for easier per-op overrides */
|
||||
using Read = athena::io::Read<PropType::None>;
|
||||
using Write = athena::io::Write<PropType::None>;
|
||||
using BinarySize = athena::io::BinarySize<PropType::None>;
|
||||
using PropCount = athena::io::PropCount<PropType::None>;
|
||||
using ReadYaml = athena::io::ReadYaml<PropType::None>;
|
||||
using WriteYaml = athena::io::WriteYaml<PropType::None>;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Virtual DNA wrapper for subclasses that utilize virtual method calls
|
||||
* @tparam DNAE Default-endianness for contained DNA values
|
||||
*
|
||||
* Typically, static template-based DNA resolution is sufficient; however, formats
|
||||
* with a tree of variously-typed data structures would benefit from having a vtable.
|
||||
*
|
||||
* Note: It's not recommended to implement these directly. Instead, use the AT_DECL_DNA or
|
||||
* AT_DECL_EXPLCIT_DNA macro in the subclasses. Specializing the Enumerate method
|
||||
* is the proper way to override individual I/O operations. Owners of the virtualized
|
||||
* subclass will typically use a unique_ptr to reference the data; specializing their own
|
||||
* Enumerate methods as such:
|
||||
*
|
||||
* template <> void MySubclass::Enumerate<Read>(typename Read::StreamT& r)
|
||||
* { (Do stuff with `r`) }
|
||||
*/
|
||||
template <Endian DNAE>
|
||||
struct DNAV : DNA<DNAE> {
|
||||
virtual ~DNAV() = default;
|
||||
virtual void read(athena::io::IStreamReader& r) = 0;
|
||||
virtual void write(athena::io::IStreamWriter& w) const = 0;
|
||||
virtual void binarySize(size_t& s) const = 0;
|
||||
virtual std::string_view DNATypeV() const = 0;
|
||||
};
|
||||
|
||||
template <Endian DNAE>
|
||||
struct DNAVYaml : DNAV<DNAE> {
|
||||
virtual ~DNAVYaml() = default;
|
||||
void read(athena::io::IStreamReader& r) override = 0;
|
||||
void write(athena::io::IStreamWriter& w) const override = 0;
|
||||
void binarySize(size_t& s) const override = 0;
|
||||
virtual void read(athena::io::YAMLDocReader& r) = 0;
|
||||
virtual void write(athena::io::YAMLDocWriter& w) const = 0;
|
||||
};
|
||||
|
||||
/** Macro to supply count variable to atdna and mute it for other compilers */
|
||||
#ifdef __clang__
|
||||
#define AT_DNA_COUNT(...) sizeof(__VA_ARGS__)
|
||||
#else
|
||||
#define AT_DNA_COUNT(...) 0
|
||||
#endif
|
||||
|
||||
} // namespace athena::io
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,121 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "athena/DNA.hpp"
|
||||
#include "athena/FileReader.hpp"
|
||||
#include "athena/FileWriter.hpp"
|
||||
#include "athena/YAMLDocReader.hpp"
|
||||
#include "athena/YAMLDocWriter.hpp"
|
||||
|
||||
namespace athena::io {
|
||||
|
||||
template <class T>
|
||||
std::string_view __GetDNAName(const T& dna) {
|
||||
if constexpr (__IsDNAVRecord_v<T>) {
|
||||
return dna.DNATypeV();
|
||||
} else {
|
||||
return dna.DNAType();
|
||||
}
|
||||
}
|
||||
|
||||
template <class T>
|
||||
std::string ToYAMLString(const T& dna) {
|
||||
YAMLDocWriter docWriter(__GetDNAName(dna));
|
||||
|
||||
std::string res;
|
||||
yaml_emitter_set_output(docWriter.getEmitter(), (yaml_write_handler_t*)YAMLStdStringWriter, &res);
|
||||
yaml_emitter_set_unicode(docWriter.getEmitter(), true);
|
||||
yaml_emitter_set_width(docWriter.getEmitter(), -1);
|
||||
|
||||
dna.write(docWriter);
|
||||
if (!docWriter.finish(nullptr))
|
||||
return std::string();
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
bool FromYAMLString(T& dna, std::string_view str) {
|
||||
YAMLStdStringViewReaderState reader(str);
|
||||
YAMLDocReader docReader;
|
||||
yaml_parser_set_input(docReader.getParser(), (yaml_read_handler_t*)YAMLStdStringReader, &reader);
|
||||
if (!docReader.parse(nullptr))
|
||||
return false;
|
||||
dna.read(docReader);
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class DNASubtype>
|
||||
bool ValidateFromYAMLString(std::string_view str) {
|
||||
YAMLStdStringViewReaderState reader(str);
|
||||
YAMLDocReader docReader;
|
||||
yaml_parser_set_input(docReader.getParser(), (yaml_read_handler_t*)YAMLStdStringReader, &reader);
|
||||
bool retval = docReader.ValidateClassType(DNASubtype::DNAType());
|
||||
return retval;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
bool ToYAMLStream(const T& dna, athena::io::IStreamWriter& fout) {
|
||||
YAMLDocWriter docWriter(__GetDNAName(dna));
|
||||
|
||||
yaml_emitter_set_unicode(docWriter.getEmitter(), true);
|
||||
yaml_emitter_set_width(docWriter.getEmitter(), -1);
|
||||
|
||||
dna.write(docWriter);
|
||||
return docWriter.finish(&fout);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
bool ToYAMLStream(const T& dna, athena::io::IStreamWriter& fout, void (T::*fn)(YAMLDocWriter& out) const) {
|
||||
YAMLDocWriter docWriter(__GetDNAName(dna));
|
||||
|
||||
yaml_emitter_set_unicode(docWriter.getEmitter(), true);
|
||||
yaml_emitter_set_width(docWriter.getEmitter(), -1);
|
||||
|
||||
(dna.*fn)(docWriter);
|
||||
return docWriter.finish(&fout);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
bool FromYAMLStream(T& dna, athena::io::IStreamReader& fin) {
|
||||
YAMLDocReader docReader;
|
||||
if (!docReader.parse(&fin))
|
||||
return false;
|
||||
dna.read(docReader);
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
bool FromYAMLStream(T& dna, athena::io::IStreamReader& fin, void (T::*fn)(YAMLDocReader& in)) {
|
||||
YAMLDocReader docReader;
|
||||
if (!docReader.parse(&fin))
|
||||
return false;
|
||||
(dna.*fn)(docReader);
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class T, typename NameT>
|
||||
bool MergeToYAMLFile(const T& dna, const NameT& filename) {
|
||||
athena::io::FileReader r(filename);
|
||||
YAMLDocWriter docWriter(__GetDNAName(dna), r.isOpen() ? &r : nullptr);
|
||||
r.close();
|
||||
|
||||
dna.write(docWriter);
|
||||
athena::io::FileWriter w(filename);
|
||||
if (!w.isOpen())
|
||||
return false;
|
||||
return docWriter.finish(&w);
|
||||
}
|
||||
|
||||
template <class DNASubtype>
|
||||
bool ValidateFromYAMLStream(athena::io::IStreamReader& fin) {
|
||||
YAMLDocReader reader;
|
||||
atUint64 pos = fin.position();
|
||||
yaml_parser_set_input(reader.getParser(), (yaml_read_handler_t*)YAMLAthenaReader, &fin);
|
||||
bool retval = reader.ValidateClassType(DNASubtype::DNAType());
|
||||
fin.seek(pos, athena::SeekOrigin::Begin);
|
||||
return retval;
|
||||
}
|
||||
|
||||
} // namespace athena::io
|
||||
@@ -2,8 +2,10 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#if _WIN32
|
||||
#if _WIN32 && !defined(__MINGW32__)
|
||||
using mode_t = int;
|
||||
#else
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
|
||||
namespace athena {
|
||||
|
||||
@@ -24,8 +24,8 @@ public:
|
||||
std::string extension() const;
|
||||
static std::string extension(std::string_view path) { return FileInfo(path).extension(); }
|
||||
|
||||
atUint64 size() const;
|
||||
static atUint64 size(std::string_view path) { return FileInfo(path).size(); }
|
||||
uint64_t size() const;
|
||||
static uint64_t size(std::string_view path) { return FileInfo(path).size(); }
|
||||
|
||||
bool exists() const;
|
||||
static bool exists(std::string_view path) { return FileInfo(path).exists(); }
|
||||
|
||||
@@ -1,14 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#if _WIN32
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#endif
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <cstdio>
|
||||
#endif
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
@@ -18,8 +10,8 @@
|
||||
namespace athena::io {
|
||||
class FileReader : public IStreamReader {
|
||||
public:
|
||||
explicit FileReader(std::string_view filename, atInt32 cacheSize = (32 * 1024), bool globalErr = true);
|
||||
explicit FileReader(std::wstring_view filename, atInt32 cacheSize = (32 * 1024), bool globalErr = true);
|
||||
explicit FileReader(std::string_view filename, int32_t cacheSize = (32 * 1024), bool globalErr = true);
|
||||
explicit FileReader(std::wstring_view filename, int32_t cacheSize = (32 * 1024), bool globalErr = true);
|
||||
~FileReader() override;
|
||||
|
||||
std::string filename() const {
|
||||
@@ -40,17 +32,16 @@ public:
|
||||
|
||||
void open();
|
||||
void close();
|
||||
bool isOpen() const { return m_fileHandle != 0; }
|
||||
bool save();
|
||||
void seek(atInt64 pos, SeekOrigin origin = SeekOrigin::Current) override;
|
||||
atUint64 position() const override;
|
||||
atUint64 length() const override;
|
||||
atUint64 readUBytesToBuf(void* buf, atUint64 len) override;
|
||||
bool isOpen() const { return m_fileHandle != nullptr; }
|
||||
void seek(int64_t pos, SeekOrigin origin = SeekOrigin::Current) override;
|
||||
uint64_t position() const override;
|
||||
uint64_t length() const override;
|
||||
uint64_t readUBytesToBuf(void* buf, uint64_t len) override;
|
||||
|
||||
void setCacheSize(const atInt32 blockSize);
|
||||
void setCacheSize(const int32_t blockSize);
|
||||
|
||||
#if _WIN32
|
||||
using HandleType = HANDLE;
|
||||
using HandleType = void*;
|
||||
#else
|
||||
using HandleType = FILE*;
|
||||
#endif
|
||||
@@ -64,10 +55,11 @@ protected:
|
||||
std::string m_filename;
|
||||
#endif
|
||||
HandleType m_fileHandle;
|
||||
std::unique_ptr<atUint8[]> m_cacheData;
|
||||
atInt32 m_blockSize;
|
||||
atInt32 m_curBlock;
|
||||
atUint64 m_offset;
|
||||
uint64_t m_fileSize;
|
||||
std::unique_ptr<uint8_t[]> m_cacheData;
|
||||
int32_t m_blockSize;
|
||||
int32_t m_curBlock;
|
||||
uint64_t m_offset;
|
||||
bool m_globalErr;
|
||||
};
|
||||
} // namespace athena::io
|
||||
|
||||
@@ -1,13 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef _WIN32
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#endif
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <cstdio>
|
||||
#endif
|
||||
|
||||
#include "athena/IStreamWriter.hpp"
|
||||
#include "athena/Types.hpp"
|
||||
@@ -37,13 +30,13 @@ public:
|
||||
void open(bool overwrite = true);
|
||||
void close();
|
||||
bool isOpen() const { return m_fileHandle != nullptr; }
|
||||
void seek(atInt64 pos, SeekOrigin origin = SeekOrigin::Current) override;
|
||||
atUint64 position() const override;
|
||||
atUint64 length() const override;
|
||||
void writeUBytes(const atUint8* data, atUint64 len) override;
|
||||
void seek(int64_t pos, SeekOrigin origin = SeekOrigin::Current) override;
|
||||
uint64_t position() const override;
|
||||
uint64_t length() const override;
|
||||
void writeUBytes(const uint8_t* data, uint64_t len) override;
|
||||
|
||||
#ifdef _WIN32
|
||||
using HandleType = HANDLE;
|
||||
using HandleType = void*;
|
||||
#else
|
||||
using HandleType = FILE*;
|
||||
#endif
|
||||
@@ -68,7 +61,7 @@ class TransactionalFileWriter : public IStreamWriter {
|
||||
#endif
|
||||
bool m_overwrite, m_globalErr;
|
||||
std::vector<uint8_t> m_deferredBuffer;
|
||||
atUint64 m_position = 0;
|
||||
uint64_t m_position = 0;
|
||||
|
||||
public:
|
||||
explicit TransactionalFileWriter(std::string_view filename, bool overwrite = true, bool globalErr = true)
|
||||
@@ -101,10 +94,10 @@ public:
|
||||
m_position = 0;
|
||||
}
|
||||
|
||||
atUint64 position() const override { return m_position; }
|
||||
atUint64 length() const override { return m_deferredBuffer.size(); }
|
||||
void seek(atInt64 pos, SeekOrigin origin = SeekOrigin::Current) override;
|
||||
void writeUBytes(const atUint8* data, atUint64 len) override;
|
||||
uint64_t position() const override { return m_position; }
|
||||
uint64_t length() const override { return m_deferredBuffer.size(); }
|
||||
void seek(int64_t pos, SeekOrigin origin = SeekOrigin::Current) override;
|
||||
void writeUBytes(const uint8_t* data, uint64_t len) override;
|
||||
|
||||
~TransactionalFileWriter() override { flush(); }
|
||||
};
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include <ostream>
|
||||
#include "athena/Types.hpp"
|
||||
|
||||
#include <fmt/format.h>
|
||||
#include <format>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable : 4996)
|
||||
@@ -47,7 +47,7 @@
|
||||
#endif
|
||||
// clang-format on
|
||||
|
||||
#if defined(GEKKO) || defined(__SWITCH__)
|
||||
#if defined(GEKKO) || defined(__SWITCH__) || defined(EMSCRIPTEN)
|
||||
#include "gekko_support.h"
|
||||
typedef struct stat atStat64_t;
|
||||
#define atStat64 stat
|
||||
@@ -118,31 +118,14 @@ enum class SeekOrigin { Begin, Current, End };
|
||||
|
||||
enum class Endian { Little, Big };
|
||||
|
||||
namespace io {
|
||||
template <Endian DNAE>
|
||||
struct DNA;
|
||||
template <Endian DNAE>
|
||||
struct DNAV;
|
||||
|
||||
template <class T>
|
||||
using __IsDNARecord = std::disjunction<std::is_base_of<DNA<Endian::Big>, T>, std::is_base_of<DNA<Endian::Little>, T>>;
|
||||
template <class T>
|
||||
constexpr bool __IsDNARecord_v = __IsDNARecord<T>::value;
|
||||
|
||||
template <class T>
|
||||
using __IsDNAVRecord =
|
||||
std::disjunction<std::is_base_of<DNAV<Endian::Big>, T>, std::is_base_of<DNAV<Endian::Little>, T>>;
|
||||
template <class T>
|
||||
constexpr bool __IsDNAVRecord_v = __IsDNAVRecord<T>::value;
|
||||
} // namespace io
|
||||
} // namespace athena
|
||||
|
||||
typedef void (*atEXCEPTION_HANDLER)(athena::error::Level level, const char* /*file*/, const char*, int /*line*/,
|
||||
fmt::string_view fmt, fmt::format_args args);
|
||||
std::string_view fmt, std::format_args args);
|
||||
|
||||
atEXCEPTION_HANDLER atGetExceptionHandler();
|
||||
/**
|
||||
* atSetExceptionHandler is only meant to be used a the start and end of an application's lifetime,
|
||||
* atSetExceptionHandler is only meant to be used at the start and end of an application's lifetime,
|
||||
* this function cannot be considered thread-safe, therefore modifying during runtime is not recommended.
|
||||
*/
|
||||
void atSetExceptionHandler(atEXCEPTION_HANDLER func);
|
||||
@@ -150,54 +133,47 @@ void atSetExceptionHandler(atEXCEPTION_HANDLER func);
|
||||
std::ostream& operator<<(std::ostream& os, const athena::SeekOrigin& origin);
|
||||
std::ostream& operator<<(std::ostream& os, const athena::Endian& endian);
|
||||
|
||||
template <typename First, typename... Rest>
|
||||
constexpr auto __FIRST_ARG__(First first, Rest...) { return first; }
|
||||
template <typename S, typename... Args>
|
||||
auto __make_args_checked__(const S& format_str, Args&&... args) {
|
||||
return fmt::make_args_checked<Args...>(format_str, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
#define atDebug(...) \
|
||||
#define atDebug(fmt, ...) \
|
||||
do { \
|
||||
atEXCEPTION_HANDLER __handler = atGetExceptionHandler(); \
|
||||
if (__handler) \
|
||||
__handler(athena::error::Level::Message, __FILE__, AT_PRETTY_FUNCTION, __LINE__, __FIRST_ARG__(__VA_ARGS__), \
|
||||
__make_args_checked__(__VA_ARGS__)); \
|
||||
__handler(athena::error::Level::Message, __FILE__, AT_PRETTY_FUNCTION, __LINE__, fmt, \
|
||||
std::make_format_args(__VA_ARGS__)); \
|
||||
} while (0)
|
||||
#else
|
||||
#define atDebug(...)
|
||||
#endif
|
||||
|
||||
#define atMessage(...) \
|
||||
#define atMessage(fmt, ...) \
|
||||
do { \
|
||||
atEXCEPTION_HANDLER __handler = atGetExceptionHandler(); \
|
||||
if (__handler) \
|
||||
__handler(athena::error::Level::Message, __FILE__, AT_PRETTY_FUNCTION, __LINE__, __FIRST_ARG__(__VA_ARGS__), \
|
||||
__make_args_checked__(__VA_ARGS__)); \
|
||||
__handler(athena::error::Level::Message, __FILE__, AT_PRETTY_FUNCTION, __LINE__, fmt, \
|
||||
std::make_format_args(__VA_ARGS__)); \
|
||||
} while (0)
|
||||
|
||||
#define atWarning(...) \
|
||||
#define atWarning(fmt, ...) \
|
||||
do { \
|
||||
atEXCEPTION_HANDLER __handler = atGetExceptionHandler(); \
|
||||
if (__handler) { \
|
||||
__handler(athena::error::Level::Warning, __FILE__, AT_PRETTY_FUNCTION, __LINE__, __FIRST_ARG__(__VA_ARGS__), \
|
||||
__make_args_checked__(__VA_ARGS__)); \
|
||||
__handler(athena::error::Level::Warning, __FILE__, AT_PRETTY_FUNCTION, __LINE__, fmt, \
|
||||
std::make_format_args(__VA_ARGS__)); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define atError(...) \
|
||||
#define atError(fmt, ...) \
|
||||
do { \
|
||||
atEXCEPTION_HANDLER __handler = atGetExceptionHandler(); \
|
||||
if (__handler) \
|
||||
__handler(athena::error::Level::Error, __FILE__, AT_PRETTY_FUNCTION, __LINE__, __FIRST_ARG__(__VA_ARGS__), \
|
||||
__make_args_checked__(__VA_ARGS__)); \
|
||||
__handler(athena::error::Level::Error, __FILE__, AT_PRETTY_FUNCTION, __LINE__, fmt, \
|
||||
std::make_format_args(__VA_ARGS__)); \
|
||||
} while (0)
|
||||
|
||||
#define atFatal(...) \
|
||||
#define atFatal(fmt, ...) \
|
||||
do { \
|
||||
atEXCEPTION_HANDLER __handler = atGetExceptionHandler(); \
|
||||
if (__handler) \
|
||||
__handler(athena::error::Level::Fatal, __FILE__, AT_PRETTY_FUNCTION, __LINE__, __FIRST_ARG__(__VA_ARGS__), \
|
||||
__make_args_checked__(__VA_ARGS__)); \
|
||||
__handler(athena::error::Level::Fatal, __FILE__, AT_PRETTY_FUNCTION, __LINE__, fmt, \
|
||||
std::make_format_args(__VA_ARGS__)); \
|
||||
} while (0)
|
||||
|
||||
@@ -12,10 +12,10 @@ public:
|
||||
Endian endian() const { return m_endian; }
|
||||
bool isBigEndian() const { return (m_endian == Endian::Big); }
|
||||
bool isLittleEndian() const { return (m_endian == Endian::Little); }
|
||||
virtual void seek(atInt64, SeekOrigin) = 0;
|
||||
virtual void seek(int64_t, SeekOrigin) = 0;
|
||||
virtual bool atEnd() const = 0;
|
||||
virtual atUint64 position() const = 0;
|
||||
virtual atUint64 length() const = 0;
|
||||
virtual uint64_t position() const = 0;
|
||||
virtual uint64_t length() const = 0;
|
||||
bool hasError() const { return m_hasError; }
|
||||
|
||||
protected:
|
||||
|
||||
@@ -24,7 +24,7 @@ public:
|
||||
* @param position where in the buffer to seek
|
||||
* @param origin The Origin to seek relative to
|
||||
*/
|
||||
void seek(atInt64 position, SeekOrigin origin = SeekOrigin::Current) override = 0;
|
||||
void seek(int64_t position, SeekOrigin origin = SeekOrigin::Current) override = 0;
|
||||
|
||||
/** @brief Sets the buffer's position relative to the next 64-byte aligned position.<br />
|
||||
*/
|
||||
@@ -52,33 +52,33 @@ public:
|
||||
*
|
||||
* @return The current position in the stream.
|
||||
*/
|
||||
atUint64 position() const override = 0;
|
||||
uint64_t position() const override = 0;
|
||||
|
||||
/** @brief Returns the length of the file.
|
||||
*
|
||||
* @return True length of the file.
|
||||
*/
|
||||
atUint64 length() const override = 0;
|
||||
uint64_t length() const override = 0;
|
||||
|
||||
/** @brief Reads a byte at the current position and advances the current position
|
||||
*
|
||||
* @return The value at the current position
|
||||
*/
|
||||
atInt8 readByte() {
|
||||
atInt8 val = 0;
|
||||
int8_t readByte() {
|
||||
int8_t val = 0;
|
||||
readUBytesToBuf(&val, 1);
|
||||
return val;
|
||||
}
|
||||
template <class T>
|
||||
atInt8 readVal(std::enable_if_t<std::is_same_v<T, atInt8>>* = nullptr) {
|
||||
int8_t readVal(std::enable_if_t<std::is_same_v<T, int8_t>>* = nullptr) {
|
||||
return readByte();
|
||||
}
|
||||
template <class T>
|
||||
atInt8 readValLittle(std::enable_if_t<std::is_same_v<T, atInt8>>* = nullptr) {
|
||||
int8_t readValLittle(std::enable_if_t<std::is_same_v<T, int8_t>>* = nullptr) {
|
||||
return readByte();
|
||||
}
|
||||
template <class T>
|
||||
atInt8 readValBig(std::enable_if_t<std::is_same_v<T, atInt8>>* = nullptr) {
|
||||
int8_t readValBig(std::enable_if_t<std::is_same_v<T, int8_t>>* = nullptr) {
|
||||
return readByte();
|
||||
}
|
||||
|
||||
@@ -86,17 +86,17 @@ public:
|
||||
*
|
||||
* @return The value at the current position
|
||||
*/
|
||||
atUint8 readUByte() { return readByte(); }
|
||||
uint8_t readUByte() { return readByte(); }
|
||||
template <class T>
|
||||
atUint8 readVal(std::enable_if_t<std::is_same_v<T, atUint8>>* = nullptr) {
|
||||
uint8_t readVal(std::enable_if_t<std::is_same_v<T, uint8_t>>* = nullptr) {
|
||||
return readUByte();
|
||||
}
|
||||
template <class T>
|
||||
atUint8 readValLittle(std::enable_if_t<std::is_same_v<T, atUint8>>* = nullptr) {
|
||||
uint8_t readValLittle(std::enable_if_t<std::is_same_v<T, uint8_t>>* = nullptr) {
|
||||
return readUByte();
|
||||
}
|
||||
template <class T>
|
||||
atUint8 readValBig(std::enable_if_t<std::is_same_v<T, atUint8>>* = nullptr) {
|
||||
uint8_t readValBig(std::enable_if_t<std::is_same_v<T, uint8_t>>* = nullptr) {
|
||||
return readUByte();
|
||||
}
|
||||
|
||||
@@ -104,8 +104,8 @@ public:
|
||||
*
|
||||
* @return The buffer at the current position from the given length.
|
||||
*/
|
||||
std::unique_ptr<atInt8[]> readBytes(atUint64 length) {
|
||||
auto buf = std::make_unique<atInt8[]>(length);
|
||||
std::unique_ptr<int8_t[]> readBytes(uint64_t length) {
|
||||
auto buf = std::make_unique<int8_t[]>(length);
|
||||
readUBytesToBuf(buf.get(), length);
|
||||
return buf;
|
||||
}
|
||||
@@ -114,8 +114,8 @@ public:
|
||||
*
|
||||
* @return The buffer at the current position from the given length.
|
||||
*/
|
||||
std::unique_ptr<atUint8[]> readUBytes(atUint64 length) {
|
||||
auto buf = std::make_unique<atUint8[]>(length);
|
||||
std::unique_ptr<uint8_t[]> readUBytes(uint64_t length) {
|
||||
auto buf = std::make_unique<uint8_t[]>(length);
|
||||
readUBytesToBuf(buf.get(), length);
|
||||
return buf;
|
||||
}
|
||||
@@ -125,7 +125,7 @@ public:
|
||||
* @param len The length of the buffer
|
||||
* @return How much data was actually read, useful for detecting read errors.
|
||||
*/
|
||||
atUint64 readBytesToBuf(void* buf, atUint64 len) { return readUBytesToBuf(buf, len); }
|
||||
uint64_t readBytesToBuf(void* buf, uint64_t len) { return readUBytesToBuf(buf, len); }
|
||||
|
||||
/** @brief Attempts to read a fixed length of data into a pre-allocated buffer, this function is client defined
|
||||
* and must be implemented.
|
||||
@@ -133,20 +133,20 @@ public:
|
||||
* @param len The length of the buffer
|
||||
* @return How much data was actually read, useful for detecting read errors.
|
||||
*/
|
||||
virtual atUint64 readUBytesToBuf(void* buf, atUint64 len) = 0;
|
||||
virtual uint64_t readUBytesToBuf(void* buf, uint64_t len) = 0;
|
||||
|
||||
/** @brief Reads a Int16 and swaps to endianness specified by setEndian depending on platform
|
||||
* and advances the current position
|
||||
*
|
||||
* @return The value at the current address
|
||||
*/
|
||||
atInt16 readInt16() {
|
||||
atInt16 val = 0;
|
||||
int16_t readInt16() {
|
||||
int16_t val = 0;
|
||||
readUBytesToBuf(&val, 2);
|
||||
return m_endian == Endian::Big ? utility::BigInt16(val) : utility::LittleInt16(val);
|
||||
}
|
||||
template <class T>
|
||||
atInt16 readVal(std::enable_if_t<std::is_same_v<T, atInt16>>* = nullptr) {
|
||||
int16_t readVal(std::enable_if_t<std::is_same_v<T, int16_t>>* = nullptr) {
|
||||
return readInt16();
|
||||
}
|
||||
|
||||
@@ -155,13 +155,13 @@ public:
|
||||
*
|
||||
* @return The value at the current address
|
||||
*/
|
||||
atInt16 readInt16Little() {
|
||||
atInt16 val = 0;
|
||||
int16_t readInt16Little() {
|
||||
int16_t val = 0;
|
||||
readUBytesToBuf(&val, 2);
|
||||
return utility::LittleInt16(val);
|
||||
}
|
||||
template <class T>
|
||||
atInt16 readValLittle(std::enable_if_t<std::is_same_v<T, atInt16>>* = nullptr) {
|
||||
int16_t readValLittle(std::enable_if_t<std::is_same_v<T, int16_t>>* = nullptr) {
|
||||
return readInt16Little();
|
||||
}
|
||||
|
||||
@@ -170,13 +170,13 @@ public:
|
||||
*
|
||||
* @return The value at the current address
|
||||
*/
|
||||
atInt16 readInt16Big() {
|
||||
atInt16 val = 0;
|
||||
int16_t readInt16Big() {
|
||||
int16_t val = 0;
|
||||
readUBytesToBuf(&val, 2);
|
||||
return utility::BigInt16(val);
|
||||
}
|
||||
template <class T>
|
||||
atInt16 readValBig(std::enable_if_t<std::is_same_v<T, atInt16>>* = nullptr) {
|
||||
int16_t readValBig(std::enable_if_t<std::is_same_v<T, int16_t>>* = nullptr) {
|
||||
return readInt16Big();
|
||||
}
|
||||
|
||||
@@ -185,9 +185,9 @@ public:
|
||||
*
|
||||
* @return The value at the current address
|
||||
*/
|
||||
atUint16 readUint16() { return readInt16(); }
|
||||
uint16_t readUint16() { return readInt16(); }
|
||||
template <class T>
|
||||
atUint16 readVal(std::enable_if_t<std::is_same_v<T, atUint16>>* = 0) {
|
||||
uint16_t readVal(std::enable_if_t<std::is_same_v<T, uint16_t>>* = 0) {
|
||||
return readUint16();
|
||||
}
|
||||
|
||||
@@ -196,13 +196,13 @@ public:
|
||||
*
|
||||
* @return The value at the current address
|
||||
*/
|
||||
atUint16 readUint16Little() {
|
||||
atUint16 val = 0;
|
||||
uint16_t readUint16Little() {
|
||||
uint16_t val = 0;
|
||||
readUBytesToBuf(&val, 2);
|
||||
return utility::LittleUint16(val);
|
||||
}
|
||||
template <class T>
|
||||
atUint16 readValLittle(std::enable_if_t<std::is_same_v<T, atUint16>>* = nullptr) {
|
||||
uint16_t readValLittle(std::enable_if_t<std::is_same_v<T, uint16_t>>* = nullptr) {
|
||||
return readUint16Little();
|
||||
}
|
||||
|
||||
@@ -211,13 +211,13 @@ public:
|
||||
*
|
||||
* @return The value at the current address
|
||||
*/
|
||||
atUint16 readUint16Big() {
|
||||
atUint16 val = 0;
|
||||
uint16_t readUint16Big() {
|
||||
uint16_t val = 0;
|
||||
readUBytesToBuf(&val, 2);
|
||||
return utility::BigUint16(val);
|
||||
}
|
||||
template <class T>
|
||||
atUint16 readValBig(std::enable_if_t<std::is_same_v<T, atUint16>>* = nullptr) {
|
||||
uint16_t readValBig(std::enable_if_t<std::is_same_v<T, uint16_t>>* = nullptr) {
|
||||
return readUint16Big();
|
||||
}
|
||||
|
||||
@@ -226,13 +226,13 @@ public:
|
||||
*
|
||||
* @return The value at the current address
|
||||
*/
|
||||
atInt32 readInt32() {
|
||||
atInt32 val = 0;
|
||||
int32_t readInt32() {
|
||||
int32_t val = 0;
|
||||
readUBytesToBuf(&val, 4);
|
||||
return m_endian == Endian::Big ? utility::BigInt32(val) : utility::LittleInt32(val);
|
||||
}
|
||||
template <class T>
|
||||
atInt32 readVal(std::enable_if_t<std::is_same_v<T, atInt32>>* = nullptr) {
|
||||
int32_t readVal(std::enable_if_t<std::is_same_v<T, int32_t>>* = nullptr) {
|
||||
return readInt32();
|
||||
}
|
||||
|
||||
@@ -241,13 +241,13 @@ public:
|
||||
*
|
||||
* @return The value at the current address
|
||||
*/
|
||||
atInt32 readInt32Little() {
|
||||
atInt32 val = 0;
|
||||
int32_t readInt32Little() {
|
||||
int32_t val = 0;
|
||||
readUBytesToBuf(&val, 4);
|
||||
return utility::LittleInt32(val);
|
||||
}
|
||||
template <class T>
|
||||
atInt32 readValLittle(std::enable_if_t<std::is_same_v<T, atInt32>>* = nullptr) {
|
||||
int32_t readValLittle(std::enable_if_t<std::is_same_v<T, int32_t>>* = nullptr) {
|
||||
return readInt32Little();
|
||||
}
|
||||
|
||||
@@ -256,13 +256,13 @@ public:
|
||||
*
|
||||
* @return The value at the current address
|
||||
*/
|
||||
atInt32 readInt32Big() {
|
||||
atInt32 val = 0;
|
||||
int32_t readInt32Big() {
|
||||
int32_t val = 0;
|
||||
readUBytesToBuf(&val, 4);
|
||||
return utility::BigInt32(val);
|
||||
}
|
||||
template <class T>
|
||||
atInt32 readValBig(std::enable_if_t<std::is_same_v<T, atInt32>>* = nullptr) {
|
||||
int32_t readValBig(std::enable_if_t<std::is_same_v<T, int32_t>>* = nullptr) {
|
||||
return readInt32Big();
|
||||
}
|
||||
|
||||
@@ -271,9 +271,9 @@ public:
|
||||
*
|
||||
* @return The value at the current address
|
||||
*/
|
||||
atUint32 readUint32() { return readInt32(); }
|
||||
uint32_t readUint32() { return readInt32(); }
|
||||
template <class T>
|
||||
atUint32 readVal(std::enable_if_t<std::is_same_v<T, atUint32>>* = nullptr) {
|
||||
uint32_t readVal(std::enable_if_t<std::is_same_v<T, uint32_t>>* = nullptr) {
|
||||
return readUint32();
|
||||
}
|
||||
|
||||
@@ -282,13 +282,13 @@ public:
|
||||
*
|
||||
* @return The value at the current address
|
||||
*/
|
||||
atUint32 readUint32Little() {
|
||||
atUint32 val = 0;
|
||||
uint32_t readUint32Little() {
|
||||
uint32_t val = 0;
|
||||
readUBytesToBuf(&val, 4);
|
||||
return utility::LittleUint32(val);
|
||||
}
|
||||
template <class T>
|
||||
atInt32 readValLittle(std::enable_if_t<std::is_same_v<T, atUint32>>* = nullptr) {
|
||||
int32_t readValLittle(std::enable_if_t<std::is_same_v<T, uint32_t>>* = nullptr) {
|
||||
return readUint32Little();
|
||||
}
|
||||
|
||||
@@ -297,13 +297,13 @@ public:
|
||||
*
|
||||
* @return The value at the current address
|
||||
*/
|
||||
atUint32 readUint32Big() {
|
||||
atUint32 val = 0;
|
||||
uint32_t readUint32Big() {
|
||||
uint32_t val = 0;
|
||||
readUBytesToBuf(&val, 4);
|
||||
return utility::BigUint32(val);
|
||||
}
|
||||
template <class T>
|
||||
atUint32 readValBig(std::enable_if_t<std::is_same_v<T, atUint32>>* = nullptr) {
|
||||
uint32_t readValBig(std::enable_if_t<std::is_same_v<T, uint32_t>>* = nullptr) {
|
||||
return readUint32Big();
|
||||
}
|
||||
|
||||
@@ -312,13 +312,13 @@ public:
|
||||
*
|
||||
* @return The value at the current address
|
||||
*/
|
||||
atInt64 readInt64() {
|
||||
atInt64 val = 0;
|
||||
int64_t readInt64() {
|
||||
int64_t val = 0;
|
||||
readUBytesToBuf(&val, 8);
|
||||
return m_endian == Endian::Big ? utility::BigInt64(val) : utility::LittleInt64(val);
|
||||
}
|
||||
template <class T>
|
||||
atInt64 readVal(std::enable_if_t<std::is_same_v<T, atInt64>>* = nullptr) {
|
||||
int64_t readVal(std::enable_if_t<std::is_same_v<T, int64_t>>* = nullptr) {
|
||||
return readInt64();
|
||||
}
|
||||
|
||||
@@ -327,13 +327,13 @@ public:
|
||||
*
|
||||
* @return The value at the current address
|
||||
*/
|
||||
atInt64 readInt64Little() {
|
||||
atInt64 val = 0;
|
||||
int64_t readInt64Little() {
|
||||
int64_t val = 0;
|
||||
readUBytesToBuf(&val, 8);
|
||||
return utility::LittleInt64(val);
|
||||
}
|
||||
template <class T>
|
||||
atInt64 readValLittle(std::enable_if_t<std::is_same_v<T, atInt64>>* = nullptr) {
|
||||
int64_t readValLittle(std::enable_if_t<std::is_same_v<T, int64_t>>* = nullptr) {
|
||||
return readInt64Little();
|
||||
}
|
||||
|
||||
@@ -342,13 +342,13 @@ public:
|
||||
*
|
||||
* @return The value at the current address
|
||||
*/
|
||||
atInt64 readInt64Big() {
|
||||
atInt64 val = 0;
|
||||
int64_t readInt64Big() {
|
||||
int64_t val = 0;
|
||||
readUBytesToBuf(&val, 8);
|
||||
return utility::BigInt64(val);
|
||||
}
|
||||
template <class T>
|
||||
atInt64 readValBig(std::enable_if_t<std::is_same_v<T, atInt64>>* = nullptr) {
|
||||
int64_t readValBig(std::enable_if_t<std::is_same_v<T, int64_t>>* = nullptr) {
|
||||
return readInt64Big();
|
||||
}
|
||||
|
||||
@@ -357,9 +357,9 @@ public:
|
||||
*
|
||||
* @return The value at the current address
|
||||
*/
|
||||
atUint64 readUint64() { return readInt64(); }
|
||||
uint64_t readUint64() { return readInt64(); }
|
||||
template <class T>
|
||||
atUint64 readVal(std::enable_if_t<std::is_same_v<T, atUint64>>* = nullptr) {
|
||||
uint64_t readVal(std::enable_if_t<std::is_same_v<T, uint64_t>>* = nullptr) {
|
||||
return readUint64();
|
||||
}
|
||||
|
||||
@@ -368,13 +368,13 @@ public:
|
||||
*
|
||||
* @return The value at the current address
|
||||
*/
|
||||
atUint64 readUint64Little() {
|
||||
atUint64 val = 0;
|
||||
uint64_t readUint64Little() {
|
||||
uint64_t val = 0;
|
||||
readUBytesToBuf(&val, 8);
|
||||
return utility::LittleUint64(val);
|
||||
}
|
||||
template <class T>
|
||||
atUint64 readValLittle(std::enable_if_t<std::is_same_v<T, atUint64>>* = nullptr) {
|
||||
uint64_t readValLittle(std::enable_if_t<std::is_same_v<T, uint64_t>>* = nullptr) {
|
||||
return readUint64Little();
|
||||
}
|
||||
|
||||
@@ -383,13 +383,13 @@ public:
|
||||
*
|
||||
* @return The value at the current address
|
||||
*/
|
||||
atUint64 readUint64Big() {
|
||||
atUint64 val = 0;
|
||||
uint64_t readUint64Big() {
|
||||
uint64_t val = 0;
|
||||
readUBytesToBuf(&val, 8);
|
||||
return utility::BigUint64(val);
|
||||
}
|
||||
template <class T>
|
||||
atUint64 readValBig(std::enable_if_t<std::is_same_v<T, atUint64>>* = nullptr) {
|
||||
uint64_t readValBig(std::enable_if_t<std::is_same_v<T, uint64_t>>* = nullptr) {
|
||||
return readUint64Big();
|
||||
}
|
||||
|
||||
@@ -488,7 +488,7 @@ public:
|
||||
* @return The value at the current address
|
||||
*/
|
||||
bool readBool() {
|
||||
atUint8 val = false;
|
||||
uint8_t val = false;
|
||||
readUBytesToBuf(&val, 1);
|
||||
return val != 0;
|
||||
}
|
||||
@@ -927,13 +927,13 @@ public:
|
||||
*
|
||||
* @return The read string
|
||||
*/
|
||||
std::string readString(atInt32 fixedLen = -1, bool doSeek = true) {
|
||||
std::string readString(int32_t fixedLen = -1, bool doSeek = true) {
|
||||
if (fixedLen == 0)
|
||||
return std::string();
|
||||
std::string ret;
|
||||
atUint8 chr = readByte();
|
||||
uint8_t chr = readByte();
|
||||
|
||||
atInt32 i;
|
||||
int32_t i;
|
||||
for (i = 1; chr != 0; ++i) {
|
||||
ret += chr;
|
||||
|
||||
@@ -961,14 +961,14 @@ public:
|
||||
*
|
||||
* @return The read wstring
|
||||
*/
|
||||
std::wstring readWString(atInt32 fixedLen = -1, bool doSeek = true) {
|
||||
std::wstring readWString(int32_t fixedLen = -1, bool doSeek = true) {
|
||||
if (fixedLen == 0)
|
||||
return std::wstring();
|
||||
|
||||
std::wstring ret;
|
||||
atUint16 chr = readUint16();
|
||||
uint16_t chr = readUint16();
|
||||
|
||||
atInt32 i;
|
||||
int32_t i;
|
||||
for (i = 1; chr != 0; ++i) {
|
||||
ret += chr;
|
||||
|
||||
@@ -997,14 +997,14 @@ public:
|
||||
*
|
||||
* @return The read wstring
|
||||
*/
|
||||
std::wstring readWStringLittle(atInt32 fixedLen = -1, bool doSeek = true) {
|
||||
std::wstring readWStringLittle(int32_t fixedLen = -1, bool doSeek = true) {
|
||||
if (fixedLen == 0)
|
||||
return std::wstring();
|
||||
|
||||
std::wstring ret;
|
||||
atUint16 chr = readUint16Little();
|
||||
uint16_t chr = readUint16Little();
|
||||
|
||||
atInt32 i;
|
||||
int32_t i;
|
||||
for (i = 1; chr != 0; ++i) {
|
||||
ret += chr;
|
||||
|
||||
@@ -1033,13 +1033,13 @@ public:
|
||||
*
|
||||
* @return The read wstring
|
||||
*/
|
||||
std::wstring readWStringBig(atInt32 fixedLen = -1, bool doSeek = true) {
|
||||
std::wstring readWStringBig(int32_t fixedLen = -1, bool doSeek = true) {
|
||||
if (fixedLen == 0)
|
||||
return std::wstring();
|
||||
std::wstring ret;
|
||||
atUint16 chr = readUint16Big();
|
||||
uint16_t chr = readUint16Big();
|
||||
|
||||
atInt32 i;
|
||||
int32_t i;
|
||||
for (i = 1; chr != 0; ++i) {
|
||||
ret += chr;
|
||||
|
||||
@@ -1068,13 +1068,13 @@ public:
|
||||
*
|
||||
* @return The read wstring
|
||||
*/
|
||||
std::u16string readU16StringBig(atInt32 fixedLen = -1, bool doSeek = true) {
|
||||
std::u16string readU16StringBig(int32_t fixedLen = -1, bool doSeek = true) {
|
||||
if (fixedLen == 0)
|
||||
return std::u16string();
|
||||
std::u16string ret;
|
||||
char16_t chr = readUint16Big();
|
||||
|
||||
atInt32 i;
|
||||
int32_t i;
|
||||
for (i = 1; chr != 0; ++i) {
|
||||
ret += chr;
|
||||
|
||||
@@ -1103,13 +1103,13 @@ public:
|
||||
*
|
||||
* @return The read wstring
|
||||
*/
|
||||
std::u32string readU32StringBig(atInt32 fixedLen = -1, bool doSeek = true) {
|
||||
std::u32string readU32StringBig(int32_t fixedLen = -1, bool doSeek = true) {
|
||||
if (fixedLen == 0)
|
||||
return std::u32string();
|
||||
std::u32string ret;
|
||||
char32_t chr = readUint32Big();
|
||||
|
||||
atInt32 i;
|
||||
int32_t i;
|
||||
for (i = 1; chr != 0; ++i) {
|
||||
ret += chr;
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ public:
|
||||
* @param position where in the buffer to seek
|
||||
* @param origin The location to seek relative to
|
||||
*/
|
||||
void seek(atInt64 position, SeekOrigin origin = SeekOrigin::Current) override = 0;
|
||||
void seek(int64_t position, SeekOrigin origin = SeekOrigin::Current) override = 0;
|
||||
|
||||
/** @brief Sets the buffers position relative to the next 32-byte aligned position.<br />
|
||||
*/
|
||||
@@ -27,11 +27,11 @@ public:
|
||||
|
||||
/** @brief Writes zero up to specified absolute offset.<br />
|
||||
*/
|
||||
void writeZeroTo(atInt64 pos) {
|
||||
atInt64 delta = pos - position();
|
||||
void writeZeroTo(int64_t pos) {
|
||||
int64_t delta = pos - position();
|
||||
if (delta <= 0)
|
||||
return;
|
||||
for (atInt64 i = 0; i < delta; ++i)
|
||||
for (int64_t i = 0; i < delta; ++i)
|
||||
writeUByte(0);
|
||||
}
|
||||
|
||||
@@ -45,29 +45,29 @@ public:
|
||||
*
|
||||
* @return The current position in the stream.
|
||||
*/
|
||||
atUint64 position() const override = 0;
|
||||
uint64_t position() const override = 0;
|
||||
|
||||
/** @brief Returns whether or not the stream is at the end.
|
||||
*
|
||||
* @return True if at end; False otherwise.
|
||||
*/
|
||||
atUint64 length() const override = 0;
|
||||
uint64_t length() const override = 0;
|
||||
|
||||
/** @brief Writes a byte at the current position and advances the position by one byte.
|
||||
* @param val The value to write
|
||||
*/
|
||||
void writeUByte(atUint8 val) { writeUBytes(&val, 1); }
|
||||
void writeVal(atUint8 val) { writeUByte(val); }
|
||||
void writeValLittle(atUint8 val) { writeUByte(val); }
|
||||
void writeValBig(atUint8 val) { writeUByte(val); }
|
||||
void writeUByte(uint8_t val) { writeUBytes(&val, 1); }
|
||||
void writeVal(uint8_t val) { writeUByte(val); }
|
||||
void writeValLittle(uint8_t val) { writeUByte(val); }
|
||||
void writeValBig(uint8_t val) { writeUByte(val); }
|
||||
|
||||
/** @brief Writes a byte at the current position and advances the position by one byte.
|
||||
* @param val The value to write
|
||||
*/
|
||||
void writeByte(atInt8 val) { writeUByte(val); }
|
||||
void writeVal(atInt8 val) { writeByte(val); }
|
||||
void writeValLittle(atInt8 val) { writeByte(val); }
|
||||
void writeValBig(atInt8 val) { writeByte(val); }
|
||||
void writeByte(int8_t val) { writeUByte(val); }
|
||||
void writeVal(int8_t val) { writeByte(val); }
|
||||
void writeValLittle(int8_t val) { writeByte(val); }
|
||||
void writeValBig(int8_t val) { writeByte(val); }
|
||||
|
||||
/** @brief Writes the given buffer with the specified length, buffers can be bigger than the length
|
||||
* however it's undefined behavior to try and write a buffer which is smaller than the given length.
|
||||
@@ -75,7 +75,7 @@ public:
|
||||
* @param data The buffer to write
|
||||
* @param length The amount to write
|
||||
*/
|
||||
virtual void writeUBytes(const atUint8* data, atUint64 length) = 0;
|
||||
virtual void writeUBytes(const uint8_t* data, uint64_t length) = 0;
|
||||
|
||||
/** @brief Writes the given buffer with the specified length, buffers can be bigger than the length
|
||||
* however it's undefined behavior to try and write a buffer which is smaller than the given length.
|
||||
@@ -83,14 +83,14 @@ public:
|
||||
* @param data The buffer to write
|
||||
* @param length The amount to write
|
||||
*/
|
||||
void writeBytes(const void* data, atUint64 length) { writeUBytes(reinterpret_cast<const atUint8*>(data), length); }
|
||||
void writeBytes(const void* data, uint64_t length) { writeUBytes(reinterpret_cast<const uint8_t*>(data), length); }
|
||||
|
||||
/** @brief Writes an Int16 to the buffer and advances the buffer.
|
||||
* It also swaps the bytes depending on the platform and Stream settings.
|
||||
*
|
||||
* @param val The value to write to the buffer
|
||||
*/
|
||||
void writeInt16(atInt16 val) {
|
||||
void writeInt16(int16_t val) {
|
||||
if (m_endian == Endian::Big) {
|
||||
utility::BigInt16(val);
|
||||
} else {
|
||||
@@ -98,60 +98,60 @@ public:
|
||||
}
|
||||
writeBytes(&val, sizeof(val));
|
||||
}
|
||||
void writeVal(atInt16 val) { writeInt16(val); }
|
||||
void writeVal(int16_t val) { writeInt16(val); }
|
||||
|
||||
/** @brief Writes an Int16 to the buffer and advances the buffer.
|
||||
* It also swaps the bytes against little depending on the platform.
|
||||
*
|
||||
* @param val The value to write to the buffer
|
||||
*/
|
||||
void writeInt16Little(atInt16 val) {
|
||||
void writeInt16Little(int16_t val) {
|
||||
utility::LittleInt16(val);
|
||||
writeBytes(&val, sizeof(val));
|
||||
}
|
||||
void writeValLittle(atInt16 val) { writeInt16Little(val); }
|
||||
void writeValLittle(int16_t val) { writeInt16Little(val); }
|
||||
|
||||
/** @brief Writes an Int16 to the buffer and advances the buffer.
|
||||
* It also swaps the bytes against big depending on the platform.
|
||||
*
|
||||
* @param val The value to write to the buffer
|
||||
*/
|
||||
void writeInt16Big(atInt16 val) {
|
||||
void writeInt16Big(int16_t val) {
|
||||
utility::BigInt16(val);
|
||||
writeBytes(&val, sizeof(val));
|
||||
}
|
||||
void writeValBig(atInt16 val) { writeInt16Big(val); }
|
||||
void writeValBig(int16_t val) { writeInt16Big(val); }
|
||||
|
||||
/** @brief Writes an Uint16 to the buffer and advances the buffer.
|
||||
* It also swaps the bytes depending on the platform and Stream settings
|
||||
*
|
||||
* @param val The value to write to the buffer
|
||||
*/
|
||||
void writeUint16(atUint16 val) { writeInt16(val); }
|
||||
void writeVal(atUint16 val) { writeUint16(val); }
|
||||
void writeUint16(uint16_t val) { writeInt16(val); }
|
||||
void writeVal(uint16_t val) { writeUint16(val); }
|
||||
|
||||
/** @brief Writes an Uint16 to the buffer and advances the buffer.
|
||||
* It also swaps the bytes against little depending on the platform
|
||||
*
|
||||
* @param val The value to write to the buffer
|
||||
*/
|
||||
void writeUint16Little(atUint16 val) { writeInt16Little(val); }
|
||||
void writeValLittle(atUint16 val) { writeUint16Little(val); }
|
||||
void writeUint16Little(uint16_t val) { writeInt16Little(val); }
|
||||
void writeValLittle(uint16_t val) { writeUint16Little(val); }
|
||||
|
||||
/** @brief Writes an Uint16 to the buffer and advances the buffer.
|
||||
* It also swaps the bytes against big depending on the platform
|
||||
*
|
||||
* @param val The value to write to the buffer
|
||||
*/
|
||||
void writeUint16Big(atUint16 val) { writeInt16Big(val); }
|
||||
void writeValBig(atUint16 val) { writeUint16Big(val); }
|
||||
void writeUint16Big(uint16_t val) { writeInt16Big(val); }
|
||||
void writeValBig(uint16_t val) { writeUint16Big(val); }
|
||||
|
||||
/** @brief Writes an Int32 to the buffer and advances the buffer.
|
||||
* It also swaps the bytes depending on the platform and Stream settings.
|
||||
*
|
||||
* @param val The value to write to the buffer
|
||||
*/
|
||||
void writeInt32(atInt32 val) {
|
||||
void writeInt32(int32_t val) {
|
||||
if (m_endian == Endian::Big) {
|
||||
utility::BigInt32(val);
|
||||
} else {
|
||||
@@ -159,60 +159,60 @@ public:
|
||||
}
|
||||
writeBytes(&val, sizeof(val));
|
||||
}
|
||||
void writeVal(atInt32 val) { writeInt32(val); }
|
||||
void writeVal(int32_t val) { writeInt32(val); }
|
||||
|
||||
/** @brief Writes an Int32 to the buffer and advances the buffer.
|
||||
* It also swaps the bytes against little depending on the platform.
|
||||
*
|
||||
* @param val The value to write to the buffer
|
||||
*/
|
||||
void writeInt32Little(atInt32 val) {
|
||||
void writeInt32Little(int32_t val) {
|
||||
utility::LittleInt32(val);
|
||||
writeBytes(&val, sizeof(val));
|
||||
}
|
||||
void writeValLittle(atInt32 val) { writeInt32Little(val); }
|
||||
void writeValLittle(int32_t val) { writeInt32Little(val); }
|
||||
|
||||
/** @brief Writes an Int32 to the buffer and advances the buffer.
|
||||
* It also swaps the bytes against big depending on the platform.
|
||||
*
|
||||
* @param val The value to write to the buffer
|
||||
*/
|
||||
void writeInt32Big(atInt32 val) {
|
||||
void writeInt32Big(int32_t val) {
|
||||
utility::BigInt32(val);
|
||||
writeBytes(&val, sizeof(val));
|
||||
}
|
||||
void writeValBig(atInt32 val) { writeInt32Big(val); }
|
||||
void writeValBig(int32_t val) { writeInt32Big(val); }
|
||||
|
||||
/** @brief Writes an Uint32 to the buffer and advances the buffer.
|
||||
* It also swaps the bytes depending on the platform and Stream settings.
|
||||
*
|
||||
* @param val The value to write to the buffer
|
||||
*/
|
||||
void writeUint32(atUint32 val) { writeInt32(val); }
|
||||
void writeVal(atUint32 val) { writeUint32(val); }
|
||||
void writeUint32(uint32_t val) { writeInt32(val); }
|
||||
void writeVal(uint32_t val) { writeUint32(val); }
|
||||
|
||||
/** @brief Writes an Uint32 to the buffer and advances the buffer.
|
||||
* It also swaps the bytes against little depending on the platform.
|
||||
*
|
||||
* @param val The value to write to the buffer
|
||||
*/
|
||||
void writeUint32Little(atUint32 val) { writeInt32Little(val); }
|
||||
void writeValLittle(atUint32 val) { writeUint32Little(val); }
|
||||
void writeUint32Little(uint32_t val) { writeInt32Little(val); }
|
||||
void writeValLittle(uint32_t val) { writeUint32Little(val); }
|
||||
|
||||
/** @brief Writes an Uint32 to the buffer and advances the buffer.
|
||||
* It also swaps the bytes against big depending on the platform.
|
||||
*
|
||||
* @param val The value to write to the buffer
|
||||
*/
|
||||
void writeUint32Big(atUint32 val) { writeInt32Big(val); }
|
||||
void writeValBig(atUint32 val) { writeUint32Big(val); }
|
||||
void writeUint32Big(uint32_t val) { writeInt32Big(val); }
|
||||
void writeValBig(uint32_t val) { writeUint32Big(val); }
|
||||
|
||||
/** @brief Writes an Int64 to the buffer and advances the buffer.
|
||||
* It also swaps the bytes depending on the platform and Stream settings.
|
||||
*
|
||||
* @param val The value to write to the buffer
|
||||
*/
|
||||
void writeInt64(atInt64 val) {
|
||||
void writeInt64(int64_t val) {
|
||||
if (m_endian == Endian::Big) {
|
||||
utility::BigInt64(val);
|
||||
} else {
|
||||
@@ -220,53 +220,53 @@ public:
|
||||
}
|
||||
writeBytes(&val, sizeof(val));
|
||||
}
|
||||
void writeVal(atInt64 val) { writeInt64(val); }
|
||||
void writeVal(int64_t val) { writeInt64(val); }
|
||||
|
||||
/** @brief Writes an Int64 to the buffer and advances the buffer.
|
||||
* It also swaps the bytes against little depending on the platform.
|
||||
*
|
||||
* @param val The value to write to the buffer
|
||||
*/
|
||||
void writeInt64Little(atInt64 val) {
|
||||
void writeInt64Little(int64_t val) {
|
||||
utility::LittleInt64(val);
|
||||
writeBytes(&val, sizeof(val));
|
||||
}
|
||||
void writeValLittle(atInt64 val) { writeInt64Little(val); }
|
||||
void writeValLittle(int64_t val) { writeInt64Little(val); }
|
||||
|
||||
/** @brief Writes an Int64 to the buffer and advances the buffer.
|
||||
* It also swaps the bytes against big depending on the platform.
|
||||
*
|
||||
* @param val The value to write to the buffer
|
||||
*/
|
||||
void writeInt64Big(atInt64 val) {
|
||||
void writeInt64Big(int64_t val) {
|
||||
utility::BigInt64(val);
|
||||
writeBytes(&val, sizeof(val));
|
||||
}
|
||||
void writeValBig(atInt64 val) { writeInt64Big(val); }
|
||||
void writeValBig(int64_t val) { writeInt64Big(val); }
|
||||
|
||||
/** @brief Writes an Uint64 to the buffer and advances the buffer.
|
||||
* It also swaps the bytes depending on the platform and Stream settings.
|
||||
*
|
||||
* @param val The value to write to the buffer
|
||||
*/
|
||||
void writeUint64(atUint64 val) { writeInt64(val); }
|
||||
void writeVal(atUint64 val) { writeUint64(val); }
|
||||
void writeUint64(uint64_t val) { writeInt64(val); }
|
||||
void writeVal(uint64_t val) { writeUint64(val); }
|
||||
|
||||
/** @brief Writes an Uint64 to the buffer and advances the buffer.
|
||||
* It also swaps the bytes against little depending on the platform.
|
||||
*
|
||||
* @param val The value to write to the buffer
|
||||
*/
|
||||
void writeUint64Little(atUint64 val) { writeInt64Little(val); }
|
||||
void writeValLittle(atUint64 val) { writeUint64Little(val); }
|
||||
void writeUint64Little(uint64_t val) { writeInt64Little(val); }
|
||||
void writeValLittle(uint64_t val) { writeUint64Little(val); }
|
||||
|
||||
/** @brief Writes an Uint64 to the buffer and advances the buffer.
|
||||
* It also swaps the bytes against big depending on the platform.
|
||||
*
|
||||
* @param val The value to write to the buffer
|
||||
*/
|
||||
void writeUint64Big(atUint64 val) { writeInt64Big(val); }
|
||||
void writeValBig(atUint64 val) { writeUint64Big(val); }
|
||||
void writeUint64Big(uint64_t val) { writeInt64Big(val); }
|
||||
void writeValBig(uint64_t val) { writeUint64Big(val); }
|
||||
|
||||
/** @brief Writes an float to the buffer and advances the buffer.
|
||||
* It also swaps the bytes depending on the platform and Stream settings.
|
||||
@@ -348,7 +348,7 @@ public:
|
||||
* @param val The value to write to the buffer
|
||||
*/
|
||||
void writeBool(bool val) {
|
||||
const auto u8Value = atUint8(val);
|
||||
const auto u8Value = uint8_t(val);
|
||||
writeUBytes(&u8Value, sizeof(u8Value));
|
||||
}
|
||||
void writeVal(bool val) { writeBool(val); }
|
||||
@@ -651,7 +651,7 @@ public:
|
||||
*
|
||||
* Endianness is set with setEndian
|
||||
*/
|
||||
void writeStringAsWString(std::string_view str, atInt32 fixedLen = -1) {
|
||||
void writeStringAsWString(std::string_view str, int32_t fixedLen = -1) {
|
||||
if (fixedLen == 0)
|
||||
return;
|
||||
std::string tmpStr = std::string("\xEF\xBB\xBF") + str.data();
|
||||
@@ -661,21 +661,21 @@ public:
|
||||
utf8proc_int32_t wc;
|
||||
utf8proc_ssize_t len = utf8proc_iterate(buf, -1, &wc);
|
||||
if (len < 0) {
|
||||
atWarning(FMT_STRING("invalid UTF-8 character while decoding"));
|
||||
atWarning("invalid UTF-8 character while decoding");
|
||||
return;
|
||||
}
|
||||
buf += len;
|
||||
if (wc != 0xFEFF)
|
||||
writeUint16(atUint16(wc));
|
||||
writeUint16(uint16_t(wc));
|
||||
}
|
||||
writeUint16(0);
|
||||
} else {
|
||||
for (atInt32 i = 0; i < fixedLen; ++i) {
|
||||
for (int32_t i = 0; i < fixedLen; ++i) {
|
||||
utf8proc_int32_t wc = 0;
|
||||
if (*buf) {
|
||||
utf8proc_ssize_t len = utf8proc_iterate(buf, -1, &wc);
|
||||
if (len < 0) {
|
||||
atWarning(FMT_STRING("invalid UTF-8 character while decoding"));
|
||||
atWarning("invalid UTF-8 character while decoding");
|
||||
return;
|
||||
}
|
||||
buf += len;
|
||||
@@ -686,7 +686,7 @@ public:
|
||||
continue;
|
||||
}
|
||||
|
||||
writeUint16(atUint16(wc));
|
||||
writeUint16(uint16_t(wc));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -699,7 +699,7 @@ public:
|
||||
*
|
||||
* Endianness is little
|
||||
*/
|
||||
void writeStringAsWStringLittle(std::string_view str, atInt32 fixedLen = -1) {
|
||||
void writeStringAsWStringLittle(std::string_view str, int32_t fixedLen = -1) {
|
||||
if (fixedLen == 0)
|
||||
return;
|
||||
std::string tmpStr = std::string("\xEF\xBB\xBF") + str.data();
|
||||
@@ -709,21 +709,21 @@ public:
|
||||
utf8proc_int32_t wc;
|
||||
utf8proc_ssize_t len = utf8proc_iterate(buf, -1, &wc);
|
||||
if (len < 0) {
|
||||
atWarning(FMT_STRING("invalid UTF-8 character while decoding"));
|
||||
atWarning("invalid UTF-8 character while decoding");
|
||||
return;
|
||||
}
|
||||
buf += len;
|
||||
if (wc != 0xFEFF)
|
||||
writeUint16Little(atUint16(wc));
|
||||
writeUint16Little(uint16_t(wc));
|
||||
}
|
||||
writeUint16Little(0);
|
||||
} else {
|
||||
for (atInt32 i = 0; i < fixedLen; ++i) {
|
||||
for (int32_t i = 0; i < fixedLen; ++i) {
|
||||
utf8proc_int32_t wc = 0;
|
||||
if (*buf) {
|
||||
utf8proc_ssize_t len = utf8proc_iterate(buf, -1, &wc);
|
||||
if (len < 0) {
|
||||
atWarning(FMT_STRING("invalid UTF-8 character while decoding"));
|
||||
atWarning("invalid UTF-8 character while decoding");
|
||||
return;
|
||||
}
|
||||
buf += len;
|
||||
@@ -734,7 +734,7 @@ public:
|
||||
continue;
|
||||
}
|
||||
|
||||
writeUint16Little(atUint16(wc));
|
||||
writeUint16Little(uint16_t(wc));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -747,7 +747,7 @@ public:
|
||||
*
|
||||
* Endianness is big
|
||||
*/
|
||||
void writeStringAsWStringBig(std::string_view str, atInt32 fixedLen = -1) {
|
||||
void writeStringAsWStringBig(std::string_view str, int32_t fixedLen = -1) {
|
||||
if (fixedLen == 0)
|
||||
return;
|
||||
|
||||
@@ -758,21 +758,21 @@ public:
|
||||
utf8proc_int32_t wc;
|
||||
utf8proc_ssize_t len = utf8proc_iterate(buf, -1, &wc);
|
||||
if (len < 0) {
|
||||
atWarning(FMT_STRING("invalid UTF-8 character while decoding"));
|
||||
atWarning("invalid UTF-8 character while decoding");
|
||||
return;
|
||||
}
|
||||
buf += len;
|
||||
if (wc != 0xFEFF)
|
||||
writeUint16Big(atUint16(wc));
|
||||
writeUint16Big(uint16_t(wc));
|
||||
}
|
||||
writeUint16Big(0);
|
||||
} else {
|
||||
for (atInt32 i = 0; i < fixedLen; ++i) {
|
||||
for (int32_t i = 0; i < fixedLen; ++i) {
|
||||
utf8proc_int32_t wc = 0;
|
||||
if (*buf) {
|
||||
utf8proc_ssize_t len = utf8proc_iterate(buf, -1, &wc);
|
||||
if (len < 0) {
|
||||
atWarning(FMT_STRING("invalid UTF-8 character while decoding"));
|
||||
atWarning("invalid UTF-8 character while decoding");
|
||||
return;
|
||||
}
|
||||
buf += len;
|
||||
@@ -783,7 +783,7 @@ public:
|
||||
continue;
|
||||
}
|
||||
|
||||
writeUint16Big(atUint16(wc));
|
||||
writeUint16Big(uint16_t(wc));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -793,12 +793,12 @@ public:
|
||||
* @param str The string to write to the buffer
|
||||
* @param fixedLen If not -1, the number of characters to zero-fill string to
|
||||
*/
|
||||
void writeString(std::string_view str, atInt32 fixedLen = -1) {
|
||||
void writeString(std::string_view str, int32_t fixedLen = -1) {
|
||||
if (fixedLen == 0)
|
||||
return;
|
||||
|
||||
if (fixedLen < 0) {
|
||||
for (atUint8 c : str) {
|
||||
for (uint8_t c : str) {
|
||||
writeUByte(c);
|
||||
|
||||
if (c == '\0')
|
||||
@@ -807,8 +807,8 @@ public:
|
||||
writeUByte(0);
|
||||
} else {
|
||||
auto it = str.begin();
|
||||
for (atInt32 i = 0; i < fixedLen; ++i) {
|
||||
atUint8 chr;
|
||||
for (int32_t i = 0; i < fixedLen; ++i) {
|
||||
uint8_t chr;
|
||||
if (it == str.end())
|
||||
chr = 0;
|
||||
else
|
||||
@@ -826,12 +826,12 @@ public:
|
||||
*
|
||||
* Endianness is set with setEndian
|
||||
*/
|
||||
void writeWString(std::wstring_view str, atInt32 fixedLen = -1) {
|
||||
void writeWString(std::wstring_view str, int32_t fixedLen = -1) {
|
||||
if (fixedLen == 0)
|
||||
return;
|
||||
|
||||
if (fixedLen < 0) {
|
||||
for (atUint16 c : str) {
|
||||
for (uint16_t c : str) {
|
||||
writeUint16(c);
|
||||
|
||||
if (c == L'\0')
|
||||
@@ -840,8 +840,8 @@ public:
|
||||
writeUint16(0);
|
||||
} else {
|
||||
auto it = str.begin();
|
||||
for (atInt32 i = 0; i < fixedLen; ++i) {
|
||||
atUint16 chr;
|
||||
for (int32_t i = 0; i < fixedLen; ++i) {
|
||||
uint16_t chr;
|
||||
if (it == str.end())
|
||||
chr = 0;
|
||||
else
|
||||
@@ -859,12 +859,12 @@ public:
|
||||
*
|
||||
* Endianness is little
|
||||
*/
|
||||
void writeWStringLittle(std::wstring_view str, atInt32 fixedLen = -1) {
|
||||
void writeWStringLittle(std::wstring_view str, int32_t fixedLen = -1) {
|
||||
if (fixedLen == 0)
|
||||
return;
|
||||
|
||||
if (fixedLen < 0) {
|
||||
for (atUint16 c : str) {
|
||||
for (uint16_t c : str) {
|
||||
writeUint16Little(c);
|
||||
|
||||
if (c == L'\0')
|
||||
@@ -873,8 +873,8 @@ public:
|
||||
writeUint16Little(0);
|
||||
} else {
|
||||
auto it = str.begin();
|
||||
for (atInt32 i = 0; i < fixedLen; ++i) {
|
||||
atUint16 chr;
|
||||
for (int32_t i = 0; i < fixedLen; ++i) {
|
||||
uint16_t chr;
|
||||
if (it == str.end())
|
||||
chr = 0;
|
||||
else
|
||||
@@ -892,7 +892,7 @@ public:
|
||||
*
|
||||
* Endianness is big
|
||||
*/
|
||||
void writeWStringBig(std::wstring_view str, atInt32 fixedLen = -1) {
|
||||
void writeWStringBig(std::wstring_view str, int32_t fixedLen = -1) {
|
||||
if (fixedLen == 0)
|
||||
return;
|
||||
|
||||
@@ -906,7 +906,7 @@ public:
|
||||
writeUint16Big(0);
|
||||
} else {
|
||||
auto it = str.begin();
|
||||
for (atInt32 i = 0; i < fixedLen; ++i) {
|
||||
for (int32_t i = 0; i < fixedLen; ++i) {
|
||||
wchar_t chr;
|
||||
if (it == str.end())
|
||||
chr = 0;
|
||||
@@ -925,7 +925,7 @@ public:
|
||||
*
|
||||
* Endianness is big
|
||||
*/
|
||||
void writeU16StringBig(std::u16string_view str, atInt32 fixedLen = -1) {
|
||||
void writeU16StringBig(std::u16string_view str, int32_t fixedLen = -1) {
|
||||
if (fixedLen == 0)
|
||||
return;
|
||||
|
||||
@@ -939,7 +939,7 @@ public:
|
||||
writeUint16Big(0);
|
||||
} else {
|
||||
auto it = str.begin();
|
||||
for (atInt32 i = 0; i < fixedLen; ++i) {
|
||||
for (int32_t i = 0; i < fixedLen; ++i) {
|
||||
char16_t chr;
|
||||
if (it == str.end())
|
||||
chr = 0;
|
||||
@@ -958,7 +958,7 @@ public:
|
||||
*
|
||||
* Endianness is big
|
||||
*/
|
||||
void writeU32StringBig(std::u32string_view str, atInt32 fixedLen = -1) {
|
||||
void writeU32StringBig(std::u32string_view str, int32_t fixedLen = -1) {
|
||||
if (fixedLen == 0)
|
||||
return;
|
||||
|
||||
@@ -972,7 +972,7 @@ public:
|
||||
writeUint32Big(0);
|
||||
} else {
|
||||
auto it = str.begin();
|
||||
for (atInt32 i = 0; i < fixedLen; ++i) {
|
||||
for (int32_t i = 0; i < fixedLen; ++i) {
|
||||
char32_t chr;
|
||||
if (it == str.end())
|
||||
chr = 0;
|
||||
@@ -984,15 +984,15 @@ public:
|
||||
}
|
||||
void writeValBig(std::u32string_view val) { writeU32StringBig(val); }
|
||||
|
||||
void fill(atUint8 val, atUint64 length) {
|
||||
void fill(uint8_t val, uint64_t length) {
|
||||
if (length == 0)
|
||||
return;
|
||||
|
||||
const std::vector<atUint8> tmp(length, val);
|
||||
const std::vector<uint8_t> tmp(length, val);
|
||||
writeUBytes(tmp.data(), length);
|
||||
}
|
||||
|
||||
void fill(atInt8 val, atUint64 length) { fill((atUint8)val, length); }
|
||||
void fill(int8_t val, uint64_t length) { fill((uint8_t)val, length); }
|
||||
|
||||
/** @brief Performs automatic std::vector enumeration writes using numeric type T
|
||||
* @param vector The std::vector read from when writing data
|
||||
|
||||
@@ -19,7 +19,7 @@ public:
|
||||
|
||||
MCFile();
|
||||
|
||||
static atUint8* unscramble(atUint8* data, atUint64 length);
|
||||
static uint8_t* unscramble(uint8_t* data, uint64_t length);
|
||||
|
||||
private:
|
||||
MCSlot* m_slots[3];
|
||||
|
||||
@@ -23,7 +23,7 @@ public:
|
||||
* \param data The existing buffer
|
||||
* \param length The length of the existing buffer
|
||||
*/
|
||||
MCFileReader(atUint8*, atUint64);
|
||||
MCFileReader(uint8_t*, uint64_t);
|
||||
|
||||
/*!
|
||||
* \brief This constructor creates an instance from a file on disk.
|
||||
|
||||
@@ -24,7 +24,7 @@ public:
|
||||
* \param data The existing buffer
|
||||
* \param length The length of the existing buffer
|
||||
*/
|
||||
MCFileWriter(atUint8*, atUint64);
|
||||
MCFileWriter(uint8_t*, uint64_t);
|
||||
|
||||
/*!
|
||||
* \brief This constructor creates an instance from a file on disk.
|
||||
@@ -40,10 +40,10 @@ public:
|
||||
*/
|
||||
void writeFile(MCFile* file);
|
||||
|
||||
static atUint16 calculateChecksum(atUint8* data, atUint32 length);
|
||||
static uint16_t calculateChecksum(uint8_t* data, uint32_t length);
|
||||
|
||||
private:
|
||||
atUint16 calculateSlotChecksum(atUint32 game);
|
||||
uint16_t calculateSlotChecksum(uint32_t game);
|
||||
};
|
||||
|
||||
} // namespace io
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
namespace athena {
|
||||
class MCSlot : public ZQuestFile {
|
||||
public:
|
||||
MCSlot(std::unique_ptr<atUint8[]>&& data, atUint32 length);
|
||||
MCSlot(std::unique_ptr<uint8_t[]>&& data, uint32_t length);
|
||||
};
|
||||
|
||||
} // namespace athena
|
||||
|
||||
@@ -28,26 +28,26 @@ public:
|
||||
* \param takeOwnership Memory will be freed with the reader if set.
|
||||
* \param globalErr Whether or not global errors are enabled.
|
||||
*/
|
||||
explicit MemoryReader(const void* data, atUint64 length, bool takeOwnership = false, bool globalErr = true);
|
||||
explicit MemoryReader(const void* data, uint64_t length, bool takeOwnership = false, bool globalErr = true);
|
||||
|
||||
/*! \brief Sets the buffers position relative to the specified position.<br />
|
||||
* It seeks relative to the current position by default.
|
||||
* \param position where in the buffer to seek
|
||||
* \param origin The Origin to seek \sa SeekOrigin
|
||||
*/
|
||||
void seek(atInt64 position, SeekOrigin origin = SeekOrigin::Current) override;
|
||||
void seek(int64_t position, SeekOrigin origin = SeekOrigin::Current) override;
|
||||
|
||||
/*! \brief Returns the current position in the stream.
|
||||
*
|
||||
* \return Int64 The current position in the stream.
|
||||
*/
|
||||
atUint64 position() const override { return m_position; }
|
||||
uint64_t position() const override { return m_position; }
|
||||
|
||||
/*! \brief Returns whether or not the stream is at the end.
|
||||
*
|
||||
* \return bool True if at end; False otherwise.
|
||||
*/
|
||||
atUint64 length() const override { return m_length; }
|
||||
uint64_t length() const override { return m_length; }
|
||||
|
||||
/*! \brief Sets the buffer to the given one, deleting the current one.<br />
|
||||
* <b>BEWARE:</b> As this deletes the current buffer it WILL cause a loss of data
|
||||
@@ -59,7 +59,7 @@ public:
|
||||
* \param takeOwnership Memory will be freed with the reader if set
|
||||
* \throw IOException
|
||||
*/
|
||||
void setData(const atUint8* data, atUint64 length, bool takeOwnership = false);
|
||||
void setData(const uint8_t* data, uint64_t length, bool takeOwnership = false);
|
||||
|
||||
/*! \brief Returns a copy of the current buffer.<br />
|
||||
* Changes to the copy do not affect the buffer so it's perfectly safe to
|
||||
@@ -68,19 +68,19 @@ public:
|
||||
* as Stream now owns the address, this is done to keep memory usage down.
|
||||
* \return Uint8* The copy of the buffer.
|
||||
*/
|
||||
atUint8* data() const;
|
||||
uint8_t* data() const;
|
||||
|
||||
/*! \brief Reads a specified number of bytes to user-allocated buffer
|
||||
* \param buf User-allocated buffer pointer
|
||||
* \param len Length to read
|
||||
* \return Number of bytes read
|
||||
*/
|
||||
atUint64 readUBytesToBuf(void* buf, atUint64 len) override;
|
||||
uint64_t readUBytesToBuf(void* buf, uint64_t len) override;
|
||||
|
||||
protected:
|
||||
const void* m_data = nullptr;
|
||||
atUint64 m_length = 0;
|
||||
atUint64 m_position = 0;
|
||||
uint64_t m_length = 0;
|
||||
uint64_t m_position = 0;
|
||||
bool m_owns = false;
|
||||
bool m_globalErr = true;
|
||||
};
|
||||
@@ -92,7 +92,7 @@ public:
|
||||
* \param data The existing buffer
|
||||
* \param length The length of the existing buffer
|
||||
*/
|
||||
explicit MemoryCopyReader(const void* data, atUint64 length);
|
||||
explicit MemoryCopyReader(const void* data, uint64_t length);
|
||||
|
||||
/*! \brief This constructor creates an instance from a file on disk.
|
||||
*
|
||||
@@ -100,11 +100,11 @@ public:
|
||||
*/
|
||||
explicit MemoryCopyReader(const std::string& filename) : m_filepath(filename) { loadData(); }
|
||||
|
||||
void setData(const atUint8* data, atUint64 length);
|
||||
void setData(const uint8_t* data, uint64_t length);
|
||||
|
||||
protected:
|
||||
void loadData();
|
||||
std::unique_ptr<atUint8[]> m_dataCopy;
|
||||
std::unique_ptr<uint8_t[]> m_dataCopy;
|
||||
std::string m_filepath; //!< Path to the target file
|
||||
};
|
||||
|
||||
|
||||
@@ -26,26 +26,26 @@ public:
|
||||
* @param takeOwnership Whether or not this writer takes ownership of the supplied data buffer.
|
||||
* If true, the buffer will be deleted by this when the destructor executes.
|
||||
*/
|
||||
explicit MemoryWriter(atUint8* data, atUint64 length, bool takeOwnership = false);
|
||||
explicit MemoryWriter(uint8_t* data, uint64_t length, bool takeOwnership = false);
|
||||
|
||||
/*! @brief Sets the buffers position relative to the specified position.<br />
|
||||
* It seeks relative to the current position by default.
|
||||
* @param position where in the buffer to seek
|
||||
* @param origin The Origin to seek @sa SeekOrigin
|
||||
*/
|
||||
void seek(atInt64 position, SeekOrigin origin = SeekOrigin::Current) override;
|
||||
void seek(int64_t position, SeekOrigin origin = SeekOrigin::Current) override;
|
||||
|
||||
/*! @brief Returns the current position in the stream.
|
||||
*
|
||||
* @return Int64 The current position in the stream.
|
||||
*/
|
||||
atUint64 position() const override { return m_position; }
|
||||
uint64_t position() const override { return m_position; }
|
||||
|
||||
/*! @brief Returns the length of the stream.
|
||||
*
|
||||
* @return Int64 The length of the stream.
|
||||
*/
|
||||
atUint64 length() const override { return m_length; }
|
||||
uint64_t length() const override { return m_length; }
|
||||
|
||||
bool isOpen() const { return true; }
|
||||
|
||||
@@ -54,14 +54,14 @@ public:
|
||||
* @param length The length of the new buffer.
|
||||
* @param takeOwnership Whether the Stream now owns the buffer.
|
||||
*/
|
||||
void setData(atUint8* data, atUint64 length, bool takeOwnership = false);
|
||||
void setData(uint8_t* data, uint64_t length, bool takeOwnership = false);
|
||||
|
||||
/*! @brief Returns a copy of the current buffer.<br />
|
||||
* Changes to the copy do not affect the buffer so it's perfectly safe to
|
||||
* directly edit the buffer and use setData to set the new information.<br />
|
||||
* @return Uint8* The copy of the buffer.
|
||||
*/
|
||||
atUint8* data() const;
|
||||
uint8_t* data() const;
|
||||
|
||||
/*! @brief Sets the target file
|
||||
*
|
||||
@@ -87,13 +87,13 @@ public:
|
||||
* @param data The buffer to write
|
||||
* @param length The amount to write
|
||||
*/
|
||||
void writeUBytes(const atUint8* data, atUint64 length) override;
|
||||
void writeUBytes(const uint8_t* data, uint64_t length) override;
|
||||
|
||||
protected:
|
||||
MemoryWriter() = default;
|
||||
atUint8* m_data = nullptr;
|
||||
atUint64 m_length = 0;
|
||||
atUint64 m_position = 0;
|
||||
uint8_t* m_data = nullptr;
|
||||
uint64_t m_length = 0;
|
||||
uint64_t m_position = 0;
|
||||
bool m_bufferOwned = false;
|
||||
std::string m_filepath; //!< Path to the target file
|
||||
};
|
||||
@@ -105,7 +105,7 @@ public:
|
||||
* @param data The existing buffer
|
||||
* @param length The length of the existing buffer
|
||||
*/
|
||||
explicit MemoryCopyWriter(atUint8* data = nullptr, atUint64 length = 0x10);
|
||||
explicit MemoryCopyWriter(uint8_t* data = nullptr, uint64_t length = 0x10);
|
||||
|
||||
/*! @brief This constructor creates an instance from a file on disk.
|
||||
*
|
||||
@@ -118,7 +118,7 @@ public:
|
||||
* @param position where in the buffer to seek
|
||||
* @param origin The Origin to seek @sa SeekOrigin
|
||||
*/
|
||||
void seek(atInt64 position, SeekOrigin origin = SeekOrigin::Current) override;
|
||||
void seek(int64_t position, SeekOrigin origin = SeekOrigin::Current) override;
|
||||
|
||||
/*! @brief Sets the buffer to the given one, deleting the current one.<br />
|
||||
* <b>BEWARE:</b> As this deletes the current buffer it WILL cause a loss of data
|
||||
@@ -129,7 +129,7 @@ public:
|
||||
* @param length The length of the new buffer.
|
||||
* @throw IOException
|
||||
*/
|
||||
void setData(const atUint8* data, atUint64 length);
|
||||
void setData(const uint8_t* data, uint64_t length);
|
||||
|
||||
/*! @brief Writes the given buffer with the specified length, buffers can be bigger than the length
|
||||
* however it's undefined behavior to try and write a buffer which is smaller than the given length.
|
||||
@@ -137,13 +137,13 @@ public:
|
||||
* @param data The buffer to write
|
||||
* @param length The amount to write
|
||||
*/
|
||||
void writeUBytes(const atUint8* data, atUint64 length) override;
|
||||
void writeUBytes(const uint8_t* data, uint64_t length) override;
|
||||
|
||||
protected:
|
||||
std::unique_ptr<atUint8[]> m_dataCopy;
|
||||
std::unique_ptr<uint8_t[]> m_dataCopy;
|
||||
|
||||
private:
|
||||
void resize(atUint64 newSize);
|
||||
void resize(uint64_t newSize);
|
||||
};
|
||||
|
||||
} // namespace athena::io
|
||||
|
||||
@@ -19,7 +19,7 @@ public:
|
||||
~SkywardSwordFile();
|
||||
|
||||
void addQuest(SkywardSwordQuest* q);
|
||||
SkywardSwordQuest* quest(atUint32 id);
|
||||
SkywardSwordQuest* quest(uint32_t id);
|
||||
std::vector<SkywardSwordQuest*> questList() const;
|
||||
|
||||
void setRegion(Region region);
|
||||
@@ -29,7 +29,7 @@ private:
|
||||
Region m_region;
|
||||
// A vector is a bit overkill
|
||||
std::vector<SkywardSwordQuest*> m_quests;
|
||||
atUint32 m_numQuests;
|
||||
uint32_t m_numQuests;
|
||||
};
|
||||
|
||||
} // namespace athena
|
||||
|
||||
@@ -7,7 +7,7 @@ class SkywardSwordFile;
|
||||
namespace io {
|
||||
class SkywardSwordFileReader : public MemoryCopyReader {
|
||||
public:
|
||||
SkywardSwordFileReader(atUint8* data, atUint64 length);
|
||||
SkywardSwordFileReader(uint8_t* data, uint64_t length);
|
||||
SkywardSwordFileReader(const std::string& filename);
|
||||
|
||||
SkywardSwordFile* read();
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace io {
|
||||
|
||||
class SkywardSwordFileWriter : public MemoryCopyWriter {
|
||||
public:
|
||||
SkywardSwordFileWriter(atUint8* data, atUint64 len);
|
||||
SkywardSwordFileWriter(uint8_t* data, uint64_t len);
|
||||
SkywardSwordFileWriter(const std::string& filename);
|
||||
|
||||
void write(SkywardSwordFile* file);
|
||||
|
||||
@@ -11,40 +11,40 @@ class SkywardSwordQuest : public ZQuestFile {
|
||||
public:
|
||||
enum AmmoType { Arrows, Bombs, Seeds };
|
||||
|
||||
SkywardSwordQuest(std::unique_ptr<atUint8[]>&& data, atUint32 len);
|
||||
SkywardSwordQuest(std::unique_ptr<uint8_t[]>&& data, uint32_t len);
|
||||
|
||||
void setPlayerName(const std::string& name);
|
||||
std::string playerName() const;
|
||||
|
||||
void setRupeeCount(atUint16 value);
|
||||
atUint16 rupeeCount();
|
||||
void setAmmoCount(AmmoType type, atUint32 count);
|
||||
atUint32 ammoCount(AmmoType type);
|
||||
void setMaxHP(atUint16 val);
|
||||
atUint16 maxHP();
|
||||
void setRupeeCount(uint16_t value);
|
||||
uint16_t rupeeCount();
|
||||
void setAmmoCount(AmmoType type, uint32_t count);
|
||||
uint32_t ammoCount(AmmoType type);
|
||||
void setMaxHP(uint16_t val);
|
||||
uint16_t maxHP();
|
||||
float maxHearts();
|
||||
void setSpawnHP(atUint16 val);
|
||||
atUint16 spawnHP();
|
||||
void setSpawnHP(uint16_t val);
|
||||
uint16_t spawnHP();
|
||||
float spawnHearts();
|
||||
void setCurrentHP(atUint16 val);
|
||||
atUint16 currentHP();
|
||||
void setCurrentHP(uint16_t val);
|
||||
uint16_t currentHP();
|
||||
float currentHearts();
|
||||
std::string currentLocation();
|
||||
std::string currentArea();
|
||||
std::string currentLocationCopy();
|
||||
|
||||
void setSkipData(std::unique_ptr<atUint8[]>&& data);
|
||||
atUint8* skipData() const;
|
||||
void setSkipData(std::unique_ptr<uint8_t[]>&& data);
|
||||
uint8_t* skipData() const;
|
||||
|
||||
atUint32 slotChecksum();
|
||||
atUint32 skipChecksum();
|
||||
uint32_t slotChecksum();
|
||||
uint32_t skipChecksum();
|
||||
void fixChecksums();
|
||||
|
||||
void setNew(bool isNew);
|
||||
bool isNew() const;
|
||||
|
||||
private:
|
||||
std::unique_ptr<atUint8[]> m_skipData;
|
||||
std::unique_ptr<uint8_t[]> m_skipData;
|
||||
};
|
||||
|
||||
} // namespace athena
|
||||
|
||||
@@ -30,23 +30,23 @@ public:
|
||||
int stateId(int index) const;
|
||||
void setStateIds(std::vector<int> ids);
|
||||
std::vector<int> stateIds() const;
|
||||
atUint32 stateCount() const;
|
||||
void setCurrentState(atUint32 id);
|
||||
atUint32 currentState() const;
|
||||
uint32_t stateCount() const;
|
||||
void setCurrentState(uint32_t id);
|
||||
uint32_t currentState() const;
|
||||
|
||||
bool addFrame(SpriteFrame* Frame);
|
||||
bool removeFrame(SpriteFrame* Frame);
|
||||
SpriteFrame* Frame(atUint32 id);
|
||||
void setFrame(atUint32 id);
|
||||
SpriteFrame* Frame(uint32_t id);
|
||||
void setFrame(uint32_t id);
|
||||
void setFrames(std::vector<SpriteFrame*> frames);
|
||||
atUint32 frameCount() const;
|
||||
uint32_t frameCount() const;
|
||||
|
||||
std::vector<SpriteFrame*> frames() const;
|
||||
|
||||
SpriteFile* container() const;
|
||||
|
||||
void setCurrentFrame(SpriteFrame* frame);
|
||||
void setCurrentFrame(atUint32 id);
|
||||
void setCurrentFrame(uint32_t id);
|
||||
SpriteFrame* currentFrame() const;
|
||||
|
||||
void advanceFrame();
|
||||
@@ -61,8 +61,8 @@ private:
|
||||
Vector2Df m_position;
|
||||
std::vector<int> m_stateIds; //!< Stores the texture id's for each state.
|
||||
std::vector<SpriteFrame*> m_frames;
|
||||
atUint32 m_currentState;
|
||||
atUint32 m_currentFrame;
|
||||
uint32_t m_currentState;
|
||||
uint32_t m_currentFrame;
|
||||
};
|
||||
|
||||
} // namespace athena::Sakura
|
||||
|
||||
@@ -19,32 +19,32 @@ public:
|
||||
/*!
|
||||
* \brief Major
|
||||
*/
|
||||
static const atUint32 Major;
|
||||
static const uint32_t Major;
|
||||
|
||||
/*!
|
||||
* \brief Minor
|
||||
*/
|
||||
static const atUint32 Minor;
|
||||
static const uint32_t Minor;
|
||||
|
||||
/*!
|
||||
* \brief Revision
|
||||
*/
|
||||
static const atUint32 Revision;
|
||||
static const uint32_t Revision;
|
||||
|
||||
/*!
|
||||
* \brief Patch
|
||||
*/
|
||||
static const atUint32 Build;
|
||||
static const uint32_t Build;
|
||||
|
||||
/*!
|
||||
* \brief Version
|
||||
*/
|
||||
static const atUint32 Version;
|
||||
static const uint32_t Version;
|
||||
|
||||
/*!
|
||||
* \brief Magic
|
||||
*/
|
||||
static const atUint32 Magic;
|
||||
static const uint32_t Magic;
|
||||
|
||||
/*!
|
||||
* \brief SSprite
|
||||
@@ -58,7 +58,7 @@ public:
|
||||
* \param originX
|
||||
* \param originY
|
||||
*/
|
||||
SpriteFile(atUint32 width, atUint32 height, float originX, float originY);
|
||||
SpriteFile(uint32_t width, uint32_t height, float originX, float originY);
|
||||
|
||||
/*!
|
||||
* \brief SSpriteFile
|
||||
@@ -84,7 +84,7 @@ public slots:
|
||||
* \param width
|
||||
* \param height
|
||||
*/
|
||||
void setSize(atUint32 width, atUint32 height);
|
||||
void setSize(uint32_t width, uint32_t height);
|
||||
|
||||
/*!
|
||||
* \brief setSize
|
||||
@@ -102,13 +102,13 @@ public slots:
|
||||
* \brief width
|
||||
* \return
|
||||
*/
|
||||
atUint32 width() const;
|
||||
uint32_t width() const;
|
||||
|
||||
/*!
|
||||
* \brief height
|
||||
* \return
|
||||
*/
|
||||
atUint32 height() const;
|
||||
uint32_t height() const;
|
||||
|
||||
/*!
|
||||
* \brief setOrigin
|
||||
@@ -158,10 +158,10 @@ public slots:
|
||||
* \param id
|
||||
* \return
|
||||
*/
|
||||
STexture* texture(atUint32 id);
|
||||
STexture* texture(uint32_t id);
|
||||
std::vector<STexture*> textures() const;
|
||||
|
||||
atUint32 textureCount() const;
|
||||
uint32_t textureCount() const;
|
||||
/*!
|
||||
* \brief setTextures
|
||||
* \param textures
|
||||
@@ -177,7 +177,7 @@ public slots:
|
||||
Sprite* sprite(const std::string& name);
|
||||
std::unordered_map<std::string, Sprite*> sprites() const;
|
||||
|
||||
atUint32 spriteCount() const;
|
||||
uint32_t spriteCount() const;
|
||||
|
||||
private:
|
||||
std::vector<STexture*> m_textures;
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace io {
|
||||
|
||||
class SpriteFileReader : public MemoryCopyReader {
|
||||
public:
|
||||
SpriteFileReader(atUint8* data, atUint64 length);
|
||||
SpriteFileReader(uint8_t* data, uint64_t length);
|
||||
SpriteFileReader(const std::string& filepath);
|
||||
|
||||
Sakura::SpriteFile* readFile();
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace io {
|
||||
|
||||
class SpriteFileWriter : public MemoryCopyWriter {
|
||||
public:
|
||||
SpriteFileWriter(atUint8* data, atUint64 length);
|
||||
SpriteFileWriter(uint8_t* data, uint64_t length);
|
||||
|
||||
SpriteFileWriter(std::string_view filepath);
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ public:
|
||||
void setParts(std::vector<SpritePart*> parts);
|
||||
std::vector<SpritePart*> parts() const;
|
||||
|
||||
atUint32 partCount() const;
|
||||
uint32_t partCount() const;
|
||||
|
||||
void setRoot(Sprite* root);
|
||||
Sprite* root() const;
|
||||
|
||||
@@ -56,7 +56,7 @@ public:
|
||||
* \param width
|
||||
* \param height
|
||||
*/
|
||||
void setSize(atUint32 width, atUint32 height);
|
||||
void setSize(uint32_t width, uint32_t height);
|
||||
|
||||
/*!
|
||||
* \brief setSize
|
||||
@@ -105,6 +105,6 @@ private:
|
||||
Vector2Di m_size;
|
||||
bool m_flippedH;
|
||||
bool m_flippedV;
|
||||
atUint32 m_frameIndex;
|
||||
uint32_t m_frameIndex;
|
||||
};
|
||||
} // namespace athena::Sakura
|
||||
|
||||
@@ -3,15 +3,6 @@
|
||||
#include <cinttypes>
|
||||
#include <cstdint>
|
||||
|
||||
using atInt8 = std::int8_t;
|
||||
using atUint8 = std::uint8_t;
|
||||
using atInt16 = std::int16_t;
|
||||
using atUint16 = std::uint16_t;
|
||||
using atInt32 = std::int32_t;
|
||||
using atUint32 = std::uint32_t;
|
||||
using atInt64 = std::int64_t;
|
||||
using atUint64 = std::uint64_t;
|
||||
|
||||
// Vector types
|
||||
#include "simd/simd.hpp"
|
||||
struct atVec2f {
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "athena/Types.hpp"
|
||||
|
||||
namespace athena::utility {
|
||||
inline bool isEmpty(atInt8* buf, atUint32 size) { return !std::memcmp(buf, buf + 1, size - 1); }
|
||||
inline bool isEmpty(int8_t* buf, uint32_t size) { return !std::memcmp(buf, buf + 1, size - 1); }
|
||||
#if _WIN32
|
||||
constexpr bool isSystemBigEndian() { return false; }
|
||||
#else
|
||||
@@ -25,7 +25,7 @@ constexpr ::athena::Endian NotSystemEndian = isSystemBigEndian() ? ::athena::End
|
||||
#define BSWAP_CONSTEXPR constexpr
|
||||
#endif
|
||||
|
||||
BSWAP_CONSTEXPR atInt16 swap16(atInt16 val) {
|
||||
BSWAP_CONSTEXPR int16_t swap16(int16_t val) {
|
||||
#if __GNUC__
|
||||
return __builtin_bswap16(val);
|
||||
#elif _MSC_VER
|
||||
@@ -34,8 +34,8 @@ BSWAP_CONSTEXPR atInt16 swap16(atInt16 val) {
|
||||
return (val = (val << 8) | ((val >> 8) & 0xFF));
|
||||
#endif
|
||||
}
|
||||
BSWAP_CONSTEXPR atUint16 swapU16(atUint16 val) { return (atUint16)swap16(val); }
|
||||
BSWAP_CONSTEXPR atInt32 swap32(atInt32 val) {
|
||||
BSWAP_CONSTEXPR uint16_t swapU16(uint16_t val) { return (uint16_t)swap16(val); }
|
||||
BSWAP_CONSTEXPR int32_t swap32(int32_t val) {
|
||||
#if __GNUC__
|
||||
return __builtin_bswap32(val);
|
||||
#elif _MSC_VER
|
||||
@@ -46,8 +46,8 @@ BSWAP_CONSTEXPR atInt32 swap32(atInt32 val) {
|
||||
return val;
|
||||
#endif
|
||||
}
|
||||
BSWAP_CONSTEXPR atUint32 swapU32(atUint32 val) { return (atUint32)swap32(val); }
|
||||
BSWAP_CONSTEXPR atInt64 swap64(atInt64 val) {
|
||||
BSWAP_CONSTEXPR uint32_t swapU32(uint32_t val) { return (uint32_t)swap32(val); }
|
||||
BSWAP_CONSTEXPR int64_t swap64(int64_t val) {
|
||||
#if __GNUC__
|
||||
return __builtin_bswap64(val);
|
||||
#elif _MSC_VER
|
||||
@@ -60,90 +60,90 @@ BSWAP_CONSTEXPR atInt64 swap64(atInt64 val) {
|
||||
(((atInt64)(val)&0x000000000000FF00ULL) << 40) | (((atInt64)(val)&0x00000000000000FFULL) << 56))));
|
||||
#endif
|
||||
}
|
||||
BSWAP_CONSTEXPR atUint64 swapU64(atUint64 val) { return (atUint64)swap64(val); }
|
||||
BSWAP_CONSTEXPR uint64_t swapU64(uint64_t val) { return (uint64_t)swap64(val); }
|
||||
BSWAP_CONSTEXPR float swapFloat(float val) {
|
||||
union { float f; atInt32 i; } uval1 = {val};
|
||||
union { atInt32 i; float f; } uval2 = {swap32(uval1.i)};
|
||||
union { float f; int32_t i; } uval1 = {val};
|
||||
union { int32_t i; float f; } uval2 = {swap32(uval1.i)};
|
||||
return uval2.f;
|
||||
}
|
||||
BSWAP_CONSTEXPR double swapDouble(double val) {
|
||||
union { double f; atInt64 i; } uval1 = {val};
|
||||
union { atInt64 i; double f; } uval2 = {swap64(uval1.i)};
|
||||
union { double f; int64_t i; } uval1 = {val};
|
||||
union { int64_t i; double f; } uval2 = {swap64(uval1.i)};
|
||||
return uval2.f;
|
||||
}
|
||||
BSWAP_CONSTEXPR atInt16 LittleInt16(atInt16& val) {
|
||||
BSWAP_CONSTEXPR int16_t LittleInt16(int16_t& val) {
|
||||
if constexpr (athena::utility::isSystemBigEndian())
|
||||
val = athena::utility::swap16(val);
|
||||
|
||||
return val;
|
||||
}
|
||||
BSWAP_CONSTEXPR atUint16 LittleUint16(atUint16& val) {
|
||||
atInt16 ret = val;
|
||||
BSWAP_CONSTEXPR uint16_t LittleUint16(uint16_t& val) {
|
||||
int16_t ret = val;
|
||||
LittleInt16(ret);
|
||||
val = ret;
|
||||
|
||||
return val;
|
||||
}
|
||||
BSWAP_CONSTEXPR atInt16 BigInt16(atInt16& val) {
|
||||
BSWAP_CONSTEXPR int16_t BigInt16(int16_t& val) {
|
||||
if constexpr (!athena::utility::isSystemBigEndian())
|
||||
val = athena::utility::swap16(val);
|
||||
|
||||
return val;
|
||||
}
|
||||
BSWAP_CONSTEXPR atUint16 BigUint16(atUint16& val) {
|
||||
atInt16 ret = val;
|
||||
BSWAP_CONSTEXPR uint16_t BigUint16(uint16_t& val) {
|
||||
int16_t ret = val;
|
||||
BigInt16(ret);
|
||||
val = ret;
|
||||
|
||||
return val;
|
||||
}
|
||||
BSWAP_CONSTEXPR atInt32 LittleInt32(atInt32& val) {
|
||||
BSWAP_CONSTEXPR int32_t LittleInt32(int32_t& val) {
|
||||
if constexpr (athena::utility::isSystemBigEndian())
|
||||
val = athena::utility::swap32(val);
|
||||
|
||||
return val;
|
||||
}
|
||||
BSWAP_CONSTEXPR atUint32 LittleUint32(atUint32& val) {
|
||||
atInt32 ret = val;
|
||||
BSWAP_CONSTEXPR uint32_t LittleUint32(uint32_t& val) {
|
||||
int32_t ret = val;
|
||||
LittleInt32(ret);
|
||||
val = ret;
|
||||
|
||||
return val;
|
||||
}
|
||||
BSWAP_CONSTEXPR atInt32 BigInt32(atInt32& val) {
|
||||
BSWAP_CONSTEXPR int32_t BigInt32(int32_t& val) {
|
||||
if constexpr (!athena::utility::isSystemBigEndian())
|
||||
val = athena::utility::swap32(val);
|
||||
|
||||
return val;
|
||||
}
|
||||
BSWAP_CONSTEXPR atUint32 BigUint32(atUint32& val) {
|
||||
atInt32 ret = val;
|
||||
BSWAP_CONSTEXPR uint32_t BigUint32(uint32_t& val) {
|
||||
int32_t ret = val;
|
||||
BigInt32(ret);
|
||||
val = ret;
|
||||
|
||||
return val;
|
||||
}
|
||||
BSWAP_CONSTEXPR atInt64 LittleInt64(atInt64& val) {
|
||||
BSWAP_CONSTEXPR int64_t LittleInt64(int64_t& val) {
|
||||
if constexpr (athena::utility::isSystemBigEndian())
|
||||
val = athena::utility::swap64(val);
|
||||
|
||||
return val;
|
||||
}
|
||||
BSWAP_CONSTEXPR atUint64 LittleUint64(atUint64& val) {
|
||||
atInt64 ret = val;
|
||||
BSWAP_CONSTEXPR uint64_t LittleUint64(uint64_t& val) {
|
||||
int64_t ret = val;
|
||||
LittleInt64(ret);
|
||||
val = ret;
|
||||
|
||||
return val;
|
||||
}
|
||||
BSWAP_CONSTEXPR atInt64 BigInt64(atInt64& val) {
|
||||
BSWAP_CONSTEXPR int64_t BigInt64(int64_t& val) {
|
||||
if constexpr (!athena::utility::isSystemBigEndian())
|
||||
val = athena::utility::swap64(val);
|
||||
|
||||
return val;
|
||||
}
|
||||
BSWAP_CONSTEXPR atUint64 BigUint64(atUint64& val) {
|
||||
atInt64 ret = val;
|
||||
BSWAP_CONSTEXPR uint64_t BigUint64(uint64_t& val) {
|
||||
int64_t ret = val;
|
||||
BigInt64(ret);
|
||||
val = ret;
|
||||
|
||||
@@ -175,9 +175,9 @@ BSWAP_CONSTEXPR double BigDouble(double val) {
|
||||
return val;
|
||||
}
|
||||
|
||||
void fillRandom(atUint8* rndArea, atUint64 count);
|
||||
void fillRandom(uint8_t* rndArea, uint64_t count);
|
||||
std::vector<std::string> split(std::string_view s, char delim);
|
||||
atUint64 rand64();
|
||||
uint64_t rand64();
|
||||
std::string join(const std::vector<std::string>& elems, std::string_view delims);
|
||||
void tolower(std::string& str);
|
||||
void toupper(std::string& str);
|
||||
@@ -193,9 +193,9 @@ std::string& rtrim(std::string& s);
|
||||
|
||||
// trim from both ends
|
||||
std::string& trim(std::string& s);
|
||||
atUint64 fileSize(std::string_view filename);
|
||||
uint64_t fileSize(std::string_view filename);
|
||||
#ifdef _WIN32
|
||||
atUint64 fileSize(std::wstring_view filename);
|
||||
uint64_t fileSize(std::wstring_view filename);
|
||||
#endif
|
||||
|
||||
std::string wideToUtf8(std::wstring_view src);
|
||||
|
||||
@@ -22,19 +22,19 @@ public:
|
||||
* @param position where in the buffer to seek
|
||||
* @param origin The Origin to seek @sa SeekOrigin
|
||||
*/
|
||||
void seek(atInt64 position, SeekOrigin origin = SeekOrigin::Current) override;
|
||||
void seek(int64_t position, SeekOrigin origin = SeekOrigin::Current) override;
|
||||
|
||||
/*! @brief Returns the current position in the stream.
|
||||
*
|
||||
* @return Int64 The current position in the stream.
|
||||
*/
|
||||
atUint64 position() const override { return m_position; }
|
||||
uint64_t position() const override { return m_position; }
|
||||
|
||||
/*! @brief Returns the length of the stream.
|
||||
*
|
||||
* @return Int64 The length of the stream.
|
||||
*/
|
||||
atUint64 length() const override { return m_data.size(); }
|
||||
uint64_t length() const override { return m_data.size(); }
|
||||
|
||||
bool isOpen() const { return true; }
|
||||
|
||||
@@ -48,11 +48,11 @@ public:
|
||||
* @param data The buffer to write
|
||||
* @param length The amount to write
|
||||
*/
|
||||
void writeUBytes(const atUint8* data, atUint64 length) override;
|
||||
void writeUBytes(const uint8_t* data, uint64_t length) override;
|
||||
|
||||
protected:
|
||||
std::vector<uint8_t> m_data;
|
||||
atUint64 m_position = 0;
|
||||
uint64_t m_position = 0;
|
||||
};
|
||||
|
||||
} // namespace athena::io
|
||||
|
||||
@@ -27,7 +27,7 @@ public:
|
||||
* \param m_banner
|
||||
* \param icons
|
||||
*/
|
||||
WiiBanner(atUint32 gameId, const std::u16string& title, const std::u16string& subtitle, WiiImage* m_banner,
|
||||
WiiBanner(uint32_t gameId, const std::u16string& title, const std::u16string& subtitle, WiiImage* m_banner,
|
||||
std::vector<WiiImage*> icons);
|
||||
virtual ~WiiBanner();
|
||||
|
||||
@@ -35,13 +35,13 @@ public:
|
||||
* \brief setGameID
|
||||
* \param id
|
||||
*/
|
||||
void setGameID(atUint64 id);
|
||||
void setGameID(uint64_t id);
|
||||
|
||||
/*!
|
||||
* \brief gameID
|
||||
* \return
|
||||
*/
|
||||
atUint64 gameID() const;
|
||||
uint64_t gameID() const;
|
||||
|
||||
/*!
|
||||
* \brief setBannerImage
|
||||
@@ -59,13 +59,13 @@ public:
|
||||
* \brief setBannerSize
|
||||
* \param size
|
||||
*/
|
||||
void setBannerSize(atUint32 size);
|
||||
void setBannerSize(uint32_t size);
|
||||
|
||||
/*!
|
||||
* \brief bannerSize
|
||||
* \return
|
||||
*/
|
||||
atUint32 bannerSize() const;
|
||||
uint32_t bannerSize() const;
|
||||
|
||||
/*!
|
||||
* \brief setTitle
|
||||
@@ -102,14 +102,14 @@ public:
|
||||
* \param id
|
||||
* \param icon
|
||||
*/
|
||||
void setIcon(atUint32 id, WiiImage* icon);
|
||||
void setIcon(uint32_t id, WiiImage* icon);
|
||||
|
||||
/*!
|
||||
* \brief getIcon
|
||||
* \param id
|
||||
* \return
|
||||
*/
|
||||
WiiImage* getIcon(atUint32 id) const;
|
||||
WiiImage* getIcon(uint32_t id) const;
|
||||
|
||||
/*!
|
||||
* \brief icons
|
||||
@@ -121,46 +121,46 @@ public:
|
||||
* \brief setAnimationSpeed
|
||||
* \param animSpeed
|
||||
*/
|
||||
void setAnimationSpeed(atUint16 animSpeed);
|
||||
void setAnimationSpeed(uint16_t animSpeed);
|
||||
|
||||
/*!
|
||||
* \brief animationSpeed
|
||||
* \return
|
||||
*/
|
||||
atUint16 animationSpeed() const;
|
||||
uint16_t animationSpeed() const;
|
||||
|
||||
/*!
|
||||
* \brief setPermissions
|
||||
* \param permissions
|
||||
*/
|
||||
void setPermissions(atUint8 permissions);
|
||||
void setPermissions(uint8_t permissions);
|
||||
|
||||
/*!
|
||||
* \brief permissions
|
||||
* \return
|
||||
*/
|
||||
atUint8 permissions() const;
|
||||
uint8_t permissions() const;
|
||||
|
||||
/*!
|
||||
* \brief setFlags
|
||||
* \param flags
|
||||
*/
|
||||
void setFlags(atUint32 flags);
|
||||
void setFlags(uint32_t flags);
|
||||
|
||||
/*!
|
||||
* \brief flags
|
||||
* \return
|
||||
*/
|
||||
atUint32 flags() const;
|
||||
uint32_t flags() const;
|
||||
|
||||
protected:
|
||||
private:
|
||||
atUint64 m_gameId;
|
||||
uint64_t m_gameId;
|
||||
WiiImage* m_banner;
|
||||
atUint32 m_animSpeed;
|
||||
atUint8 m_permissions;
|
||||
atUint32 m_flags;
|
||||
atUint32 m_bannerSize;
|
||||
uint32_t m_animSpeed;
|
||||
uint8_t m_permissions;
|
||||
uint32_t m_flags;
|
||||
uint32_t m_bannerSize;
|
||||
std::vector<WiiImage*> m_icons;
|
||||
std::u16string m_title;
|
||||
std::u16string m_subtitle;
|
||||
|
||||
@@ -7,11 +7,11 @@
|
||||
|
||||
namespace athena {
|
||||
|
||||
const atUint8 SD_KEY[16] = {0xab, 0x01, 0xb9, 0xd8, 0xe1, 0x62, 0x2b, 0x08,
|
||||
const uint8_t SD_KEY[16] = {0xab, 0x01, 0xb9, 0xd8, 0xe1, 0x62, 0x2b, 0x08,
|
||||
0xaf, 0xba, 0xd8, 0x4d, 0xbf, 0xc2, 0xa5, 0x5d};
|
||||
const atUint8 SD_IV[16] = {0x21, 0x67, 0x12, 0xe6, 0xaa, 0x1f, 0x68, 0x9f,
|
||||
const uint8_t SD_IV[16] = {0x21, 0x67, 0x12, 0xe6, 0xaa, 0x1f, 0x68, 0x9f,
|
||||
0x95, 0xc5, 0xa2, 0x23, 0x24, 0xdc, 0x6a, 0x98};
|
||||
const atUint8 MD5_BLANKER[16] = {0x0e, 0x65, 0x37, 0x81, 0x99, 0xbe, 0x45, 0x17,
|
||||
const uint8_t MD5_BLANKER[16] = {0x0e, 0x65, 0x37, 0x81, 0x99, 0xbe, 0x45, 0x17,
|
||||
0xab, 0x06, 0xec, 0x22, 0x45, 0x1a, 0x57, 0x93};
|
||||
|
||||
/*! \class WiiFile
|
||||
@@ -59,7 +59,7 @@ public:
|
||||
* \param data
|
||||
* \param length
|
||||
*/
|
||||
WiiFile(const std::string& filename, atUint8 permissions, const atUint8* data, atUint32 length);
|
||||
WiiFile(const std::string& filename, uint8_t permissions, const uint8_t* data, uint32_t length);
|
||||
virtual ~WiiFile();
|
||||
|
||||
/*!
|
||||
@@ -78,12 +78,12 @@ public:
|
||||
* \brief setData
|
||||
* \param data
|
||||
*/
|
||||
void setData(const atUint8* data);
|
||||
void setData(const uint8_t* data);
|
||||
/*!
|
||||
* \brief data
|
||||
* \return
|
||||
*/
|
||||
atUint8* data() const;
|
||||
uint8_t* data() const;
|
||||
|
||||
/*!
|
||||
* \brief setLength
|
||||
@@ -101,25 +101,25 @@ public:
|
||||
* \brief setPermissions
|
||||
* \param permissions
|
||||
*/
|
||||
void setPermissions(const atUint8 permissions);
|
||||
void setPermissions(const uint8_t permissions);
|
||||
|
||||
/*!
|
||||
* \brief permissions
|
||||
* \return
|
||||
*/
|
||||
atUint8 permissions() const;
|
||||
uint8_t permissions() const;
|
||||
|
||||
/*!
|
||||
* \brief setAttributes
|
||||
* \param attr
|
||||
*/
|
||||
void setAttributes(const atUint8 attr);
|
||||
void setAttributes(const uint8_t attr);
|
||||
|
||||
/*!
|
||||
* \brief attributes
|
||||
* \return
|
||||
*/
|
||||
atUint8 attributes() const;
|
||||
uint8_t attributes() const;
|
||||
|
||||
/*!
|
||||
* \brief setType
|
||||
@@ -188,7 +188,7 @@ public:
|
||||
* \brief fileCount
|
||||
* \return
|
||||
*/
|
||||
atUint32 fileCount();
|
||||
uint32_t fileCount();
|
||||
|
||||
/*!
|
||||
* \brief allChildren
|
||||
@@ -204,12 +204,12 @@ public:
|
||||
|
||||
protected:
|
||||
private:
|
||||
atUint8 m_permissions;
|
||||
atUint8 m_attributes;
|
||||
uint8_t m_permissions;
|
||||
uint8_t m_attributes;
|
||||
Type m_type;
|
||||
std::string m_filename;
|
||||
int m_fileLen;
|
||||
atUint8* m_fileData;
|
||||
uint8_t* m_fileData;
|
||||
WiiFile* m_parent;
|
||||
std::vector<WiiFile*> m_children;
|
||||
};
|
||||
|
||||
@@ -20,54 +20,54 @@ public:
|
||||
* \param height
|
||||
* \param data
|
||||
*/
|
||||
WiiImage(atUint32 width, atUint32 height, std::unique_ptr<atUint8[]>&& data);
|
||||
WiiImage(uint32_t width, uint32_t height, std::unique_ptr<uint8_t[]>&& data);
|
||||
|
||||
/*!
|
||||
* \brief setWidth
|
||||
* \param width
|
||||
*/
|
||||
void setWidth(const atUint32 width);
|
||||
void setWidth(const uint32_t width);
|
||||
|
||||
/*!
|
||||
* \brief width
|
||||
* \return
|
||||
*/
|
||||
atUint32 width() const;
|
||||
uint32_t width() const;
|
||||
|
||||
/*!
|
||||
* \brief setHeight
|
||||
* \param height
|
||||
*/
|
||||
void setHeight(const atUint32 height);
|
||||
void setHeight(const uint32_t height);
|
||||
|
||||
/*!
|
||||
* \brief height
|
||||
* \return
|
||||
*/
|
||||
atUint32 height() const;
|
||||
uint32_t height() const;
|
||||
|
||||
/*!
|
||||
* \brief setData
|
||||
* \param data
|
||||
*/
|
||||
void setData(const atUint8* data);
|
||||
void setData(const uint8_t* data);
|
||||
|
||||
/*!
|
||||
* \brief data
|
||||
* \return
|
||||
*/
|
||||
atUint8* data();
|
||||
uint8_t* data();
|
||||
|
||||
/*!
|
||||
* \brief toRGBA
|
||||
* \return
|
||||
*/
|
||||
atUint8* toRGBA();
|
||||
uint8_t* toRGBA();
|
||||
|
||||
private:
|
||||
atUint32 m_width;
|
||||
atUint32 m_height;
|
||||
std::unique_ptr<atUint8[]> m_data;
|
||||
uint32_t m_width;
|
||||
uint32_t m_height;
|
||||
std::unique_ptr<uint8_t[]> m_data;
|
||||
};
|
||||
|
||||
} // namespace athena
|
||||
|
||||
@@ -48,7 +48,7 @@ public:
|
||||
*/
|
||||
WiiFile* file(const std::string& filename);
|
||||
|
||||
atUint32 fileCount() const;
|
||||
uint32_t fileCount() const;
|
||||
/*!
|
||||
* \brief fileList
|
||||
* \return
|
||||
|
||||
@@ -25,7 +25,7 @@ public:
|
||||
* \param data The existing buffer
|
||||
* \param length The length of the existing buffer
|
||||
*/
|
||||
WiiSaveReader(const atUint8*, atUint64);
|
||||
WiiSaveReader(const uint8_t*, uint64_t);
|
||||
|
||||
/*! \brief This constructor creates an instance from a file on disk.
|
||||
*
|
||||
@@ -42,8 +42,8 @@ public:
|
||||
private:
|
||||
WiiBanner* readBanner();
|
||||
WiiFile* readFile();
|
||||
WiiImage* readImage(atUint32 width, atUint32 height);
|
||||
void readCerts(atUint32 totalSize);
|
||||
WiiImage* readImage(uint32_t width, uint32_t height);
|
||||
void readCerts(uint32_t totalSize);
|
||||
WiiFile* buildTree(std::vector<WiiFile*> files);
|
||||
};
|
||||
|
||||
|
||||
@@ -36,14 +36,14 @@ public:
|
||||
* \param filepath
|
||||
* \return
|
||||
*/
|
||||
bool writeSave(WiiSave* save, atUint8* macAddress, atUint32 ngId, atUint8* ngPriv, atUint8* ngSig, atUint32 ngKeyId,
|
||||
bool writeSave(WiiSave* save, uint8_t* macAddress, uint32_t ngId, uint8_t* ngPriv, uint8_t* ngSig, uint32_t ngKeyId,
|
||||
const std::string& filepath = "");
|
||||
|
||||
private:
|
||||
void writeBanner(WiiBanner* banner);
|
||||
atUint32 writeFile(WiiFile* file);
|
||||
uint32_t writeFile(WiiFile* file);
|
||||
void writeImage(WiiImage* image);
|
||||
void writeCerts(atUint32 filesSize, atUint32 ngId, atUint8* ngPriv, atUint8* ngSig, atUint32 ngKeyId);
|
||||
void writeCerts(uint32_t filesSize, uint32_t ngId, uint8_t* ngPriv, uint8_t* ngSig, uint32_t ngKeyId);
|
||||
};
|
||||
|
||||
} // namespace io
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <yaml.h>
|
||||
#include "yaml.h"
|
||||
|
||||
#include "athena/Types.hpp"
|
||||
|
||||
|
||||
@@ -61,12 +61,6 @@ public:
|
||||
|
||||
RecordRAII enterSubRecord(std::string_view name = {});
|
||||
|
||||
template <class T>
|
||||
void enumerate(std::string_view name, T& record, std::enable_if_t<__IsDNARecord_v<T>>* = nullptr) {
|
||||
if (auto rec = enterSubRecord(name))
|
||||
record.read(*this);
|
||||
}
|
||||
|
||||
class VectorRAII {
|
||||
friend class YAMLDocReader;
|
||||
YAMLDocReader* m_r = nullptr;
|
||||
|
||||
@@ -47,12 +47,6 @@ public:
|
||||
|
||||
RecordRAII enterSubRecord(std::string_view name = {});
|
||||
|
||||
template <class T>
|
||||
void enumerate(std::string_view name, T& record, std::enable_if_t<__IsDNARecord_v<T>>* = nullptr) {
|
||||
if (auto rec = enterSubRecord(name))
|
||||
record.write(*this);
|
||||
}
|
||||
|
||||
class VectorRAII {
|
||||
friend class YAMLDocWriter;
|
||||
YAMLDocWriter* m_w = nullptr;
|
||||
|
||||
@@ -18,24 +18,24 @@ public:
|
||||
/*!
|
||||
* \brief The current major version of the ZQuest format
|
||||
*/
|
||||
static const atUint32 Major;
|
||||
static const uint32_t Major;
|
||||
/*!
|
||||
* \brief The current minor version of the ZQuest format
|
||||
*/
|
||||
static const atUint32 Minor;
|
||||
static const uint32_t Minor;
|
||||
/*!
|
||||
* \brief The current revision of the ZQuest format
|
||||
*/
|
||||
static const atUint32 Revision;
|
||||
static const uint32_t Revision;
|
||||
/*!
|
||||
* \brief The current version of the ZQuest format
|
||||
*/
|
||||
static const atUint32 Version;
|
||||
static const uint32_t Version;
|
||||
|
||||
/*!
|
||||
* \brief The magic number used to identify the file e.g. "ZQS1"
|
||||
*/
|
||||
static const atUint32 Magic;
|
||||
static const uint32_t Magic;
|
||||
|
||||
/*!
|
||||
* \enum Game
|
||||
@@ -79,7 +79,7 @@ public:
|
||||
* \param data
|
||||
* \param length
|
||||
*/
|
||||
ZQuestFile(Game game, Endian endian, std::unique_ptr<atUint8[]>&& data, atUint32 length,
|
||||
ZQuestFile(Game game, Endian endian, std::unique_ptr<uint8_t[]>&& data, uint32_t length,
|
||||
const std::string& gameString = std::string());
|
||||
|
||||
/*!
|
||||
@@ -111,19 +111,19 @@ public:
|
||||
* \param data The data to assign
|
||||
* \param length The length of the data
|
||||
*/
|
||||
void setData(std::unique_ptr<atUint8[]>&& data, atUint32 length);
|
||||
void setData(std::unique_ptr<uint8_t[]>&& data, uint32_t length);
|
||||
|
||||
/*!
|
||||
* \brief data
|
||||
* \return
|
||||
*/
|
||||
atUint8* data() const;
|
||||
uint8_t* data() const;
|
||||
|
||||
/*!
|
||||
* \brief length
|
||||
* \return
|
||||
*/
|
||||
atUint32 length() const;
|
||||
uint32_t length() const;
|
||||
|
||||
void setGameString(const std::string& gameString);
|
||||
/*!
|
||||
@@ -138,8 +138,8 @@ protected:
|
||||
Game m_game;
|
||||
std::string m_gameString;
|
||||
Endian m_endian;
|
||||
std::unique_ptr<atUint8[]> m_data;
|
||||
atUint32 m_length;
|
||||
std::unique_ptr<uint8_t[]> m_data;
|
||||
uint32_t m_length;
|
||||
|
||||
// Game strings support
|
||||
};
|
||||
|
||||
@@ -20,7 +20,7 @@ public:
|
||||
* \param data
|
||||
* \param length
|
||||
*/
|
||||
ZQuestFileReader(atUint8* data, atUint64 length);
|
||||
ZQuestFileReader(uint8_t* data, uint64_t length);
|
||||
|
||||
/*!
|
||||
* \brief ZQuestFileReader
|
||||
|
||||
@@ -19,7 +19,7 @@ public:
|
||||
* \param data
|
||||
* \param length
|
||||
*/
|
||||
ZQuestFileWriter(atUint8* data, atUint64 length);
|
||||
ZQuestFileWriter(uint8_t* data, uint64_t length);
|
||||
|
||||
/*!
|
||||
* \brief ZQuestFileWriter
|
||||
|
||||
@@ -1518,6 +1518,11 @@ public:
|
||||
const __simd_storage<_Up, __simd_abi<_StorageKind::_Array, __Unum_element>>& other) {
|
||||
std::copy(other.__native().begin(), other.__native().end(), __storage_.begin());
|
||||
}
|
||||
template <typename... _T2, std::enable_if_t<(... && std::is_convertible_v<_T2, _Tp>), bool> = true,
|
||||
std::enable_if_t<sizeof...(_T2) == __num_element, bool> = true>
|
||||
constexpr __simd_storage(_T2... values) : __storage_{values...} {}
|
||||
template <std::enable_if_t<__num_element == 4, bool> = true>
|
||||
constexpr __simd_storage(_Tp __rv) : __storage_{__rv, __rv, __rv, __rv} {}
|
||||
constexpr const storage_type& __native() const { return __storage_; }
|
||||
};
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ using namespace std;
|
||||
#elif __ARM_NEON
|
||||
#include "simd_neon.hpp"
|
||||
#else
|
||||
namespace simd_abi {
|
||||
namespace athena::_simd::simd_abi {
|
||||
template <typename T>
|
||||
struct athena_native {};
|
||||
template <>
|
||||
|
||||
@@ -31,7 +31,7 @@ public:
|
||||
using storage_type = __m128;
|
||||
storage_type __storage_{};
|
||||
[[nodiscard]] inline float __get(size_t __index) const noexcept {
|
||||
#if _MSC_VER && !defined(__clang__)
|
||||
#if _MSC_VER
|
||||
alignas(16) std::array<float, 4> sse_data;
|
||||
_mm_store_ps(sse_data.data(), __storage_);
|
||||
return sse_data[__index];
|
||||
@@ -40,7 +40,7 @@ public:
|
||||
#endif
|
||||
}
|
||||
inline void __set(size_t __index, float __val) noexcept {
|
||||
#if _MSC_VER && !defined(__clang__)
|
||||
#if _MSC_VER
|
||||
alignas(16) std::array<float, 4> sse_data;
|
||||
_mm_store_ps(sse_data.data(), __storage_);
|
||||
sse_data[__index] = __val;
|
||||
@@ -210,7 +210,7 @@ public:
|
||||
using storage_type = std::array<__m128d, 2>;
|
||||
storage_type __storage_{};
|
||||
[[nodiscard]] inline double __get(size_t __index) const noexcept {
|
||||
#if _MSC_VER && !defined(__clang__)
|
||||
#if _MSC_VER
|
||||
alignas(16) std::array<double, 2> sse_data;
|
||||
_mm_store_pd(sse_data.data(), __storage_[__index / 2]);
|
||||
return sse_data[__index % 2];
|
||||
@@ -219,7 +219,7 @@ public:
|
||||
#endif
|
||||
}
|
||||
inline void __set(size_t __index, double __val) noexcept {
|
||||
#if _MSC_VER && !defined(__clang__)
|
||||
#if _MSC_VER
|
||||
alignas(16) std::array<double, 2> sse_data;
|
||||
_mm_store_pd(sse_data.data(), __storage_[__index / 2]);
|
||||
sse_data[__index % 2] = __val;
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @mainpage
|
||||
*
|
||||
@@ -36,9 +35,11 @@
|
||||
* The features of utf8proc include:
|
||||
*
|
||||
* - Transformation of strings (@ref utf8proc_map) to:
|
||||
* - decompose (@ref UTF8PROC_DECOMPOSE) or compose (@ref UTF8PROC_COMPOSE) Unicode combining characters (http://en.wikipedia.org/wiki/Combining_character)
|
||||
* - decompose (@ref UTF8PROC_DECOMPOSE) or compose (@ref UTF8PROC_COMPOSE) Unicode combining characters
|
||||
* (http://en.wikipedia.org/wiki/Combining_character)
|
||||
* - canonicalize Unicode compatibility characters (@ref UTF8PROC_COMPAT)
|
||||
* - strip "ignorable" (@ref UTF8PROC_IGNORE) characters, control characters (@ref UTF8PROC_STRIPCC), or combining characters such as accents (@ref UTF8PROC_STRIPMARK)
|
||||
* - strip "ignorable" (@ref UTF8PROC_IGNORE) characters, control characters (@ref UTF8PROC_STRIPCC), or combining
|
||||
* characters such as accents (@ref UTF8PROC_STRIPMARK)
|
||||
* - case-folding (@ref UTF8PROC_CASEFOLD)
|
||||
* - Unicode normalization: @ref utf8proc_NFD, @ref utf8proc_NFC, @ref utf8proc_NFKD, @ref utf8proc_NFKC
|
||||
* - Detecting grapheme boundaries (@ref utf8proc_grapheme_break and @ref UTF8PROC_CHARBOUND)
|
||||
@@ -98,7 +99,6 @@ typedef bool utf8proc_bool;
|
||||
#endif
|
||||
#else
|
||||
#ifdef __cplusplus
|
||||
# include <cstdbool>
|
||||
#include <cinttypes>
|
||||
#else
|
||||
#include <stdbool.h>
|
||||
@@ -148,14 +148,14 @@ typedef bool utf8proc_bool;
|
||||
* In case of success, the number of bytes read is returned; otherwise, a
|
||||
* negative error code is returned.
|
||||
*/
|
||||
static inline utf8proc_ssize_t utf8proc_iterate(
|
||||
const utf8proc_uint8_t *str, utf8proc_ssize_t strlen, utf8proc_int32_t *dst
|
||||
) {
|
||||
static inline utf8proc_ssize_t utf8proc_iterate(const utf8proc_uint8_t* str, utf8proc_ssize_t strlen,
|
||||
utf8proc_int32_t* dst) {
|
||||
utf8proc_uint32_t uc;
|
||||
const utf8proc_uint8_t* end;
|
||||
|
||||
*dst = -1;
|
||||
if (!strlen) return 0;
|
||||
if (!strlen)
|
||||
return 0;
|
||||
end = str + ((strlen < 0) ? 4 : strlen);
|
||||
uc = *str++;
|
||||
if (uc < 0x80) {
|
||||
@@ -163,10 +163,12 @@ static inline utf8proc_ssize_t utf8proc_iterate(
|
||||
return 1;
|
||||
}
|
||||
// Must be between 0xc2 and 0xf4 inclusive to be valid
|
||||
if ((uc - 0xc2) > (0xf4-0xc2)) return UTF8PROC_ERROR_INVALIDUTF8;
|
||||
if ((uc - 0xc2) > (0xf4 - 0xc2))
|
||||
return UTF8PROC_ERROR_INVALIDUTF8;
|
||||
if (uc < 0xe0) { // 2-byte sequence
|
||||
// Must have valid continuation character
|
||||
if (!UTF8PROC_cont(*str)) return UTF8PROC_ERROR_INVALIDUTF8;
|
||||
if (!UTF8PROC_cont(*str))
|
||||
return UTF8PROC_ERROR_INVALIDUTF8;
|
||||
*dst = ((uc & 0x1f) << 6) | (*str & 0x3f);
|
||||
return 2;
|
||||
}
|
||||
@@ -188,9 +190,11 @@ static inline utf8proc_ssize_t utf8proc_iterate(
|
||||
return UTF8PROC_ERROR_INVALIDUTF8;
|
||||
// Make sure in correct range (0x10000 - 0x10ffff)
|
||||
if (uc == 0xf0) {
|
||||
if (*str < 0x90) return UTF8PROC_ERROR_INVALIDUTF8;
|
||||
if (*str < 0x90)
|
||||
return UTF8PROC_ERROR_INVALIDUTF8;
|
||||
} else if (uc == 0xf4) {
|
||||
if (*str > 0x8f) return UTF8PROC_ERROR_INVALIDUTF8;
|
||||
if (*str > 0x8f)
|
||||
return UTF8PROC_ERROR_INVALIDUTF8;
|
||||
}
|
||||
*dst = ((uc & 7) << 18) | ((*str & 0x3f) << 12) | ((str[1] & 0x3f) << 6) | (str[2] & 0x3f);
|
||||
return 4;
|
||||
@@ -228,16 +232,17 @@ static inline utf8proc_ssize_t utf8proc_encode_char(utf8proc_int32_t uc, utf8pro
|
||||
dst[2] = 0x80 + ((uc >> 6) & 0x3F);
|
||||
dst[3] = 0x80 + (uc & 0x3F);
|
||||
return 4;
|
||||
} else return 0;
|
||||
} else
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include <iterator>
|
||||
#include <string>
|
||||
|
||||
class UTF8Iterator
|
||||
{
|
||||
class UTF8Iterator {
|
||||
std::string_view::const_iterator m_it;
|
||||
|
||||
public:
|
||||
using iterator_category = std::forward_iterator_tag;
|
||||
using value_type = uint32_t;
|
||||
@@ -246,22 +251,17 @@ public:
|
||||
using reference = uint32_t&;
|
||||
|
||||
UTF8Iterator(const std::string_view::const_iterator& it) : m_it(it) {}
|
||||
UTF8Iterator& operator+=(size_t v)
|
||||
{
|
||||
for (size_t i=0 ; i<v ; ++i)
|
||||
{
|
||||
UTF8Iterator& operator+=(size_t v) {
|
||||
for (size_t i = 0; i < v; ++i) {
|
||||
utf8proc_int32_t dummy;
|
||||
utf8proc_ssize_t sz = utf8proc_iterate(reinterpret_cast<const utf8proc_uint8_t*>(&*m_it), -1, &dummy);
|
||||
#ifndef NDEBUG
|
||||
if (*m_it == '\0')
|
||||
{
|
||||
if (*m_it == '\0') {
|
||||
fprintf(stderr, "ERROR! UTF8-iterator null-term fail\n");
|
||||
abort();
|
||||
}
|
||||
else if (sz > 0)
|
||||
} else if (sz > 0)
|
||||
m_it += sz;
|
||||
else
|
||||
{
|
||||
else {
|
||||
fprintf(stderr, "ERROR! UTF8Iterator character fail");
|
||||
abort();
|
||||
}
|
||||
@@ -272,29 +272,22 @@ public:
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
UTF8Iterator& operator++()
|
||||
{
|
||||
return this->operator+=(1);
|
||||
}
|
||||
UTF8Iterator operator+(size_t v) const
|
||||
{
|
||||
UTF8Iterator& operator++() { return this->operator+=(1); }
|
||||
UTF8Iterator operator+(size_t v) const {
|
||||
UTF8Iterator ret(m_it);
|
||||
ret += v;
|
||||
return ret;
|
||||
}
|
||||
uint32_t operator*() const
|
||||
{
|
||||
uint32_t operator*() const {
|
||||
utf8proc_int32_t ret;
|
||||
utf8proc_iterate(reinterpret_cast<const utf8proc_uint8_t*>(&*m_it), -1, &ret);
|
||||
return ret;
|
||||
}
|
||||
std::string_view::const_iterator iter() const { return m_it; }
|
||||
size_t countTo(std::string_view::const_iterator end) const
|
||||
{
|
||||
size_t countTo(std::string_view::const_iterator end) const {
|
||||
UTF8Iterator it(m_it);
|
||||
size_t ret = 0;
|
||||
while (it.iter() < end && *it != '\0')
|
||||
{
|
||||
while (it.iter() < end && *it != '\0') {
|
||||
++ret;
|
||||
++it;
|
||||
}
|
||||
@@ -305,4 +298,3 @@ public:
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
|
||||
#include "athena/Types.hpp"
|
||||
namespace bignum {
|
||||
int compare(const atUint8* a, const atUint8* b, atUint32 n);
|
||||
void subModulus(atUint8* a, const atUint8* N, atUint32 n);
|
||||
void add(atUint8* d, atUint8* a, const atUint8* b, const atUint8* N, atUint32 n);
|
||||
void mul(atUint8* d, atUint8* a, const atUint8* b, const atUint8* N, atUint32 n);
|
||||
void exp(atUint8* d, const atUint8* a, const atUint8* N, atUint32 n, atUint8* e, atUint32 en);
|
||||
void inv(atUint8* d, atUint8* a, const atUint8* N, atUint32 n);
|
||||
int compare(const uint8_t* a, const uint8_t* b, uint32_t n);
|
||||
void subModulus(uint8_t* a, const uint8_t* N, uint32_t n);
|
||||
void add(uint8_t* d, uint8_t* a, const uint8_t* b, const uint8_t* N, uint32_t n);
|
||||
void mul(uint8_t* d, uint8_t* a, const uint8_t* b, const uint8_t* N, uint32_t n);
|
||||
void exp(uint8_t* d, const uint8_t* a, const uint8_t* N, uint32_t n, uint8_t* e, uint32_t en);
|
||||
void inv(uint8_t* d, uint8_t* a, const uint8_t* N, uint32_t n);
|
||||
} // namespace bignum
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include "athena/Types.hpp"
|
||||
|
||||
namespace ecc {
|
||||
void checkEC(atUint8* ng, atUint8* ap, atUint8* sig, atUint8* sigHash, bool& apValid, bool& ngValid);
|
||||
void makeECCert(atUint8* cert, atUint8* sig, const char* signer, const char* name, atUint8* priv, atUint32 keyId);
|
||||
void createECDSA(atUint8* R, atUint8* S, atUint8* k, atUint8* hash);
|
||||
void checkEC(uint8_t* ng, uint8_t* ap, uint8_t* sig, uint8_t* sigHash, bool& apValid, bool& ngValid);
|
||||
void makeECCert(uint8_t* cert, uint8_t* sig, const char* signer, const char* name, uint8_t* priv, uint32_t keyId);
|
||||
void createECDSA(uint8_t* R, uint8_t* S, uint8_t* k, uint8_t* hash);
|
||||
} // namespace ecc
|
||||
|
||||
@@ -37,7 +37,7 @@ void SHA1Input(SHA1Context*,
|
||||
|
||||
|
||||
|
||||
atUint8* getSha1(atUint8* stuff, atUint32 stuff_size);
|
||||
uint8_t* getSha1(uint8_t* stuff, uint32_t stuff_size);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ libdir=${prefix}/lib
|
||||
|
||||
Name: libAthena
|
||||
Description: Basic cross platform IO library
|
||||
Version: @ATHENA_VERSION@
|
||||
Version: @ATHENA_VERSION_STRING@
|
||||
Cflags: -I${includedir}/Athena
|
||||
Libs: -L${libdir} -lathena-core -lathena-sakura -lathena-zelda -lathena-wiiSave
|
||||
Requires: zlib
|
||||
|
||||
@@ -26,12 +26,12 @@ int subMatch(const uint8_t* str1, const uint8_t* str2, const int len) {
|
||||
// Up to 4096 bytes Up to 18 bytes
|
||||
// Sliding Window
|
||||
// Up to 4114 bytes
|
||||
LZLengthOffset windowSearch(const atUint8* beginSearchPtr, const atUint8* searchPosPtr, const atUint8* endLABufferPtr,
|
||||
const atUint8* startLBPtr) {
|
||||
atInt32 size = (atUint32)(endLABufferPtr - beginSearchPtr); // Size of the entire sliding window
|
||||
atInt32 n = (atUint32)(endLABufferPtr - searchPosPtr);
|
||||
LZLengthOffset windowSearch(const uint8_t* beginSearchPtr, const uint8_t* searchPosPtr, const uint8_t* endLABufferPtr,
|
||||
const uint8_t* startLBPtr) {
|
||||
int32_t size = (uint32_t)(endLABufferPtr - beginSearchPtr); // Size of the entire sliding window
|
||||
int32_t n = (uint32_t)(endLABufferPtr - searchPosPtr);
|
||||
LZLengthOffset result = {0, 0};
|
||||
atInt32 temp = 0;
|
||||
int32_t temp = 0;
|
||||
|
||||
if (n > size) // If the string that is being looked for is bigger than the string that is being searched
|
||||
return result;
|
||||
@@ -44,12 +44,12 @@ LZLengthOffset windowSearch(const atUint8* beginSearchPtr, const atUint8* search
|
||||
do {
|
||||
temp = subMatch(startLBPtr, searchPosPtr, n);
|
||||
|
||||
if (result.length < (atUint32)temp) {
|
||||
if (result.length < (uint32_t)temp) {
|
||||
result.length = temp;
|
||||
result.offset = (atInt32)(searchPosPtr - startLBPtr);
|
||||
result.offset = (int32_t)(searchPosPtr - startLBPtr);
|
||||
}
|
||||
|
||||
if (result.length == (atUint32)n)
|
||||
if (result.length == (uint32_t)n)
|
||||
return result;
|
||||
|
||||
// ReadAheadBuffer is the maximum size of a character match
|
||||
@@ -60,7 +60,7 @@ LZLengthOffset windowSearch(const atUint8* beginSearchPtr, const atUint8* search
|
||||
}
|
||||
} // Anonymous namespace
|
||||
|
||||
LZBase::LZBase(atInt32 minimumOffset, atInt32 slidingWindow, atInt32 minimumMatch, atInt32 blockSize)
|
||||
LZBase::LZBase(int32_t minimumOffset, int32_t slidingWindow, int32_t minimumMatch, int32_t blockSize)
|
||||
: m_slidingWindow(slidingWindow)
|
||||
, m_readAheadBuffer(minimumMatch)
|
||||
, m_minMatch(minimumMatch)
|
||||
@@ -69,25 +69,25 @@ LZBase::LZBase(atInt32 minimumOffset, atInt32 slidingWindow, atInt32 minimumMatc
|
||||
|
||||
LZBase::~LZBase() = default;
|
||||
|
||||
void LZBase::setSlidingWindow(atInt32 slidingWindow) { m_slidingWindow = slidingWindow; }
|
||||
void LZBase::setSlidingWindow(int32_t slidingWindow) { m_slidingWindow = slidingWindow; }
|
||||
|
||||
atInt32 LZBase::slidingWindow() const { return m_slidingWindow; }
|
||||
int32_t LZBase::slidingWindow() const { return m_slidingWindow; }
|
||||
|
||||
void LZBase::setReadAheadBuffer(atInt32 readAheadBuffer) { m_readAheadBuffer = readAheadBuffer; }
|
||||
void LZBase::setReadAheadBuffer(int32_t readAheadBuffer) { m_readAheadBuffer = readAheadBuffer; }
|
||||
|
||||
atInt32 LZBase::readAheadBuffer() const { return m_readAheadBuffer; }
|
||||
int32_t LZBase::readAheadBuffer() const { return m_readAheadBuffer; }
|
||||
|
||||
void LZBase::setMinMatch(atInt32 minimumMatch) { m_minMatch = minimumMatch; }
|
||||
void LZBase::setMinMatch(int32_t minimumMatch) { m_minMatch = minimumMatch; }
|
||||
|
||||
atInt32 LZBase::minMatch() const { return m_minMatch; }
|
||||
int32_t LZBase::minMatch() const { return m_minMatch; }
|
||||
|
||||
void LZBase::setBlockSize(atInt32 blockSize) { m_blockSize = blockSize; }
|
||||
void LZBase::setBlockSize(int32_t blockSize) { m_blockSize = blockSize; }
|
||||
|
||||
atInt32 LZBase::blockSize() const { return m_blockSize; }
|
||||
int32_t LZBase::blockSize() const { return m_blockSize; }
|
||||
|
||||
void LZBase::setMinimumOffset(atUint32 minimumOffset) { m_minOffset = minimumOffset; }
|
||||
void LZBase::setMinimumOffset(uint32_t minimumOffset) { m_minOffset = minimumOffset; }
|
||||
|
||||
atUint32 LZBase::minimumOffset() const { return m_minOffset; }
|
||||
uint32_t LZBase::minimumOffset() const { return m_minOffset; }
|
||||
|
||||
/*
|
||||
DerricMc:
|
||||
@@ -100,7 +100,7 @@ atUint32 LZBase::minimumOffset() const { return m_minOffset; }
|
||||
and 17 bytes did match then 17 bytes match is return).
|
||||
|
||||
*/
|
||||
LZLengthOffset LZBase::search(const atUint8* posPtr, const atUint8* dataBegin, const atUint8* dataEnd) const {
|
||||
LZLengthOffset LZBase::search(const uint8_t* posPtr, const uint8_t* dataBegin, const uint8_t* dataEnd) const {
|
||||
LZLengthOffset results = {0, 0};
|
||||
|
||||
// Returns negative 1 for Search failures since the current position is passed the size to be compressed
|
||||
@@ -109,7 +109,7 @@ LZLengthOffset LZBase::search(const atUint8* posPtr, const atUint8* dataBegin, c
|
||||
return results;
|
||||
}
|
||||
|
||||
const atUint8* searchWindow;
|
||||
const uint8_t* searchWindow;
|
||||
// LookAheadBuffer is ReadAheadBuffer Size if there are more bytes than ReadAheadBufferSize waiting
|
||||
// to be compressed else the number of remaining bytes is the LookAheadBuffer
|
||||
const int lookAheadBuffer_len =
|
||||
@@ -121,7 +121,7 @@ LZLengthOffset LZBase::search(const atUint8* posPtr, const atUint8* dataBegin, c
|
||||
else
|
||||
searchWindow = dataBegin;
|
||||
|
||||
const atUint8* endPos = posPtr + lookAheadBuffer_len;
|
||||
const uint8_t* endPos = posPtr + lookAheadBuffer_len;
|
||||
|
||||
if (!((posPtr - dataBegin < 1) || (dataEnd - posPtr < m_minMatch)))
|
||||
results = windowSearch(searchWindow, posPtr, endPos, posPtr - m_minOffset);
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
LZLookupTable::LZLookupTable() : m_buffer(m_minimumMatch) {}
|
||||
|
||||
LZLookupTable::LZLookupTable(atInt32 minimumMatch, atInt32 slidingWindow, atInt32 lookAheadWindow) {
|
||||
LZLookupTable::LZLookupTable(int32_t minimumMatch, int32_t slidingWindow, int32_t lookAheadWindow) {
|
||||
if (minimumMatch > 0)
|
||||
m_minimumMatch = minimumMatch;
|
||||
else
|
||||
@@ -21,14 +21,14 @@ LZLookupTable::LZLookupTable(atInt32 minimumMatch, atInt32 slidingWindow, atInt3
|
||||
|
||||
LZLookupTable::~LZLookupTable() = default;
|
||||
|
||||
void LZLookupTable::setLookAheadWindow(atInt32 lookAheadWindow) {
|
||||
void LZLookupTable::setLookAheadWindow(int32_t lookAheadWindow) {
|
||||
if (lookAheadWindow > 0)
|
||||
m_lookAheadWindow = lookAheadWindow;
|
||||
else
|
||||
m_lookAheadWindow = 18;
|
||||
}
|
||||
|
||||
LZLengthOffset LZLookupTable::search(const atUint8* curPos, const atUint8* dataBegin, const atUint8* dataEnd) {
|
||||
LZLengthOffset LZLookupTable::search(const uint8_t* curPos, const uint8_t* dataBegin, const uint8_t* dataEnd) {
|
||||
LZLengthOffset loPair = {0, 0};
|
||||
|
||||
// Returns negative 1 for search failures since the current position is passed the size to be compressed
|
||||
@@ -38,7 +38,7 @@ LZLengthOffset LZLookupTable::search(const atUint8* curPos, const atUint8* dataB
|
||||
}
|
||||
|
||||
std::copy(curPos, curPos + m_minimumMatch, m_buffer.begin());
|
||||
int32_t currentOffset = static_cast<atInt32>(curPos - dataBegin);
|
||||
int32_t currentOffset = static_cast<int32_t>(curPos - dataBegin);
|
||||
|
||||
// Find code
|
||||
if (currentOffset > 0 && (dataEnd - curPos) >= m_minimumMatch) {
|
||||
@@ -60,13 +60,13 @@ LZLengthOffset LZLookupTable::search(const atUint8* curPos, const atUint8* dataB
|
||||
|
||||
// Store the longest match found so far into length_offset struct.
|
||||
// When lengths are the same the closer offset to the lookahead buffer wins
|
||||
if (loPair.length < (atUint32)matchLength) {
|
||||
if (loPair.length < (uint32_t)matchLength) {
|
||||
loPair.length = matchLength;
|
||||
loPair.offset = currentOffset - iter->second;
|
||||
}
|
||||
|
||||
// Found the longest match so break out of loop
|
||||
if (loPair.length == (atUint32)m_lookAheadWindow)
|
||||
if (loPair.length == (uint32_t)m_lookAheadWindow)
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -75,7 +75,7 @@ LZLengthOffset LZLookupTable::search(const atUint8* curPos, const atUint8* dataB
|
||||
// Insert code
|
||||
table.insert(std::make_pair(m_buffer, currentOffset));
|
||||
|
||||
for (atUint32 i = 1; i < loPair.length; i++) {
|
||||
for (uint32_t i = 1; i < loPair.length; i++) {
|
||||
if (dataEnd - (curPos + i) < m_minimumMatch)
|
||||
break;
|
||||
|
||||
|
||||
@@ -8,46 +8,46 @@
|
||||
|
||||
#include <athena/MemoryWriter.hpp>
|
||||
|
||||
LZType10::LZType10(atInt32 MinimumOffset, atInt32 SlidingWindow, atInt32 MinimumMatch, atInt32 BlockSize)
|
||||
LZType10::LZType10(int32_t MinimumOffset, int32_t SlidingWindow, int32_t MinimumMatch, int32_t BlockSize)
|
||||
: LZBase(MinimumOffset, SlidingWindow, MinimumMatch, BlockSize) {
|
||||
// ReadAheadBuffer is normalize between (minumum match) and(minimum match + 15) so that matches fit within
|
||||
// 4-bits.
|
||||
m_readAheadBuffer = m_minMatch + 0xF;
|
||||
}
|
||||
|
||||
atUint32 LZType10::compress(const atUint8* src, atUint8** dstBuf, atUint32 srcLength) {
|
||||
atUint32 encodeSize = (srcLength << 8) | (0x10);
|
||||
uint32_t LZType10::compress(const uint8_t* src, uint8_t** dstBuf, uint32_t srcLength) {
|
||||
uint32_t encodeSize = (srcLength << 8) | (0x10);
|
||||
encodeSize = athena::utility::LittleUint32(encodeSize); // File size needs to be written as little endian always
|
||||
|
||||
athena::io::MemoryCopyWriter outbuf("tmp");
|
||||
outbuf.writeUint32(encodeSize);
|
||||
|
||||
const atUint8* ptrStart = src;
|
||||
const atUint8* ptrEnd = src + srcLength;
|
||||
const uint8_t* ptrStart = src;
|
||||
const uint8_t* ptrEnd = src + srcLength;
|
||||
|
||||
// At most their will be two bytes written if the bytes can be compressed. So if all bytes in the block can be
|
||||
// compressed it would take blockSize*2 bytes
|
||||
auto compressedBytes = std::unique_ptr<atUint8[]>(new atUint8[m_blockSize * 2]); // Holds the compressed bytes yet to be written
|
||||
auto compressedBytes = std::unique_ptr<uint8_t[]>(new uint8_t[m_blockSize * 2]); // Holds the compressed bytes yet to be written
|
||||
|
||||
while (ptrStart < ptrEnd) {
|
||||
atUint8 blockLen = 0;
|
||||
uint8_t blockLen = 0;
|
||||
// In Binary represents 1 if byte is compressed or 0 if not compressed
|
||||
// For example 01001000 means that the second and fifth byte in the blockSize from the left is compressed
|
||||
atUint8* ptrBytes = compressedBytes.get();
|
||||
uint8_t* ptrBytes = compressedBytes.get();
|
||||
|
||||
for (atInt32 i = 0; i < m_blockSize; i++) {
|
||||
for (int32_t i = 0; i < m_blockSize; i++) {
|
||||
// length_offset searchResult=Search(ptrStart, filedata, ptrEnd);
|
||||
const LZLengthOffset searchResult = m_lookupTable.search(ptrStart, src, ptrEnd);
|
||||
|
||||
// If the number of bytes to be compressed is at least the size of the Minimum match
|
||||
if (searchResult.length >= static_cast<atUint32>(m_minMatch)) {
|
||||
if (searchResult.length >= static_cast<uint32_t>(m_minMatch)) {
|
||||
// Gotta swap the bytes since system is wii is big endian and most computers are little endian
|
||||
atUint16 lenOff = (((searchResult.length - m_minMatch) & 0xF) << 12) | ((searchResult.offset - 1) & 0xFFF);
|
||||
uint16_t lenOff = (((searchResult.length - m_minMatch) & 0xF) << 12) | ((searchResult.offset - 1) & 0xFFF);
|
||||
athena::utility::BigUint16(lenOff);
|
||||
|
||||
memcpy(ptrBytes, &lenOff, sizeof(atUint16));
|
||||
memcpy(ptrBytes, &lenOff, sizeof(uint16_t));
|
||||
|
||||
ptrBytes += sizeof(atUint16);
|
||||
ptrBytes += sizeof(uint16_t);
|
||||
|
||||
ptrStart += searchResult.length;
|
||||
|
||||
@@ -60,7 +60,7 @@ atUint32 LZType10::compress(const atUint8* src, atUint8** dstBuf, atUint32 srcLe
|
||||
}
|
||||
|
||||
outbuf.writeByte(blockLen);
|
||||
outbuf.writeUBytes(compressedBytes.get(), static_cast<atUint64>(ptrBytes - compressedBytes.get()));
|
||||
outbuf.writeUBytes(compressedBytes.get(), static_cast<uint64_t>(ptrBytes - compressedBytes.get()));
|
||||
}
|
||||
|
||||
// Add zeros until the file is a multiple of 4
|
||||
@@ -70,16 +70,16 @@ atUint32 LZType10::compress(const atUint8* src, atUint8** dstBuf, atUint32 srcLe
|
||||
|
||||
*dstBuf = outbuf.data();
|
||||
outbuf.save();
|
||||
return static_cast<atUint32>(outbuf.length());
|
||||
return static_cast<uint32_t>(outbuf.length());
|
||||
}
|
||||
|
||||
atUint32 LZType10::decompress(const atUint8* src, atUint8** dst, atUint32 srcLength) {
|
||||
uint32_t LZType10::decompress(const uint8_t* src, uint8_t** dst, uint32_t srcLength) {
|
||||
if (*src != 0x10) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Size of data when it is uncompressed
|
||||
atUint32 uncompressedSize;
|
||||
uint32_t uncompressedSize;
|
||||
std::memcpy(&uncompressedSize, src, sizeof(uncompressedSize));
|
||||
|
||||
// The compressed file has the filesize encoded in little endian
|
||||
@@ -88,28 +88,28 @@ atUint32 LZType10::decompress(const atUint8* src, atUint8** dst, atUint32 srcLen
|
||||
// first byte is the encode flag
|
||||
uncompressedSize = uncompressedSize >> 8;
|
||||
|
||||
auto uncompressedData = std::unique_ptr<atUint8[]>(new atUint8[uncompressedSize]);
|
||||
atUint8* outputPtr = uncompressedData.get();
|
||||
atUint8* outputEndPtr = uncompressedData.get() + uncompressedSize;
|
||||
const atUint8* inputPtr = src + 4;
|
||||
const atUint8* inputEndPtr = src + srcLength;
|
||||
auto uncompressedData = std::unique_ptr<uint8_t[]>(new uint8_t[uncompressedSize]);
|
||||
uint8_t* outputPtr = uncompressedData.get();
|
||||
uint8_t* outputEndPtr = uncompressedData.get() + uncompressedSize;
|
||||
const uint8_t* inputPtr = src + 4;
|
||||
const uint8_t* inputEndPtr = src + srcLength;
|
||||
|
||||
while (inputPtr < inputEndPtr && outputPtr < outputEndPtr) {
|
||||
const atUint8 isCompressed = *inputPtr++;
|
||||
const uint8_t isCompressed = *inputPtr++;
|
||||
|
||||
for (atUint32 i = 0; i < static_cast<atUint32>(m_blockSize); i++) {
|
||||
for (uint32_t i = 0; i < static_cast<uint32_t>(m_blockSize); i++) {
|
||||
// Checks to see if the next byte is compressed by looking
|
||||
// at its binary representation - E.g 10010000
|
||||
// This says that the first extracted byte and the four extracted byte is compressed
|
||||
if ((isCompressed >> (7 - i)) & 0x1) {
|
||||
atUint16 lenOff;
|
||||
memcpy(&lenOff, inputPtr, sizeof(atUint16));
|
||||
uint16_t lenOff;
|
||||
memcpy(&lenOff, inputPtr, sizeof(uint16_t));
|
||||
athena::utility::BigUint16(lenOff);
|
||||
inputPtr += sizeof(atUint16); // Move forward two bytes
|
||||
inputPtr += sizeof(uint16_t); // Move forward two bytes
|
||||
// length offset pair has been decoded.
|
||||
LZLengthOffset decoding;
|
||||
decoding.length = (lenOff >> 12) + m_minMatch;
|
||||
decoding.offset = static_cast<atUint16>((lenOff & 0xFFF) + 1);
|
||||
decoding.offset = static_cast<uint16_t>((lenOff & 0xFFF) + 1);
|
||||
|
||||
if ((outputPtr - decoding.offset) < uncompressedData.get()) {
|
||||
// If the offset to look for uncompressed is passed the current uncompresed data then the data is not
|
||||
|
||||
@@ -8,41 +8,41 @@
|
||||
|
||||
#include <athena/MemoryWriter.hpp>
|
||||
|
||||
LZType11::LZType11(atInt32 minimumOffset, atInt32 slidingWindow, atInt32 minimumMatch, atInt32 blockSize)
|
||||
LZType11::LZType11(int32_t minimumOffset, int32_t slidingWindow, int32_t minimumMatch, int32_t blockSize)
|
||||
: LZBase(minimumOffset, slidingWindow, minimumMatch, blockSize) {
|
||||
m_readAheadBuffer = (0xF + 0xFF + 0xFFFF + m_minMatch);
|
||||
m_lookupTable.setLookAheadWindow(m_readAheadBuffer);
|
||||
}
|
||||
|
||||
atUint32 LZType11::compress(const atUint8* src, atUint8** dst, atUint32 srcLength) {
|
||||
uint32_t LZType11::compress(const uint8_t* src, uint8_t** dst, uint32_t srcLength) {
|
||||
athena::io::MemoryCopyWriter outbuff("tmp");
|
||||
|
||||
if (srcLength > 0xFFFFFF) { // If length is greater than 24 bits or 16 Megs
|
||||
atUint32 encodeFlag = 0x11;
|
||||
uint32_t encodeFlag = 0x11;
|
||||
athena::utility::LittleUint32(encodeFlag);
|
||||
athena::utility::LittleUint32(srcLength); // Filesize data is little endian
|
||||
outbuff.writeUint32(encodeFlag);
|
||||
outbuff.writeUint32(srcLength);
|
||||
} else {
|
||||
atUint32 encodeSize = (srcLength << 8) | (0x11);
|
||||
uint32_t encodeSize = (srcLength << 8) | (0x11);
|
||||
athena::utility::LittleUint32(encodeSize);
|
||||
outbuff.writeUint32(encodeSize);
|
||||
}
|
||||
|
||||
const atUint8* ptrStart = src;
|
||||
const atUint8* ptrEnd = src + srcLength;
|
||||
const uint8_t* ptrStart = src;
|
||||
const uint8_t* ptrEnd = src + srcLength;
|
||||
|
||||
// At most their will be two bytes written if the bytes can be compressed. So if all bytes in the block can be
|
||||
// compressed it would take blockSize*2 bytes
|
||||
|
||||
// Holds the compressed bytes yet to be written
|
||||
auto compressedBytes = std::unique_ptr<atUint8[]>(new atUint8[m_blockSize * 2]);
|
||||
auto compressedBytes = std::unique_ptr<uint8_t[]>(new uint8_t[m_blockSize * 2]);
|
||||
|
||||
const atUint8 maxTwoByteMatch = 0xF + 1;
|
||||
const atUint8 minThreeByteMatch = maxTwoByteMatch + 1; // Minimum Three byte match is maximum TwoByte match + 1
|
||||
const atUint16 maxThreeByteMatch = 0xFF + minThreeByteMatch;
|
||||
const atUint16 minFourByteMatch = maxThreeByteMatch + 1; // Minimum Four byte match is maximum Three Byte match + 1
|
||||
const atInt32 maxFourByteMatch = 0xFFFF + minFourByteMatch;
|
||||
const uint8_t maxTwoByteMatch = 0xF + 1;
|
||||
const uint8_t minThreeByteMatch = maxTwoByteMatch + 1; // Minimum Three byte match is maximum TwoByte match + 1
|
||||
const uint16_t maxThreeByteMatch = 0xFF + minThreeByteMatch;
|
||||
const uint16_t minFourByteMatch = maxThreeByteMatch + 1; // Minimum Four byte match is maximum Three Byte match + 1
|
||||
const int32_t maxFourByteMatch = 0xFFFF + minFourByteMatch;
|
||||
|
||||
/*
|
||||
Normaliazation Example: If MIN_MATCH is 3 then 3 gets mapped to 2 and 16 gets mapped to 15.
|
||||
@@ -59,36 +59,36 @@ atUint32 LZType11::compress(const atUint8* src, atUint8** dst, atUint32 srcLengt
|
||||
In the four byte case the first 4 bits a 0001
|
||||
*/
|
||||
while (ptrStart < ptrEnd) {
|
||||
atUint8 blockSize = 0;
|
||||
uint8_t blockSize = 0;
|
||||
// In Binary represents 1 if byte is compressed or 0 if not compressed
|
||||
// For example 01001000 means that the second and fifth byte in the blockSize from the left is compressed
|
||||
atUint8* ptrBytes = compressedBytes.get();
|
||||
uint8_t* ptrBytes = compressedBytes.get();
|
||||
|
||||
for (atInt32 i = 0; i < m_blockSize; i++) {
|
||||
for (int32_t i = 0; i < m_blockSize; i++) {
|
||||
// length_offset searchResult=Search(filedata,ptrStart,ptrEnd);
|
||||
const LZLengthOffset searchResult = m_lookupTable.search(ptrStart, src, ptrEnd);
|
||||
|
||||
// If the number of bytes to be compressed is at least the size of the Minimum match
|
||||
if (searchResult.length >= static_cast<atUint32>(m_minMatch)) {
|
||||
if (searchResult.length >= static_cast<uint32_t>(m_minMatch)) {
|
||||
// Gotta swap the bytes since system is wii is big endian and most computers are little endian
|
||||
|
||||
if (searchResult.length <= maxTwoByteMatch) {
|
||||
atUint16 lenOff = ((((searchResult.length - 1) & 0xF) << 12) | // Bits 15-12
|
||||
uint16_t lenOff = ((((searchResult.length - 1) & 0xF) << 12) | // Bits 15-12
|
||||
((searchResult.offset - 1) & 0xFFF) // Bits 11-0
|
||||
);
|
||||
athena::utility::BigUint16(lenOff);
|
||||
memcpy(ptrBytes, &lenOff, 2);
|
||||
ptrBytes += 2;
|
||||
} else if (searchResult.length <= maxThreeByteMatch) {
|
||||
atUint32 lenOff = ((((searchResult.length - minThreeByteMatch) & 0xFF) << 12) | // Bits 20-12
|
||||
uint32_t lenOff = ((((searchResult.length - minThreeByteMatch) & 0xFF) << 12) | // Bits 20-12
|
||||
((searchResult.offset - 1) & 0xFFF) // Bits 11-0
|
||||
);
|
||||
athena::utility::BigUint32(lenOff);
|
||||
memcpy(ptrBytes, reinterpret_cast<atUint8*>(&lenOff) + 1,
|
||||
memcpy(ptrBytes, reinterpret_cast<uint8_t*>(&lenOff) + 1,
|
||||
3); // Make sure to copy the lower 24 bits. 0x12345678- This statement copies 0x123456
|
||||
ptrBytes += 3;
|
||||
} else if (searchResult.length <= static_cast<atUint32>(maxFourByteMatch)) {
|
||||
atUint32 lenOff = ((1 << 28) | // Bits 31-28 Flag to say that this is four bytes
|
||||
} else if (searchResult.length <= static_cast<uint32_t>(maxFourByteMatch)) {
|
||||
uint32_t lenOff = ((1 << 28) | // Bits 31-28 Flag to say that this is four bytes
|
||||
(((searchResult.length - minFourByteMatch) & 0xFFFF) << 12) | // Bits 28-12
|
||||
((searchResult.offset - 1) & 0xFFF) // Bits 11-0
|
||||
);
|
||||
@@ -108,7 +108,7 @@ atUint32 LZType11::compress(const atUint8* src, atUint8** dst, atUint32 srcLengt
|
||||
}
|
||||
|
||||
outbuff.writeByte(blockSize);
|
||||
outbuff.writeUBytes(compressedBytes.get(), static_cast<atUint64>(ptrBytes - compressedBytes.get()));
|
||||
outbuff.writeUBytes(compressedBytes.get(), static_cast<uint64_t>(ptrBytes - compressedBytes.get()));
|
||||
}
|
||||
|
||||
// Add zeros until the file is a multiple of 4
|
||||
@@ -117,66 +117,66 @@ atUint32 LZType11::compress(const atUint8* src, atUint8** dst, atUint32 srcLengt
|
||||
}
|
||||
|
||||
*dst = outbuff.data();
|
||||
return static_cast<atUint32>(outbuff.length());
|
||||
return static_cast<uint32_t>(outbuff.length());
|
||||
}
|
||||
|
||||
atUint32 LZType11::decompress(const atUint8* src, atUint8** dst, atUint32 srcLength) {
|
||||
uint32_t LZType11::decompress(const uint8_t* src, uint8_t** dst, uint32_t srcLength) {
|
||||
if (*src != 0x11) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
atUint32 uncompressedLen;
|
||||
uint32_t uncompressedLen;
|
||||
std::memcpy(&uncompressedLen, src, sizeof(uncompressedLen));
|
||||
athena::utility::LittleUint32(uncompressedLen); // The compressed file has the filesize encoded in little endian
|
||||
uncompressedLen = uncompressedLen >> 8; // First byte is the encode flag
|
||||
atUint32 currentOffset = 4;
|
||||
uint32_t currentOffset = 4;
|
||||
|
||||
// If the filesize var is zero then the true filesize is over 14MB and must be read in from the next 4 bytes
|
||||
if (uncompressedLen == 0) {
|
||||
atUint32 filesize;
|
||||
uint32_t filesize;
|
||||
std::memcpy(&filesize, src + 4, sizeof(filesize));
|
||||
filesize = athena::utility::LittleUint32(filesize);
|
||||
currentOffset += 4;
|
||||
}
|
||||
|
||||
auto uncompressedData = std::unique_ptr<atUint8[]>(new atUint8[uncompressedLen]);
|
||||
atUint8* outputPtr = uncompressedData.get();
|
||||
atUint8* outputEndPtr = uncompressedData.get() + uncompressedLen;
|
||||
const atUint8* inputPtr = src + currentOffset;
|
||||
const atUint8* inputEndPtr = src + srcLength;
|
||||
auto uncompressedData = std::unique_ptr<uint8_t[]>(new uint8_t[uncompressedLen]);
|
||||
uint8_t* outputPtr = uncompressedData.get();
|
||||
uint8_t* outputEndPtr = uncompressedData.get() + uncompressedLen;
|
||||
const uint8_t* inputPtr = src + currentOffset;
|
||||
const uint8_t* inputEndPtr = src + srcLength;
|
||||
|
||||
LZLengthOffset decoding;
|
||||
const atUint8 maxTwoByteMatch = 0xF + 1;
|
||||
const atUint8 threeByteDenorm = maxTwoByteMatch + 1; // Amount to add to length when compression is 3 bytes
|
||||
const atUint16 maxThreeByteMatch = 0xFF + threeByteDenorm;
|
||||
const atUint16 fourByteDenorm = maxThreeByteMatch + 1;
|
||||
const uint8_t maxTwoByteMatch = 0xF + 1;
|
||||
const uint8_t threeByteDenorm = maxTwoByteMatch + 1; // Amount to add to length when compression is 3 bytes
|
||||
const uint16_t maxThreeByteMatch = 0xFF + threeByteDenorm;
|
||||
const uint16_t fourByteDenorm = maxThreeByteMatch + 1;
|
||||
|
||||
while (inputPtr < inputEndPtr && outputPtr < outputEndPtr) {
|
||||
const atUint8 isCompressed = *inputPtr++;
|
||||
const uint8_t isCompressed = *inputPtr++;
|
||||
|
||||
for (atInt32 i = 0; i < m_blockSize; i++) {
|
||||
for (int32_t i = 0; i < m_blockSize; i++) {
|
||||
// Checks to see if the next byte is compressed by looking
|
||||
// at its binary representation - E.g 10010000
|
||||
// This says that the first extracted byte and the four extracted byte is compressed
|
||||
if ((isCompressed >> (7 - i)) & 0x1) {
|
||||
const atUint8 metaDataSize = *inputPtr >> 4; // Look at the top 4 bits
|
||||
const uint8_t metaDataSize = *inputPtr >> 4; // Look at the top 4 bits
|
||||
|
||||
if (metaDataSize >= 2) { // Two Bytes of Length/Offset MetaData
|
||||
atUint16 lenOff = 0;
|
||||
uint16_t lenOff = 0;
|
||||
memcpy(&lenOff, inputPtr, 2);
|
||||
inputPtr += 2;
|
||||
athena::utility::BigUint16(lenOff);
|
||||
decoding.length = (lenOff >> 12) + 1;
|
||||
decoding.offset = (lenOff & 0xFFF) + 1;
|
||||
} else if (metaDataSize == 0) { // Three Bytes of Length/Offset MetaData
|
||||
atUint32 lenOff = 0;
|
||||
memcpy(reinterpret_cast<atUint8*>(&lenOff) + 1, inputPtr, 3);
|
||||
uint32_t lenOff = 0;
|
||||
memcpy(reinterpret_cast<uint8_t*>(&lenOff) + 1, inputPtr, 3);
|
||||
inputPtr += 3;
|
||||
athena::utility::BigUint32(lenOff);
|
||||
decoding.length = (lenOff >> 12) + threeByteDenorm;
|
||||
decoding.offset = (lenOff & 0xFFF) + 1;
|
||||
} else if (metaDataSize == 1) { // Four Bytes of Length/Offset MetaData
|
||||
atUint32 lenOff = 0;
|
||||
uint32_t lenOff = 0;
|
||||
memcpy(&lenOff, inputPtr, 4);
|
||||
inputPtr += 4;
|
||||
athena::utility::BigUint32(lenOff);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user