From 83ce81f775f2cc95f3d57b515d52f3e5bf5720d2 Mon Sep 17 00:00:00 2001
From: Luis Michaelis
Date: Sat, 9 Sep 2023 17:15:53 +0200
Subject: [PATCH] refactor(v2): step 2: api changes
---
CMakeLists.txt | 251 ++--
examples/CMakeLists.txt | 6 +-
examples/load_vdf.cc | 22 +-
examples/load_zen.cc | 2 +-
examples/run_interpreter.cc | 6 +-
include/phoenix/Vfs.hh | 17 +
include/phoenix/animation.hh | 11 +
include/phoenix/archive.hh | 11 +
include/phoenix/buffer.hh | 194 ++--
include/phoenix/ext/daedalus_classes.hh | 51 +
include/phoenix/ext/dds_convert.hh | 16 +
include/phoenix/font.hh | 9 +
include/phoenix/material.hh | 13 +
include/phoenix/math.hh | 9 +
include/phoenix/mesh.hh | 15 +
include/phoenix/messages.hh | 10 +
include/phoenix/model.hh | 8 +
include/phoenix/model_hierarchy.hh | 9 +
include/phoenix/model_mesh.hh | 8 +
include/phoenix/model_script.hh | 44 +
include/phoenix/morph_mesh.hh | 10 +
include/phoenix/phoenix.hh | 155 +--
include/phoenix/proto_mesh.hh | 16 +
include/phoenix/save_game.hh | 15 +
include/phoenix/script.hh | 36 +
include/phoenix/softskin_mesh.hh | 12 +
include/phoenix/texture.hh | 26 +
include/phoenix/vdfs.hh | 239 ----
include/phoenix/vm.hh | 31 +
include/phoenix/vobs/camera.hh | 17 +
include/phoenix/vobs/light.hh | 14 +
include/phoenix/vobs/misc.hh | 24 +
include/phoenix/vobs/mob.hh | 16 +
include/phoenix/vobs/sound.hh | 14 +
include/phoenix/vobs/trigger.hh | 24 +
include/phoenix/vobs/vob.hh | 14 +
include/phoenix/vobs/zone.hh | 10 +
include/phoenix/world.hh | 12 +
include/phoenix/world/bsp_tree.hh | 11 +
include/phoenix/world/vob_tree.hh | 13 +
include/phoenix/world/way_net.hh | 10 +
include/zenkit/Archive.hh | 158 ++-
include/zenkit/Boxes.hh | 26 +-
include/zenkit/CutsceneLibrary.hh | 34 +-
include/zenkit/DaedalusScript.hh | 653 ++++++-----
include/zenkit/DaedalusVm.hh | 552 ++++-----
include/zenkit/Date.hh | 28 +
include/zenkit/Error.hh | 37 +
include/zenkit/Font.hh | 39 +-
include/zenkit/Library.hh | 30 +-
include/zenkit/Logger.hh | 50 +
include/zenkit/Material.hh | 136 ++-
include/zenkit/Mesh.hh | 72 +-
include/zenkit/Misc.hh | 36 +
include/zenkit/Model.hh | 31 +-
include/zenkit/ModelAnimation.hh | 157 ++-
include/zenkit/ModelHierarchy.hh | 41 +-
include/zenkit/ModelMesh.hh | 33 +-
include/zenkit/ModelScript.hh | 509 +++++----
include/zenkit/MorphMesh.hh | 45 +-
include/zenkit/MultiResolutionMesh.hh | 110 +-
include/zenkit/SaveGame.hh | 96 +-
include/zenkit/SoftSkinMesh.hh | 45 +-
include/zenkit/Stream.hh | 167 +++
include/zenkit/Texture.hh | 123 +-
include/zenkit/Vfs.hh | 120 +-
include/zenkit/World.hh | 47 +-
include/zenkit/addon/daedalus.hh | 1383 +++++++----------------
include/zenkit/addon/texcvt.hh | 14 +-
include/zenkit/vobs/Camera.hh | 123 +-
include/zenkit/vobs/Light.hh | 72 +-
include/zenkit/vobs/Misc.hh | 182 ++-
include/zenkit/vobs/MovableObject.hh | 81 +-
include/zenkit/vobs/Sound.hh | 55 +-
include/zenkit/vobs/Trigger.hh | 157 ++-
include/zenkit/vobs/VirtualObject.hh | 165 ++-
include/zenkit/vobs/Zone.hh | 130 ++-
include/zenkit/world/BspTree.hh | 63 +-
include/zenkit/world/VobTree.hh | 14 +-
include/zenkit/world/WayNet.hh | 38 +-
source/buffer.cc | 11 +-
source/phoenix.cc | 76 --
source/vdfs.cc | 303 -----
src/Archive.cc | 236 ++--
src/Boxes.cc | 61 +-
src/CutsceneLibrary.cc | 96 +-
src/DaedalusScript.cc | 532 +++++----
src/DaedalusVm.cc | 673 +++++------
src/Date.cc | 27 +
src/Error.cc | 23 +
src/Font.cc | 82 +-
src/Internal.hh | 10 +
src/Logger.cc | 94 ++
src/Material.cc | 161 ++-
src/Mesh.cc | 461 ++++----
src/Misc.cc | 20 +
src/Model.cc | 27 +-
src/ModelAnimation.cc | 171 ++-
src/ModelHierarchy.cc | 119 +-
src/ModelMesh.cc | 135 +--
src/ModelScript.cc | 764 +++++++------
src/ModelScriptDsl.cc | 923 +++++++--------
src/ModelScriptDsl.hh | 105 +-
src/MorphMesh.cc | 112 +-
src/MultiResolutionMesh.cc | 208 ++--
src/SaveGame.cc | 190 ++--
src/SoftSkinMesh.cc | 114 +-
src/Stream.cc | 500 ++++++++
src/Texture.cc | 139 ++-
src/Vfs.cc | 375 +++---
src/World.cc | 350 +++---
src/addon/daedalus.cc | 890 ++++++++++++++-
src/addon/texcvt.cc | 139 ++-
src/archive/ArchiveAscii.cc | 200 ++--
src/archive/ArchiveAscii.hh | 26 +-
src/archive/ArchiveBinary.cc | 127 ++-
src/archive/ArchiveBinary.hh | 27 +-
src/archive/ArchiveBinsafe.cc | 332 +++---
src/archive/ArchiveBinsafe.hh | 53 +-
src/vobs/Camera.cc | 116 +-
src/vobs/Light.cc | 89 +-
src/vobs/Misc.cc | 444 +++++---
src/vobs/MovableObject.cc | 125 +-
src/vobs/Sound.cc | 59 +-
src/vobs/Trigger.cc | 205 ++--
src/vobs/VirtualObject.cc | 275 +++--
src/vobs/Zone.cc | 73 +-
src/world/BspTree.cc | 149 ++-
src/world/VobTree.cc | 404 ++++---
src/world/WayNet.cc | 143 ++-
support/BuildSupport.cmake | 86 ++
tests/TestArchive.cc | 41 +-
tests/TestCutsceneLibrary.cc | 16 +-
tests/TestDaedalusScript.cc | 39 +-
tests/TestFont.cc | 35 +-
tests/TestMaterial.cc | 42 +-
tests/TestModel.cc | 2 +-
tests/TestModelAnimation.cc | 61 +-
tests/TestModelHierarchy.cc | 19 +-
tests/TestModelMesh.cc | 25 +-
tests/TestModelScript.cc | 70 +-
tests/TestMorphMesh.cc | 18 +-
tests/TestMultiResolutionMesh.cc | 24 +-
tests/TestSaveGame.cc | 44 +-
tests/TestStream.cc | 290 +++++
tests/TestTexture.cc | 22 +-
tests/TestVfs.cc | 38 +-
tests/TestVobsG1.cc | 552 ++++-----
tests/TestVobsG2.cc | 746 ++++++------
tests/TestWorld.cc | 64 +-
tests/test_buffer.cc | 571 ----------
151 files changed, 11411 insertions(+), 9651 deletions(-)
create mode 100644 include/phoenix/Vfs.hh
create mode 100644 include/phoenix/animation.hh
create mode 100644 include/phoenix/archive.hh
create mode 100644 include/phoenix/ext/daedalus_classes.hh
create mode 100644 include/phoenix/ext/dds_convert.hh
create mode 100644 include/phoenix/font.hh
create mode 100644 include/phoenix/material.hh
create mode 100644 include/phoenix/math.hh
create mode 100644 include/phoenix/mesh.hh
create mode 100644 include/phoenix/messages.hh
create mode 100644 include/phoenix/model.hh
create mode 100644 include/phoenix/model_hierarchy.hh
create mode 100644 include/phoenix/model_mesh.hh
create mode 100644 include/phoenix/model_script.hh
create mode 100644 include/phoenix/morph_mesh.hh
create mode 100644 include/phoenix/proto_mesh.hh
create mode 100644 include/phoenix/save_game.hh
create mode 100644 include/phoenix/script.hh
create mode 100644 include/phoenix/softskin_mesh.hh
create mode 100644 include/phoenix/texture.hh
delete mode 100644 include/phoenix/vdfs.hh
create mode 100644 include/phoenix/vm.hh
create mode 100644 include/phoenix/vobs/camera.hh
create mode 100644 include/phoenix/vobs/light.hh
create mode 100644 include/phoenix/vobs/misc.hh
create mode 100644 include/phoenix/vobs/mob.hh
create mode 100644 include/phoenix/vobs/sound.hh
create mode 100644 include/phoenix/vobs/trigger.hh
create mode 100644 include/phoenix/vobs/vob.hh
create mode 100644 include/phoenix/vobs/zone.hh
create mode 100644 include/phoenix/world.hh
create mode 100644 include/phoenix/world/bsp_tree.hh
create mode 100644 include/phoenix/world/vob_tree.hh
create mode 100644 include/phoenix/world/way_net.hh
create mode 100644 include/zenkit/Date.hh
create mode 100644 include/zenkit/Error.hh
create mode 100644 include/zenkit/Logger.hh
create mode 100644 include/zenkit/Misc.hh
create mode 100644 include/zenkit/Stream.hh
delete mode 100644 source/phoenix.cc
delete mode 100644 source/vdfs.cc
create mode 100644 src/Date.cc
create mode 100644 src/Error.cc
create mode 100644 src/Internal.hh
create mode 100644 src/Logger.cc
create mode 100644 src/Misc.cc
create mode 100644 src/Stream.cc
create mode 100644 support/BuildSupport.cmake
create mode 100644 tests/TestStream.cc
delete mode 100644 tests/test_buffer.cc
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 22719237..b85bfea5 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,153 +1,123 @@
cmake_minimum_required(VERSION 3.10)
-include(CheckIncludeFiles)
-project(phoenix VERSION 1.1.1)
+project(ZenKit VERSION 2.0.0)
+include(support/BuildSupport.cmake)
set(CMAKE_CXX_STANDARD 17)
-set(PHOENIX_LOG_LEVEL 3 CACHE STRING "The logging level to use for phoenix. Set to 4, 3, 2, or 1 for DEBUG, INFO, WARN or ERROR respectively")
-option(PHOENIX_BUILD_EXAMPLES "Build example code" OFF)
-option(PHOENIX_BUILD_TESTS "Build tests" ON)
-option(PHOENIX_BUILD_SHARED "Build phoenix as a shared library" OFF)
-option(PHOENIX_DISABLE_SANITIZERS "Build without sanitizers in debug mode" OFF)
-option(PHOENIX_INSTALL "Configure phoenix for cmake install" ON)
+option(ZK_BUILD_EXAMPLES "ZenKit: Build the examples." OFF)
+option(ZK_BUILD_TESTS "ZenKit: Build the test suite." ON)
+option(ZK_BUILD_SHARED "ZenKit: Build a shared library." OFF)
-set(PHOENIX_DEBUG_POSTFIX d CACHE STRING "Debug library postfix.")
-
-if (MSVC)
- # enable all warnings
- set(PHOENIX_CXX_FLAGS "/W4")
-
- # in debug mode, enable sanitizers
- if (${CMAKE_BUILD_TYPE} MATCHES "Debug" AND NOT ${PHOENIX_DISABLE_SANITIZERS})
- set(PHOENIX_CXX_FLAGS ${PHOENIX_CXX_FLAGS} "/fsanitize=address")
- endif ()
-else ()
- # enable all warnings
- set(PHOENIX_CXX_FLAGS -Wall -Wextra -Werror -Wconversion -Wshadow -Wpedantic)
-
- # in debug mode, enable sanitizers; note: MinGW does not seem to understand sanitizers on Windows
- if (${CMAKE_BUILD_TYPE} MATCHES "Debug" AND NOT ${PHOENIX_DISABLE_SANITIZERS} AND NOT WIN32)
- set(PHOENIX_CXX_FLAGS ${PHOENIX_CXX_FLAGS} -fsanitize=address -fsanitize=undefined)
-
- # when not compiling for MacOS, enable leak sanitizer
- if (NOT APPLE)
- set(PHOENIX_CXX_FLAGS ${PHOENIX_CXX_FLAGS} -fsanitize=leak)
- endif ()
- endif ()
-
- # in debug mode on Clang to get proper debugging support, add -fstandalone-debug
- if (${CMAKE_BUILD_TYPE} MATCHES "Debug" AND ${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
- set(PHOENIX_CXX_FLAGS ${PHOENIX_CXX_FLAGS} -fstandalone-debug)
- endif ()
-endif ()
+option(ZK_ENABLE_ASAN "ZenKit: Enable sanitizers in debug builds." ON)
+option(ZK_ENABLE_DEPRECATION "ZenKit: Enable deprecation warnings." ON)
+option(ZK_ENABLE_INSTALL "ZenKit: Enable CMake install target creation." ON)
add_subdirectory(vendor)
-# add log level definition
-set(PHOENIX_DEFINES PHOENIX_LOG_LEVEL=${PHOENIX_LOG_LEVEL})
-
# find all header files; required for them to show up properly in VisualStudio
-file(GLOB_RECURSE PHOENIX_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/include/**/*.hh")
-
-set(PHOENIX_SOURCES
- source/animation.cc
- source/archive.cc
- source/archive/archive_ascii.cc
- source/archive/archive_binary.cc
- source/archive/archive_binsafe.cc
+file(GLOB_RECURSE _ZK_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/include/**/*.hh")
+
+list(APPEND _ZK_SOURCES
source/buffer.cc
- source/font.cc
- source/material.cc
- source/math.cc
- source/mesh.cc
- source/messages.cc
- source/model.cc
- source/model_hierarchy.cc
- source/model_mesh.cc
- source/model_script.cc
- source/model_script_dsl.cc
- source/morph_mesh.cc
- source/phoenix.cc
- source/proto_mesh.cc
- source/save_game.cc
- source/script.cc
- source/softskin_mesh.cc
- source/texture.cc
- source/vdfs.cc
- source/Vfs.cc
- source/vobs/camera.cc
- source/vobs/light.cc
- source/vobs/misc.cc
- source/vobs/mob.cc
- source/vobs/sound.cc
- source/vobs/trigger.cc
- source/vobs/vob.cc
- source/vobs/zone.cc
- source/vm.cc
- source/world.cc
- source/world/bsp_tree.cc
- source/world/vob_tree.cc
- source/world/way_net.cc)
-
-set(PHOENIX_EXTENSIONS
- source/ext/dds_convert.cc
- source/ext/daedalus_classes.cc)
-
-set(PHOENIX_TESTS
- tests/test_animation.cc
- tests/test_archive.cc
- tests/test_buffer.cc
- tests/test_font.cc
- tests/test_material.cc
- tests/test_messages.cc
- tests/test_model.cc
- tests/test_model_hierarchy.cc
- tests/test_model_mesh.cc
- tests/test_model_script.cc
- tests/test_morph_mesh.cc
- tests/test_proto_mesh.cc
- tests/test_save_game.cc
- tests/test_script.cc
- tests/test_texture.cc
+
+ src/world/BspTree.cc
+ src/world/VobTree.cc
+ src/world/WayNet.cc
+
+ src/vobs/Camera.cc
+ src/vobs/Light.cc
+ src/vobs/Misc.cc
+ src/vobs/MovableObject.cc
+ src/vobs/Sound.cc
+ src/vobs/Trigger.cc
+ src/vobs/VirtualObject.cc
+ src/vobs/Zone.cc
+
+ src/addon/daedalus.cc
+ src/addon/texcvt.cc
+
+ src/archive/ArchiveAscii.cc
+ src/archive/ArchiveBinary.cc
+ src/archive/ArchiveBinsafe.cc
+
+ src/Archive.cc
+ src/Boxes.cc
+ src/CutsceneLibrary.cc
+ src/DaedalusScript.cc
+ src/Date.cc
+ src/DaedalusVm.cc
+ src/Error.cc
+ src/Font.cc
+ src/Logger.cc
+ src/Material.cc
+ src/Mesh.cc
+ src/Misc.cc
+ src/Model.cc
+ src/ModelAnimation.cc
+ src/ModelHierarchy.cc
+ src/ModelMesh.cc
+ src/ModelScript.cc
+ src/ModelScriptDsl.cc
+ src/MorphMesh.cc
+ src/MultiResolutionMesh.cc
+ src/SaveGame.cc
+ src/SoftSkinMesh.cc
+ src/Stream.cc
+ src/Texture.cc
+ src/Vfs.cc
+ src/World.cc
+)
+
+list(APPEND _ZK_TESTS
+ tests/TestArchive.cc
+ tests/TestCutsceneLibrary.cc
+ tests/TestDaedalusScript.cc
+ tests/TestFont.cc
+ tests/TestMaterial.cc
+ tests/TestModel.cc
+ tests/TestModelAnimation.cc
+ tests/TestModelHierarchy.cc
+ tests/TestModelMesh.cc
+ tests/TestModelScript.cc
+ tests/TestMorphMesh.cc
+ tests/TestMultiResolutionMesh.cc
+ tests/TestSaveGame.cc
+ tests/TestStream.cc
+ tests/TestTexture.cc
tests/TestVfs.cc
- tests/test_vobs_g1.cc
- tests/test_vobs_g2.cc
- tests/test_world.cc)
-
-# add the phoenix library definition
-if (BUILD_SHARED_LIBS AND PHOENIX_BUILD_SHARED)
- add_library(phoenix SHARED)
- set_target_properties(phoenix PROPERTIES CXX_VISIBILITY_PRESET hidden VISIBILITY_INLINES_HIDDEN 1)
+ tests/TestVobsG1.cc
+ tests/TestVobsG2.cc
+ tests/TestWorld.cc
+)
+
+if (BUILD_SHARED_LIBS AND ZK_BUILD_SHARED)
+ add_library(zenkit SHARED)
+ set_target_properties(zenkit PROPERTIES CXX_VISIBILITY_PRESET hidden VISIBILITY_INLINES_HIDDEN 1)
+ target_compile_definitions(zenkit PRIVATE ZKDYN=1)
else ()
- add_library(phoenix STATIC)
- set(PHOENIX_DEFINES ${PHOENIX_DEFINES} PHOENIX_STATIC=1)
- set_target_properties(phoenix PROPERTIES COMPILE_FLAGS "-DPHOENIX_STATIC=1")
+ add_library(zenkit STATIC)
endif ()
-target_sources(phoenix PRIVATE ${PHOENIX_SOURCES} ${PHOENIX_EXTENSIONS} ${PHOENIX_HEADERS})
-target_include_directories(phoenix PUBLIC include)
-
-# Apps using phoenix will also need to link to glm, fmt and squish to avoid missing symbols
-target_link_libraries(phoenix
- PUBLIC glm::glm_static squish
- PRIVATE mio)
-
-target_compile_definitions(phoenix PUBLIC ${PHOENIX_DEFINES} PRIVATE PHOENIX_EXPORTS=1)
-target_compile_options(phoenix PRIVATE ${PHOENIX_CXX_FLAGS})
-
-if (NOT MSVC)
- target_link_options(phoenix PUBLIC ${PHOENIX_CXX_FLAGS})
+if (NOT ZK_ENABLE_DEPRECATION)
+ target_compile_definitions(zenkit PUBLIC ZKNO_REM=1)
endif ()
-set_target_properties(phoenix PROPERTIES
- DEBUG_POSTFIX "${PHOENIX_DEBUG_POSTFIX}"
- VERSION ${PROJECT_VERSION})
+bs_select_cflags(${ZK_ENABLE_ASAN} _ZK_COMPILE_FLAGS _ZK_LINK_FLAGS)
+
+target_sources(zenkit PRIVATE ${_ZK_SOURCES} ${_ZK_HEADERS})
+target_include_directories(zenkit PUBLIC include)
+target_compile_definitions(zenkit PRIVATE _ZKEXPORT=1)
+target_compile_options(zenkit PRIVATE ${_ZK_COMPILE_FLAGS})
+target_link_options(zenkit PUBLIC ${_ZK_LINK_FLAGS})
+target_link_libraries(zenkit PUBLIC glm::glm_static squish mio)
+set_target_properties(zenkit PROPERTIES DEBUG_POSTFIX "d" VERSION ${PROJECT_VERSION})
-if (PHOENIX_INSTALL)
- install(TARGETS phoenix ARCHIVE LIBRARY RUNTIME)
+if (ZK_ENABLE_INSTALL)
+ install(TARGETS zenkit ARCHIVE LIBRARY RUNTIME)
install(DIRECTORY "include/phoenix" TYPE INCLUDE)
+ install(DIRECTORY "include/zenkit" TYPE INCLUDE)
- if (NOT PHOENIX_BUILD_SHARED)
+ if (NOT ZK_BUILD_SHARED)
# For static linking we'll need to provide the dependency static libraries
install(DIRECTORY "${glm_SOURCE_DIR}/glm" TYPE INCLUDE FILES_MATCHING PATTERN "*.hpp" PATTERN "*.inl" PATTERN "*.h")
@@ -158,24 +128,19 @@ if (PHOENIX_INSTALL)
endif ()
# when building tests, create a test executable and load it into CTest
-if (PHOENIX_BUILD_TESTS AND CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
+if (ZK_BUILD_TESTS AND CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
enable_testing()
include(${doctest_SOURCE_DIR}/scripts/cmake/doctest.cmake)
- add_executable(phoenix-tests ${PHOENIX_TESTS})
- target_link_libraries(phoenix-tests PRIVATE phoenix doctest_with_main)
- target_compile_options(phoenix-tests PRIVATE ${PHOENIX_CXX_FLAGS})
-
- if (NOT MSVC)
- target_compile_options(phoenix-tests PRIVATE -Wno-overloaded-shift-op-parentheses -Wno-deprecated-declarations)
- endif ()
-
- target_link_options(phoenix-tests PRIVATE ${PHOENIX_CXX_FLAGS})
+ add_executable(test-zenkit ${_ZK_TESTS})
+ target_link_libraries(test-zenkit PRIVATE zenkit doctest_with_main)
+ target_compile_options(test-zenkit PRIVATE ${_ZK_COMPILE_FLAGS})
+ target_link_options(test-zenkit PUBLIC ${_ZK_LINK_FLAGS})
- doctest_discover_tests(phoenix-tests EXTRA_ARGS -tse=messages,script,world WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/tests)
+ doctest_discover_tests(test-zenkit EXTRA_ARGS -tse=CutsceneLibrary,DaedalusScript,World WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/tests)
endif ()
# when building examples, include the subdirectory
-if (PHOENIX_BUILD_EXAMPLES)
+if (ZK_BUILD_EXAMPLES)
add_subdirectory(examples)
endif ()
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
index 2a4e7f9b..b336eb97 100644
--- a/examples/CMakeLists.txt
+++ b/examples/CMakeLists.txt
@@ -1,11 +1,11 @@
add_executable(load_vdf load_vdf.cc)
-target_link_libraries(load_vdf PRIVATE phoenix)
+target_link_libraries(load_vdf PRIVATE zenkit)
add_executable(load_zen load_zen.cc)
-target_link_libraries(load_zen PRIVATE phoenix)
+target_link_libraries(load_zen PRIVATE zenkit)
add_executable(run_interpreter run_interpreter.cc)
-target_link_libraries(run_interpreter PRIVATE phoenix)
+target_link_libraries(run_interpreter PRIVATE zenkit)
set_target_properties(load_vdf load_zen run_interpreter
PROPERTIES
diff --git a/examples/load_vdf.cc b/examples/load_vdf.cc
index ee567520..fa86d327 100644
--- a/examples/load_vdf.cc
+++ b/examples/load_vdf.cc
@@ -1,15 +1,15 @@
-// Copyright © 2022 Luis Michaelis
+// Copyright © 2022-2023 GothicKit Contributors.
// SPDX-License-Identifier: MIT
-#include
+#include
#include
-void print_entries(const std::set& entries) {
+void print_entries(const std::set& entries) {
for (auto& e : entries) {
- if (e.is_directory()) {
- print_entries(e.children);
+ if (e.type() == zenkit::VfsNodeType::DIRECTORY) {
+ print_entries(e.children());
} else {
- std::cout << " " << e.name << ": " << e.size << " bytes\n";
+ std::cout << e.name() << "\n";
}
}
}
@@ -20,12 +20,8 @@ int main(int argc, char** argv) {
return -1;
}
- auto vdf = phoenix::vdf_file::open(argv[1]);
- auto& header = vdf.header;
-
- std::cout << "Description: " << header.comment << "\n"
- << "Timestamp (Unix): " << header.timestamp << "\nEntries:\n";
-
- print_entries(vdf.entries);
+ zenkit::Vfs vfs {};
+ vfs.mount_disk(argv[1]);
+ print_entries(vfs.root().children());
return 0;
}
diff --git a/examples/load_zen.cc b/examples/load_zen.cc
index 8c909a52..454ca12d 100644
--- a/examples/load_zen.cc
+++ b/examples/load_zen.cc
@@ -1,4 +1,4 @@
-// Copyright © 2022 Luis Michaelis
+// Copyright © 2022-2023 GothicKit Contributors.
// SPDX-License-Identifier: MIT
#include
diff --git a/examples/run_interpreter.cc b/examples/run_interpreter.cc
index 4f8e2073..0d0de550 100644
--- a/examples/run_interpreter.cc
+++ b/examples/run_interpreter.cc
@@ -1,7 +1,9 @@
-// Copyright © 2022 Luis Michaelis
+// Copyright © 2022-2023 GothicKit Contributors.
// SPDX-License-Identifier: MIT
#include
+#include
#include
+#include
#include
@@ -11,6 +13,8 @@ int main(int argc, char** argv) {
return -1;
}
+ zenkit::Logger::set_default(zenkit::LogLevel::DEBUG);
+
phoenix::vm vm {phoenix::script::parse(argv[1])};
phoenix::register_all_script_classes(vm); // needed for Gothic scripts
diff --git a/include/phoenix/Vfs.hh b/include/phoenix/Vfs.hh
new file mode 100644
index 00000000..67c6c02d
--- /dev/null
+++ b/include/phoenix/Vfs.hh
@@ -0,0 +1,17 @@
+// Copyright © 2023 GothicKit Contributors.
+// SPDX-License-Identifier: MIT
+#pragma once
+#include "zenkit/Vfs.hh"
+
+namespace phoenix {
+ using VfsBrokenDiskError ZKREM("renamed to zenkit::VfsBrokenDiskError") = zenkit::VfsBrokenDiskError;
+ using VfsFileExistsError ZKREM("renamed to zenkit::VfsFileExistsError") = zenkit::VfsFileExistsError;
+ using VfsNotFoundError ZKREM("renamed to zenkit::VfsNotFoundError") = zenkit::VfsNotFoundError;
+ using VfsNodeType ZKREM("renamed to zenkit::VfsNodeType") = zenkit::VfsNodeType;
+ using VfsFileDescriptor ZKREM("renamed to zenkit::VfsFileDescriptor") = zenkit::VfsFileDescriptor;
+ using VfsNode ZKREM("renamed to zenkit::VfsNode") = zenkit::VfsNode;
+ using VfsNodeComparator ZKREM("renamed to zenkit::VfsNodeComparator") = zenkit::VfsNodeComparator;
+ using VfsNode ZKREM("renamed to zenkit::VfsNode") = zenkit::VfsNode;
+ using VfsOverwriteBehavior ZKREM("renamed to zenkit::VfsOverwriteBehavior") = zenkit::VfsOverwriteBehavior;
+ using Vfs ZKREM("renamed to zenkit::Vfs") = zenkit::Vfs;
+} // namespace phoenix
diff --git a/include/phoenix/animation.hh b/include/phoenix/animation.hh
new file mode 100644
index 00000000..6cf40507
--- /dev/null
+++ b/include/phoenix/animation.hh
@@ -0,0 +1,11 @@
+// Copyright © 2023 GothicKit Contributors.
+// SPDX-License-Identifier: MIT
+#pragma once
+#include "zenkit/ModelAnimation.hh"
+
+namespace phoenix {
+ using animation ZKREM("renamed to zenkit::Animation") = zenkit::ModelAnimation;
+ using animation_sample ZKREM("renamed to zenkit::AnimationSample") = zenkit::AnimationSample;
+ using animation_event ZKREM("renamed to zenkit::AnimationEvent") = zenkit::AnimationEvent;
+ using animation_event_type ZKREM("renamed to zenkit::AnimationEventType") = zenkit::AnimationEventType;
+} // namespace phoenix
diff --git a/include/phoenix/archive.hh b/include/phoenix/archive.hh
new file mode 100644
index 00000000..f921ed0a
--- /dev/null
+++ b/include/phoenix/archive.hh
@@ -0,0 +1,11 @@
+// Copyright © 2023 GothicKit Contributors.
+// SPDX-License-Identifier: MIT
+#pragma once
+#include "zenkit/Archive.hh"
+
+namespace phoenix {
+ using archive_format ZKREM("renamed to zenkit::ArchiveFormat") = zenkit::ArchiveFormat;
+ using archive_header ZKREM("renamed to zenkit::ArchiveHeader") = zenkit::ArchiveHeader;
+ using archive_object ZKREM("renamed to zenkit::ArchiveObject") = zenkit::ArchiveObject;
+ using archive_reader ZKREM("renamed to zenkit::ArchiveReader") = zenkit::ReadArchive;
+} // namespace phoenix
diff --git a/include/phoenix/buffer.hh b/include/phoenix/buffer.hh
index c0ee69d3..95f80389 100644
--- a/include/phoenix/buffer.hh
+++ b/include/phoenix/buffer.hh
@@ -1,6 +1,7 @@
-// Copyright © 2022 Luis Michaelis
+// Copyright © 2022-2023 GothicKit Contributors.
// SPDX-License-Identifier: MIT
#pragma once
+#include "zenkit/Library.hh"
#include
#include
@@ -21,9 +22,9 @@
namespace phoenix {
/// \brief Base class for exceptions thrown by a phoenix::buffer.
- class buffer_error : public error {
+ class buffer_error : public zenkit::Error {
public:
- using error::error;
+ using zenkit::Error::Error;
};
/// \brief Exception thrown when reading too many bytes from a buffer.
@@ -32,9 +33,9 @@ namespace phoenix {
/// is more than the number of bytes remaining.
class buffer_underflow : public buffer_error {
public:
- PHOENIX_API buffer_underflow(std::uint64_t byte, std::uint64_t size);
- PHOENIX_API buffer_underflow(std::uint64_t byte, std::uint64_t size, std::string&& context);
- PHOENIX_API buffer_underflow(std::uint64_t byte, std::string&& context);
+ ZKAPI buffer_underflow(std::uint64_t byte, std::uint64_t size);
+ ZKAPI buffer_underflow(std::uint64_t byte, std::uint64_t size, std::string&& context);
+ ZKAPI buffer_underflow(std::uint64_t byte, std::string&& context);
public:
const std::uint64_t byte, size;
@@ -47,8 +48,8 @@ namespace phoenix {
/// is more than the number of bytes remaining.
class buffer_overflow : public buffer_error {
public:
- PHOENIX_API buffer_overflow(std::uint64_t byte, std::uint64_t size);
- PHOENIX_API buffer_overflow(std::uint64_t byte, std::uint64_t size, std::string&& context);
+ ZKAPI buffer_overflow(std::uint64_t byte, std::uint64_t size);
+ ZKAPI buffer_overflow(std::uint64_t byte, std::uint64_t size, std::string&& context);
public:
const std::uint64_t byte, size;
@@ -58,7 +59,7 @@ namespace phoenix {
/// \brief Exception thrown if a write is attempted on a readonly buffer.
class buffer_readonly : public buffer_error {
public:
- PHOENIX_API explicit buffer_readonly() : buffer_error("buffer is not readonly") {}
+ ZKAPI explicit buffer_readonly() : buffer_error("buffer is not readonly") {}
};
/// \brief Base class for all buffer backings.
@@ -67,7 +68,7 @@ namespace phoenix {
/// each referencing a subsection of the backing. For this reason, buffer backings should be stateless.
class buffer_backing {
public:
- PHOENIX_API virtual ~buffer_backing() = default;
+ ZKAPI virtual ~buffer_backing() = default;
/// \brief Returns whether this backing considered direct or not.
///
@@ -76,22 +77,22 @@ namespace phoenix {
/// file.
///
/// \return `true` if this backing is direct and `false` if not.
- [[nodiscard]] PHOENIX_API virtual bool direct() const noexcept = 0;
+ [[nodiscard]] ZKAPI virtual bool direct() const noexcept = 0;
/// \brief Returns whether or not this backing is readonly or not.
///
/// A readonly backing is a backing which can not be written to.
///
/// \return `true` if this backing is read-only and `false` if not.
- [[nodiscard]] PHOENIX_API virtual bool readonly() const noexcept = 0;
+ [[nodiscard]] ZKAPI virtual bool readonly() const noexcept = 0;
/// \brief Returns the number of bytes available in this backing.
/// \return The number of bytes available in this backing.
- [[nodiscard]] PHOENIX_API virtual std::uint64_t size() const noexcept = 0;
+ [[nodiscard]] ZKAPI virtual std::uint64_t size() const noexcept = 0;
/// \brief Retrieves a read-only raw byte array of this backing.
/// \return A read-only raw byte array into this backing.
- [[nodiscard]] PHOENIX_API virtual const std::byte* array() const = 0;
+ [[nodiscard]] ZKAPI virtual const std::byte* array() const = 0;
/// \brief Fills the given \p buf with bytes from this backing starting at \p offset.
///
@@ -101,7 +102,7 @@ namespace phoenix {
/// \param size The number of bytes to read.
/// \param offset The offset at which to start reading bytes into \p buf.
/// \throws buffer_underflow if filling \p buf with bytes starting at \p offset fails.
- PHOENIX_API virtual void read(std::byte* buf, std::uint64_t size, std::uint64_t offset) const = 0;
+ ZKAPI virtual void read(std::byte* buf, std::uint64_t size, std::uint64_t offset) const = 0;
/// \brief Writes all bytes from \p buf into this backing beginning at \p offset.
///
@@ -112,9 +113,9 @@ namespace phoenix {
/// \param offset The offset at which to start writing.
/// \throws buffer_overflow if writing all bytes of \p buf starting at \p offset fails.
/// \throws buffer_readonly if this backing is readonly.
- PHOENIX_API virtual void write([[maybe_unused]] const std::byte* buf,
- [[maybe_unused]] std::uint64_t size,
- [[maybe_unused]] std::uint64_t offset) {
+ ZKAPI virtual void write([[maybe_unused]] const std::byte* buf,
+ [[maybe_unused]] std::uint64_t size,
+ [[maybe_unused]] std::uint64_t offset) {
throw buffer_readonly {};
}
};
@@ -122,13 +123,15 @@ namespace phoenix {
/// \brief A buffer implementation inspired by Java's ByteBuffer
class buffer {
private:
- PHOENIX_INTERNAL buffer(std::shared_ptr backing, std::uint64_t begin, std::uint64_t end);
- PHOENIX_INTERNAL buffer(std::shared_ptr backing,
- std::uint64_t begin,
- std::uint64_t end,
- std::uint64_t capacity,
- std::uint64_t position,
- std::optional mark);
+ ZKREM("Deprecated. Use zenkit::Read instead.")
+ ZKINT buffer(std::shared_ptr backing, std::uint64_t begin, std::uint64_t end);
+ ZKREM("Deprecated. Use zenkit::Read instead.")
+ ZKINT buffer(std::shared_ptr backing,
+ std::uint64_t begin,
+ std::uint64_t end,
+ std::uint64_t capacity,
+ std::uint64_t position,
+ std::optional mark);
/// \brief Reads a scalar of type \p T at the current #position.
///
@@ -141,7 +144,7 @@ namespace phoenix {
template <
typename T,
typename = typename std::enable_if::value || std::is_floating_point::value>::type>
- [[nodiscard]] PHOENIX_INTERNAL T _get_t();
+ [[nodiscard]] ZKREM("Deprecated. Use zenkit::Read instead.") ZKINT T _get_t();
/// \brief Reads a scalar of type \p T at the given \p pos.
/// \tparam T The type of scalar to read. Must be a std::integral or a std::floating_point type.
@@ -151,7 +154,7 @@ namespace phoenix {
template <
typename T,
typename = typename std::enable_if::value || std::is_floating_point::value>::type>
- [[nodiscard]] PHOENIX_INTERNAL T _get_t(std::uint64_t pos) const;
+ [[nodiscard]] ZKREM("Deprecated. Use zenkit::Read instead.") ZKINT T _get_t(std::uint64_t pos) const;
/// \brief Writes a scalar of type \p T at the current #position.
///
@@ -163,7 +166,8 @@ namespace phoenix {
template <
typename T,
typename = typename std::enable_if::value || std::is_floating_point::value>::type>
- PHOENIX_INTERNAL void _put_t(T value);
+ ZKREM("Deprecated. Use zenkit::Read instead.")
+ ZKINT void _put_t(T value);
public:
/// \brief Constructs a new buffer from the given backing.
@@ -172,22 +176,23 @@ namespace phoenix {
/// To shrink the buffer, see #slice or #extract.
///
/// \param backing The buffer backing to use.
- PHOENIX_API explicit buffer(std::shared_ptr backing);
+ ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI explicit buffer(std::shared_ptr backing);
/// \brief Gets the current position of this buffer.
/// \return The current position of this buffer.
- [[nodiscard]] PHOENIX_API inline std::uint64_t position() const noexcept {
+ [[nodiscard]] ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI inline std::uint64_t
+ position() const noexcept {
return _m_position;
}
/// \brief Sets this buffer's position.
/// \param pos The new position value.
/// \throws buffer_underflow if \p pos is greater than #limit.
- PHOENIX_API void position(std::uint64_t pos);
+ ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI void position(std::uint64_t pos);
/// \brief Returns the number of bytes available in this buffer.
/// \return The limit of this buffer.
- [[nodiscard]] PHOENIX_API inline std::uint64_t limit() const noexcept {
+ [[nodiscard]] ZKAPI inline std::uint64_t limit() const noexcept {
return _m_backing_end - _m_backing_begin;
}
@@ -197,12 +202,12 @@ namespace phoenix {
///
/// \param limit The new limit to set.
/// \throws buffer_underflow if \p limit is greater than #capacity.
- PHOENIX_API void limit(std::uint64_t limit);
+ ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI void limit(std::uint64_t limit);
/// \brief Rewinds this buffer by setting the position to 0.
///
/// This operation discards the #mark if it is set.
- PHOENIX_API inline void rewind() {
+ ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI inline void rewind() {
_m_position = 0;
_m_mark.reset();
}
@@ -211,7 +216,7 @@ namespace phoenix {
/// \param count The number of bytes to skip.
/// \throws buffer_underflow if #position + \p count > #limit
/// \see #position
- PHOENIX_API inline void skip(std::uint64_t count) {
+ ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI inline void skip(std::uint64_t count) {
return this->position(this->position() + count);
}
@@ -220,7 +225,8 @@ namespace phoenix {
/// The number of remaining bytes is equal to #limit - #position.
///
/// \return The number of bytes remaining in this buffer.
- [[nodiscard]] PHOENIX_API inline std::uint64_t remaining() const noexcept {
+ [[nodiscard]] ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI inline std::uint64_t
+ remaining() const noexcept {
return this->limit() - this->position();
}
@@ -230,21 +236,22 @@ namespace phoenix {
/// the total number of bytes available in the backing.
///
/// \return The capacity of this buffer.
- [[nodiscard]] PHOENIX_API inline std::uint64_t capacity() const noexcept {
+ [[nodiscard]] ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI inline std::uint64_t
+ capacity() const noexcept {
return _m_capacity;
}
/// \brief Returns whether this buffer is considered to be direct or not.
/// \return `true` if the backing of this buffer is considered to be direct.
/// \see buffer_backing::direct
- [[nodiscard]] PHOENIX_API inline bool direct() const noexcept {
+ [[nodiscard]] ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI inline bool direct() const noexcept {
return _m_backing->direct();
}
/// \brief Returns whether this buffer is read-only or not.
/// \return `true` if this buffer is read-only.
/// \see buffer_backing::readonly
- [[nodiscard]] PHOENIX_API inline bool readonly() const noexcept {
+ [[nodiscard]] ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI inline bool readonly() const noexcept {
return _m_backing->readonly();
}
@@ -252,22 +259,22 @@ namespace phoenix {
///
/// #limit is set to #capacity and #position is set to 0. The mark is discarded if
/// it is set.
- PHOENIX_API void clear() noexcept;
+ ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI void clear() noexcept;
/// \brief Flips this buffer.
///
/// Its limit is set to the current position and its current position is set to 0.
- PHOENIX_API void flip() noexcept;
+ ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI void flip() noexcept;
/// \brief Sets this buffer's mark at its position.
/// \return This buffer.
- PHOENIX_API inline void mark() noexcept {
+ ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI inline void mark() noexcept {
_m_mark = position();
}
/// \brief Resets this buffer's position to the previously-marked position.
/// \return This buffer.
- PHOENIX_API inline void reset() {
+ ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI inline void reset() {
if (_m_mark) {
position(*_m_mark);
}
@@ -279,14 +286,14 @@ namespace phoenix {
/// capacity and limit.
///
/// \return The newly created buffer.
- [[nodiscard]] PHOENIX_API buffer duplicate() const noexcept;
+ [[nodiscard]] ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI buffer duplicate() const noexcept;
/// \brief Creates a new buffer which shares a subsequence of this buffer.
///
/// The shared subsequence starts at the current position and ends at this buffer's limit.
///
/// \return The newly created buffer.
- [[nodiscard]] PHOENIX_API buffer slice() const noexcept;
+ [[nodiscard]] ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI buffer slice() const noexcept;
/// \brief Creates a new buffer which shares a subsequence of this buffer.
///
@@ -296,7 +303,8 @@ namespace phoenix {
/// \param size The number of bytes the new buffer will encompass.
/// \return The newly created buffer.
/// \throws buffer_underflow if \p index + \p size > #limit.
- [[nodiscard]] PHOENIX_API buffer slice(std::uint64_t index, std::uint64_t size) const;
+ [[nodiscard]] ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI buffer
+ slice(std::uint64_t index, std::uint64_t size) const;
/// \brief Creates a new buffer which shares a subsequence of this buffer.
///
@@ -306,14 +314,14 @@ namespace phoenix {
/// \param size The number of bytes to extract.
/// \return The newly created buffer.
/// \throws buffer_underflow if #position + \p size > #limit.
- [[nodiscard]] PHOENIX_API buffer extract(std::uint64_t size) {
+ [[nodiscard]] ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI buffer extract(std::uint64_t size) {
auto sl = this->slice(position(), size);
_m_position += size;
return sl;
}
/// \return A read-only view into the raw contents of this buffer.
- [[nodiscard]] PHOENIX_API inline const std::byte* array() const noexcept {
+ [[nodiscard]] ZKAPI inline const std::byte* array() const noexcept {
return _m_backing->array() + _m_backing_begin;
}
@@ -321,85 +329,87 @@ namespace phoenix {
/// \param buf The buffer to write into.
/// \param size The number of bytes to get.
/// \throws buffer_underflow if the size of \p buf > #remaining.
- PHOENIX_API void get(std::byte* buf, std::uint64_t size);
+ ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI void get(std::byte* buf, std::uint64_t size);
/// \brief Get bytes from the buffer, put them into buf and advance the position accordingly.
/// \param buf The buffer to write into.
/// \param size The number of bytes to get.
/// \throws buffer_underflow if the size of \p buf > #remaining.
- PHOENIX_API inline void get(std::uint8_t* buf, std::uint64_t size) {
+ ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI inline void get(std::uint8_t* buf, std::uint64_t size) {
return this->get((std::byte*) buf, size);
}
/// \brief Get a value of type std::uint8_t from the buffer and advance the position accordingly.
/// \return The value just read.
/// \throws buffer_underflow if the value can't be read.
- [[nodiscard]] PHOENIX_API std::uint8_t get();
+ [[nodiscard]] ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI std::uint8_t get();
/// \brief Get a value of type ``char`` from the buffer and advance the position accordingly.
/// \return The value just read.
/// \throws buffer_underflow if the value can't be read.
- [[nodiscard]] PHOENIX_API char get_char();
+ [[nodiscard]] ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI char get_char();
/// \brief Get a value of type std::int16_t from the buffer and advance the position accordingly.
/// \return The value just read.
/// \throws buffer_underflow if the value can't be read.
- [[nodiscard]] PHOENIX_API std::int16_t get_short();
+ [[nodiscard]] ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI std::int16_t get_short();
/// \brief Get a value of type std::uint16_t from the buffer and advance the position accordingly.
/// \return The value just read.
/// \throws buffer_underflow if the value can't be read.
- [[nodiscard]] PHOENIX_API std::uint16_t get_ushort();
+ [[nodiscard]] ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI std::uint16_t get_ushort();
/// \brief Get a value of type std::int32_t from the buffer and advance the position accordingly.
/// \return The value just read.
/// \throws buffer_underflow if the value can't be read.
- [[nodiscard]] PHOENIX_API std::int32_t get_int();
+ [[nodiscard]] ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI std::int32_t get_int();
/// \brief Get a value of type std::uint32_t from the buffer and advance the position accordingly.
/// \return The value just read.
/// \throws buffer_underflow if the value can't be read.
- [[nodiscard]] PHOENIX_API std::uint32_t get_uint();
+ [[nodiscard]] ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI std::uint32_t get_uint();
/// \brief Get a value of type std::int64_t from the buffer and advance the position accordingly.
/// \return The value just read.
/// \throws buffer_underflow if the value can't be read.
- [[nodiscard]] PHOENIX_API std::int64_t get_long();
+ [[nodiscard]] ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI std::int64_t get_long();
/// \brief Get a value of type std::uint64_t from the buffer and advance the position accordingly.
/// \return The value just read.
/// \throws buffer_underflow if the value can't be read.
- [[nodiscard]] PHOENIX_API std::uint64_t get_ulong();
+ [[nodiscard]] ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI std::uint64_t get_ulong();
/// \brief Get a value of type float from the buffer and advance the position accordingly.
/// \return The value just read.
/// \throws buffer_underflow if the value can't be read.
- [[nodiscard]] PHOENIX_API float get_float();
+ [[nodiscard]] ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI float get_float();
/// \brief Get a value of type double from the buffer and advance the position accordingly.
/// \return The value just read.
/// \throws buffer_underflow if the value can't be read.
- [[nodiscard]] PHOENIX_API double get_double();
+ [[nodiscard]] ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI double get_double();
/// \brief Get a string of the given size from the buffer and advance the position accordingly
/// \param size The number of characters to read.
/// \return The string just read.
/// \throws buffer_underflow if the string can't be read.
- [[nodiscard]] PHOENIX_API std::string get_string(std::uint64_t size);
+ [[nodiscard]] ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI std::string get_string(std::uint64_t size);
/// \brief Get a line from the buffer and advance the position accordingly.
/// \param skip_whitespace Set to `true` to skip whitespace characters immediately following the line.
/// \return The line just read.
/// \throws buffer_underflow if the string can't be read.
/// \see isspace
- [[nodiscard]] PHOENIX_API std::string get_line(bool skip_whitespace = true);
+ [[nodiscard]] ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI std::string
+ get_line(bool skip_whitespace = true);
/// \brief Get a line from the buffer and advance the position accordingly.
/// \param skip_whitespace Set to `true` to skip whitespace characters immediately following the line.
/// \return The line just read.
/// \throws buffer_underflow if the string can't be read.
/// \see isspace
- [[nodiscard]] PHOENIX_API std::string get_line_and_ignore(std::string_view whitespace);
+ [[nodiscard]] ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI std::string
+ get_line_and_ignore(std::string_view whitespace);
/// \brief Get a line from the buffer, unescape all relevant escape sequences, and
/// advance the position accordingly.
@@ -407,32 +417,33 @@ namespace phoenix {
/// \return The line just read.
/// \throws buffer_underflow if the string can't be read.
/// \see isspace
- [[nodiscard]] PHOENIX_API std::string get_line_escaped(bool skip_whitespace = true);
+ [[nodiscard]] ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI std::string
+ get_line_escaped(bool skip_whitespace = true);
/// \brief Get a 2D-vector from the buffer.
/// \return The vector just read
/// \throws buffer_underflow if the value can't be read.
- [[nodiscard]] PHOENIX_API glm::vec2 get_vec2();
+ [[nodiscard]] ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI glm::vec2 get_vec2();
/// \brief Get a 3D-vector from the buffer.
/// \return The vector just read
/// \throws buffer_underflow if the value can't be read.
- [[nodiscard]] PHOENIX_API glm::vec3 get_vec3();
+ [[nodiscard]] ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI glm::vec3 get_vec3();
/// \brief Get a 3x3 column-major matrix from the buffer.
/// \return The vector just read
/// \throws buffer_underflow if the value can't be read.
- [[nodiscard]] PHOENIX_API glm::mat3x3 get_mat3x3();
+ [[nodiscard]] ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI glm::mat3x3 get_mat3x3();
/// \brief Get a 4x4 column-major matrix from the buffer.
/// \return The vector just read
/// \throws buffer_underflow if the value can't be read.
- [[nodiscard]] PHOENIX_API glm::mat4x4 get_mat4x4();
+ [[nodiscard]] ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI glm::mat4x4 get_mat4x4();
/// \brief Get a 4D-vector from the buffer.
/// \return The vector just read
/// \throws buffer_underflow if the value can't be read.
- [[nodiscard]] PHOENIX_API glm::vec4 get_vec4();
+ [[nodiscard]] ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI glm::vec4 get_vec4();
/// \brief Put bytes from buf into the buffer and advance the position accordingly.
/// \param buf The data to write.
@@ -440,7 +451,7 @@ namespace phoenix {
/// \return This buffer.
/// \throws buffer_overflow if the value can't be written.
/// \throws buffer_readonly if the buffer is read-only.
- PHOENIX_API void put(const std::byte* buf, std::uint64_t size);
+ ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI void put(const std::byte* buf, std::uint64_t size);
/// \brief Put bytes from buf into the buffer and advance the position accordingly.
/// \param buf The data to write.
@@ -448,91 +459,91 @@ namespace phoenix {
/// \return This buffer.
/// \throws buffer_overflow if the value can't be written.
/// \throws buffer_readonly if the buffer is read-only.
- PHOENIX_API void put(const std::uint8_t* buf, std::uint64_t size);
+ ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI void put(const std::uint8_t* buf, std::uint64_t size);
/// \brief Put a value of type std::uint8_t into the buffer and advance the position accordingly
/// \param value The value to put into the buffer
/// \return This buffer.
/// \throws buffer_overflow if the value can't be written.
/// \throws buffer_readonly if the buffer is read-only.
- PHOENIX_API void put(std::uint8_t value);
+ ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI void put(std::uint8_t value);
/// \brief Put a value of type char into the buffer and advance the position accordingly
/// \param value The value to put into the buffer
/// \return This buffer.
/// \throws buffer_overflow if the value can't be written.
/// \throws buffer_readonly if the buffer is read-only.
- PHOENIX_API void put_char(char value);
+ ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI void put_char(char value);
/// \brief Put a value of type std::int16_t into the buffer and advance the position accordingly
/// \param value The value to put into the buffer
/// \return This buffer.
/// \throws buffer_overflow if the value can't be written.
/// \throws buffer_readonly if the buffer is read-only.
- PHOENIX_API void put_short(std::int16_t value);
+ ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI void put_short(std::int16_t value);
/// \brief Put a value of type std::uint16_t into the buffer and advance the position accordingly
/// \param value The value to put into the buffer
/// \return This buffer.
/// \throws buffer_overflow if the value can't be written.
/// \throws buffer_readonly if the buffer is read-only.
- PHOENIX_API void put_ushort(std::uint16_t value);
+ ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI void put_ushort(std::uint16_t value);
/// \brief Put a value of type std::int32_t into the buffer and advance the position accordingly
/// \param value The value to put into the buffer
/// \return This buffer.
/// \throws buffer_overflow if the value can't be written.
/// \throws buffer_readonly if the buffer is read-only.
- PHOENIX_API void put_int(std::int32_t value);
+ ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI void put_int(std::int32_t value);
/// \brief Put a value of type std::uint32_t into the buffer and advance the position accordingly
/// \param value The value to put into the buffer
/// \return This buffer.
/// \throws buffer_overflow if the value can't be written.
/// \throws buffer_readonly if the buffer is read-only.
- PHOENIX_API void put_uint(std::uint32_t value);
+ ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI void put_uint(std::uint32_t value);
/// \brief Put a value of type std::int64_t into the buffer and advance the position accordingly
/// \param value The value to put into the buffer
/// \return This buffer.
/// \throws buffer_overflow if the value can't be written.
/// \throws buffer_readonly if the buffer is read-only.
- PHOENIX_API void put_long(std::int64_t value);
+ ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI void put_long(std::int64_t value);
/// \brief Put a value of type std::uint64_t into the buffer and advance the position accordingly
/// \param value The value to put into the buffer
/// \return This buffer.
/// \throws buffer_overflow if the value can't be written.
/// \throws buffer_readonly if the buffer is read-only.
- PHOENIX_API void put_ulong(std::uint64_t value);
+ ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI void put_ulong(std::uint64_t value);
/// \brief Put a value of type float into the buffer and advance the position accordingly
/// \param value The value to put into the buffer
/// \return This buffer.
/// \throws buffer_overflow if the value can't be written.
/// \throws buffer_readonly if the buffer is read-only.
- PHOENIX_API void put_float(float value);
+ ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI void put_float(float value);
/// \brief Put a value of type double into the buffer and advance the position accordingly
/// \param value The value to put into the buffer
/// \return This buffer.
/// \throws buffer_overflow if the value can't be written.
/// \throws buffer_readonly if the buffer is read-only.
- PHOENIX_API void put_double(double value);
+ ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI void put_double(double value);
/// \brief Put string into the buffer and advance the position accordingly
/// \param str The string to put into the buffer.
/// \return This buffer.
/// \throws buffer_overflow if the string can't be written.
/// \throws buffer_readonly if the buffer is read-only.
- PHOENIX_API void put_string(std::string_view str);
+ ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI void put_string(std::string_view str);
/// \brief Put string followed by into the buffer and advance the position accordingly
/// \param str The string to put into the buffer.
/// \return This buffer.
/// \throws buffer_overflow if the string can't be written.
/// \throws buffer_readonly if the buffer is read-only.
- PHOENIX_API void put_line(std::string_view str);
+ ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI void put_line(std::string_view str);
/// \brief Allocates a new buffer with the given size.
///
@@ -541,7 +552,7 @@ namespace phoenix {
///
/// \param size The number of bytes to allocate.
/// \return The newly allocated buffer.
- PHOENIX_API static buffer allocate(std::uint64_t size);
+ ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI static buffer allocate(std::uint64_t size);
/// \brief Creates a new buffer from the given vector.
///
@@ -551,7 +562,8 @@ namespace phoenix {
/// \param buf A vector containing the data to be wrapped into a buffer.
/// \param readonly Set to `false` to be able to write to the buffer.
/// \return The newly created buffer.
- PHOENIX_API static buffer of(std::vector&& buf, bool readonly = true);
+ ZKREM("Deprecated. Use zenkit::Read instead.")
+ ZKAPI static buffer of(std::vector&& buf, bool readonly = true);
/// \brief Opens the given file as a direct buffer.
///
@@ -560,7 +572,8 @@ namespace phoenix {
/// \param path The path of the file to mmap.
/// \param readonly Set to `false` to be able to write to the buffer.
/// \return The newly created buffer.
- PHOENIX_API static buffer mmap(const std::filesystem::path& path, bool readonly = true);
+ ZKREM("Deprecated. Use zenkit::Read instead.")
+ ZKAPI static buffer mmap(const std::filesystem::path& path, bool readonly = true);
/// \brief Opens the given file as an indirect buffer.
///
@@ -572,15 +585,16 @@ namespace phoenix {
/// gain for small files but it is generally slower and uses more memory. You should probably use #mmap
/// instead.
/// \return The newly created buffer.
- PHOENIX_API static buffer read(const std::filesystem::path& path, bool readonly = true);
+ ZKREM("Deprecated. Use zenkit::Read instead.")
+ ZKAPI static buffer read(const std::filesystem::path& path, bool readonly = true);
/// \brief Returns a duplicate of the empty buffer.
/// \return The empty buffer.
- PHOENIX_API static buffer empty();
+ ZKREM("Deprecated. Use zenkit::Read instead.") ZKAPI static buffer empty();
private:
static std::unique_ptr _m_empty;
- PHOENIX_API friend bool operator==(const buffer&, const buffer&);
+ ZKAPI friend bool operator==(const buffer&, const buffer&);
std::shared_ptr _m_backing;
std::uint64_t _m_backing_begin, _m_backing_end;
@@ -590,5 +604,5 @@ namespace phoenix {
std::optional _m_mark;
};
- PHOENIX_API bool operator==(const buffer&, const buffer&);
+ ZKREM("Deprecated") ZKAPI bool operator==(const buffer&, const buffer&);
} // namespace phoenix
diff --git a/include/phoenix/ext/daedalus_classes.hh b/include/phoenix/ext/daedalus_classes.hh
new file mode 100644
index 00000000..0562b016
--- /dev/null
+++ b/include/phoenix/ext/daedalus_classes.hh
@@ -0,0 +1,51 @@
+// Copyright © 2023 GothicKit Contributors.
+// SPDX-License-Identifier: MIT
+#pragma once
+#include "zenkit/addon/daedalus.hh"
+
+#include "phoenix/script.hh"
+
+namespace phoenix {
+ using c_gil_values ZKREM("renamed to zenkit::IGuildValues") = zenkit::IGuildValues;
+ using c_npc ZKREM("renamed to zenkit::INpc") = zenkit::INpc;
+ using c_item ZKREM("renamed to zenkit::IItem") = zenkit::IItem;
+ using c_item_react ZKREM("renamed to zenkit::IItemReact") = zenkit::IItemReact;
+ using c_mission ZKREM("renamed to zenkit::IMission") = zenkit::IMission;
+ using c_focus ZKREM("renamed to zenkit::IFocus") = zenkit::IFocus;
+ using c_info ZKREM("renamed to zenkit::IInfo") = zenkit::IInfo;
+ using c_info_choice ZKREM("renamed to zenkit::IInfoChoice") = zenkit::IInfoChoice;
+ using c_spell ZKREM("renamed to zenkit::ISpell") = zenkit::ISpell;
+ using c_svm ZKREM("renamed to zenkit::ISvm") = zenkit::ISvm;
+ using c_menu ZKREM("renamed to zenkit::IMenu") = zenkit::IMenu;
+ using c_menu_item ZKREM("renamed to zenkit::IMenuItem") = zenkit::IMenuItem;
+ using c_camera ZKREM("renamed to zenkit::ICamera") = zenkit::ICamera;
+ using c_music_system ZKREM("renamed to zenkit::IMusicSystem") = zenkit::IMusicSystem;
+ using c_music_theme ZKREM("renamed to zenkit::IMusicTheme") = zenkit::IMusicTheme;
+ using c_music_jingle ZKREM("renamed to zenkit::IMusicJingle") = zenkit::IMusicJingle;
+ using c_particle_fx ZKREM("renamed to zenkit::IParticleEffect") = zenkit::IParticleEffect;
+ using c_particle_fx_emit_key ZKREM("renamed to zenkit::IParticleEffectEmitKey") = zenkit::IParticleEffectEmitKey;
+ using c_fx_base ZKREM("renamed to zenkit::IEffectBase") = zenkit::IEffectBase;
+ using c_fight_ai ZKREM("renamed to zenkit::IFightAi") = zenkit::IFightAi;
+ using c_sfx ZKREM("renamed to zenkit::ISoundEffect") = zenkit::ISoundEffect;
+ using c_sound_system ZKREM("renamed to zenkit::ISoundSystem") = zenkit::ISoundSystem;
+
+ namespace damage_type = zenkit::DamageType;
+ namespace npc_attribute = zenkit::NpcAttribute;
+
+ using npc_type ZKREM("renamed to zenkit::NpcType") = zenkit::NpcType;
+ using npc_flag ZKREM("renamed to zenkit::NpcFlag") = zenkit::NpcFlag;
+ using item_flags ZKREM("renamed to zenkit::ItemFlag") = zenkit::ItemFlag;
+ using c_menu_flags ZKREM("renamed to zenkit::MenuFlag") = zenkit::MenuFlag;
+ using c_menu_item_flags ZKREM("renamed to zenkit::MenuItemFlag") = zenkit::MenuItemFlag;
+ using c_menu_item_type ZKREM("renamed to zenkit::MenuItemType") = zenkit::MenuItemType;
+ using c_menu_item_select_event ZKREM("renamed to zenkit::MenuItemSelectEvent") = zenkit::MenuItemSelectEvent;
+ using c_menu_item_select_action ZKREM("renamed to zenkit::MenuItemSelectAction") = zenkit::MenuItemSelectAction;
+ using music_transition_type ZKREM("renamed to zenkit::MusicTransitionEffect") = zenkit::MusicTransitionEffect;
+ using music_transition_subtype ZKREM("renamed to zenkit::MusicTransitionType") = zenkit::MusicTransitionType;
+ using c_fight_ai_move ZKREM("renamed to zenkit::FightAiMove") = zenkit::FightAiMove;
+
+ ZKREM("renamed to zenkit::register_all_script_classes")
+ inline void register_all_script_classes(zenkit::DaedalusScript& s) {
+ zenkit::register_all_script_classes(s);
+ }
+} // namespace phoenix
diff --git a/include/phoenix/ext/dds_convert.hh b/include/phoenix/ext/dds_convert.hh
new file mode 100644
index 00000000..4ae5b8aa
--- /dev/null
+++ b/include/phoenix/ext/dds_convert.hh
@@ -0,0 +1,16 @@
+// Copyright © 2023 GothicKit Contributors.
+// SPDX-License-Identifier: MIT
+#pragma once
+#include "zenkit/Library.hh"
+#include "zenkit/addon/texcvt.hh"
+
+#include "phoenix/buffer.hh"
+
+namespace phoenix {
+ /// \brief Converts a texture to the DDS format.
+ /// \param tex The texture to convert.
+ /// \return A buffer containing the DDS file.
+ [[nodiscard]] ZKREM("use zenkit::to_dds") inline buffer texture_to_dds(zenkit::Texture const& tex) {
+ return buffer::of(zenkit::to_dds(tex));
+ }
+} // namespace phoenix
diff --git a/include/phoenix/font.hh b/include/phoenix/font.hh
new file mode 100644
index 00000000..c58ddeb6
--- /dev/null
+++ b/include/phoenix/font.hh
@@ -0,0 +1,9 @@
+// Copyright © 2023 GothicKit Contributors.
+// SPDX-License-Identifier: MIT
+#pragma once
+#include "zenkit/Font.hh"
+
+namespace phoenix {
+ using glyph ZKREM("renamed to FontGlyph") = zenkit::FontGlyph;
+ using font ZKREM("renamed to Font") = zenkit::Font;
+} // namespace phoenix
diff --git a/include/phoenix/material.hh b/include/phoenix/material.hh
new file mode 100644
index 00000000..835e874f
--- /dev/null
+++ b/include/phoenix/material.hh
@@ -0,0 +1,13 @@
+// Copyright © 2023 GothicKit Contributors.
+// SPDX-License-Identifier: MIT
+#pragma once
+#include "zenkit/Material.hh"
+
+namespace phoenix {
+ using alpha_function ZKREM("renamed to zenkit::AlphaFunction") = zenkit::AlphaFunction;
+ using material_group ZKREM("renamed to zenkit::MaterialGroup") = zenkit::MaterialGroup;
+ using wave_speed_type ZKREM("renamed to zenkit::WaveSpeed") = zenkit::WaveSpeed;
+ using wave_mode_type ZKREM("renamed to zenkit::WaveMode") = zenkit::WaveMode;
+ using animation_mapping_mode ZKREM("renamed to zenkit::AnimationMapping") = zenkit::AnimationMapping;
+ using material ZKREM("renamed to zenkit::Material") = zenkit::Material;
+} // namespace phoenix
diff --git a/include/phoenix/math.hh b/include/phoenix/math.hh
new file mode 100644
index 00000000..70acaa81
--- /dev/null
+++ b/include/phoenix/math.hh
@@ -0,0 +1,9 @@
+// Copyright © 2023 GothicKit Contributors.
+// SPDX-License-Identifier: MIT
+#pragma once
+#include "zenkit/Boxes.hh"
+
+namespace phoenix {
+ using bounding_box ZKREM("renamed to zenkit::AxisAlignedBoundingBox") = zenkit::AxisAlignedBoundingBox;
+ using obb ZKREM("renamed to zenkit::OrientedBoundingBox") = zenkit::OrientedBoundingBox;
+} // namespace phoenix
diff --git a/include/phoenix/mesh.hh b/include/phoenix/mesh.hh
new file mode 100644
index 00000000..eedce6f1
--- /dev/null
+++ b/include/phoenix/mesh.hh
@@ -0,0 +1,15 @@
+// Copyright © 2023 GothicKit Contributors.
+// SPDX-License-Identifier: MIT
+#pragma once
+#include "zenkit/Mesh.hh"
+
+#include "phoenix/material.hh"
+#include "phoenix/math.hh"
+
+namespace phoenix {
+ using light_map ZKREM("renamed to zenkit::LightMap") = zenkit::LightMap;
+ using vertex_feature ZKREM("renamed to zenkit::VertexFeature") = zenkit::VertexFeature;
+ using polygon_flags ZKREM("renamed to zenkit::PolygonFlags") = zenkit::PolygonFlagSet;
+ using polygon_list ZKREM("renamed to zenkit::PolygonList") = zenkit::PolygonList;
+ using mesh ZKREM("renamed to zenkit::Mesh") = zenkit::Mesh;
+} // namespace phoenix
diff --git a/include/phoenix/messages.hh b/include/phoenix/messages.hh
new file mode 100644
index 00000000..9f283cb2
--- /dev/null
+++ b/include/phoenix/messages.hh
@@ -0,0 +1,10 @@
+// Copyright © 2023 GothicKit Contributors.
+// SPDX-License-Identifier: MIT
+#pragma once
+#include "zenkit/CutsceneLibrary.hh"
+
+namespace phoenix {
+ using atomic_message ZKREM("renamed to zenkit::CutsceneMessage") = zenkit::CutsceneMessage;
+ using message_block ZKREM("renamed to zenkit::CutsceneBlock") = zenkit::CutsceneBlock;
+ using messages ZKREM("renamed to zenkit::CutsceneLibrary") = zenkit::CutsceneLibrary;
+} // namespace phoenix
diff --git a/include/phoenix/model.hh b/include/phoenix/model.hh
new file mode 100644
index 00000000..3af93aed
--- /dev/null
+++ b/include/phoenix/model.hh
@@ -0,0 +1,8 @@
+// Copyright © 2023 GothicKit Contributors.
+// SPDX-License-Identifier: MIT
+#pragma once
+#include "zenkit/Model.hh"
+
+namespace phoenix {
+ using model ZKREM("renamed to zenkit::Model") = zenkit::Model;
+}
diff --git a/include/phoenix/model_hierarchy.hh b/include/phoenix/model_hierarchy.hh
new file mode 100644
index 00000000..419e6f46
--- /dev/null
+++ b/include/phoenix/model_hierarchy.hh
@@ -0,0 +1,9 @@
+// Copyright © 2023 GothicKit Contributors.
+// SPDX-License-Identifier: MIT
+#pragma once
+#include "zenkit/ModelHierarchy.hh"
+
+namespace phoenix {
+ using model_hierarchy_node ZKREM("renamed to zenkit::ModelHierarchyNode") = zenkit::ModelHierarchyNode;
+ using model_hierarchy ZKREM("renamed to zenkit::ModelHierarchy") = zenkit::ModelHierarchy;
+} // namespace phoenix
diff --git a/include/phoenix/model_mesh.hh b/include/phoenix/model_mesh.hh
new file mode 100644
index 00000000..a505d335
--- /dev/null
+++ b/include/phoenix/model_mesh.hh
@@ -0,0 +1,8 @@
+// Copyright © 2023 GothicKit Contributors.
+// SPDX-License-Identifier: MIT
+#pragma once
+#include "zenkit/ModelMesh.hh"
+
+namespace phoenix {
+ using model_mesh ZKREM("renamed to zenkit::ModelMesh") = zenkit::ModelMesh;
+} // namespace phoenix
diff --git a/include/phoenix/model_script.hh b/include/phoenix/model_script.hh
new file mode 100644
index 00000000..882f695f
--- /dev/null
+++ b/include/phoenix/model_script.hh
@@ -0,0 +1,44 @@
+// Copyright © 2023 GothicKit Contributors.
+// SPDX-License-Identifier: MIT
+#pragma once
+#include "phoenix.hh"
+#include "zenkit/ModelScript.hh"
+
+namespace phoenix {
+ namespace mds {
+ ZKREM("use zenkit::AnimationFlags::NONE") static constexpr auto const af_none = zenkit::AnimationFlags::NONE;
+ ZKREM("use zenkit::AnimationFlags::MOVE") static constexpr auto const af_move = zenkit::AnimationFlags::MOVE;
+ ZKREM("use zenkit::AnimationFlags::ROTATE")
+ static constexpr auto const af_rotate = zenkit::AnimationFlags::ROTATE;
+ ZKREM("use zenkit::AnimationFlags::QUEUE") static constexpr auto const af_queue = zenkit::AnimationFlags::QUEUE;
+ ZKREM("use zenkit::AnimationFlags::FLY") static constexpr auto const af_fly = zenkit::AnimationFlags::FLY;
+ ZKREM("use zenkit::AnimationFlags::IDLE") static constexpr auto const af_idle = zenkit::AnimationFlags::IDLE;
+ ZKREM("use zenkit::AnimationFlags::INPLACE")
+ static constexpr auto const af_inplace = zenkit::AnimationFlags::INPLACE;
+
+ using animation_direction ZKREM("renamed to zenkit::AnimationDirection") = zenkit::AnimationDirection;
+ using animation_flags ZKREM("use zenkit::AnimationFlags instead") = zenkit::AnimationFlags;
+ using event_fight_mode ZKREM("renamed to zenkit::MdsFightMode") = zenkit::MdsFightMode;
+ using event_tag_type ZKREM("renamed to zenkit::MdsEventType") = zenkit::MdsEventType;
+ using skeleton ZKREM("renamed to zenkit::MdsSkeleton") = zenkit::MdsSkeleton;
+ using model_tag ZKREM("renamed to zenkit::MdsModelTag") = zenkit::MdsModelTag;
+ using event_tag ZKREM("renamed to zenkit::MdsEventTag") = zenkit::MdsEventTag;
+ using event_pfx ZKREM("renamed to zenkit::MdsParticleEffect") = zenkit::MdsParticleEffect;
+ using event_camera_tremor ZKREM("renamed to zenkit::MdsCameraTremor") = zenkit::MdsCameraTremor;
+ using event_pfx_stop ZKREM("renamed to zenkit::MdsParticleEffectStop") = zenkit::MdsParticleEffectStop;
+ using event_sfx ZKREM("renamed to zenkit::MdsSoundEffect") = zenkit::MdsSoundEffect;
+ using event_sfx_ground ZKREM("renamed to zenkit::MdsSoundEffectGround") = zenkit::MdsSoundEffectGround;
+ using event_morph_animate ZKREM("renamed to zenkit::MdsMorphAnimation") = zenkit::MdsMorphAnimation;
+ using animation ZKREM("renamed to zenkit::MdsAnimation") = zenkit::MdsAnimation;
+ using animation_alias ZKREM("renamed to zenkit::MdsAnimationAlias") = zenkit::MdsAnimationAlias;
+ using animation_blending ZKREM("renamed to zenkit::MdsAnimationBlend") = zenkit::MdsAnimationBlend;
+ using animation_combination ZKREM("renamed to zenkit::MdsAnimationCombine") = zenkit::MdsAnimationCombine;
+ } // namespace mds
+
+ struct script_sytax_error : public zenkit::ParserError {
+ public:
+ ZKINT inline script_sytax_error(std::string&&, std::string&&) : zenkit::ParserError("") {}
+ };
+
+ using model_script ZKREM("renamed to zenkit::ModelScript") = zenkit::ModelScript;
+} // namespace phoenix
diff --git a/include/phoenix/morph_mesh.hh b/include/phoenix/morph_mesh.hh
new file mode 100644
index 00000000..bc537207
--- /dev/null
+++ b/include/phoenix/morph_mesh.hh
@@ -0,0 +1,10 @@
+// Copyright © 2023 GothicKit Contributors.
+// SPDX-License-Identifier: MIT
+#pragma once
+#include "zenkit/MorphMesh.hh"
+
+namespace phoenix {
+ using morph_mesh ZKREM("using zenkit::MorphMesh") = zenkit::MorphMesh;
+ using morph_source ZKREM("using zenkit::MorphSource") = zenkit::MorphSource;
+ using morph_animation ZKREM("using zenkit::MorphAnimation") = zenkit::MorphAnimation;
+} // namespace phoenix
diff --git a/include/phoenix/phoenix.hh b/include/phoenix/phoenix.hh
index 7f3c4acf..8cf42e31 100644
--- a/include/phoenix/phoenix.hh
+++ b/include/phoenix/phoenix.hh
@@ -1,7 +1,10 @@
-// Copyright © 2022 Luis Michaelis
+// Copyright © 2022-2023 GothicKit Contributors.
// SPDX-License-Identifier: MIT
#pragma once
-#include "Api.hh"
+#include "zenkit/Date.hh"
+#include "zenkit/Error.hh"
+#include "zenkit/Logger.hh"
+#include "zenkit/Misc.hh"
#include
#include
@@ -11,151 +14,21 @@
#include
#include
-#if PHOENIX_LOG_LEVEL > 0
- #define PX_LOGE(...) phoenix::logging::log(phoenix::logging::level::error, __VA_ARGS__)
-#else
- #define PX_LOGE(...)
-#endif
-
-#if PHOENIX_LOG_LEVEL > 1
- #define PX_LOGW(...) phoenix::logging::log(phoenix::logging::level::warn, __VA_ARGS__)
-#else
- #define PX_LOGW(...)
-#endif
-
-#if PHOENIX_LOG_LEVEL > 2
- #define PX_LOGI(...) phoenix::logging::log(phoenix::logging::level::info, __VA_ARGS__)
-#else
- #define PX_LOGI(...)
-#endif
-
-#if PHOENIX_LOG_LEVEL > 3
- #define PX_LOGD(...) phoenix::logging::log(phoenix::logging::level::debug, __VA_ARGS__)
-#else
- #define PX_LOGD(...)
-#endif
-
namespace phoenix {
class buffer;
- class archive_reader;
-
- /// \brief An enum for providing a game version hint to some functions
- enum class game_version {
- gothic_1, ///< Represents any patch of Gothic
- gothic_2, ///< Represents any patch of Gothic II, including _Night of the Raven_.
- };
-
- /// \brief Tests whether two strings are equal when ignoring case.
- ///
- /// Internally, uses std::tolower to compare the strings character by character.
- ///
- /// \param a A string.
- /// \param b Another string.
- /// \return ``true`` if both strings are equal when ignoring case.
- PHOENIX_API bool iequals(std::string_view a, std::string_view b);
-
- /// \brief Tests whether \p a is lexicographically less than \p b.
- ///
- /// Internally, uses std::tolower to compare the strings character by character.
- ///
- /// \param a A string.
- /// \param b Another string.
- /// \return ``true`` if \p a is lexicographically less than \p b.
- PHOENIX_API bool icompare(std::string_view a, std::string_view b);
-
- /// \brief A basic datetime structure used by the *ZenGin*.
- struct date {
- /// \brief Parses a date from a buffer.
- /// \param buf The buffer to read from
- /// \return The date.
- PHOENIX_API static date parse(buffer& buf);
-
- std::uint32_t year;
- std::uint16_t month;
- std::uint16_t day;
- std::uint16_t hour;
- std::uint16_t minute;
- std::uint16_t second;
- };
-
- /// \brief Logging manager for phoenix.
- class logging {
- public:
- enum class level { error, warn, info, debug };
-
- /// \brief Supply a custom logger callback to be used for log output from phoenix.
- /// \param callback The callback to use.
- PHOENIX_API static void use_logger(std::function&& callback);
- /// \brief Use the default logger callback for phoenix.
- PHOENIX_API static void use_default_logger();
+ using game_version ZKREM("renamed to zenkit::GameVersion") = zenkit::GameVersion;
+ using error ZKREM("renamed to zenkit::Error") = zenkit::Error;
+ using parser_error ZKREM("renamed to zenkit::ParserError") = zenkit::ParserError;
- /// \brief Send a logging event to the underlying log callback.
- /// \param lvl The level of the log message.
- /// \param message The message to send.
- template
- static void log(level lvl, const T&... msg) {
- if (logging::callback) {
- std::stringstream msg_buffer {};
- logging::_build_log_message(msg_buffer, msg...);
- (*logging::callback)(lvl, msg_buffer.str());
- }
- }
-
- private:
- template
- static void _build_log_message(std::stringstream& stream, const T& v, const Ts&... vals) {
- stream << v;
-
- if constexpr (sizeof...(vals) > 0) {
- _build_log_message(stream, vals...);
- }
- }
-
- static std::optional> callback;
- };
-
- /// \brief Base class for all exceptions.
- class error : public std::exception {
- public:
- PHOENIX_API explicit error(std::string&& message);
-
- [[nodiscard]] PHOENIX_API inline const char* what() const noexcept override {
- return message.c_str();
- }
-
- public:
- const std::string message;
- };
-
- /// \brief An error representing a parsing failure of any kind.
- class parser_error : public error {
- public:
- PHOENIX_INTERNAL explicit parser_error(std::string&& resource_type);
- PHOENIX_API explicit parser_error(std::string&& resource_type, std::string&& context);
- PHOENIX_INTERNAL explicit parser_error(std::string&& resource_type, const std::exception& cause);
- PHOENIX_INTERNAL explicit parser_error(std::string&& resource_type,
- const std::exception& cause,
- std::string&& context);
-
- public:
- const std::string resource_type;
- const std::optional context {std::nullopt};
- const std::optional cause {std::nullopt};
- };
-
- template
- T parse([[maybe_unused]] buffer& buf) {
- throw parser_error {"unknown", "parsing routine not implemented"};
+ inline bool iequals(std::string_view a, std::string_view b) {
+ return zenkit::iequals(a, b);
}
- template
- inline T parse(buffer&& buf) {
- return parse(buf);
+ inline bool icompare(std::string_view a, std::string_view b) {
+ return zenkit::icompare(a, b);
}
- template
- T parse([[maybe_unused]] archive_reader& buf) {
- throw parser_error {"unknown", "parsing routine not implemented"};
- }
+ using date ZKREM("renamed to zenkit::Date") = zenkit::Date;
+ using logging ZKREM("renamed to zenkit::Logger") = zenkit::Logger;
} // namespace phoenix
diff --git a/include/phoenix/proto_mesh.hh b/include/phoenix/proto_mesh.hh
new file mode 100644
index 00000000..9fb9af0d
--- /dev/null
+++ b/include/phoenix/proto_mesh.hh
@@ -0,0 +1,16 @@
+// Copyright © 2023 GothicKit Contributors.
+// SPDX-License-Identifier: MIT
+#pragma once
+#include "zenkit/MultiResolutionMesh.hh"
+
+namespace phoenix {
+ using triangle ZKREM("renamed to zenkit::MeshTriangle") = zenkit::MeshTriangle;
+ using triangle_edge ZKREM("renamed to zenkit::MeshTriangleEdge") = zenkit::MeshTriangleEdge;
+ using edge ZKREM("renamed to zenkit::MeshEdge") = zenkit::MeshEdge;
+ using wedge ZKREM("renamed to zenkit::MeshWedge") = zenkit::MeshWedge;
+ using plane ZKREM("renamed to zenkit::MeshPlane") = zenkit::MeshPlane;
+ using mesh_section ZKREM("renamed to zenkit::MeshSection") = zenkit::MeshSection;
+ using sub_mesh_section ZKREM("renamed to zenkit::SubMeshSection") = zenkit::SubMeshSection;
+ using sub_mesh ZKREM("renamed to zenkit::SubMesh") = zenkit::SubMesh;
+ using proto_mesh ZKREM("renamed to zenkit::MultiResolutionMesh") = zenkit::MultiResolutionMesh;
+} // namespace phoenix
diff --git a/include/phoenix/save_game.hh b/include/phoenix/save_game.hh
new file mode 100644
index 00000000..b26a3005
--- /dev/null
+++ b/include/phoenix/save_game.hh
@@ -0,0 +1,15 @@
+// Copyright © 2023 GothicKit Contributors.
+// SPDX-License-Identifier: MIT
+#pragma once
+#include "zenkit/SaveGame.hh"
+
+namespace phoenix::unstable {
+ using save_info ZKREM("renamed to zenkit::unstable::SaveInfo") = zenkit::unstable::SaveInfo;
+ using topic_section ZKREM("renamed to zenkit::unstable::SaveTopicSection") = zenkit::unstable::SaveTopicSection;
+ using topic_status ZKREM("renamed to zenkit::unstable::SaveTopicStatus") = zenkit::unstable::SaveTopicStatus;
+ using log_topic ZKREM("renamed to zenkit::unstable::SaveLogTopic") = zenkit::unstable::SaveLogTopic;
+ using info_state ZKREM("renamed to zenkit::unstable::SaveInfoState") = zenkit::unstable::SaveInfoState;
+ using symbol_state ZKREM("renamed to zenkit::unstable::SaveSymbolState") = zenkit::unstable::SaveSymbolState;
+ using script_state ZKREM("renamed to zenkit::unstable::SaveScriptState") = zenkit::unstable::SaveScriptState;
+ using save_game ZKREM("renamed to zenkit::unstable::SaveGame") = zenkit::unstable::SaveGame;
+} // namespace phoenix::unstable
diff --git a/include/phoenix/script.hh b/include/phoenix/script.hh
new file mode 100644
index 00000000..a450dc51
--- /dev/null
+++ b/include/phoenix/script.hh
@@ -0,0 +1,36 @@
+// Copyright © 2023 GothicKit Contributors.
+// SPDX-License-Identifier: MIT
+#pragma once
+#include "zenkit/DaedalusScript.hh"
+
+namespace phoenix {
+ namespace symbol_flag = zenkit::DaedalusSymbolFlag;
+
+ using datatype ZKREM("renamed to zenkit::DaedalusDataType") = zenkit::DaedalusDataType;
+ using opcode ZKREM("renamed to zenkit::DaedalusOpcode") = zenkit::DaedalusOpcode;
+ using symbol ZKREM("renamed to zenkit::DaedalusSymbol") = zenkit::DaedalusSymbol;
+ using instance ZKREM("renamed to zenkit::DaedalusInstance") = zenkit::DaedalusInstance;
+ using script_error ZKREM("renamed to zenkit::DaedalusScriptError") = zenkit::DaedalusScriptError;
+ using symbol_not_found ZKREM("renamed to zenkit::DaedalusSymbolNotFound") = zenkit::DaedalusSymbolNotFound;
+ using member_registration_error
+ ZKREM("renamed to zenkit::DaedalusMemberRegistrationError") = zenkit::DaedalusMemberRegistrationError;
+ using invalid_registration_datatype
+ ZKREM("renamed to zenkit::DaedalusInvalidRegistrationDataType") = zenkit::DaedalusInvalidRegistrationDataType;
+ using illegal_access ZKREM("renamed to zenkit::DaedalusIllegalAccess") = zenkit::DaedalusIllegalAccess;
+ using illegal_type_access ZKREM("renamed to zenkit::DaedalusIllegalTypeAccess") = zenkit::DaedalusIllegalTypeAccess;
+ using illegal_index_access
+ ZKREM("renamed to zenkit::DaedalusIllegalIndexAccess") = zenkit::DaedalusIllegalIndexAccess;
+ using illegal_const_access
+ ZKREM("renamed to zenkit::DaedalusIllegalConstAccess") = zenkit::DaedalusIllegalConstAccess;
+ using illegal_instance_access
+ ZKREM("renamed to zenkit::DaedalusIllegalInstanceAccess") = zenkit::DaedalusIllegalInstanceAccess;
+ using unbound_member_access
+ ZKREM("renamed to zenkit::DaedalusUnboundMemberAccess") = zenkit::DaedalusUnboundMemberAccess;
+ using no_context ZKREM("renamed to zenkit::DaedalusNoContextError") = zenkit::DaedalusNoContextError;
+ using illegal_context_type
+ ZKREM("renamed to zenkit::DaedalusIllegalContextType") = zenkit::DaedalusIllegalContextType;
+ using instruction ZKREM("renamed to zenkit::DaedalusInstruction") = zenkit::DaedalusInstruction;
+ using script ZKREM("renamed to zenkit::DaedalusScript") = zenkit::DaedalusScript;
+ using transient_instance ZKREM("renamed to zenkit::DaedalusTransientInstance") = zenkit::DaedalusTransientInstance;
+ using opaque_instance ZKREM("renamed to zenkit::DaedalusOpaqueInstance") = zenkit::DaedalusOpaqueInstance;
+} // namespace phoenix
diff --git a/include/phoenix/softskin_mesh.hh b/include/phoenix/softskin_mesh.hh
new file mode 100644
index 00000000..888efff5
--- /dev/null
+++ b/include/phoenix/softskin_mesh.hh
@@ -0,0 +1,12 @@
+// Copyright © 2023 GothicKit Contributors.
+// SPDX-License-Identifier: MIT
+#pragma once
+#include "zenkit/SoftSkinMesh.hh"
+
+#include "phoenix/math.hh"
+
+namespace phoenix {
+ using softskin_mesh ZKREM("renamed to zenkit::SoftSkinMesh") = zenkit::SoftSkinMesh;
+ using wedge_normal ZKREM("renamed to zenkit::SoftSkinWedgeNormal") = zenkit::SoftSkinWedgeNormal;
+ using weight_entry ZKREM("renamed to zenkit::SoftSkinWeightEntry") = zenkit::SoftSkinWeightEntry;
+} // namespace phoenix
diff --git a/include/phoenix/texture.hh b/include/phoenix/texture.hh
new file mode 100644
index 00000000..846cbcd7
--- /dev/null
+++ b/include/phoenix/texture.hh
@@ -0,0 +1,26 @@
+// Copyright © 2023 GothicKit Contributors.
+// SPDX-License-Identifier: MIT
+#pragma once
+#include "zenkit/Texture.hh"
+
+namespace phoenix {
+ constexpr zenkit::TextureFormat const tex_B8G8R8A8 ZKREM("use zenkit::TextureFormat") = zenkit::tex_B8G8R8A8;
+ constexpr zenkit::TextureFormat const tex_R8G8B8A8 ZKREM("use zenkit::TextureFormat") = zenkit::tex_R8G8B8A8;
+ constexpr zenkit::TextureFormat const tex_A8B8G8R8 ZKREM("use zenkit::TextureFormat") = zenkit::tex_A8B8G8R8;
+ constexpr zenkit::TextureFormat const tex_A8R8G8B8 ZKREM("use zenkit::TextureFormat") = zenkit::tex_A8R8G8B8;
+ constexpr zenkit::TextureFormat const tex_B8G8R8 ZKREM("use zenkit::TextureFormat") = zenkit::tex_B8G8R8;
+ constexpr zenkit::TextureFormat const tex_R8G8B8 ZKREM("use zenkit::TextureFormat") = zenkit::tex_R8G8B8;
+ constexpr zenkit::TextureFormat const tex_A4R4G4B4 ZKREM("use zenkit::TextureFormat") = zenkit::tex_A4R4G4B4;
+ constexpr zenkit::TextureFormat const tex_A1R5G5B5 ZKREM("use zenkit::TextureFormat") = zenkit::tex_A1R5G5B5;
+ constexpr zenkit::TextureFormat const tex_R5G6B5 ZKREM("use zenkit::TextureFormat") = zenkit::tex_R5G6B5;
+ constexpr zenkit::TextureFormat const tex_p8 ZKREM("use zenkit::TextureFormat") = zenkit::tex_p8;
+ constexpr zenkit::TextureFormat const tex_dxt1 ZKREM("use zenkit::TextureFormat") = zenkit::tex_dxt1;
+ constexpr zenkit::TextureFormat const tex_dxt2 ZKREM("use zenkit::TextureFormat") = zenkit::tex_dxt2;
+ constexpr zenkit::TextureFormat const tex_dxt3 ZKREM("use zenkit::TextureFormat") = zenkit::tex_dxt3;
+ constexpr zenkit::TextureFormat const tex_dxt4 ZKREM("use zenkit::TextureFormat") = zenkit::tex_dxt4;
+ constexpr zenkit::TextureFormat const tex_dxt5 ZKREM("use zenkit::TextureFormat") = zenkit::tex_dxt5;
+
+ using texture ZKREM("renamed to zenkit::Texture") = zenkit::Texture;
+ using texture_format ZKREM("renamed to zenkit::TextureFormat") = zenkit::TextureFormat;
+ using argb ZKREM("renamed to zenkit::ColorARGB") = zenkit::ColorARGB;
+} // namespace phoenix
diff --git a/include/phoenix/vdfs.hh b/include/phoenix/vdfs.hh
deleted file mode 100644
index 8b83dca6..00000000
--- a/include/phoenix/vdfs.hh
+++ /dev/null
@@ -1,239 +0,0 @@
-// Copyright © 2022 Luis Michaelis
-// SPDX-License-Identifier: MIT
-#pragma once
-#include "Api.hh"
-#include
-
-#include
-#include
-#include
-#include
-#include
-
-namespace phoenix {
- static constexpr std::string_view VDF_SIGNATURE_G1 = "PSVDSC_V2.00\r\n\r\n";
- static constexpr std::string_view VDF_SIGNATURE_G2 = "PSVDSC_V2.00\n\r\n\r";
- static constexpr std::uint32_t VDF_MASK_DIRECTORY = 0x80'00'00'00;
- static constexpr std::uint32_t VDF_MASK_LAST = 0x40'00'00'00;
- static constexpr std::uint32_t VDF_VERSION = 0x50;
- static constexpr std::uint32_t VDF_COMMENT_LENGTH = 256;
- static constexpr std::uint32_t VDF_SIGNATURE_LENGTH = 16;
- static constexpr std::uint32_t VDF_ENTRY_NAME_LENGTH = 64;
-
- /// \brief Converts a ``DOS`` timestamp into a unix timestamp.
- ///
- /// This date format does not seem to be documented anywhere, so this implementation
- /// is based on the implementation in PhysicsFS
- /// ([here](https://github.com/icculus/physfs/blob/0d4e9aac4575744ddaae56b146f1be19f064f0e5/src/physfs_archiver_vdf.c#l37)).
- ///
- /// \param dos The timestamp to convert.
- /// \return The converted unix timestamp.
- /// \note Assumes the ``DOS`` timestamp is in the ``GMT`` timezone.
- PHOENIX_API std::time_t dos_to_unix_time(std::uint32_t dos) noexcept;
-
- /// \brief Converts a unix timestamp (std::time_t) to a ``DOS`` timestamp.
- /// \param tm The unix timestamp to convert
- /// \return The unix timestamp as a ``DOS`` timestamp.
- /// \note This will convert to a ``DOS`` timestamp in the ``GMT`` timezone.
- PHOENIX_API std::uint32_t unix_time_to_dos(std::time_t tm) noexcept;
-
- /// \brief An exception thrown if the signature of a VDF file is not recognized.
- ///
- /// If the signature is not recognized, this means that the VDF file was created using a 3rd-party tool
- /// like Union and is not necessarily compatible with the VDFS spec. Accepted signatures are
- /// phoenix::VDF_SIGNATURE_G1 and phoenix::VDF_SIGNATURE_G2.
- class vdfs_signature_error : public error {
- public:
- PHOENIX_INTERNAL explicit vdfs_signature_error(const std::string& signature);
- };
-
- /// \brief Represents the header of a VDF.
- class vdf_header {
- public:
- /// \brief Constructs a new header with the given comment and timestamp.
- /// \param comment The comment to set. Note that comments are trimmed to 256 characters.
- /// \param timestamp The timestamp to set.#
- PHOENIX_API explicit vdf_header(std::string_view comment, std::time_t timestamp = -1);
-
- PHOENIX_API vdf_header() = default;
-
- /// \brief Reads a vdf_header from the given buffer.
- /// \param in The reader to read from.
- /// \return The header read.
- PHOENIX_INTERNAL static vdf_header read(buffer& in);
-
- static constexpr const auto packed_size = VDF_COMMENT_LENGTH + VDF_SIGNATURE_LENGTH + 6 * sizeof(std::uint32_t);
-
- public:
- /// \brief The comment of the VDF.
- std::string comment;
-
- /// \brief The signature of the VDF.
- std::string signature {VDF_SIGNATURE_G2};
-
- /// \brief The number of file entries in the VDF.
- std::uint32_t entry_count {0};
-
- /// \brief The total number of entries in the VDF.
- std::uint32_t file_count {0};
-
- /// \brief The timestamp of the VDF.
- std::time_t timestamp {0};
-
- /// \brief The total size of the VDF in bytes.
- std::uint32_t size {0};
-
- /// \brief The offset of the entry catalog in bytes.
- std::uint32_t catalog_offset {0};
-
- /// \brief The version of the VDF.
- std::uint32_t version {VDF_VERSION};
- };
-
- class vdf_entry;
-
- struct vdf_entry_comparator {
- public:
- using is_transparent = std::true_type;
-
- PHOENIX_INTERNAL bool operator()(const vdf_entry& a, const vdf_entry& b) const;
- PHOENIX_INTERNAL bool operator()(const vdf_entry& a, std::string_view b) const;
- PHOENIX_INTERNAL bool operator()(std::string_view a, const vdf_entry& b) const;
- };
-
- /// \brief Represents an entry of a VDF.
- class vdf_entry {
- public:
- /// \brief Creates a new directory entry with the given name and attributes.
- /// \param name The name of the entry to create.
- /// \param attributes Attributes to set on the entry.
- PHOENIX_API explicit vdf_entry(std::string_view name, std::uint32_t attributes = 0);
-
- PHOENIX_API vdf_entry() = default;
-
- /// \brief Reads a vdf_entry and all it's children from the given buffer.
- /// \param in The buffer to read from.
- /// \param catalog_offset The offset of the entry catalog.
- /// \return The entry read.
- PHOENIX_INTERNAL static vdf_entry read(buffer& in, std::uint32_t catalog_offset);
-
- /// \brief Searches the entry for the first child with the given name.
- /// \param name The name of the child to search for.
- /// \return The child with the given name or `nullptr` if no entry was found.
- [[nodiscard]] PHOENIX_API const vdf_entry* find_child(std::string_view name) const;
-
- /// \brief Resolves the given path into the entry.
- /// \param path The path to resolve.
- /// \return The child at the given path or `nullptr` if no entry was found.
- [[nodiscard]] PHOENIX_API const vdf_entry* resolve_path(std::string_view path) const;
-
- /// \brief Searches the entry for the first child with the given name.
- /// \param name The name of the child to search for.
- /// \return The child with the give name or `nullptr` if no entry was found.
- PHOENIX_DEPRECATED("mutating vdf_entry children is broken!")
- PHOENIX_API vdf_entry* find_child(std::string_view name);
-
- /// \brief Merges the given VDF entry into this one.
- /// \param itm The entry to merge.
- /// \param override_existing Whether to replace existing files with the new ones.
- PHOENIX_API void merge(const vdf_entry& itm, bool override_existing = true);
-
- /// \return A new reader for the contents of the entry.
- [[nodiscard]] PHOENIX_API inline buffer open() const noexcept {
- return _m_data.duplicate();
- }
-
- /// \return `true` if the entry is a file entry, `false` if not.
- [[nodiscard]] PHOENIX_API inline bool is_file() const noexcept {
- return !is_directory();
- }
-
- /// \return `true` if the entry is a directory entry, `false` if not.
- [[nodiscard]] PHOENIX_API inline bool is_directory() const noexcept {
- return (type & VDF_MASK_DIRECTORY) != 0;
- }
-
- /// \return `true` if the entry is the last entry in a directory, `false` if not.
- [[nodiscard]] PHOENIX_API inline bool is_last() const noexcept {
- return (type & VDF_MASK_LAST) != 0;
- }
-
- static constexpr const auto packed_size = VDF_ENTRY_NAME_LENGTH + 4 * sizeof(std::uint32_t);
-
- public:
- /// \brief The name of the entry.
- std::string name;
-
- /// \brief A list of child entries of the entry.
- std::set children {};
-
- /// \brief The offset of the entry's data in the VDF.
- std::uint32_t offset {0};
-
- /// \brief The size of the entry in bytes.
- std::uint32_t size {0};
-
- /// \brief The type of the entry.
- std::uint32_t type {0};
-
- /// \brief The attributes of the file.
- std::uint32_t attributes {0};
-
- private:
- buffer _m_data = buffer::empty();
- };
-
- /// \brief Represents a VDF file (`.VDF` files).
- class vdf_file {
- public:
- /// \brief Opens the file at the given \p path as a VDF file.
- /// \param comment The comment on the file. Note that comments are trimmed to 256 characters.
- /// \param timestamp The timestamp of the archive.
- PHOENIX_DEPRECATED("scheduled for removal; use Vfs instead")
- PHOENIX_API explicit vdf_file(std::string_view comment, std::time_t timestamp = -1);
-
- /// \brief Reads the header and catalog from a file and creates a vdf_file from it.
- /// \param path The path of the file to read from.
- /// \return The vdf_file.
- PHOENIX_DEPRECATED("scheduled for removal; use Vfs instead")
- PHOENIX_API static vdf_file open(const std::filesystem::path& path);
-
- /// \brief Reads the header and catalog from a buffer and creates a vdf_file from it.
- /// \param path The buffer to read from.
- /// \return The vdf_file.
- PHOENIX_DEPRECATED("scheduled for removal; use Vfs instead")
- PHOENIX_API static vdf_file open(phoenix::buffer& buf);
-
- /// \brief Searches the VDF file for the first entry with the given name.
- /// \param name The name of the entry to search for.
- /// \return The entry with the give name or `nullptr` if no entry was found.
- [[nodiscard]] PHOENIX_API const vdf_entry* find_entry(std::string_view name) const;
-
- /// \brief Resolves the given path into the VDF.
- /// \param path The path to resolve.
- /// \return The child at the given path or `nullptr` if no entry was found.
- [[nodiscard]] PHOENIX_API const vdf_entry* resolve_path(std::string_view path) const;
-
- /// \brief Searches the VDF file for the first entry with the given name.
- /// \param name The name of the entry to search for.
- /// \return The entry with the give name or `nullptr` if no entry was found.
- PHOENIX_DEPRECATED("mutating vdf_entry children is broken!")
- PHOENIX_API vdf_entry* find_entry(std::string_view name);
-
- /// \brief Merges the given VDF file into this one.
- /// \param itm The file to merge.
- /// \param override_existing Whether to replace existing files with the new ones.
- PHOENIX_API void merge(const vdf_file& file, bool override_existing = true);
-
- public:
- /// \brief A list of root entries in the VDF file.
- std::set entries;
-
- /// \brief The header data of the VDF file.
- vdf_header header;
-
- protected:
- vdf_file() = default;
- };
-
-} // namespace phoenix
diff --git a/include/phoenix/vm.hh b/include/phoenix/vm.hh
new file mode 100644
index 00000000..3c987827
--- /dev/null
+++ b/include/phoenix/vm.hh
@@ -0,0 +1,31 @@
+// Copyright © 2023 GothicKit Contributors.
+// SPDX-License-Identifier: MIT
+#pragma once
+#include "zenkit/DaedalusVm.hh"
+
+#include "phoenix/script.hh"
+
+namespace phoenix {
+ namespace execution_flag = zenkit::DaedalusVmExecutionFlag;
+
+ using illegal_external_definition
+ ZKREM("renamed to zenkit::DaedalusIllegalExternalDefinition") = zenkit::DaedalusIllegalExternalDefinition;
+ using illegal_external_rtype
+ ZKREM("renamed to zenkit::DaedalusIllegalExternalReturnType") = zenkit::DaedalusIllegalExternalReturnType;
+ using illegal_external_param
+ ZKREM("renamed to zenkit::DaedalusIllegalExternalParameter") = zenkit::DaedalusIllegalExternalParameter;
+ using vm_exception ZKREM("renamed to zenkit::DaedalusVmException") = zenkit::DaedalusVmException;
+ using vm_exception_strategy
+ ZKREM("renamed to zenkit::DaedalusVmExceptionStrategy") = zenkit::DaedalusVmExceptionStrategy;
+ using daedalus_stack_frame ZKREM("renamed to zenkit::DaedalusStackFrame") = zenkit::DaedalusStackFrame;
+ using daedalus_call_stack_frame ZKREM("renamed to zenkit::DaedalusCallStackFrame") = zenkit::DaedalusCallStackFrame;
+ using vm ZKREM("renamed to zenkit::DaedalusVm") = zenkit::DaedalusVm;
+ using func ZKREM("renamed to zenkit::DaedalusFunction") = zenkit::DaedalusFunction;
+ using naked_call ZKREM("renamed to zenkit::DaedalusNakedCall") = zenkit::DaedalusNakedCall;
+
+ inline zenkit::DaedalusVmExceptionStrategy lenient_vm_exception_handler(zenkit::DaedalusVm& v,
+ zenkit::DaedalusScriptError const& exc,
+ zenkit::DaedalusInstruction const& instr) {
+ return zenkit::lenient_vm_exception_handler(v, exc, instr);
+ }
+} // namespace phoenix
diff --git a/include/phoenix/vobs/camera.hh b/include/phoenix/vobs/camera.hh
new file mode 100644
index 00000000..5f3eff72
--- /dev/null
+++ b/include/phoenix/vobs/camera.hh
@@ -0,0 +1,17 @@
+// Copyright © 2023 GothicKit Contributors.
+// SPDX-License-Identifier: MIT
+#pragma once
+#include "zenkit/vobs/Camera.hh"
+
+namespace phoenix {
+ namespace vobs {
+ using camera_trj_frame
+ ZKREM("renamed to zenkit::vobs::CameraTrajectoryFrame") = zenkit::vobs::CameraTrajectoryFrame;
+ using cs_camera ZKREM("renamed to zenkit::vobs::CutsceneCamera") = zenkit::vobs::CutsceneCamera;
+ } // namespace vobs
+
+ using camera_motion ZKREM("renamed to zenkit::CameraMotion") = zenkit::CameraMotion;
+ using camera_trajectory ZKREM("renamed to zenkit::CameraTrajectory") = zenkit::CameraTrajectory;
+ using camera_lerp_mode ZKREM("renamed to zenkit::CameraLerpType") = zenkit::CameraLerpType;
+ using camera_loop ZKREM("renamed to zenkit::CameraLoop") = zenkit::CameraLoop;
+} // namespace phoenix
diff --git a/include/phoenix/vobs/light.hh b/include/phoenix/vobs/light.hh
new file mode 100644
index 00000000..4b70716a
--- /dev/null
+++ b/include/phoenix/vobs/light.hh
@@ -0,0 +1,14 @@
+// Copyright © 2023 GothicKit Contributors.
+// SPDX-License-Identifier: MIT
+#pragma once
+#include "zenkit/vobs/Light.hh"
+
+namespace phoenix {
+ namespace vobs {
+ using light_preset ZKREM("renamed to zenkit::vobs::LightPreset") = zenkit::vobs::LightPreset;
+ using light ZKREM("renamed to zenkit::vobs::Light") = zenkit::vobs::Light;
+ } // namespace vobs
+
+ using light_mode ZKREM("renamed to zenkit::LightType") = zenkit::LightType;
+ using light_quality ZKREM("renamed to zenkit::LightQuality") = zenkit::LightQuality;
+} // namespace phoenix
diff --git a/include/phoenix/vobs/misc.hh b/include/phoenix/vobs/misc.hh
new file mode 100644
index 00000000..8a8eb531
--- /dev/null
+++ b/include/phoenix/vobs/misc.hh
@@ -0,0 +1,24 @@
+// Copyright © 2023 GothicKit Contributors.
+// SPDX-License-Identifier: MIT
+#pragma once
+#include "zenkit/vobs/Misc.hh"
+
+namespace phoenix {
+ namespace vobs {
+ using animate ZKREM("renamed to zenkit::vobs::Animate") = zenkit::vobs::Animate;
+ using item ZKREM("renamed to zenkit::vobs::Item") = zenkit::vobs::Item;
+ using lens_flare ZKREM("renamed to zenkit::vobs::LensFlare") = zenkit::vobs::LensFlare;
+ using pfx_controller
+ ZKREM("renamed to zenkit::vobs::ParticleEffectController") = zenkit::vobs::ParticleEffectController;
+ using code_master ZKREM("renamed to zenkit::vobs::CodeMaster") = zenkit::vobs::CodeMaster;
+ using message_filter ZKREM("renamed to zenkit::vobs::MessageFilter") = zenkit::vobs::MessageFilter;
+ using mover_controller ZKREM("renamed to zenkit::vobs::MoverController") = zenkit::vobs::MoverController;
+ using touch_damage ZKREM("renamed to zenkit::vobs::TouchDamage") = zenkit::vobs::TouchDamage;
+ using earthquake ZKREM("renamed to zenkit::vobs::Earthquake") = zenkit::vobs::Earthquake;
+ using npc ZKREM("renamed to zenkit::vobs::Npc") = zenkit::vobs::Npc;
+ } // namespace vobs
+
+ using message_filter_action ZKREM("renamed to zenkit::MessageFilterAction") = zenkit::MessageFilterAction;
+ using mover_message_type ZKREM("renamed to zenkit::MoverMessageType") = zenkit::MoverMessageType;
+ using collision_type ZKREM("renamed to zenkit::TouchCollisionType") = zenkit::TouchCollisionType;
+} // namespace phoenix
diff --git a/include/phoenix/vobs/mob.hh b/include/phoenix/vobs/mob.hh
new file mode 100644
index 00000000..4e9e1dd5
--- /dev/null
+++ b/include/phoenix/vobs/mob.hh
@@ -0,0 +1,16 @@
+// Copyright © 2023 GothicKit Contributors.
+// SPDX-License-Identifier: MIT
+#pragma once
+#include "zenkit/vobs/MovableObject.hh"
+
+namespace phoenix {
+ namespace vobs {
+ using mob ZKREM("renamed to zenkit::vobs::MovableObject") = zenkit::vobs::MovableObject;
+ using mob_inter ZKREM("renamed to zenkit::vobs::InteractiveObject") = zenkit::vobs::InteractiveObject;
+ using mob_fire ZKREM("renamed to zenkit::vobs::Fire") = zenkit::vobs::Fire;
+ using mob_container ZKREM("renamed to zenkit::vobs::Container") = zenkit::vobs::Container;
+ using mob_door ZKREM("renamed to zenkit::vobs::Door") = zenkit::vobs::Door;
+ } // namespace vobs
+
+ using sound_material ZKREM("renamed to zenkit::SoundMaterialType") = zenkit::SoundMaterialType;
+} // namespace phoenix
diff --git a/include/phoenix/vobs/sound.hh b/include/phoenix/vobs/sound.hh
new file mode 100644
index 00000000..77d8f735
--- /dev/null
+++ b/include/phoenix/vobs/sound.hh
@@ -0,0 +1,14 @@
+// Copyright © 2023 GothicKit Contributors.
+// SPDX-License-Identifier: MIT
+#pragma once
+#include "zenkit/vobs/Sound.hh"
+
+namespace phoenix {
+ namespace vobs {
+ using sound ZKREM("renamed to zenkit::vobs::Sound") = zenkit::vobs::Sound;
+ using sound_daytime ZKREM("renamed to zenkit::vobs::SoundDaytime") = zenkit::vobs::SoundDaytime;
+ } // namespace vobs
+
+ using sound_mode ZKREM("renamed to zenkit::SoundMode") = zenkit::SoundMode;
+ using sound_trigger_volume ZKREM("renamed to SoundTriggerVolumeType") = zenkit::SoundTriggerVolumeType;
+} // namespace phoenix
diff --git a/include/phoenix/vobs/trigger.hh b/include/phoenix/vobs/trigger.hh
new file mode 100644
index 00000000..4f495397
--- /dev/null
+++ b/include/phoenix/vobs/trigger.hh
@@ -0,0 +1,24 @@
+// Copyright © 2023 GothicKit Contributors.
+// SPDX-License-Identifier: MIT
+#pragma once
+#include "zenkit/vobs/Trigger.hh"
+
+#include "phoenix/animation.hh"
+
+namespace phoenix {
+ namespace vobs {
+ using trigger ZKREM("renamed to zenkit::vobs::Trigger") = zenkit::vobs::Trigger;
+ using trigger_mover ZKREM("renamed to zenkit::vobs::Mover") = zenkit::vobs::Mover;
+ using trigger_list ZKREM("renamed to zenkit::vobs::TriggerList") = zenkit::vobs::TriggerList;
+ using trigger_script ZKREM("renamed to zenkit::vobs::TriggerScript") = zenkit::vobs::TriggerScript;
+ using trigger_change_level
+ ZKREM("renamed to zenkit::vobs::TriggerChangeLevel") = zenkit::vobs::TriggerChangeLevel;
+ using trigger_world_start ZKREM("renamed to zenkit::vobs::TriggerWorldStart") = zenkit::vobs::TriggerWorldStart;
+ using trigger_untouch ZKREM("renamed to zenkit::vobs::TriggerUntouch") = zenkit::vobs::TriggerUntouch;
+ } // namespace vobs
+
+ using mover_behavior ZKREM("renamed to zenkit::MoverBehavior") = zenkit::MoverBehavior;
+ using mover_lerp_mode ZKREM("renamed to zenkit::MoverLerpType") = zenkit::MoverLerpType;
+ using mover_speed_mode ZKREM("renamed to zenkit::MoverSpeedType") = zenkit::MoverSpeedType;
+ using trigger_batch_mode ZKREM("renamed to zenkit::TriggerBatchMode") = zenkit::TriggerBatchMode;
+} // namespace phoenix
diff --git a/include/phoenix/vobs/vob.hh b/include/phoenix/vobs/vob.hh
new file mode 100644
index 00000000..47b6051c
--- /dev/null
+++ b/include/phoenix/vobs/vob.hh
@@ -0,0 +1,14 @@
+// Copyright © 2023 GothicKit Contributors.
+// SPDX-License-Identifier: MIT
+#pragma once
+#include "zenkit/vobs/VirtualObject.hh"
+
+namespace phoenix {
+ using vob_type ZKREM("renamed to zenkit::VobType") = zenkit::VobType;
+ using shadow_mode ZKREM("renamed to zenkit::ShadowType") = zenkit::ShadowType;
+ using visual_type ZKREM("renamed to zenkit::VisualType") = zenkit::VisualType;
+ using sprite_alignment ZKREM("renamed to zenkit::SpriteAlignment") = zenkit::SpriteAlignment;
+ using animation_mode ZKREM("renamed to zenkit::AnimationType") = zenkit::AnimationType;
+ using decal ZKREM("renamed to zenkit::Decal") = zenkit::Decal;
+ using vob ZKREM("renamed to zenkit::VirtualObject") = zenkit::VirtualObject;
+} // namespace phoenix
diff --git a/include/phoenix/vobs/zone.hh b/include/phoenix/vobs/zone.hh
new file mode 100644
index 00000000..ead08c5f
--- /dev/null
+++ b/include/phoenix/vobs/zone.hh
@@ -0,0 +1,10 @@
+// Copyright © 2023 GothicKit Contributors.
+// SPDX-License-Identifier: MIT
+#pragma once
+#include "zenkit/vobs/Zone.hh"
+
+namespace phoenix::vobs {
+ using zone_music ZKREM("renamed to zenkit::vobs::ZoneMusic") = zenkit::vobs::ZoneMusic;
+ using zone_far_plane ZKREM("renamed to zenkit::vobs::ZoneFarPlane") = zenkit::vobs::ZoneFarPlane;
+ using zone_fog ZKREM("renamed to zenkit::vobs::ZoneFog") = zenkit::vobs::ZoneFog;
+} // namespace phoenix::vobs
diff --git a/include/phoenix/world.hh b/include/phoenix/world.hh
new file mode 100644
index 00000000..020a8121
--- /dev/null
+++ b/include/phoenix/world.hh
@@ -0,0 +1,12 @@
+// Copyright © 2023 GothicKit Contributors.
+// SPDX-License-Identifier: MIT
+#pragma once
+#include "zenkit/World.hh"
+
+#include "phoenix/world/bsp_tree.hh"
+#include "phoenix/world/vob_tree.hh"
+#include "phoenix/world/way_net.hh"
+
+namespace phoenix {
+ using world ZKREM("renamed to zenkit::World") = zenkit::World;
+}
diff --git a/include/phoenix/world/bsp_tree.hh b/include/phoenix/world/bsp_tree.hh
new file mode 100644
index 00000000..adb32672
--- /dev/null
+++ b/include/phoenix/world/bsp_tree.hh
@@ -0,0 +1,11 @@
+// Copyright © 2023 GothicKit Contributors.
+// SPDX-License-Identifier: MIT
+#pragma once
+#include "zenkit/world/BspTree.hh"
+
+namespace phoenix {
+ using bsp_tree ZKREM("renamed to zenkit::BspTree") = zenkit::BspTree;
+ using bsp_sector ZKREM("renamed to zenkit::BspSector") = zenkit::BspSector;
+ using bsp_node ZKREM("renamed to zenkit::BspNode") = zenkit::BspNode;
+ using bsp_tree_mode ZKREM("renamed to zenkit::BspTreeType") = zenkit::BspTreeType;
+} // namespace phoenix
diff --git a/include/phoenix/world/vob_tree.hh b/include/phoenix/world/vob_tree.hh
new file mode 100644
index 00000000..543475a3
--- /dev/null
+++ b/include/phoenix/world/vob_tree.hh
@@ -0,0 +1,13 @@
+// Copyright © 2023 GothicKit Contributors.
+// SPDX-License-Identifier: MIT
+#pragma once
+#include "zenkit/world/VobTree.hh"
+
+#include "phoenix/vobs/vob.hh"
+
+namespace phoenix {
+ ZKAPI inline std::unique_ptr parse_vob_tree(zenkit::ReadArchive& in,
+ zenkit::GameVersion version) {
+ return zenkit::parse_vob_tree(in, version);
+ }
+} // namespace phoenix
diff --git a/include/phoenix/world/way_net.hh b/include/phoenix/world/way_net.hh
new file mode 100644
index 00000000..5ef5bb81
--- /dev/null
+++ b/include/phoenix/world/way_net.hh
@@ -0,0 +1,10 @@
+// Copyright © 2023 GothicKit Contributors.
+// SPDX-License-Identifier: MIT
+#pragma once
+#include "zenkit/world/WayNet.hh"
+
+namespace phoenix {
+ using way_net ZKREM("renamed to zenkit::WayNet") = zenkit::WayNet;
+ using way_edge ZKREM("renamed to zenkit::WayEdge") = zenkit::WayEdge;
+ using way_point ZKREM("renamed to zenkit::WayPoint") = zenkit::WayPoint;
+} // namespace phoenix
diff --git a/include/zenkit/Archive.hh b/include/zenkit/Archive.hh
index 144e5a9c..a35a0846 100644
--- a/include/zenkit/Archive.hh
+++ b/include/zenkit/Archive.hh
@@ -1,10 +1,11 @@
-// Copyright © 2022 Luis Michaelis
+// Copyright © 2021-2023 GothicKit Contributors.
// SPDX-License-Identifier: MIT
#pragma once
-#include "phoenix/Api.hh"
-#include
-#include
-#include
+#include "zenkit/Boxes.hh"
+#include "zenkit/Library.hh"
+#include "zenkit/Stream.hh"
+
+#include "phoenix/buffer.hh"
#include
#include
@@ -17,17 +18,31 @@
#include
namespace phoenix {
- enum class archive_format { binary, binsafe, ascii };
+ class buffer;
+}
+
+namespace zenkit {
+ class Read;
+
+ enum class ArchiveFormat {
+ BINARY = 0,
+ BINSAFE = 1,
+ ASCII = 2,
+
+ binary ZKREM("renamed to ArchiveFormat::BINARY") = BINARY,
+ binsafe ZKREM("renamed to ArchiveFormat::BINSAFE") = BINSAFE,
+ ascii ZKREM("renamed to ArchiveFormat::ASCII") = ASCII,
+ };
/// \brief Represents the header of a ZenGin archive.
- struct archive_header {
+ struct ArchiveHeader {
int32_t version;
/// \brief The type of archiver used to create the archive. Either `zCArchiverGeneric` or `zCArchiverBinSafe`.
std::string archiver;
/// \brief The format of the archive.
- archive_format format;
+ ArchiveFormat format;
/// \brief Whether the archive contains a save-game or not.
bool save {false};
@@ -38,15 +53,11 @@ namespace phoenix {
/// \brief The date this archive was created at.
std::string date;
- /// \brief Reads in an archive_header from the given reader.
- /// \param in The reader to read from.
- /// \return The header read.
- /// \throws parser_error if parsing fails.
- [[nodiscard]] PHOENIX_INTERNAL static archive_header parse(buffer& in);
+ void load(Read* r);
};
/// \brief Represents the header of an object stored in a ZenGin archive.
- struct archive_object {
+ struct ArchiveObject {
/// \brief The name of the sub-object used for storing this object in the ZenGin.
std::string object_name;
@@ -61,49 +72,50 @@ namespace phoenix {
std::uint32_t index;
};
- enum class archive_entry_type : uint8_t {
- string = 0x1,
- int_ = 0x2,
- float_ = 0x3,
- byte = 0x4,
- word = 0x5,
- bool_ = 0x6,
- vec3 = 0x7,
- color = 0x8,
- raw = 0x9,
- raw_float = 0x10,
- enum_ = 0x11,
- hash = 0x12,
- };
-
- struct archive_entry {
- archive_entry_type type;
- std::string name;
- std::variant value;
+ enum class ArchiveEntryType : uint8_t {
+ STRING = 0x1,
+ INTEGER = 0x2,
+ FLOAT = 0x3,
+ BYTE = 0x4,
+ WORD = 0x5,
+ BOOL = 0x6,
+ VEC3 = 0x7,
+ COLOR = 0x8,
+ RAW = 0x9,
+ RAW_FLOAT = 0x10,
+ ENUM = 0x11,
+ HASH = 0x12,
+
+ string ZKREM("renamed to ArchiveEntryType::STRING") = STRING,
+ int_ ZKREM("renamed to ArchiveEntryType::INTEGER") = INTEGER,
+ float_ ZKREM("renamed to ArchiveEntryType::FLOAT") = FLOAT,
+ byte ZKREM("renamed to ArchiveEntryType::BYTE") = BYTE,
+ word ZKREM("renamed to ArchiveEntryType::WORD") = WORD,
+ bool_ ZKREM("renamed to ArchiveEntryType::BOOL") = BOOL,
+ vec3 ZKREM("renamed to ArchiveEntryType::VEC3") = VEC3,
+ color ZKREM("renamed to ArchiveEntryType::COLOR") = COLOR,
+ raw ZKREM("renamed to ArchiveEntryType::RAW") = RAW,
+ raw_float ZKREM("renamed to ArchiveEntryType::RAW_FLOAT") = RAW_FLOAT,
+ enum_ ZKREM("renamed to ArchiveEntryType::ENUM") = ENUM,
+ hash ZKREM("renamed to ArchiveEntryType::HASH") = HASH,
};
- struct archive_object_end {};
-
- using archive_visitor =
- std::function&, const std::optional&)>;
-
/// \brief A reader for ZenGin archives.
- class PHOENIX_API archive_reader {
+ class ZKAPI ReadArchive {
public:
- /// \brief Constructs a new archive_reader from the given reader and header.
- /// \note This constructor should never be called explicitly. Use #open instead!
- /// \param in The reader to read from
- /// \param header The header of the archive.
- inline archive_reader(buffer& in, archive_header&& parent_header)
- : header(std::move(parent_header)), input(in) {}
+ virtual ~ReadArchive() = default;
- virtual ~archive_reader() = default;
+ /// \brief Creates a new archive_reader from the given buffer.
+ /// \param[in] in The buffer to use.
+ /// \return The new archive_reader.
+ /// \throws zenkit::ParserError
+ ZKREM("use ::from(Read*)") static std::unique_ptr open(phoenix::buffer& in);
/// \brief Creates a new archive_reader from the given buffer.
- /// \param[in,out] in The buffer to use.
+ /// \param[in] r The buffer to use.
/// \return The new archive_reader.
- /// \throws phoenix::parser_error
- static std::unique_ptr open(buffer& in);
+ /// \throws zenkit::ParserError
+ static std::unique_ptr from(Read* r);
/// \brief Tries to read the begin of a new object from the archive.
///
@@ -112,7 +124,7 @@ namespace phoenix {
///
/// \param[out] obj The object to store the data in.
/// \return `true` if the begin of an object was read successfully, `false` if not.
- virtual bool read_object_begin(archive_object& obj) = 0;
+ virtual bool read_object_begin(ArchiveObject& obj) = 0;
/// \brief Tries to read the end of an object from the archive.
///
@@ -175,51 +187,27 @@ namespace phoenix {
/// \brief Reads a bounding box consisting of two consecutive vec3's from the reader.
/// \return The value read.
/// \throws parser_error if the value actually present is not a bounding box
- virtual bounding_box read_bbox() = 0;
+ virtual AxisAlignedBoundingBox read_bbox() = 0;
/// \brief Reads a 3-by-3 matrix from the reader.
/// \return The matrix.
virtual glm::mat3x3 read_mat3x3() = 0;
- /// \brief Reads a raw entry and returns the raw bytes stored within.
- /// \return A vector containing the raw bytes of the entry.
- /// \throws parser_error if the value actually present is not raw
- PHOENIX_DEPRECATED("unsafe api: use read_raw_bytes(uint32_t) instead") virtual buffer read_raw_bytes() = 0;
-
/// \brief Reads a raw entry and returns the raw bytes stored within.
/// \param size The number of bytes to read (checked at runtime for ASCII and BIN_SAFE archives)
/// \return A vector containing the raw bytes of the entry.
/// \throws parser_error if the value actually present is not raw
- virtual buffer read_raw_bytes(uint32_t size) = 0;
+ ZKREM("use ::read_raw()") virtual phoenix::buffer read_raw_bytes(uint32_t size) = 0;
+
+ virtual std::unique_ptr read_raw(uint32_t size) = 0;
/// \brief Skips the next object in the reader and all it's children
/// \param skip_current If `false` skips the next object in this buffer, otherwise skip the object
/// currently being read.
virtual void skip_object(bool skip_current);
- /// \brief Dumps the current or next object of this reader as XML to standard out.
- /// \param open_object If `false`, dumps out the next object in the reader, otherwise dumps all
- /// values until the current object closes.
- virtual void print_structure(bool open_object);
-
- /// \brief Get the next element in the archive.
- ///
- /// Parses the next element, either an object begin, object end or entry from the archive and returns
- /// its associated value.
- ///
- /// \return The value of the next element in the archive.
- /// \warning This API is unstable and may change at any time!
- virtual std::variant unstable__next() = 0;
-
- /// \brief Walks the current or next object of the archive recursively, calling `cb` for each element.
- /// \param open_object If `false`, walks out the next object in the reader, otherwise walks all
- /// values until the current object closes.
- /// \param cb A callback function to handle each element.
- /// \warning This API is unstable and may change at any time!
- void unstable__visit_objects(bool open_object, const archive_visitor& cb);
-
/// \return The header of the archive
- [[nodiscard]] const archive_header& get_header() const noexcept {
+ [[nodiscard]] const ArchiveHeader& get_header() const noexcept {
return header;
}
@@ -229,6 +217,9 @@ namespace phoenix {
}
protected:
+ ReadArchive(ArchiveHeader head, Read* read);
+ ReadArchive(ArchiveHeader head, Read* read, std::unique_ptr owned);
+
/// \brief Read the header of the specific archive format.
virtual void read_header() = 0;
@@ -236,7 +227,10 @@ namespace phoenix {
virtual void skip_entry() = 0;
protected:
- archive_header header;
- buffer& input;
+ ArchiveHeader header;
+ Read* read;
+
+ private:
+ std::unique_ptr _m_owned;
};
-} // namespace phoenix
+} // namespace zenkit
diff --git a/include/zenkit/Boxes.hh b/include/zenkit/Boxes.hh
index 4ffc9a24..dd4ec420 100644
--- a/include/zenkit/Boxes.hh
+++ b/include/zenkit/Boxes.hh
@@ -1,15 +1,21 @@
-// Copyright © 2022 Luis Michaelis
+// Copyright © 2021-2023 GothicKit Contributors.
// SPDX-License-Identifier: MIT
#pragma once
+#include "zenkit/Library.hh"
+
#include
#include
namespace phoenix {
class buffer;
+}
+
+namespace zenkit {
+ class Read;
/// \brief Represents a axis-aligned bounding box (AABB)
- struct bounding_box {
+ struct AxisAlignedBoundingBox {
/// \brief The coordinates of the minimum corner of the bounding box.
glm::vec3 min;
@@ -19,7 +25,9 @@ namespace phoenix {
/// \brief Parses a bounding box from the given buffer.
/// \param[in,out] in The buffer to parse from.
/// \return The bounding box parsed.
- PHOENIX_API static bounding_box parse(buffer& in);
+ [[nodiscard]] ZKREM("use ::load()") ZKAPI static AxisAlignedBoundingBox parse(phoenix::buffer& in);
+
+ ZKAPI void load(Read* r);
};
/// \brief Represents an oriented bounding box.
@@ -27,21 +35,23 @@ namespace phoenix {
/// In contrast to regular bounding boxes, [oriented bounding
/// boxes](https://en.wikipedia.org/wiki/Minimum_bounding_box#Arbitrarily_oriented_minimum_bounding_box) may be
/// rotated in the coordinate system and don't have to align with its axes.
- struct obb {
+ struct OrientedBoundingBox {
glm::vec3 center;
glm::vec3 axes[3];
glm::vec3 half_width;
- std::vector children;
+ std::vector children;
+
+ ZKAPI void load(Read* r);
/// \brief Calculates an axis-aligned bounding box from this oriented bounding box.
/// \todo Write a test for this.
/// \return An AABB which contains this OBB.
- [[nodiscard]] PHOENIX_API bounding_box as_bbox() const;
+ [[nodiscard]] ZKAPI AxisAlignedBoundingBox as_bbox() const;
/// \brief Parses an oriented bounding box from a buffer.
/// \param[in,out] in The buffer to parse from.
/// \return The parsed bounding box.
- [[nodiscard]] PHOENIX_API static obb parse(buffer& in);
+ [[nodiscard]] ZKREM("use ::load()") ZKAPI static OrientedBoundingBox parse(phoenix::buffer& in);
};
-} // namespace phoenix
+} // namespace zenkit
diff --git a/include/zenkit/CutsceneLibrary.hh b/include/zenkit/CutsceneLibrary.hh
index 37d3837e..8c593c77 100644
--- a/include/zenkit/CutsceneLibrary.hh
+++ b/include/zenkit/CutsceneLibrary.hh
@@ -1,16 +1,22 @@
-// Copyright © 2022 Luis Michaelis
+// Copyright © 2021-2023 GothicKit Contributors.
// SPDX-License-Identifier: MIT
#pragma once
-#include "Api.hh"
-#include
+#include "zenkit/Library.hh"
+#include
#include
#include
#include
namespace phoenix {
+ class buffer;
+}
+
+namespace zenkit {
+ class Read;
+
/// \brief A single cutscene message.
- struct atomic_message {
+ struct CutsceneMessage {
uint32_t type = 0;
/// \brief The text associated with the message.
@@ -21,7 +27,7 @@ namespace phoenix {
};
/// \brief A block containing a cutscene message and a unique name.
- struct message_block {
+ struct CutsceneBlock {
/// \brief The unique name of the message.
std::string name;
@@ -29,7 +35,7 @@ namespace phoenix {
/// \details It seems like it was possible to specify multiple atomic_message object for each message_block.
/// This seems to have been abandoned, however, so this implementation only supports one atomic_message
/// per message block.
- atomic_message message;
+ CutsceneMessage message;
};
/// \brief Represents a cutscene library.
@@ -40,7 +46,7 @@ namespace phoenix {
/// of Gothic and Gothic II installations. Cutscene libraries are *ZenGin* archives in either binary or ASCII
/// format. They have either the `.DAT` or `.BIN` extension for binary files or the `.CSL` or `.LSC` extension for
/// text files
- class messages {
+ class CutsceneLibrary {
public:
/// \brief Parses a message database from the data in the given buffer.
///
@@ -54,24 +60,24 @@ namespace phoenix {
/// using buffer::duplicate.
/// \throws parser_error if parsing fails.
/// \see #parse(buffer&&)
- [[nodiscard]] PHOENIX_API static messages parse(buffer& path);
+ [[nodiscard]] ZKREM("use ::load()") ZKAPI static CutsceneLibrary parse(phoenix::buffer& path);
/// \brief Parses a message database from the data in the given buffer.
/// \param[in] buf The buffer to read from (by rvalue-reference).
/// \return The parsed message database object.
/// \throws parser_error if parsing fails.
/// \see #parse(buffer&)
- [[nodiscard]] PHOENIX_API inline static messages parse(buffer&& path) {
- return messages::parse(path);
- }
+ [[nodiscard]] ZKREM("use ::load()") ZKAPI static CutsceneLibrary parse(phoenix::buffer&& path);
/// \brief Retrieves a message block by it's name.
/// \param name The name of the block to get
/// \return A pointer to the block or `nullptr` if the block was not found.
- [[nodiscard]] PHOENIX_API const message_block* block_by_name(std::string_view name) const;
+ [[nodiscard]] ZKAPI const CutsceneBlock* block_by_name(std::string_view name) const;
+
+ ZKAPI void load(Read* r);
public:
/// \brief A list of all message blocks in the database.
- std::vector blocks {};
+ std::vector blocks {};
};
-} // namespace phoenix
+} // namespace zenkit
diff --git a/include/zenkit/DaedalusScript.hh b/include/zenkit/DaedalusScript.hh
index bee2bbc3..69cf54d7 100644
--- a/include/zenkit/DaedalusScript.hh
+++ b/include/zenkit/DaedalusScript.hh
@@ -1,30 +1,48 @@
-// Copyright © 2022 Luis Michaelis
+// Copyright © 2021-2023 GothicKit Contributors.
// SPDX-License-Identifier: MIT
#pragma once
-#include "Api.hh"
-#include
+#include "zenkit/Error.hh"
+#include "zenkit/Library.hh"
+#include "zenkit/Stream.hh"
+#include "phoenix/buffer.hh"
+
+#include
#include
#include
-#include
#include
+#include
#include
#include
#include
-#define unset 0xFF'FF'FF'FFU
-
namespace phoenix {
+ class buffer;
+}
+
+namespace zenkit {
+ class Read;
+
/// \brief Daedalus data types.
- enum class datatype : std::uint32_t {
- void_ = 0U, ///< A datatype similar to C++'s `void`.
- float_ = 1U, ///< A 32-bit floating point type similar to C++'s `float`.
- integer = 2U, ///< A 32-bit signed integer type like std::int32_t
- string = 3U, ///< A [Windows-1252](https://en.wikipedia.org/wiki/Windows-1252) encoded character array.
- class_ = 4U, ///< A structure definition.
- function = 5U, ///< A function definition or a function pointer represented as a 32-bit signed integer.
- prototype = 6U, ///< A prototype definition.
- instance = 7U, ///< An instance definition or instance reference represented as a 32-bit unsigned integer.
+ enum class DaedalusDataType : std::uint32_t {
+ VOID = 0U, ///< A datatype similar to C++'s `void`.
+ FLOAT = 1U, ///< A 32-bit floating point type similar to C++'s `float`.
+ INT = 2U, ///< A 32-bit signed integer type like std::int32_t
+ STRING = 3U, ///< A [Windows-1252](https://en.wikipedia.org/wiki/Windows-1252) encoded character array.
+ CLASS = 4U, ///< A structure definition.
+ FUNCTION = 5U, ///< A function definition or a function pointer represented as a 32-bit signed integer.
+ PROTOTYPE = 6U, ///< A prototype definition.
+ INSTANCE = 7U, ///< An instance definition or instance reference represented as a 32-bit unsigned integer.
+
+ // Deprecated entries.
+ void_ ZKREM("renamed to DaedalusDataType::VOID") = VOID,
+ float_ ZKREM("renamed to DaedalusDataType::FLOAT") = FLOAT,
+ integer ZKREM("renamed to DaedalusDataType::INT") = INT,
+ string ZKREM("renamed to DaedalusDataType::STRING") = STRING,
+ class_ ZKREM("renamed to DaedalusDataType::CLASS") = CLASS,
+ function ZKREM("renamed to DaedalusDataType::FUNCTION") = FUNCTION,
+ prototype ZKREM("renamed to DaedalusDataType::PROTOTYPE") = PROTOTYPE,
+ instance ZKREM("renamed to DaedalusDataType::INSTANCE") = INSTANCE,
};
constexpr const char* const DAEDALUS_DATA_TYPE_NAMES[] = {
@@ -39,14 +57,22 @@ namespace phoenix {
};
/// \brief Flags of symbols.
- namespace symbol_flag {
- static constexpr auto const_ = 1U << 0U; ///< The symbol is not mutable.
- static constexpr auto return_ = 1U << 1U; ///< The symbol is a function and has a return value.
- static constexpr auto member = 1U << 2U; ///< The symbol is a class member.
- static constexpr auto external = 1U << 3U; ///< The symbol refers to an external function.
- static constexpr auto merged = 1U << 4U; ///< Unused.
- static constexpr auto access_trap = 1U << 6U; ///< VM should call trap callback, when symbol accessed.
- } // namespace symbol_flag
+ namespace DaedalusSymbolFlag {
+ static constexpr auto CONST = 1U << 0U; ///< The symbol is not mutable.
+ static constexpr auto RETURN = 1U << 1U; ///< The symbol is a function and has a return value.
+ static constexpr auto MEMBER = 1U << 2U; ///< The symbol is a class member.
+ static constexpr auto EXTERNAL = 1U << 3U; ///< The symbol refers to an external function.
+ static constexpr auto MERGED = 1U << 4U; ///< Unused.
+ static constexpr auto TRAP_ACCESS = 1U << 6U; ///< VM should call trap callback, when symbol accessed.
+
+ // Deprecated entries.
+ ZKREM("renamed to DaedalusSymbolFlag::CONST") static constexpr auto const_ = CONST;
+ ZKREM("renamed to DaedalusSymbolFlag::RETURN") static constexpr auto return_ = RETURN;
+ ZKREM("renamed to DaedalusSymbolFlag::MEMBER") static constexpr auto member = MEMBER;
+ ZKREM("renamed to DaedalusSymbolFlag::EXTERNAL") static constexpr auto external = EXTERNAL;
+ ZKREM("renamed to DaedalusSymbolFlag::MERGED") static constexpr auto merged = MERGED;
+ ZKREM("renamed to DaedalusSymbolFlag::TRAP_ACCESS") static constexpr auto access_trap = TRAP_ACCESS;
+ } // namespace DaedalusSymbolFlag
/// \brief All opcodes supported by the daedalus interpreter.
///
@@ -59,158 +85,201 @@ namespace phoenix {
/// `x` refers to the first value on the stack and is required to be variable reference.
/// `y` refers to the second value on the stack and is required to be variable reference.
///
- enum class opcode : std::uint8_t {
+ enum class DaedalusOpcode : std::uint8_t {
/// \brief Add `a` and `b` and put the result back onto the stack.
- add = 0,
+ ADD = 0,
/// \brief Subtract `b` from `a` and put the result back onto the stack.
- sub = 1,
+ SUB = 1,
/// \brief Multiply `a` and `b` and put the result back onto the stack.
- mul = 2,
+ MUL = 2,
/// \brief Divide `a` by `b` and put the result back onto the stack.
- div = 3,
+ DIV = 3,
/// \brief Divide `a` by `b` and put the remainder back onto the stack.
- mod = 4,
+ MOD = 4,
/// \brief Compute the bitwise or of `a` and `b` and put the result back onto the stack.
- or_ = 5,
+ OR = 5,
/// \brief Compute the bitwise and of `a` and `b` and put the result back onto the stack.
- andb = 6, ///< a & b
+ ANDB = 6, ///< a & b
/// \brief Test if `a` is less than `b` and put `1` or `0` onto the stack if
/// the test is true or false respectively.
- lt = 7,
+ LT = 7,
/// \brief Test if `a` is greater than `b` and put `1` or `0` onto the stack
/// if the test is true or false respectively.
- gt = 8,
+ GT = 8,
/// \brief Write `b` to `x` as an integer.
- movi = 9,
+ MOVI = 9,
/// \brief Test if `a == 1` or `b == 1` and put `1` or `0` onto the stack if
/// the test is true or false respectively.
- orr = 11,
+ ORR = 11,
/// \brief Test if `a == 1` and `b == 1` and put `1` or `0` onto the stack if
/// the test is true or false respectively.
- and_ = 12,
+ AND = 12,
/// \brief Left shift `a` by `b` bits and put the result back onto the stack.
- lsl = 13,
+ LSL = 13,
/// \brief Right shift `a` by `b` bits and put the result back onto the stack.
- lsr = 14,
+ LSR = 14,
/// \brief Test if `a` is less than or equal to `b` and put `1` or `0` onto the
/// stack if the test is true or false respectively.
- lte = 15,
+ LTE = 15,
/// \brief Test if `a` is equal to `b` and put `1` or `0` onto the
/// stack if the test is true or false respectively.
- eq = 16,
+ EQ = 16,
/// \brief Test if `a` is not equal to `b` and put `1` or `0` onto the
/// stack if the test is true or false respectively.
- neq = 17,
+ NEQ = 17,
/// \brief Test if `a` is greater than or equal to `b` and put `1` or `0` onto the
/// stack if the test is true or false respectively.
- gte = 18,
+ GTE = 18,
/// \brief Add `x` and `b` and assign the result back to `x`.
/// \note `x` must be a reference to an integer.
- addmovi = 19,
+ ADDMOVI = 19,
/// \brief Subtract `b` from `x` and assign the result back to `x`.
/// \note `x` must be a reference to an integer.
- submovi = 20,
+ SUBMOVI = 20,
/// \brief Multiply `x` from `b` and assign the result back to `x`.
/// \note `x` must be a reference to an integer.
- mulmovi = 21,
+ MULMOVI = 21,
/// \brief Divide `x` by `b` and assign the result back to `x`.
/// \note `x` must be a reference to an integer.
- divmovi = 22,
+ DIVMOVI = 22,
/// \brief Compute `+a` and put the result back onto the stack.
- plus = 30,
+ PLUS = 30,
/// \brief Compute `-a` and put the result back onto the stack.
- negate = 31,
+ NEGATE = 31,
/// \brief Compute `!a` and put the result back onto the stack.
- not_ = 32,
+ NOT = 32,
/// \brief Compute the bitwise complement `a` and put the result back onto the stack.
- cmpl = 33,
+ CMPL = 33,
/// \brief Do nothing.
- nop = 45,
+ NOP = 45,
/// \brief Return from the currently running function
- rsr = 60,
+ RSR = 60,
/// \brief Call the function at the address provided in the instruction.
- bl = 61,
+ BL = 61,
/// \brief Call the external function at the symbol index provided in the instruction.
- be = 62,
+ BE = 62,
/// \brief Push the immediate value provided in the instruction onto the stack as an integer.
- pushi = 64,
+ PUSHI = 64,
/// \brief Push the symbol with the index provided in the instruction onto the stack as a reference.
- pushv = 65,
+ PUSHV = 65,
/// \brief Push the instance with the symbol index provided in the instruction onto the stack as a reference.
- pushvi = 67,
+ PUSHVI = 67,
/// \brief Write `m` to `x` as a string.
- movs = 70,
+ MOVS = 70,
/// \brief Write `m` to `x` as a string reference; not implemented.
- movss = 71,
+ MOVSS = 71,
/// \brief Write `b` to `x` as a function reference.
- movvf = 72,
+ MOVVF = 72,
/// \brief Write `b` to `x` as a floating point number.
- movf = 73,
+ MOVF = 73,
/// \brief Write `y` to `x` as an instance reference.
- movvi = 74,
+ MOVVI = 74,
/// \brief Immediately jump to the instruction at the address provided in the instruction.
- b = 75,
+ B = 75,
/// \brief Jump to the instruction at the address provided in the instruction if `a == 0`.
- bz = 76,
+ BZ = 76,
/// \brief Set the global instance reference to the instance with the symbol index provided in the instrucion.
- gmovi = 80,
+ GMOVI = 80,
/// \brief Push the element at the given index of the symbol with the index provided in the
/// instruction onto the stack as a reference.
- pushvv = 245,
+ PUSHVV = 245,
+
+ add ZKREM("renamed to DaedalusDataType::ADD") = ADD,
+ sub ZKREM("renamed to DaedalusDataType::SUB") = SUB,
+ mul ZKREM("renamed to DaedalusDataType::MUL") = MUL,
+ div ZKREM("renamed to DaedalusDataType::DIV") = DIV,
+ mod ZKREM("renamed to DaedalusDataType::MOD") = MOD,
+ or_ ZKREM("renamed to DaedalusDataType::OR") = OR,
+ andb ZKREM("renamed to DaedalusDataType::ANDB") = ANDB,
+ lt ZKREM("renamed to DaedalusDataType::LT") = LT,
+ gt ZKREM("renamed to DaedalusDataType::GT") = GT,
+ movi ZKREM("renamed to DaedalusDataType::MOVI") = MOVI,
+ orr ZKREM("renamed to DaedalusDataType::ORR") = ORR,
+ and_ ZKREM("renamed to DaedalusDataType::ADD") = AND,
+ lsl ZKREM("renamed to DaedalusDataType::LSL") = LSL,
+ lsr ZKREM("renamed to DaedalusDataType::LSR") = LSR,
+ lte ZKREM("renamed to DaedalusDataType::LTE") = LTE,
+ eq ZKREM("renamed to DaedalusDataType::EQ") = EQ,
+ neq ZKREM("renamed to DaedalusDataType::NEQ") = NEQ,
+ gte ZKREM("renamed to DaedalusDataType::GTE") = GTE,
+ addmovi ZKREM("renamed to DaedalusDataType::ADDMOVI") = ADDMOVI,
+ submovi ZKREM("renamed to DaedalusDataType::SUBMOVI") = SUBMOVI,
+ mulmovi ZKREM("renamed to DaedalusDataType::MULMOVI") = MULMOVI,
+ divmovi ZKREM("renamed to DaedalusDataType::DIVMOVI") = DIVMOVI,
+ plus ZKREM("renamed to DaedalusDataType::PLUS") = PLUS,
+ negate ZKREM("renamed to DaedalusDataType::NEGATE") = NEGATE,
+ not_ ZKREM("renamed to DaedalusDataType::NOT") = NOT,
+ cmpl ZKREM("renamed to DaedalusDataType::CMPL") = CMPL,
+ nop ZKREM("renamed to DaedalusDataType::NOP") = NOP,
+ rsr ZKREM("renamed to DaedalusDataType::RSR") = RSR,
+ bl ZKREM("renamed to DaedalusDataType::BL") = BL,
+ be ZKREM("renamed to DaedalusDataType::BE") = BE,
+ pushi ZKREM("renamed to DaedalusDataType::PUSHI") = PUSHI,
+ pushv ZKREM("renamed to DaedalusDataType::PUSHV") = PUSHV,
+ pushvi ZKREM("renamed to DaedalusDataType::PUSHVI") = PUSHVI,
+ movs ZKREM("renamed to DaedalusDataType::MOVS") = MOVS,
+ movss ZKREM("renamed to DaedalusDataType::MOVSS") = MOVSS,
+ movvf ZKREM("renamed to DaedalusDataType::MOVVF") = MOVVF,
+ movf ZKREM("renamed to DaedalusDataType::MOVF") = MOVF,
+ movvi ZKREM("renamed to DaedalusDataType::MOVVI") = MOVVI,
+ b ZKREM("renamed to DaedalusDataType::B") = B,
+ bz ZKREM("renamed to DaedalusDataType::BZ") = BZ,
+ gmovi ZKREM("renamed to DaedalusDataType::GMOVI") = GMOVI,
+ pushvv ZKREM("renamed to DaedalusDataType::PUSHVV") = PUSHVV,
};
- class symbol;
+ class DaedalusSymbol;
/// \brief Represents an object associated with an instance in the script.
///
/// Every class defined in C++ that can be used as an instance has to inherit from this class.
- class instance {
+ class ZKAPI DaedalusInstance {
public:
- PHOENIX_API virtual ~instance() = default;
+ virtual ~DaedalusInstance() = default;
/// \return The index of the symbol this instance is bound to.
- [[nodiscard]] PHOENIX_API inline uint32_t symbol_index() const {
+ [[nodiscard]] uint32_t symbol_index() const {
return _m_symbol_index;
}
@@ -218,46 +287,46 @@ namespace phoenix {
void* user_ptr = nullptr;
protected:
- PHOENIX_INTERNAL virtual std::uint8_t* data() {
+ virtual std::uint8_t* data() {
return reinterpret_cast(this);
}
- PHOENIX_INTERNAL virtual const std::uint8_t* data() const {
+ [[nodiscard]] virtual const std::uint8_t* data() const {
return reinterpret_cast(this);
}
private:
- friend class transient_instance;
- friend class symbol;
- friend class script;
- friend class vm;
+ friend class DaedalusTransientInstance;
+ friend class DaedalusSymbol;
+ friend class DaedalusScript;
+ friend class DaedalusVm;
- uint32_t _m_symbol_index {unset};
+ uint32_t _m_symbol_index {static_cast(-1)};
const std::type_info* _m_type {nullptr};
};
/// \brief Represents an object associated with an instance in the script.
///
/// Instances allocated with init_opaque will be backed up by this class with plain memory storage
- class opaque_instance final : public instance {
+ class DaedalusOpaqueInstance final : public DaedalusInstance {
public:
- PHOENIX_INTERNAL opaque_instance(symbol const& sym, std::vector const& members);
- PHOENIX_INTERNAL ~opaque_instance();
+ ZKAPI DaedalusOpaqueInstance(DaedalusSymbol const& sym, std::vector const& members);
+ ZKAPI ~DaedalusOpaqueInstance();
protected:
friend class symbol;
- PHOENIX_INTERNAL std::uint8_t* data() override {
+ ZKAPI std::uint8_t* data() override {
return _m_storage.get();
}
- PHOENIX_INTERNAL const std::uint8_t* data() const override {
+ [[nodiscard]] ZKAPI std::uint8_t const* data() const override {
return _m_storage.get();
}
private:
template
- PHOENIX_INTERNAL T* construct_at(size_t offset, Args&&... args);
+ ZKINT T* construct_at(size_t offset, Args&&... args);
std::unique_ptr _m_storage;
std::vector _m_strings;
@@ -266,192 +335,198 @@ namespace phoenix {
/// \brief Represents object instance in the script with no defined backing to memory.
///
/// Expected to be used for DMA mods or to emulate variable-like access to engine-functions.
- class transient_instance : public instance {
+ class ZKAPI DaedalusTransientInstance : public DaedalusInstance {
public:
- transient_instance();
- ~transient_instance();
+ DaedalusTransientInstance();
+ ~DaedalusTransientInstance();
protected:
- friend class symbol;
+ friend class DaedalusSymbol;
- virtual void set_int(symbol const& sym, uint16_t index, std::int32_t value) = 0;
- virtual std::int32_t get_int(symbol const& sym, uint16_t index) = 0;
+ virtual void set_int(DaedalusSymbol const& sym, uint16_t index, std::int32_t value) = 0;
+ virtual std::int32_t get_int(DaedalusSymbol const& sym, uint16_t index) = 0;
- virtual void set_float(symbol const& sym, uint16_t index, float value) = 0;
- virtual float get_float(symbol const& sym, uint16_t index) = 0;
+ virtual void set_float(DaedalusSymbol const& sym, uint16_t index, float value) = 0;
+ virtual float get_float(DaedalusSymbol const& sym, uint16_t index) = 0;
- virtual void set_string(symbol const& sym, uint16_t index, std::string_view value) = 0;
- virtual const std::string& get_string(symbol const& sym, uint16_t index) = 0;
+ virtual void set_string(DaedalusSymbol const& sym, uint16_t index, std::string_view value) = 0;
+ virtual const std::string& get_string(DaedalusSymbol const& sym, uint16_t index) = 0;
};
/// \brief The base class for all exceptions thrown by interacting with a script.
- struct script_error : public error {
- using error::error;
+ struct DaedalusScriptError : public Error {
+ using Error::Error;
};
/// \brief An exception thrown if the symbol with a given name could not be found.
- struct symbol_not_found : public script_error {
+ struct DaedalusSymbolNotFound : public DaedalusScriptError {
public:
- PHOENIX_API explicit symbol_not_found(std::string&& name);
+ ZKAPI explicit DaedalusSymbolNotFound(std::string&& name);
public:
std::string name;
};
/// \brief An exception thrown if registering a class member was unsuccessful.
- struct member_registration_error : public script_error {
+ struct DaedalusMemberRegistrationError : public DaedalusScriptError {
public:
- PHOENIX_API explicit member_registration_error(const symbol* sym, std::string&& message);
+ ZKAPI explicit DaedalusMemberRegistrationError(DaedalusSymbol const* sym, std::string&& message);
public:
/// \brief The symbol being registered.
- const symbol* sym;
+ DaedalusSymbol const* sym;
};
/// \brief An exception thrown if the type of the member being registered does not match the type provided.
- struct invalid_registration_datatype final : public member_registration_error {
+ struct DaedalusInvalidRegistrationDataType final : public DaedalusMemberRegistrationError {
public:
- PHOENIX_API explicit invalid_registration_datatype(const symbol* sym, std::string&& given);
+ ZKAPI explicit DaedalusInvalidRegistrationDataType(const DaedalusSymbol* sym, std::string&& given);
public:
std::string given;
};
/// \brief An exception thrown when the value of a symbol accessed in a way which is not permissible.
- struct illegal_access : public script_error {
- using script_error::script_error;
+ struct DaedalusIllegalAccess : public DaedalusScriptError {
+ using DaedalusScriptError::DaedalusScriptError;
};
/// \brief An exception thrown when the type of a symbol does not match the type expected.
- struct illegal_type_access final : public illegal_access {
+ struct DaedalusIllegalTypeAccess final : public DaedalusIllegalAccess {
public:
- PHOENIX_INTERNAL illegal_type_access(const symbol* sym, datatype expected);
+ ZKINT DaedalusIllegalTypeAccess(DaedalusSymbol const* sym, DaedalusDataType expected);
public:
/// \brief The symbol being accessed.
- const symbol* sym;
+ DaedalusSymbol const* sym;
/// \brief The datatype excepted.
- datatype expected;
+ DaedalusDataType expected;
};
/// \brief An exception thrown when an out-of-bounds index is accessed.
- struct illegal_index_access final : public illegal_access {
+ struct DaedalusIllegalIndexAccess final : public DaedalusIllegalAccess {
public:
- PHOENIX_INTERNAL illegal_index_access(const symbol* sym, std::uint8_t index);
+ ZKINT DaedalusIllegalIndexAccess(DaedalusSymbol const* sym, std::uint8_t index);
public:
/// \brief The symbol being accessed.
- const symbol* sym;
+ const DaedalusSymbol* sym;
/// \brief The index being accessed
std::uint8_t index;
};
/// \brief An exception thrown when a constant symbol is accessed as mutable
- struct illegal_const_access final : public illegal_access {
+ struct DaedalusIllegalConstAccess final : public DaedalusIllegalAccess {
public:
- PHOENIX_INTERNAL explicit illegal_const_access(const symbol* sym);
+ ZKINT explicit DaedalusIllegalConstAccess(DaedalusSymbol const* sym);
public:
/// \brief The symbol being accessed.
- const symbol* sym;
+ DaedalusSymbol const* sym;
};
/// \brief An exception thrown when the parent class of a member does not match the class of an instance.
- struct illegal_instance_access final : public illegal_access {
+ struct DaedalusIllegalInstanceAccess final : public DaedalusIllegalAccess {
public:
- PHOENIX_INTERNAL illegal_instance_access(const symbol* sym, std::uint32_t expected_parent);
+ ZKINT DaedalusIllegalInstanceAccess(DaedalusSymbol const* sym, std::uint32_t expected_parent);
public:
/// \brief The symbol being accessed.
- const symbol* sym;
+ DaedalusSymbol const* sym;
/// \brief The parent which was expected for the member.
std::uint32_t expected_parent;
};
/// \brief An exception thrown when the parent class of a member does not match the class of an instance.
- struct unbound_member_access final : public illegal_access {
+ struct DaedalusUnboundMemberAccess final : public DaedalusIllegalAccess {
public:
- PHOENIX_API explicit unbound_member_access(const symbol* sym);
+ ZKAPI explicit DaedalusUnboundMemberAccess(DaedalusSymbol const* sym);
public:
/// \brief The symbol being accessed.
- const symbol* sym;
+ DaedalusSymbol const* sym;
};
/// \brief An exception thrown if a member symbol is being access without a context set.
- struct no_context final : public illegal_access {
+ struct DaedalusNoContextError final : public DaedalusIllegalAccess {
public:
- PHOENIX_INTERNAL explicit no_context(const symbol* sym);
+ ZKINT explicit DaedalusNoContextError(DaedalusSymbol const* sym);
public:
/// \brief The symbol being accessed.
- const symbol* sym;
+ DaedalusSymbol const* sym;
};
- /// \brief An excpetion thrown if a member symbol is being accessed with a context instance it is not bound to.
- struct illegal_context_type final : public illegal_access {
+ /// \brief An exception thrown if a member symbol is being accessed with a context instance it is not bound to.
+ struct DaedalusIllegalContextType final : public DaedalusIllegalAccess {
public:
- PHOENIX_API illegal_context_type(const symbol* sym, const std::type_info& context_type);
+ ZKAPI DaedalusIllegalContextType(DaedalusSymbol const* sym, const std::type_info& context_type);
public:
/// \brief The symbol being accessed.
- const symbol* sym;
+ DaedalusSymbol const* sym;
/// \brief The type of context currently set.
const std::type_info& context_type;
};
/// \brief Represents a compiled daedalus symbol.
- class symbol final {
+ class DaedalusSymbol final {
public:
+ ZKINT DaedalusSymbol() = default;
+
/// \brief Parses a symbol from the given reader.
/// \param[in,out] in The reader to read the symbol from.
/// \return The symbol parsed.
- [[nodiscard]] PHOENIX_API static symbol parse(buffer& in);
+ [[nodiscard]] ZKREM("use ::load()") ZKAPI static DaedalusSymbol parse(phoenix::buffer& in);
+ ZKAPI void load(Read* in);
/// \brief Validates that the symbol is a string and retrieves it's value in the given context.
/// \param index The index of the value to get.
/// \param context An instance to use as context for getting member variables.
/// \return The string associated with the symbol.
- /// \throws illegal_type_access if the #type of this symbol is not dt_string.
- /// \throws illegal_index_access if \p index >= #count.
- /// \throws no_context if this symbol #is_member and \p context is `nullptr`.
- /// \throws unbound_member_access if this symbol has not been registered yet
- /// \throws illegal_context_type if this symbol #is_registered_to a different type than the type of \p context.
- [[nodiscard]] PHOENIX_API const std::string&
- get_string(std::size_t index = 0, const std::shared_ptr& context = nullptr) const;
+ /// \throws DaedalusIllegalTypeAccess if the #type of this symbol is not dt_string.
+ /// \throws DaedalusIllegalIndexAccess if \p index >= #count.
+ /// \throws DaedalusNoContextError if this symbol #is_member and \p context is `nullptr`.
+ /// \throws DaedalusUnboundMemberAccess if this symbol has not been registered yet
+ /// \throws DaedalusIllegalContextType if this symbol #is_registered_to a different type than the type of \p
+ /// context.
+ [[nodiscard]] ZKAPI const std::string&
+ get_string(std::size_t index = 0, const std::shared_ptr& context = nullptr) const;
/// \brief Validates that the symbol is a float and retrieves it's value in the given context.
/// \param index The index of the value to get.
/// \param context An instance to use as context for getting member variables.
/// \return The float value associated with the symbol.
- /// \throws illegal_type_access if the #type of this symbol is not dt_float.
- /// \throws illegal_index_access if \p index >= #count.
- /// \throws no_context if this symbol #is_member and \p context is `nullptr`.
- /// \throws unbound_member_access if this symbol has not been registered yet
- /// \throws illegal_context_type if this symbol #is_registered_to a different type than the type of \p context.
- [[nodiscard]] PHOENIX_API float get_float(std::size_t index = 0,
- const std::shared_ptr& context = nullptr) const;
+ /// \throws DaedalusIllegalTypeAccess if the #type of this symbol is not dt_float.
+ /// \throws DaedalusIllegalIndexAccess if \p index >= #count.
+ /// \throws DaedalusNoContextError if this symbol #is_member and \p context is `nullptr`.
+ /// \throws DaedalusUnboundMemberAccess if this symbol has not been registered yet
+ /// \throws DaedalusIllegalContextType if this symbol #is_registered_to a different type than the type of \p
+ /// context.
+ [[nodiscard]] ZKAPI float get_float(std::size_t index = 0,
+ const std::shared_ptr& context = nullptr) const;
/// \brief Validates that the symbol is an int and retrieves it's value in the given context.
/// \param index The index of the value to get.
/// \param context An instance to use as context for getting member variables.
/// \return The int value associated with the symbol.
- /// \throws illegal_type_access if the #type of this symbol is not dt_int or dt_function.
- /// \throws illegal_index_access if \p index >= #count.
- /// \throws no_context if this symbol #is_member and \p context is `nullptr`.
- /// \throws unbound_member_access if this symbol has not been registered yet
- /// \throws illegal_context_type if this symbol #is_registered_to a different type than the type of \p context.
- [[nodiscard]] PHOENIX_API std::int32_t get_int(std::size_t index = 0,
- const std::shared_ptr& context = nullptr) const;
+ /// \throws DaedalusIllegalTypeAccess if the #type of this symbol is not dt_int or dt_function.
+ /// \throws DaedalusIllegalIndexAccess if \p index >= #count.
+ /// \throws DaedalusNoContextError if this symbol #is_member and \p context is `nullptr`.
+ /// \throws DaedalusUnboundMemberAccess if this symbol has not been registered yet
+ /// \throws DaedalusIllegalContextType if this symbol #is_registered_to a different type than the type of \p
+ /// context.
+ [[nodiscard]] ZKAPI std::int32_t get_int(std::size_t index = 0,
+ const std::shared_ptr& context = nullptr) const;
/// \brief Validates that the symbol is an instance and retrieves it's value
/// \return The instance associated with the symbol.
- /// \throws illegal_type_access if the #type of this symbol is not dt_instance
- [[nodiscard]] PHOENIX_API const std::shared_ptr& get_instance();
+ /// \throws DaedalusIllegalTypeAccess if the #type of this symbol is not dt_instance
+ [[nodiscard]] ZKAPI const std::shared_ptr& get_instance();
// -=-= Value setters =-=- //
@@ -459,177 +534,179 @@ namespace phoenix {
/// \param value The new value to set.
/// \param index The index of the value to set
/// \param context An instance to use as context for setting member variables.
- /// \throws illegal_type_access if the #type of this symbol is not dt_string.
- /// \throws illegal_index_access if \p index >= #count.
- /// \throws no_context if this symbol #is_member and \p context is `nullptr`.
- /// \throws unbound_member_access if this symbol has not been registered yet
- /// \throws illegal_context_type if this symbol #is_registered_to a different type than the type of \p context.
- PHOENIX_API void
- set_string(std::string_view value, std::size_t index = 0, const std::shared_ptr& context = nullptr);
+ /// \throws DaedalusIllegalTypeAccess if the #type of this symbol is not dt_string.
+ /// \throws DaedalusIllegalIndexAccess if \p index >= #count.
+ /// \throws DaedalusNoContextError if this symbol #is_member and \p context is `nullptr`.
+ /// \throws DaedalusUnboundMemberAccess if this symbol has not been registered yet
+ /// \throws DaedalusIllegalContextType if this symbol #is_registered_to a different type than the type of \p
+ /// context.
+ ZKAPI void set_string(std::string_view value,
+ std::size_t index = 0,
+ const std::shared_ptr& context = nullptr);
/// \brief Validates that the symbol is a float and not constant and sets it's value in the given context.
/// \param value The new value to set.
/// \param index The index of the value to set
/// \param context An instance to use as context for setting member variables.
- /// \throws illegal_type_access if the #type of this symbol is not dt_float
- /// \throws illegal_index_access if \p index >= #count.
- /// \throws no_context if this symbol #is_member and \p context is `nullptr`.
- /// \throws unbound_member_access if this symbol has not been registered yet
- /// \throws illegal_context_type if this symbol #is_registered_to a different type than the type of \p context.
- PHOENIX_API void
- set_float(float value, std::size_t index = 0, const std::shared_ptr& context = nullptr);
+ /// \throws DaedalusIllegalTypeAccess if the #type of this symbol is not dt_float
+ /// \throws DaedalusIllegalIndexAccess if \p index >= #count.
+ /// \throws DaedalusNoContextError if this symbol #is_member and \p context is `nullptr`.
+ /// \throws DaedalusUnboundMemberAccess if this symbol has not been registered yet
+ /// \throws DaedalusIllegalContextType if this symbol #is_registered_to a different type than the type of \p
+ /// context.
+ ZKAPI void
+ set_float(float value, std::size_t index = 0, const std::shared_ptr& context = nullptr);
/// \brief Validates that the symbol is an int and not constant and sets it's value in the given context.
/// \param value The new value to set.
/// \param index The index of the value to set
/// \param context An instance to use as context for setting member variables.
- /// \throws illegal_type_access if the #type of this symbol is not dt_int or dt_function.
- /// \throws illegal_index_access if \p index >= #count.
- /// \throws no_context if this symbol #is_member and \p context is `nullptr`.
- /// \throws unbound_member_access if this symbol has not been registered yet
- /// \throws illegal_context_type if this symbol #is_registered_to a different type than the type of \p context.
- PHOENIX_API void
- set_int(std::int32_t value, std::size_t index = 0, const std::shared_ptr& context = nullptr);
+ /// \throws DaedalusIllegalTypeAccess if the #type of this symbol is not dt_int or dt_function.
+ /// \throws DaedalusIllegalIndexAccess if \p index >= #count.
+ /// \throws DaedalusNoContextError if this symbol #is_member and \p context is `nullptr`.
+ /// \throws DaedalusUnboundMemberAccess if this symbol has not been registered yet
+ /// \throws DaedalusIllegalContextType if this symbol #is_registered_to a different type than the type of \p
+ /// context.
+ ZKAPI void
+ set_int(std::int32_t value, std::size_t index = 0, const std::shared_ptr& context = nullptr);
/// \brief Validates that the symbol is an instance and sets it's value
/// \param inst The instance value to set
- /// \throws illegal_type_access if the #type of this symbol is not dt_instance.
- PHOENIX_API void set_instance(const std::shared_ptr& inst);
+ /// \throws DaedalusIllegalTypeAccess if the #type of this symbol is not dt_instance.
+ ZKAPI void set_instance(const std::shared_ptr& inst);
/// \brief Tests whether this symbol holds an instance of the given type.
/// \tparam T The type of instance to check for.
/// \return true if the symbol contains an instance of the given type, false if not.
template
- PHOENIX_API typename std::enable_if,
- bool>::type inline is_instance_of() { // clang-format on
- return this->type() == datatype::instance && this->get_instance() != nullptr &&
+ ZKAPI typename std::enable_if,
+ bool>::type inline is_instance_of() { // clang-format on
+ return this->type() == DaedalusDataType::INSTANCE && this->get_instance() != nullptr &&
this->get_instance()->_m_type == &typeid(T);
}
/// \brief Allows VM traps on access to this symbol
/// \param enable true to enable and false to disable
- PHOENIX_API void set_access_trap_enable(bool enable) noexcept;
+ ZKAPI void set_access_trap_enable(bool enable) noexcept;
/// \brief Tests whether the symbol is a constant.
/// \return `true` if the symbol is a constant, `false` if not.
- [[nodiscard]] PHOENIX_API inline bool is_const() const noexcept {
- return (_m_flags & symbol_flag::const_) != 0;
+ [[nodiscard]] ZKAPI inline bool is_const() const noexcept {
+ return (_m_flags & DaedalusSymbolFlag::CONST) != 0;
}
/// \brief Tests whether the symbol is a member variable.
/// \return `true` if the symbol is a member, `false` if not.
- [[nodiscard]] PHOENIX_API inline bool is_member() const noexcept {
- return (_m_flags & symbol_flag::member) != 0;
+ [[nodiscard]] ZKAPI inline bool is_member() const noexcept {
+ return (_m_flags & DaedalusSymbolFlag::MEMBER) != 0;
}
/// \brief Tests whether the symbol is an extern symbol.
/// \return `true` if the symbol is an extern symbol, `false` if not.
- [[nodiscard]] PHOENIX_API inline bool is_external() const noexcept {
- return (_m_flags & symbol_flag::external) != 0;
+ [[nodiscard]] ZKAPI inline bool is_external() const noexcept {
+ return (_m_flags & DaedalusSymbolFlag::EXTERNAL) != 0;
}
/// \brief Tests whether the symbol is merged.
/// \return `true` if the symbol is merged, `false` if not.
/// \note It is currently not known what 'merged' means.
- [[nodiscard]] PHOENIX_API inline bool is_merged() const noexcept {
- return (_m_flags & symbol_flag::merged) != 0;
+ [[nodiscard]] ZKAPI inline bool is_merged() const noexcept {
+ return (_m_flags & DaedalusSymbolFlag::MERGED) != 0;
}
/// \brief Tests whether the symbol has access trap.
/// \return `true` if the symbol has trap enabled, `false` if not.
- [[nodiscard]] PHOENIX_API inline bool has_access_trap() const noexcept {
- return (_m_flags & symbol_flag::access_trap) != 0;
+ [[nodiscard]] ZKAPI inline bool has_access_trap() const noexcept {
+ return (_m_flags & DaedalusSymbolFlag::TRAP_ACCESS) != 0;
}
/// \brief brief Tests whether the symbol is a compiler-generated symbol
/// \return return `true` if the symbol is generated, `false` if not.
- [[nodiscard]] PHOENIX_API inline bool is_generated() const noexcept {
+ [[nodiscard]] ZKAPI inline bool is_generated() const noexcept {
return _m_generated;
}
/// \brief brief Tests whether the symbol has a return value.
/// \return return `true` if the symbol has a return value, `false` if not.
- [[nodiscard]] PHOENIX_API inline bool has_return() const noexcept {
- return (_m_flags & symbol_flag::return_) != 0;
+ [[nodiscard]] ZKAPI inline bool has_return() const noexcept {
+ return (_m_flags & DaedalusSymbolFlag::RETURN) != 0;
}
/// \return The name of the symbol.
- [[nodiscard]] PHOENIX_API inline const std::string& name() const noexcept {
+ [[nodiscard]] ZKAPI inline const std::string& name() const noexcept {
return _m_name;
}
/// \return The address of the symbol.
- [[nodiscard]] PHOENIX_API inline std::uint32_t address() const noexcept {
+ [[nodiscard]] ZKAPI inline std::uint32_t address() const noexcept {
return _m_address;
}
/// \return The index of the parent symbol or unset if the symbol does not have a parent.
- [[nodiscard]] PHOENIX_API inline std::uint32_t parent() const noexcept {
+ [[nodiscard]] ZKAPI inline std::uint32_t parent() const noexcept {
return _m_parent;
}
/// \return The count of values stored in the symbol.
- [[nodiscard]] PHOENIX_API inline std::uint32_t count() const noexcept {
+ [[nodiscard]] ZKAPI inline std::uint32_t count() const noexcept {
return _m_count;
}
/// \return The type of the symbol.
- [[nodiscard]] PHOENIX_API inline datatype type() const noexcept {
+ [[nodiscard]] ZKAPI inline DaedalusDataType type() const noexcept {
return _m_type;
}
/// \return The index of the symbol.
- [[nodiscard]] PHOENIX_API inline std::uint32_t index() const noexcept {
+ [[nodiscard]] ZKAPI inline std::uint32_t index() const noexcept {
return _m_index;
}
/// \return The return type of the symbol.
- [[nodiscard]] PHOENIX_API inline datatype rtype() const noexcept {
+ [[nodiscard]] ZKAPI inline DaedalusDataType rtype() const noexcept {
return _m_return_type;
}
/// \return The index of the file the symbol was in.
- [[nodiscard]] PHOENIX_API inline std::uint32_t file_index() const noexcept {
+ [[nodiscard]] ZKAPI inline std::uint32_t file_index() const noexcept {
return _m_file_index;
}
/// \return The offset in bytes of a member from the start of the instance.
- [[nodiscard]] PHOENIX_API inline std::uint32_t offset_as_member() const noexcept {
+ [[nodiscard]] ZKAPI inline std::uint32_t offset_as_member() const noexcept {
return _m_member_offset;
}
- [[nodiscard]] PHOENIX_API inline std::uint32_t line_start() const noexcept {
+ [[nodiscard]] ZKAPI inline std::uint32_t line_start() const noexcept {
return _m_line_start;
}
- [[nodiscard]] PHOENIX_API inline std::uint32_t line_count() const noexcept {
+ [[nodiscard]] ZKAPI inline std::uint32_t line_count() const noexcept {
return _m_line_count;
}
- [[nodiscard]] PHOENIX_API inline std::uint32_t char_start() const noexcept {
+ [[nodiscard]] ZKAPI inline std::uint32_t char_start() const noexcept {
return _m_char_start;
}
- [[nodiscard]] PHOENIX_API inline std::uint32_t char_count() const noexcept {
+ [[nodiscard]] ZKAPI inline std::uint32_t char_count() const noexcept {
return _m_char_count;
}
- [[nodiscard]] PHOENIX_API inline std::uint32_t class_size() const noexcept {
+ [[nodiscard]] ZKAPI inline std::uint32_t class_size() const noexcept {
return _m_class_size;
}
- [[nodiscard]] PHOENIX_API inline const std::type_info& registered_to() const noexcept {
+ [[nodiscard]] ZKAPI inline const std::type_info& registered_to() const noexcept {
return *_m_registered_to;
};
protected:
- PHOENIX_INTERNAL symbol() = default;
-
template
- inline const T* get_member_ptr(std::uint8_t index, const std::shared_ptr& context) const {
+ inline const T* get_member_ptr(std::uint8_t index, const std::shared_ptr& context) const {
if (!_m_registered_to)
- throw unbound_member_access(this);
+ throw DaedalusUnboundMemberAccess(this);
if (*_m_registered_to != *context->_m_type)
- throw illegal_context_type {this, *context->_m_type};
+ throw DaedalusIllegalContextType {this, *context->_m_type};
auto data_ptr = context->data();
std::uint32_t target_offset = offset_as_member() + index * sizeof(T);
@@ -637,11 +714,11 @@ namespace phoenix {
}
template
- inline T* get_member_ptr(std::uint8_t index, const std::shared_ptr& context) {
+ inline T* get_member_ptr(std::uint8_t index, const std::shared_ptr& context) {
if (!_m_registered_to)
- throw unbound_member_access(this);
+ throw DaedalusUnboundMemberAccess(this);
if (*_m_registered_to != *context->_m_type)
- throw illegal_context_type {this, *context->_m_type};
+ throw DaedalusIllegalContextType {this, *context->_m_type};
auto data_ptr = context->data();
std::uint32_t target_offset = offset_as_member() + index * sizeof(T);
@@ -649,19 +726,19 @@ namespace phoenix {
}
private:
- friend class script;
+ friend class DaedalusScript;
std::string _m_name;
std::variant,
std::unique_ptr,
std::unique_ptr,
- std::shared_ptr>
+ std::shared_ptr>
_m_value;
- std::uint32_t _m_address {unset};
- std::uint32_t _m_parent {unset};
- std::uint32_t _m_class_offset {unset};
+ std::uint32_t _m_address {static_cast(-1)};
+ std::uint32_t _m_parent {static_cast(-1)};
+ std::uint32_t _m_class_offset {static_cast(-1)};
std::uint32_t _m_count {0};
- datatype _m_type {0};
+ DaedalusDataType _m_type {0};
std::uint32_t _m_flags {0};
bool _m_generated {false};
@@ -671,16 +748,16 @@ namespace phoenix {
std::uint32_t _m_char_start {0};
std::uint32_t _m_char_count {0};
- std::uint32_t _m_member_offset {unset};
- std::uint32_t _m_class_size {unset};
- datatype _m_return_type {datatype::void_};
- std::uint32_t _m_index {unset};
+ std::uint32_t _m_member_offset {static_cast(-1)};
+ std::uint32_t _m_class_size {static_cast(-1)};
+ DaedalusDataType _m_return_type {DaedalusDataType::VOID};
+ std::uint32_t _m_index {static_cast(-1)};
const std::type_info* _m_registered_to {nullptr};
};
/// \brief Represents a daedalus VM instruction.
- struct instruction {
- opcode op {opcode::nop};
+ struct DaedalusInstruction {
+ DaedalusOpcode op {DaedalusOpcode::NOP};
std::uint32_t address {0};
std::uint32_t symbol {0};
std::int32_t immediate {0};
@@ -690,32 +767,36 @@ namespace phoenix {
/// \brief Reads an instruction from a reader.
/// \param[in,out] in The reader to read from
/// \return The instruction read.
- PHOENIX_INTERNAL static instruction decode(buffer& in);
+ ZKINT static DaedalusInstruction decode(Read* r);
};
/// \brief Represents a compiled daedalus script
- class script {
+ class DaedalusScript {
public:
- PHOENIX_API script(const script& copy) = default;
- PHOENIX_API script(script&& move) = default;
+ ZKAPI DaedalusScript() = default;
+ ZKAPI DaedalusScript(const DaedalusScript& copy) = delete;
+ ZKAPI DaedalusScript(DaedalusScript&& move) = default;
/// \brief Parses in a compiled daedalus script.
/// \param path The path of the script file.
/// \return The script parsed
- [[nodiscard]] PHOENIX_API static script parse(const std::string& path);
+ [[nodiscard]] ZKREM("use ::load") ZKAPI static DaedalusScript parse(const std::string& path);
/// \brief Parses in a compiled daedalus script.
/// \param buf A buffer containing the script data.
/// \return The script parsed
- [[nodiscard]] PHOENIX_API static script parse(phoenix::buffer& buf);
+ [[nodiscard]] ZKREM("use ::load") ZKAPI static DaedalusScript parse(phoenix::buffer& buf);
+
+ ZKAPI void load(Read* r);
/// \brief Registers a member offset
/// \param name The name of the member in the script
/// \param field The field to register
- /// \throws symbol_not_found if there is no symbol with the given name.
- /// \throws member_registration_error if the member could not be registered
- /// \throws invalid_registration_datatype If the datatype of \p _member is different than that of the symbol.
+ /// \throws DaedalusSymbolNotFound if there is no symbol with the given name.
+ /// \throws DaedalusMemberRegistrationError if the member could not be registered
+ /// \throws DaedalusInvalidRegistrationDataType If the datatype of \p _member is different than that of the
+ /// symbol.
template
typename std::enable_if || std::is_same_v<_member, float> ||
std::is_same_v<_member, std::int32_t> ||
@@ -734,9 +815,10 @@ namespace phoenix {
/// \brief Registers a member offset
/// \param name The name of the member in the script
/// \param field The field to register
- /// \throws symbol_not_found if there is no symbol with the given name.
- /// \throws member_registration_error if the member could not be registered
- /// \throws invalid_registration_datatype If the datatype of \p _member is different than that of the symbol.
+ /// \throws DaedalusSymbolNotFound if there is no symbol with the given name.
+ /// \throws DaedalusMemberRegistrationError if the member could not be registered
+ /// \throws DaedalusInvalidRegistrationDataType If the datatype of \p _member is different than that of the
+ /// symbol.
template
typename std::enable_if || std::is_same_v<_member, float> ||
std::is_same_v<_member, std::int32_t> ||
@@ -753,72 +835,71 @@ namespace phoenix {
}
/// \return All symbols in the script
- [[nodiscard]] PHOENIX_API inline const std::vector& symbols() const noexcept {
+ [[nodiscard]] ZKAPI inline const std::vector& symbols() const noexcept {
return _m_symbols;
}
/// \brief Retrieves the symbol with the given \p index
/// \param index The index of the symbol to get
/// \return The symbol or `nullptr` if the index was out-of-range.
- [[nodiscard]] PHOENIX_API const symbol* find_symbol_by_index(std::uint32_t index) const;
+ [[nodiscard]] ZKAPI const DaedalusSymbol* find_symbol_by_index(std::uint32_t index) const;
/// \brief Looks for parameters of the given function symbol. Only works for external functions.
/// \param parent The function symbol to get the parameter symbols for.
/// \return A list of function parameter symbols.
- [[nodiscard]] PHOENIX_API std::vector find_parameters_for_function(const symbol* parent) const;
+ [[nodiscard]] ZKAPI std::vector
+ find_parameters_for_function(const DaedalusSymbol* parent) const;
/// \brief Retrieves the symbol with the given \p address set
/// \param index The address of the symbol to get
/// \return The symbol or `nullptr` if no symbol with that address was found.
- [[nodiscard]] PHOENIX_API const symbol* find_symbol_by_address(std::uint32_t address) const;
+ [[nodiscard]] ZKAPI const DaedalusSymbol* find_symbol_by_address(std::uint32_t address) const;
/// \brief Retrieves the symbol with the given \p name.
/// \param name The name of the symbol to get.
/// \return The symbol or `nullptr` if no symbol with that name was found.
- [[nodiscard]] PHOENIX_API const symbol* find_symbol_by_name(std::string_view name) const;
+ [[nodiscard]] ZKAPI const DaedalusSymbol* find_symbol_by_name(std::string_view name) const;
/// \brief Retrieves the symbol with the given \p index
/// \param index The index of the symbol to get
/// \return The symbol or `nullptr` if the index was out-of-range.
- [[nodiscard]] PHOENIX_API symbol* find_symbol_by_index(std::uint32_t index);
+ [[nodiscard]] ZKAPI DaedalusSymbol* find_symbol_by_index(std::uint32_t index);
/// \brief Retrieves the symbol with the given \p address set
/// \param index The address of the symbol to get
/// \return The symbol or `nullptr` if no symbol with that address was found.
- [[nodiscard]] PHOENIX_API symbol* find_symbol_by_address(std::uint32_t address);
+ [[nodiscard]] ZKAPI DaedalusSymbol* find_symbol_by_address(std::uint32_t address);
/// \brief Looks for parameters of the given function symbol. Only works for external functions.
/// \param parent The function symbol to get the parameter symbols for.
/// \return A list of function parameter symbols.
- [[nodiscard]] PHOENIX_API std::vector find_parameters_for_function(const symbol* parent);
+ [[nodiscard]] ZKAPI std::vector find_parameters_for_function(const DaedalusSymbol* parent);
/// \brief Retrieves the symbol with the given \p name.
/// \param name The name of the symbol to get.
/// \return The symbol or `nullptr` if no symbol with that name was found.
- [[nodiscard]] PHOENIX_API symbol* find_symbol_by_name(std::string_view name);
+ [[nodiscard]] ZKAPI DaedalusSymbol* find_symbol_by_name(std::string_view name);
/// \brief Call the given callback function for every instance symbol which is a descendant of the class with
/// the given name.
/// \param name The name of the parent class.
/// \param callback The function to call with each instance symbol.
- PHOENIX_API void enumerate_instances_by_class_name(std::string_view name,
- const std::function& callback);
+ ZKAPI void enumerate_instances_by_class_name(std::string_view name,
+ const std::function& callback);
/// \brief Decodes the instruction at \p address and returns it.
/// \param address The address of the instruction to decode
/// \return The instruction.
- [[nodiscard]] PHOENIX_API instruction instruction_at(std::uint32_t address) const;
+ [[nodiscard]] ZKAPI DaedalusInstruction instruction_at(std::uint32_t address) const;
/// \return The total size of the script.
- [[nodiscard]] PHOENIX_API std::uint32_t size() const noexcept {
- return _m_text.limit() & 0xFFFFFF;
- }
+ [[nodiscard]] ZKAPI std::uint32_t size() const noexcept;
/// \brief Finds the symbol the given instance is currently bound to.
/// \param inst The instance to get the symbol for.
/// \return The symbol associated with that instance or nullptr if the symbol is not associated
/// with any instance.
- PHOENIX_API inline const symbol* find_symbol_by_instance(const instance& inst) const {
+ ZKAPI inline const DaedalusSymbol* find_symbol_by_instance(const DaedalusInstance& inst) const {
return find_symbol_by_index(inst._m_symbol_index);
}
@@ -826,7 +907,7 @@ namespace phoenix {
/// \param inst The instance to get the symbol for.
/// \return The symbol associated with that instance or nullptr if the symbol is not associated
/// with any instance.
- PHOENIX_API inline symbol* find_symbol_by_instance(const instance& inst) {
+ ZKAPI inline DaedalusSymbol* find_symbol_by_instance(const DaedalusInstance& inst) {
return find_symbol_by_index(inst._m_symbol_index);
}
@@ -835,9 +916,8 @@ namespace phoenix {
/// \return The symbol associated with that instance or nullptr if the symbol is not associated
/// with any instance.
template
- PHOENIX_API
- typename std::enable_if, const symbol*>::type inline find_symbol_by_instance(
- const std::shared_ptr& inst) const { // clang-format on
+ ZKAPI typename std::enable_if, const DaedalusSymbol*>::
+ type inline find_symbol_by_instance(const std::shared_ptr& inst) const { // clang-format on
return find_symbol_by_index(inst->_m_symbol_index);
}
@@ -846,74 +926,71 @@ namespace phoenix {
/// \return The symbol associated with that instance or nullptr if the symbol is not associated
/// with any instance.
template
- PHOENIX_API
- typename std::enable_if, symbol*>::type inline find_symbol_by_instance(
- const std::shared_ptr& inst) {
+ ZKAPI typename std::enable_if, DaedalusSymbol*>::
+ type inline find_symbol_by_instance(const std::shared_ptr& inst) {
return find_symbol_by_index(inst->_m_symbol_index);
}
- [[nodiscard]] PHOENIX_API std::vector find_class_members(symbol const& cls);
+ [[nodiscard]] ZKAPI std::vector find_class_members(DaedalusSymbol const& cls);
- inline void register_as_opaque(std::string_view class_name) {
+ ZKAPI void register_as_opaque(std::string_view class_name) {
return register_as_opaque(find_symbol_by_name(class_name));
}
- void register_as_opaque(symbol* sym);
+ void register_as_opaque(DaedalusSymbol* sym);
protected:
- PHOENIX_INTERNAL script() = default;
-
template
- symbol* _check_member(std::string_view name, const std::type_info* type) {
+ DaedalusSymbol* _check_member(std::string_view name, const std::type_info* type) {
auto* sym = find_symbol_by_name(name);
if (sym == nullptr)
- throw symbol_not_found {std::string {name}};
+ throw DaedalusSymbolNotFound {std::string {name}};
if (!sym->is_member())
- throw member_registration_error {sym, "not a member"};
+ throw DaedalusMemberRegistrationError {sym, "not a member"};
if (sym->count() > N)
- throw member_registration_error {sym,
- "incorrect number of elements: given " + std::to_string(N) +
- " expected " + std::to_string(sym->count())};
+ throw DaedalusMemberRegistrationError {sym,
+ "incorrect number of elements: given " + std::to_string(N) +
+ " expected " + std::to_string(sym->count())};
// check class registration
auto* parent = find_symbol_by_index(sym->parent());
if (parent == nullptr)
- throw member_registration_error {sym, "no parent found"};
+ throw DaedalusMemberRegistrationError {sym, "no parent found"};
if (parent->_m_registered_to == nullptr) {
parent->_m_registered_to = type;
} else if (parent->_m_registered_to != type) {
- throw member_registration_error {sym,
- "parent class is already registered with a different type (" +
- std::string {parent->_m_registered_to->name()} + ")"};
+ throw DaedalusMemberRegistrationError {sym,
+ "parent class is already registered with a different type (" +
+ std::string {parent->_m_registered_to->name()} + ")"};
}
// check type matches
if constexpr (std::is_same_v) {
- if (sym->type() != datatype::string)
- throw invalid_registration_datatype {sym, "string"};
+ if (sym->type() != DaedalusDataType::STRING)
+ throw DaedalusInvalidRegistrationDataType {sym, "string"};
} else if constexpr (std::is_same_v) {
- if (sym->type() != datatype::float_)
- throw invalid_registration_datatype {sym, "float"};
+ if (sym->type() != DaedalusDataType::FLOAT)
+ throw DaedalusInvalidRegistrationDataType {sym, "float"};
} else if constexpr (std::is_same_v || std::is_enum_v<_member>) {
- if (sym->type() != datatype::integer && sym->type() != datatype::function)
- throw invalid_registration_datatype {sym, "int"};
+ if (sym->type() != DaedalusDataType::INT && sym->type() != DaedalusDataType::FUNCTION)
+ throw DaedalusInvalidRegistrationDataType {sym, "int"};
} else {
- throw invalid_registration_datatype {sym, ""};
+ throw DaedalusInvalidRegistrationDataType {sym, ""};
}
return sym;
}
- PHOENIX_API symbol* add_temporary_strings_symbol();
+ ZKAPI DaedalusSymbol* add_temporary_strings_symbol();
private:
- std::vector _m_symbols;
+ std::vector _m_symbols;
std::unordered_map _m_symbols_by_name;
std::unordered_map _m_symbols_by_address;
- mutable buffer _m_text = buffer::empty();
+ mutable std::unique_ptr _m_text;
std::uint8_t _m_version {0};
};
-} // namespace phoenix
+} // namespace zenkit
diff --git a/include/zenkit/DaedalusVm.hh b/include/zenkit/DaedalusVm.hh
index ed854268..6adb9cc9 100644
--- a/include/zenkit/DaedalusVm.hh
+++ b/include/zenkit/DaedalusVm.hh
@@ -1,109 +1,119 @@
-// Copyright © 2022 Luis Michaelis
+// Copyright © 2021-2023 GothicKit Contributors.
// SPDX-License-Identifier: MIT
#pragma once
-#include "Api.hh"
-#include
+#include "zenkit/DaedalusScript.hh"
+#include "zenkit/Library.hh"
#include
+#include
#include
+#include
#include
#include
-#include
-#include
-#include
+#include
+#include
-namespace phoenix {
- struct _ignore_return_value {};
+namespace zenkit {
+ struct IgnoreReturnValue {};
- struct naked_call {};
+ struct DaedalusNakedCall {};
- struct func {
- symbol* value;
+ struct DaedalusFunction {
+ DaedalusSymbol* value;
};
template
static constexpr bool is_instance_ptr_v = false;
template
- static constexpr bool is_instance_ptr_v> = std::is_base_of_v;
+ static constexpr bool is_instance_ptr_v> = std::is_base_of_v;
template
- static constexpr bool is_raw_instance_ptr_v = std::is_base_of_v>;
+ static constexpr bool is_raw_instance_ptr_v = std::is_base_of_v>;
/// \brief An exception thrown if the definition of an external is incorrect.
- class illegal_external_definition : public script_error {
+ class DaedalusIllegalExternalDefinition : public DaedalusScriptError {
public:
- PHOENIX_API illegal_external_definition(const symbol* sym, std::string&& message);
+ ZKAPI DaedalusIllegalExternalDefinition(const DaedalusSymbol* sym, std::string&& message);
public:
/// \brief The symbol the external is being registered for.
- const symbol* sym;
+ const DaedalusSymbol* sym;
};
/// \brief An exception thrown if the return type of a new external registration does not match
/// the return type defined in the script.
- class illegal_external_rtype : public illegal_external_definition {
+ class DaedalusIllegalExternalReturnType : public DaedalusIllegalExternalDefinition {
public:
- PHOENIX_API illegal_external_rtype(const symbol* sym, std::string&& provided);
+ ZKAPI DaedalusIllegalExternalReturnType(const DaedalusSymbol* sym, std::string&& provided);
};
/// \brief An exception thrown if one of the parameter types of a new external registration does not match
/// the type defined in the script.
- class illegal_external_param : public illegal_external_definition {
+ class DaedalusIllegalExternalParameter : public DaedalusIllegalExternalDefinition {
public:
- PHOENIX_API illegal_external_param(const symbol* sym, std::string&& provided, std::uint8_t i);
+ ZKAPI DaedalusIllegalExternalParameter(const DaedalusSymbol* sym, std::string&& provided, std::uint8_t i);
};
- class vm_exception : public script_error {
- using script_error::script_error;
+ class DaedalusVmException : public DaedalusScriptError {
+ using DaedalusScriptError::DaedalusScriptError;
};
/// \brief An exception handling strategy given by VM exception handlers.
- enum class vm_exception_strategy {
- /// \brief Continue with execution of the script.
- continue_,
-
- /// \brief Return from the current subroutine.
- return_,
-
- /// \brief Re-throw the exception and fail.
- fail_,
+ enum class DaedalusVmExceptionStrategy {
+ CONTINUE = 0, ///< Continue with execution of the script.
+ RETURN = 1, ///< Return from the current subroutine.
+ FAIL = 2, ///< Re-throw the exception and fail.
+
+ // Deprecated entries.
+ continue_ ZKREM("renamed to DaedalusVmExceptionStrategy::CONTINUE") = CONTINUE,
+ return_ ZKREM("renamed to DaedalusVmExceptionStrategy::RETURN") = RETURN,
+ fail_ ZKREM("renamed to DaedalusVmExceptionStrategy::FAIL") = FAIL,
};
/// \brief A stack frame in the VM.
- struct daedalus_stack_frame {
- std::shared_ptr context;
+ struct DaedalusStackFrame {
+ std::shared_ptr context;
bool reference;
- std::variant> value;
+ std::variant> value;
uint16_t index {0};
};
/// \brief A call stack frame in the VM.
- struct daedalus_call_stack_frame {
- const symbol* function;
+ struct DaedalusCallStackFrame {
+ const DaedalusSymbol* function;
std::uint32_t program_counter;
- std::shared_ptr context;
+ std::shared_ptr context;
};
- namespace execution_flag {
- static constexpr std::uint8_t none = 0;
- static constexpr std::uint8_t vm_allow_null_instance_access = 1 << 1;
- static constexpr std::uint8_t vm_ignore_const_specifier = 1 << 2;
- } // namespace execution_flag
+ namespace DaedalusVmExecutionFlag {
+ static constexpr std::uint8_t NONE = 0;
+ static constexpr std::uint8_t ALLOW_NULL_INSTANCE_ACCESS = 1 << 1;
+ static constexpr std::uint8_t IGNORE_CONST_SPECIFIER = 1 << 2;
+
+ // Deprecated entries.
+ ZKREM("renamed to DaedalusVmExecutionFlag::NONE") static constexpr std::uint8_t none = NONE;
+
+ ZKREM("renamed to DaedalusVmExecutionFlag::ALLOW_NULL_INSTANCE_ACCESS")
+ static constexpr std::uint8_t vm_allow_null_instance_access = ALLOW_NULL_INSTANCE_ACCESS;
+
+ ZKREM("renamed to DaedalusVmExecutionFlag::IGNORE_CONST_SPECIFIER")
+ static constexpr std::uint8_t vm_ignore_const_specifier = IGNORE_CONST_SPECIFIER;
+ } // namespace DaedalusVmExecutionFlag
- class vm : public script {
+ class DaedalusVm : public DaedalusScript {
public:
static constexpr auto stack_size = 2048;
- /// \brief Creates a DaedalusVM instance for the given script.
+ /// \brief Creates a DaedalusVM DaedalusInstance for the given script.
/// \param scr The script to load into the VM.
- PHOENIX_API explicit vm(script&& scr, uint8_t flags = execution_flag::none);
+ ZKAPI explicit DaedalusVm(DaedalusScript&& scr, uint8_t flags = DaedalusVmExecutionFlag::NONE);
/// \brief Calls a function by it's name.
/// \tparam P The types for the argument values.
/// \param sym The name of the function to call.
/// \param args The arguments for the function call.
- template
+ template
R call_function(std::string_view name, P... args) {
return call_function(find_symbol_by_name(name), args...);
}
@@ -112,28 +122,28 @@ namespace phoenix {
/// \tparam P The types for the argument values.
/// \param sym The symbol of the function to call.
/// \param args The arguments for the function call.
- template
- R call_function(const symbol* sym, P... args) {
+ template
+ R call_function(const DaedalusSymbol* sym, P... args) {
if (sym == nullptr) {
- throw vm_exception {"Cannot call function: not found"};
+ throw DaedalusVmException {"Cannot call function: not found"};
}
- if (sym->type() != datatype::function) {
- throw vm_exception {"Cannot call " + sym->name() + ": not a function"};
+ if (sym->type() != DaedalusDataType::FUNCTION) {
+ throw DaedalusVmException {"Cannot call " + sym->name() + ": not a function"};
}
- std::vector params = find_parameters_for_function(sym);
+ std::vector params = find_parameters_for_function(sym);
if (params.size() < sizeof...(P)) {
- throw vm_exception {"too many arguments provided for " + sym->name() + ": given " +
- std::to_string(sizeof...(P)) + " expected " + std::to_string(params.size())};
+ throw DaedalusVmException {"too many arguments provided for " + sym->name() + ": given " +
+ std::to_string(sizeof...(P)) + " expected " + std::to_string(params.size())};
}
if (params.size() > sizeof...(P)) {
- throw vm_exception {"not enough arguments provided for " + sym->name() + ": given " +
- std::to_string(sizeof...(P)) + " expected " + std::to_string(params.size())};
+ throw DaedalusVmException {"not enough arguments provided for " + sym->name() + ": given " +
+ std::to_string(sizeof...(P)) + " expected " + std::to_string(params.size())};
}
- if constexpr (!std::is_same_v) {
+ if constexpr (!std::is_same_v) {
check_call_return_type(sym);
}
@@ -141,10 +151,9 @@ namespace phoenix {
push_call_parameters<0, P...>(params, args...);
}
- PX_LOGD("vm: calling function ", sym->name());
unsafe_call(sym);
- if constexpr (std::is_same_v) {
+ if constexpr (std::is_same_v) {
// clear the stack
_m_stack_ptr = 0;
@@ -172,7 +181,7 @@ namespace phoenix {
/// \return The initialized instance.
template
- typename std::enable_if, std::shared_ptr<_instance_t>>::type
+ typename std::enable_if, std::shared_ptr<_instance_t>>::type
init_instance(std::string_view name) {
return init_instance<_instance_t>(find_symbol_by_name(name));
}
@@ -182,7 +191,7 @@ namespace phoenix {
/// \param instance The instance to initialize.
/// \param name The name of the instance to initialize (ie. 'STT_309_WHISTLER')
template
- typename std::enable_if, void>::type
+ typename std::enable_if, void>::type
init_instance(const std::shared_ptr<_instance_t>& instance, std::string_view name) {
init_instance<_instance_t>(instance, find_symbol_by_name(name));
}
@@ -197,23 +206,21 @@ namespace phoenix {
/// \return The initialized instance.
template
- typename std::enable_if, std::shared_ptr<_instance_t>>::type
- init_instance(symbol* sym) {
+ typename std::enable_if, std::shared_ptr<_instance_t>>::type
+ init_instance(DaedalusSymbol* sym) {
// create the instance
auto inst = std::make_shared<_instance_t>();
init_instance(inst, sym);
return inst;
}
- std::shared_ptr init_opaque_instance(symbol* sym);
-
/// \brief Initializes an instance with the given type into \p instance
/// \tparam _instance_t The type of the instance to initialize (ie. C_NPC).
/// \param instance The instance to initialize.
/// \param sym The symbol to initialize.
template
- typename std::enable_if, void>::type
- init_instance(const std::shared_ptr<_instance_t>& instance, symbol* sym) {
+ typename std::enable_if, void>::type
+ init_instance(const std::shared_ptr<_instance_t>& instance, DaedalusSymbol* sym) {
// Perform initial instance setup
this->allocate_instance(instance, sym);
@@ -233,6 +240,8 @@ namespace phoenix {
_m_self_sym->set_instance(old_self_instance);
}
+ std::shared_ptr init_opaque_instance(DaedalusSymbol* sym);
+
/// \brief Allocates an instance with the given type and name and returns it.
///
/// In contrast to #init_instance, this function will only create an instance of _instance_t and assign
@@ -242,8 +251,7 @@ namespace phoenix {
/// \param name The name of the instance to initialize (ie. 'STT_309_WHISTLER')
/// \return The initialized instance.
template
-
- typename std::enable_if, std::shared_ptr<_instance_t>>::type
+ typename std::enable_if, std::shared_ptr<_instance_t>>::type
allocate_instance(std::string_view name) {
return allocate_instance<_instance_t>(find_symbol_by_name(name));
}
@@ -257,7 +265,7 @@ namespace phoenix {
/// \param instance The instance to initialize.
/// \param name The name of the instance to initialize (ie. 'STT_309_WHISTLER')
template
- typename std::enable_if, void>::type
+ typename std::enable_if, void>::type
allocate_instance(const std::shared_ptr<_instance_t>& instance, std::string_view name) {
allocate_instance<_instance_t>(instance, find_symbol_by_name(name));
}
@@ -272,8 +280,8 @@ namespace phoenix {
/// \return The initialized instance.
template
- typename std::enable_if, std::shared_ptr<_instance_t>>::type
- allocate_instance(symbol* sym) {
+ typename std::enable_if, std::shared_ptr<_instance_t>>::type
+ allocate_instance(DaedalusSymbol* sym) {
// create the instance
auto inst = std::make_shared<_instance_t>();
allocate_instance(inst, sym);
@@ -289,13 +297,13 @@ namespace phoenix {
/// \param instance The instance to initialize.
/// \param sym The symbol to initialize.
template
- typename std::enable_if, void>::type
- allocate_instance(const std::shared_ptr<_instance_t>& instance, symbol* sym) {
+ typename std::enable_if, void>::type
+ allocate_instance(const std::shared_ptr<_instance_t>& instance, DaedalusSymbol* sym) {
if (sym == nullptr) {
- throw vm_exception {"Cannot init instance: not found"};
+ throw DaedalusVmException {"Cannot init instance: not found"};
}
- if (sym->type() != datatype::instance) {
- throw vm_exception {"Cannot init " + sym->name() + ": not an instance"};
+ if (sym->type() != DaedalusDataType::INSTANCE) {
+ throw DaedalusVmException {"Cannot init " + sym->name() + ": not an instance"};
}
// check that the parent class is registered for the given instance type
@@ -303,38 +311,37 @@ namespace phoenix {
if (parent == nullptr) {
// We're probably trying to initialize $INSTANCE_HELP which is not permitted
- throw vm_exception {"Cannot init " + sym->name() +
- ": parent class not found (did you try to initialize $INSTANCE_HELP?)"};
+ throw DaedalusVmException {"Cannot init " + sym->name() +
+ ": parent class not found (did you try to initialize $INSTANCE_HELP?)"};
}
- while (parent->type() != datatype::class_) {
+ while (parent->type() != DaedalusDataType::CLASS) {
parent = find_symbol_by_index(parent->parent());
}
if (parent->registered_to() != typeid(_instance_t)) {
- throw vm_exception {"Cannot init " + sym->name() +
- ": parent class is not registered or is "
- "registered to a different instance class"};
+ throw DaedalusVmException {"Cannot init " + sym->name() +
+ ": parent class is not registered or is "
+ "registered to a different instance class"};
}
- PX_LOGD("vm: initializing instance ", sym->name());
-
instance->_m_symbol_index = sym->index();
instance->_m_type = &typeid(_instance_t);
sym->set_instance(instance);
}
- PHOENIX_API void push_int(std::int32_t value);
- PHOENIX_API void push_float(float value);
- PHOENIX_API void push_instance(std::shared_ptr value);
- PHOENIX_API void push_reference(symbol* value, std::uint8_t index = 0);
- PHOENIX_API void push_string(std::string_view value);
+ ZKAPI void push_int(std::int32_t value);
+ ZKAPI void push_float(float value);
+ ZKAPI void push_instance(std::shared_ptr value);
+ ZKAPI void push_reference(DaedalusSymbol* value, std::uint8_t index = 0);
+ ZKAPI void push_string(std::string_view value);
- [[nodiscard]] PHOENIX_API std::int32_t pop_int();
- [[nodiscard]] PHOENIX_API float pop_float();
- [[nodiscard]] PHOENIX_API std::shared_ptr pop_instance();
- [[nodiscard]] PHOENIX_API const std::string& pop_string();
- [[nodiscard]] PHOENIX_API std::tuple> pop_reference();
+ [[nodiscard]] ZKAPI std::int32_t pop_int();
+ [[nodiscard]] ZKAPI float pop_float();
+ [[nodiscard]] ZKAPI std::shared_ptr pop_instance();
+ [[nodiscard]] ZKAPI const std::string& pop_string();
+ [[nodiscard]] ZKAPI std::tuple>
+ pop_reference();
/// \brief Registers a Daedalus external function.
///
@@ -403,16 +410,16 @@ namespace phoenix {
///
///
///
- /// [1] instances in the C++-World have to inherit from phoenix::instance.
+ /// [1] instances in the C++-World have to inherit from phoenix::DaedalusInstance.
///
///
/// \tparam R The return type of the external.
/// \tparam P The parameters types of the external.
/// \param name The name of the external to register.
/// \param callback The C++ function to register as the external.
- /// \throws illegal_external_rtype if the return type of the C++ function does not match it's
+ /// \throws DaedalusIllegalExternalReturnType if the return type of the C++ function does not match it's
/// definition in the script.
- /// \throws illegal_external_param if a parameter type of the C++ function does not match it's
+ /// \throws DaedalusIllegalExternalParameter if a parameter type of the C++ function does not match it's
/// definition in the script.
/// \throws illegal_external if The number of parameters of the definition and callback is not the same.
/// \throws runtime_error if any other error occurs.
@@ -423,50 +430,50 @@ namespace phoenix {
return;
if (!sym->is_external())
- throw vm_exception {"symbol is not external"};
+ throw DaedalusVmException {"symbol is not external"};
if constexpr (!std::is_same_v) {
if (!sym->has_return())
- throw illegal_external_rtype(sym, "");
+ throw DaedalusIllegalExternalReturnType(sym, "");
if constexpr (is_instance_ptr_v) {
- if (sym->rtype() != datatype::instance)
- throw illegal_external_rtype(sym, "instance");
+ if (sym->rtype() != DaedalusDataType::INSTANCE)
+ throw DaedalusIllegalExternalReturnType(sym, "instance");
} else if constexpr (std::is_floating_point_v) {
- if (sym->rtype() != datatype::float_)
- throw illegal_external_rtype(sym, "float");
+ if (sym->rtype() != DaedalusDataType::FLOAT)
+ throw DaedalusIllegalExternalReturnType(sym, "float");
} else if constexpr (std::is_convertible_v) {
- if (sym->rtype() != datatype::integer)
- throw illegal_external_rtype(sym, "int");
+ if (sym->rtype() != DaedalusDataType::INT)
+ throw DaedalusIllegalExternalReturnType(sym, "int");
} else if constexpr (std::is_convertible_v) {
- if (sym->rtype() != datatype::string)
- throw illegal_external_rtype(sym, "string");
+ if (sym->rtype() != DaedalusDataType::STRING)
+ throw DaedalusIllegalExternalReturnType(sym, "string");
} else {
- throw vm_exception {"unsupported return type"};
+ throw DaedalusVmException {"unsupported return type"};
}
} else {
if (sym->has_return())
- throw illegal_external_rtype(sym, "void");
+ throw DaedalusIllegalExternalReturnType(sym, "void");
}
- std::vector params = find_parameters_for_function(sym);
+ std::vector params = find_parameters_for_function(sym);
if (params.size() < sizeof...(P))
- throw illegal_external_definition {sym,
- "too many arguments declared for external " + sym->name() +
- ": declared " + std::to_string(sizeof...(P)) + " expected " +
- std::to_string(params.size())};
+ throw DaedalusIllegalExternalDefinition {sym,
+ "too many arguments declared for external " + sym->name() +
+ ": declared " + std::to_string(sizeof...(P)) +
+ " expected " + std::to_string(params.size())};
if (params.size() > sizeof...(P))
- throw illegal_external_definition {sym,
- "not enough arguments declared for external " + sym->name() +
- ": declared " + std::to_string(sizeof...(P)) + " expected " +
- std::to_string(params.size())};
+ throw DaedalusIllegalExternalDefinition {sym,
+ "not enough arguments declared for external " + sym->name() +
+ ": declared " + std::to_string(sizeof...(P)) +
+ " expected " + std::to_string(params.size())};
if constexpr (sizeof...(P) > 0) {
check_external_params<0, P...>(params);
}
// *evil template hacking ensues*
- _m_externals[sym] = [callback](vm& machine) {
+ _m_externals[sym] = [callback](DaedalusVm& machine) {
if constexpr (std::is_same_v) {
if constexpr (sizeof...(P) > 0) {
auto v = machine.pop_values_for_external();
@@ -482,8 +489,6 @@ namespace phoenix {
}
}
};
-
- PX_LOGD("vm: registered external for ", sym->name());
}
/// \brief Registers an external function.
@@ -516,52 +521,52 @@ namespace phoenix {
void override_function(std::string_view name, const std::function& callback) {
auto* sym = find_symbol_by_name(name);
if (sym == nullptr)
- throw vm_exception {"symbol not found"};
+ throw DaedalusVmException {"symbol not found"};
if (sym->is_external())
- throw vm_exception {"symbol is already an external"};
+ throw DaedalusVmException {"symbol is already an external"};
if constexpr (!std::is_same_v) {
if (!sym->has_return())
- throw illegal_external_rtype(sym, "");
+ throw DaedalusIllegalExternalReturnType(sym, "");
if constexpr (is_instance_ptr_v) {
- if (sym->rtype() != datatype::instance)
- throw illegal_external_rtype(sym, "instance");
+ if (sym->rtype() != DaedalusDataType::INSTANCE)
+ throw DaedalusIllegalExternalReturnType(sym, "instance");
} else if constexpr (std::is_floating_point_v) {
- if (sym->rtype() != datatype::float_)
- throw illegal_external_rtype(sym, "float");
+ if (sym->rtype() != DaedalusDataType::FLOAT)
+ throw DaedalusIllegalExternalReturnType(sym, "float");
} else if constexpr (std::is_convertible_v) {
- if (sym->rtype() != datatype::integer)
- throw illegal_external_rtype(sym, "int");
+ if (sym->rtype() != DaedalusDataType::INT)
+ throw DaedalusIllegalExternalReturnType(sym, "int");
} else if constexpr (std::is_convertible_v) {
- if (sym->rtype() != datatype::string)
- throw illegal_external_rtype(sym, "string");
+ if (sym->rtype() != DaedalusDataType::STRING)
+ throw DaedalusIllegalExternalReturnType(sym, "string");
} else {
- throw vm_exception {"unsupported return type"};
+ throw DaedalusVmException {"unsupported return type"};
}
} else {
if (sym->has_return())
- throw illegal_external_rtype(sym, "void");
+ throw DaedalusIllegalExternalReturnType(sym, "void");
}
- std::vector params = find_parameters_for_function(sym);
+ std::vector params = find_parameters_for_function(sym);
if (params.size() < sizeof...(P))
- throw illegal_external_definition {sym,
- "too many arguments declared for function override " + sym->name() +
- ": declared " + std::to_string(sizeof...(P)) + " expected " +
- std::to_string(params.size())};
+ throw DaedalusIllegalExternalDefinition {
+ sym,
+ "too many arguments declared for function override " + sym->name() + ": declared " +
+ std::to_string(sizeof...(P)) + " expected " + std::to_string(params.size())};
if (params.size() > sizeof...(P))
- throw illegal_external_definition {sym,
- "not enough arguments declared for function override " +
- sym->name() + ": declared " + std::to_string(sizeof...(P)) +
- " expected " + std::to_string(params.size())};
+ throw DaedalusIllegalExternalDefinition {
+ sym,
+ "not enough arguments declared for function override " + sym->name() + ": declared " +
+ std::to_string(sizeof...(P)) + " expected " + std::to_string(params.size())};
if constexpr (sizeof...(P) > 0) {
check_external_params<0, P...>(params);
}
// *evil template hacking ensues*
- _m_function_overrides[sym->address()] = [callback, sym](vm& machine) {
+ _m_function_overrides[sym->address()] = [callback, sym](DaedalusVm& machine) {
machine.push_call(sym);
if constexpr (std::is_same_v) {
if constexpr (sizeof...(P) > 0) {
@@ -579,8 +584,6 @@ namespace phoenix {
}
machine.pop_call();
};
-
- PX_LOGD("vm: overrode function ", sym->name());
}
/// \brief Overrides a function in Daedalus code with an external naked call.
@@ -590,18 +593,16 @@ namespace phoenix {
///
/// \param name The name of the function to override.
/// \param callback The C++ function to register as the external.
- void override_function(std::string_view name, const std::function& callback) {
+ void override_function(std::string_view name, const std::function& callback) {
auto* sym = find_symbol_by_name(name);
if (sym == nullptr)
- throw vm_exception {"symbol not found"};
+ throw DaedalusVmException {"symbol not found"};
if (sym->is_external())
- throw vm_exception {"symbol is already an external"};
+ throw DaedalusVmException {"symbol is already an external"};
- _m_function_overrides[sym->address()] = [callback](vm& machine) {
+ _m_function_overrides[sym->address()] = [callback](DaedalusVm& machine) {
callback(machine);
};
-
- PX_LOGD("vm: overrode function ", sym->name());
}
/// \brief Overrides a function in Daedalus code with an external definition.
@@ -627,11 +628,11 @@ namespace phoenix {
///
/// \param callback The function to call. The one parameter of the function is the name of the unresolved
/// external.
- PHOENIX_API void register_default_external(const std::function& callback);
+ ZKAPI void register_default_external(const std::function& callback);
- PHOENIX_API void register_default_external_custom(const std::function& callback);
+ ZKAPI void register_default_external_custom(const std::function& callback);
- PHOENIX_API void register_access_trap(const std::function& callback);
+ ZKAPI void register_access_trap(const std::function& callback);
/// \brief Registers a function to be called when script execution fails.
///
@@ -642,8 +643,10 @@ namespace phoenix {
/// If the function returns `true` the error is assumed to have been handled and execution will
/// continue as normal. If `false` is returned, the VM will re-raise the exception and thus,
/// halt execution.
- PHOENIX_API void register_exception_handler(
- const std::function& callback);
+ ZKAPI void register_exception_handler(
+ const std::function& callback);
/// \brief Calls the given symbol as a function.
///
@@ -651,51 +654,69 @@ namespace phoenix {
/// the caller is required to deal with them appropriately.
///
/// \param sym The symbol to unsafe_call.
- PHOENIX_API void unsafe_call(const symbol* sym);
+ ZKAPI void unsafe_call(const DaedalusSymbol* sym);
- PHOENIX_API void unsafe_jump(uint32_t address);
+ ZKAPI void unsafe_jump(uint32_t address);
/// \return the symbol referring to the global var C_NPC self.
- PHOENIX_API inline symbol* global_self() {
+ ZKAPI inline DaedalusSymbol* global_self() {
return _m_self_sym;
}
/// \return the symbol referring to the global var C_NPC other.
- PHOENIX_API inline symbol* global_other() {
+ ZKAPI inline DaedalusSymbol* global_other() {
return _m_other_sym;
}
/// \return the symbol referring to the global var C_NPC victim.
- PHOENIX_API inline symbol* global_victim() {
+ ZKAPI inline DaedalusSymbol* global_victim() {
return _m_victim_sym;
}
/// \return the symbol referring to the global var C_NPC hero.
- PHOENIX_API inline symbol* global_hero() {
+ ZKAPI inline DaedalusSymbol* global_hero() {
return _m_hero_sym;
}
/// \return the symbol referring to the global var C_NPC item.
- PHOENIX_API inline symbol* global_item() {
+ ZKAPI inline DaedalusSymbol* global_item() {
return _m_item_sym;
}
/// \brief Prints the contents of the function call stack and the VMs stack to stderr.
- PHOENIX_API void print_stack_trace() const;
+ ZKAPI void print_stack_trace() const;
/// \return The current program counter (or instruction index) the VM is at.
- [[nodiscard]] PHOENIX_API inline uint32_t pc() const noexcept {
+ [[nodiscard]] ZKAPI inline uint32_t pc() const noexcept {
return _m_pc;
}
+ [[nodiscard]] ZKAPI std::int32_t
+ get_int(std::shared_ptr& context,
+ std::variant>& value,
+ uint16_t index);
+ [[nodiscard]] ZKAPI float
+ get_float(std::shared_ptr& context,
+ std::variant>& value,
+ uint16_t index);
+
+ ZKAPI void
+ set_int(std::shared_ptr& context, DaedalusSymbol* ref, uint16_t index, std::int32_t value);
+ ZKAPI void
+ set_float(std::shared_ptr& context, DaedalusSymbol* ref, uint16_t index, float value);
+ ZKAPI void set_string(std::shared_ptr& context,
+ DaedalusSymbol* ref,
+ uint16_t index,
+ std::string_view value);
+
protected:
/// \brief Runs the instruction at the current program counter and advances it properly.
/// \return false, the instruction executed was a op_return instruction, otherwise true.
- PHOENIX_INTERNAL bool exec();
+ ZKINT bool exec();
/// \brief Validates the given address and jumps to it (sets the program counter).
/// \param address The address to jump to.
- PHOENIX_INTERNAL void jump(std::uint32_t address);
+ ZKINT void jump(std::uint32_t address);
/// \brief Pushes a call stack frame onto the call stack.
///
@@ -703,13 +724,13 @@ namespace phoenix {
/// as #pop_call is invoked.
///
/// \param sym The symbol referring to the function called.
- PHOENIX_INTERNAL void push_call(const symbol* sym);
+ ZKINT void push_call(const DaedalusSymbol* sym);
/// \brief Pops a call stack from from the call stack.
///
/// This method restores the interpreter's state to before the function which the
/// call stack entry refers to was called.
- PHOENIX_INTERNAL void pop_call();
+ ZKINT void pop_call();
/// \brief Checks that the type of each symbol in the given set of defined symbols matches the given type
/// parameters.
@@ -722,22 +743,23 @@ namespace phoenix {
/// \tparam P A type
/// \tparam Px more types.
/// \param defined A list of symbols to check the types P and then P... against.
- /// \throws illegal_external_param If the types don't match.
+ /// \throws DaedalusIllegalExternalParameter If the types don't match.
/// \note Requires that sizeof...(Px) + 1 == defined.size().
template
- void check_external_params(const std::vector& defined) {
- if constexpr (is_instance_ptr_v || std::is_same_v || is_raw_instance_ptr_v) {
- if (defined[i]->type() != datatype::instance)
- throw illegal_external_param(defined[i], "instance", i + 1);
+ void check_external_params(const std::vector& defined) {
+ if constexpr (is_instance_ptr_v || std::is_same_v || is_raw_instance_ptr_v) {
+ if (defined[i]->type() != DaedalusDataType::INSTANCE)
+ throw DaedalusIllegalExternalParameter(defined[i], "instance", i + 1);
} else if constexpr (std::is_same_v) {
- if (defined[i]->type() != datatype::float_)
- throw illegal_external_param(defined[i], "float", i + 1);
- } else if constexpr (std::is_same_v || std::is_same_v || std::is_same_v) {
- if (defined[i]->type() != datatype::integer && defined[i]->type() != datatype::function)
- throw illegal_external_param(defined[i], "int/func", i + 1);
+ if (defined[i]->type() != DaedalusDataType::FLOAT)
+ throw DaedalusIllegalExternalParameter(defined[i], "float", i + 1);
+ } else if constexpr (std::is_same_v || std::is_same_v ||
+ std::is_same_v) {
+ if (defined[i]->type() != DaedalusDataType::INT && defined[i]->type() != DaedalusDataType::FUNCTION)
+ throw DaedalusIllegalExternalParameter(defined[i], "int/func", i + 1);
} else if constexpr (std::is_same_v) {
- if (defined[i]->type() != datatype::string)
- throw illegal_external_param(defined[i], "string", i + 1);
+ if (defined[i]->type() != DaedalusDataType::STRING)
+ throw DaedalusIllegalExternalParameter(defined[i], "string", i + 1);
}
if constexpr (sizeof...(Px) > 0) {
@@ -750,29 +772,30 @@ namespace phoenix {
/// This is only used by #pop_values_for_external for now as it does checks related to external
/// functions. It is not recommended to use this function for anything else.
///
- /// \tparam T The type of the value to pop (one of std::shared_ptr extends instance>, float, int32_t,
- /// symbol*, std::string_view)
+ /// \tparam T The type of the value to pop (one of std::shared_ptr extends DaedalusInstance>, float, int32_t,
+ /// DaedalusSymbol*, std::string_view)
/// \return The value popped.
template
typename std::enable_if || std::is_same_v || std::is_same_v ||
std::is_same_v || std::is_same_v ||
- std::is_same_v || is_raw_instance_ptr_v || std::is_same_v,
+ std::is_same_v || is_raw_instance_ptr_v ||
+ std::is_same_v,
T>::type
pop_value_for_external() {
if constexpr (is_instance_ptr_v) {
auto r = pop_instance();
- if (r != nullptr && !std::is_same_v>) {
+ if (r != nullptr && !std::is_same_v>) {
auto& expected = typeid(typename T::element_type);
if (!r->_m_type) {
- throw vm_exception {"Popping instance of unregistered type: " +
- std::string {r->_m_type->name()} + ", expected " + expected.name()};
+ throw DaedalusVmException {"Popping instance of unregistered type: " +
+ std::string {r->_m_type->name()} + ", expected " + expected.name()};
}
if (*r->_m_type != expected) {
- throw vm_exception {"Popping instance of wrong type: " + std::string {r->_m_type->name()} +
- ", expected " + expected.name()};
+ throw DaedalusVmException {"Popping instance of wrong type: " +
+ std::string {r->_m_type->name()} + ", expected " + expected.name()};
}
}
@@ -780,17 +803,17 @@ namespace phoenix {
} else if constexpr (is_raw_instance_ptr_v) {
auto r = pop_instance();
- if (r != nullptr && !std::is_same_v) {
+ if (r != nullptr && !std::is_same_v) {
auto& expected = typeid(typename std::remove_pointer_t);
if (!r->_m_type) {
- throw vm_exception {"Popping instance of unregistered type: " +
- std::string {r->_m_type->name()} + ", expected " + expected.name()};
+ throw DaedalusVmException {"Popping instance of unregistered type: " +
+ std::string {r->_m_type->name()} + ", expected " + expected.name()};
}
if (*r->_m_type != expected) {
- throw vm_exception {"Popping instance of wrong type: " + std::string {r->_m_type->name()} +
- ", expected " + expected.name()};
+ throw DaedalusVmException {"Popping instance of wrong type: " +
+ std::string {r->_m_type->name()} + ", expected " + expected.name()};
}
}
@@ -803,26 +826,24 @@ namespace phoenix {
return pop_int() != 0;
} else if constexpr (std::is_same_v) {
return pop_string();
- } else if constexpr (std::is_same_v) {
+ } else if constexpr (std::is_same_v) {
return std::get<0>(pop_reference());
- } else if constexpr (std::is_same_v) {
+ } else if constexpr (std::is_same_v) {
auto symbol_id = static_cast(pop_int());
auto* sym = find_symbol_by_index(symbol_id);
- while (sym != nullptr && sym->type() == datatype::function && !sym->is_const()) {
+ while (sym != nullptr && sym->type() == DaedalusDataType::FUNCTION && !sym->is_const()) {
symbol_id = static_cast(sym->get_int());
sym = find_symbol_by_index(symbol_id);
}
- if (sym != nullptr && sym->type() != datatype::function) {
- PX_LOGW("Failed to resolve external function parameter (func): Reference chain leads to a "
- "non-function symbol!");
- return func {nullptr};
+ if (sym != nullptr && sym->type() != DaedalusDataType::FUNCTION) {
+ return DaedalusFunction {nullptr};
}
- return func {sym};
+ return DaedalusFunction {sym};
} else {
- throw vm_exception {"pop: unsupported stack frame type"};
+ throw DaedalusVmException {"pop: unsupported stack frame type"};
}
}
@@ -836,21 +857,21 @@ namespace phoenix {
template
typename std::enable_if || std::is_convertible_v ||
std::is_convertible_v || std::is_same_v ||
- std::is_same_v || std::is_same_v,
+ std::is_same_v