inkcpp_rb 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- 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,144 @@
|
|
1
|
+
#include "catch.hpp"
|
2
|
+
|
3
|
+
#include <story.h>
|
4
|
+
#include <runner.h>
|
5
|
+
#include <globals.h>
|
6
|
+
#include <compiler.h>
|
7
|
+
#include <choice.h>
|
8
|
+
|
9
|
+
#include <string.h>
|
10
|
+
|
11
|
+
using namespace ink::runtime;
|
12
|
+
|
13
|
+
SCENARIO("List logic operations", "[lists]")
|
14
|
+
{
|
15
|
+
GIVEN("a demo story")
|
16
|
+
{
|
17
|
+
auto ink = story::from_file(INK_TEST_RESOURCE_DIR "ListLogicStory.bin");
|
18
|
+
runner thread = ink->new_runner();
|
19
|
+
WHEN("just run")
|
20
|
+
{
|
21
|
+
std::string out = thread->getall();
|
22
|
+
|
23
|
+
REQUIRE(out == R"==(A, C
|
24
|
+
yes
|
25
|
+
false
|
26
|
+
true
|
27
|
+
true
|
28
|
+
true
|
29
|
+
true
|
30
|
+
A
|
31
|
+
B
|
32
|
+
>B
|
33
|
+
>
|
34
|
+
> Z, A, B, C
|
35
|
+
>
|
36
|
+
>
|
37
|
+
B, C
|
38
|
+
>C > > >
|
39
|
+
>A, C >B >
|
40
|
+
>B
|
41
|
+
>
|
42
|
+
> >Z >A >
|
43
|
+
Hey
|
44
|
+
)==");
|
45
|
+
}
|
46
|
+
}
|
47
|
+
}
|
48
|
+
SCENARIO("run a story with lists", "[lists]")
|
49
|
+
{
|
50
|
+
GIVEN("a story with multi lists")
|
51
|
+
{
|
52
|
+
auto ink = story::from_file(INK_TEST_RESOURCE_DIR "ListStory.bin");
|
53
|
+
globals globals = ink->new_globals();
|
54
|
+
runner thread = ink->new_runner(globals);
|
55
|
+
|
56
|
+
WHEN("just run")
|
57
|
+
{
|
58
|
+
std::string out = thread->getall();
|
59
|
+
std::string choice1 = thread->get_choice(0)->text();
|
60
|
+
thread->choose(0);
|
61
|
+
std::string out2 = thread->getall();
|
62
|
+
THEN("should output expected")
|
63
|
+
{
|
64
|
+
REQUIRE(out == "cat, snake\n");
|
65
|
+
REQUIRE(choice1 == "list: bird, red, yellow");
|
66
|
+
REQUIRE(out2 == "list: bird, red, yellow\ncat, snake\nbird, red, yellow\n");
|
67
|
+
}
|
68
|
+
}
|
69
|
+
|
70
|
+
WHEN("modify with full flag name")
|
71
|
+
{
|
72
|
+
std::string out = thread->getall();
|
73
|
+
std::string choice1 = thread->get_choice(0)->text();
|
74
|
+
thread->choose(0);
|
75
|
+
|
76
|
+
list l1 = *globals->get<list>("list");
|
77
|
+
l1->add("animals.dog");
|
78
|
+
l1->remove("colors.red");
|
79
|
+
REQUIRE(globals->set<list>("list", l1));
|
80
|
+
|
81
|
+
std::string out2 = thread->getall();
|
82
|
+
|
83
|
+
THEN("Output should be changed")
|
84
|
+
{
|
85
|
+
REQUIRE(out2 == "list: bird, dog, yellow\ncat, snake\nbird, dog, yellow\n");
|
86
|
+
}
|
87
|
+
}
|
88
|
+
|
89
|
+
WHEN("modify")
|
90
|
+
{
|
91
|
+
std::string out = thread->getall();
|
92
|
+
std::string choice1 = thread->get_choice(0)->text();
|
93
|
+
thread->choose(0);
|
94
|
+
|
95
|
+
list l1 = *globals->get<list>("list");
|
96
|
+
l1->add("dog");
|
97
|
+
l1->remove("red");
|
98
|
+
REQUIRE(globals->set<list>("list", l1));
|
99
|
+
|
100
|
+
l1 = *globals->get<list>("animals");
|
101
|
+
l1->add("bird");
|
102
|
+
l1->add("dog");
|
103
|
+
l1->remove("snake");
|
104
|
+
l1->remove("cat");
|
105
|
+
l1->add("cat");
|
106
|
+
REQUIRE(globals->set<list>("animals", l1));
|
107
|
+
|
108
|
+
std::string out2 = thread->getall();
|
109
|
+
THEN("should output change")
|
110
|
+
{
|
111
|
+
REQUIRE(out == "cat, snake\n");
|
112
|
+
REQUIRE(choice1 == "list: bird, red, yellow");
|
113
|
+
// changing the list will also change the text of the repeated choice
|
114
|
+
REQUIRE(out2 == "list: bird, dog, yellow\nbird, cat, dog\nbird, dog, yellow\n");
|
115
|
+
}
|
116
|
+
|
117
|
+
THEN("list should contain things")
|
118
|
+
{
|
119
|
+
l1 = *globals->get<list>("list");
|
120
|
+
REQUIRE(l1->contains("bird"));
|
121
|
+
REQUIRE(l1->contains("dog"));
|
122
|
+
REQUIRE(l1->contains("yellow"));
|
123
|
+
|
124
|
+
REQUIRE_FALSE(l1->contains("cat"));
|
125
|
+
REQUIRE_FALSE(l1->contains("snake"));
|
126
|
+
REQUIRE_FALSE(l1->contains("blue"));
|
127
|
+
REQUIRE_FALSE(l1->contains("white"));
|
128
|
+
}
|
129
|
+
|
130
|
+
THEN("should iterate all contained flags")
|
131
|
+
{
|
132
|
+
l1 = *globals->get<list>("list");
|
133
|
+
for(auto flag : *l1) {
|
134
|
+
INFO(flag);
|
135
|
+
REQUIRE((strcmp(flag.list_name, "colors")==0 || strcmp(flag.list_name, "animals") == 0));
|
136
|
+
REQUIRE((strcmp(flag.flag_name, "bird") == 0
|
137
|
+
|| strcmp(flag.flag_name, "dog") == 0
|
138
|
+
|| strcmp(flag.flag_name, "yellow") == 0
|
139
|
+
));
|
140
|
+
}
|
141
|
+
}
|
142
|
+
}
|
143
|
+
}
|
144
|
+
}
|
@@ -0,0 +1,46 @@
|
|
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 external functions and glue", "[external]")
|
11
|
+
{
|
12
|
+
GIVEN("The story")
|
13
|
+
{
|
14
|
+
auto ink = story::from_file(INK_TEST_RESOURCE_DIR "LookaheadSafe.bin");
|
15
|
+
|
16
|
+
int cnt = 0;
|
17
|
+
auto foo = [&cnt]() {
|
18
|
+
cnt += 1;
|
19
|
+
};
|
20
|
+
WHEN("the function in lookahead save")
|
21
|
+
{
|
22
|
+
auto thread = ink->new_runner();
|
23
|
+
thread->bind("foo", foo, true);
|
24
|
+
std::string out = thread->getline();
|
25
|
+
REQUIRE(cnt == 3);
|
26
|
+
REQUIRE(out == "Call1 glued to Call 2\n");
|
27
|
+
out = thread->getline();
|
28
|
+
REQUIRE(out == "Call 3 is seperated\n");
|
29
|
+
REQUIRE(cnt == 4);
|
30
|
+
}
|
31
|
+
WHEN("the function is not lookahead save")
|
32
|
+
{
|
33
|
+
auto thread = ink->new_runner();
|
34
|
+
thread->bind("foo", foo, false);
|
35
|
+
std::string out = thread->getline();
|
36
|
+
REQUIRE(out == "Call1\n");
|
37
|
+
REQUIRE(cnt == 1);
|
38
|
+
out = thread->getline();
|
39
|
+
REQUIRE(out == "glued to Call 2\n");
|
40
|
+
REQUIRE(cnt == 2);
|
41
|
+
out = thread->getline();
|
42
|
+
REQUIRE(out == "Call 3 is seperated\n");
|
43
|
+
REQUIRE(cnt == 3);
|
44
|
+
}
|
45
|
+
}
|
46
|
+
}
|
@@ -0,0 +1,95 @@
|
|
1
|
+
#include "catch.hpp"
|
2
|
+
#include "system.h"
|
3
|
+
|
4
|
+
#include <story.h>
|
5
|
+
#include <globals.h>
|
6
|
+
#include <choice.h>
|
7
|
+
#include <runner.h>
|
8
|
+
|
9
|
+
using namespace ink::runtime;
|
10
|
+
|
11
|
+
SCENARIO("run a story, but jump around manually", "[move_to]")
|
12
|
+
{
|
13
|
+
GIVEN("a story with side talking points")
|
14
|
+
{
|
15
|
+
auto ink = story::from_file(INK_TEST_RESOURCE_DIR "MoveTo.bin");
|
16
|
+
globals globStore = ink->new_globals();
|
17
|
+
runner main = ink->new_runner(globStore);
|
18
|
+
runner side = ink->new_runner(globStore);
|
19
|
+
|
20
|
+
WHEN("just run main story")
|
21
|
+
{
|
22
|
+
THEN("expect normal output")
|
23
|
+
{
|
24
|
+
REQUIRE(
|
25
|
+
main->getall()
|
26
|
+
== "Lava kadaver a very boring introduction\nYou are head to head to the minister\n"
|
27
|
+
);
|
28
|
+
REQUIRE(main->num_choices() == 1);
|
29
|
+
REQUIRE(main->get_choice(0)->text() == std::string("Hellow mister menistery"));
|
30
|
+
main->choose(0);
|
31
|
+
REQUIRE(main->getall() == "Hellow mister menistery\nYou are head to head to the minister\nIt seems you are out of options, you shold give up\n");
|
32
|
+
}
|
33
|
+
}
|
34
|
+
|
35
|
+
WHEN("skip intorduction")
|
36
|
+
{
|
37
|
+
main->move_to(ink::hash_string("Dialog.core"));
|
38
|
+
THEN("expect output minus introduction")
|
39
|
+
{
|
40
|
+
REQUIRE(main->getall() == "You are head to head to the minister\n");
|
41
|
+
REQUIRE(main->num_choices() == 1);
|
42
|
+
REQUIRE(main->get_choice(0)->text() == std::string("Hellow mister menistery"));
|
43
|
+
main->choose(0);
|
44
|
+
REQUIRE(main->getall() == "Hellow mister menistery\nYou are head to head to the minister\nIt seems you are out of options, you shold give up\n");
|
45
|
+
}
|
46
|
+
}
|
47
|
+
|
48
|
+
WHEN("second runner is executed")
|
49
|
+
{
|
50
|
+
main->move_to(ink::hash_string("Dialog.core"));
|
51
|
+
side->move_to(ink::hash_string("Transformations.Nothing"));
|
52
|
+
THEN("normal main output, and side output")
|
53
|
+
{
|
54
|
+
REQUIRE(side->getall() == "Hard you could transform if you would like\n");
|
55
|
+
|
56
|
+
REQUIRE(main->getall() == "You are head to head to the minister\n");
|
57
|
+
REQUIRE(main->num_choices() == 1);
|
58
|
+
REQUIRE(main->get_choice(0)->text() == std::string("Hellow mister menistery"));
|
59
|
+
main->choose(0);
|
60
|
+
REQUIRE(main->getall() == "Hellow mister menistery\nYou are head to head to the minister\nIt seems you are out of options, you shold give up\n");
|
61
|
+
}
|
62
|
+
}
|
63
|
+
WHEN("second runner modifies value")
|
64
|
+
{
|
65
|
+
main->move_to(ink::hash_string("Dialog.core"));
|
66
|
+
side->move_to(ink::hash_string("Transformations.ToTiger"));
|
67
|
+
THEN("main thread output changes")
|
68
|
+
{
|
69
|
+
REQUIRE(side->getall() == "Your body growths, and growth, you feel the muscels building.\nAnd there you are, a tiger.\n");
|
70
|
+
REQUIRE(main->getall() == "You are head to head to the minister\n");
|
71
|
+
REQUIRE(main->num_choices() == 1);
|
72
|
+
REQUIRE(main->get_choice(0)->text() == std::string("Roar"));
|
73
|
+
main->choose(0);
|
74
|
+
REQUIRE(main->getall() == "Grrrrh, Roarrr\nThe people are quit confused\nYou are head to head to the minister\nIt seems you are out of options, you shold give up\n");
|
75
|
+
}
|
76
|
+
}
|
77
|
+
WHEN("execute mutliple small runners with sideeffects")
|
78
|
+
{
|
79
|
+
main->move_to(ink::hash_string("Dialog.core"));
|
80
|
+
side->move_to(ink::hash_string("Transformations.ToTiger"));
|
81
|
+
runner side2 = ink->new_runner(globStore);
|
82
|
+
side2->move_to(ink::hash_string("Transformations.ToOwl"));
|
83
|
+
THEN("side threads should influence each other")
|
84
|
+
{
|
85
|
+
REQUIRE(side2->getall() == "You Shrink and you get feathers. And, now you are a Owl\n");
|
86
|
+
REQUIRE(side->getall() == "Your body growths, and growth, you feel the muscels building.\nAnd there you are, a tiger.\nyou puke a few feathers, where are they coming from?\n");
|
87
|
+
REQUIRE(main->getall() == "You are head to head to the minister\n");
|
88
|
+
REQUIRE(main->num_choices() == 1);
|
89
|
+
REQUIRE(main->get_choice(0)->text() == std::string("Roar"));
|
90
|
+
main->choose(0);
|
91
|
+
REQUIRE(main->getall() == "Grrrrh, Roarrr\nThe people are quit confused\nYou are head to head to the minister\nIt seems you are out of options, you shold give up\n");
|
92
|
+
}
|
93
|
+
}
|
94
|
+
}
|
95
|
+
}
|
@@ -0,0 +1,76 @@
|
|
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 has the proper line breaks", "[lines]")
|
11
|
+
{
|
12
|
+
GIVEN("a story with line breaks")
|
13
|
+
{
|
14
|
+
auto ink = story::from_file(INK_TEST_RESOURCE_DIR "LinesStory.bin");
|
15
|
+
runner thread = ink->new_runner();
|
16
|
+
WHEN("start thread")
|
17
|
+
{
|
18
|
+
THEN("thread can continue") { REQUIRE(thread->can_continue()); }
|
19
|
+
WHEN("consume lines")
|
20
|
+
{
|
21
|
+
std::string line1 = thread->getline();
|
22
|
+
std::string line2 = thread->getline();
|
23
|
+
std::string line3 = thread->getline();
|
24
|
+
std::string line4 = thread->getline();
|
25
|
+
THEN("lines are correct")
|
26
|
+
{
|
27
|
+
REQUIRE(line1 == "Line 1\n");
|
28
|
+
REQUIRE(line2 == "Line 2\n");
|
29
|
+
REQUIRE(line3 == "Line 3\n");
|
30
|
+
REQUIRE(line4 == "Line 4\n");
|
31
|
+
}
|
32
|
+
}
|
33
|
+
WHEN("consume lines with functions")
|
34
|
+
{
|
35
|
+
thread->move_to(ink::hash_string("Functions"));
|
36
|
+
std::string line1 = thread->getline();
|
37
|
+
std::string line2 = thread->getline();
|
38
|
+
|
39
|
+
THEN("function lines are correct")
|
40
|
+
{
|
41
|
+
REQUIRE(line1 == "Function Line\n");
|
42
|
+
REQUIRE(line2 == "Function Result\n");
|
43
|
+
}
|
44
|
+
}
|
45
|
+
WHEN("consume lines with tunnels")
|
46
|
+
{
|
47
|
+
thread->move_to(ink::hash_string("Tunnels"));
|
48
|
+
std::string line1 = thread->getline();
|
49
|
+
std::string line2 = thread->getline();
|
50
|
+
|
51
|
+
THEN("tunnel lines are correct")
|
52
|
+
{
|
53
|
+
REQUIRE(line1 == "Tunnel Line\n");
|
54
|
+
REQUIRE(line2 == "Tunnel Result\n");
|
55
|
+
}
|
56
|
+
|
57
|
+
THEN("thread cannot continue") { REQUIRE(! thread->can_continue()); }
|
58
|
+
}
|
59
|
+
}
|
60
|
+
}
|
61
|
+
GIVEN("a complex story")
|
62
|
+
{
|
63
|
+
auto ink = story::from_file(INK_TEST_RESOURCE_DIR "TheIntercept.bin");
|
64
|
+
runner thread = ink->new_runner();
|
65
|
+
// based on issue #82
|
66
|
+
WHEN("run sequence 1 3 3 3 2 3")
|
67
|
+
{
|
68
|
+
for (int i : {1, 3, 3, 3, 2, 3}) {
|
69
|
+
thread->getall();
|
70
|
+
thread->choose(i - 1);
|
71
|
+
}
|
72
|
+
std::string text = thread->getall();
|
73
|
+
THEN("no newline before dot") { REQUIRE(text == "\"I don't see why,\" I reply.\n"); }
|
74
|
+
}
|
75
|
+
}
|
76
|
+
}
|
@@ -0,0 +1,33 @@
|
|
1
|
+
#include "catch.hpp"
|
2
|
+
|
3
|
+
#include <compiler.h>
|
4
|
+
#include <globals.h>
|
5
|
+
#include <runner.h>
|
6
|
+
#include <story.h>
|
7
|
+
|
8
|
+
using namespace ink::runtime;
|
9
|
+
|
10
|
+
SCENARIO("Story with tags and glues", "[glue, tags]")
|
11
|
+
{
|
12
|
+
GIVEN("lines intersected with tags and glue")
|
13
|
+
{
|
14
|
+
auto ink = story::from_file(INK_TEST_RESOURCE_DIR "NoEarlyTags.bin");
|
15
|
+
auto thread = ink->new_runner();
|
16
|
+
WHEN("no glue")
|
17
|
+
{
|
18
|
+
std::string out = thread->getline();
|
19
|
+
REQUIRE(out == "Hey there, nice to meet you!\n");
|
20
|
+
REQUIRE(thread->num_tags() == 2);
|
21
|
+
}
|
22
|
+
WHEN("glue: tags will stop lookahead")
|
23
|
+
{
|
24
|
+
thread->getline();
|
25
|
+
std::string out = thread->getline();
|
26
|
+
REQUIRE(out == "Hey, I'm Hey and this is YOU, nice to meet you too!\n");
|
27
|
+
REQUIRE(thread->num_tags() == 3);
|
28
|
+
out = thread->getline();
|
29
|
+
REQUIRE(out == "I'm Do! Most people can't pronounce it, just think 'Kee-vah\".\n");
|
30
|
+
REQUIRE(thread->num_tags() == 5);
|
31
|
+
}
|
32
|
+
}
|
33
|
+
}
|
@@ -0,0 +1,245 @@
|
|
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("Observer", "[variables]")
|
12
|
+
{
|
13
|
+
GIVEN("a story which changes variables")
|
14
|
+
{
|
15
|
+
auto ink = story::from_file(INK_TEST_RESOURCE_DIR "ObserverStory.bin");
|
16
|
+
auto globals = ink->new_globals();
|
17
|
+
runner thread = ink->new_runner(globals);
|
18
|
+
WHEN("Run without observers")
|
19
|
+
{
|
20
|
+
std::string out = thread->getall();
|
21
|
+
REQUIRE(out == "hello line 1 1 hello line 2 5 test line 3 5\n");
|
22
|
+
}
|
23
|
+
WHEN("Run with observers read only, with specific type")
|
24
|
+
{
|
25
|
+
int var1_cnt = 0;
|
26
|
+
auto var1 = [&var1_cnt](int32_t i) {
|
27
|
+
if (var1_cnt++ == 0) {
|
28
|
+
REQUIRE(i == 1);
|
29
|
+
} else {
|
30
|
+
REQUIRE(i == 5);
|
31
|
+
}
|
32
|
+
};
|
33
|
+
int var2_cnt = 0;
|
34
|
+
auto var2 = [&var2_cnt](const char* s) {
|
35
|
+
std::string str(s);
|
36
|
+
if (var2_cnt++ == 0) {
|
37
|
+
REQUIRE(str == "hello");
|
38
|
+
} else {
|
39
|
+
REQUIRE(str == "test");
|
40
|
+
}
|
41
|
+
};
|
42
|
+
|
43
|
+
globals->observe("var1", var1);
|
44
|
+
globals->observe("var2", var2);
|
45
|
+
std::string out = thread->getall();
|
46
|
+
|
47
|
+
REQUIRE(out == "hello line 1 1 hello line 2 5 test line 3 5\n");
|
48
|
+
REQUIRE(var1_cnt == 2);
|
49
|
+
REQUIRE(var2_cnt == 2);
|
50
|
+
}
|
51
|
+
WHEN("Run with generic observer")
|
52
|
+
{
|
53
|
+
int var1_cnt = 0;
|
54
|
+
auto var1 = [&var1_cnt](value v) {
|
55
|
+
REQUIRE(v.type == value::Type::Int32);
|
56
|
+
if (var1_cnt++ == 0) {
|
57
|
+
REQUIRE(v.get<value::Type::Int32>() == 1);
|
58
|
+
} else {
|
59
|
+
REQUIRE(v.get<value::Type::Int32>() == 5);
|
60
|
+
}
|
61
|
+
};
|
62
|
+
int var2_cnt = 0;
|
63
|
+
auto var2 = [&var2_cnt](value v) {
|
64
|
+
REQUIRE(v.type == value::Type::String);
|
65
|
+
std::string str(v.get<value::Type::String>());
|
66
|
+
if (var2_cnt++ == 0) {
|
67
|
+
REQUIRE(str == "hello");
|
68
|
+
} else {
|
69
|
+
REQUIRE(str == "test");
|
70
|
+
}
|
71
|
+
};
|
72
|
+
|
73
|
+
globals->observe("var1", var1);
|
74
|
+
globals->observe("var2", var2);
|
75
|
+
std::string out = thread->getall();
|
76
|
+
|
77
|
+
REQUIRE(out == "hello line 1 1 hello line 2 5 test line 3 5\n");
|
78
|
+
REQUIRE(var1_cnt == 2);
|
79
|
+
REQUIRE(var2_cnt == 2);
|
80
|
+
}
|
81
|
+
WHEN("Bind multiple observer to same variables")
|
82
|
+
{
|
83
|
+
int var1_cnt = 0;
|
84
|
+
auto var1 = [&var1_cnt](int32_t i) {
|
85
|
+
if (var1_cnt++ < 2) {
|
86
|
+
REQUIRE(i == 1);
|
87
|
+
} else {
|
88
|
+
REQUIRE(i == 5);
|
89
|
+
}
|
90
|
+
};
|
91
|
+
globals->observe("var1", var1);
|
92
|
+
globals->observe("var1", var1);
|
93
|
+
std::string out = thread->getall();
|
94
|
+
|
95
|
+
REQUIRE(out == "hello line 1 1 hello line 2 5 test line 3 5\n");
|
96
|
+
REQUIRE(var1_cnt == 4);
|
97
|
+
}
|
98
|
+
WHEN("Run with missmatching type")
|
99
|
+
{
|
100
|
+
auto var1 = [](uint32_t i) {
|
101
|
+
};
|
102
|
+
CHECK_THROWS(globals->observe("var1", var1));
|
103
|
+
}
|
104
|
+
WHEN("Just get pinged")
|
105
|
+
{
|
106
|
+
int var1_cnt = 0;
|
107
|
+
auto var1 = [&var1_cnt]() {
|
108
|
+
var1_cnt++;
|
109
|
+
};
|
110
|
+
globals->observe("var1", var1);
|
111
|
+
std::string out = thread->getall();
|
112
|
+
|
113
|
+
REQUIRE(out == "hello line 1 1 hello line 2 5 test line 3 5\n");
|
114
|
+
REQUIRE(var1_cnt == 2);
|
115
|
+
}
|
116
|
+
WHEN("call with new and old value")
|
117
|
+
{
|
118
|
+
int var1_cnt = 0;
|
119
|
+
auto var1 = [&var1_cnt](int32_t i, ink::optional<int32_t> o_i) {
|
120
|
+
if (var1_cnt++ == 0) {
|
121
|
+
REQUIRE(i == 1);
|
122
|
+
REQUIRE_FALSE(o_i.has_value());
|
123
|
+
} else {
|
124
|
+
REQUIRE(i == 5);
|
125
|
+
REQUIRE(o_i.has_value());
|
126
|
+
REQUIRE(o_i.value() == 1);
|
127
|
+
}
|
128
|
+
};
|
129
|
+
|
130
|
+
int var2_cnt = 0;
|
131
|
+
auto var2 = [&var2_cnt](value v, ink::optional<value> o_v) {
|
132
|
+
REQUIRE(v.type == value::Type::String);
|
133
|
+
std::string str(v.get<value::Type::String>());
|
134
|
+
if (var2_cnt++ == 0) {
|
135
|
+
REQUIRE(str == "hello");
|
136
|
+
REQUIRE_FALSE(o_v.has_value());
|
137
|
+
} else {
|
138
|
+
REQUIRE(str == "test");
|
139
|
+
REQUIRE(o_v.has_value());
|
140
|
+
REQUIRE(o_v.value().type == value::Type::String);
|
141
|
+
std::string str2(o_v.value().get<value::Type::String>());
|
142
|
+
REQUIRE(str2 == "hello");
|
143
|
+
}
|
144
|
+
};
|
145
|
+
|
146
|
+
globals->observe("var1", var1);
|
147
|
+
globals->observe("var2", var2);
|
148
|
+
std::string out = thread->getall();
|
149
|
+
|
150
|
+
REQUIRE(out == "hello line 1 1 hello line 2 5 test line 3 5\n");
|
151
|
+
REQUIRE(var1_cnt == 2);
|
152
|
+
REQUIRE(var2_cnt == 2);
|
153
|
+
}
|
154
|
+
WHEN("Changing Same value at runtime")
|
155
|
+
{
|
156
|
+
int var1_cnt = 0;
|
157
|
+
auto var1 = [&var1_cnt, &globals](int32_t i) {
|
158
|
+
++var1_cnt;
|
159
|
+
if (var1_cnt == 1) {
|
160
|
+
REQUIRE(i == 1);
|
161
|
+
} else if (var1_cnt == 2) {
|
162
|
+
REQUIRE(i == 5);
|
163
|
+
globals->set<int32_t>("var1", 8);
|
164
|
+
} else if (var1_cnt == 3) {
|
165
|
+
REQUIRE(i == 8);
|
166
|
+
}
|
167
|
+
};
|
168
|
+
globals->observe("var1", var1);
|
169
|
+
std::string out = thread->getall();
|
170
|
+
|
171
|
+
REQUIRE(8 == globals->get<int32_t>("var1").value());
|
172
|
+
REQUIRE(out == "hello line 1 1 hello line 2 8 test line 3 8\n");
|
173
|
+
REQUIRE(var1_cnt == 3);
|
174
|
+
}
|
175
|
+
WHEN("Changing Sam value at bind time")
|
176
|
+
{
|
177
|
+
int var1_cnt = 0;
|
178
|
+
auto var1 = [&var1_cnt, &globals](int32_t i) {
|
179
|
+
++var1_cnt;
|
180
|
+
if (var1_cnt == 1) {
|
181
|
+
REQUIRE(i == 1);
|
182
|
+
globals->set<int32_t>("var1", 8);
|
183
|
+
} else if (var1_cnt == 2) {
|
184
|
+
REQUIRE(i == 8);
|
185
|
+
} else if (var1_cnt == 3) {
|
186
|
+
REQUIRE(i == 5);
|
187
|
+
}
|
188
|
+
};
|
189
|
+
globals->observe("var1", var1);
|
190
|
+
std::string out = thread->getall();
|
191
|
+
|
192
|
+
REQUIRE(5 == globals->get<int32_t>("var1").value());
|
193
|
+
REQUIRE(out == "hello line 1 8 hello line 2 5 test line 3 5\n");
|
194
|
+
REQUIRE(var1_cnt == 3);
|
195
|
+
}
|
196
|
+
WHEN("Changing Same value multiple times")
|
197
|
+
{
|
198
|
+
int var1_cnt = 0;
|
199
|
+
auto var1 = [&var1_cnt, &globals](int32_t i) {
|
200
|
+
++var1_cnt;
|
201
|
+
if (var1_cnt == 1) {
|
202
|
+
REQUIRE(i == 1);
|
203
|
+
globals->set<int32_t>("var1", 8);
|
204
|
+
} else if (var1_cnt == 2) {
|
205
|
+
REQUIRE(i == 8);
|
206
|
+
globals->set<int32_t>("var1", 10);
|
207
|
+
} else if (var1_cnt == 3) {
|
208
|
+
REQUIRE(i == 10);
|
209
|
+
} else if (var1_cnt == 4) {
|
210
|
+
REQUIRE(i == 5);
|
211
|
+
}
|
212
|
+
};
|
213
|
+
globals->observe("var1", var1);
|
214
|
+
std::string out = thread->getall();
|
215
|
+
|
216
|
+
REQUIRE(5 == globals->get<int32_t>("var1").value());
|
217
|
+
REQUIRE(out == "hello line 1 10 hello line 2 5 test line 3 5\n");
|
218
|
+
REQUIRE(var1_cnt == 4);
|
219
|
+
}
|
220
|
+
WHEN("Changing Other value")
|
221
|
+
{
|
222
|
+
int var1_cnt = 0;
|
223
|
+
auto var1 = [&var1_cnt, &globals](int32_t i) {
|
224
|
+
if (var1_cnt++ == 0) {
|
225
|
+
REQUIRE(i == 1);
|
226
|
+
} else {
|
227
|
+
REQUIRE(i == 5);
|
228
|
+
globals->set<const char*>("var2", "didum");
|
229
|
+
}
|
230
|
+
};
|
231
|
+
int var2_cnt = 0;
|
232
|
+
auto var2 = [&var2_cnt]() {
|
233
|
+
++var2_cnt;
|
234
|
+
};
|
235
|
+
|
236
|
+
globals->observe("var1", var1);
|
237
|
+
globals->observe("var2", var2);
|
238
|
+
std::string out = thread->getall();
|
239
|
+
|
240
|
+
REQUIRE(out == "hello line 1 1 didum line 2 5 test line 3 5\n");
|
241
|
+
REQUIRE(var1_cnt == 2);
|
242
|
+
REQUIRE(var2_cnt == 3);
|
243
|
+
}
|
244
|
+
}
|
245
|
+
}
|