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,75 @@
|
|
|
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 "story_ptr.h"
|
|
8
|
+
|
|
9
|
+
namespace ink::runtime::internal
|
|
10
|
+
{
|
|
11
|
+
void ref_block::remove_reference(ref_block*& block)
|
|
12
|
+
{
|
|
13
|
+
if (block == nullptr)
|
|
14
|
+
return;
|
|
15
|
+
|
|
16
|
+
// If we only have one references left
|
|
17
|
+
if (block->references <= 1)
|
|
18
|
+
{
|
|
19
|
+
// delete the block
|
|
20
|
+
delete block;
|
|
21
|
+
block = nullptr;
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Otherwise, derecement references
|
|
26
|
+
block->references--;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
story_ptr_base::story_ptr_base(internal::ref_block* story)
|
|
30
|
+
: _story_block(story)
|
|
31
|
+
{
|
|
32
|
+
_instance_block = new ref_block();
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
story_ptr_base::story_ptr_base(internal::ref_block* story, internal::ref_block* instance)
|
|
36
|
+
: _story_block(story), _instance_block(instance)
|
|
37
|
+
{
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
story_ptr_base::story_ptr_base(const story_ptr_base& other)
|
|
41
|
+
: _story_block(other._story_block)
|
|
42
|
+
, _instance_block(other._instance_block)
|
|
43
|
+
{
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
void story_ptr_base::set(const story_ptr_base& other)
|
|
47
|
+
{
|
|
48
|
+
_story_block = other._story_block;
|
|
49
|
+
_instance_block = other._instance_block;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
void story_ptr_base::add_reference()
|
|
53
|
+
{
|
|
54
|
+
// If our block isn't valid, don't bother
|
|
55
|
+
if (_story_block == nullptr || _instance_block == nullptr || !_story_block->valid || !_instance_block->valid)
|
|
56
|
+
{
|
|
57
|
+
_story_block = _instance_block = nullptr;
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
_instance_block->references++;
|
|
62
|
+
_story_block->references++;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
bool story_ptr_base::remove_reference()
|
|
66
|
+
{
|
|
67
|
+
ref_block::remove_reference(_story_block);
|
|
68
|
+
ref_block::remove_reference(_instance_block);
|
|
69
|
+
|
|
70
|
+
bool is_destroyed = _instance_block == nullptr;
|
|
71
|
+
|
|
72
|
+
_instance_block = _story_block = nullptr;
|
|
73
|
+
return is_destroyed;
|
|
74
|
+
}
|
|
75
|
+
} // namespace ink::runtime::internal
|
|
@@ -0,0 +1,125 @@
|
|
|
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
|
+
/// implementation for commands on strings
|
|
8
|
+
/// string_cast is a class which convert an value to a string.
|
|
9
|
+
/// if the value is already a string it dose nothing (just serve the pointer),
|
|
10
|
+
/// else it convert the value to a string and store it, in it internal storage.
|
|
11
|
+
|
|
12
|
+
#include "stack.h"
|
|
13
|
+
#include "value.h"
|
|
14
|
+
#include "string_utils.h"
|
|
15
|
+
#include "operations.h"
|
|
16
|
+
#include "string_table.h"
|
|
17
|
+
|
|
18
|
+
namespace ink::runtime::internal {
|
|
19
|
+
namespace casting {
|
|
20
|
+
/**
|
|
21
|
+
* @brief Wrapper to cast values to string.
|
|
22
|
+
* string representation is stored inside string_cast.
|
|
23
|
+
*/
|
|
24
|
+
class string_cast {
|
|
25
|
+
public:
|
|
26
|
+
string_cast(const value& val);
|
|
27
|
+
const char* get() const { return _str; }
|
|
28
|
+
private:
|
|
29
|
+
const value& _val;
|
|
30
|
+
const char* _str;
|
|
31
|
+
char _data[512]; //TODO define central
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
// constructor for string_cast class
|
|
35
|
+
string_cast::string_cast(const value& val) : _val{val}, _str{nullptr} {
|
|
36
|
+
if (val.type() == value_type::string) {
|
|
37
|
+
// reference string if value is already a string
|
|
38
|
+
_str = val.get<value_type::string>();
|
|
39
|
+
} else {
|
|
40
|
+
// convert else
|
|
41
|
+
_str = _data;
|
|
42
|
+
toStr(_data, 512, val);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
void operation<Command::ADD, value_type::string, void>::operator()(basic_eval_stack& stack, value* vals) {
|
|
47
|
+
// convert values to strings
|
|
48
|
+
casting::string_cast lh(vals[0]);
|
|
49
|
+
casting::string_cast rh (vals[1]);
|
|
50
|
+
|
|
51
|
+
// create new string with needed size
|
|
52
|
+
char* str = _string_table.create(c_str_len(lh.get()) + c_str_len(rh.get()) + 1);
|
|
53
|
+
|
|
54
|
+
// copy to new string
|
|
55
|
+
char* dst = str;
|
|
56
|
+
for(const char* src = lh.get(); *src; ++src) { *dst++ = *src; }
|
|
57
|
+
for(const char* src = rh.get(); *src; ++src) { *dst++ = *src; }
|
|
58
|
+
*dst = 0;
|
|
59
|
+
|
|
60
|
+
stack.push(value{}.set<value_type::string>(str));
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
void operation<Command::IS_EQUAL, value_type::string, void>::operator()(basic_eval_stack& stack, value* vals) {
|
|
64
|
+
// convert values to string
|
|
65
|
+
casting::string_cast lh (vals[0]);
|
|
66
|
+
casting::string_cast rh(vals[1]);
|
|
67
|
+
|
|
68
|
+
// compare strings char wise
|
|
69
|
+
const char* li = lh.get();
|
|
70
|
+
const char* ri = rh.get();
|
|
71
|
+
while(*li && *ri && *li == *ri) { ++li; ++ri; }
|
|
72
|
+
|
|
73
|
+
stack.push(value{}.set<value_type::boolean>(*li == *ri));
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
void operation<Command::NOT_EQUAL, value_type::string, void>::operator()(basic_eval_stack& stack, value* vals) {
|
|
77
|
+
// convert values to string
|
|
78
|
+
casting::string_cast lh (vals[0]);
|
|
79
|
+
casting::string_cast rh(vals[1]);
|
|
80
|
+
|
|
81
|
+
// compare strings char wise
|
|
82
|
+
const char* li = lh.get();
|
|
83
|
+
const char* ri = rh.get();
|
|
84
|
+
while(*li && *ri && *li == *ri){ ++li; ++ri; }
|
|
85
|
+
|
|
86
|
+
stack.push(value{}.set<value_type::boolean>(*li != *ri));
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
bool has(const char* lh, const char* rh) {
|
|
90
|
+
while(isspace(*lh)) { ++lh; }
|
|
91
|
+
while(isspace(*rh)) { ++rh; }
|
|
92
|
+
if(!*lh && !*rh) { return true; }
|
|
93
|
+
for(const char* li = lh; *li; ++li) {
|
|
94
|
+
const char* ri = rh;
|
|
95
|
+
bool match = true;
|
|
96
|
+
int offset = 0;
|
|
97
|
+
for(int i = 0; ri[i] != 0; ++i) {
|
|
98
|
+
if(li[i + offset] != ri[i]) {
|
|
99
|
+
if(isspace(ri[i])) {
|
|
100
|
+
--offset;
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
match = false; break;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
if(match) { return true; }
|
|
107
|
+
}
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
void operation<Command::HAS, value_type::string, void>::operator()(basic_eval_stack& stack, value* vals)
|
|
112
|
+
{
|
|
113
|
+
casting::string_cast lh(vals[0]);
|
|
114
|
+
casting::string_cast rh(vals[1]);
|
|
115
|
+
stack.push(value{}.set<value_type::boolean>(has(lh.get(), rh.get())));
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
void operation<Command::HASNT, value_type::string, void>::operator()(basic_eval_stack& stack, value* vals)
|
|
119
|
+
{
|
|
120
|
+
casting::string_cast lh(vals[0]);
|
|
121
|
+
casting::string_cast rh(vals[1]);
|
|
122
|
+
stack.push(value{}.set<value_type::boolean>(!has(lh.get(), rh.get())));
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
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
|
+
/// defines operations allowed on strings.
|
|
10
|
+
|
|
11
|
+
namespace ink::runtime::internal {
|
|
12
|
+
|
|
13
|
+
namespace casting {
|
|
14
|
+
// define valid castings
|
|
15
|
+
// when operate on float and string, the result is a string
|
|
16
|
+
template<>
|
|
17
|
+
struct cast<value_type::float32, value_type::string>
|
|
18
|
+
{ static constexpr value_type value = value_type::string; };
|
|
19
|
+
template<>
|
|
20
|
+
struct cast<value_type::int32, value_type::string>
|
|
21
|
+
{ static constexpr value_type value = value_type::string; };
|
|
22
|
+
template<>
|
|
23
|
+
struct cast<value_type::uint32, value_type::string>
|
|
24
|
+
{ static constexpr value_type value = value_type::string; };
|
|
25
|
+
template<>
|
|
26
|
+
struct cast<value_type::string, value_type::newline>
|
|
27
|
+
{ static constexpr value_type value = value_type::string; };
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// operation declaration add
|
|
31
|
+
template<>
|
|
32
|
+
class operation<Command::ADD, value_type::string, void> : public operation_base<string_table> {
|
|
33
|
+
public:
|
|
34
|
+
using operation_base::operation_base;
|
|
35
|
+
void operator()(basic_eval_stack& stack, value* vals);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
// operation declaration equality
|
|
39
|
+
template<>
|
|
40
|
+
class operation<Command::IS_EQUAL, value_type::string, void> : public operation_base<void> {
|
|
41
|
+
public:
|
|
42
|
+
using operation_base::operation_base;
|
|
43
|
+
void operator()(basic_eval_stack& stack, value* vals);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
template<>
|
|
47
|
+
class operation<Command::NOT_EQUAL, value_type::string, void> : public operation_base<void> {
|
|
48
|
+
public:
|
|
49
|
+
using operation_base::operation_base;
|
|
50
|
+
void operator()(basic_eval_stack& stack, value* vals);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
template<>
|
|
54
|
+
class operation<Command::HAS, value_type::string, void> : public operation_base<void> {
|
|
55
|
+
public:
|
|
56
|
+
using operation_base::operation_base;
|
|
57
|
+
void operator()(basic_eval_stack& stack, value* vals);
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
template<>
|
|
61
|
+
class operation<Command::HASNT, value_type::string, void> : public operation_base<void> {
|
|
62
|
+
public:
|
|
63
|
+
using operation_base::operation_base;
|
|
64
|
+
void operator()(basic_eval_stack& stack, value* vals);
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
}
|
|
@@ -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
|
+
#include "string_table.h"
|
|
8
|
+
|
|
9
|
+
namespace ink::runtime::internal
|
|
10
|
+
{
|
|
11
|
+
string_table::~string_table()
|
|
12
|
+
{
|
|
13
|
+
// Delete all allocated strings
|
|
14
|
+
for (auto iter = _table.begin(); iter != _table.end(); ++iter)
|
|
15
|
+
delete[] iter.key();
|
|
16
|
+
_table.clear();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
char* string_table::duplicate(const char* str)
|
|
20
|
+
{
|
|
21
|
+
int len = 0;
|
|
22
|
+
for (const char* i = str; *i != 0; ++i) {
|
|
23
|
+
++len;
|
|
24
|
+
}
|
|
25
|
+
char* res = create(len + 1);
|
|
26
|
+
char* out = res;
|
|
27
|
+
for (const char* i = str; *i != 0; ++i, ++out) {
|
|
28
|
+
*out = *i;
|
|
29
|
+
}
|
|
30
|
+
*out = 0;
|
|
31
|
+
return res;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
char* string_table::create(size_t length)
|
|
35
|
+
{
|
|
36
|
+
// allocate the string
|
|
37
|
+
/// @todo use continuous memory
|
|
38
|
+
char* data = new char[length];
|
|
39
|
+
if (data == nullptr)
|
|
40
|
+
return nullptr;
|
|
41
|
+
|
|
42
|
+
// Add to the tree
|
|
43
|
+
bool success = _table.insert(data, true); // TODO: Should it start as used?
|
|
44
|
+
inkAssert(success, "Duplicate string pointer in the string_table. How is that possible?");
|
|
45
|
+
if (! success) {
|
|
46
|
+
delete[] data;
|
|
47
|
+
return nullptr;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Return allocated string
|
|
51
|
+
return data;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
void string_table::clear_usage()
|
|
55
|
+
{
|
|
56
|
+
// Clear usages
|
|
57
|
+
for (auto iter = _table.begin(); iter != _table.end(); ++iter)
|
|
58
|
+
iter.val() = false;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
void string_table::mark_used(const char* string)
|
|
62
|
+
{
|
|
63
|
+
auto iter = _table.find(string);
|
|
64
|
+
if (iter == _table.end())
|
|
65
|
+
return; // assert??
|
|
66
|
+
|
|
67
|
+
// set used flag
|
|
68
|
+
*iter = true;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
void string_table::gc()
|
|
72
|
+
{
|
|
73
|
+
// begin at the start
|
|
74
|
+
auto iter = _table.begin();
|
|
75
|
+
|
|
76
|
+
const char* last = nullptr;
|
|
77
|
+
while (iter != _table.end()) {
|
|
78
|
+
// If the string is not used
|
|
79
|
+
if (! *iter) {
|
|
80
|
+
// Delete it
|
|
81
|
+
delete[] iter.key();
|
|
82
|
+
_table.erase(iter);
|
|
83
|
+
|
|
84
|
+
// Re-establish iterator at last position
|
|
85
|
+
// TODO: BAD. We need inline delete that doesn't invalidate pointers
|
|
86
|
+
if (last == nullptr)
|
|
87
|
+
iter = _table.begin();
|
|
88
|
+
else {
|
|
89
|
+
iter = _table.find(last);
|
|
90
|
+
iter++;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Next
|
|
97
|
+
last = iter.key();
|
|
98
|
+
iter++;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
size_t string_table::snap(unsigned char* data, const snapper&) const
|
|
103
|
+
{
|
|
104
|
+
unsigned char* ptr = data;
|
|
105
|
+
bool should_write = data != nullptr;
|
|
106
|
+
for (size_t i = 0; i < _table.size(); ++i) {
|
|
107
|
+
for (auto itr = _table.begin(); itr != _table.end(); ++itr) {
|
|
108
|
+
if (itr.temp_identifier() == i) {
|
|
109
|
+
size_t length = strlen(itr.key()) + 1;
|
|
110
|
+
if (length == 1) {
|
|
111
|
+
ptr = snap_write(ptr, EMPTY_STRING, 2, should_write);
|
|
112
|
+
} else {
|
|
113
|
+
ptr = snap_write(ptr, itr.key(), length, should_write);
|
|
114
|
+
}
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
ptr = snap_write(ptr, "\0", 1, should_write);
|
|
120
|
+
return ptr - data;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const unsigned char* string_table::snap_load(const unsigned char* data, const loader& loader)
|
|
124
|
+
{
|
|
125
|
+
auto* ptr = data;
|
|
126
|
+
int i = 0;
|
|
127
|
+
while (*ptr) {
|
|
128
|
+
size_t len = 0;
|
|
129
|
+
for (; ptr[len]; ++len)
|
|
130
|
+
;
|
|
131
|
+
++len;
|
|
132
|
+
auto str = create(len);
|
|
133
|
+
loader.string_table.push() = str;
|
|
134
|
+
ptr = snap_read(ptr, str, len);
|
|
135
|
+
if (len == 2 && str[0] == EMPTY_STRING[0]) {
|
|
136
|
+
str[0] = 0;
|
|
137
|
+
}
|
|
138
|
+
mark_used(str);
|
|
139
|
+
}
|
|
140
|
+
return ptr + 1;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
size_t string_table::get_id(const char* string) const
|
|
144
|
+
{
|
|
145
|
+
auto iter = _table.find(string);
|
|
146
|
+
inkAssert(iter != _table.end(), "Try to fetch not contained string!");
|
|
147
|
+
return iter.temp_identifier();
|
|
148
|
+
}
|
|
149
|
+
} // namespace ink::runtime::internal
|
|
@@ -0,0 +1,47 @@
|
|
|
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 "avl_array.h"
|
|
10
|
+
#include "system.h"
|
|
11
|
+
#include "snapshot_impl.h"
|
|
12
|
+
|
|
13
|
+
namespace ink::runtime::internal
|
|
14
|
+
{
|
|
15
|
+
// hash tree sorted by string pointers
|
|
16
|
+
class string_table final : public snapshot_interface
|
|
17
|
+
{
|
|
18
|
+
public:
|
|
19
|
+
virtual ~string_table();
|
|
20
|
+
|
|
21
|
+
// Create a dynmaic string of a particular length
|
|
22
|
+
char* create(size_t length);
|
|
23
|
+
char* duplicate(const char* str);
|
|
24
|
+
|
|
25
|
+
// zeroes all usage values
|
|
26
|
+
void clear_usage();
|
|
27
|
+
|
|
28
|
+
// mark a string as used
|
|
29
|
+
void mark_used(const char* string);
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
// snapshot interface implementation
|
|
33
|
+
size_t snap(unsigned char* data, const snapper&) const;
|
|
34
|
+
const unsigned char* snap_load(const unsigned char* data, const loader&);
|
|
35
|
+
|
|
36
|
+
// get position of string when iterate through data
|
|
37
|
+
// used to enable storing a string table references
|
|
38
|
+
size_t get_id(const char* string) const;
|
|
39
|
+
|
|
40
|
+
// deletes all unused strings
|
|
41
|
+
void gc();
|
|
42
|
+
|
|
43
|
+
private:
|
|
44
|
+
avl_array<const char*, bool, ink::size_t, 100> _table;
|
|
45
|
+
static constexpr const char* EMPTY_STRING = "\x03";
|
|
46
|
+
};
|
|
47
|
+
}
|
|
@@ -0,0 +1,207 @@
|
|
|
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
|
+
#include "traits.h"
|
|
11
|
+
#include "value.h"
|
|
12
|
+
|
|
13
|
+
#include <cstdio>
|
|
14
|
+
|
|
15
|
+
#ifndef EINVAL
|
|
16
|
+
# define EINVAL -1
|
|
17
|
+
#endif
|
|
18
|
+
|
|
19
|
+
namespace ink::runtime::internal
|
|
20
|
+
{
|
|
21
|
+
// error behavior from:
|
|
22
|
+
// https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/itoa-s-itow-s?view=msvc-160
|
|
23
|
+
inline int toStr(char* buffer, size_t size, uint32_t value)
|
|
24
|
+
{
|
|
25
|
+
#ifdef WIN32
|
|
26
|
+
return _itoa_s(value, buffer, size, 10);
|
|
27
|
+
#else
|
|
28
|
+
if (buffer == nullptr || size < 1) {
|
|
29
|
+
return EINVAL;
|
|
30
|
+
}
|
|
31
|
+
int res = snprintf(buffer, size, "%d", value);
|
|
32
|
+
if (res > 0 && res < size) {
|
|
33
|
+
return 0;
|
|
34
|
+
}
|
|
35
|
+
return EINVAL;
|
|
36
|
+
#endif
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// error behavior from:
|
|
40
|
+
// https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/itoa-s-itow-s?view=msvc-160
|
|
41
|
+
inline int toStr(char* buffer, size_t size, int32_t value)
|
|
42
|
+
{
|
|
43
|
+
#ifdef WIN32
|
|
44
|
+
return _itoa_s(value, buffer, size, 10);
|
|
45
|
+
#else
|
|
46
|
+
if (buffer == nullptr || size < 1) {
|
|
47
|
+
return EINVAL;
|
|
48
|
+
}
|
|
49
|
+
int res = snprintf(buffer, size, "%d", value);
|
|
50
|
+
if (res > 0 && res < size) {
|
|
51
|
+
return 0;
|
|
52
|
+
}
|
|
53
|
+
return EINVAL;
|
|
54
|
+
#endif
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// error behavior from:
|
|
58
|
+
// https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/gcvt-s?view=msvc-160
|
|
59
|
+
inline int toStr(char* buffer, size_t size, float value)
|
|
60
|
+
{
|
|
61
|
+
#ifdef WIN32
|
|
62
|
+
int digits = 7;
|
|
63
|
+
for (float f = value; f > 1.f; f /= 10.f) {
|
|
64
|
+
++digits;
|
|
65
|
+
}
|
|
66
|
+
int res = _gcvt_s(buffer, size, value, digits); // number of significant digits
|
|
67
|
+
return res;
|
|
68
|
+
#else
|
|
69
|
+
if (buffer == nullptr || size < 1) {
|
|
70
|
+
return EINVAL;
|
|
71
|
+
}
|
|
72
|
+
int res = snprintf(buffer, size, "%.7f", value);
|
|
73
|
+
if (res < 0 || res >= size) {
|
|
74
|
+
return EINVAL;
|
|
75
|
+
}
|
|
76
|
+
// trunc cat zeros B007
|
|
77
|
+
char* itr = buffer + res - 1;
|
|
78
|
+
while (*itr == '0') {
|
|
79
|
+
*itr-- = 0;
|
|
80
|
+
--res;
|
|
81
|
+
}
|
|
82
|
+
if (*itr == '.') {
|
|
83
|
+
*itr-- = 0;
|
|
84
|
+
--res;
|
|
85
|
+
}
|
|
86
|
+
return 0;
|
|
87
|
+
#endif
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
inline int toStr(char* buffer, size_t size, const char* c)
|
|
91
|
+
{
|
|
92
|
+
char* ptr = buffer;
|
|
93
|
+
size_t i = 0;
|
|
94
|
+
while (*c && i < size) {
|
|
95
|
+
*ptr++ = *c;
|
|
96
|
+
++i;
|
|
97
|
+
}
|
|
98
|
+
if (i >= size) {
|
|
99
|
+
return EINVAL;
|
|
100
|
+
}
|
|
101
|
+
*ptr = 0;
|
|
102
|
+
return 0;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
inline int toStr(char* buffer, size_t size, const value& v)
|
|
106
|
+
{
|
|
107
|
+
switch (v.type()) {
|
|
108
|
+
case value_type::int32: return toStr(buffer, size, v.get<value_type::int32>());
|
|
109
|
+
case value_type::uint32: return toStr(buffer, size, v.get<value_type::uint32>());
|
|
110
|
+
case value_type::float32: return toStr(buffer, size, v.get<value_type::float32>());
|
|
111
|
+
case value_type::newline: return toStr(buffer, size, "\n");
|
|
112
|
+
default: inkFail("only support toStr for numeric types"); return -1;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// return a upper bound for the string representation of the number
|
|
117
|
+
inline constexpr size_t decimal_digits(uint32_t number)
|
|
118
|
+
{
|
|
119
|
+
size_t length = 1;
|
|
120
|
+
while (number /= 10) {
|
|
121
|
+
++length;
|
|
122
|
+
}
|
|
123
|
+
return length;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
inline constexpr size_t decimal_digits(int32_t number)
|
|
127
|
+
{
|
|
128
|
+
size_t length = number < 0 ? 2 : 1;
|
|
129
|
+
while (number /= 10) {
|
|
130
|
+
++length;
|
|
131
|
+
}
|
|
132
|
+
return length;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
inline constexpr size_t decimal_digits(float number)
|
|
136
|
+
{
|
|
137
|
+
return decimal_digits(static_cast<int32_t>(number)) + 8;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
inline constexpr size_t value_length(const value& v)
|
|
141
|
+
{
|
|
142
|
+
switch (v.type()) {
|
|
143
|
+
case value_type::int32: return decimal_digits(v.get<value_type::int32>());
|
|
144
|
+
case value_type::uint32: return decimal_digits(v.get<value_type::uint32>());
|
|
145
|
+
case value_type::float32: return decimal_digits(v.get<value_type::float32>());
|
|
146
|
+
case value_type::string: return c_str_len(v.get<value_type::string>());
|
|
147
|
+
case value_type::newline: return 1;
|
|
148
|
+
default: inkFail("Can't determine length of this value type"); return -1;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
inline constexpr bool str_equal(const char* lh, const char* rh)
|
|
153
|
+
{
|
|
154
|
+
while (*lh && *rh && *lh == *rh) {
|
|
155
|
+
++lh;
|
|
156
|
+
++rh;
|
|
157
|
+
}
|
|
158
|
+
return *lh == *rh;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
inline constexpr bool str_equal_len(const char* lh, const char* rh, size_t len)
|
|
162
|
+
{
|
|
163
|
+
for (size_t i = 0; i < len; ++i) {
|
|
164
|
+
if (! (*rh && *lh && *lh == *rh)) {
|
|
165
|
+
return false;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
return true;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
inline constexpr const char* str_find(const char* str, char c)
|
|
172
|
+
{
|
|
173
|
+
while (*str && *str != c) {
|
|
174
|
+
++str;
|
|
175
|
+
}
|
|
176
|
+
if (*str == c) {
|
|
177
|
+
return str;
|
|
178
|
+
}
|
|
179
|
+
return nullptr;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/** removes leading & tailing spaces as wide spaces
|
|
183
|
+
* @param begin iterator of string
|
|
184
|
+
* @param end iterator of string
|
|
185
|
+
* @return new end iterator
|
|
186
|
+
*/
|
|
187
|
+
template<bool LEADING_SPACES, bool TAILING_SPACES, typename ITR>
|
|
188
|
+
inline constexpr ITR clean_string(ITR begin, ITR end)
|
|
189
|
+
{
|
|
190
|
+
auto dst = begin;
|
|
191
|
+
for (auto src = begin; src != end; ++src) {
|
|
192
|
+
if (dst == begin) {
|
|
193
|
+
if (LEADING_SPACES && isspace(src[0])) {
|
|
194
|
+
continue;
|
|
195
|
+
}
|
|
196
|
+
} else if (src[-1] == '\n' && isspace(src[0])) {
|
|
197
|
+
continue;
|
|
198
|
+
} else if ((isspace(src[0]) && src[0] != '\n') && ((src + 1 == end && TAILING_SPACES) || ((src + 1 != end) && isspace(src[1])))) {
|
|
199
|
+
continue;
|
|
200
|
+
} else if (src[0] == '\n' && dst != begin && dst[-1] == '\n') {
|
|
201
|
+
continue;
|
|
202
|
+
}
|
|
203
|
+
*dst++ = *src;
|
|
204
|
+
}
|
|
205
|
+
return dst;
|
|
206
|
+
}
|
|
207
|
+
} // namespace ink::runtime::internal
|
|
@@ -0,0 +1,39 @@
|
|
|
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 "system.h"
|
|
8
|
+
|
|
9
|
+
#ifndef INK_ENABLE_UNREAL
|
|
10
|
+
|
|
11
|
+
namespace ink
|
|
12
|
+
{
|
|
13
|
+
#define A 54059 /* a prime */
|
|
14
|
+
#define B 76963 /* another prime */
|
|
15
|
+
#define C 86969 /* yet another prime */
|
|
16
|
+
#define FIRSTH 37 /* also prime */
|
|
17
|
+
|
|
18
|
+
hash_t hash_string(const char* string)
|
|
19
|
+
{
|
|
20
|
+
hash_t h = FIRSTH;
|
|
21
|
+
while (*string) {
|
|
22
|
+
h = (h * A) ^ (string[0] * B);
|
|
23
|
+
string++;
|
|
24
|
+
}
|
|
25
|
+
return h; // or return h % C;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
namespace internal
|
|
29
|
+
{
|
|
30
|
+
void zero_memory(void* buffer, size_t length)
|
|
31
|
+
{
|
|
32
|
+
char* buf = static_cast<char*>(buffer);
|
|
33
|
+
for (size_t i = 0; i < length; i++)
|
|
34
|
+
*(buf++) = 0;
|
|
35
|
+
}
|
|
36
|
+
} // namespace internal
|
|
37
|
+
} // namespace ink
|
|
38
|
+
|
|
39
|
+
#endif
|