Remove atdna and fmt

This commit is contained in:
Phillip Stephens 2025-01-02 01:17:06 -08:00
parent fa346ace47
commit f7c1cd8f59
35 changed files with 104 additions and 4658 deletions

4
.gitmodules vendored
View File

@ -2,7 +2,3 @@
path = extern/lzokay
url = https://github.com/AxioDL/lzokay.git
branch = master
[submodule "extern/fmt"]
path = extern/fmt
url = https://github.com/fmtlib/fmt
branch = master

View File

@ -156,7 +156,6 @@ add_library(athena-core
src/LZ77/LZBase.cpp
src/athena/FileInfo.cpp
src/athena/Dir.cpp
src/athena/DNAYaml.cpp
include/athena/IStream.hpp
include/athena/IStreamReader.hpp
@ -179,9 +178,6 @@ 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
@ -225,7 +221,6 @@ target_include_directories(athena-core PUBLIC
)
target_link_libraries(athena-core PUBLIC
athena-libyaml
fmt
$<BUILD_INTERFACE:${ZLIB_LIBRARIES}>
)
@ -245,6 +240,9 @@ 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
src/athena/WiiBanner.cpp
@ -271,6 +269,9 @@ add_library(athena-wiisave EXCLUDE_FROM_ALL
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()
@ -310,7 +311,9 @@ 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)
@ -331,12 +334,9 @@ endforeach()
# Define installs
install(DIRECTORY include/athena DESTINATION ${INSTALL_INCLUDE_DIR} COMPONENT athena)
install(DIRECTORY extern/fmt/include/fmt DESTINATION ${INSTALL_INCLUDE_DIR} COMPONENT athena)
if (ATHENA_ZLIB)
set(ZLIB_INSTALL ${ZLIB_LIBRARIES})
endif ()
install(TARGETS athena-core fmt ${ZLIB_INSTALL}
DESTINATION ${INSTALL_LIB_DIR} EXPORT AthenaTargets COMPONENT athena)
if(WIN32 AND NOT CYGWIN)
install(FILES Athena.ico DESTINATION ${INSTALL_LIB_DIR} COMPONENT athena)
elseif(UNIX)
@ -350,9 +350,6 @@ endif()
# Package Export #
##################
# Add all targets to the build-tree export set
export(TARGETS athena-core athena-libyaml fmt ${ZLIB_LIBRARIES} 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)
@ -380,23 +377,6 @@ 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)
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()
target_atdna(atdna-test atdna_test.cpp atdna/test.hpp)
endif()
#########
# CPack #
#########

View File

