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,344 @@
|
|
1
|
+
#include "inkcpp.h"
|
2
|
+
#include "list.h"
|
3
|
+
#include "system.h"
|
4
|
+
#include "types.h"
|
5
|
+
|
6
|
+
#include <cstring>
|
7
|
+
|
8
|
+
#include <story.h>
|
9
|
+
#include <snapshot.h>
|
10
|
+
#include <globals.h>
|
11
|
+
#include <runner.h>
|
12
|
+
#include <choice.h>
|
13
|
+
#include <compiler.h>
|
14
|
+
|
15
|
+
using namespace ink::runtime;
|
16
|
+
|
17
|
+
InkValue inkvar_to_c(value& val)
|
18
|
+
{
|
19
|
+
switch (val.type) {
|
20
|
+
case value::Type::Bool:
|
21
|
+
return InkValue{
|
22
|
+
.bool_v = val.get<value::Type::Bool>(),
|
23
|
+
.type = InkValue::ValueTypeBool,
|
24
|
+
};
|
25
|
+
case value::Type::Uint32:
|
26
|
+
return InkValue{
|
27
|
+
.uint32_v = val.get<value::Type::Uint32>(),
|
28
|
+
.type = InkValue::ValueTypeUint32,
|
29
|
+
};
|
30
|
+
case value::Type::Int32:
|
31
|
+
return InkValue{
|
32
|
+
.int32_v = val.get<value::Type::Int32>(),
|
33
|
+
.type = InkValue::ValueTypeInt32,
|
34
|
+
};
|
35
|
+
case value::Type::String:
|
36
|
+
return InkValue{
|
37
|
+
.string_v = val.get<value::Type::String>(),
|
38
|
+
.type = InkValue::ValueTypeString,
|
39
|
+
};
|
40
|
+
case value::Type::Float:
|
41
|
+
return InkValue{
|
42
|
+
.float_v = val.get<value::Type::Float>(),
|
43
|
+
.type = InkValue::ValueTypeFloat,
|
44
|
+
};
|
45
|
+
case value::Type::List:
|
46
|
+
return InkValue{
|
47
|
+
.list_v = reinterpret_cast<HInkList*>(val.get<value::Type::List>()),
|
48
|
+
.type = InkValue::ValueTypeList,
|
49
|
+
};
|
50
|
+
}
|
51
|
+
inkFail("Undefined value type can not be translated");
|
52
|
+
return InkValue{};
|
53
|
+
}
|
54
|
+
|
55
|
+
value inkvar_from_c(InkValue& val)
|
56
|
+
{
|
57
|
+
switch (val.type) {
|
58
|
+
case InkValue::ValueTypeBool: return value(val.bool_v);
|
59
|
+
case InkValue::ValueTypeUint32: return value(val.uint32_v);
|
60
|
+
case InkValue::ValueTypeInt32: return value(val.int32_v);
|
61
|
+
case InkValue::ValueTypeString: return value(val.string_v);
|
62
|
+
case InkValue::ValueTypeFloat: return value(val.float_v);
|
63
|
+
case InkValue::ValueTypeList: return value(reinterpret_cast<list_interface*>(val.list_v));
|
64
|
+
case InkValue::ValueTypeNone: break;
|
65
|
+
}
|
66
|
+
inkFail("Undefined value type can not be translated");
|
67
|
+
return value{};
|
68
|
+
}
|
69
|
+
|
70
|
+
extern "C" {
|
71
|
+
HInkSnapshot* ink_snapshot_from_file(const char* filename)
|
72
|
+
{
|
73
|
+
return reinterpret_cast<HInkSnapshot*>(snapshot::from_file(filename));
|
74
|
+
}
|
75
|
+
|
76
|
+
int ink_snapshot_num_runners(const HInkSnapshot* self)
|
77
|
+
{
|
78
|
+
return reinterpret_cast<const snapshot*>(self)->num_runners();
|
79
|
+
}
|
80
|
+
|
81
|
+
void ink_snapshot_write_to_file(const HInkSnapshot* self, const char* filename)
|
82
|
+
{
|
83
|
+
reinterpret_cast<const snapshot*>(self)->write_to_file(filename);
|
84
|
+
}
|
85
|
+
|
86
|
+
const char* ink_choice_text(const HInkChoice* self)
|
87
|
+
{
|
88
|
+
return reinterpret_cast<const choice*>(self)->text();
|
89
|
+
}
|
90
|
+
|
91
|
+
int ink_choice_num_tags(const HInkChoice* self)
|
92
|
+
{
|
93
|
+
return reinterpret_cast<const choice*>(self)->num_tags();
|
94
|
+
}
|
95
|
+
|
96
|
+
const char* ink_choice_get_tag(const HInkChoice* self, int tag_id)
|
97
|
+
{
|
98
|
+
return reinterpret_cast<const choice*>(self)->get_tag(tag_id);
|
99
|
+
}
|
100
|
+
|
101
|
+
void ink_list_add(HInkList* self, const char* flag_name)
|
102
|
+
{
|
103
|
+
reinterpret_cast<list>(self)->add(flag_name);
|
104
|
+
}
|
105
|
+
|
106
|
+
void ink_list_remove(HInkList* self, const char* flag_name)
|
107
|
+
{
|
108
|
+
reinterpret_cast<list>(self)->remove(flag_name);
|
109
|
+
}
|
110
|
+
|
111
|
+
int ink_list_contains(const HInkList* self, const char* flag_name)
|
112
|
+
{
|
113
|
+
return reinterpret_cast<const list_interface*>(self)->contains(flag_name);
|
114
|
+
}
|
115
|
+
|
116
|
+
int ink_list_flags(const HInkList* self, InkListIter* iter)
|
117
|
+
{
|
118
|
+
list_interface::iterator itr = reinterpret_cast<const list_interface*>(self)->begin();
|
119
|
+
*iter = InkListIter{
|
120
|
+
._data = &itr._list,
|
121
|
+
._i = itr._i,
|
122
|
+
._single_list = itr._one_list_iterator,
|
123
|
+
.flag_name = itr._flag_name,
|
124
|
+
.list_name = itr._list_name,
|
125
|
+
};
|
126
|
+
return itr != reinterpret_cast<const list_interface*>(self)->end();
|
127
|
+
}
|
128
|
+
|
129
|
+
int ink_list_flags_from(const HInkList* self, const char* list_name, InkListIter* iter)
|
130
|
+
{
|
131
|
+
list_interface::iterator itr = reinterpret_cast<const list_interface*>(self)->begin(list_name);
|
132
|
+
*iter = InkListIter{
|
133
|
+
._data = &itr._list,
|
134
|
+
._i = itr._i,
|
135
|
+
._single_list = itr._one_list_iterator,
|
136
|
+
.flag_name = itr._flag_name,
|
137
|
+
.list_name = itr._list_name,
|
138
|
+
};
|
139
|
+
return itr != reinterpret_cast<const list_interface*>(self)->end();
|
140
|
+
}
|
141
|
+
|
142
|
+
int ink_list_iter_next(InkListIter* self)
|
143
|
+
{
|
144
|
+
list_interface::iterator itr(
|
145
|
+
self->flag_name, *reinterpret_cast<const list_interface*>(self->_data), self->_i,
|
146
|
+
self->_single_list
|
147
|
+
);
|
148
|
+
++itr;
|
149
|
+
self->flag_name = itr._flag_name;
|
150
|
+
self->list_name = itr._list_name;
|
151
|
+
self->_i = itr._i;
|
152
|
+
return itr != itr._list.end();
|
153
|
+
}
|
154
|
+
|
155
|
+
void ink_runner_delete(HInkRunner* self) { delete reinterpret_cast<const runner*>(self); }
|
156
|
+
|
157
|
+
HInkSnapshot* ink_runner_create_snapshot(const HInkRunner* self)
|
158
|
+
{
|
159
|
+
return reinterpret_cast<HInkSnapshot*>(
|
160
|
+
reinterpret_cast<const runner*>(self)->get()->create_snapshot()
|
161
|
+
);
|
162
|
+
}
|
163
|
+
|
164
|
+
int ink_runner_can_continue(const HInkRunner* self)
|
165
|
+
{
|
166
|
+
return reinterpret_cast<const runner*>(self)->get()->can_continue();
|
167
|
+
}
|
168
|
+
|
169
|
+
const char* ink_runner_get_line(HInkRunner* self)
|
170
|
+
{
|
171
|
+
return reinterpret_cast<runner*>(self)->get()->getline_alloc();
|
172
|
+
}
|
173
|
+
|
174
|
+
int ink_runner_get_num_tags(const HInkRunner* self)
|
175
|
+
{
|
176
|
+
return reinterpret_cast<const runner*>(self)->get()->num_tags();
|
177
|
+
}
|
178
|
+
|
179
|
+
const char* ink_runner_tag(const HInkRunner* self, int tag_id)
|
180
|
+
{
|
181
|
+
return reinterpret_cast<const runner*>(self)->get()->get_tag(tag_id);
|
182
|
+
}
|
183
|
+
|
184
|
+
int ink_runner_num_choices(const HInkRunner* self)
|
185
|
+
{
|
186
|
+
return reinterpret_cast<const runner*>(self)->get()->num_choices();
|
187
|
+
}
|
188
|
+
|
189
|
+
const HInkChoice* ink_runner_get_choice(const HInkRunner* self, int choice_id)
|
190
|
+
{
|
191
|
+
return reinterpret_cast<const HInkChoice*>(
|
192
|
+
reinterpret_cast<const runner*>(self)->get()->get_choice(choice_id)
|
193
|
+
);
|
194
|
+
}
|
195
|
+
|
196
|
+
void ink_runner_choose(HInkRunner* self, int choice_id)
|
197
|
+
{
|
198
|
+
return reinterpret_cast<runner*>(self)->get()->choose(choice_id);
|
199
|
+
}
|
200
|
+
|
201
|
+
void ink_runner_bind_void(
|
202
|
+
HInkRunner* self, const char* function_name, InkExternalFunctionVoid callback,
|
203
|
+
int lookaheadSafe
|
204
|
+
)
|
205
|
+
{
|
206
|
+
static_assert(sizeof(ink::runtime::value) >= sizeof(InkValue));
|
207
|
+
return reinterpret_cast<runner*>(self)->get()->bind(
|
208
|
+
function_name,
|
209
|
+
[callback](size_t len, const value* vals) {
|
210
|
+
InkValue* c_vals = reinterpret_cast<InkValue*>(const_cast<value*>(vals));
|
211
|
+
int c_len = len;
|
212
|
+
for (int i = 0; i < c_len; ++i) {
|
213
|
+
c_vals[i] = inkvar_to_c(const_cast<value&>(vals[i]));
|
214
|
+
}
|
215
|
+
callback(c_len, c_vals);
|
216
|
+
},
|
217
|
+
lookaheadSafe
|
218
|
+
);
|
219
|
+
}
|
220
|
+
|
221
|
+
void ink_runner_bind(
|
222
|
+
HInkRunner* self, const char* function_name, InkExternalFunction callback, int lookaheadSafe
|
223
|
+
)
|
224
|
+
{
|
225
|
+
static_assert(sizeof(ink::runtime::value) >= sizeof(InkValue));
|
226
|
+
return reinterpret_cast<runner*>(self)->get()->bind(
|
227
|
+
function_name,
|
228
|
+
[callback](size_t len, const value* vals) -> value {
|
229
|
+
InkValue* c_vals = reinterpret_cast<InkValue*>(const_cast<value*>(vals));
|
230
|
+
int c_len = len;
|
231
|
+
for (int i = 0; i < c_len; ++i) {
|
232
|
+
c_vals[i] = inkvar_to_c(const_cast<value&>(vals[i]));
|
233
|
+
}
|
234
|
+
InkValue res = callback(c_len, c_vals);
|
235
|
+
return inkvar_from_c(res);
|
236
|
+
},
|
237
|
+
lookaheadSafe
|
238
|
+
);
|
239
|
+
}
|
240
|
+
|
241
|
+
void ink_globals_delete(HInkGlobals* self) { delete reinterpret_cast<globals*>(self); }
|
242
|
+
|
243
|
+
HInkSnapshot* ink_globals_create_snapshot(const HInkGlobals* self)
|
244
|
+
{
|
245
|
+
return reinterpret_cast<HInkSnapshot*>(
|
246
|
+
reinterpret_cast<const globals*>(self)->get()->create_snapshot()
|
247
|
+
);
|
248
|
+
}
|
249
|
+
|
250
|
+
void ink_globals_observe(HInkGlobals* self, const char* variable_name, InkObserver observer)
|
251
|
+
{
|
252
|
+
reinterpret_cast<globals*>(self)->get()->observe(
|
253
|
+
variable_name,
|
254
|
+
[observer](value new_value, ink::optional<value> old_value) {
|
255
|
+
observer(
|
256
|
+
inkvar_to_c(new_value), old_value.has_value()
|
257
|
+
? inkvar_to_c(old_value.value())
|
258
|
+
: InkValue{.type = InkValue::Type::ValueTypeNone}
|
259
|
+
);
|
260
|
+
}
|
261
|
+
);
|
262
|
+
}
|
263
|
+
|
264
|
+
InkValue ink_globals_get(const HInkGlobals* self, const char* variable_name)
|
265
|
+
{
|
266
|
+
ink::optional<value> o_val
|
267
|
+
= reinterpret_cast<const globals*>(self)->get()->get<value>(variable_name);
|
268
|
+
if (! o_val.has_value()) {
|
269
|
+
return InkValue{
|
270
|
+
.type = InkValue::ValueTypeNone,
|
271
|
+
};
|
272
|
+
} else {
|
273
|
+
return inkvar_to_c(o_val.value());
|
274
|
+
}
|
275
|
+
}
|
276
|
+
|
277
|
+
int ink_globals_set(HInkGlobals* self, const char* variable_name, InkValue val)
|
278
|
+
{
|
279
|
+
return reinterpret_cast<globals*>(self)->get()->set(variable_name, inkvar_from_c(val));
|
280
|
+
}
|
281
|
+
|
282
|
+
HInkStory* ink_story_from_file(const char* filename)
|
283
|
+
{
|
284
|
+
return reinterpret_cast<HInkStory*>(story::from_file(filename));
|
285
|
+
}
|
286
|
+
|
287
|
+
void ink_story_delete(HInkStory* self) { delete reinterpret_cast<story*>(self); }
|
288
|
+
|
289
|
+
HInkRunner* ink_story_new_runner(HInkStory* self, HInkGlobals* global_store)
|
290
|
+
{
|
291
|
+
runner* res = new runner(
|
292
|
+
global_store
|
293
|
+
? reinterpret_cast<story*>(self)->new_runner(*reinterpret_cast<globals*>(global_store))
|
294
|
+
: reinterpret_cast<story*>(self)->new_runner()
|
295
|
+
);
|
296
|
+
return reinterpret_cast<HInkRunner*>(res);
|
297
|
+
}
|
298
|
+
|
299
|
+
HInkRunner* ink_story_new_runner_from_snapshot(
|
300
|
+
HInkStory* self, const HInkSnapshot* snapshot, HInkGlobals* global_store, int runner_id
|
301
|
+
)
|
302
|
+
{
|
303
|
+
const ink::runtime::snapshot& snap = *reinterpret_cast<const ink::runtime::snapshot*>(snapshot);
|
304
|
+
runner* res = new runner(
|
305
|
+
global_store
|
306
|
+
? reinterpret_cast<story*>(self)->new_runner_from_snapshot(
|
307
|
+
snap, *reinterpret_cast<globals*>(global_store), runner_id
|
308
|
+
)
|
309
|
+
: reinterpret_cast<story*>(self)->new_runner_from_snapshot(snap, nullptr, runner_id)
|
310
|
+
);
|
311
|
+
return reinterpret_cast<HInkRunner*>(res);
|
312
|
+
}
|
313
|
+
|
314
|
+
HInkGlobals* ink_story_new_globals(HInkStory* self)
|
315
|
+
{
|
316
|
+
return reinterpret_cast<HInkGlobals*>(new globals(reinterpret_cast<story*>(self)->new_globals())
|
317
|
+
);
|
318
|
+
}
|
319
|
+
|
320
|
+
HInkGlobals* ink_story_new_globals_from_snapshot(HInkStory* self, const HInkSnapshot* snap)
|
321
|
+
{
|
322
|
+
return reinterpret_cast<HInkGlobals*>(
|
323
|
+
new globals(reinterpret_cast<story*>(self)->new_globals_from_snapshot(
|
324
|
+
*reinterpret_cast<const snapshot*>(snap)
|
325
|
+
))
|
326
|
+
);
|
327
|
+
}
|
328
|
+
|
329
|
+
void ink_compile_json(const char* input_filename, const char* output_filename, const char** error)
|
330
|
+
{
|
331
|
+
ink::compiler::compilation_results result;
|
332
|
+
ink::compiler::run(input_filename, output_filename, &result);
|
333
|
+
if (error != nullptr && ! result.errors.empty() || ! result.warnings.empty()) {
|
334
|
+
std::string str{};
|
335
|
+
for (auto& warn : result.warnings) {
|
336
|
+
str += "WARNING: " + warn + '\n';
|
337
|
+
}
|
338
|
+
for (auto& err : result.errors) {
|
339
|
+
str += "ERROR: " + err + '\n';
|
340
|
+
}
|
341
|
+
*error = strdup(str.c_str());
|
342
|
+
}
|
343
|
+
}
|
344
|
+
}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
prefix=@PREFIX@
|
2
|
+
exec_prefix=${prefix}
|
3
|
+
libdir=${prefix}/lib/ink
|
4
|
+
includedir=${prefix}/include
|
5
|
+
|
6
|
+
Name: inkcpp
|
7
|
+
Description: C Bindnigs for inkpp. @CMAKE_PROJECT_DESCRIPTION@
|
8
|
+
Version: @PROJECT_VERSION@
|
9
|
+
CFlags: -I${includedir}
|
10
|
+
Libs: -L${libdir} -linkcpp_c
|
@@ -0,0 +1,56 @@
|
|
1
|
+
#include <string.h>
|
2
|
+
#include <math.h>
|
3
|
+
#include <stdlib.h>
|
4
|
+
#include <stdio.h>
|
5
|
+
|
6
|
+
#include <inkcpp.h>
|
7
|
+
|
8
|
+
#undef NDEBUG
|
9
|
+
#include <assert.h>
|
10
|
+
|
11
|
+
int cnt_my_sqrt = 0;
|
12
|
+
|
13
|
+
InkValue my_sqrt(int argc, const InkValue argv[])
|
14
|
+
{
|
15
|
+
cnt_my_sqrt += 1;
|
16
|
+
assert(argc == 1);
|
17
|
+
InkValue v = argv[0];
|
18
|
+
switch (v.type) {
|
19
|
+
case ValueTypeFloat: v.float_v = sqrtf(v.float_v); break;
|
20
|
+
case ValueTypeInt32: v.int32_v = sqrt(v.int32_v); break;
|
21
|
+
case ValueTypeUint32: v.uint32_v = sqrtf(v.uint32_v); break;
|
22
|
+
default: assert(0);
|
23
|
+
}
|
24
|
+
return v;
|
25
|
+
}
|
26
|
+
|
27
|
+
int cnt_greeting = 0;
|
28
|
+
|
29
|
+
InkValue greeting(int argc, const InkValue argv[])
|
30
|
+
{
|
31
|
+
cnt_greeting += 1;
|
32
|
+
assert(argc == 0);
|
33
|
+
InkValue v;
|
34
|
+
v.type = ValueTypeString;
|
35
|
+
v.string_v = "Hohooh";
|
36
|
+
return v;
|
37
|
+
}
|
38
|
+
|
39
|
+
int main(int argc, const char* argv[])
|
40
|
+
{
|
41
|
+
HInkStory* story = ink_story_from_file(INK_TEST_RESOURCE_DIR "FallBack.bin");
|
42
|
+
HInkRunner* runner = ink_story_new_runner(story, NULL);
|
43
|
+
ink_runner_bind(runner, "greeting", greeting, 0);
|
44
|
+
ink_runner_bind(runner, "sqrt", my_sqrt, 0);
|
45
|
+
|
46
|
+
const char* res = ink_runner_get_line(runner);
|
47
|
+
assert(strcmp(res, "Hohooh ! A small demonstration of my power:\n") == 0);
|
48
|
+
assert(ink_runner_can_continue(runner));
|
49
|
+
|
50
|
+
assert(strcmp(ink_runner_get_line(runner), "Math 4 * 4 = 16, stunning i would say\n") == 0);
|
51
|
+
assert(ink_runner_can_continue(runner) == 0);
|
52
|
+
|
53
|
+
assert(cnt_my_sqrt == 2);
|
54
|
+
assert(cnt_greeting == 1);
|
55
|
+
return 0;
|
56
|
+
}
|
@@ -0,0 +1,98 @@
|
|
1
|
+
#include <string.h>
|
2
|
+
#include <math.h>
|
3
|
+
#include <stdlib.h>
|
4
|
+
#include <stdio.h>
|
5
|
+
|
6
|
+
#include <inkcpp.h>
|
7
|
+
|
8
|
+
#undef NDEBUG
|
9
|
+
#include <assert.h>
|
10
|
+
|
11
|
+
HInkStory* story = NULL;
|
12
|
+
HInkGlobals* store = NULL;
|
13
|
+
HInkRunner* thread = NULL;
|
14
|
+
|
15
|
+
void setup()
|
16
|
+
{
|
17
|
+
if (! story) {
|
18
|
+
story = ink_story_from_file(INK_TEST_RESOURCE_DIR "GlobalStory.bin");
|
19
|
+
}
|
20
|
+
if (store) {
|
21
|
+
ink_globals_delete(store);
|
22
|
+
}
|
23
|
+
store = ink_story_new_globals(story);
|
24
|
+
if (thread) {
|
25
|
+
ink_runner_delete(thread);
|
26
|
+
}
|
27
|
+
thread = ink_story_new_runner(story, store);
|
28
|
+
}
|
29
|
+
|
30
|
+
int main()
|
31
|
+
{
|
32
|
+
//====== Just reading Globals =====
|
33
|
+
setup();
|
34
|
+
|
35
|
+
// check story
|
36
|
+
assert(
|
37
|
+
strcmp(
|
38
|
+
ink_runner_get_line(thread),
|
39
|
+
"My name is Jean Passepartout, but my friend's call me Jackie. I'm 23 years old.\n"
|
40
|
+
)
|
41
|
+
== 0
|
42
|
+
);
|
43
|
+
assert(strcmp(ink_runner_get_line(thread), "Foo:23\n") == 0);
|
44
|
+
|
45
|
+
// check values in store
|
46
|
+
InkValue val = ink_globals_get(store, "age");
|
47
|
+
assert(val.type == ValueTypeInt32 && val.int32_v == 23);
|
48
|
+
val = ink_globals_get(store, "friendly_name_of_player");
|
49
|
+
assert(val.type == ValueTypeString && strcmp(val.string_v, "Jackie") == 0);
|
50
|
+
|
51
|
+
|
52
|
+
//===== Modifing Globals =====
|
53
|
+
setup();
|
54
|
+
|
55
|
+
// set value of 'age'
|
56
|
+
val.type = ValueTypeInt32;
|
57
|
+
val.int32_v = 30;
|
58
|
+
assert(ink_globals_set(store, "age", val));
|
59
|
+
|
60
|
+
// set value of 'friendl_name_of_player'
|
61
|
+
val.type = ValueTypeString;
|
62
|
+
val.string_v = "Freddy";
|
63
|
+
assert(ink_globals_set(store, "friendly_name_of_player", val));
|
64
|
+
|
65
|
+
|
66
|
+
// check story output
|
67
|
+
assert(
|
68
|
+
strcmp(
|
69
|
+
ink_runner_get_line(thread),
|
70
|
+
"My name is Jean Passepartout, but my friend's call me Freddy. I'm 30 years old.\n"
|
71
|
+
)
|
72
|
+
== 0
|
73
|
+
);
|
74
|
+
assert(strcmp(ink_runner_get_line(thread), "Foo:30\n") == 0);
|
75
|
+
|
76
|
+
// check variable content
|
77
|
+
val = ink_globals_get(store, "age");
|
78
|
+
assert(val.type == ValueTypeInt32 && val.int32_v == 30);
|
79
|
+
val = ink_globals_get(store, "friendly_name_of_player");
|
80
|
+
assert(val.type == ValueTypeString && strcmp(val.string_v, "Freddy") == 0);
|
81
|
+
val = ink_globals_get(store, "concat");
|
82
|
+
assert(val.type == ValueTypeString && strcmp(val.string_v, "Foo:30") == 0);
|
83
|
+
|
84
|
+
//===== Fail to set variables with invalid types or non existing variables =====
|
85
|
+
setup();
|
86
|
+
val = ink_globals_get(store, "foo");
|
87
|
+
assert(val.type == ValueTypeNone);
|
88
|
+
// not existing variable
|
89
|
+
val.type = ValueTypeString;
|
90
|
+
val.string_v = "o";
|
91
|
+
assert(! ink_globals_set(store, "foo", val));
|
92
|
+
val.type = ValueTypeString;
|
93
|
+
val.string_v = "o";
|
94
|
+
// wrong type
|
95
|
+
assert(! ink_globals_set(store, "age", val));
|
96
|
+
|
97
|
+
return 0;
|
98
|
+
}
|
@@ -0,0 +1,73 @@
|
|
1
|
+
#include <string.h>
|
2
|
+
#include <math.h>
|
3
|
+
#include <stdlib.h>
|
4
|
+
#include <stdio.h>
|
5
|
+
|
6
|
+
#include <inkcpp.h>
|
7
|
+
|
8
|
+
#undef NDEBUG
|
9
|
+
#include <assert.h>
|
10
|
+
|
11
|
+
int main()
|
12
|
+
{
|
13
|
+
HInkStory* story = ink_story_from_file(INK_TEST_RESOURCE_DIR "ListStory.bin");
|
14
|
+
HInkGlobals* store = ink_story_new_globals(story);
|
15
|
+
HInkRunner* runner = ink_story_new_runner(story, store);
|
16
|
+
|
17
|
+
InkValue val = ink_globals_get(store, "list");
|
18
|
+
assert(val.type == ValueTypeList);
|
19
|
+
HInkList* list = val.list_v;
|
20
|
+
|
21
|
+
InkListIter iter;
|
22
|
+
|
23
|
+
// iterate through all flags
|
24
|
+
{
|
25
|
+
int hits[3] = {0};
|
26
|
+
if (ink_list_flags(list, &iter)) {
|
27
|
+
do {
|
28
|
+
if (strcmp(iter.flag_name, "bird") == 0 && strcmp(iter.list_name, "animals") == 0) {
|
29
|
+
hits[0] = 1;
|
30
|
+
} else if (strcmp(iter.flag_name, "red") == 0 && strcmp(iter.list_name, "colors") == 0) {
|
31
|
+
hits[1] = 1;
|
32
|
+
} else if (strcmp(iter.flag_name, "yellow") == 0 && strcmp(iter.list_name, "colors") == 0) {
|
33
|
+
hits[2] = 1;
|
34
|
+
} else {
|
35
|
+
assert(0);
|
36
|
+
}
|
37
|
+
} while (ink_list_iter_next(&iter));
|
38
|
+
assert(hits[0] && hits[1] && hits[2]);
|
39
|
+
}
|
40
|
+
}
|
41
|
+
// through all animals in list
|
42
|
+
{
|
43
|
+
int hits[2] = {0};
|
44
|
+
if (ink_list_flags_from(list, "colors", &iter)) {
|
45
|
+
do {
|
46
|
+
if (strcmp(iter.flag_name, "red") == 0 && strcmp(iter.list_name, "colors") == 0) {
|
47
|
+
hits[0] = 1;
|
48
|
+
} else if (strcmp(iter.flag_name, "yellow") == 0 && strcmp(iter.list_name, "colors") == 0) {
|
49
|
+
hits[1] = 1;
|
50
|
+
} else {
|
51
|
+
assert(0);
|
52
|
+
}
|
53
|
+
} while (ink_list_iter_next(&iter));
|
54
|
+
}
|
55
|
+
assert(hits[0] && hits[1]);
|
56
|
+
}
|
57
|
+
|
58
|
+
assert(ink_list_contains(list, "yellow"));
|
59
|
+
assert(ink_list_contains(list, "white") == 0);
|
60
|
+
|
61
|
+
ink_list_add(list, "white");
|
62
|
+
ink_list_remove(list, "yellow");
|
63
|
+
assert(ink_list_contains(list, "yellow") == 0);
|
64
|
+
assert(ink_list_contains(list, "white"));
|
65
|
+
|
66
|
+
assert(ink_globals_set(store, "list", val));
|
67
|
+
|
68
|
+
assert(strcmp(ink_runner_get_line(runner), "cat, snake\n") == 0);
|
69
|
+
assert(ink_runner_num_choices(runner) == 2);
|
70
|
+
const HInkChoice* choice = ink_runner_get_choice(runner, 0);
|
71
|
+
assert(strcmp(ink_choice_text(choice), "list: bird, white, red") == 0);
|
72
|
+
return 0;
|
73
|
+
}
|
@@ -0,0 +1,36 @@
|
|
1
|
+
#include <string.h>
|
2
|
+
#include <math.h>
|
3
|
+
#include <stdlib.h>
|
4
|
+
#include <stdio.h>
|
5
|
+
|
6
|
+
#include <inkcpp.h>
|
7
|
+
|
8
|
+
#undef NDEBUG
|
9
|
+
#include <assert.h>
|
10
|
+
|
11
|
+
int cnt = 0;
|
12
|
+
|
13
|
+
void observer(InkValue new_value, InkValue old_value)
|
14
|
+
{
|
15
|
+
if (cnt++ == 0) {
|
16
|
+
assert(new_value.type == ValueTypeInt32 && new_value.int32_v == 1);
|
17
|
+
assert(old_value.type == ValueTypeNone);
|
18
|
+
} else {
|
19
|
+
assert(new_value.type == ValueTypeInt32 && new_value.int32_v == 5);
|
20
|
+
assert(old_value.type == ValueTypeInt32 && old_value.int32_v == 1);
|
21
|
+
}
|
22
|
+
}
|
23
|
+
|
24
|
+
int main()
|
25
|
+
{
|
26
|
+
HInkStory* story = ink_story_from_file(INK_TEST_RESOURCE_DIR "ObserverStory.bin");
|
27
|
+
HInkGlobals* store = ink_story_new_globals(story);
|
28
|
+
HInkRunner* thread = ink_story_new_runner(story, store);
|
29
|
+
|
30
|
+
ink_globals_observe(store, "var1", observer);
|
31
|
+
|
32
|
+
assert(strcmp(ink_runner_get_line(thread), "hello line 1 1 hello line 2 5 test line 3 5\n") == 0);
|
33
|
+
assert(cnt == 2);
|
34
|
+
|
35
|
+
return 0;
|
36
|
+
}
|
@@ -0,0 +1,65 @@
|
|
1
|
+
#include <string.h>
|
2
|
+
#include <math.h>
|
3
|
+
#include <stdlib.h>
|
4
|
+
#include <stdio.h>
|
5
|
+
|
6
|
+
#include <inkcpp.h>
|
7
|
+
|
8
|
+
#undef NDEBUG
|
9
|
+
#include <assert.h>
|
10
|
+
|
11
|
+
void check_end(HInkRunner* runner)
|
12
|
+
{
|
13
|
+
assert(ink_runner_num_choices(runner) == 3);
|
14
|
+
ink_runner_choose(runner, 2);
|
15
|
+
while (ink_runner_can_continue(runner)) {
|
16
|
+
ink_runner_get_line(runner);
|
17
|
+
}
|
18
|
+
assert(ink_runner_num_choices(runner) == 2);
|
19
|
+
}
|
20
|
+
|
21
|
+
int main()
|
22
|
+
{
|
23
|
+
HInkStory* story = ink_story_from_file(INK_TEST_RESOURCE_DIR "SimpleStoryFlow.bin");
|
24
|
+
HInkRunner* runner = ink_story_new_runner(story, NULL);
|
25
|
+
|
26
|
+
ink_runner_get_line(runner);
|
27
|
+
assert(ink_runner_num_choices(runner) == 3);
|
28
|
+
ink_runner_choose(runner, 2);
|
29
|
+
|
30
|
+
// snapshot after choose -> snapshot will print text after loading
|
31
|
+
HInkSnapshot* snap1 = ink_runner_create_snapshot(runner);
|
32
|
+
|
33
|
+
int cnt = 0;
|
34
|
+
while (ink_runner_can_continue(runner)) {
|
35
|
+
ink_runner_get_line(runner);
|
36
|
+
++cnt;
|
37
|
+
}
|
38
|
+
|
39
|
+
// snapshot befroe choose, context (last output lines) can not bet optained at loading
|
40
|
+
HInkSnapshot* snap2 = ink_runner_create_snapshot(runner);
|
41
|
+
|
42
|
+
check_end(runner);
|
43
|
+
|
44
|
+
|
45
|
+
ink_runner_delete(runner);
|
46
|
+
runner = ink_story_new_runner_from_snapshot(story, snap1, NULL, 0);
|
47
|
+
|
48
|
+
// same amount at output then before
|
49
|
+
while (ink_runner_can_continue(runner)) {
|
50
|
+
ink_runner_get_line(runner);
|
51
|
+
--cnt;
|
52
|
+
}
|
53
|
+
assert(cnt == 0);
|
54
|
+
|
55
|
+
check_end(runner);
|
56
|
+
|
57
|
+
|
58
|
+
ink_runner_delete(runner);
|
59
|
+
runner = ink_story_new_runner_from_snapshot(story, snap2, NULL, 0);
|
60
|
+
|
61
|
+
assert(ink_runner_can_continue(runner) == 0);
|
62
|
+
check_end(runner);
|
63
|
+
|
64
|
+
return 0;
|
65
|
+
}
|