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,233 @@
|
|
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 "system.h"
|
10
|
+
|
11
|
+
namespace ink::runtime
|
12
|
+
{
|
13
|
+
namespace internal
|
14
|
+
{
|
15
|
+
/** @private */
|
16
|
+
struct ref_block {
|
17
|
+
ref_block()
|
18
|
+
: references(0)
|
19
|
+
, valid(true)
|
20
|
+
{
|
21
|
+
}
|
22
|
+
|
23
|
+
size_t references;
|
24
|
+
bool valid;
|
25
|
+
|
26
|
+
static void remove_reference(ref_block*&);
|
27
|
+
};
|
28
|
+
|
29
|
+
/** @private */
|
30
|
+
class story_ptr_base
|
31
|
+
{
|
32
|
+
protected:
|
33
|
+
/** construct a new pointer with new instance block */
|
34
|
+
story_ptr_base(internal::ref_block* story);
|
35
|
+
/** construct a new pointer with existing instance block */
|
36
|
+
story_ptr_base(internal::ref_block* story, internal::ref_block* instance);
|
37
|
+
/** construct a new pointer basedd on existing story pointer */
|
38
|
+
story_ptr_base(const story_ptr_base&);
|
39
|
+
|
40
|
+
story_ptr_base& operator=(const story_ptr_base&) = delete;
|
41
|
+
|
42
|
+
/** increases reference count */
|
43
|
+
void add_reference();
|
44
|
+
/** decreses reference count
|
45
|
+
* @retval true if count reaches zero and object was removed
|
46
|
+
*/
|
47
|
+
bool remove_reference();
|
48
|
+
|
49
|
+
/** switch lifetime block */
|
50
|
+
void set(const story_ptr_base& other);
|
51
|
+
|
52
|
+
/** checks if pointer is still alive */
|
53
|
+
inline bool is_valid() const
|
54
|
+
{
|
55
|
+
return _story_block != nullptr && _instance_block != nullptr && _story_block->valid
|
56
|
+
&& _instance_block->valid;
|
57
|
+
}
|
58
|
+
|
59
|
+
/** checks if story still exists */
|
60
|
+
inline bool is_story_valid() const { return _story_block != nullptr && _story_block->valid; }
|
61
|
+
|
62
|
+
private:
|
63
|
+
// reference block for the parent story
|
64
|
+
ref_block* _story_block;
|
65
|
+
|
66
|
+
// reference block for this pointer
|
67
|
+
ref_block* _instance_block;
|
68
|
+
};
|
69
|
+
} // namespace internal
|
70
|
+
|
71
|
+
/**
|
72
|
+
* Pointer wrapper to an object whose lifetime is tied to a story object.
|
73
|
+
*
|
74
|
+
* A shared pointer whose lifetime is also tied to the lifetime of the parent
|
75
|
+
* story object. The referenced object will live until either
|
76
|
+
* 1) There are no more story_ptr's pointing to this object
|
77
|
+
* 2) The story object which owns this object dies
|
78
|
+
*
|
79
|
+
* @see story_interface
|
80
|
+
* @see runner_interface
|
81
|
+
* @see globals_interface
|
82
|
+
*/
|
83
|
+
template<typename T>
|
84
|
+
class story_ptr : public internal::story_ptr_base
|
85
|
+
{
|
86
|
+
public:
|
87
|
+
/** constructor. internal use only.
|
88
|
+
* @private
|
89
|
+
*/
|
90
|
+
story_ptr(T* ptr, internal::ref_block* story)
|
91
|
+
: story_ptr_base(story)
|
92
|
+
, _ptr(ptr)
|
93
|
+
{
|
94
|
+
add_reference();
|
95
|
+
}
|
96
|
+
|
97
|
+
/** casting constructor. internal use only
|
98
|
+
* @private
|
99
|
+
*/
|
100
|
+
template<typename U>
|
101
|
+
story_ptr(T* ptr, const story_ptr<U>& other)
|
102
|
+
: story_ptr_base(other)
|
103
|
+
, _ptr(ptr)
|
104
|
+
{
|
105
|
+
add_reference();
|
106
|
+
}
|
107
|
+
|
108
|
+
/** pointer constructor. for nullptr only.
|
109
|
+
* @param ptr will be ignored, should be nullptr
|
110
|
+
*/
|
111
|
+
story_ptr(T* ptr)
|
112
|
+
: story_ptr_base(nullptr, nullptr)
|
113
|
+
, _ptr(nullptr)
|
114
|
+
{
|
115
|
+
inkAssert(ptr == nullptr, "can not create story_ptr from existing pointer!");
|
116
|
+
}
|
117
|
+
|
118
|
+
// null constructor
|
119
|
+
story_ptr()
|
120
|
+
: story_ptr_base(nullptr, nullptr)
|
121
|
+
, _ptr(nullptr)
|
122
|
+
{
|
123
|
+
}
|
124
|
+
|
125
|
+
// destructor
|
126
|
+
~story_ptr();
|
127
|
+
|
128
|
+
// == copy methods ==
|
129
|
+
/** copy constructor
|
130
|
+
* @param oth
|
131
|
+
*/
|
132
|
+
story_ptr(const story_ptr<T>& oth);
|
133
|
+
/** copy assigment operator
|
134
|
+
* @param oth
|
135
|
+
*/
|
136
|
+
story_ptr<T>& operator=(const story_ptr<T>& oth);
|
137
|
+
|
138
|
+
// == casting ==
|
139
|
+
/** pointer cast while keeping ref count
|
140
|
+
* @tparam U new pointer type, valid cast form T to U must be available
|
141
|
+
*/
|
142
|
+
template<typename U>
|
143
|
+
story_ptr<U> cast()
|
144
|
+
{
|
145
|
+
// if cast fails, return null
|
146
|
+
#ifdef INK_ENABLE_UNREAL
|
147
|
+
// Unreal disables RTTI
|
148
|
+
U* casted = reinterpret_cast<U*>(_ptr);
|
149
|
+
#else
|
150
|
+
U* casted = dynamic_cast<U*>(_ptr);
|
151
|
+
#endif
|
152
|
+
if (casted == nullptr)
|
153
|
+
return nullptr;
|
154
|
+
|
155
|
+
// create new pointer with casted value but same instance blocks
|
156
|
+
return story_ptr<U>(casted, *this);
|
157
|
+
}
|
158
|
+
|
159
|
+
// == equality ==
|
160
|
+
/** implement operator== */
|
161
|
+
inline bool operator==(const story_ptr<T>& other) { return _ptr == other._ptr; }
|
162
|
+
|
163
|
+
// == validity ==
|
164
|
+
/** checks if optional contains a value */
|
165
|
+
bool is_valid() const { return story_ptr_base::is_valid() && _ptr; }
|
166
|
+
|
167
|
+
/** auto cast to bool with value from @ref #is_valid() */
|
168
|
+
inline operator bool() const { return is_valid(); }
|
169
|
+
|
170
|
+
// === dereference operators ==
|
171
|
+
/** access value as ptr
|
172
|
+
* @retval nullptr if value is not @ref #is_valid() "valid"
|
173
|
+
*/
|
174
|
+
inline T* get() { return is_valid() ? _ptr : nullptr; }
|
175
|
+
|
176
|
+
/** access value as ptr
|
177
|
+
* @retval nullptr if value is not @ref #is_valid() "valid"
|
178
|
+
*/
|
179
|
+
inline const T* get() const { return is_valid() ? _ptr : nullptr; }
|
180
|
+
|
181
|
+
/** implement operator-> */
|
182
|
+
inline T* operator->() { return get(); }
|
183
|
+
|
184
|
+
/** implement operator-> */
|
185
|
+
inline const T* operator->() const { return get(); }
|
186
|
+
|
187
|
+
/** implement operator* */
|
188
|
+
inline T& operator*() { return *get(); }
|
189
|
+
|
190
|
+
/** implement operator* */
|
191
|
+
inline const T& operator*() const { return *get(); }
|
192
|
+
|
193
|
+
private:
|
194
|
+
T* _ptr;
|
195
|
+
};
|
196
|
+
|
197
|
+
template<typename T>
|
198
|
+
story_ptr<T>::~story_ptr()
|
199
|
+
{
|
200
|
+
if (remove_reference()) {
|
201
|
+
delete _ptr;
|
202
|
+
_ptr = nullptr;
|
203
|
+
}
|
204
|
+
}
|
205
|
+
|
206
|
+
template<typename T>
|
207
|
+
story_ptr<T>::story_ptr(const story_ptr<T>& other)
|
208
|
+
: story_ptr_base(other)
|
209
|
+
, _ptr(other._ptr)
|
210
|
+
{
|
211
|
+
add_reference();
|
212
|
+
}
|
213
|
+
|
214
|
+
template<typename T>
|
215
|
+
story_ptr<T>& story_ptr<T>::operator=(const story_ptr<T>& other)
|
216
|
+
{
|
217
|
+
// Clear out any old data
|
218
|
+
if (remove_reference()) {
|
219
|
+
delete _ptr;
|
220
|
+
_ptr = nullptr;
|
221
|
+
}
|
222
|
+
|
223
|
+
// Set pointers
|
224
|
+
set(other);
|
225
|
+
_ptr = other._ptr;
|
226
|
+
|
227
|
+
// initialize
|
228
|
+
add_reference();
|
229
|
+
|
230
|
+
// return reference to self
|
231
|
+
return *this;
|
232
|
+
}
|
233
|
+
} // namespace ink::runtime
|
@@ -0,0 +1,270 @@
|
|
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
|
+
|
12
|
+
#ifdef INK_ENABLE_STL
|
13
|
+
# include <string>
|
14
|
+
#endif
|
15
|
+
|
16
|
+
/** Util templates and implimentation of STL if STL is not available */
|
17
|
+
namespace ink::runtime::internal
|
18
|
+
{
|
19
|
+
template<typename... Ts>
|
20
|
+
constexpr size_t sizeof_largest_type()
|
21
|
+
{
|
22
|
+
size_t ret = 0;
|
23
|
+
return ((ret = sizeof(Ts) > ret ? sizeof(Ts) : ret), ...);
|
24
|
+
}
|
25
|
+
|
26
|
+
template<unsigned int N, typename Arg, typename... Args>
|
27
|
+
struct get_ith_type : /** @cond */ get_ith_type<N - 1, Args...> /** @endcond */ { /** @cond */
|
28
|
+
};
|
29
|
+
|
30
|
+
template<typename Arg, typename... Args>
|
31
|
+
struct get_ith_type<0, Arg, Args...> {
|
32
|
+
/** @endcond */
|
33
|
+
using type = Arg;
|
34
|
+
};
|
35
|
+
|
36
|
+
// constant and is_same from http://www.cppreference.com
|
37
|
+
template<typename T, T v>
|
38
|
+
struct constant {
|
39
|
+
static constexpr T value = v;
|
40
|
+
typedef T value_type;
|
41
|
+
typedef constant type; // using injected-class-name
|
42
|
+
|
43
|
+
constexpr operator value_type() const noexcept { return value; }
|
44
|
+
|
45
|
+
constexpr value_type operator()() const noexcept { return value; } // since c++14
|
46
|
+
};
|
47
|
+
|
48
|
+
struct false_type : constant<bool, false> {
|
49
|
+
};
|
50
|
+
|
51
|
+
struct true_type : constant<bool, true> {
|
52
|
+
};
|
53
|
+
|
54
|
+
template<typename B>
|
55
|
+
true_type test_ptr_conv(const volatile B*);
|
56
|
+
template<typename>
|
57
|
+
false_type test_ptr_conv(const volatile void*);
|
58
|
+
template<typename B, typename D>
|
59
|
+
auto test_is_base_of(int) -> decltype(test_ptr_conv<B>(static_cast<D*>(nullptr)));
|
60
|
+
|
61
|
+
// template<typename, typename> /// FIXME: needed?
|
62
|
+
// auto test_is_base_of(...) -> true_type;
|
63
|
+
|
64
|
+
template<class Base, class Derived>
|
65
|
+
struct is_base_of : constant<bool, decltype(test_is_base_of<Base, Derived>(0))::value> {
|
66
|
+
};
|
67
|
+
|
68
|
+
template<class T, class U>
|
69
|
+
struct is_same : false_type {
|
70
|
+
};
|
71
|
+
|
72
|
+
template<class T>
|
73
|
+
struct is_same<T, T> : true_type {
|
74
|
+
};
|
75
|
+
|
76
|
+
template<typename T>
|
77
|
+
struct is_pointer : false_type {
|
78
|
+
};
|
79
|
+
|
80
|
+
template<typename T>
|
81
|
+
struct is_pointer<T*> : true_type {
|
82
|
+
};
|
83
|
+
|
84
|
+
template<class T>
|
85
|
+
struct remove_cv {
|
86
|
+
typedef T type;
|
87
|
+
};
|
88
|
+
|
89
|
+
template<class T>
|
90
|
+
struct remove_cv<const T> {
|
91
|
+
typedef T type;
|
92
|
+
};
|
93
|
+
|
94
|
+
template<class T>
|
95
|
+
struct remove_cv<volatile T> {
|
96
|
+
typedef T type;
|
97
|
+
};
|
98
|
+
|
99
|
+
template<class T>
|
100
|
+
struct remove_cv<const volatile T> {
|
101
|
+
typedef T type;
|
102
|
+
};
|
103
|
+
|
104
|
+
template<class T>
|
105
|
+
struct remove_cvref {
|
106
|
+
typedef std::remove_cv_t<std::remove_reference_t<T>> type;
|
107
|
+
};
|
108
|
+
|
109
|
+
// == string testing (from me) ==
|
110
|
+
|
111
|
+
template<typename T>
|
112
|
+
struct is_string : false_type {
|
113
|
+
};
|
114
|
+
|
115
|
+
template<typename T>
|
116
|
+
struct is_string<T&> : is_string<T> {
|
117
|
+
};
|
118
|
+
|
119
|
+
template<typename T>
|
120
|
+
struct is_string<const T> : is_string<T> {
|
121
|
+
};
|
122
|
+
|
123
|
+
template<typename T>
|
124
|
+
struct is_string<const T*> : is_string<T*> {
|
125
|
+
};
|
126
|
+
|
127
|
+
template<typename T>
|
128
|
+
struct string_handler {
|
129
|
+
};
|
130
|
+
|
131
|
+
template<typename T>
|
132
|
+
struct string_handler<const T> : string_handler<T> {
|
133
|
+
};
|
134
|
+
|
135
|
+
template<typename T>
|
136
|
+
struct string_handler<const T*> : string_handler<T*> {
|
137
|
+
};
|
138
|
+
|
139
|
+
template<typename T>
|
140
|
+
struct string_handler<T&> : string_handler<T> {
|
141
|
+
};
|
142
|
+
|
143
|
+
#define MARK_AS_STRING(TYPE, LEN, SRC) \
|
144
|
+
template<> \
|
145
|
+
struct is_string<TYPE> : constant<bool, true> { \
|
146
|
+
}; \
|
147
|
+
template<> \
|
148
|
+
struct string_handler<TYPE> { \
|
149
|
+
static size_t length(const TYPE& x) { return static_cast<size_t>(LEN); } \
|
150
|
+
static void src_copy(const TYPE& x, char* output) \
|
151
|
+
{ \
|
152
|
+
[&output](const char* src) { \
|
153
|
+
while (*src != '\0') \
|
154
|
+
*(output++) = *(src++); \
|
155
|
+
*output = 0; \
|
156
|
+
}(SRC); \
|
157
|
+
} \
|
158
|
+
}
|
159
|
+
|
160
|
+
inline size_t c_str_len(const char* c)
|
161
|
+
{
|
162
|
+
const char* i = c;
|
163
|
+
while (*i != 0)
|
164
|
+
i++;
|
165
|
+
return i - c;
|
166
|
+
}
|
167
|
+
|
168
|
+
MARK_AS_STRING(char*, c_str_len(x), x);
|
169
|
+
#ifdef INK_ENABLE_STL
|
170
|
+
MARK_AS_STRING(std::string, x.size(), x.c_str());
|
171
|
+
#endif
|
172
|
+
#ifdef INK_ENABLE_UNREAL
|
173
|
+
MARK_AS_STRING(FString, x.Len(), TCHAR_TO_UTF8(*x));
|
174
|
+
#endif
|
175
|
+
|
176
|
+
#undef MARK_AS_STRING
|
177
|
+
|
178
|
+
// function_traits from https://functionalcpp.wordpress.com/2013/08/05/function-traits/
|
179
|
+
|
180
|
+
template<class F>
|
181
|
+
struct function_traits;
|
182
|
+
|
183
|
+
// function pointer
|
184
|
+
template<class R, class... Args>
|
185
|
+
struct function_traits<R (*)(Args...)> : public function_traits<R(Args...)> {
|
186
|
+
};
|
187
|
+
|
188
|
+
template<class R, class... Args>
|
189
|
+
struct function_traits<R(Args...)> {
|
190
|
+
using return_type = R;
|
191
|
+
|
192
|
+
static constexpr unsigned int arity = sizeof...(Args);
|
193
|
+
|
194
|
+
template<unsigned int N>
|
195
|
+
struct argument {
|
196
|
+
static_assert(N < arity, "error: invalid parameter index.");
|
197
|
+
using type = typename get_ith_type<N, Args...>::type;
|
198
|
+
};
|
199
|
+
};
|
200
|
+
|
201
|
+
// member function pointer
|
202
|
+
template<class C, class R, class... Args>
|
203
|
+
struct function_traits<R (C::*)(Args...)> : public function_traits<R(C&, Args...)> {
|
204
|
+
};
|
205
|
+
|
206
|
+
// const member function pointer
|
207
|
+
template<class C, class R, class... Args>
|
208
|
+
struct function_traits<R (C::*)(Args...) const> : public function_traits<R(C&, Args...)> {
|
209
|
+
};
|
210
|
+
|
211
|
+
// member object pointer
|
212
|
+
template<class C, class R>
|
213
|
+
struct function_traits<R(C::*)> : public function_traits<R(C&)> {
|
214
|
+
};
|
215
|
+
|
216
|
+
// functor
|
217
|
+
template<class F>
|
218
|
+
struct function_traits {
|
219
|
+
private:
|
220
|
+
using call_type = function_traits<decltype(&F::operator())>;
|
221
|
+
|
222
|
+
public:
|
223
|
+
using return_type = typename call_type::return_type;
|
224
|
+
|
225
|
+
static constexpr unsigned int arity = call_type::arity - 1;
|
226
|
+
|
227
|
+
template<unsigned int N>
|
228
|
+
struct argument {
|
229
|
+
static_assert(N < arity, "error: invalid parameter index.");
|
230
|
+
using type = typename call_type::template argument<N + 1>::type;
|
231
|
+
};
|
232
|
+
};
|
233
|
+
|
234
|
+
// from https://stackoverflow.com/questions/17424477/implementation-c14-make-integer-sequence
|
235
|
+
// using aliases for cleaner syntax
|
236
|
+
template<class T>
|
237
|
+
using Invoke = typename T::type;
|
238
|
+
|
239
|
+
template<unsigned...>
|
240
|
+
struct seq {
|
241
|
+
using type = seq;
|
242
|
+
};
|
243
|
+
|
244
|
+
template<class S1, class S2>
|
245
|
+
struct concat;
|
246
|
+
|
247
|
+
template<unsigned... I1, unsigned... I2>
|
248
|
+
struct concat<seq<I1...>, seq<I2...>> : seq<I1..., (sizeof...(I1) + I2)...> {
|
249
|
+
};
|
250
|
+
|
251
|
+
template<class S1, class S2>
|
252
|
+
using Concat = Invoke<concat<S1, S2>>;
|
253
|
+
|
254
|
+
template<unsigned N>
|
255
|
+
struct gen_seq;
|
256
|
+
template<unsigned N>
|
257
|
+
using GenSeq = Invoke<gen_seq<N>>;
|
258
|
+
|
259
|
+
template<unsigned N>
|
260
|
+
struct gen_seq : Concat<GenSeq<N / 2>, GenSeq<N - N / 2>> {
|
261
|
+
};
|
262
|
+
|
263
|
+
template<>
|
264
|
+
struct gen_seq<0> : seq<> {
|
265
|
+
};
|
266
|
+
|
267
|
+
template<>
|
268
|
+
struct gen_seq<1> : seq<0> {
|
269
|
+
};
|
270
|
+
} // namespace ink::runtime::internal
|
@@ -0,0 +1,169 @@
|
|
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 "list.h"
|
10
|
+
#include "story_ptr.h"
|
11
|
+
#include "system.h"
|
12
|
+
|
13
|
+
namespace ink::runtime
|
14
|
+
{
|
15
|
+
class globals_interface;
|
16
|
+
class runner_interface;
|
17
|
+
class snapshot;
|
18
|
+
|
19
|
+
/** alias for an managed @ref ink::runtime::globals_interface pointer */
|
20
|
+
using globals = story_ptr<globals_interface>;
|
21
|
+
/** alias for an managed @ref ink::runtime::runner_interface pointer */
|
22
|
+
using runner = story_ptr<runner_interface>;
|
23
|
+
/** alias for @ref ink::runtime::list_interface pointer */
|
24
|
+
using list = list_interface*;
|
25
|
+
|
26
|
+
/** A Ink variable
|
27
|
+
*
|
28
|
+
* Used for accassing, writing and observing global variables
|
29
|
+
* @ref ink::runtime::globals_interface::get()
|
30
|
+
* @ref ink::runtime::globals_interface::set()
|
31
|
+
* @ref ink::runtime::globals_interface::observe()
|
32
|
+
*
|
33
|
+
* and for the execution of extern functions
|
34
|
+
* @ref ink::runtime::runner_interface::bind()
|
35
|
+
*/
|
36
|
+
struct value {
|
37
|
+
private:
|
38
|
+
union {
|
39
|
+
bool v_bool;
|
40
|
+
uint32_t v_uint32;
|
41
|
+
int32_t v_int32;
|
42
|
+
const char* v_string;
|
43
|
+
float v_float;
|
44
|
+
list v_list;
|
45
|
+
};
|
46
|
+
|
47
|
+
public:
|
48
|
+
/** Type labels for @ref ink::runtime::value */
|
49
|
+
enum class Type {
|
50
|
+
Bool, ///< containing bool
|
51
|
+
Uint32, ///< containing uint32_t
|
52
|
+
Int32, ///< containing int32_t
|
53
|
+
String, ///< contaning a const char*
|
54
|
+
Float, ///< containing a float
|
55
|
+
List ///< containing a @ref list_interface
|
56
|
+
} type; ///< Label of type currently contained in @ref value
|
57
|
+
|
58
|
+
value()
|
59
|
+
: v_int32{0}
|
60
|
+
, type{Type::Int32}
|
61
|
+
{
|
62
|
+
}
|
63
|
+
|
64
|
+
///@{
|
65
|
+
/** Construct value from corresponding type */
|
66
|
+
value(bool v)
|
67
|
+
: v_bool{v}
|
68
|
+
, type{Type::Bool}
|
69
|
+
{
|
70
|
+
}
|
71
|
+
|
72
|
+
value(uint32_t v)
|
73
|
+
: v_uint32{v}
|
74
|
+
, type{Type::Uint32}
|
75
|
+
{
|
76
|
+
}
|
77
|
+
|
78
|
+
value(int32_t v)
|
79
|
+
: v_int32{v}
|
80
|
+
, type{Type::Int32}
|
81
|
+
{
|
82
|
+
}
|
83
|
+
|
84
|
+
value(const char* v)
|
85
|
+
: v_string{v}
|
86
|
+
, type{Type::String}
|
87
|
+
{
|
88
|
+
}
|
89
|
+
|
90
|
+
value(float v)
|
91
|
+
: v_float{v}
|
92
|
+
, type{Type::Float}
|
93
|
+
{
|
94
|
+
}
|
95
|
+
|
96
|
+
value(list_interface* list)
|
97
|
+
: v_list{list}
|
98
|
+
, type{Type::List}
|
99
|
+
{
|
100
|
+
}
|
101
|
+
|
102
|
+
value(const value& v)
|
103
|
+
: type{v.type}
|
104
|
+
{
|
105
|
+
switch (type) {
|
106
|
+
case Type::Bool: v_bool = v.v_bool; break;
|
107
|
+
case Type::Uint32: v_uint32 = v.v_uint32; break;
|
108
|
+
case Type::Int32: v_int32 = v.v_int32; break;
|
109
|
+
case Type::String: v_string = v.v_string; break;
|
110
|
+
case Type::Float: v_float = v.v_float; break;
|
111
|
+
case Type::List: v_list = v.v_list; break;
|
112
|
+
}
|
113
|
+
}
|
114
|
+
|
115
|
+
/// @}
|
116
|
+
|
117
|
+
/** Get value to corresponding type
|
118
|
+
* @tparam Ty #Type label of type to get
|
119
|
+
* @attention behavior if undefined if Ty != value.type
|
120
|
+
*/
|
121
|
+
template<Type Ty>
|
122
|
+
const auto& get() const
|
123
|
+
{
|
124
|
+
static_assert(Ty != Ty, "No value getter for the selected type");
|
125
|
+
}
|
126
|
+
};
|
127
|
+
|
128
|
+
/** access #value::Type::Bool value */
|
129
|
+
template<>
|
130
|
+
inline const auto& value::get<value::Type::Bool>() const
|
131
|
+
{
|
132
|
+
return v_bool;
|
133
|
+
}
|
134
|
+
|
135
|
+
/** access #value::Type::Uint32 value */
|
136
|
+
template<>
|
137
|
+
inline const auto& value::get<value::Type::Uint32>() const
|
138
|
+
{
|
139
|
+
return v_uint32;
|
140
|
+
}
|
141
|
+
|
142
|
+
/** access #value::Type::Int32 value */
|
143
|
+
template<>
|
144
|
+
inline const auto& value::get<value::Type::Int32>() const
|
145
|
+
{
|
146
|
+
return v_int32;
|
147
|
+
}
|
148
|
+
|
149
|
+
/** access #value::Type::String value */
|
150
|
+
template<>
|
151
|
+
inline const auto& value::get<value::Type::String>() const
|
152
|
+
{
|
153
|
+
return v_string;
|
154
|
+
}
|
155
|
+
|
156
|
+
/** access #value::Type::Float value */
|
157
|
+
template<>
|
158
|
+
inline const auto& value::get<value::Type::Float>() const
|
159
|
+
{
|
160
|
+
return v_float;
|
161
|
+
}
|
162
|
+
|
163
|
+
/** access #value::Type::List value */
|
164
|
+
template<>
|
165
|
+
inline const auto& value::get<value::Type::List>() const
|
166
|
+
{
|
167
|
+
return v_list;
|
168
|
+
}
|
169
|
+
} // namespace ink::runtime
|