@ -1,171 +0,0 @@
###############
# ATDNA Build #
###############
if(NOT TARGET atdna AND NOT CMAKE_CROSSCOMPILING)
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
if (NOT "${LLVM_ROOT_DIR}" STREQUAL "")
# use existing LLVM_ROOT_DIR
elseif (APPLE AND CMAKE_SYSTEM_PROCESSOR STREQUAL x86_64)
set(LLVM_ROOT_DIR /usr/local/opt/llvm)
elseif (APPLE AND CMAKE_SYSTEM_PROCESSOR STREQUAL arm64)
set(LLVM_ROOT_DIR /opt/homebrew/opt/llvm)
elseif (WIN32)
get_filename_component(LLVM_ROOT_DIR [HKEY_LOCAL_MACHINE\\Software\\LLVM\\LLVM] ABSOLUTE)
else ()
set(LLVM_ROOT_DIR "")
endif ()
find_package(Clang REQUIRED PATHS ${LLVM_ROOT_DIR})
find_package(LLVM REQUIRED PATHS ${CLANG_INSTALL_PREFIX})
if(LLVM_FOUND)
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()
set(CLANG_LIBS "")
set(LLVM_LIBS "")
if (ATDNA_DYNAMIC_LLVM)
list(APPEND CLANG_LIBS clang-cpp)
list(APPEND LLVM_LIBS LLVM)
else()
function(recursive_remove_library target library)
get_target_property(target_dependencies ${target} INTERFACE_LINK_LIBRARIES)
foreach(dep ${target_dependencies})
if (NOT "${dep}" STREQUAL "${library}" AND TARGET "${dep}")
recursive_remove_library(${dep} ${library})
endif()
endforeach()
list(FIND target_dependencies "${library}" list_index)
if (${list_index} GREATER -1)
list(REMOVE_AT target_dependencies ${list_index})
set_property(TARGET ${target} PROPERTY INTERFACE_LINK_LIBRARIES "${target_dependencies}")
endif()
endfunction()
# Add LLVM static libs
list(APPEND CLANG_LIBS clangTooling)
list(APPEND LLVM_LIBS LLVMFrontendOpenMP LLVMOption)
# Remove LLVM dynamic library from Clang dependencies
foreach (lib ${CLANG_LIBS})
recursive_remove_library(${lib} LLVM)
endforeach ()
# Hack around link order issues
target_link_libraries(clangAST INTERFACE LLVMFrontendOpenMP)
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")
set(INSTALL_CMAKE_DIR lib/cmake/atdna)
# 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 ${CLANG_LIBS} ${LLVM_LIBS})
if (APPLE)
set(ATDNA_ARGV0 clang-tool)
else ()
set(ATDNA_ARGV0 "${LLVM_TOOLS_BINARY_DIR}/clang-tool")
endif ()
target_compile_definitions(atdna PRIVATE
INSTALL_PREFIX=${ABS_INSTALL_BIN_DIR}
__STDC_LIMIT_MACROS=1
__STDC_CONSTANT_MACROS=1
ATDNA_ARGV0=${ATDNA_ARGV0})
target_include_directories(atdna PRIVATE ${CLANG_INCLUDE_DIRS})
# Clang 10.0.x headers currently broken with C++20
set_property(TARGET atdna PROPERTY CXX_STANDARD 17)
if(MSVC)
if (VCPKG_TOOLCHAIN)
# Assumes static build of LLVM
if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
set_property(TARGET atdna PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreadedDebug")
else ()
set_property(TARGET atdna PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded")
endif ()
else ()
# 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")
endif ()
else ()
target_compile_options(atdna PRIVATE -fno-rtti -fvisibility=hidden -Wno-error)
if (METAFORCE_ASAN AND CMAKE_SYSTEM_NAME STREQUAL "Linux")
# On Linux, we need to compile without ASAN; explicitly disable it here
target_compile_options(atdna PRIVATE -stdlib=libstdc++ -fno-sanitize=address)
target_link_options(atdna PRIVATE -stdlib=libstdc++ -fno-sanitize=address)
endif ()
endif()
# Define installs
install(TARGETS atdna DESTINATION ${INSTALL_BIN_DIR} EXPORT atdnaTargets COMPONENT atdna)
install(DIRECTORY ${LLVM_INCLUDE_DIR}/clang DESTINATION ${INSTALL_INCLUDE_DIR}/athena 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()
endif()
include(atdnaHelpers.cmake)

View File

@ -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)

View File

@ -1,88 +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})
if (NOT dir MATCHES ".*emscripten.*")
list(APPEND inccli "-I${dir}")
endif()
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()
file(GLOB SYSTEM_INCLUDE_DIR "${COMPILER_DIR}/../lib/clang/*/include")
list(APPEND extraargs
-isysroot ${CMAKE_OSX_SYSROOT}
-stdlib++-isystem "${COMPILER_DIR}/../include/c++/v1"
-isystem "${SYSTEM_INCLUDE_DIR}")
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()

View File

@ -1,12 +0,0 @@
set(PACKAGE_VERSION "@ATHENA_VERSION_STRING@")
# 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()

View File

@ -1,164 +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()
set(inccli "")
foreach(dir ${incdirs})
if (NOT dir MATCHES ".*emscripten.*")
list(APPEND inccli "-I${dir}")
endif()
endforeach()
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()
file(GLOB SYSTEM_INCLUDE_DIR "${COMPILER_DIR}/../lib/clang/*/include")
list(APPEND extraargs
-isysroot ${CMAKE_OSX_SYSROOT}
-stdlib++-isystem "${COMPILER_DIR}/../include/c++/v1"
-isystem "${SYSTEM_INCLUDE_DIR}")
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
${inccli} ${cdefcli}
"-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}
${inccli} ${cdefcli}
"-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()

File diff suppressed because it is too large Load Diff

