From 8239a772720ccd51ae177b331ed1729219114dea Mon Sep 17 00:00:00 2001 From: Julian Benda Date: Wed, 6 Dec 2023 17:29:45 +0100 Subject: [PATCH 01/10] Bump workflows with deprecation warning --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f7865218..3b565fd2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -39,7 +39,7 @@ jobs: submodules: true # Download inklecate - - uses: suisei-cn/actions-download-file@v1 + - uses: suisei-cn/actions-download-file@v1.4.0 name: Download Inklecate id: download_inklecate with: @@ -62,7 +62,7 @@ jobs: # Setup CMake - name: Setup cmake - uses: jwlawson/actions-setup-cmake@v1.9 + uses: jwlawson/actions-setup-cmake@v1.14.2 with: cmake-version: '3.21.x' From 9c862cc4bda833a4997c57ade8e5da17020840a8 Mon Sep 17 00:00:00 2001 From: Julian Benda Date: Tue, 12 Dec 2023 16:40:51 +0100 Subject: [PATCH 02/10] Add new test based on https://github.com/brwarner/inkcpp/issues/63 --- inkcpp_test/CMakeLists.txt | 1 + inkcpp_test/SpaceAfterBracketChoice.cpp | 48 +++++++++++++++++++++++++ inkcpp_test/ink/ChoiceBracketStory.ink | 7 ++++ 3 files changed, 56 insertions(+) create mode 100644 inkcpp_test/SpaceAfterBracketChoice.cpp create mode 100644 inkcpp_test/ink/ChoiceBracketStory.ink diff --git a/inkcpp_test/CMakeLists.txt b/inkcpp_test/CMakeLists.txt index 7ffc8aff..4f5166d5 100644 --- a/inkcpp_test/CMakeLists.txt +++ b/inkcpp_test/CMakeLists.txt @@ -13,6 +13,7 @@ add_executable(inkcpp_test catch.hpp Main.cpp LabelCondition.cpp Observer.cpp InkyJson.cpp + SpaceAfterBracketChoice.cpp ) target_link_libraries(inkcpp_test PUBLIC inkcpp inkcpp_compiler inkcpp_shared) diff --git a/inkcpp_test/SpaceAfterBracketChoice.cpp b/inkcpp_test/SpaceAfterBracketChoice.cpp new file mode 100644 index 00000000..9ee8715e --- /dev/null +++ b/inkcpp_test/SpaceAfterBracketChoice.cpp @@ -0,0 +1,48 @@ +#include "catch.hpp" +#include "../inkcpp_cl/test.h" + +#include +#include +#include +#include + +using namespace ink::runtime; + +SCENARIO("a story with bracketed choices and spaces can choose correctly", "[choices]") +{ + GIVEN("a story with line breaks") + { + inklecate("ink/ChoiceBracketStory.ink", "ChoiceBracketStory.tmp"); + ink::compiler::run("ChoiceBracketStory.tmp", "ChoiceBracketStory.bin"); + auto ink = story::from_file("ChoiceBracketStory.bin"); + runner thread = ink->new_runner(); + thread->getall(); + WHEN("start thread") + { + THEN("thread has choices") + { + thread->getall(); + REQUIRE(thread->has_choices()); + } + WHEN("choose choice 1") + { + thread->choose(0); + thread->getall(); + THEN("still has choices") + { + thread->getall(); + REQUIRE(thread->has_choices()); + } + } + WHEN("choose choice 2") + { + thread->choose(1); + thread->getall(); + THEN("still has choices") + { + REQUIRE(thread->has_choices()); + } + } + } + } +} diff --git a/inkcpp_test/ink/ChoiceBracketStory.ink b/inkcpp_test/ink/ChoiceBracketStory.ink new file mode 100644 index 00000000..6658b24c --- /dev/null +++ b/inkcpp_test/ink/ChoiceBracketStory.ink @@ -0,0 +1,7 @@ +-> choices += choices + ++ [Choice 1] ++ [Choice 2] + +- -> choices \ No newline at end of file From e5d1c973051ae240dc82bb568e3501736885b196 Mon Sep 17 00:00:00 2001 From: Julian Benda Date: Wed, 13 Dec 2023 10:32:10 +0100 Subject: [PATCH 03/10] Add check if end after begin for removing spaces --- inkcpp/output.cpp | 8 ++++++-- inkcpp/runner_impl.cpp | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/inkcpp/output.cpp b/inkcpp/output.cpp index 0c13452e..392ec3d3 100644 --- a/inkcpp/output.cpp +++ b/inkcpp/output.cpp @@ -140,8 +140,12 @@ namespace ink::runtime::internal std::string result = str.str(); if ( !result.empty() ) { auto end = clean_string( result.begin(), result.end() ); - _last_char = *( end - 1 ); - result.resize( end - result.begin() - ( _last_char == ' ' ? 1 : 0 ) ); + if (result.begin() == end) { + result.resize(0); + } else { + _last_char = *( end - 1 ); + result.resize( end - result.begin() - ( _last_char == ' ' ? 1 : 0 ) ); + } } return result; } diff --git a/inkcpp/runner_impl.cpp b/inkcpp/runner_impl.cpp index 7ae1a136..5f4d829c 100644 --- a/inkcpp/runner_impl.cpp +++ b/inkcpp/runner_impl.cpp @@ -185,7 +185,7 @@ namespace ink::runtime::internal const uint32_t* iter = nullptr; container_t id; - ip_t offset; + ip_t offset = nullptr; size_t comm_end; bool reversed = _ptr > dest; From 810261d29afd0360c9e890be01c928b513eff94d Mon Sep 17 00:00:00 2001 From: Julian Benda Date: Wed, 13 Dec 2023 15:22:56 +0100 Subject: [PATCH 04/10] Clear data from managed_array on decstruction --- inkcpp/array.h | 6 ++++++ inkcpp/story_ptr.cpp | 2 +- inkcpp_cl/inkcpp_cl.cpp | 5 ++--- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/inkcpp/array.h b/inkcpp/array.h index 5c3ac652..42a6a40f 100644 --- a/inkcpp/array.h +++ b/inkcpp/array.h @@ -20,6 +20,12 @@ namespace ink::runtime::internal { } } + ~managed_array() { + if constexpr (dynamic) { + delete[] _dynamic_data; + } + } + const T& operator[]( size_t i ) const { return data()[i]; } T& operator[]( size_t i ) { return data()[i]; } const T* data() const diff --git a/inkcpp/story_ptr.cpp b/inkcpp/story_ptr.cpp index 99f9b6dd..d425bacc 100644 --- a/inkcpp/story_ptr.cpp +++ b/inkcpp/story_ptr.cpp @@ -66,4 +66,4 @@ namespace ink::runtime::internal _instance_block = _story_block = nullptr; return is_destroyed; } -} \ No newline at end of file +} diff --git a/inkcpp_cl/inkcpp_cl.cpp b/inkcpp_cl/inkcpp_cl.cpp index f5d55f4b..1e800450 100644 --- a/inkcpp_cl/inkcpp_cl.cpp +++ b/inkcpp_cl/inkcpp_cl.cpp @@ -155,7 +155,7 @@ int main(int argc, const char** argv) using namespace ink::runtime; // Load story - story* myInk = story::from_file(outputFilename.c_str()); + std::unique_ptr myInk{story::from_file(outputFilename.c_str())}; // Start runner runner thread; @@ -213,12 +213,11 @@ int main(int argc, const char** argv) // out of content break; } - - return 0; } catch (const std::exception& e) { std::cerr << "Unhandled ink runtime exception: " << e.what() << std::endl; return 1; } + return 0; } From 52cf7b9a4ea5fd9b91cf6d8ca6c8ebc3a5634332 Mon Sep 17 00:00:00 2001 From: Julian Benda Date: Wed, 13 Dec 2023 15:50:42 +0100 Subject: [PATCH 05/10] Bump inkproof to master --- .github/workflows/build.yml | 2 +- proofing/ink-proof | 2 +- proofing/inkcpp_runtime_driver | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3b565fd2..f8a469b3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -144,7 +144,7 @@ jobs: shell: bash working-directory: proofing/ink-proof run: | - python3 proof.py --examples 'I...' inkcpp inklecate_v0.9.0 > run.out + python3 proof.py --examples 'I...' inklecate_v1.1.1 inkcpp_runtime > run.out echo -e "| ${{ matrix.name }} | $(cat run.out) |" > ${{ matrix.artifact }}.txt # Creates a "disabled" artifact if ink proofing is disabled diff --git a/proofing/ink-proof b/proofing/ink-proof index efdfb70e..6f22c543 160000 --- a/proofing/ink-proof +++ b/proofing/ink-proof @@ -1 +1 @@ -Subproject commit efdfb70e81350d94375e221b457197be140dc968 +Subproject commit 6f22c5430f98e76cf29f1d92d8e8b718207e407e diff --git a/proofing/inkcpp_runtime_driver b/proofing/inkcpp_runtime_driver index 5db41602..25022f95 100644 --- a/proofing/inkcpp_runtime_driver +++ b/proofing/inkcpp_runtime_driver @@ -6,7 +6,7 @@ import shutil ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) PATH = os.path.join(ROOT, 'deps', 'inkcpp', 'inkcpp_cl') -ARGS = ["inkcpp_cl", "-p"] + sys.argv[1:] +ARGS = ["inkcpp_cl", "--ommit-choice-tags", "-p"] + sys.argv[1:] os.execv(PATH, ARGS) sleep(2) From 4c997768d53b735fd2a98091158557074b198df0 Mon Sep 17 00:00:00 2001 From: Julian Benda Date: Wed, 13 Dec 2023 16:02:38 +0100 Subject: [PATCH 06/10] Fix pull request report condition --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f8a469b3..bdab9d2d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -172,7 +172,7 @@ jobs: reporting: name: "Pull Request Report" - if: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository }} + if: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == 'brwarner/inkcpp' }} runs-on: ubuntu-latest needs: compilation steps: From d1dbb2ec18eec33933e1f346f91b13930c7d383b Mon Sep 17 00:00:00 2001 From: Julian Benda Date: Wed, 13 Dec 2023 16:17:40 +0100 Subject: [PATCH 07/10] Debug output for badge --- .github/workflows/build.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bdab9d2d..68866b30 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -172,11 +172,14 @@ jobs: reporting: name: "Pull Request Report" - if: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == 'brwarner/inkcpp' }} + # if: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == 'brwarner/inkcpp' }} runs-on: ubuntu-latest needs: compilation steps: # Download Ink Proof Results + - name: Debug + run: | + echo ${{github.event_name}} ${{github.event.pull_request.head.repo.full_name}} ${{github.event.pull_request.head.ref}} ${{github.event.pull_request.base.full_name}} ${{github.event.pull_request.base.ref}} - uses: actions/download-artifact@v2 with: name: results From 57476a855a51ebdd7f19f468440d062a5a9b34ba Mon Sep 17 00:00:00 2001 From: Julian Benda Date: Wed, 13 Dec 2023 16:33:00 +0100 Subject: [PATCH 08/10] Add permissions --- .github/workflows/build.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 68866b30..6bf89e4e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -173,8 +173,11 @@ jobs: reporting: name: "Pull Request Report" # if: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == 'brwarner/inkcpp' }} + if: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.ref == 'master' }} runs-on: ubuntu-latest needs: compilation + permissions: + pull-request: write steps: # Download Ink Proof Results - name: Debug @@ -203,7 +206,7 @@ jobs: done # Post Comment - - uses: marocchino/sticky-pull-request-comment@v2 + - uses: marocchino/sticky-pull-request-comment@v2.8 with: recreate: true path: comment.txt From 25940410f98e5ca7c75a74da78eda746d3d9e188 Mon Sep 17 00:00:00 2001 From: Julian Benda Date: Wed, 13 Dec 2023 16:34:42 +0100 Subject: [PATCH 09/10] fix typo --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6bf89e4e..3131c0f5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -177,7 +177,7 @@ jobs: runs-on: ubuntu-latest needs: compilation permissions: - pull-request: write + pull-requests: write steps: # Download Ink Proof Results - name: Debug From 7b99da25b14efe78b4a1e9ac503cd6020bca139b Mon Sep 17 00:00:00 2001 From: Julian Benda Date: Wed, 13 Dec 2023 16:39:32 +0100 Subject: [PATCH 10/10] extend tag label --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3131c0f5..9995ca40 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -206,7 +206,7 @@ jobs: done # Post Comment - - uses: marocchino/sticky-pull-request-comment@v2.8 + - uses: marocchino/sticky-pull-request-comment@v2.8.0 with: recreate: true path: comment.txt