From 7a3606883e96d509d621b05ed87965472d5b69f7 Mon Sep 17 00:00:00 2001 From: JBenda Date: Tue, 23 Apr 2024 23:32:54 +0200 Subject: [PATCH 1/2] Compiles with U5.4 --- inkcpp/list_impl.cpp | 6 +-- inkcpp_compiler/CMakeLists.txt | 2 +- inkcpp_compiler/binary_emitter.cpp | 2 +- shared/private/command.h | 2 - shared/public/system.h | 41 +++++++------------ .../inkcpp/Source/inkcpp/Private/InkList.cpp | 1 + .../Private/inklecate_cmd.cpp.in | 1 + 7 files changed, 22 insertions(+), 33 deletions(-) diff --git a/inkcpp/list_impl.cpp b/inkcpp/list_impl.cpp index 6ce66717..f004bfbc 100644 --- a/inkcpp/list_impl.cpp +++ b/inkcpp/list_impl.cpp @@ -13,21 +13,21 @@ namespace ink::runtime::internal bool list_impl::contains(const char* flag_name) const { auto flag = _list_table->toFlag(flag_name); - inkAssert(flag.has_value(), "No flag with name found! '%s'", flag_name); + inkAssert(flag.has_value(), "No flag with name found! " FORMAT_STRING_STR "'", flag_name); return _list_table->has(list_table::list{_list}, *flag); } void list_impl::add(const char* flag_name) { auto flag = _list_table->toFlag(flag_name); - inkAssert(flag.has_value(), "No flag with name found to add! '%s'", flag_name); + inkAssert(flag.has_value(), "No flag with name found to add! '" FORMAT_STRING_STR "'", flag_name); _list = _list_table->add(list_table::list{_list}, *flag).lid; } void list_impl::remove(const char* flag_name) { auto flag = _list_table->toFlag(flag_name); - inkAssert(flag.has_value(), "No flag with name found to remove! '%s'", flag_name); + inkAssert(flag.has_value(), "No flag with name found to remove! '" FORMAT_STRING_STR "'", flag_name); _list = _list_table->sub(list_table::list{_list}, *flag).lid; } diff --git a/inkcpp_compiler/CMakeLists.txt b/inkcpp_compiler/CMakeLists.txt index 7ce011e4..e287ee87 100644 --- a/inkcpp_compiler/CMakeLists.txt +++ b/inkcpp_compiler/CMakeLists.txt @@ -7,7 +7,7 @@ list(APPEND SOURCES list_data.h list_data.cpp command.cpp ) -add_definitions(-DINK_COMPILER -DINK_EXPOSE_JSON) +add_definitions(-DINK_EXPOSE_JSON) add_library(inkcpp_compiler_o OBJECT ${SOURCES}) add_library(inkcpp_compiler $) diff --git a/inkcpp_compiler/binary_emitter.cpp b/inkcpp_compiler/binary_emitter.cpp index 77938d87..61cc9ddf 100644 --- a/inkcpp_compiler/binary_emitter.cpp +++ b/inkcpp_compiler/binary_emitter.cpp @@ -373,7 +373,7 @@ void binary_emitter::process_paths() // Otherwise, write container address if (container == nullptr) { _containers.set(position, 0); - inkAssert(optional, "Was not able to resolve a not optional path! '%s'", path.c_str()); + inkAssert(optional, "Was not able to resolve a not optional path! '%hs'", path.c_str()); } else { _containers.set(position, container->offset); } diff --git a/shared/private/command.h b/shared/private/command.h index 83ae6323..3854c329 100644 --- a/shared/private/command.h +++ b/shared/private/command.h @@ -168,7 +168,5 @@ namespace ink template constexpr unsigned int CommandSize = sizeof(Command) + sizeof(CommandFlag) + sizeof(PayloadType); -#ifdef INK_COMPILER extern const char* CommandStrings[]; -#endif } diff --git a/shared/public/system.h b/shared/public/system.h index 2e0c280f..ade192ac 100644 --- a/shared/public/system.h +++ b/shared/public/system.h @@ -24,6 +24,20 @@ # include #endif +// Platform specific defines // + +#ifdef INK_ENABLE_UNREAL +# define inkZeroMemory(buff, len) FMemory::Memset(buff, 0, len) +# define inkAssert(condition, text, ...) checkf(condition, TEXT(text), ##__VA_ARGS__) +# define inkFail(text,...) checkf(false, TEXT(text), ##__VA_ARGS__) +#define FORMAT_STRING_STR "%hs" +#else +# define inkZeroMemory ink::internal::zero_memory +# define inkAssert ink::ink_assert +# define inkFail(...) ink::ink_assert(false, __VA_ARGS__) +#define FORMAT_STRING_STR "%s" +#endif + namespace ink { /** define basic numeric type @@ -168,20 +182,6 @@ template ink_assert(false, msg, args...); exit(EXIT_FAILURE); } -#else -/** platform indipendent assert(false) with message. - * @param msg formatting string - * @param args arguments to format string - */ -template -inline void ink_fail(const char* msg, Args... args) -{ - if (sizeof...(args) > 0) { - checkf(false, UTF8_TO_TCHAR(msg), args...) - } else { - checkf(false, UTF8_TO_TCHAR(msg)); - } -} #endif namespace runtime::internal @@ -295,7 +295,7 @@ class optional void test_value() const { if (! _has_value) { - ink_fail("Can't access empty optional!"); + inkFail("Can't access empty optional!"); } } @@ -305,14 +305,3 @@ class optional #endif } // namespace ink -// Platform specific defines // - -#ifdef INK_ENABLE_UNREAL -# define inkZeroMemory(buff, len) FMemory::Memset(buff, 0, len) -# define inkAssert(condition, text, ...) checkf(condition, TEXT(text), ##__VA_ARGS__) -# define inkFail ink::ink_fail -#else -# define inkZeroMemory ink::internal::zero_memory -# define inkAssert ink::ink_assert -# define inkFail(...) ink::ink_assert(false, __VA_ARGS__) -#endif diff --git a/unreal/inkcpp/Source/inkcpp/Private/InkList.cpp b/unreal/inkcpp/Source/inkcpp/Private/InkList.cpp index f7df1dce..6112e2e3 100644 --- a/unreal/inkcpp/Source/inkcpp/Private/InkList.cpp +++ b/unreal/inkcpp/Source/inkcpp/Private/InkList.cpp @@ -8,6 +8,7 @@ #include "InkList.h" #include +#include "ink/list.h" bool UInkList::ContainsFlag(const FString& flag_name) const { diff --git a/unreal/inkcpp/Source/inkcpp_editor/Private/inklecate_cmd.cpp.in b/unreal/inkcpp/Source/inkcpp_editor/Private/inklecate_cmd.cpp.in index 45f161d1..7a29118a 100644 --- a/unreal/inkcpp/Source/inkcpp_editor/Private/inklecate_cmd.cpp.in +++ b/unreal/inkcpp/Source/inkcpp_editor/Private/inklecate_cmd.cpp.in @@ -7,6 +7,7 @@ #pragma once #include "Kismet/GameplayStatics.h" +#include "string" inline std::string get_inklecate_cmd() { FString platform = UGameplayStatics::GetPlatformName(); From 41db2d99506fe442467737379f8c64be2a926b88 Mon Sep 17 00:00:00 2001 From: Julian Benda Date: Wed, 24 Apr 2024 17:26:36 +0200 Subject: [PATCH 2/2] formatting --- inkcpp/list_impl.cpp | 4 +++- shared/private/command.h | 2 +- shared/public/system.h | 13 ++++++------- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/inkcpp/list_impl.cpp b/inkcpp/list_impl.cpp index f004bfbc..26e71b2f 100644 --- a/inkcpp/list_impl.cpp +++ b/inkcpp/list_impl.cpp @@ -27,7 +27,9 @@ void list_impl::add(const char* flag_name) void list_impl::remove(const char* flag_name) { auto flag = _list_table->toFlag(flag_name); - inkAssert(flag.has_value(), "No flag with name found to remove! '" FORMAT_STRING_STR "'", flag_name); + inkAssert( + flag.has_value(), "No flag with name found to remove! '" FORMAT_STRING_STR "'", flag_name + ); _list = _list_table->sub(list_table::list{_list}, *flag).lid; } diff --git a/shared/private/command.h b/shared/private/command.h index 3854c329..9a391ab2 100644 --- a/shared/private/command.h +++ b/shared/private/command.h @@ -168,5 +168,5 @@ namespace ink template constexpr unsigned int CommandSize = sizeof(Command) + sizeof(CommandFlag) + sizeof(PayloadType); - extern const char* CommandStrings[]; + extern const char* CommandStrings[]; } diff --git a/shared/public/system.h b/shared/public/system.h index ade192ac..c8f68bad 100644 --- a/shared/public/system.h +++ b/shared/public/system.h @@ -29,13 +29,13 @@ #ifdef INK_ENABLE_UNREAL # define inkZeroMemory(buff, len) FMemory::Memset(buff, 0, len) # define inkAssert(condition, text, ...) checkf(condition, TEXT(text), ##__VA_ARGS__) -# define inkFail(text,...) checkf(false, TEXT(text), ##__VA_ARGS__) -#define FORMAT_STRING_STR "%hs" +# define inkFail(text, ...) checkf(false, TEXT(text), ##__VA_ARGS__) +# define FORMAT_STRING_STR "%hs" #else -# define inkZeroMemory ink::internal::zero_memory -# define inkAssert ink::ink_assert -# define inkFail(...) ink::ink_assert(false, __VA_ARGS__) -#define FORMAT_STRING_STR "%s" +# define inkZeroMemory ink::internal::zero_memory +# define inkAssert ink::ink_assert +# define inkFail(...) ink::ink_assert(false, __VA_ARGS__) +# define FORMAT_STRING_STR "%s" #endif namespace ink @@ -304,4 +304,3 @@ class optional }; #endif } // namespace ink -