View File

@ -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_VERSION@"
VALUE "LegalCopyright", "Copyright (C) 2016 Jackoalan / Antidote"
VALUE "InternalName", "atdna"
VALUE "OriginalFilename", "atdna.exe"
VALUE "ProductName", "ATDNA"
VALUE "ProductVersion", "@ATHENA_VERSION@"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x0, 1200
END
END

View File

@ -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;
}

View File

@ -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;
};

18
extern/CMakeLists.txt vendored
View File

@ -1,14 +1,8 @@
add_subdirectory(lzokay)
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
target_compile_options(lzokay PRIVATE -Wno-maybe-uninitialized)
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_ARM_ABI_COMPATIBILITY=1
FMT_EXCEPTIONS=0)
target_compile_definitions(fmt INTERFACE
FMT_ENFORCE_COMPILE_STRING=1)
endif()
add_subdirectory(yaml)

1
extern/fmt vendored

@ -1 +0,0 @@
Subproject commit 9e8b86fd2d9806672cc73133d21780dd182bfd24

2
extern/lzokay vendored

@ -1 +1 @@
Subproject commit ee8b4c29ad0fabcaa210962e30c081d05e55e2b3
Subproject commit db2df1fcbebc2ed06c10f727f72567d40f06a2be

View File

@ -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

View File

@ -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

View File

