From f791b3602321513ecbe827d68b74a49286419f7e Mon Sep 17 00:00:00 2001 From: willvale <66674079+willvale@users.noreply.github.com> Date: Sat, 8 Nov 2025 00:27:07 +1300 Subject: [PATCH 1/8] Small config changes to build without STL and Unreal --- inkcpp/include/runner.h | 2 ++ inkcpp/include/story_ptr.h | 7 +++---- inkcpp/include/traits.h | 21 +++++++++++++++++++-- inkcpp/list_table.h | 4 ++-- inkcpp/runner_impl.cpp | 8 ++++++-- inkcpp/runner_impl.h | 2 ++ shared/public/config.h | 14 ++++++++++++++ shared/public/system.h | 18 +++++++++++++++++- 8 files changed, 65 insertions(+), 11 deletions(-) diff --git a/inkcpp/include/runner.h b/inkcpp/include/runner.h index 68400d49..64bbb780 100644 --- a/inkcpp/include/runner.h +++ b/inkcpp/include/runner.h @@ -95,6 +95,7 @@ class runner_interface */ virtual snapshot* create_snapshot() const = 0; +#ifndef INK_ENABLE_CSTD /** * Execute the next line of the script. * @@ -114,6 +115,7 @@ class runner_interface * @return string with the next line of output */ virtual line_type getall() = 0; +#endif #ifdef INK_ENABLE_STL /** diff --git a/inkcpp/include/story_ptr.h b/inkcpp/include/story_ptr.h index ad4b4290..44c12c98 100644 --- a/inkcpp/include/story_ptr.h +++ b/inkcpp/include/story_ptr.h @@ -143,11 +143,10 @@ class story_ptr : public internal::story_ptr_base story_ptr cast() { // if cast fails, return null -#ifdef INK_ENABLE_UNREAL - // Unreal disables RTTI - U* casted = reinterpret_cast(_ptr); -#else +#ifdef INK_ENABLE_RTTI U* casted = dynamic_cast(_ptr); +#else + U* casted = reinterpret_cast(_ptr); #endif if (casted == nullptr) return nullptr; diff --git a/inkcpp/include/traits.h b/inkcpp/include/traits.h index e119a640..bb0de3b2 100644 --- a/inkcpp/include/traits.h +++ b/inkcpp/include/traits.h @@ -101,9 +101,26 @@ struct remove_cv { typedef T type; }; +template +struct remove_reference { + typedef T type; +}; + +template +struct remove_reference { + typedef T type; +}; + +template +struct remove_reference +{ + typedef T type; +}; + template -struct remove_cvref { - typedef std::remove_cv_t> type; +struct remove_cvref +{ + typedef remove_cv>::type; }; // == string testing (from me) == diff --git a/inkcpp/list_table.h b/inkcpp/list_table.h index 7abcca39..ded1993d 100644 --- a/inkcpp/list_table.h +++ b/inkcpp/list_table.h @@ -264,13 +264,13 @@ class list_table : public snapshot_interface const data_t* getPtr(int eid) const { return _data.begin() - + static_cast(_entrySize) * static_cast(eid); + + static_cast(_entrySize) * static_cast(eid); } data_t* getPtr(int eid) { return _data.begin() - + static_cast(_entrySize) * static_cast(eid); + + static_cast(_entrySize) * static_cast(eid); } int numFlags() const diff --git a/inkcpp/runner_impl.cpp b/inkcpp/runner_impl.cpp index 05ab406b..1ab2c914 100644 --- a/inkcpp/runner_impl.cpp +++ b/inkcpp/runner_impl.cpp @@ -505,6 +505,8 @@ runner_impl::~runner_impl() } } +#ifndef INK_ENABLE_CSTD + runner_impl::line_type runner_impl::getline() { // Advance interpreter one line and write to output @@ -545,6 +547,8 @@ runner_impl::line_type runner_impl::getall() return result; } +#endif + #ifdef INK_ENABLE_STL void runner_impl::getline(std::ostream& out) { out << getline(); } @@ -864,7 +868,7 @@ bool runner_impl::line_step() void runner_impl::step() { -#ifndef INK_ENABLE_UNREAL +#ifdef INK_ENABLE_EH try #endif { @@ -1496,7 +1500,7 @@ void runner_impl::step() } #endif } -#ifndef INK_ENABLE_UNREAL +#ifdef INK_ENABLE_EH catch (...) { // Reset our whole state as it's probably corrupt reset(); diff --git a/inkcpp/runner_impl.h b/inkcpp/runner_impl.h index 26f4e44a..8e119929 100644 --- a/inkcpp/runner_impl.h +++ b/inkcpp/runner_impl.h @@ -132,11 +132,13 @@ class runner_impl // move to path virtual bool move_to(hash_t path) override; +#ifndef INK_ENABLE_CSTD // Gets a single line of output virtual line_type getline() override; // get all into string virtual line_type getall() override; +#endif #ifdef INK_ENABLE_STL // Reads a line into a std::ostream diff --git a/shared/public/config.h b/shared/public/config.h index 4bb0877f..d0c164e1 100644 --- a/shared/public/config.h +++ b/shared/public/config.h @@ -7,7 +7,13 @@ #pragma once #ifdef INKCPP_API +#ifndef INKCPP_NO_UNREAL # define INK_ENABLE_UNREAL +# define INKCPP_NO_EH +# define INKCPP_NO_RTTI +#else +# define INK_ENABLE_CSTD +#endif #elif INKCPP_BUILD_CLIB # define INK_ENABLE_CSTD #else @@ -15,6 +21,14 @@ # define INK_ENABLE_CSTD #endif +#ifndef INKCPP_NO_EH +#define INK_ENABLE_EH +#endif + +#ifndef INKCPP_NO_RTTI +#define INK_ENABLE_RTTI +#endif + // Only turn on if you have json.hpp and you want to use it with the compiler // #define INK_EXPOSE_JSON diff --git a/shared/public/system.h b/shared/public/system.h index 5047a971..23f5fffd 100644 --- a/shared/public/system.h +++ b/shared/public/system.h @@ -13,7 +13,6 @@ # include "Misc/CString.h" # include "HAL/UnrealMemory.h" # include "Hash/CityHash.h" - #endif #ifdef INK_ENABLE_STL # include @@ -24,6 +23,9 @@ # include # include #endif +#ifdef INK_ENABLE_CSTD +# include +#endif // Platform specific defines // @@ -46,6 +48,20 @@ namespace ink */ typedef unsigned int uint32_t; +#ifndef INK_ENABLE_STL + +/** Additional signed integer types */ +typedef int int32_t; +typedef short int16_t; + +/** Additional unsigned integer types */ +typedef unsigned long long uint64_t; +typedef unsigned short uint16_t; +typedef long long ptrdiff_t; +#else +typedef std::ptrdiff_t ptrdiff_t; +#endif // ndef INK_ENABLE_STL + /** Name hash (used for temporary variables) */ typedef uint32_t hash_t; From 8645d012c07f6739e069f87482d8d295e01c6835 Mon Sep 17 00:00:00 2001 From: willvale <66674079+willvale@users.noreply.github.com> Date: Sat, 8 Nov 2025 20:09:50 +1300 Subject: [PATCH 2/8] Fix optional::emplace(), which wasn't marking the newly-constructed value as present. Replace unchecked access to _value with checked access for the various operators. --- shared/public/system.h | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/shared/public/system.h b/shared/public/system.h index 23f5fffd..89e8e318 100644 --- a/shared/public/system.h +++ b/shared/public/system.h @@ -285,13 +285,13 @@ class optional { } - const T& operator*() const { return _value; } + const T& operator*() const { return value(); } - T& operator*() { return _value; } + T& operator*() { return value(); } - const T* operator->() const { return &_value; } + const T* operator->() const { return &value(); } - T* operator->() { return &_value; } + T* operator->() { return &value(); } constexpr bool has_value() const { return _has_value; } @@ -318,8 +318,12 @@ class optional template T& emplace(Args... args) { - _value.~T(); - return *(new (&_value) T(args...)); + if (_has_value) + _value.~T(); + + new (&_value) T(args...); + _has_value = true; + return _value; } private: From 00509f57c408d2bbb686e1abaec19fe4f01d3c3a Mon Sep 17 00:00:00 2001 From: willvale <66674079+willvale@users.noreply.github.com> Date: Mon, 10 Nov 2025 20:43:16 +1300 Subject: [PATCH 3/8] Verify sized types And define ptrdiff_t using decltype so it works for 32b and 64b arch. --- inkcpp/include/runner.h | 18 ++++++++---------- shared/public/system.h | 15 ++++++++++++--- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/inkcpp/include/runner.h b/inkcpp/include/runner.h index 64bbb780..d765ac24 100644 --- a/inkcpp/include/runner.h +++ b/inkcpp/include/runner.h @@ -76,6 +76,13 @@ class runner_interface */ virtual bool can_continue() const = 0; + /** + * @brief creates a snapshot containing the runner, globals and all other runners connected to the + * globals. + * @sa story::new_runner_from_snapshot, story::new_globals_from_snapshot + */ + virtual snapshot* create_snapshot() const = 0; + #ifdef INK_ENABLE_CSTD /** * Continue execution until the next newline, then allocate a c-style @@ -86,16 +93,7 @@ class runner_interface * @return allocated c-style string with the output of a single line of execution */ virtual const char* getline_alloc() = 0; -#endif - - /** - * @brief creates a snapshot containing the runner, globals and all other runners connected to the - * globals. - * @sa story::new_runner_from_snapshot, story::new_globals_from_snapshot - */ - virtual snapshot* create_snapshot() const = 0; - -#ifndef INK_ENABLE_CSTD +#else /** * Execute the next line of the script. * diff --git a/shared/public/system.h b/shared/public/system.h index 89e8e318..7a01a8c7 100644 --- a/shared/public/system.h +++ b/shared/public/system.h @@ -57,9 +57,6 @@ typedef short int16_t; /** Additional unsigned integer types */ typedef unsigned long long uint64_t; typedef unsigned short uint16_t; -typedef long long ptrdiff_t; -#else -typedef std::ptrdiff_t ptrdiff_t; #endif // ndef INK_ENABLE_STL /** Name hash (used for temporary variables) */ @@ -81,6 +78,18 @@ hash_t hash_string(const char* string); /** Byte type */ typedef unsigned char byte_t; +/** Ptr difference type */ +typedef decltype(static_cast(nullptr) - static_cast(nullptr)) ptrdiff_t; + +/** Verify sizes */ +static_assert(sizeof(byte_t) == 1); +static_assert(sizeof(uint16_t) == 2); +static_assert(sizeof(int16_t) == 2); +static_assert(sizeof(uint32_t) == 4); +static_assert(sizeof(int32_t) == 4); +static_assert(sizeof(uint64_t) == 8); +static_assert(sizeof(ptrdiff_t) == sizeof(void*)); + /** Used to identify an offset in a data table (like a string in the string table) */ typedef uint32_t offset_t; From 6a44a0a36ec8a859b52862043594609da8c7b5a7 Mon Sep 17 00:00:00 2001 From: Will Vale <66674079+willvale@users.noreply.github.com> Date: Wed, 19 Nov 2025 13:02:59 +1300 Subject: [PATCH 4/8] Allow manual workflow dispatch. --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1c7b7cae..a6b6b6f3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,6 +4,7 @@ on: branches: - master pull_request: + workflow_dispatch: env: BUILD_TYPE: release From b4f47e08b9300f0e607dcb4b70e7b473aaf7bc14 Mon Sep 17 00:00:00 2001 From: willvale <66674079+willvale@users.noreply.github.com> Date: Wed, 19 Nov 2025 14:28:17 +1300 Subject: [PATCH 5/8] Fix traits for ubuntu? --- inkcpp/include/traits.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inkcpp/include/traits.h b/inkcpp/include/traits.h index bb0de3b2..38f2afee 100644 --- a/inkcpp/include/traits.h +++ b/inkcpp/include/traits.h @@ -120,7 +120,7 @@ struct remove_reference template struct remove_cvref { - typedef remove_cv>::type; + using typename remove_cv>::type; }; // == string testing (from me) == From 4c56a70baa53d226b16e1e8f100563e8042416a2 Mon Sep 17 00:00:00 2001 From: willvale <66674079+willvale@users.noreply.github.com> Date: Wed, 19 Nov 2025 14:42:05 +1300 Subject: [PATCH 6/8] Fix definitions for line_type-based APIs. This might be better with a high-level flag as well? --- inkcpp/include/runner.h | 4 +++- inkcpp/runner_impl.cpp | 2 +- inkcpp/runner_impl.h | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/inkcpp/include/runner.h b/inkcpp/include/runner.h index d765ac24..f9a647b4 100644 --- a/inkcpp/include/runner.h +++ b/inkcpp/include/runner.h @@ -93,7 +93,9 @@ class runner_interface * @return allocated c-style string with the output of a single line of execution */ virtual const char* getline_alloc() = 0; -#else +#endif + +#if defined(INK_ENABLE_STL) || defined(INK_ENABLE_UNREAL) /** * Execute the next line of the script. * diff --git a/inkcpp/runner_impl.cpp b/inkcpp/runner_impl.cpp index 1ab2c914..05be3fd7 100644 --- a/inkcpp/runner_impl.cpp +++ b/inkcpp/runner_impl.cpp @@ -505,7 +505,7 @@ runner_impl::~runner_impl() } } -#ifndef INK_ENABLE_CSTD +#if defined(INK_ENABLE_STL) || defined(INK_ENABLE_UNREAL) runner_impl::line_type runner_impl::getline() { diff --git a/inkcpp/runner_impl.h b/inkcpp/runner_impl.h index 8e119929..7cf61d32 100644 --- a/inkcpp/runner_impl.h +++ b/inkcpp/runner_impl.h @@ -132,7 +132,7 @@ class runner_impl // move to path virtual bool move_to(hash_t path) override; -#ifndef INK_ENABLE_CSTD +#if defined(INK_ENABLE_STL) || defined(INK_ENABLE_UNREAL) // Gets a single line of output virtual line_type getline() override; From 23ffa041ec758bb9234961b81ad86dec337e4184 Mon Sep 17 00:00:00 2001 From: willvale <66674079+willvale@users.noreply.github.com> Date: Wed, 19 Nov 2025 15:05:04 +1300 Subject: [PATCH 7/8] For real this time (Template wasn't being instantiated in my build environment, d'oh) --- inkcpp/include/traits.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inkcpp/include/traits.h b/inkcpp/include/traits.h index 38f2afee..8f6af95a 100644 --- a/inkcpp/include/traits.h +++ b/inkcpp/include/traits.h @@ -120,7 +120,7 @@ struct remove_reference template struct remove_cvref { - using typename remove_cv>::type; + typedef typename remove_cv::type>::type type; }; // == string testing (from me) == From 3f7f6f2a825220ad88bdcb8da60ccce4b3f0443d Mon Sep 17 00:00:00 2001 From: Julian Benda Date: Fri, 28 Nov 2025 11:54:47 +0100 Subject: [PATCH 8/8] build(Options) Add NO_EH and NO_RTTI as cmake options. --- .cmake-format.json | 6 + .editorconfig | 5 +- .pre-commit-config.yaml | 2 +- CMakeLists.txt | 289 +++++++++++++++++++++++----------------- inkcpp/include/traits.h | 46 +++---- inkcpp/list_table.h | 6 +- shared/public/config.h | 9 +- shared/public/system.h | 4 +- 8 files changed, 210 insertions(+), 157 deletions(-) create mode 100644 .cmake-format.json diff --git a/.cmake-format.json b/.cmake-format.json new file mode 100644 index 00000000..f0c505c3 --- /dev/null +++ b/.cmake-format.json @@ -0,0 +1,6 @@ +{ + "format": { + "line_width": 100, + "use_tabchars": true + } +} diff --git a/.editorconfig b/.editorconfig index bc97b69a..218304f5 100644 --- a/.editorconfig +++ b/.editorconfig @@ -3,7 +3,10 @@ root = true [*] guidelines = 100 indent_style = tab -indent_size = 4 +indent_size = 2 # Unix-style newlines end_of_line = lf insert_final_newline = true + +[CMakeLists.txt] +max_line_length = 100 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 38ab6a8d..55f7478b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -24,7 +24,7 @@ repos: hooks: - id: text-unicode-replacement-char - repo: https://github.com/cheshirekow/cmake-format-precommit - rev: v0.6.10 + rev: v0.6.13 hooks: - id: cmake-format - id: cmake-lint diff --git a/CMakeLists.txt b/CMakeLists.txt index 490af3e7..cebfd9f1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,21 +4,21 @@ if(${CMAKE_VERSION} VERSION_GREATER "3.24.0") cmake_policy(SET CMP0135 NEW) endif() include(FetchContent) -FetchContent_Declare(inklecate_mac -URL https://github.com/inkle/ink/releases/download/v1.1.1/inklecate_mac.zip -URL_HASH SHA256=c516402bca5fa249a7712e62591b048b137eba3098c53f9fb85a4253f9b9e2c0 -SOURCE_DIR "${CMAKE_BINARY_DIR}/inklecate/mac" -) -FetchContent_Declare(inklecate_windows -URL https://github.com/inkle/ink/releases/download/v1.1.1/inklecate_windows.zip -URL_HASH SHA256=6f317cb4c59bf1b31c6dd61e80c6a2287a1d8c241a703f0586f736ae00871aab -SOURCE_DIR "${CMAKE_BINARY_DIR}/inklecate/windows" -) -FetchContent_Declare(inklecate_linux -URL https://github.com/inkle/ink/releases/download/v1.1.1/inklecate_linux.zip -URL_HASH SHA256=26f4e188e02536d6e99e73e71d9b13e2c2144187f1368a87e82fd5066176cff8 -SOURCE_DIR "${CMAKE_BINARY_DIR}/inklecate/linux" -) +FetchContent_Declare( + inklecate_mac + URL https://github.com/inkle/ink/releases/download/v1.1.1/inklecate_mac.zip + URL_HASH SHA256=c516402bca5fa249a7712e62591b048b137eba3098c53f9fb85a4253f9b9e2c0 + SOURCE_DIR "${CMAKE_BINARY_DIR}/inklecate/mac") +FetchContent_Declare( + inklecate_windows + URL https://github.com/inkle/ink/releases/download/v1.1.1/inklecate_windows.zip + URL_HASH SHA256=6f317cb4c59bf1b31c6dd61e80c6a2287a1d8c241a703f0586f736ae00871aab + SOURCE_DIR "${CMAKE_BINARY_DIR}/inklecate/windows") +FetchContent_Declare( + inklecate_linux + URL https://github.com/inkle/ink/releases/download/v1.1.1/inklecate_linux.zip + URL_HASH SHA256=26f4e188e02536d6e99e73e71d9b13e2c2144187f1368a87e82fd5066176cff8 + SOURCE_DIR "${CMAKE_BINARY_DIR}/inklecate/linux") set(FETCHCONTENT_QUIET OFF) mark_as_advanced(FETCHCONTENT_QUIET) set(CMAKE_TLS_VERIFY true) @@ -42,46 +42,67 @@ enable_testing() # Project setup project(inkcpp VERSION 0.1.9) -SET(CMAKE_CXX_STANDARD 17) -SET(CMAKE_CXX_STANDARD_REQUIRED ON) -SET(CMAKE_INSTALL_LIBRARY_DIR lib) -SET(CMAKE_INSTALL_INCLUDE_DIR include) +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_INSTALL_LIBRARY_DIR lib) +set(CMAKE_INSTALL_INCLUDE_DIR include) # Add subdirectories include(CMakeDependentOption) option(INKCPP_PY "Build python bindings" OFF) -cmake_dependent_option(WHEEL_BUILD "Set for build wheel python lib. (see setup.py for ussage)" OFF "INKCPP_PY" OFF) +cmake_dependent_option(WHEEL_BUILD "Set for build wheel python lib. (see setup.py for ussage)" OFF + "INKCPP_PY" OFF) option(INKCPP_C "Build c library" OFF) -option(INKCPP_TEST "Build inkcpp tests (requires: inklecate in path / env: INKLECATE set / INKCPP_INKLECATE=OS or ALL)" OFF) -set(INKCPP_INKLECATE "NONE" CACHE STRING "If inklecate should be downloaded automatically from the official release page. NONE -> No, OS -> Yes, but only for the current OS, ALL -> Yes, for all availible OSs") +option(INKCPP_TEST "Build inkcpp tests (requires: inklecate in path / env: INKLECATE set \ + / INKCPP_INKLECATE=OS or ALL)" OFF) +set(INKCPP_INKLECATE + "NONE" + CACHE STRING "If inklecate should be downloaded automatically from the official release page. \ + NONE -> No, OS -> Yes, but only for the current OS, ALL -> Yes, for all availible OSs") set_property(CACHE INKCPP_INKLECATE PROPERTY STRINGS "NONE" "OS" "ALL") +option(INKCPP_NO_EH "Disable try/catch in runtime. Used to build without error handling." OFF) +option(INKCPP_NO_RTTI + "Disable real time type information depended code. Used to build without RTTI." OFF) + +if(INKCPP_NO_EH) + add_definitions(-DINKCPP_NO_EH) +endif() +if(INKCPP_NO_RTTI) + add_definitions(-DINKCPP_NO_RTTI) +endif() string(TOUPPER "${INKCPP_INKLECATE}" inkcpp_inklecate_upper) -if (inkcpp_inklecate_upper STREQUAL "ALL") +if(inkcpp_inklecate_upper STREQUAL "ALL") FetchContent_MakeAvailable(inklecate_windows inklecate_mac inklecate_linux) -elseif(inkcpp_inklecate_upper STREQUAL "OS") +elseif(inkcpp_inklecate_upper STREQUAL "OS") if(UNIX AND NOT APPLE) FetchContent_MakeAvailable(inklecate_linux) elseif(APPLE) FetchContent_MakeAvailable(inklecate_mac) - elseif(MSYS OR MINGW OR WIN32 OR CYGWIN) + elseif( + MSYS + OR MINGW + OR WIN32 + OR CYGWIN) FetchContent_MakeAvailable(inklecate_windows) else() - message(FATAL_ERROR "Unable to identify OS for option INKCPP_INKLECATE=OS, please consider using NONE or ALL.") + message( + FATAL_ERROR + "Unable to identify OS for option INKCPP_INKLECATE=OS, please consider using NONE or ALL.") endif() endif() -if (INKCPP_PY) +if(INKCPP_PY) add_compile_options(-fPIC) add_subdirectory(inkcpp_python) endif(INKCPP_PY) add_subdirectory(shared) add_subdirectory(inkcpp) add_subdirectory(inkcpp_compiler) -if (INKCPP_C) +if(INKCPP_C) add_subdirectory(inkcpp_c) endif(INKCPP_C) -if (NOT WHEEL_BUILD) +if(NOT WHEEL_BUILD) add_subdirectory(inkcpp_cl) if(INKCPP_TEST) add_subdirectory(inkcpp_test) @@ -89,35 +110,40 @@ if (NOT WHEEL_BUILD) add_subdirectory(unreal) endif(NOT WHEEL_BUILD) - -install(TARGETS inkcpp inkcpp_shared inkcpp_compiler +install( + TARGETS inkcpp inkcpp_shared inkcpp_compiler EXPORT inkcppTarget ARCHIVE DESTINATION "lib/ink" - COMPONENT lib EXCLUDE_FROM_ALL - PUBLIC_HEADER DESTINATION "include/ink" - COMPONENT lib EXCLUDE_FROM_ALL -) + COMPONENT lib + EXCLUDE_FROM_ALL + PUBLIC_HEADER + DESTINATION "include/ink" + COMPONENT lib + EXCLUDE_FROM_ALL) -install(EXPORT inkcppTarget - FILE inkcppTargets.cmake DESTINATION "lib/cmake/inkcpp" - COMPONENT lib EXCLUDE_FROM_ALL) +install( + EXPORT inkcppTarget + FILE inkcppTargets.cmake + DESTINATION "lib/cmake/inkcpp" + COMPONENT lib + EXCLUDE_FROM_ALL) include(CMakePackageConfigHelpers) -configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in - "${CMAKE_CURRENT_BINARY_DIR}/inkcppConfig.cmake" +configure_package_config_file( + ${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/inkcppConfig.cmake" INSTALL_DESTINATION "lib/cmake/inkcpp" - NO_SET_AND_CHECK_MACRO - NO_CHECK_REQUIRED_COMPONENTS_MACRO) + NO_SET_AND_CHECK_MACRO NO_CHECK_REQUIRED_COMPONENTS_MACRO) write_basic_package_version_file( "${CMAKE_CURRENT_BINARY_DIR}/inkcppConfigVersion.cmake" VERSION "${inkcpp_VERSION_MAJOR}.${inkcpp_VERSION_MINOR}" COMPATIBILITY AnyNewerVersion) -install(FILES - ${CMAKE_CURRENT_BINARY_DIR}/inkcppConfig.cmake - ${CMAKE_CURRENT_BINARY_DIR}/inkcppConfigVersion.cmake - DESTINATION lib/cmake/inkcpp COMPONENT lib EXCLUDE_FROM_ALL) -export(EXPORT inkcppTarget - FILE "${CMAKE_CURRENT_BINARY_DIR}/inkcppTargets.cmake") +install( + FILES ${CMAKE_CURRENT_BINARY_DIR}/inkcppConfig.cmake + ${CMAKE_CURRENT_BINARY_DIR}/inkcppConfigVersion.cmake + DESTINATION lib/cmake/inkcpp + COMPONENT lib + EXCLUDE_FROM_ALL) +export(EXPORT inkcppTarget FILE "${CMAKE_CURRENT_BINARY_DIR}/inkcppTargets.cmake") # include(InstallRequiredSystemLibraries) set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.txt") @@ -130,78 +156,103 @@ set(CPACK_COMPONENTS_GROUPING IGNORE) include(CPack) if(NOT WHEEL_BUILD) -find_package(Doxygen) -if (DOXYGEN_FOUND) - option(INKCPP_DOC_BlueprintUE "Building doxygen documentation with BlueprintUE visualisation for unreal blueprints. (Requires node js)" ON) - if (INKCPP_DOC_BlueprintUE) - set(NODEJS_HINT "None" CACHE PATH "Directory of NodeJS executable to use for generating BlueprintUE visualisation.") - if (IS_DIRECTORY "${NODEJS_HINT}") - find_program(NODEJS_PATH node HINTS ${NODEJS_HINT} DOC "NodeJS executable to build BlueprintUE visualisation in documentation.") - else() - find_program(NODEJS_PATH node DOC "NodeJS executable to build BlueprintUE visualisation in documentation.") - endif (IS_DIRECTORY "${NODEJS_HINT}") - if ("${NODEJS_PATH}" STREQUAL "NODEJS-NOTFOUND") - message(SEND_ERROR "NodeJS is required to build BlueprintUE visualisation. But it was not found. Install NodeJS set NODEJS_HINT to a directory containing the executable. Or disable building the visualisation with setting INKCPP_DOC_BlueprintUE=OFF") - endif("${NODEJS_PATH}" STREQUAL "NODEJS-NOTFOUND") - endif(INKCPP_DOC_BlueprintUE) + find_package(Doxygen) + if(DOXYGEN_FOUND) + option(INKCPP_DOC_BlueprintUE + "Building doxygen documentation with BlueprintUE visualisation for unreal blueprints. \ + (Requires node js)" ON) + if(INKCPP_DOC_BlueprintUE) + set(NODEJS_HINT + "None" + CACHE PATH + "Directory of NodeJS executable to use for generating BlueprintUE visualisation.") + if(IS_DIRECTORY "${NODEJS_HINT}") + find_program( + NODEJS_PATH node + HINTS ${NODEJS_HINT} + DOC "NodeJS executable to build BlueprintUE visualisation in documentation.") + else() + find_program(NODEJS_PATH node + DOC "NodeJS executable to build BlueprintUE visualisation in documentation.") + endif(IS_DIRECTORY "${NODEJS_HINT}") + if("${NODEJS_PATH}" STREQUAL "NODEJS-NOTFOUND") + message( + SEND_ERROR + "NodeJS is required to build BlueprintUE visualisation. \ + But it was not found. Install NodeJS set NODEJS_HINT \ + to a directory containing the executable. \ + Or disable building the visualisation with setting INKCPP_DOC_BlueprintUE=OFF") + endif("${NODEJS_PATH}" STREQUAL "NODEJS-NOTFOUND") + endif(INKCPP_DOC_BlueprintUE) - set(DOXYGEN_PROJECT_NAME ${PROJECT_NAME}) - # enable if update to cmake version 3.28 - # doxygen_add_docs(doc WORKING_DIR ${PROJECT_SOURCE_DIR} CONFIG_FILE "${PROJECT_SOURCE_DIR}/Doxyfile" COMMENT "Generate docs") - set(INPUT_FILTER "") + set(DOXYGEN_PROJECT_NAME ${PROJECT_NAME}) + # enable if update to cmake version 3.28 doxygen_add_docs(doc WORKING_DIR ${PROJECT_SOURCE_DIR} + # CONFIG_FILE "${PROJECT_SOURCE_DIR}/Doxyfile" COMMENT "Generate docs") + set(INPUT_FILTER "") - if (INKCPP_DOC_BlueprintUE AND NOT "${NODEJS_PATH}" STREQUAL "NODEJS-NOTFOUND") - # TODO: make as dependecy - file(COPY "${PROJECT_SOURCE_DIR}/unreal/blueprint_filter.js" DESTINATION ${PROJECT_BINARY_DIR}) - # file(DOWNLOAD - # "https://raw.githubusercontent.com/blueprintue/blueprintue-self-hosted-edition/main/www/bue-render/render.css" - # "${PROJECT_BINARY_DIR}/render.css" - # EXPECTED_HASH SHA256=875364e36f8aa5d6c1d41d58043f13b48a499b5c969e8daef35bd29bbf7c6e8d) - file(COPY "${PROJECT_SOURCE_DIR}/unreal/render.css" DESTINATION ${PROJECT_BINARY_DIR}) - file(APPEND "${PROJECT_BINARY_DIR}/render.css" ".bue-render .icon { background-color: unset; }") - file(READ "${PROJECT_SOURCE_DIR}/Doxyfile" DOXYFILE) - string(REPLACE "FILTER_PATTERNS =" "FILTER_PATTERNS = \"*/unreal/*=node ${PROJECT_BINARY_DIR}/blueprint_filter.js\"" DOXYFILE2 ${DOXYFILE}) - string(REPLACE "HTML_EXTRA_STYLESHEET =" "HTML_EXTRA_STYLESHEET = ${PROJECT_BINARY_DIR}/render.css " DOXYFILE ${DOXYFILE2}) - file(WRITE "${PROJECT_BINARY_DIR}/Doxyfile" ${DOXYFILE}) - else () - configure_file( - "${PROJECT_SOURCE_DIR}/Doxyfile" - "${PROJECT_BINARY_DIR}/Doxyfile" - COPYONLY) - endif() -# "Build Doxygen documentation in ${PROJECT_SOURCE_DIR}/Documentation." "To view them you can for example use" "'python -m http.server -d \"${PROJECT_SOURCE_DIR}/Documentation\" 8080'" "'explorer http://localhost:8080/html'" - add_custom_target(doc - ${DOXYGEN_EXECUTABLE} "${PROJECT_BINARY_DIR}/Doxyfile" - WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}" - COMMAND ${CMAKE_COMMAND} -E echo - COMMENT "Generate DoxygenDocumentation") - add_custom_command(TARGET doc POST_BUILD - COMMAND ${CMAKE_COMMAND} -E cmake_echo_color --cyan - "Build Doxygen documentation in ${PROJECT_SOURCE_DIR}/Documentation." - "To view them you can for example use" - "\" python -m http.server -d \\\"${PROJECT_SOURCE_DIR}/Documentation\\\" 8080\"" - " explorer http://localhost:8080/html") + if(INKCPP_DOC_BlueprintUE AND NOT "${NODEJS_PATH}" STREQUAL "NODEJS-NOTFOUND") + # TODO: make as dependecy + file(COPY "${PROJECT_SOURCE_DIR}/unreal/blueprint_filter.js" + DESTINATION ${PROJECT_BINARY_DIR}) + # file(DOWNLOAD "https://raw.githubusercontent.com/blueprintue/ \ + # blueprintue-self-hosted-edition/main/www/bue-render/render.css" + # "${PROJECT_BINARY_DIR}/render.css" EXPECTED_HASH + # SHA256=875364e36f8aa5d6c1d41d58043f13b48a499b5c969e8daef35bd29bbf7c6e8d) + file(COPY "${PROJECT_SOURCE_DIR}/unreal/render.css" DESTINATION ${PROJECT_BINARY_DIR}) + file(APPEND "${PROJECT_BINARY_DIR}/render.css" + ".bue-render .icon { background-color: unset; }") + file(READ "${PROJECT_SOURCE_DIR}/Doxyfile" DOXYFILE) + string( + REPLACE + "FILTER_PATTERNS =" + "FILTER_PATTERNS = \"*/unreal/*=node ${PROJECT_BINARY_DIR}/blueprint_filter.js\"" + DOXYFILE2 ${DOXYFILE}) + string(REPLACE "HTML_EXTRA_STYLESHEET =" + "HTML_EXTRA_STYLESHEET = ${PROJECT_BINARY_DIR}/render.css " DOXYFILE + ${DOXYFILE2}) + file(WRITE "${PROJECT_BINARY_DIR}/Doxyfile" ${DOXYFILE}) + else() + configure_file("${PROJECT_SOURCE_DIR}/Doxyfile" "${PROJECT_BINARY_DIR}/Doxyfile" COPYONLY) + endif() + # "Build Doxygen documentation in ${PROJECT_SOURCE_DIR}/Documentation." "To view them you can + # for example use" "'python -m http.server -d \"${PROJECT_SOURCE_DIR}/Documentation\" 8080'" + # "'explorer http://localhost:8080/html'" + add_custom_target( + doc + ${DOXYGEN_EXECUTABLE} "${PROJECT_BINARY_DIR}/Doxyfile" + WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}" + COMMAND ${CMAKE_COMMAND} -E echo + COMMENT "Generate DoxygenDocumentation") + add_custom_command( + TARGET doc + POST_BUILD + COMMENT "" + COMMAND + ${CMAKE_COMMAND} -E cmake_echo_color --cyan + "Build Doxygen documentation in ${PROJECT_SOURCE_DIR}/Documentation." + "To view them you can for example use" "\" python -m http.server -d \\\"\ + ${PROJECT_SOURCE_DIR}/Documentation\\\" 8080\"" " explorer http://localhost:8080/html") - set(PY_HTML "${PROJECT_SOURCE_DIR}/Documentation/inkcpp_py.html") - if (INKCPP_PY) - find_package( - Python3 - REQUIRED - COMPONENTS Interpreter - ) - add_custom_target(inkcpp_py_doc - python -m pybind11_stubgen -o . inkcpp_py - COMMAND python -m pdoc -d google -o . inkcpp_py.pyi - COMMAND ${CMAKE_COMMAND} -E copy "./inkcpp_py.html" ${PY_HTML} - DEPENDS inkcpp_py - WORKING_DIRECTORY $ - COMMENT "Generates simple python documentation") - add_dependencies(doc inkcpp_py_doc) - else() - message(WARNING "The python target is disabled, therfore no python documentation will be build. Set INKCPP_PY to change this") - file(WRITE ${PY_HTML} "

