inkcpp_rb 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.ruby-version +1 -0
- data/CHANGELOG.md +1 -0
- data/Gemfile +10 -0
- data/Gemfile.lock +84 -0
- data/LICENSE +7 -0
- data/README.md +3 -0
- data/Rakefile +16 -0
- data/bin/console +15 -0
- data/bin/setup +10 -0
- data/bin/tapioca +29 -0
- data/ext/inkcpp_rb/extconf.rb +19 -0
- data/ext/inkcpp_rb/inkcpp/.clang-format +99 -0
- data/ext/inkcpp_rb/inkcpp/.github/FUNDING.yml +1 -0
- data/ext/inkcpp_rb/inkcpp/.github/workflows/build.yml +344 -0
- data/ext/inkcpp_rb/inkcpp/.github/workflows/release.yml +49 -0
- data/ext/inkcpp_rb/inkcpp/.gitignore +25 -0
- data/ext/inkcpp_rb/inkcpp/.gitmodules +9 -0
- data/ext/inkcpp_rb/inkcpp/CMakeLists.txt +170 -0
- data/ext/inkcpp_rb/inkcpp/CODE_OF_CONDUCT.md +76 -0
- data/ext/inkcpp_rb/inkcpp/CONTRIBUTING.md +55 -0
- data/ext/inkcpp_rb/inkcpp/Config.cmake.in +2 -0
- data/ext/inkcpp_rb/inkcpp/Documentation/cmake_example/CMakeLists.txt +13 -0
- data/ext/inkcpp_rb/inkcpp/Documentation/cmake_example/main.c +38 -0
- data/ext/inkcpp_rb/inkcpp/Documentation/cmake_example/main.cpp +40 -0
- data/ext/inkcpp_rb/inkcpp/Documentation/cmake_example/test.ink +8 -0
- data/ext/inkcpp_rb/inkcpp/Documentation/cmake_example/test.ink.json +1 -0
- data/ext/inkcpp_rb/inkcpp/Documentation/cmake_example.zip +0 -0
- data/ext/inkcpp_rb/inkcpp/Documentation/unreal/InkCPP_DEMO.zip +0 -0
- data/ext/inkcpp_rb/inkcpp/Documentation/unreal/imgs/CreateThread.png +0 -0
- data/ext/inkcpp_rb/inkcpp/Documentation/unreal/imgs/HandleChoice.png +0 -0
- data/ext/inkcpp_rb/inkcpp/Documentation/unreal/imgs/ListElementOf.png +0 -0
- data/ext/inkcpp_rb/inkcpp/Documentation/unreal/imgs/MinimalRuntime.png +0 -0
- data/ext/inkcpp_rb/inkcpp/Documentation/unreal/imgs/MinimalThread.png +0 -0
- data/ext/inkcpp_rb/inkcpp/Documentation/unreal/imgs/ObseverChange.png +0 -0
- data/ext/inkcpp_rb/inkcpp/Documentation/unreal/imgs/TagListGetValue.png +0 -0
- data/ext/inkcpp_rb/inkcpp/Documentation/unreal/imgs/YieldResume.png +0 -0
- data/ext/inkcpp_rb/inkcpp/Doxyfile +2825 -0
- data/ext/inkcpp_rb/inkcpp/LICENSE.txt +22 -0
- data/ext/inkcpp_rb/inkcpp/Minimal.runsettings +8 -0
- data/ext/inkcpp_rb/inkcpp/README.md +192 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/CMakeLists.txt +67 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/array.h +481 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/avl_array.h +833 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/casting.h +93 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/choice.cpp +54 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/collections/restorable.cpp +124 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/collections/restorable.h +406 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/container_operations.cpp +52 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/container_operations.h +34 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/executioner.h +179 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/functional.cpp +86 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/functions.cpp +54 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/functions.h +40 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/globals_impl.cpp +289 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/globals_impl.h +149 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/header.cpp +44 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/include/choice.h +106 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/include/functional.h +327 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/include/globals.h +196 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/include/list.h +187 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/include/runner.h +291 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/include/snapshot.h +61 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/include/story.h +219 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/include/story_ptr.h +233 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/include/traits.h +270 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/include/types.h +169 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/list_impl.cpp +79 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/list_impl.h +39 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/list_operations.cpp +276 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/list_operations.h +356 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/list_table.cpp +841 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/list_table.h +450 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/numeric_operations.cpp +40 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/numeric_operations.h +529 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/operation_bases.h +164 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/operations.h +100 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/output.cpp +528 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/output.h +153 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/platform.h +22 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/random.h +38 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/runner_impl.cpp +1396 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/runner_impl.h +336 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/simple_restorable_stack.h +335 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/snapshot_impl.cpp +182 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/snapshot_impl.h +91 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/snapshot_interface.h +57 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/stack.cpp +618 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/stack.h +243 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/story_impl.cpp +361 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/story_impl.h +92 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/story_ptr.cpp +75 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/string_operations.cpp +125 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/string_operations.h +67 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/string_table.cpp +149 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/string_table.h +47 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/string_utils.h +207 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/system.cpp +39 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/tuple.hpp +151 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/value.cpp +279 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/value.h +666 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_c/CMakeLists.txt +62 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_c/include/inkcpp.h +393 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_c/inkcpp.cpp +344 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_c/inkcpp_c.pc.in +10 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_c/tests/ExternalFunction.c +56 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_c/tests/Globals.c +98 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_c/tests/Lists.c +73 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_c/tests/Observer.c +36 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_c/tests/Snapshot.c +65 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_cl/CMakeLists.txt +49 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_cl/inkcpp_cl.cpp +215 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_cl/test.cpp +209 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_cl/test.h +8 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_compiler/CMakeLists.txt +37 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_compiler/binary_emitter.cpp +446 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_compiler/binary_emitter.h +70 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_compiler/binary_stream.cpp +166 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_compiler/binary_stream.h +79 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_compiler/command.cpp +107 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_compiler/compiler.cpp +96 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_compiler/emitter.cpp +62 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_compiler/emitter.h +104 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_compiler/include/compilation_results.h +22 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_compiler/include/compiler.h +44 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_compiler/json.hpp +24596 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_compiler/json_compiler.cpp +411 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_compiler/json_compiler.h +62 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_compiler/list_data.cpp +47 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_compiler/list_data.h +70 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_compiler/reporter.cpp +107 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_compiler/reporter.h +55 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_py/CMakeLists.txt +19 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_py/example.py +78 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_py/src/module.cpp +317 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_py/tests/conftest.py +53 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_py/tests/test_ExternalFunctions.py +35 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_py/tests/test_Globals.py +40 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_py/tests/test_Lists.py +43 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_py/tests/test_Observer.py +27 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_py/tests/test_Snapshot.py +57 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_py/unreal_example.ink +71 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/Array.cpp +115 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/CMakeLists.txt +117 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/Callstack.cpp +392 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/EmptyStringForDivert.cpp +36 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/ExternalFunctionsExecuteProperly.cpp +34 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/FallbackFunction.cpp +77 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/Globals.cpp +73 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/InkyJson.cpp +34 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/LabelCondition.cpp +60 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/Lists.cpp +144 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/LookaheadSafe.cpp +46 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/Main.cpp +7 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/MoveTo.cpp +95 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/NewLines.cpp +76 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/NoEarlyTags.cpp +33 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/Observer.cpp +245 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/Pointer.cpp +191 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/Restorable.cpp +294 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/SpaceAfterBracketChoice.cpp +45 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/Stack.cpp +224 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/Tags.cpp +131 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/ThirdTierChoiceAfterBrackets.cpp +38 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/UTF8.cpp +56 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/Value.cpp +210 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/catch.hpp +17970 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/ink/AHF.ink +7 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/ink/ChoiceBracketStory.ink +7 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/ink/EmptyStringForDivert.ink +13 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/ink/ExternalFunctionsExecuteProperly.ink +11 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/ink/FallBack.ink +15 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/ink/GlobalStory.ink +9 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/ink/LabelConditionStory.ink +5 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/ink/LinesStory.ink +42 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/ink/ListLogicStory.ink +40 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/ink/ListStory.ink +8 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/ink/LookaheadSafe.ink +14 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/ink/MoveTo.ink +36 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/ink/NoEarlyTags.ink +19 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/ink/ObserverStory.ink +8 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/ink/SimpleStoryFlow.ink +65 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/ink/TagsStory.ink +22 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/ink/TheIntercept.ink +1686 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/ink/ThirdTierChoiceAfterBracketsStory.ink +13 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/ink/UTF-8-demo.txt +212 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/ink/UTF8Story.ink +218 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/ink/simple-1.1.1-inklecate.json +154 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/ink/simple-1.1.1-inky.json +160 -0
- data/ext/inkcpp_rb/inkcpp/notes/ArchitectureNotes.md +54 -0
- data/ext/inkcpp_rb/inkcpp/notes/ListNotes.md +69 -0
- data/ext/inkcpp_rb/inkcpp/notes/OperationNotes.md +35 -0
- data/ext/inkcpp_rb/inkcpp/notes/TagsNotes.md +24 -0
- data/ext/inkcpp_rb/inkcpp/notes/WhitespaceNotes.md +28 -0
- data/ext/inkcpp_rb/inkcpp/proofing/README.md +3 -0
- data/ext/inkcpp_rb/inkcpp/proofing/inkcpp_runtime_driver +12 -0
- data/ext/inkcpp_rb/inkcpp/pyproject.toml +63 -0
- data/ext/inkcpp_rb/inkcpp/setup.py +166 -0
- data/ext/inkcpp_rb/inkcpp/shared/CMakeLists.txt +14 -0
- data/ext/inkcpp_rb/inkcpp/shared/private/command.h +172 -0
- data/ext/inkcpp_rb/inkcpp/shared/private/header.h +46 -0
- data/ext/inkcpp_rb/inkcpp/shared/public/config.h +53 -0
- data/ext/inkcpp_rb/inkcpp/shared/public/system.h +307 -0
- data/ext/inkcpp_rb/inkcpp/shared/public/version.h +14 -0
- data/ext/inkcpp_rb/inkcpp/tests/TestAllSequenceTypes.ink +59 -0
- data/ext/inkcpp_rb/inkcpp/tests/TestArithmetic.ink +17 -0
- data/ext/inkcpp_rb/inkcpp/tests/TestBasicStringLiterals.ink +8 -0
- data/ext/inkcpp_rb/inkcpp/tests/TestBasicTunnel.ink +10 -0
- data/ext/inkcpp_rb/inkcpp/tests/TestBlanksInInlineSequences.ink +51 -0
- data/ext/inkcpp_rb/inkcpp/tests/TestCallStackEvaluation.ink +15 -0
- data/ext/inkcpp_rb/inkcpp/tests/TestChoiceCount.ink +15 -0
- data/ext/inkcpp_rb/inkcpp/tests/TestChoiceDivertsToDone.ink +6 -0
- data/ext/inkcpp_rb/inkcpp/tests/TestChoiceWithBracketsOnly.ink +9 -0
- data/ext/inkcpp_rb/inkcpp/tests/TestCompareDivertTargets.ink +26 -0
- data/ext/inkcpp_rb/inkcpp/tests/TestComplexTunnels.ink +22 -0
- data/ext/inkcpp_rb/inkcpp/tests/TestConditionalChoiceInWeave.ink +19 -0
- data/ext/inkcpp_rb/inkcpp/tests/TestTunnelOnwardsAfterTunnel.ink +17 -0
- data/ext/inkcpp_rb/inkcpp/unreal/CMakeLists.txt +51 -0
- data/ext/inkcpp_rb/inkcpp/unreal/UE_example.ink +92 -0
- data/ext/inkcpp_rb/inkcpp/unreal/blueprint_filter.js +377 -0
- data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Resources/Icon128.png +0 -0
- data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp/Private/InkAsset.cpp +47 -0
- data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp/Private/InkChoice.cpp +40 -0
- data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp/Private/InkList.cpp +86 -0
- data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp/Private/InkRuntime.cpp +265 -0
- data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp/Private/InkThread.cpp +239 -0
- data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp/Private/InkVar.cpp +143 -0
- data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp/Private/TagList.cpp +95 -0
- data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp/Private/inkcpp.cpp +13 -0
- data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp/Public/InkAsset.h +50 -0
- data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp/Public/InkChoice.h +58 -0
- data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp/Public/InkDelegates.h +139 -0
- data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp/Public/InkList.h +102 -0
- data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp/Public/InkRuntime.h +177 -0
- data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp/Public/InkSnapshot.h +30 -0
- data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp/Public/InkThread.h +215 -0
- data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp/Public/InkVar.h +245 -0
- data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp/Public/TagList.h +77 -0
- data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp/Public/inkcpp.h +217 -0
- data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp/inkcpp.Build.cs +62 -0
- data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp_editor/Private/InkAssetFactory.cpp +237 -0
- data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp_editor/Private/InkAssetFactory.h +43 -0
- data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp_editor/Private/inkcpp_editor.cpp +13 -0
- data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp_editor/Private/inklecate_cmd.cpp.in +24 -0
- data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp_editor/Public/inkcpp_editor.h +9 -0
- data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp_editor/inkcpp_editor.Build.cs +61 -0
- data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/inkcpp.uplugin +44 -0
- data/ext/inkcpp_rb/inkcpp/unreal/render.css +1 -0
- data/ext/inkcpp_rb/inkcpp_rb.cpp +321 -0
- data/inkcpp_rb.gemspec +54 -0
- data/rbi/inkcpp_rb.rbi +211 -0
- data/sorbet/config +4 -0
- data/sorbet/rbi/annotations/.gitattributes +1 -0
- data/sorbet/rbi/annotations/minitest.rbi +119 -0
- data/sorbet/rbi/gems/.gitattributes +1 -0
- data/sorbet/rbi/gems/benchmark@0.4.0.rbi +618 -0
- data/sorbet/rbi/gems/erubi@1.13.1.rbi +155 -0
- data/sorbet/rbi/gems/minitest@5.25.4.rbi +1547 -0
- data/sorbet/rbi/gems/netrc@0.11.0.rbi +159 -0
- data/sorbet/rbi/gems/parallel@1.26.3.rbi +291 -0
- data/sorbet/rbi/gems/prism@1.3.0.rbi +40040 -0
- data/sorbet/rbi/gems/rake-compiler@1.2.8.rbi +9 -0
- data/sorbet/rbi/gems/rake@13.2.1.rbi +3033 -0
- data/sorbet/rbi/gems/rbi@0.2.2.rbi +4527 -0
- data/sorbet/rbi/gems/rice@4.3.3.rbi +44 -0
- data/sorbet/rbi/gems/spoom@1.5.0.rbi +4932 -0
- data/sorbet/rbi/gems/tapioca@0.16.7.rbi +3611 -0
- data/sorbet/rbi/gems/thor@1.3.2.rbi +4378 -0
- data/sorbet/rbi/gems/yard-sorbet@0.9.0.rbi +435 -0
- data/sorbet/rbi/gems/yard@0.9.37.rbi +18379 -0
- data/sorbet/tapioca/config.yml +13 -0
- data/sorbet/tapioca/require.rb +4 -0
- metadata +400 -0
|
@@ -0,0 +1,392 @@
|
|
|
1
|
+
#include "catch.hpp"
|
|
2
|
+
|
|
3
|
+
#include "../inkcpp/stack.h"
|
|
4
|
+
|
|
5
|
+
using ink::hash_t;
|
|
6
|
+
using ink::thread_t;
|
|
7
|
+
using ink::runtime::internal::value;
|
|
8
|
+
using ink::runtime::internal::value_type;
|
|
9
|
+
using ink::runtime::internal::frame_type;
|
|
10
|
+
|
|
11
|
+
const hash_t X = ink::hash_string("X");
|
|
12
|
+
const hash_t Y = ink::hash_string("Y");
|
|
13
|
+
const hash_t Z = ink::hash_string("Z");
|
|
14
|
+
|
|
15
|
+
value operator "" _v(unsigned long long i) {
|
|
16
|
+
return value{}.set<value_type::int32>(static_cast<int32_t>(i));
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
SCENARIO("threading with the callstack", "[callstack]")
|
|
20
|
+
{
|
|
21
|
+
GIVEN("a callstack with a few temporary variables")
|
|
22
|
+
{
|
|
23
|
+
// Create the stack
|
|
24
|
+
auto stack = ink::runtime::internal::stack<50>();
|
|
25
|
+
|
|
26
|
+
// Set X and Y temporary variables
|
|
27
|
+
stack.set(X, 100_v);
|
|
28
|
+
stack.set(Y, 200_v);
|
|
29
|
+
|
|
30
|
+
WHEN("there is a fork and more is pushed")
|
|
31
|
+
{
|
|
32
|
+
thread_t thread = stack.fork_thread();
|
|
33
|
+
|
|
34
|
+
THEN("old variables aren't accessible")
|
|
35
|
+
{
|
|
36
|
+
REQUIRE(stack.get(X) == nullptr);
|
|
37
|
+
REQUIRE(stack.get(Y) == nullptr);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Push something onto the thread
|
|
41
|
+
stack.set(X, 200_v);
|
|
42
|
+
REQUIRE(stack.get(X)->get<value_type::int32>() == 200);
|
|
43
|
+
|
|
44
|
+
WHEN("when that thread ends")
|
|
45
|
+
{
|
|
46
|
+
stack.complete_thread(thread);
|
|
47
|
+
|
|
48
|
+
WHEN("we collapse to the thread")
|
|
49
|
+
{
|
|
50
|
+
stack.collapse_to_thread(thread);
|
|
51
|
+
|
|
52
|
+
THEN("we should have the value from that thread")
|
|
53
|
+
{
|
|
54
|
+
REQUIRE(stack.get(X)->get<value_type::int32>() == 200);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
WHEN("we collapse to the main thraed")
|
|
59
|
+
{
|
|
60
|
+
stack.collapse_to_thread(~0);
|
|
61
|
+
|
|
62
|
+
THEN("we should have the value from the original thread")
|
|
63
|
+
{
|
|
64
|
+
REQUIRE(stack.get(X)->get<value_type::int32>() == 100);
|
|
65
|
+
REQUIRE(stack.get(Y)->get<value_type::int32>() == 200);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
THEN("we should be able to access original thread values")
|
|
70
|
+
{
|
|
71
|
+
REQUIRE(stack.get(X)->get<value_type::int32>() == 100);
|
|
72
|
+
REQUIRE(stack.get(Y)->get<value_type::int32>() == 200);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
WHEN("we push more on the main thread")
|
|
76
|
+
{
|
|
77
|
+
stack.set(Z, 500_v);
|
|
78
|
+
|
|
79
|
+
THEN("collapsing to the thread shouldn't have the values anymore")
|
|
80
|
+
{
|
|
81
|
+
stack.collapse_to_thread(thread);
|
|
82
|
+
REQUIRE(stack.get(Z) == nullptr);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
WHEN("we start a second thread that closes")
|
|
86
|
+
{
|
|
87
|
+
thread_t thread2 = stack.fork_thread();
|
|
88
|
+
stack.set(X, 999_v);
|
|
89
|
+
stack.complete_thread(thread2);
|
|
90
|
+
|
|
91
|
+
THEN("we can still collapse to the main thread")
|
|
92
|
+
{
|
|
93
|
+
stack.collapse_to_thread(~0);
|
|
94
|
+
REQUIRE(stack.get(X)->get<value_type::int32>() == 100);
|
|
95
|
+
REQUIRE(stack.get(Y)->get<value_type::int32>() == 200);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
THEN("we can still collapse to the first thread")
|
|
99
|
+
{
|
|
100
|
+
stack.collapse_to_thread(thread);
|
|
101
|
+
REQUIRE(stack.get(Y)->get<value_type::int32>() == 200);
|
|
102
|
+
REQUIRE(stack.get(Z) == nullptr);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
WHEN("that thread also forks a thread")
|
|
109
|
+
{
|
|
110
|
+
thread_t thread2 = stack.fork_thread();
|
|
111
|
+
|
|
112
|
+
// Put something on this thread
|
|
113
|
+
stack.set(X, 999_v);
|
|
114
|
+
|
|
115
|
+
WHEN("that inner thread and outer thread complete")
|
|
116
|
+
{
|
|
117
|
+
stack.complete_thread(thread2);
|
|
118
|
+
stack.complete_thread(thread);
|
|
119
|
+
|
|
120
|
+
WHEN("we collapse to the inner thread")
|
|
121
|
+
{
|
|
122
|
+
stack.collapse_to_thread(thread2);
|
|
123
|
+
|
|
124
|
+
THEN("we should have the value from that thread")
|
|
125
|
+
{
|
|
126
|
+
REQUIRE(stack.get(X)->get<value_type::int32>() == 999);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
WHEN("we collapse to the outer thread")
|
|
131
|
+
{
|
|
132
|
+
stack.collapse_to_thread(thread);
|
|
133
|
+
|
|
134
|
+
THEN("we should have the value from that thread")
|
|
135
|
+
{
|
|
136
|
+
REQUIRE(stack.get(X)->get<value_type::int32>() == 200);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
WHEN("we collapse to the main thraed")
|
|
141
|
+
{
|
|
142
|
+
stack.collapse_to_thread(~0);
|
|
143
|
+
|
|
144
|
+
THEN("we should have the value from the original thread")
|
|
145
|
+
{
|
|
146
|
+
REQUIRE(stack.get(X)->get<value_type::int32>() == 100);
|
|
147
|
+
REQUIRE(stack.get(Y)->get<value_type::int32>() == 200);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
WHEN("there is a fork with a tunnel that finishes")
|
|
155
|
+
{
|
|
156
|
+
thread_t thread = stack.fork_thread();
|
|
157
|
+
stack.push_frame<frame_type::tunnel>(555, false);
|
|
158
|
+
stack.complete_thread(thread);
|
|
159
|
+
|
|
160
|
+
THEN("there should be no frames on the stack")
|
|
161
|
+
{
|
|
162
|
+
REQUIRE(stack.has_frame() == false);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
GIVEN("a callstack with a single tunnel pushed")
|
|
168
|
+
{
|
|
169
|
+
// Create the stack
|
|
170
|
+
auto stack = ink::runtime::internal::stack<50>();
|
|
171
|
+
|
|
172
|
+
// Set X and Y temporary variables
|
|
173
|
+
stack.set(X, 100_v);
|
|
174
|
+
stack.set(Y, 200_v);
|
|
175
|
+
|
|
176
|
+
// Push a tunnel
|
|
177
|
+
stack.push_frame<frame_type::tunnel>(505, false);
|
|
178
|
+
|
|
179
|
+
// Push some more temps
|
|
180
|
+
stack.set(X, 101_v);
|
|
181
|
+
stack.set(Y, 201_v);
|
|
182
|
+
|
|
183
|
+
bool eval_mode;
|
|
184
|
+
|
|
185
|
+
WHEN("a thread is forked")
|
|
186
|
+
{
|
|
187
|
+
thread_t thread = stack.fork_thread();
|
|
188
|
+
|
|
189
|
+
WHEN("that thread does a tunnel return")
|
|
190
|
+
{
|
|
191
|
+
frame_type type;
|
|
192
|
+
auto offset = stack.pop_frame(&type, eval_mode);
|
|
193
|
+
|
|
194
|
+
THEN("that thread should be outside the tunnel")
|
|
195
|
+
{
|
|
196
|
+
REQUIRE(type == frame_type::tunnel);
|
|
197
|
+
REQUIRE(offset == 505);
|
|
198
|
+
|
|
199
|
+
REQUIRE(stack.get(X)->get<value_type::int32>() == 100);
|
|
200
|
+
REQUIRE(stack.get(Y)->get<value_type::int32>() == 200);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
stack.complete_thread(thread);
|
|
204
|
+
|
|
205
|
+
WHEN("we collapse to that thread")
|
|
206
|
+
{
|
|
207
|
+
stack.collapse_to_thread(thread);
|
|
208
|
+
THEN("the stack should be outside the tunnel")
|
|
209
|
+
{
|
|
210
|
+
REQUIRE(stack.get(X)->type() == value_type::int32);
|
|
211
|
+
REQUIRE(stack.get(X)->get<value_type::int32>() == 100);
|
|
212
|
+
REQUIRE(stack.get(Y)->type() == value_type::int32);
|
|
213
|
+
REQUIRE(stack.get(Y)->get<value_type::int32>() == 200);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
WHEN("we collapse back to the main thread")
|
|
218
|
+
{
|
|
219
|
+
stack.collapse_to_thread(~0);
|
|
220
|
+
THEN("the stack should be inside the tunnel")
|
|
221
|
+
{
|
|
222
|
+
REQUIRE(stack.get(X)->type() == value_type::int32);
|
|
223
|
+
REQUIRE(stack.get(X)->get<value_type::int32>() == 101);
|
|
224
|
+
REQUIRE(stack.get(Y)->type() == value_type::int32);
|
|
225
|
+
REQUIRE(stack.get(Y)->get<value_type::int32>() == 201);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
WHEN("we do a tunnel return")
|
|
229
|
+
{
|
|
230
|
+
frame_type type;
|
|
231
|
+
auto offset = stack.pop_frame(&type, eval_mode);
|
|
232
|
+
|
|
233
|
+
THEN("we should be back outside")
|
|
234
|
+
{
|
|
235
|
+
REQUIRE(type == frame_type::tunnel);
|
|
236
|
+
REQUIRE(offset == 505);
|
|
237
|
+
REQUIRE(stack.get(X)->type() == value_type::int32);
|
|
238
|
+
REQUIRE(stack.get(X)->get<value_type::int32>() == 100);
|
|
239
|
+
REQUIRE(stack.get(Y)->type() == value_type::int32);
|
|
240
|
+
REQUIRE(stack.get(Y)->get<value_type::int32>() == 200);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
WHEN("that thread completes and we pop off the main thread")
|
|
247
|
+
{
|
|
248
|
+
stack.complete_thread(thread);
|
|
249
|
+
frame_type type;
|
|
250
|
+
auto offset = stack.pop_frame(&type, eval_mode);
|
|
251
|
+
|
|
252
|
+
THEN("we should be outside the tunnel")
|
|
253
|
+
{
|
|
254
|
+
REQUIRE(stack.get(X)->type() == value_type::int32);
|
|
255
|
+
REQUIRE(stack.get(X)->get<value_type::int32>() == 100);
|
|
256
|
+
REQUIRE(stack.get(Y)->type() == value_type::int32);
|
|
257
|
+
REQUIRE(stack.get(Y)->get<value_type::int32>() == 200);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
THEN("collapsing to the thread will have the correct callstack")
|
|
261
|
+
{
|
|
262
|
+
stack.collapse_to_thread(thread);
|
|
263
|
+
|
|
264
|
+
REQUIRE(stack.get(X)->type() == value_type::int32);
|
|
265
|
+
REQUIRE(stack.get(X)->get<value_type::int32>() == 101);
|
|
266
|
+
REQUIRE(stack.get(Y)->type() == value_type::int32);
|
|
267
|
+
REQUIRE(stack.get(Y)->get<value_type::int32>() == 201);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
GIVEN("A thread with a frame pushed")
|
|
274
|
+
{
|
|
275
|
+
// Create the stack
|
|
276
|
+
auto stack = ink::runtime::internal::stack<50>();
|
|
277
|
+
|
|
278
|
+
// Create the thread
|
|
279
|
+
thread_t thread = stack.fork_thread();
|
|
280
|
+
|
|
281
|
+
// Set X and Y temporary variables
|
|
282
|
+
stack.set(X, 100_v);
|
|
283
|
+
stack.set(Y, 200_v);
|
|
284
|
+
|
|
285
|
+
// Push a tunnel
|
|
286
|
+
stack.push_frame<frame_type::tunnel>(505, false);
|
|
287
|
+
|
|
288
|
+
// Push some more temps
|
|
289
|
+
stack.set(X, 101_v);
|
|
290
|
+
stack.set(Y, 201_v);
|
|
291
|
+
|
|
292
|
+
bool eval_mode;
|
|
293
|
+
|
|
294
|
+
WHEN("a second thread is forked off the first")
|
|
295
|
+
{
|
|
296
|
+
thread_t thread2 = stack.fork_thread();
|
|
297
|
+
|
|
298
|
+
WHEN("the second thread ends")
|
|
299
|
+
{
|
|
300
|
+
stack.complete_thread(thread2);
|
|
301
|
+
|
|
302
|
+
WHEN("the first thread does a pop")
|
|
303
|
+
{
|
|
304
|
+
frame_type _ignore;
|
|
305
|
+
stack.pop_frame(&_ignore, eval_mode);
|
|
306
|
+
|
|
307
|
+
THEN("accessing the variable should return the original")
|
|
308
|
+
{
|
|
309
|
+
REQUIRE(stack.get(X)->type() == value_type::int32);
|
|
310
|
+
REQUIRE(stack.get(X)->get<value_type::int32>() == 100);
|
|
311
|
+
REQUIRE(stack.get(Y)->type() == value_type::int32);
|
|
312
|
+
REQUIRE(stack.get(Y)->get<value_type::int32>() == 200);
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
WHEN("the first thread ends")
|
|
316
|
+
{
|
|
317
|
+
stack.complete_thread(thread);
|
|
318
|
+
|
|
319
|
+
THEN("collapsing to the first thread should return the correct variables")
|
|
320
|
+
{
|
|
321
|
+
stack.collapse_to_thread(thread);
|
|
322
|
+
|
|
323
|
+
REQUIRE(stack.get(X)->type() == value_type::int32);
|
|
324
|
+
REQUIRE(stack.get(X)->get<value_type::int32>() == 100);
|
|
325
|
+
REQUIRE(stack.get(Y)->type() == value_type::int32);
|
|
326
|
+
REQUIRE(stack.get(Y)->get<value_type::int32>() == 200);
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
GIVEN("A thread with two frames pushed")
|
|
335
|
+
{
|
|
336
|
+
// Create the stack
|
|
337
|
+
auto stack = ink::runtime::internal::stack<50>();
|
|
338
|
+
|
|
339
|
+
// Create the thread
|
|
340
|
+
thread_t thread = stack.fork_thread();
|
|
341
|
+
|
|
342
|
+
// Set X and Y temporary variables
|
|
343
|
+
stack.set(X, 100_v);
|
|
344
|
+
stack.set(Y, 200_v);
|
|
345
|
+
|
|
346
|
+
// Push a tunnel
|
|
347
|
+
stack.push_frame<frame_type::tunnel>(505, false);
|
|
348
|
+
|
|
349
|
+
// Push some more temps
|
|
350
|
+
stack.set(X, 101_v);
|
|
351
|
+
stack.set(Y, 201_v);
|
|
352
|
+
|
|
353
|
+
// Push another tunnel
|
|
354
|
+
stack.push_frame<frame_type::tunnel>(505, false);
|
|
355
|
+
|
|
356
|
+
// Push some more temps
|
|
357
|
+
stack.set(X, 102_v);
|
|
358
|
+
stack.set(Y, 202_v);
|
|
359
|
+
|
|
360
|
+
WHEN("another thread is started and completed on top of it")
|
|
361
|
+
{
|
|
362
|
+
thread_t thread2 = stack.fork_thread();
|
|
363
|
+
stack.complete_thread(thread2);
|
|
364
|
+
|
|
365
|
+
WHEN("we then try to pop both frames")
|
|
366
|
+
{
|
|
367
|
+
frame_type _ignore;
|
|
368
|
+
bool eval_mode;
|
|
369
|
+
stack.pop_frame(&_ignore, eval_mode);
|
|
370
|
+
stack.pop_frame(&_ignore, eval_mode);
|
|
371
|
+
|
|
372
|
+
THEN("we should have access to the original variables")
|
|
373
|
+
{
|
|
374
|
+
REQUIRE(stack.get(X)->type() == value_type::int32);
|
|
375
|
+
REQUIRE(stack.get(X)->get<value_type::int32>() == 100);
|
|
376
|
+
REQUIRE(stack.get(Y)->type() == value_type::int32);
|
|
377
|
+
REQUIRE(stack.get(Y)->get<value_type::int32>() == 200);
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
THEN("collapsing to the thread should also get us the original variables")
|
|
381
|
+
{
|
|
382
|
+
stack.complete_thread(thread);
|
|
383
|
+
stack.collapse_to_thread(thread);
|
|
384
|
+
REQUIRE(stack.get(X)->type() == value_type::int32);
|
|
385
|
+
REQUIRE(stack.get(X)->get<value_type::int32>() == 100);
|
|
386
|
+
REQUIRE(stack.get(Y)->type() == value_type::int32);
|
|
387
|
+
REQUIRE(stack.get(Y)->get<value_type::int32>() == 200);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#include "catch.hpp"
|
|
2
|
+
|
|
3
|
+
#include <story.h>
|
|
4
|
+
#include <globals.h>
|
|
5
|
+
#include <runner.h>
|
|
6
|
+
#include <compiler.h>
|
|
7
|
+
|
|
8
|
+
using namespace ink::runtime;
|
|
9
|
+
|
|
10
|
+
SCENARIO("a story with a white space infront of an conditional Divert", "[Output]")
|
|
11
|
+
{
|
|
12
|
+
// based on https://github.com/JBenda/inkcpp/issues/71
|
|
13
|
+
GIVEN("A story")
|
|
14
|
+
{
|
|
15
|
+
auto ink = story::from_file(INK_TEST_RESOURCE_DIR "EmptyStringForDivert.bin");
|
|
16
|
+
runner thread = ink->new_runner();
|
|
17
|
+
|
|
18
|
+
WHEN("run")
|
|
19
|
+
{
|
|
20
|
+
THEN("print 'This displays first'")
|
|
21
|
+
{
|
|
22
|
+
thread->getall();
|
|
23
|
+
REQUIRE(thread->has_choices());
|
|
24
|
+
thread->choose(0);
|
|
25
|
+
REQUIRE(thread->getall() == "This displays first\n");
|
|
26
|
+
REQUIRE(thread->has_choices());
|
|
27
|
+
thread->choose(0);
|
|
28
|
+
REQUIRE(thread->getall() == "This is the continuation.\n");
|
|
29
|
+
REQUIRE(thread->has_choices());
|
|
30
|
+
thread->choose(0);
|
|
31
|
+
REQUIRE(thread->getall() == "");
|
|
32
|
+
REQUIRE(! thread->has_choices());
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
#include "catch.hpp"
|
|
2
|
+
|
|
3
|
+
#include <story.h>
|
|
4
|
+
#include <globals.h>
|
|
5
|
+
#include <runner.h>
|
|
6
|
+
#include <compiler.h>
|
|
7
|
+
|
|
8
|
+
using namespace ink::runtime;
|
|
9
|
+
|
|
10
|
+
SCENARIO("a story with an external function evaluates the function at the right time", "[story]")
|
|
11
|
+
{
|
|
12
|
+
GIVEN("a story with an external function")
|
|
13
|
+
{
|
|
14
|
+
auto ink = story::from_file(INK_TEST_RESOURCE_DIR "ExternalFunctionsExecuteProperly.bin");
|
|
15
|
+
runner thread = ink->new_runner();
|
|
16
|
+
|
|
17
|
+
int line_count = 0;
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
thread->bind("GET_LINE_COUNT", [&line_count]() { return line_count; });
|
|
21
|
+
|
|
22
|
+
WHEN("run thread")
|
|
23
|
+
{
|
|
24
|
+
THEN("thread has correct line counts")
|
|
25
|
+
{
|
|
26
|
+
while (thread->can_continue()) {
|
|
27
|
+
auto line = thread->getline();
|
|
28
|
+
REQUIRE(line == "Line count: " + std::to_string(line_count) + "\n");
|
|
29
|
+
line_count++;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
#include "catch.hpp"
|
|
2
|
+
|
|
3
|
+
#include <system.h>
|
|
4
|
+
#include <story.h>
|
|
5
|
+
#include <runner.h>
|
|
6
|
+
#include <globals.h>
|
|
7
|
+
#include <compiler.h>
|
|
8
|
+
|
|
9
|
+
#include <cmath>
|
|
10
|
+
|
|
11
|
+
using namespace ink::runtime;
|
|
12
|
+
|
|
13
|
+
SCENARIO("run a story with external function and fallback function", "[external function]")
|
|
14
|
+
{
|
|
15
|
+
GIVEN("story with two external functions, one with fallback")
|
|
16
|
+
{
|
|
17
|
+
auto ink = story::from_file(INK_TEST_RESOURCE_DIR "FallBack.bin");
|
|
18
|
+
runner thread = ink->new_runner();
|
|
19
|
+
|
|
20
|
+
WHEN("bind both external functions")
|
|
21
|
+
{
|
|
22
|
+
int cnt_sqrt = 0;
|
|
23
|
+
auto fn_sqrt = [&cnt_sqrt](int x) -> int {
|
|
24
|
+
++cnt_sqrt;
|
|
25
|
+
return sqrt(x);
|
|
26
|
+
};
|
|
27
|
+
int cnt_greeting = 0;
|
|
28
|
+
auto fn_greeting = [&cnt_greeting]() -> const char* {
|
|
29
|
+
++cnt_greeting;
|
|
30
|
+
return "Hohooh";
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
thread->bind("sqrt", fn_sqrt);
|
|
34
|
+
thread->bind("greeting", fn_greeting);
|
|
35
|
+
|
|
36
|
+
std::string out;
|
|
37
|
+
REQUIRE_NOTHROW(out = thread->getall());
|
|
38
|
+
THEN("Both function should be called the correct amount of times")
|
|
39
|
+
{
|
|
40
|
+
REQUIRE(
|
|
41
|
+
out
|
|
42
|
+
== "Hohooh ! A small demonstration of my power:\nMath 4 * 4 = 16, stunning i would "
|
|
43
|
+
"say\n"
|
|
44
|
+
);
|
|
45
|
+
REQUIRE(cnt_sqrt == 2);
|
|
46
|
+
REQUIRE(cnt_greeting == 1);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
WHEN("only bind function without fallback")
|
|
50
|
+
{
|
|
51
|
+
int cnt_sqrt = 0;
|
|
52
|
+
auto fn_sqrt = [&cnt_sqrt](int x) -> int {
|
|
53
|
+
++cnt_sqrt;
|
|
54
|
+
return sqrt(x);
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
thread->bind("sqrt", fn_sqrt);
|
|
58
|
+
|
|
59
|
+
std::string out;
|
|
60
|
+
REQUIRE_NOTHROW(out = thread->getall());
|
|
61
|
+
;
|
|
62
|
+
THEN("Sqrt should be falled twice, and uses default greeting")
|
|
63
|
+
{
|
|
64
|
+
REQUIRE(
|
|
65
|
+
out
|
|
66
|
+
== "Hello ! A small demonstration of my power:\nMath 4 * 4 = 16, stunning i would say\n"
|
|
67
|
+
);
|
|
68
|
+
REQUIRE(cnt_sqrt == 2);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
WHEN("bind no function")
|
|
72
|
+
{
|
|
73
|
+
std::string out;
|
|
74
|
+
REQUIRE_THROWS_AS(out = thread->getall(), ink::ink_exception);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
#include "catch.hpp"
|
|
2
|
+
|
|
3
|
+
#include <story.h>
|
|
4
|
+
#include <globals.h>
|
|
5
|
+
#include <runner.h>
|
|
6
|
+
#include <compiler.h>
|
|
7
|
+
|
|
8
|
+
using namespace ink::runtime;
|
|
9
|
+
|
|
10
|
+
SCENARIO("run story with global variable", "[global variables]")
|
|
11
|
+
{
|
|
12
|
+
GIVEN ("a story with global variables")
|
|
13
|
+
{
|
|
14
|
+
auto ink = story::from_file(INK_TEST_RESOURCE_DIR "GlobalStory.bin");
|
|
15
|
+
globals globStore = ink->new_globals();
|
|
16
|
+
runner thread = ink->new_runner(globStore);
|
|
17
|
+
|
|
18
|
+
WHEN( "just runs")
|
|
19
|
+
{
|
|
20
|
+
THEN("variables should contain values as in inkScript")
|
|
21
|
+
{
|
|
22
|
+
REQUIRE(thread->getall() == "My name is Jean Passepartout, but my friend's call me Jackie. I'm 23 years old.\nFoo:23\n");
|
|
23
|
+
REQUIRE(*globStore->get<int32_t>("age") == 23);
|
|
24
|
+
REQUIRE(*globStore->get<const char*>("friendly_name_of_player") == std::string{"Jackie"});
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
WHEN ("edit number")
|
|
28
|
+
{
|
|
29
|
+
bool resi
|
|
30
|
+
= globStore->set<int32_t>("age", 30);
|
|
31
|
+
bool resc
|
|
32
|
+
= globStore->set<const char*>("friendly_name_of_player", "Freddy");
|
|
33
|
+
THEN("execution should success")
|
|
34
|
+
{
|
|
35
|
+
REQUIRE(resi == true);
|
|
36
|
+
REQUIRE(resc == true);
|
|
37
|
+
}
|
|
38
|
+
THEN("variable should contain new value")
|
|
39
|
+
{
|
|
40
|
+
REQUIRE(thread->getall() == "My name is Jean Passepartout, but my friend's call me Freddy. I'm 30 years old.\nFoo:30\n");
|
|
41
|
+
REQUIRE(*globStore->get<int32_t>("age") == 30);
|
|
42
|
+
REQUIRE(*globStore->get<const char*>("friendly_name_of_player") == std::string{"Freddy"});
|
|
43
|
+
}
|
|
44
|
+
WHEN ("something added to string")
|
|
45
|
+
{
|
|
46
|
+
// concat in GlobalsStory.ink
|
|
47
|
+
thread->getall();
|
|
48
|
+
THEN("get should return the whole string")
|
|
49
|
+
{
|
|
50
|
+
REQUIRE(*globStore->get<const char*>("concat") == std::string{"Foo:30"});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
WHEN ("name or type not exist")
|
|
55
|
+
{
|
|
56
|
+
auto wrongType = globStore->get<uint32_t>("age");
|
|
57
|
+
auto notExistingName = globStore->get<int32_t>("foo");
|
|
58
|
+
THEN("should return nullptr")
|
|
59
|
+
{
|
|
60
|
+
REQUIRE(wrongType.has_value() == false);
|
|
61
|
+
REQUIRE(notExistingName.has_value() == false);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
bool rest = globStore->set<uint32_t>("age", 3);
|
|
65
|
+
bool resn = globStore->set<int32_t>("foo", 3);
|
|
66
|
+
THEN("should return false")
|
|
67
|
+
{
|
|
68
|
+
REQUIRE(rest == false);
|
|
69
|
+
REQUIRE(resn == false);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
#include "catch.hpp"
|
|
2
|
+
|
|
3
|
+
#include <story.h>
|
|
4
|
+
#include <globals.h>
|
|
5
|
+
#include <runner.h>
|
|
6
|
+
#include <compiler.h>
|
|
7
|
+
|
|
8
|
+
using namespace ink::runtime;
|
|
9
|
+
|
|
10
|
+
static constexpr const char* OUTPUT_PART_1 = "Once upon a time...\n";
|
|
11
|
+
static constexpr const char* OUTPUT_PART_2
|
|
12
|
+
= "There were two choices.\nThey lived happily ever after.\n";
|
|
13
|
+
static constexpr size_t CHOICE = 0;
|
|
14
|
+
|
|
15
|
+
SCENARIO("run inklecate 1.1.1 story")
|
|
16
|
+
{
|
|
17
|
+
auto compiler = GENERATE("inklecate", "inky");
|
|
18
|
+
GIVEN(compiler)
|
|
19
|
+
{
|
|
20
|
+
auto input_file = std::string(INK_TEST_RESOURCE_DIR "simple-1.1.1-") + compiler + ".json";
|
|
21
|
+
ink::compiler::run(input_file.c_str(), "simple.bin");
|
|
22
|
+
auto ink = story::from_file("simple.bin");
|
|
23
|
+
runner thread = ink->new_runner();
|
|
24
|
+
|
|
25
|
+
THEN("Expect normal output")
|
|
26
|
+
{
|
|
27
|
+
REQUIRE(thread->getall() == OUTPUT_PART_1);
|
|
28
|
+
REQUIRE(thread->has_choices());
|
|
29
|
+
REQUIRE(thread->num_choices() == 2);
|
|
30
|
+
thread->choose(CHOICE);
|
|
31
|
+
REQUIRE(thread->getall() == OUTPUT_PART_2);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
#include "catch.hpp"
|
|
2
|
+
|
|
3
|
+
#include <choice.h>
|
|
4
|
+
#include <compiler.h>
|
|
5
|
+
#include <globals.h>
|
|
6
|
+
#include <runner.h>
|
|
7
|
+
#include <story.h>
|
|
8
|
+
|
|
9
|
+
using namespace ink::runtime;
|
|
10
|
+
|
|
11
|
+
SCENARIO( "run story with hidden choice" )
|
|
12
|
+
{
|
|
13
|
+
GIVEN( "a story with choice visibale by second visit" )
|
|
14
|
+
{
|
|
15
|
+
auto ink = story::from_file(INK_TEST_RESOURCE_DIR "LabelConditionStory.bin");
|
|
16
|
+
globals globals = ink->new_globals();
|
|
17
|
+
runner thread = ink->new_runner( globals );
|
|
18
|
+
|
|
19
|
+
WHEN( "normal run" )
|
|
20
|
+
{
|
|
21
|
+
std::string out = thread->getall();
|
|
22
|
+
REQUIRE( thread->num_choices() == 1 );
|
|
23
|
+
std::string choice1a = thread->get_choice( 0 )->text();
|
|
24
|
+
thread->choose( 0 );
|
|
25
|
+
std::string out2 = thread->getall();
|
|
26
|
+
REQUIRE( thread->num_choices() == 1 );
|
|
27
|
+
std::string choice2a = thread->get_choice( 0 )->text();
|
|
28
|
+
|
|
29
|
+
THEN( "second choice keeps hidden" )
|
|
30
|
+
{
|
|
31
|
+
REQUIRE( out == "" );
|
|
32
|
+
REQUIRE( choice1a == "labeled choice" );
|
|
33
|
+
REQUIRE( out2 == "" );
|
|
34
|
+
REQUIRE( choice2a == "labeled choice" );
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
WHEN( "set global variable to enable hidden choice" )
|
|
39
|
+
{
|
|
40
|
+
globals->set<bool>( "bool_variable", false );
|
|
41
|
+
std::string out = thread->getall();
|
|
42
|
+
REQUIRE( thread->num_choices() == 1 );
|
|
43
|
+
std::string choice1a = thread->get_choice( 0 )->text();
|
|
44
|
+
thread->choose( 0 );
|
|
45
|
+
std::string out2 = thread->getall();
|
|
46
|
+
REQUIRE( thread->num_choices() == 2 );
|
|
47
|
+
std::string choice2a = thread->get_choice( 0 )->text();
|
|
48
|
+
std::string choice2b = thread->get_choice( 1 )->text();
|
|
49
|
+
|
|
50
|
+
THEN( "second choice is visible" )
|
|
51
|
+
{
|
|
52
|
+
REQUIRE( out == "" );
|
|
53
|
+
REQUIRE( choice1a == "labeled choice" );
|
|
54
|
+
REQUIRE( out2 == "" );
|
|
55
|
+
REQUIRE( choice2a == "labeled choice" );
|
|
56
|
+
REQUIRE( choice2b == "hidden choice" );
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|