@ -3,7 +3,7 @@
#include <ostream>
#include "athena/Types.hpp"
#include <fmt/format.h>
#include <format>
#ifdef _MSC_VER
#pragma warning(disable : 4996)
@ -17,11 +17,11 @@
#include <sys/stat.h>
#if !defined(S_ISREG) && defined(S_IFMT) && defined(S_IFREG)
#define S_ISREG(m) (((m)&S_IFMT) == S_IFREG)
#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
#endif
#if !defined(S_ISDIR) && defined(S_IFMT) && defined(S_IFDIR)
#define S_ISDIR(m) (((m)&S_IFMT) == S_IFDIR)
#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
#endif
#if !defined(S_ISLNK)
@ -118,27 +118,10 @@ 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();
/**
@ -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)

View File

@ -661,7 +661,7 @@ 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;
@ -675,7 +675,7 @@ public:
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;
@ -709,7 +709,7 @@ 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;
@ -723,7 +723,7 @@ public:
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;
@ -758,7 +758,7 @@ 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;
@ -772,7 +772,7 @@ public:
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;

View File

@ -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;

View File

@ -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;

File diff suppressed because it is too large Load Diff

View File

@ -51,7 +51,7 @@ bool Dir::rm(std::string_view path) { return !(remove((m_path + "/" + path.data(
bool Dir::touch() {
std::srand(std::time(nullptr));
atUint64 tmp = utility::rand64();
std::string tmpFile = fmt::format(FMT_STRING("{:016X}.tmp"), tmp);
std::string tmpFile = std::format("{:016X}.tmp", tmp);
bool ret = FileInfo(m_path + "/" + tmpFile).touch();
if (ret)
return rm(tmpFile);

View File

@ -33,7 +33,7 @@ void FileReader::open() {
if (!m_fileHandle) {
std::string _filename = filename();
if (m_globalErr)
atError(FMT_STRING("File not found '{}'"), _filename);
atError("File not found '{}'", _filename);
setError();
return;
}
@ -47,7 +47,7 @@ void FileReader::open() {
void FileReader::close() {
if (!m_fileHandle) {
if (m_globalErr)
atError(FMT_STRING("Cannot close an unopened stream"));
atError("Cannot close an unopened stream");
setError();
return;
}
@ -76,7 +76,7 @@ void FileReader::seek(atInt64 pos, SeekOrigin origin) {
}
if (m_offset > length()) {
if (m_globalErr)
atError(FMT_STRING("Unable to seek in file"));
atError("Unable to seek in file");
setError();
return;
}
@ -89,7 +89,7 @@ void FileReader::seek(atInt64 pos, SeekOrigin origin) {
}
} else if (fseeko64(m_fileHandle, pos, int(origin)) != 0) {
if (m_globalErr)
atError(FMT_STRING("Unable to seek in file"));
atError("Unable to seek in file");
setError();
}
}
@ -97,7 +97,7 @@ void FileReader::seek(atInt64 pos, SeekOrigin origin) {
atUint64 FileReader::position() const {
if (!isOpen()) {
if (m_globalErr)
atError(FMT_STRING("File not open"));
atError("File not open");
return 0;
}
@ -110,7 +110,7 @@ atUint64 FileReader::position() const {
atUint64 FileReader::length() const {
if (!isOpen()) {
if (m_globalErr)
atError(FMT_STRING("File not open"));
atError("File not open");
return 0;
}
@ -120,7 +120,7 @@ atUint64 FileReader::length() const {
atUint64 FileReader::readUBytesToBuf(void* buf, atUint64 len) {
if (!isOpen()) {
if (m_globalErr)
atError(FMT_STRING("File not open for reading"));
atError("File not open for reading");
setError();
return 0;
}

View File

@ -48,8 +48,9 @@ void FileWriter::open(bool overwrite) {
}
if (!m_fileHandle) {
if (m_globalErr)
atError(FMT_STRING("Unable to open file '%s'"), filename().c_str());
if (m_globalErr) {
atError("Unable to open file '{}'", m_filename);
}
setError();
return;
}
@ -61,7 +62,7 @@ void FileWriter::open(bool overwrite) {
void FileWriter::close() {
if (!m_fileHandle) {
if (m_globalErr)
atError(FMT_STRING("Cannot close an unopened stream"));
atError("Cannot close an unopened stream");
setError();
return;
}
@ -81,14 +82,14 @@ void FileWriter::close() {
void FileWriter::seek(atInt64 pos, SeekOrigin origin) {
if (!isOpen()) {
if (m_globalErr)
atError(FMT_STRING("Unable to seek in file, not open"));
atError("Unable to seek in file, not open");
setError();
return;
}
if (fseeko64(m_fileHandle, pos, int(origin)) != 0) {
if (m_globalErr)
atError(FMT_STRING("Unable to seek in file"));
atError("Unable to seek in file");
setError();
}
}
@ -100,14 +101,14 @@ atUint64 FileWriter::length() const { return utility::fileSize(m_filename); }
void FileWriter::writeUBytes(const atUint8* data, atUint64 len) {
if (!isOpen()) {
if (m_globalErr)
atError(FMT_STRING("File not open for writing"));
atError("File not open for writing");
setError();
return;
}
if (fwrite(data, 1, len, m_fileHandle) != len) {
if (m_globalErr)
atError(FMT_STRING("Unable to write to stream"));
atError("Unable to write to stream");
setError();
}
}

View File

@ -35,7 +35,7 @@ std::ostream& operator<<(std::ostream& os, const athena::Endian& endian) {
}
static void __defaultExceptionHandler(athena::error::Level level, const char* file, const char* function, int line,
fmt::string_view fmt, fmt::format_args args) {
std::string_view fmt, std::format_args args) {
std::string levelStr;
switch (level) {
case athena::error::Level::Warning:
@ -51,7 +51,7 @@ static void __defaultExceptionHandler(athena::error::Level level, const char* fi
break;
}
std::string msg = fmt::vformat(fmt, args);
std::string msg = std::vformat(fmt, args);
std::cerr << levelStr << " " << file << " " << function << "(" << line << "): " << msg << std::endl;
}

View File

@ -13,7 +13,7 @@ MemoryReader::MemoryReader(const void* data, atUint64 length, bool takeOwnership
: m_data(data), m_length(length), m_position(0), m_owns(takeOwnership), m_globalErr(globalErr) {
if (!data) {
if (m_globalErr)
atError(FMT_STRING("data cannot be NULL"));
atError("data cannot be NULL");
setError();
return;
}
@ -27,7 +27,7 @@ MemoryReader::~MemoryReader() {
MemoryCopyReader::MemoryCopyReader(const void* data, atUint64 length) : MemoryReader(data, length, false) {
if (!data) {
if (m_globalErr)
atError(FMT_STRING("data cannot be NULL"));
atError("data cannot be NULL");
setError();
return;
}
@ -42,7 +42,7 @@ void MemoryReader::seek(atInt64 position, SeekOrigin origin) {
case SeekOrigin::Begin:
if ((position < 0 || atInt64(position) > atInt64(m_length))) {
if (m_globalErr)
atFatal(FMT_STRING("Position {:08X} outside stream bounds "), position);
atFatal("Position {:08X} outside stream bounds ", position);
m_position = m_length;
setError();
return;
@ -54,7 +54,7 @@ void MemoryReader::seek(atInt64 position, SeekOrigin origin) {
case SeekOrigin::Current:
if (((atInt64(m_position) + position) < 0 || (m_position + atUint64(position)) > m_length)) {
if (m_globalErr)
atFatal(FMT_STRING("Position {:08X} outside stream bounds "), position);
atFatal("Position {:08X} outside stream bounds ", position);
m_position = (position < 0 ? 0 : m_length);
setError();
return;
@ -66,7 +66,7 @@ void MemoryReader::seek(atInt64 position, SeekOrigin origin) {
case SeekOrigin::End:
if ((((atInt64)m_length - position < 0) || (m_length - position) > m_length)) {
if (m_globalErr)
atFatal(FMT_STRING("Position {:08X} outside stream bounds "), position);
atFatal("Position {:08X} outside stream bounds ", position);
m_position = m_length;
setError();
return;
@ -104,7 +104,7 @@ atUint8* MemoryReader::data() const {
atUint64 MemoryReader::readUBytesToBuf(void* buf, atUint64 length) {
if (m_position >= m_length) {
if (m_globalErr)
atError(FMT_STRING("Position {:08X} outside stream bounds "), m_position);
atError("Position {:08X} outside stream bounds ", m_position);
m_position = m_length;
setError();
return 0;
@ -123,7 +123,7 @@ void MemoryCopyReader::loadData() {
if (!in) {
if (m_globalErr)
atError(FMT_STRING("Unable to open file '%s'"), m_filepath);
atError("Unable to open file '%s'", m_filepath);
setError();
return;
}
@ -145,7 +145,7 @@ void MemoryCopyReader::loadData() {
if (ret < 0) {
if (m_globalErr)
atError(FMT_STRING("Error reading data from disk"));
atError("Error reading data from disk");
setError();
return;
} else if (ret == 0)

View File

@ -12,7 +12,7 @@ namespace athena::io {
MemoryWriter::MemoryWriter(atUint8* data, atUint64 length, bool takeOwnership)
: m_data(data), m_length(length), m_bufferOwned(takeOwnership) {
if (!data) {
atError(FMT_STRING("data cannot be NULL"));
atError("data cannot be NULL");
setError();
return;
}
@ -32,7 +32,7 @@ MemoryCopyWriter::MemoryCopyWriter(atUint8* data, atUint64 length) {
m_bufferOwned = false;
if (length == 0) {
atError(FMT_STRING("length cannot be 0"));
atError("length cannot be 0");
setError();
return;
}
@ -51,7 +51,7 @@ MemoryCopyWriter::MemoryCopyWriter(std::string_view filename) {
m_bufferOwned = false;
if (!m_data) {
atError(FMT_STRING("Could not allocate memory!"));
atError("Could not allocate memory!");
setError();
return;
}
@ -61,13 +61,13 @@ void MemoryWriter::seek(atInt64 position, SeekOrigin origin) {
switch (origin) {
case SeekOrigin::Begin:
if (position < 0) {
atError(FMT_STRING("Position outside stream bounds"));
atError("Position outside stream bounds");
setError();
return;
}
if ((atUint64)position > m_length) {
atError(FMT_STRING("data exceeds available buffer space"));
atError("data exceeds available buffer space");
setError();
return;
}
@ -77,13 +77,13 @@ void MemoryWriter::seek(atInt64 position, SeekOrigin origin) {
case SeekOrigin::Current:
if ((((atInt64)m_position + position) < 0)) {
atError(FMT_STRING("Position outside stream bounds"));
atError("Position outside stream bounds");
setError();
return;
}
if (m_position + position > m_length) {
atError(FMT_STRING("data exceeds available buffer space"));
atError("data exceeds available buffer space");
setError();
return;
}
@ -93,13 +93,13 @@ void MemoryWriter::seek(atInt64 position, SeekOrigin origin) {
case SeekOrigin::End:
if (((atInt64)m_length - position) < 0) {
atError(FMT_STRING("Position outside stream bounds"));
atError("Position outside stream bounds");
setError();
return;
}
if ((atUint64)position > m_length) {
atError(FMT_STRING("data exceeds available buffer space"));
atError("data exceeds available buffer space");
setError();
return;
}
@ -113,7 +113,7 @@ void MemoryCopyWriter::seek(atInt64 position, SeekOrigin origin) {
switch (origin) {
case SeekOrigin::Begin:
if (position < 0) {
atError(FMT_STRING("Position outside stream bounds"));
atError("Position outside stream bounds");
setError();
return;
}
@ -126,7 +126,7 @@ void MemoryCopyWriter::seek(atInt64 position, SeekOrigin origin) {
case SeekOrigin::Current:
if ((((atInt64)m_position + position) < 0)) {
atError(FMT_STRING("Position outside stream bounds"));
atError("Position outside stream bounds");
setError();
return;
}
@ -139,7 +139,7 @@ void MemoryCopyWriter::seek(atInt64 position, SeekOrigin origin) {
case SeekOrigin::End:
if (((atInt64)m_length - position) < 0) {
atError(FMT_STRING("Position outside stream bounds"));
atError("Position outside stream bounds");
setError();
return;
}
@ -180,7 +180,7 @@ atUint8* MemoryWriter::data() const {
void MemoryWriter::save(std::string_view filename) {
if (filename.empty() && m_filepath.empty()) {
atError(FMT_STRING("No file specified, cannot save."));
atError("No file specified, cannot save.");
setError();
return;
}
@ -191,7 +191,7 @@ void MemoryWriter::save(std::string_view filename) {
std::unique_ptr<FILE, decltype(&std::fclose)> out{std::fopen(m_filepath.c_str(), "wb"), std::fclose};
if (!out) {
atError(FMT_STRING("Unable to open file '{}'"), m_filepath);
atError("Unable to open file '{}'", m_filepath);
setError();
return;
}
@ -207,7 +207,7 @@ void MemoryWriter::save(std::string_view filename) {
const atInt64 ret = std::fwrite(m_data + done, 1, blocksize, out.get());
if (ret < 0) {
atError(FMT_STRING("Error writing data to disk"));
atError("Error writing data to disk");
setError();
return;
}
@ -222,13 +222,13 @@ void MemoryWriter::save(std::string_view filename) {
void MemoryWriter::writeUBytes(const atUint8* data, atUint64 length) {
if (!data) {
atError(FMT_STRING("data cannnot be NULL"));
atError("data cannnot be NULL");
setError();
return;
}
if (m_position + length > m_length) {
atError(FMT_STRING("data length exceeds available buffer space"));
atError("data length exceeds available buffer space");
setError();
return;
}
@ -240,7 +240,7 @@ void MemoryWriter::writeUBytes(const atUint8* data, atUint64 length) {
void MemoryCopyWriter::writeUBytes(const atUint8* data, atUint64 length) {
if (!data) {
atError(FMT_STRING("data cannnot be NULL"));
atError("data cannnot be NULL");
setError();
return;
}
@ -255,7 +255,7 @@ void MemoryCopyWriter::writeUBytes(const atUint8* data, atUint64 length) {
void MemoryCopyWriter::resize(atUint64 newSize) {
if (newSize < m_length) {
atError(FMT_STRING("New size cannot be less to the old size."));
atError("New size cannot be less to the old size.");
return;
}

View File

@ -1,7 +1,7 @@
#include "athena/SkywardSwordQuest.hpp"
#include "athena/Checksums.hpp"
#include "athena/Utility.hpp"
#include "utf8proc.h"
#include "athena/utf8proc.h"
#include <sstream>
namespace athena {

View File

@ -16,6 +16,7 @@
#endif
#include "athena/Global.hpp"
#include <string.h>
namespace athena::net {
@ -84,7 +85,7 @@ bool Socket::openSocket() {
m_socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if (m_socket == -1) {
atError(FMT_STRING("Can't allocate socket"));
atError("Can't allocate socket");
return false;
}
@ -138,13 +139,13 @@ bool Socket::openAndListen(const IPAddress& address, uint32_t port) {
sockaddr_in addr = createAddress(address.toInteger(), port);
if (bind(m_socket, reinterpret_cast<sockaddr*>(&addr), sizeof(addr)) == -1) {
/* Not likely to happen, but... */
atError(FMT_STRING("Failed to bind listener socket to port {}"), port);
atError("Failed to bind listener socket to port {}", port);
return false;
}
if (::listen(m_socket, 0) == -1) {
/* Oops, socket is deaf */
atError(FMT_STRING("Failed to listen to port {}"), port);
atError("Failed to listen to port {}", port);
return false;
}
@ -163,8 +164,10 @@ Socket::EResult Socket::accept(Socket& remoteSocketOut, sockaddr_in& fromAddress
if (remoteSocket == -1) {
#ifndef _WIN32
EResult res = (errno == EAGAIN) ? EResult::Busy : EResult::Error;
if (res == EResult::Error)
atError(FMT_STRING("Failed to accept incoming connection: {}"), strerror(errno));
if (res == EResult::Error) {
auto err = strerror(errno);
atError("Failed to accept incoming connection: {}", err);
}
#else
EResult res = LastWSAError();
if (res == EResult::Error)

View File

@ -51,7 +51,6 @@ Sakura::SpriteFile* SpriteFileReader::readFile() {
// which require data to be 32 byte aligned, or it causes some issues.
// It's also convenient to have this, for later expansion.
atUint32 reserved = readUint32();
UNUSED(reserved);
// Next we have to load the textures
// If we tried to add them one at a time to the sprite container

View File

@ -167,7 +167,7 @@ std::string wideToUtf8(std::wstring_view src) {
utf8proc_uint8_t mb[4];
utf8proc_ssize_t c = utf8proc_encode_char(utf8proc_int32_t(ch), mb);
if (c < 0) {
atWarning(FMT_STRING("invalid UTF-8 character while encoding"));
atWarning("invalid UTF-8 character while encoding");
return retval;
}
retval.append(reinterpret_cast<char*>(mb), c);
@ -183,7 +183,7 @@ std::wstring utf8ToWide(std::string_view src) {
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 retval;
}
buf += len;

View File

@ -10,7 +10,7 @@ void VectorWriter::seek(atInt64 position, SeekOrigin origin) {
switch (origin) {
case SeekOrigin::Begin:
if (position < 0) {
atError(FMT_STRING("Position outside stream bounds"));
atError("Position outside stream bounds");
setError();
return;
}
@ -23,7 +23,7 @@ void VectorWriter::seek(atInt64 position, SeekOrigin origin) {
case SeekOrigin::Current:
if ((((atInt64)m_position + position) < 0)) {
atError(FMT_STRING("Position outside stream bounds"));
atError("Position outside stream bounds");
setError();
return;
}
@ -36,13 +36,13 @@ void VectorWriter::seek(atInt64 position, SeekOrigin origin) {
case SeekOrigin::End:
if (((atInt64)m_data.size() - position) < 0) {
atError(FMT_STRING("Position outside stream bounds"));
atError("Position outside stream bounds");
setError();
return;
}
if ((atUint64)position > m_data.size()) {
atError(FMT_STRING("data exceeds vector size"));
atError("data exceeds vector size");
setError();
return;
}
@ -54,7 +54,7 @@ void VectorWriter::seek(atInt64 position, SeekOrigin origin) {
void VectorWriter::writeUBytes(const atUint8* data, atUint64 length) {
if (!data) {
atError(FMT_STRING("data cannnot be NULL"));
atError("data cannnot be NULL");
setError();
return;
}

View File

@ -78,7 +78,7 @@ bool WiiFile::isFile() const { return (m_type == WiiFile::File); }
void WiiFile::addChild(WiiFile* file) {
if (!isDirectory()) {
atWarning("{} is not a directory", filename());
atWarning("{} is not a directory", m_filename);
return;
}

View File

@ -78,7 +78,7 @@ static void square(atUint8* d, const atUint8* a) {
static void itInvert(atUint8* d, const atUint8* a, const atUint8* b, atUint32 j) {
atUint8 t[30];
memcpy(t, a, 32);
memcpy(t, a, 30);
while (j--) {
square(d, t);
memcpy(t, d, 30);