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,289 @@
|
|
|
1
|
+
/* Copyright (c) 2024 Julian Benda
|
|
2
|
+
*
|
|
3
|
+
* This file is part of inkCPP which is released under MIT license.
|
|
4
|
+
* See file LICENSE.txt or go to
|
|
5
|
+
* https://github.com/JBenda/inkcpp for full license details.
|
|
6
|
+
*/
|
|
7
|
+
#include "globals_impl.h"
|
|
8
|
+
#include "story_impl.h"
|
|
9
|
+
#include "runner_impl.h"
|
|
10
|
+
#include "snapshot_impl.h"
|
|
11
|
+
#include "system.h"
|
|
12
|
+
#include "types.h"
|
|
13
|
+
|
|
14
|
+
namespace ink::runtime::internal
|
|
15
|
+
{
|
|
16
|
+
globals_impl::globals_impl(const story_impl* story)
|
|
17
|
+
: _num_containers(story->num_containers())
|
|
18
|
+
, _turn_cnt{0}
|
|
19
|
+
, _visit_counts()
|
|
20
|
+
, _visit_counts_backup()
|
|
21
|
+
, _owner(story)
|
|
22
|
+
, _runners_start(nullptr)
|
|
23
|
+
, _lists(story->list_meta(), story->get_header())
|
|
24
|
+
, _globals_initialized(false)
|
|
25
|
+
{
|
|
26
|
+
_visit_counts.resize(_num_containers);
|
|
27
|
+
_visit_counts_backup.resize(_num_containers);
|
|
28
|
+
if (_lists) {
|
|
29
|
+
// initelize static lists
|
|
30
|
+
const list_flag* flags = story->lists();
|
|
31
|
+
while (*flags != null_flag) {
|
|
32
|
+
list_table::list l = _lists.create_permament();
|
|
33
|
+
while (*flags != null_flag) {
|
|
34
|
+
list_flag flag = _lists.external_fvalue_to_internal(*flags);
|
|
35
|
+
_lists.add_inplace(l, flag);
|
|
36
|
+
++flags;
|
|
37
|
+
}
|
|
38
|
+
++flags;
|
|
39
|
+
}
|
|
40
|
+
for (const auto& flag : _lists.named_flags()) {
|
|
41
|
+
set_variable(
|
|
42
|
+
hash_string(flag.name),
|
|
43
|
+
value{}.set<value_type::list_flag>(list_flag{flag.flag.list_id, flag.flag.flag})
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
void globals_impl::visit(uint32_t container_id, bool entering_at_start)
|
|
50
|
+
{
|
|
51
|
+
if ((! (_owner->container_flag(container_id) & CommandFlag::CONTAINER_MARKER_ONLY_FIRST))
|
|
52
|
+
|| entering_at_start) {
|
|
53
|
+
_visit_counts[container_id].visits += 1;
|
|
54
|
+
_visit_counts[container_id].turns = 0;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
uint32_t globals_impl::visits(uint32_t container_id) const
|
|
59
|
+
{
|
|
60
|
+
return _visit_counts[container_id].visits;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
uint32_t globals_impl::turns() const { return _turn_cnt; }
|
|
64
|
+
|
|
65
|
+
void globals_impl::turn()
|
|
66
|
+
{
|
|
67
|
+
++_turn_cnt;
|
|
68
|
+
for (size_t i = 0; i < _visit_counts.size(); ++i) {
|
|
69
|
+
if (_visit_counts[i].turns != -1) {
|
|
70
|
+
_visit_counts[i].turns += 1;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
uint32_t globals_impl::turns(uint32_t container_id) const
|
|
76
|
+
{
|
|
77
|
+
return _visit_counts[container_id].turns;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
void globals_impl::add_runner(const runner_impl* runner)
|
|
81
|
+
{
|
|
82
|
+
// cache start of list
|
|
83
|
+
auto first = _runners_start;
|
|
84
|
+
|
|
85
|
+
// create new entry as start, linked to the previous start
|
|
86
|
+
_runners_start = new runner_entry{runner, first};
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
void globals_impl::remove_runner(const runner_impl* runner)
|
|
90
|
+
{
|
|
91
|
+
// iterate linked list
|
|
92
|
+
runner_entry* prev = nullptr;
|
|
93
|
+
auto iter = _runners_start;
|
|
94
|
+
while (iter != nullptr) {
|
|
95
|
+
if (iter->object == runner) {
|
|
96
|
+
// Fixup next pointer
|
|
97
|
+
if (prev != nullptr)
|
|
98
|
+
prev->next = iter->next;
|
|
99
|
+
else
|
|
100
|
+
_runners_start = iter->next;
|
|
101
|
+
|
|
102
|
+
// delete
|
|
103
|
+
delete iter;
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// move on to next entry
|
|
108
|
+
prev = iter;
|
|
109
|
+
iter = iter->next;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
void globals_impl::set_variable(hash_t name, const value& val)
|
|
114
|
+
{
|
|
115
|
+
ink::optional<value> old_var = ink::nullopt;
|
|
116
|
+
value* p_old_var = get_variable(name);
|
|
117
|
+
if (p_old_var != nullptr) {
|
|
118
|
+
old_var = *p_old_var;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
_variables.set(name, val);
|
|
122
|
+
|
|
123
|
+
for (auto& callback : _callbacks) {
|
|
124
|
+
if (callback.name == name) {
|
|
125
|
+
if (old_var.has_value()) {
|
|
126
|
+
callback.operation->call(
|
|
127
|
+
val.to_interface_value(lists()), {old_var->to_interface_value(lists())}
|
|
128
|
+
);
|
|
129
|
+
} else {
|
|
130
|
+
callback.operation->call(val.to_interface_value(lists()), ink::nullopt);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const value* globals_impl::get_variable(hash_t name) const { return _variables.get(name); }
|
|
137
|
+
|
|
138
|
+
value* globals_impl::get_variable(hash_t name) { return _variables.get(name); }
|
|
139
|
+
|
|
140
|
+
optional<ink::runtime::value> globals_impl::get_var(hash_t name) const
|
|
141
|
+
{
|
|
142
|
+
auto* var = get_variable(name);
|
|
143
|
+
if (! var) {
|
|
144
|
+
return nullopt;
|
|
145
|
+
}
|
|
146
|
+
return {var->to_interface_value(_lists)};
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
bool globals_impl::set_var(hash_t name, const ink::runtime::value& val)
|
|
150
|
+
{
|
|
151
|
+
auto* var = get_variable(name);
|
|
152
|
+
if (! var) {
|
|
153
|
+
return false;
|
|
154
|
+
}
|
|
155
|
+
ink::runtime::value old_val = var->to_interface_value(lists());
|
|
156
|
+
|
|
157
|
+
bool ret = false;
|
|
158
|
+
if (val.type == ink::runtime::value::Type::String) {
|
|
159
|
+
if (! (var->type() == value_type::none || var->type() == value_type::string)) {
|
|
160
|
+
return false;
|
|
161
|
+
}
|
|
162
|
+
size_t size = 0;
|
|
163
|
+
char* ptr;
|
|
164
|
+
for (const char* i = val.get<runtime::value::Type::String>(); *i; ++i) {
|
|
165
|
+
++size;
|
|
166
|
+
}
|
|
167
|
+
char* new_string = strings().create(size + 1);
|
|
168
|
+
strings().mark_used(new_string);
|
|
169
|
+
ptr = new_string;
|
|
170
|
+
for (const char* i = val.get<runtime::value::Type::String>(); *i; ++i) {
|
|
171
|
+
*ptr++ = *i;
|
|
172
|
+
}
|
|
173
|
+
*ptr = 0;
|
|
174
|
+
*var = value{}.set<value_type::string>(static_cast<const char*>(new_string), true);
|
|
175
|
+
ret = true;
|
|
176
|
+
} else {
|
|
177
|
+
ret = var->set(val);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
for (auto& callback : _callbacks) {
|
|
181
|
+
if (callback.name == name) {
|
|
182
|
+
callback.operation->call(val, {old_val});
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
return ret;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
void globals_impl::internal_observe(hash_t name, callback_base* callback)
|
|
190
|
+
{
|
|
191
|
+
_callbacks.push() = Callback{.name = name, .operation = callback};
|
|
192
|
+
if (_globals_initialized) {
|
|
193
|
+
value* p_var = _variables.get(name);
|
|
194
|
+
inkAssert(
|
|
195
|
+
p_var != nullptr,
|
|
196
|
+
"Global variable to observe does not exists after initiliazation. This variable will "
|
|
197
|
+
"therofe not get any value."
|
|
198
|
+
);
|
|
199
|
+
callback->call(p_var->to_interface_value(lists()), ink::nullopt);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
void globals_impl::initialize_globals(runner_impl* run)
|
|
204
|
+
{
|
|
205
|
+
// If no way to move there, then there are no globals.
|
|
206
|
+
if (! run->move_to(hash_string("global decl"))) {
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// execute one line to startup the globals
|
|
211
|
+
run->getline_silent();
|
|
212
|
+
_globals_initialized = true;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
void globals_impl::gc()
|
|
216
|
+
{
|
|
217
|
+
// Mark all strings as unused
|
|
218
|
+
_strings.clear_usage();
|
|
219
|
+
_lists.clear_usage();
|
|
220
|
+
|
|
221
|
+
// Iterate runners and mark their strings
|
|
222
|
+
auto iter = _runners_start;
|
|
223
|
+
while (iter != nullptr) {
|
|
224
|
+
iter->object->mark_used(_strings, _lists);
|
|
225
|
+
iter = iter->next;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
// Mark our own strings
|
|
229
|
+
_variables.mark_used(_strings, _lists);
|
|
230
|
+
|
|
231
|
+
// run garbage collection
|
|
232
|
+
_strings.gc();
|
|
233
|
+
_lists.gc();
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
void globals_impl::save()
|
|
237
|
+
{
|
|
238
|
+
for (uint32_t i = 0; i < _num_containers; ++i) {
|
|
239
|
+
_visit_counts_backup[i] = _visit_counts[i];
|
|
240
|
+
}
|
|
241
|
+
_variables.save();
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
void globals_impl::restore()
|
|
245
|
+
{
|
|
246
|
+
for (uint32_t i = 0; i < _num_containers; ++i) {
|
|
247
|
+
_visit_counts[i] = _visit_counts_backup[i];
|
|
248
|
+
}
|
|
249
|
+
_variables.restore();
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
void globals_impl::forget() { _variables.forget(); }
|
|
253
|
+
|
|
254
|
+
snapshot* globals_impl::create_snapshot() const { return new snapshot_impl(*this); }
|
|
255
|
+
|
|
256
|
+
size_t globals_impl::snap(unsigned char* data, const snapper& snapper) const
|
|
257
|
+
{
|
|
258
|
+
unsigned char* ptr = data;
|
|
259
|
+
inkAssert(_num_containers == _visit_counts.size(), "Should be equal!");
|
|
260
|
+
inkAssert(
|
|
261
|
+
_globals_initialized,
|
|
262
|
+
"Only support snapshot of globals with runner! or you don't need a snapshot for this state"
|
|
263
|
+
);
|
|
264
|
+
ptr = snap_write(ptr, _turn_cnt, data != nullptr);
|
|
265
|
+
ptr += _visit_counts.snap(data ? ptr : nullptr, snapper);
|
|
266
|
+
ptr += _visit_counts_backup.snap(data ? ptr : nullptr, snapper);
|
|
267
|
+
ptr += _strings.snap(data ? ptr : nullptr, snapper);
|
|
268
|
+
ptr += _lists.snap(data ? ptr : nullptr, snapper);
|
|
269
|
+
ptr += _variables.snap(data ? ptr : nullptr, snapper);
|
|
270
|
+
return ptr - data;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
const unsigned char* globals_impl::snap_load(const unsigned char* ptr, const loader& loader)
|
|
274
|
+
{
|
|
275
|
+
_globals_initialized = true;
|
|
276
|
+
ptr = snap_read(ptr, _turn_cnt);
|
|
277
|
+
ptr = _visit_counts.snap_load(ptr, loader);
|
|
278
|
+
ptr = _visit_counts_backup.snap_load(ptr, loader);
|
|
279
|
+
inkAssert(_visit_counts.size() == _visit_counts_backup.size(), "Data inconsitency");
|
|
280
|
+
inkAssert(
|
|
281
|
+
_num_containers == _visit_counts.size(),
|
|
282
|
+
"errer when loading visit counts, story file dont match snapshot!"
|
|
283
|
+
);
|
|
284
|
+
ptr = _strings.snap_load(ptr, loader);
|
|
285
|
+
ptr = _lists.snap_load(ptr, loader);
|
|
286
|
+
ptr = _variables.snap_load(ptr, loader);
|
|
287
|
+
return ptr;
|
|
288
|
+
}
|
|
289
|
+
} // namespace ink::runtime::internal
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/* Copyright (c) 2024 Julian Benda
|
|
2
|
+
*
|
|
3
|
+
* This file is part of inkCPP which is released under MIT license.
|
|
4
|
+
* See file LICENSE.txt or go to
|
|
5
|
+
* https://github.com/JBenda/inkcpp for full license details.
|
|
6
|
+
*/
|
|
7
|
+
#pragma once
|
|
8
|
+
|
|
9
|
+
#include "config.h"
|
|
10
|
+
#include "system.h"
|
|
11
|
+
#include "array.h"
|
|
12
|
+
#include "globals.h"
|
|
13
|
+
#include "string_table.h"
|
|
14
|
+
#include "list_table.h"
|
|
15
|
+
#include "list_impl.h"
|
|
16
|
+
#include "stack.h"
|
|
17
|
+
#include "snapshot_impl.h"
|
|
18
|
+
#include "functional.h"
|
|
19
|
+
|
|
20
|
+
namespace ink::runtime::internal
|
|
21
|
+
{
|
|
22
|
+
class story_impl;
|
|
23
|
+
class runner_impl;
|
|
24
|
+
class snapshot_impl;
|
|
25
|
+
|
|
26
|
+
// Implementation of the global store
|
|
27
|
+
class globals_impl final
|
|
28
|
+
: public globals_interface
|
|
29
|
+
, public snapshot_interface
|
|
30
|
+
{
|
|
31
|
+
friend snapshot_impl;
|
|
32
|
+
|
|
33
|
+
public:
|
|
34
|
+
size_t snap(unsigned char* data, const snapper&) const;
|
|
35
|
+
const unsigned char* snap_load(const unsigned char* data, const loader&);
|
|
36
|
+
// Initializes a new global store from the given story
|
|
37
|
+
globals_impl(const story_impl*);
|
|
38
|
+
|
|
39
|
+
virtual ~globals_impl() {}
|
|
40
|
+
|
|
41
|
+
snapshot* create_snapshot() const override;
|
|
42
|
+
|
|
43
|
+
protected:
|
|
44
|
+
optional<ink::runtime::value> get_var(hash_t name) const override;
|
|
45
|
+
bool set_var(hash_t name, const ink::runtime::value& val) override;
|
|
46
|
+
void internal_observe(hash_t name, internal::callback_base* callback) override;
|
|
47
|
+
|
|
48
|
+
public:
|
|
49
|
+
// Records a visit to a container
|
|
50
|
+
/// @param start_cmd iff the visit was initiatet through a MARKER_START_CONTAINER
|
|
51
|
+
void visit(uint32_t container_id, bool entering_at_start);
|
|
52
|
+
|
|
53
|
+
// Checks the number of visits to a container
|
|
54
|
+
uint32_t visits(uint32_t container_id) const;
|
|
55
|
+
// Number of current turn (number of passed choices)
|
|
56
|
+
uint32_t turns() const;
|
|
57
|
+
|
|
58
|
+
// Returnn number of turns since container was last visited
|
|
59
|
+
// \retval -1 if container was never visited before
|
|
60
|
+
uint32_t turns(uint32_t container_id) const;
|
|
61
|
+
|
|
62
|
+
// signal that a turn is habbend (eg. a choice is taken)
|
|
63
|
+
void turn();
|
|
64
|
+
|
|
65
|
+
// registers/unregisters a runner as using this globals object
|
|
66
|
+
void add_runner(const runner_impl*);
|
|
67
|
+
void remove_runner(const runner_impl*);
|
|
68
|
+
|
|
69
|
+
// sets a global variable
|
|
70
|
+
void set_variable(hash_t name, const value&);
|
|
71
|
+
|
|
72
|
+
// gets a global variable
|
|
73
|
+
const value* get_variable(hash_t name) const;
|
|
74
|
+
value* get_variable(hash_t name);
|
|
75
|
+
|
|
76
|
+
// checks if globals are initialized
|
|
77
|
+
bool are_globals_initialized() const { return _globals_initialized; }
|
|
78
|
+
|
|
79
|
+
// initializes globals using a runner
|
|
80
|
+
void initialize_globals(runner_impl*);
|
|
81
|
+
|
|
82
|
+
// gets the allocated string table
|
|
83
|
+
inline string_table& strings() { return _strings; }
|
|
84
|
+
|
|
85
|
+
inline const string_table& strings() const { return _strings; }
|
|
86
|
+
|
|
87
|
+
// gets list entries
|
|
88
|
+
list_table& lists() { return _lists; }
|
|
89
|
+
|
|
90
|
+
// run garbage collection
|
|
91
|
+
void gc();
|
|
92
|
+
|
|
93
|
+
// == Save/Restore ==
|
|
94
|
+
void save();
|
|
95
|
+
void restore();
|
|
96
|
+
void forget();
|
|
97
|
+
|
|
98
|
+
private:
|
|
99
|
+
// Store the number of containers. This is the length of most of our lists
|
|
100
|
+
const uint32_t _num_containers;
|
|
101
|
+
|
|
102
|
+
uint32_t _turn_cnt = 0;
|
|
103
|
+
|
|
104
|
+
// Visit count array
|
|
105
|
+
struct visit_count {
|
|
106
|
+
uint32_t visits = 0;
|
|
107
|
+
int32_t turns = -1;
|
|
108
|
+
|
|
109
|
+
bool operator==(const visit_count& vc) const
|
|
110
|
+
{
|
|
111
|
+
return visits == vc.visits && turns == vc.turns;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
bool operator!=(const visit_count& vc) const { return ! (*this == vc); }
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
managed_array<visit_count, true, 1> _visit_counts;
|
|
118
|
+
managed_array<visit_count, true, 1> _visit_counts_backup;
|
|
119
|
+
|
|
120
|
+
// Pointer back to owner story.
|
|
121
|
+
const story_impl* const _owner;
|
|
122
|
+
|
|
123
|
+
struct runner_entry {
|
|
124
|
+
const runner_impl* object;
|
|
125
|
+
runner_entry* next = nullptr;
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
// Linked list of runners operating under this globals object.
|
|
129
|
+
// Used for garbage collection of the global string table.
|
|
130
|
+
runner_entry* _runners_start;
|
|
131
|
+
|
|
132
|
+
// Allocated string table (shared by all runners using this global store)
|
|
133
|
+
mutable string_table _strings;
|
|
134
|
+
mutable list_table _lists;
|
|
135
|
+
|
|
136
|
+
// Implemented as a stack (slow lookup) because it has save/restore functionality.
|
|
137
|
+
// If I could create an avl tree with save/restore, that'd be great but seems super complex.
|
|
138
|
+
internal::stack < abs(config::limitGlobalVariables), config::limitGlobalVariables<0> _variables;
|
|
139
|
+
|
|
140
|
+
struct Callback {
|
|
141
|
+
hash_t name;
|
|
142
|
+
callback_base* operation;
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
managed_array < Callback,
|
|
146
|
+
config::limitGlobalVariableObservers<0, abs(config::limitGlobalVariableObservers)> _callbacks;
|
|
147
|
+
bool _globals_initialized;
|
|
148
|
+
};
|
|
149
|
+
} // namespace ink::runtime::internal
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/* Copyright (c) 2024 Julian Benda
|
|
2
|
+
*
|
|
3
|
+
* This file is part of inkCPP which is released under MIT license.
|
|
4
|
+
* See file LICENSE.txt or go to
|
|
5
|
+
* https://github.com/JBenda/inkcpp for full license details.
|
|
6
|
+
*/
|
|
7
|
+
#include "header.h"
|
|
8
|
+
#include "version.h"
|
|
9
|
+
|
|
10
|
+
namespace ink::internal {
|
|
11
|
+
|
|
12
|
+
header header::parse_header(const char *data)
|
|
13
|
+
{
|
|
14
|
+
header res;
|
|
15
|
+
const char* ptr = data;
|
|
16
|
+
res.endien = *reinterpret_cast<const header::endian_types*>(ptr);
|
|
17
|
+
ptr += sizeof(header::endian_types);
|
|
18
|
+
|
|
19
|
+
using v_t = decltype(header::ink_version_number);
|
|
20
|
+
using vcpp_t = decltype(header::ink_bin_version_number);
|
|
21
|
+
|
|
22
|
+
if (res.endien == header::endian_types::same) {
|
|
23
|
+
res.ink_version_number =
|
|
24
|
+
*reinterpret_cast<const v_t*>(ptr);
|
|
25
|
+
ptr += sizeof(v_t);
|
|
26
|
+
res.ink_bin_version_number =
|
|
27
|
+
*reinterpret_cast<const vcpp_t*>(ptr);
|
|
28
|
+
|
|
29
|
+
} else if (res.endien == header::endian_types::differ) {
|
|
30
|
+
res.ink_version_number =
|
|
31
|
+
swap_bytes(*reinterpret_cast<const v_t*>(ptr));
|
|
32
|
+
ptr += sizeof(v_t);
|
|
33
|
+
res.ink_bin_version_number =
|
|
34
|
+
swap_bytes(*reinterpret_cast<const vcpp_t*>(ptr));
|
|
35
|
+
} else {
|
|
36
|
+
inkFail("Failed to parse endian encoding!");
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (res.ink_bin_version_number != InkBinVersion) {
|
|
40
|
+
inkFail("InkCpp-version mismatch: file was compiled with different InkCpp-version!");
|
|
41
|
+
}
|
|
42
|
+
return res;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/* Copyright (c) 2024 Julian Benda
|
|
2
|
+
*
|
|
3
|
+
* This file is part of inkCPP which is released under MIT license.
|
|
4
|
+
* See file LICENSE.txt or go to
|
|
5
|
+
* https://github.com/JBenda/inkcpp for full license details.
|
|
6
|
+
*/
|
|
7
|
+
#pragma once
|
|
8
|
+
#include "system.h"
|
|
9
|
+
|
|
10
|
+
namespace ink
|
|
11
|
+
{
|
|
12
|
+
namespace runtime
|
|
13
|
+
{
|
|
14
|
+
namespace internal
|
|
15
|
+
{
|
|
16
|
+
class basic_stream;
|
|
17
|
+
class runner_impl;
|
|
18
|
+
class string_table;
|
|
19
|
+
class list_table;
|
|
20
|
+
} // namespace internal
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* An ink choice that is being presented to the user
|
|
24
|
+
*
|
|
25
|
+
* Contains all the data about a single choice being faced
|
|
26
|
+
* by an ink runner. Of primary concern is the index and the
|
|
27
|
+
* text.
|
|
28
|
+
*
|
|
29
|
+
* @see runner
|
|
30
|
+
*/
|
|
31
|
+
class choice
|
|
32
|
+
{
|
|
33
|
+
public:
|
|
34
|
+
/**
|
|
35
|
+
* Choice index
|
|
36
|
+
*
|
|
37
|
+
* Pass this to the runner to choose this choice and
|
|
38
|
+
* have it follow its branch.
|
|
39
|
+
*
|
|
40
|
+
* @returns index of the choice. 0 is the first, etc.
|
|
41
|
+
*/
|
|
42
|
+
int index() const { return _index; }
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Choice text
|
|
46
|
+
*
|
|
47
|
+
* Text to display to the user for choosing this choice.
|
|
48
|
+
*
|
|
49
|
+
* @returns choice text as a string
|
|
50
|
+
*/
|
|
51
|
+
const char* text() const { return _text; }
|
|
52
|
+
|
|
53
|
+
/** @private */
|
|
54
|
+
choice()
|
|
55
|
+
: choice(0)
|
|
56
|
+
{
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** @private */
|
|
60
|
+
choice(int)
|
|
61
|
+
: _tags{nullptr}
|
|
62
|
+
, _text{nullptr}
|
|
63
|
+
, _index{~0}
|
|
64
|
+
, _path{~0u}
|
|
65
|
+
, _thread{~0u}
|
|
66
|
+
{
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** does this choice has tags? */
|
|
70
|
+
bool has_tags() const { return _tags != nullptr; }
|
|
71
|
+
|
|
72
|
+
/** number of tags assoziated with this choice
|
|
73
|
+
* @see @ref ink::runtime::choice::has_tags() "has_tags()"
|
|
74
|
+
*/
|
|
75
|
+
size_t num_tags() const
|
|
76
|
+
{
|
|
77
|
+
size_t i = 0;
|
|
78
|
+
if (has_tags())
|
|
79
|
+
while (_tags[i] != nullptr) {
|
|
80
|
+
++i;
|
|
81
|
+
};
|
|
82
|
+
return i;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** @copydoc ink::runtime::runner_interface::get_tag() */
|
|
86
|
+
const char* get_tag(size_t index) const { return _tags[index]; }
|
|
87
|
+
|
|
88
|
+
private:
|
|
89
|
+
friend class internal::runner_impl;
|
|
90
|
+
|
|
91
|
+
uint32_t path() const { return _path; }
|
|
92
|
+
|
|
93
|
+
choice& setup(
|
|
94
|
+
internal::basic_stream&, internal::string_table& strings, internal::list_table& lists,
|
|
95
|
+
int index, uint32_t path, thread_t thread, const char* const* tags
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
protected:
|
|
99
|
+
const char* const* _tags; ///< @private
|
|
100
|
+
const char* _text; ///< @private
|
|
101
|
+
int _index; ///< @private
|
|
102
|
+
uint32_t _path; ///< @private
|
|
103
|
+
thread_t _thread; ///< @private
|
|
104
|
+
};
|
|
105
|
+
} // namespace runtime
|
|
106
|
+
} // namespace ink
|