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,100 @@
|
|
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
|
+
/// Define base constructs to specify by operation headers.
|
10
|
+
|
11
|
+
#include "command.h"
|
12
|
+
#include "stack.h"
|
13
|
+
#include "value.h"
|
14
|
+
|
15
|
+
namespace ink::runtime::internal
|
16
|
+
{
|
17
|
+
|
18
|
+
namespace casting
|
19
|
+
{
|
20
|
+
// default cast to none (invalid cast)
|
21
|
+
template<value_type t1, value_type t2>
|
22
|
+
struct cast {
|
23
|
+
static constexpr value_type value = value_type::none;
|
24
|
+
};
|
25
|
+
|
26
|
+
// no cast for same type
|
27
|
+
template<value_type t>
|
28
|
+
struct cast<t, t> {
|
29
|
+
static constexpr value_type value = t;
|
30
|
+
};
|
31
|
+
} // namespace casting
|
32
|
+
|
33
|
+
/**
|
34
|
+
* @brief Determines the number of arguments needed for an command.
|
35
|
+
*/
|
36
|
+
constexpr size_t command_num_args(Command cmd)
|
37
|
+
{
|
38
|
+
if (cmd >= Command::TERNARY_OPERATORS_START && cmd <= Command::TERNARY_OPERATORS_END) {
|
39
|
+
return 3;
|
40
|
+
} else if (cmd >= Command::BINARY_OPERATORS_START && cmd <= Command::BINARY_OPERATORS_END) {
|
41
|
+
return 2;
|
42
|
+
} else if (cmd >= Command::UNARY_OPERATORS_START && cmd <= Command::UNARY_OPERATORS_END) {
|
43
|
+
return 1;
|
44
|
+
} else {
|
45
|
+
return 0;
|
46
|
+
}
|
47
|
+
}
|
48
|
+
|
49
|
+
/**
|
50
|
+
* @brief Operation definition.
|
51
|
+
* A class which contains a call operator to execute the operation needed
|
52
|
+
* for the command type combination.
|
53
|
+
* @tparam cmd Command which should be executed
|
54
|
+
* @tparam ty type on which the command should be executed
|
55
|
+
*/
|
56
|
+
template<Command cmd, value_type ty, typename enable = void>
|
57
|
+
class operation
|
58
|
+
{
|
59
|
+
public:
|
60
|
+
static constexpr bool enabled = false;
|
61
|
+
|
62
|
+
template<typename T>
|
63
|
+
operation(const T& t)
|
64
|
+
{
|
65
|
+
}
|
66
|
+
|
67
|
+
/**
|
68
|
+
* @brief execute operation.
|
69
|
+
* @param stack were the result(s) get pushed
|
70
|
+
* @param vs array of values, first one = first argument etc
|
71
|
+
*/
|
72
|
+
void operator()(basic_eval_stack& stack, value* vs) { inkFail("operation not implemented!"); }
|
73
|
+
};
|
74
|
+
} // namespace ink::runtime::internal
|
75
|
+
|
76
|
+
// include header here to ensure correct order
|
77
|
+
|
78
|
+
#include "operation_bases.h"
|
79
|
+
#include "numeric_operations.h"
|
80
|
+
#include "string_operations.h"
|
81
|
+
#include "list_operations.h"
|
82
|
+
#include "container_operations.h"
|
83
|
+
#include "casting.h"
|
84
|
+
|
85
|
+
template<typename... T>
|
86
|
+
ink::runtime::internal::value
|
87
|
+
ink::runtime::internal::value::redefine(const value& oth, T&... env) const
|
88
|
+
{
|
89
|
+
if (type() != oth.type() && (type() == value_type::list_flag || type() == value_type::list)
|
90
|
+
&& (oth.type() == value_type::list_flag || oth.type() == value_type::list)) {
|
91
|
+
/// @todo could break origin
|
92
|
+
if (oth.type() == value_type::list) {
|
93
|
+
return value{}.set<value_type::list>(oth.get<value_type::list>());
|
94
|
+
} else {
|
95
|
+
return value{}.set<value_type::list_flag>(oth.get<value_type::list_flag>());
|
96
|
+
}
|
97
|
+
}
|
98
|
+
inkAssert(type() == oth.type(), "try to redefine value of other type");
|
99
|
+
return redefine<value_type::OP_BEGIN, T...>(oth, {&env...});
|
100
|
+
}
|
@@ -0,0 +1,528 @@
|
|
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 "output.h"
|
8
|
+
#include "string_table.h"
|
9
|
+
#include "list_table.h"
|
10
|
+
#include <system.h>
|
11
|
+
#include "string_utils.h"
|
12
|
+
|
13
|
+
#ifdef INK_ENABLE_STL
|
14
|
+
# include <iomanip>
|
15
|
+
#endif
|
16
|
+
|
17
|
+
namespace ink::runtime::internal
|
18
|
+
{
|
19
|
+
basic_stream::basic_stream(value* buffer, size_t len)
|
20
|
+
: _data(buffer)
|
21
|
+
, _max(len)
|
22
|
+
, _size(0)
|
23
|
+
, _save(~0)
|
24
|
+
{
|
25
|
+
}
|
26
|
+
|
27
|
+
void basic_stream::append(const value& in)
|
28
|
+
{
|
29
|
+
// newline after glue -> no newline
|
30
|
+
// newline after glue
|
31
|
+
// SPECIAL: Incoming newline
|
32
|
+
if (in.type() == value_type::newline && _size > 1) {
|
33
|
+
// If the end of the stream is a function start marker, we actually
|
34
|
+
// want to ignore this. Function start trimming.
|
35
|
+
if (_data[_size - 1].type() == value_type::func_start)
|
36
|
+
return;
|
37
|
+
size_t i = _size - 1;
|
38
|
+
while (true) {
|
39
|
+
value& d = _data[i];
|
40
|
+
// ignore additional newlines after newline or glue
|
41
|
+
if (d.type() == value_type::newline || d.type() == value_type::glue) {
|
42
|
+
return;
|
43
|
+
} else if (d.type() == value_type::string && ink::internal::is_whitespace(d.get<value_type::string>())) {
|
44
|
+
} else if (d.type() == value_type::func_start || d.type() == value_type::func_end) {
|
45
|
+
} else {
|
46
|
+
break;
|
47
|
+
}
|
48
|
+
if (i == 0) {
|
49
|
+
return;
|
50
|
+
}
|
51
|
+
--i;
|
52
|
+
}
|
53
|
+
}
|
54
|
+
|
55
|
+
// Ignore leading newlines
|
56
|
+
if (in.type() == value_type::newline && _size == 0)
|
57
|
+
return;
|
58
|
+
|
59
|
+
// Add to data stream
|
60
|
+
inkAssert(_size < _max, "Output stream overflow");
|
61
|
+
_data[_size++] = in;
|
62
|
+
|
63
|
+
// Special: Incoming glue. Trim whitespace/newlines prior
|
64
|
+
// This also applies when a function ends to trim trailing whitespace.
|
65
|
+
if ((in.type() == value_type::glue || in.type() == value_type::func_end) && _size > 1) {
|
66
|
+
// Run backwards
|
67
|
+
size_t i = _size - 2;
|
68
|
+
int func_end_cnt = 0;
|
69
|
+
while (true) {
|
70
|
+
value& d = _data[i];
|
71
|
+
|
72
|
+
// Nullify newlines
|
73
|
+
if (d.type() == value_type::newline) {
|
74
|
+
d = value{};
|
75
|
+
}
|
76
|
+
|
77
|
+
// Nullify whitespace
|
78
|
+
else if (d.type() == value_type::string && ::ink::internal::is_whitespace(d.get<value_type::string>()))
|
79
|
+
d = value{};
|
80
|
+
else if (d.type() == value_type::func_end) {
|
81
|
+
++func_end_cnt;
|
82
|
+
} else if (d.type() == value_type::func_start && func_end_cnt > 0) {
|
83
|
+
--func_end_cnt;
|
84
|
+
}
|
85
|
+
|
86
|
+
// If it's not a newline or whitespace, stop
|
87
|
+
else
|
88
|
+
break;
|
89
|
+
|
90
|
+
// If we've hit the end, break
|
91
|
+
if (i == 0)
|
92
|
+
break;
|
93
|
+
|
94
|
+
// Move on to next element
|
95
|
+
i--;
|
96
|
+
}
|
97
|
+
}
|
98
|
+
}
|
99
|
+
|
100
|
+
void basic_stream::append(const value* in, unsigned int length)
|
101
|
+
{
|
102
|
+
// TODO: Better way to bulk while still executing glue checks?
|
103
|
+
for (size_t i = 0; i < length; i++)
|
104
|
+
append(in[i]);
|
105
|
+
}
|
106
|
+
|
107
|
+
template<typename T>
|
108
|
+
inline void write_char(T& output, char c)
|
109
|
+
{
|
110
|
+
static_assert(always_false<T>::value, "Invalid output type");
|
111
|
+
}
|
112
|
+
|
113
|
+
template<>
|
114
|
+
inline void write_char(char*& output, char c)
|
115
|
+
{
|
116
|
+
(*output++) = c;
|
117
|
+
}
|
118
|
+
|
119
|
+
#ifdef INK_ENABLE_STL
|
120
|
+
template<>
|
121
|
+
inline void write_char(std::stringstream& output, char c)
|
122
|
+
{
|
123
|
+
output.put(c);
|
124
|
+
}
|
125
|
+
#endif
|
126
|
+
|
127
|
+
inline bool get_next(const value* list, size_t i, size_t size, const value** next)
|
128
|
+
{
|
129
|
+
while (i + 1 < size) {
|
130
|
+
*next = &list[i + 1];
|
131
|
+
value_type type = (*next)->type();
|
132
|
+
if ((*next)->printable()) {
|
133
|
+
return true;
|
134
|
+
}
|
135
|
+
i++;
|
136
|
+
}
|
137
|
+
|
138
|
+
return false;
|
139
|
+
}
|
140
|
+
|
141
|
+
template<typename T>
|
142
|
+
void basic_stream::copy_string(const char* str, size_t& dataIter, T& output)
|
143
|
+
{
|
144
|
+
while (*str != 0) {
|
145
|
+
write_char(output, *str++);
|
146
|
+
}
|
147
|
+
}
|
148
|
+
|
149
|
+
#ifdef INK_ENABLE_STL
|
150
|
+
std::string basic_stream::get()
|
151
|
+
{
|
152
|
+
size_t start = find_start();
|
153
|
+
|
154
|
+
// Move up from marker
|
155
|
+
bool hasGlue = false, lastNewline = false;
|
156
|
+
std::stringstream str;
|
157
|
+
for (size_t i = start; i < _size; i++) {
|
158
|
+
if (should_skip(i, hasGlue, lastNewline))
|
159
|
+
continue;
|
160
|
+
if (_data[i].printable()) {
|
161
|
+
_data[i].write(str, _lists_table);
|
162
|
+
}
|
163
|
+
}
|
164
|
+
|
165
|
+
// Reset stream size to where we last held the marker
|
166
|
+
_size = start;
|
167
|
+
|
168
|
+
// Return processed string
|
169
|
+
// remove mulitple accourencies of ' '
|
170
|
+
std::string result = str.str();
|
171
|
+
if (! result.empty()) {
|
172
|
+
auto end = clean_string<true, false>(result.begin(), result.end());
|
173
|
+
if (result.begin() == end) {
|
174
|
+
result.resize(0);
|
175
|
+
} else {
|
176
|
+
_last_char = *(end - 1);
|
177
|
+
result.resize(end - result.begin() - (_last_char == ' ' ? 1 : 0));
|
178
|
+
}
|
179
|
+
}
|
180
|
+
return result;
|
181
|
+
}
|
182
|
+
#endif
|
183
|
+
#ifdef INK_ENABLE_UNREAL
|
184
|
+
FString basic_stream::get()
|
185
|
+
{
|
186
|
+
UE_LOG(
|
187
|
+
InkCpp, Warning,
|
188
|
+
TEXT("Basic stream::get is not implemented correctly and should not be used implemented "
|
189
|
+
"correctly!")
|
190
|
+
);
|
191
|
+
FString str;
|
192
|
+
return str;
|
193
|
+
}
|
194
|
+
#endif
|
195
|
+
|
196
|
+
int basic_stream::queued() const
|
197
|
+
{
|
198
|
+
size_t start = find_start();
|
199
|
+
return _size - start;
|
200
|
+
}
|
201
|
+
|
202
|
+
const value& basic_stream::peek() const
|
203
|
+
{
|
204
|
+
inkAssert(_size > 0, "Attempting to peek empty stream!");
|
205
|
+
return _data[_size - 1];
|
206
|
+
}
|
207
|
+
|
208
|
+
void basic_stream::discard(size_t length)
|
209
|
+
{
|
210
|
+
// discard elements
|
211
|
+
_size -= length;
|
212
|
+
if (_size < 0)
|
213
|
+
_size = 0;
|
214
|
+
}
|
215
|
+
|
216
|
+
void basic_stream::get(value* ptr, size_t length)
|
217
|
+
{
|
218
|
+
// Find start
|
219
|
+
size_t start = find_start();
|
220
|
+
|
221
|
+
const value* end = ptr + length;
|
222
|
+
// inkAssert(_size - start < length, "Insufficient space in data array to store stream
|
223
|
+
// contents!");
|
224
|
+
|
225
|
+
// Move up from marker
|
226
|
+
bool hasGlue = false, lastNewline = false;
|
227
|
+
for (size_t i = start; i < _size; i++) {
|
228
|
+
if (should_skip(i, hasGlue, lastNewline))
|
229
|
+
continue;
|
230
|
+
|
231
|
+
// Make sure we can fit the next element
|
232
|
+
inkAssert(ptr < end, "Insufficient space in data array to store stream contents!");
|
233
|
+
|
234
|
+
// Copy any value elements
|
235
|
+
if (_data[i].printable()) {
|
236
|
+
*(ptr++) = _data[i];
|
237
|
+
}
|
238
|
+
}
|
239
|
+
|
240
|
+
// Reset stream size to where we last held the marker
|
241
|
+
_size = start;
|
242
|
+
}
|
243
|
+
|
244
|
+
bool basic_stream::has_marker() const { return entries_since_marker() >= 0; }
|
245
|
+
|
246
|
+
int basic_stream::entries_since_marker() const
|
247
|
+
{
|
248
|
+
// TODO: Cache?
|
249
|
+
for (size_t i = 0; i < _size; i++) {
|
250
|
+
if (_data[i].type() == value_type::marker)
|
251
|
+
return i;
|
252
|
+
}
|
253
|
+
|
254
|
+
return -1;
|
255
|
+
}
|
256
|
+
|
257
|
+
bool basic_stream::ends_with(value_type type) const
|
258
|
+
{
|
259
|
+
if (_size == 0)
|
260
|
+
return false;
|
261
|
+
|
262
|
+
return _data[_size - 1].type() == type;
|
263
|
+
}
|
264
|
+
|
265
|
+
bool basic_stream::saved_ends_with(value_type type) const
|
266
|
+
{
|
267
|
+
inkAssert(_save != ~0, "Stream is not saved!");
|
268
|
+
|
269
|
+
if (_save == 0)
|
270
|
+
return false;
|
271
|
+
|
272
|
+
return _data[_save - 1].type() == type;
|
273
|
+
}
|
274
|
+
|
275
|
+
void basic_stream::save()
|
276
|
+
{
|
277
|
+
inkAssert(_save == ~0, "Can not save over existing save point!");
|
278
|
+
|
279
|
+
// Save the current size
|
280
|
+
_save = _size;
|
281
|
+
}
|
282
|
+
|
283
|
+
void basic_stream::restore()
|
284
|
+
{
|
285
|
+
inkAssert(_save != ~0, "No save point to restore!");
|
286
|
+
|
287
|
+
// Restore size to saved position
|
288
|
+
_size = _save;
|
289
|
+
_save = ~0;
|
290
|
+
}
|
291
|
+
|
292
|
+
void basic_stream::forget()
|
293
|
+
{
|
294
|
+
inkAssert(_save != ~0, "No save point to forget!");
|
295
|
+
|
296
|
+
// Just null the save point and continue as normal
|
297
|
+
_save = ~0;
|
298
|
+
}
|
299
|
+
|
300
|
+
template char* basic_stream::get_alloc<true>(string_table& strings, list_table& lists);
|
301
|
+
template char* basic_stream::get_alloc<false>(string_table& strings, list_table& lists);
|
302
|
+
|
303
|
+
template<bool RemoveTail>
|
304
|
+
char* basic_stream::get_alloc(string_table& strings, list_table& lists)
|
305
|
+
{
|
306
|
+
size_t start = find_start();
|
307
|
+
|
308
|
+
// Two passes. First for length
|
309
|
+
size_t length = 0;
|
310
|
+
bool hasGlue = false, lastNewline = false;
|
311
|
+
for (size_t i = start; i < _size; i++) {
|
312
|
+
if (should_skip(i, hasGlue, lastNewline))
|
313
|
+
continue;
|
314
|
+
++length; // potenzial space to sperate
|
315
|
+
if (_data[i].printable()) {
|
316
|
+
switch (_data[i].type()) {
|
317
|
+
case value_type::list: length += lists.stringLen(_data[i].get<value_type::list>()); break;
|
318
|
+
case value_type::list_flag:
|
319
|
+
length += lists.stringLen(_data[i].get<value_type::list_flag>());
|
320
|
+
break;
|
321
|
+
default: length += value_length(_data[i]);
|
322
|
+
}
|
323
|
+
}
|
324
|
+
}
|
325
|
+
|
326
|
+
// Allocate
|
327
|
+
char* buffer = strings.create(length + 1);
|
328
|
+
char* end = buffer + length + 1;
|
329
|
+
char* ptr = buffer;
|
330
|
+
hasGlue = false;
|
331
|
+
lastNewline = false;
|
332
|
+
for (size_t i = start; i < _size; i++) {
|
333
|
+
if (should_skip(i, hasGlue, lastNewline))
|
334
|
+
continue;
|
335
|
+
if (! _data[i].printable()) {
|
336
|
+
continue;
|
337
|
+
}
|
338
|
+
switch (_data[i].type()) {
|
339
|
+
case value_type::int32:
|
340
|
+
case value_type::float32:
|
341
|
+
case value_type::uint32:
|
342
|
+
// Convert to string and advance
|
343
|
+
toStr(ptr, end - ptr, _data[i]);
|
344
|
+
while (*ptr != 0)
|
345
|
+
ptr++;
|
346
|
+
|
347
|
+
break;
|
348
|
+
case value_type::string: {
|
349
|
+
// Copy string and advance
|
350
|
+
const char* value = _data[i].get<value_type::string>();
|
351
|
+
copy_string(value, i, ptr);
|
352
|
+
} break;
|
353
|
+
case value_type::newline:
|
354
|
+
*ptr = '\n';
|
355
|
+
ptr++;
|
356
|
+
break;
|
357
|
+
case value_type::list: ptr = lists.toString(ptr, _data[i].get<value_type::list>()); break;
|
358
|
+
case value_type::list_flag:
|
359
|
+
ptr = lists.toString(ptr, _data[i].get<value_type::list>());
|
360
|
+
break;
|
361
|
+
default: inkFail("cant convert expression to string!");
|
362
|
+
}
|
363
|
+
}
|
364
|
+
|
365
|
+
// Make sure last character is a null
|
366
|
+
*ptr = 0;
|
367
|
+
|
368
|
+
// Reset stream size to where we last held the marker
|
369
|
+
_size = start;
|
370
|
+
|
371
|
+
// Return processed string
|
372
|
+
end = clean_string<true, false>(buffer, buffer + c_str_len(buffer));
|
373
|
+
*end = 0;
|
374
|
+
if (end != buffer) {
|
375
|
+
_last_char = end[-1];
|
376
|
+
if constexpr (RemoveTail) {
|
377
|
+
if (_last_char == ' ') {
|
378
|
+
end[-1] = 0;
|
379
|
+
}
|
380
|
+
}
|
381
|
+
} else {
|
382
|
+
_last_char = 'e';
|
383
|
+
}
|
384
|
+
|
385
|
+
return buffer;
|
386
|
+
}
|
387
|
+
|
388
|
+
size_t basic_stream::find_start() const
|
389
|
+
{
|
390
|
+
// Find marker (or start)
|
391
|
+
size_t start = _size;
|
392
|
+
while (start > 0) {
|
393
|
+
start--;
|
394
|
+
if (_data[start].type() == value_type::marker)
|
395
|
+
break;
|
396
|
+
}
|
397
|
+
|
398
|
+
// Make sure we're not violating a save point
|
399
|
+
if (_save != ~0 && start < _save) {
|
400
|
+
// TODO: check if we don't reset save correct
|
401
|
+
// at some point we can modifiy the output even behind save (probally discard?) and push a new
|
402
|
+
// element -> invalid save point
|
403
|
+
inkAssert(false, "Trying to access output stream prior to save point!");
|
404
|
+
}
|
405
|
+
|
406
|
+
return start;
|
407
|
+
}
|
408
|
+
|
409
|
+
bool basic_stream::should_skip(size_t iter, bool& hasGlue, bool& lastNewline) const
|
410
|
+
{
|
411
|
+
if (_data[iter].printable() && _data[iter].type() != value_type::newline
|
412
|
+
&& _data[iter].type() != value_type::string) {
|
413
|
+
lastNewline = false;
|
414
|
+
hasGlue = false;
|
415
|
+
} else {
|
416
|
+
switch (_data[iter].type()) {
|
417
|
+
case value_type::newline:
|
418
|
+
if (lastNewline)
|
419
|
+
return true;
|
420
|
+
if (hasGlue)
|
421
|
+
return true;
|
422
|
+
lastNewline = true;
|
423
|
+
break;
|
424
|
+
case value_type::glue: hasGlue = true; break;
|
425
|
+
case value_type::string: {
|
426
|
+
lastNewline = false;
|
427
|
+
// an empty string don't count as glued I095
|
428
|
+
for (const char* i = _data[iter].get<value_type::string>(); *i; ++i) {
|
429
|
+
// isspace only supports characters in [0, UCHAR_MAX]
|
430
|
+
if (! isspace(static_cast<unsigned char>(*i))) {
|
431
|
+
hasGlue = false;
|
432
|
+
break;
|
433
|
+
}
|
434
|
+
}
|
435
|
+
} break;
|
436
|
+
default: break;
|
437
|
+
}
|
438
|
+
}
|
439
|
+
|
440
|
+
return false;
|
441
|
+
}
|
442
|
+
|
443
|
+
bool basic_stream::text_past_save() const
|
444
|
+
{
|
445
|
+
// Check if there is text past the save
|
446
|
+
for (size_t i = _save; i < _size; i++) {
|
447
|
+
const value& d = _data[i];
|
448
|
+
if (d.type() == value_type::string) {
|
449
|
+
// TODO: Cache what counts as whitespace?
|
450
|
+
if (! ink::internal::is_whitespace(d.get<value_type::string>(), false))
|
451
|
+
return true;
|
452
|
+
} else if (d.printable()) {
|
453
|
+
return true;
|
454
|
+
} else if (d.type() == value_type::null) {
|
455
|
+
return true;
|
456
|
+
}
|
457
|
+
}
|
458
|
+
|
459
|
+
// No text
|
460
|
+
return false;
|
461
|
+
}
|
462
|
+
|
463
|
+
void basic_stream::clear()
|
464
|
+
{
|
465
|
+
_save = ~0;
|
466
|
+
_size = 0;
|
467
|
+
}
|
468
|
+
|
469
|
+
void basic_stream::mark_used(string_table& strings, list_table& lists) const
|
470
|
+
{
|
471
|
+
// Find all allocated strings and mark them as used
|
472
|
+
for (size_t i = 0; i < _size; i++) {
|
473
|
+
if (_data[i].type() == value_type::string) {
|
474
|
+
string_type str = _data[i].get<value_type::string>();
|
475
|
+
if (str.allocated) {
|
476
|
+
strings.mark_used(str.str);
|
477
|
+
}
|
478
|
+
} else if (_data[i].type() == value_type::list) {
|
479
|
+
lists.mark_used(_data[i].get<value_type::list>());
|
480
|
+
}
|
481
|
+
}
|
482
|
+
}
|
483
|
+
|
484
|
+
#ifdef INK_ENABLE_STL
|
485
|
+
std::ostream& operator<<(std::ostream& out, basic_stream& in)
|
486
|
+
{
|
487
|
+
out << in.get();
|
488
|
+
return out;
|
489
|
+
}
|
490
|
+
|
491
|
+
basic_stream& operator>>(basic_stream& in, std::string& out)
|
492
|
+
{
|
493
|
+
out = in.get();
|
494
|
+
return in;
|
495
|
+
}
|
496
|
+
#endif
|
497
|
+
#ifdef INK_ENABLE_UNREAL
|
498
|
+
basic_stream& operator>>(basic_stream& in, FString& out)
|
499
|
+
{
|
500
|
+
out = in.get();
|
501
|
+
return in;
|
502
|
+
}
|
503
|
+
#endif
|
504
|
+
|
505
|
+
size_t basic_stream::snap(unsigned char* data, const snapper& snapper) const
|
506
|
+
{
|
507
|
+
unsigned char* ptr = data;
|
508
|
+
ptr = snap_write(ptr, _last_char, data != nullptr);
|
509
|
+
ptr = snap_write(ptr, _size, data != nullptr);
|
510
|
+
ptr = snap_write(ptr, _save, data != nullptr);
|
511
|
+
for (auto itr = _data; itr != _data + _size; ++itr) {
|
512
|
+
ptr += itr->snap(data ? ptr : nullptr, snapper);
|
513
|
+
}
|
514
|
+
return ptr - data;
|
515
|
+
}
|
516
|
+
|
517
|
+
const unsigned char* basic_stream::snap_load(const unsigned char* ptr, const loader& loader)
|
518
|
+
{
|
519
|
+
ptr = snap_read(ptr, _last_char);
|
520
|
+
ptr = snap_read(ptr, _size);
|
521
|
+
ptr = snap_read(ptr, _save);
|
522
|
+
inkAssert(_max >= _size, "output is to small to hold stored data");
|
523
|
+
for (auto itr = _data; itr != _data + _size; ++itr) {
|
524
|
+
ptr = itr->snap_load(ptr, loader);
|
525
|
+
}
|
526
|
+
return ptr;
|
527
|
+
}
|
528
|
+
} // namespace ink::runtime::internal
|