Python Documenattion was not build!

") - endif(INKCPP_PY) -else(DOXYGEN_FOUND) - message("Doxygen needed to generate documntation!") -endif(DOXYGEN_FOUND) + set(PY_HTML "${PROJECT_SOURCE_DIR}/Documentation/inkcpp_py.html") + if(INKCPP_PY) + find_package(Python3 REQUIRED COMPONENTS Interpreter) + add_custom_target( + inkcpp_py_doc + python -m pybind11_stubgen -o . inkcpp_py + COMMAND python -m pdoc -d google -o . inkcpp_py.pyi + COMMAND ${CMAKE_COMMAND} -E copy "./inkcpp_py.html" ${PY_HTML} + DEPENDS inkcpp_py + WORKING_DIRECTORY $ + COMMENT "Generates simple python documentation") + add_dependencies(doc inkcpp_py_doc) + else() + message( + WARNING "The python target is disabled, therfore no python documentation will be build. \ + Set INKCPP_PY to change this") + file(WRITE ${PY_HTML} + "

Python Documenattion was not build!

") + endif(INKCPP_PY) + else(DOXYGEN_FOUND) + message("Doxygen needed to generate documntation!") + endif(DOXYGEN_FOUND) endif(NOT WHEEL_BUILD) diff --git a/inkcpp/include/traits.h b/inkcpp/include/traits.h index 8f6af95a..43f95bb9 100644 --- a/inkcpp/include/traits.h +++ b/inkcpp/include/traits.h @@ -101,25 +101,23 @@ struct remove_cv { typedef T type; }; -template +template struct remove_reference { typedef T type; }; -template +template struct remove_reference { - typedef T type; + typedef T type; }; -template -struct remove_reference -{ - typedef T type; +template +struct remove_reference { + typedef T type; }; template -struct remove_cvref -{ +struct remove_cvref { typedef typename remove_cv::type>::type type; }; @@ -157,21 +155,21 @@ template struct string_handler : string_handler { }; -#define MARK_AS_STRING(TYPE, LEN, SRC) \ - template<> \ - struct is_string : constant { \ - }; \ - template<> \ - struct string_handler { \ - static size_t length(const TYPE& x) { return static_cast(LEN); } \ - static void src_copy(const TYPE& x, char* output) \ - { \ - [&output](const char* src) { \ - while (*src != '\0') \ - *(output++) = *(src++); \ - *output = 0; \ - }(SRC); \ - } \ +#define MARK_AS_STRING(TYPE, LEN, SRC) \ + template<> \ + struct is_string : constant { \ + }; \ + template<> \ + struct string_handler { \ + static size_t length(const TYPE& x) { return static_cast(LEN); } \ + static void src_copy(const TYPE& x, char* output) \ + { \ + [&output](const char* src) { \ + while (*src != '\0') \ + *(output++) = *(src++); \ + *output = 0; \ + }(SRC); \ + } \ } inline size_t c_str_len(const char* c) diff --git a/inkcpp/list_table.h b/inkcpp/list_table.h index 16b12ee9..1740d9b8 100644 --- a/inkcpp/list_table.h +++ b/inkcpp/list_table.h @@ -263,14 +263,12 @@ class list_table : public snapshot_interface const data_t* getPtr(int eid) const { - return _data.begin() - + static_cast(_entrySize) * static_cast(eid); + return _data.begin() + static_cast(_entrySize) * static_cast(eid); } data_t* getPtr(int eid) { - return _data.begin() - + static_cast(_entrySize) * static_cast(eid); + return _data.begin() + static_cast(_entrySize) * static_cast(eid); } int numFlags() const diff --git a/shared/public/config.h b/shared/public/config.h index d0c164e1..e2d14ea4 100644 --- a/shared/public/config.h +++ b/shared/public/config.h @@ -6,14 +6,11 @@ */ #pragma once +// The UE build process will define INKCPP_API #ifdef INKCPP_API -#ifndef INKCPP_NO_UNREAL # define INK_ENABLE_UNREAL # define INKCPP_NO_EH # define INKCPP_NO_RTTI -#else -# define INK_ENABLE_CSTD -#endif #elif INKCPP_BUILD_CLIB # define INK_ENABLE_CSTD #else @@ -22,11 +19,11 @@ #endif #ifndef INKCPP_NO_EH -#define INK_ENABLE_EH +# define INK_ENABLE_EH #endif #ifndef INKCPP_NO_RTTI -#define INK_ENABLE_RTTI +# define INK_ENABLE_RTTI #endif // Only turn on if you have json.hpp and you want to use it with the compiler diff --git a/shared/public/system.h b/shared/public/system.h index 7a01a8c7..25040751 100644 --- a/shared/public/system.h +++ b/shared/public/system.h @@ -51,12 +51,12 @@ typedef unsigned int uint32_t; #ifndef INK_ENABLE_STL /** Additional signed integer types */ -typedef int int32_t; +typedef int int32_t; typedef short int16_t; /** Additional unsigned integer types */ typedef unsigned long long uint64_t; -typedef unsigned short uint16_t; +typedef unsigned short uint16_t; #endif // ndef INK_ENABLE_STL /** Name hash (used for temporary variables) */