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,450 @@
|
|
|
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 "array.h"
|
|
11
|
+
#include "snapshot_impl.h"
|
|
12
|
+
|
|
13
|
+
#ifdef INK_ENABLE_STL
|
|
14
|
+
# include <iosfwd>
|
|
15
|
+
#endif
|
|
16
|
+
|
|
17
|
+
namespace ink::internal
|
|
18
|
+
{
|
|
19
|
+
struct header;
|
|
20
|
+
} // namespace ink::internal
|
|
21
|
+
|
|
22
|
+
namespace ink::runtime::internal
|
|
23
|
+
{
|
|
24
|
+
class prng;
|
|
25
|
+
|
|
26
|
+
// TODO: move to utils
|
|
27
|
+
// memory segments
|
|
28
|
+
// @param bits size in bits
|
|
29
|
+
// @param size segment size in bytes
|
|
30
|
+
constexpr int segmentsFromBits(int bits, int size)
|
|
31
|
+
{
|
|
32
|
+
size *= 8;
|
|
33
|
+
return bits / size + (bits % size ? 1 : 0);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/// managed all list entries and list metadata
|
|
37
|
+
class list_table : public snapshot_interface
|
|
38
|
+
{
|
|
39
|
+
using data_t = int;
|
|
40
|
+
enum class state : char {
|
|
41
|
+
unused,
|
|
42
|
+
used,
|
|
43
|
+
permanent,
|
|
44
|
+
empty
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
public:
|
|
48
|
+
/// handle to acces a list
|
|
49
|
+
struct list {
|
|
50
|
+
constexpr explicit list(int id)
|
|
51
|
+
: lid{id}
|
|
52
|
+
{
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
int lid; ///< id of list to handle
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
/// creates an empty list
|
|
59
|
+
list create();
|
|
60
|
+
|
|
61
|
+
/** @return list_flag with list_id set to list with name list_name */
|
|
62
|
+
list_flag get_list_id(const char* list_name) const;
|
|
63
|
+
|
|
64
|
+
/** @brief converts external flag value to internal */
|
|
65
|
+
list_flag external_fvalue_to_internal(list_flag flag) const
|
|
66
|
+
{
|
|
67
|
+
if (flag == null_flag || flag == empty_flag) {
|
|
68
|
+
return flag;
|
|
69
|
+
}
|
|
70
|
+
// origin flag (no flag but list origin)
|
|
71
|
+
if (flag.list_id < -1) {
|
|
72
|
+
flag.list_id = -flag.list_id - 2;
|
|
73
|
+
flag.flag = -1;
|
|
74
|
+
return flag;
|
|
75
|
+
}
|
|
76
|
+
for (int i = listBegin(flag.list_id); i < _list_end[flag.list_id]; ++i) {
|
|
77
|
+
if (_flag_values[i] == flag.flag) {
|
|
78
|
+
flag.flag = i - listBegin(flag.list_id);
|
|
79
|
+
return flag;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
flag.flag = -1;
|
|
83
|
+
return flag;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
int get_flag_value(list_flag flag) const
|
|
87
|
+
{
|
|
88
|
+
return _flag_values[listBegin(flag.list_id) + flag.flag];
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/// zeros all usage values
|
|
92
|
+
void clear_usage();
|
|
93
|
+
|
|
94
|
+
/// mark list as used
|
|
95
|
+
void mark_used(list);
|
|
96
|
+
|
|
97
|
+
/// delete unused lists
|
|
98
|
+
void gc();
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
// function to setup list_table
|
|
102
|
+
list create_permament();
|
|
103
|
+
list& add_inplace(list& lh, list_flag rh);
|
|
104
|
+
|
|
105
|
+
// parse binary list meta data
|
|
106
|
+
list_table(const char* data, const ink::internal::header&);
|
|
107
|
+
|
|
108
|
+
explicit list_table()
|
|
109
|
+
: _entrySize{0}
|
|
110
|
+
, _valid{false}
|
|
111
|
+
{
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
size_t stringLen(const list_flag& e) const;
|
|
115
|
+
const char* toString(const list_flag& e) const;
|
|
116
|
+
|
|
117
|
+
/** returns len of string representation of list */
|
|
118
|
+
size_t stringLen(const list& l) const;
|
|
119
|
+
|
|
120
|
+
/** converts list to string representation
|
|
121
|
+
* @param out char array with minimu size of stringLen(l)
|
|
122
|
+
* @param l list to stringify
|
|
123
|
+
* @return pointer to end of inserted string
|
|
124
|
+
*/
|
|
125
|
+
char* toString(char* out, const list& l) const;
|
|
126
|
+
|
|
127
|
+
/** Finds flag id to flag name
|
|
128
|
+
* currently used a simple O(n) serach, for the expected number of flags should this be no problem
|
|
129
|
+
* @param flag_name null terminated string contaning the flag name
|
|
130
|
+
* @return list_flag with corresponding name
|
|
131
|
+
* @retval nullopt if no flag was found
|
|
132
|
+
*/
|
|
133
|
+
optional<list_flag> toFlag(const char* flag_name) const;
|
|
134
|
+
|
|
135
|
+
// snapshot interface implementation
|
|
136
|
+
size_t snap(unsigned char* data, const snapper&) const;
|
|
137
|
+
const unsigned char* snap_load(const unsigned char* data, const loader&);
|
|
138
|
+
|
|
139
|
+
/** special traitment when a list get assignet again
|
|
140
|
+
* when a list get assigned and would have no origin, it gets the origin of the base with origin
|
|
141
|
+
* eg. I072
|
|
142
|
+
*/
|
|
143
|
+
list redefine(list lh, list rh);
|
|
144
|
+
|
|
145
|
+
list add(list l, int i);
|
|
146
|
+
list_flag add(list_flag f, int i);
|
|
147
|
+
|
|
148
|
+
list add(list lh, list rh);
|
|
149
|
+
list add(list lh, list_flag rh);
|
|
150
|
+
|
|
151
|
+
list add(list_flag lh, list rh) { return add(rh, lh); }
|
|
152
|
+
|
|
153
|
+
list add(list_flag lh, list_flag rh);
|
|
154
|
+
|
|
155
|
+
list sub(list l, int i);
|
|
156
|
+
list_flag sub(list_flag l, int i);
|
|
157
|
+
list sub(list lh, list rh);
|
|
158
|
+
list sub(list lh, list_flag rh);
|
|
159
|
+
list_flag sub(list_flag lh, list rh);
|
|
160
|
+
|
|
161
|
+
list_flag sub(list_flag lh, list_flag rh) { return lh == rh ? list_flag{lh.list_id, -1} : lh; }
|
|
162
|
+
|
|
163
|
+
list intersect(list lh, list rh);
|
|
164
|
+
list_flag intersect(list lh, list_flag rh);
|
|
165
|
+
|
|
166
|
+
list_flag intersect(list_flag lh, list rh) { return intersect(rh, lh); }
|
|
167
|
+
|
|
168
|
+
list_flag intersect(list_flag lh, list_flag rh) { return lh == rh ? lh : null_flag; }
|
|
169
|
+
|
|
170
|
+
bool to_bool(list l) const { return count(l) > 0; }
|
|
171
|
+
|
|
172
|
+
bool not_bool(list l) const { return ! to_bool(l); }
|
|
173
|
+
|
|
174
|
+
bool to_bool(list_flag lf) const { return count(lf) > 0; }
|
|
175
|
+
|
|
176
|
+
bool not_bool(list_flag lf) const { return ! to_bool(lf); }
|
|
177
|
+
|
|
178
|
+
int count(list l) const;
|
|
179
|
+
int count(list_flag f) const;
|
|
180
|
+
|
|
181
|
+
list_flag min(list l) const;
|
|
182
|
+
|
|
183
|
+
list_flag min(list_flag f) const { return f; }
|
|
184
|
+
|
|
185
|
+
list_flag max(list l) const;
|
|
186
|
+
|
|
187
|
+
list_flag max(list_flag f) const { return f; }
|
|
188
|
+
|
|
189
|
+
list_flag lrnd(list l, prng&) const;
|
|
190
|
+
|
|
191
|
+
list_flag lrnd(list_flag f) const { return f; }
|
|
192
|
+
|
|
193
|
+
list all(list l);
|
|
194
|
+
list all(list_flag l);
|
|
195
|
+
list invert(list l);
|
|
196
|
+
list invert(list_flag f);
|
|
197
|
+
|
|
198
|
+
template<typename L, typename R>
|
|
199
|
+
bool less(L lh, R rh) const
|
|
200
|
+
{
|
|
201
|
+
return max(lh).flag < min(rh).flag;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
template<typename L, typename R>
|
|
205
|
+
bool greater(L lh, R rh) const
|
|
206
|
+
{
|
|
207
|
+
return min(lh).flag > max(rh).flag;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
bool equal(list lh, list rh) const;
|
|
211
|
+
bool equal(list lh, list_flag rh) const;
|
|
212
|
+
|
|
213
|
+
bool equal(list_flag lh, list rh) const { return equal(rh, lh); }
|
|
214
|
+
|
|
215
|
+
bool equal(list_flag lh, list_flag rh) const { return lh == rh; }
|
|
216
|
+
|
|
217
|
+
template<typename L, typename R>
|
|
218
|
+
bool not_equal(L lh, R rh) const
|
|
219
|
+
{
|
|
220
|
+
return equal(lh, rh);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
template<typename L, typename R>
|
|
224
|
+
bool greater_equal(L lh, R rh) const
|
|
225
|
+
{
|
|
226
|
+
return max(lh).flag >= max(rh).flag && min(lh).flag >= min(rh).flag;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
template<typename L, typename R>
|
|
230
|
+
bool less_equal(L lh, R rh) const
|
|
231
|
+
{
|
|
232
|
+
return max(lh).flag <= max(rh).flag && min(lh).flag <= min(rh).flag;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
bool has(list lh, list rh) const;
|
|
236
|
+
bool has(list lh, list_flag rh) const;
|
|
237
|
+
|
|
238
|
+
bool has(list_flag lh, list rh) const { return has(rh, lh); }
|
|
239
|
+
|
|
240
|
+
bool has(list_flag lh, list_flag rh) const { return lh == rh; }
|
|
241
|
+
|
|
242
|
+
template<typename L, typename R>
|
|
243
|
+
bool hasnt(L lh, R rh) const
|
|
244
|
+
{
|
|
245
|
+
return ! has(lh, rh);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
operator bool() const { return _valid; }
|
|
249
|
+
|
|
250
|
+
list range(list l, int min, int max);
|
|
251
|
+
|
|
252
|
+
list_interface* handout_list(list);
|
|
253
|
+
|
|
254
|
+
private:
|
|
255
|
+
void copy_lists(const data_t* src, data_t* dst);
|
|
256
|
+
static constexpr int bits_per_data = sizeof(data_t) * 8;
|
|
257
|
+
|
|
258
|
+
int listBegin(int lid) const { return lid == 0 ? 0 : _list_end[lid - 1]; }
|
|
259
|
+
|
|
260
|
+
const data_t* getPtr(int eid) const
|
|
261
|
+
{
|
|
262
|
+
return _data.begin()
|
|
263
|
+
+ static_cast<std::ptrdiff_t>(_entrySize) * static_cast<std::ptrdiff_t>(eid);
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
data_t* getPtr(int eid)
|
|
267
|
+
{
|
|
268
|
+
return _data.begin()
|
|
269
|
+
+ static_cast<std::ptrdiff_t>(_entrySize) * static_cast<std::ptrdiff_t>(eid);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
int numFlags() const
|
|
273
|
+
{
|
|
274
|
+
return _flag_names.size();
|
|
275
|
+
// return _list_end.end()[-1]; TODO:
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
int numLists() const { return _list_end.size(); }
|
|
279
|
+
|
|
280
|
+
bool getBit(const data_t* data, int id) const
|
|
281
|
+
{
|
|
282
|
+
return data[id / bits_per_data] & (0x01 << (bits_per_data - 1 - (id % bits_per_data)));
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
void setBit(data_t* data, int id, bool value = true)
|
|
286
|
+
{
|
|
287
|
+
data_t mask = 0x01 << (bits_per_data - 1 - (id % bits_per_data));
|
|
288
|
+
if (value) {
|
|
289
|
+
data[id / bits_per_data] |= mask;
|
|
290
|
+
} else {
|
|
291
|
+
data[id / bits_per_data] &= ~mask;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
bool hasList(const data_t* data, int lid) const { return getBit(data, lid); }
|
|
296
|
+
|
|
297
|
+
void setList(data_t* data, int lid, bool value = true)
|
|
298
|
+
{
|
|
299
|
+
if (lid >= 0) {
|
|
300
|
+
setBit(data, lid, value);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
bool hasFlag(const data_t* data, int fid) const { return getBit(data, fid + numLists()); }
|
|
305
|
+
|
|
306
|
+
void setFlag(data_t* data, int fid, bool value = true)
|
|
307
|
+
{
|
|
308
|
+
if (fid >= 0) {
|
|
309
|
+
setBit(data, fid + numLists(), value);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
int toFid(list_flag e) const;
|
|
314
|
+
|
|
315
|
+
auto flagStartMask() const
|
|
316
|
+
{
|
|
317
|
+
struct {
|
|
318
|
+
int segment;
|
|
319
|
+
data_t mask;
|
|
320
|
+
} res{numLists() / bits_per_data, ~static_cast<data_t>(0) >> (numLists() % bits_per_data)};
|
|
321
|
+
|
|
322
|
+
return res;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
template<typename T, int config>
|
|
326
|
+
using managed_array = managed_array < T,
|
|
327
|
+
config<0, abs(config)>;
|
|
328
|
+
|
|
329
|
+
static constexpr int maxMemorySize
|
|
330
|
+
= (config::maxListTypes < 0 || config::maxFlags < 0 || config::maxLists < 0 ? -1 : 1)
|
|
331
|
+
* segmentsFromBits(abs(config::maxListTypes) + abs(config::maxFlags), sizeof(data_t))
|
|
332
|
+
* static_cast<int>(abs(config::maxLists));
|
|
333
|
+
|
|
334
|
+
int _entrySize; ///< entry size in data_t
|
|
335
|
+
// entries (created lists)
|
|
336
|
+
managed_array<data_t, maxMemorySize> _data;
|
|
337
|
+
managed_array<state, config::maxLists> _entry_state;
|
|
338
|
+
|
|
339
|
+
// defined list (meta data)
|
|
340
|
+
managed_array<int, config::maxListTypes> _list_end;
|
|
341
|
+
managed_array<const char*, config::maxFlags> _flag_names;
|
|
342
|
+
managed_array<int, config::maxFlags> _flag_values;
|
|
343
|
+
managed_array<const char*, config::maxListTypes> _list_names;
|
|
344
|
+
/// keep track over lists accessed with get_var, and clear then at gc time
|
|
345
|
+
managed_array<list_interface, config::limitEditableLists> _list_handouts;
|
|
346
|
+
|
|
347
|
+
bool _valid;
|
|
348
|
+
|
|
349
|
+
public:
|
|
350
|
+
friend class name_flag_itr;
|
|
351
|
+
friend class list_impl;
|
|
352
|
+
|
|
353
|
+
class named_flag_itr
|
|
354
|
+
{
|
|
355
|
+
const list_table& _list;
|
|
356
|
+
const data_t* _data;
|
|
357
|
+
|
|
358
|
+
struct {
|
|
359
|
+
list_flag flag;
|
|
360
|
+
const char* name;
|
|
361
|
+
} _pos;
|
|
362
|
+
|
|
363
|
+
void carry()
|
|
364
|
+
{
|
|
365
|
+
if (_pos.flag.flag
|
|
366
|
+
== _list._list_end[_pos.flag.list_id] - _list.listBegin(_pos.flag.list_id)) {
|
|
367
|
+
_pos.flag.flag = 0;
|
|
368
|
+
++_pos.flag.list_id;
|
|
369
|
+
}
|
|
370
|
+
if (_pos.flag.list_id == _list.numLists()) {
|
|
371
|
+
_pos.flag = null_flag;
|
|
372
|
+
} else {
|
|
373
|
+
_pos.name = _list._flag_names[_list.toFid(_pos.flag)];
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
void goToValid()
|
|
378
|
+
{
|
|
379
|
+
bool valid;
|
|
380
|
+
do {
|
|
381
|
+
valid = true;
|
|
382
|
+
int fid = _list.toFid(_pos.flag);
|
|
383
|
+
if (_data == nullptr) {
|
|
384
|
+
if (_list._flag_names[fid] == nullptr) {
|
|
385
|
+
valid = false;
|
|
386
|
+
++_pos.flag.flag;
|
|
387
|
+
}
|
|
388
|
+
} else if (! _list.hasList(_data, _pos.flag.list_id)) {
|
|
389
|
+
valid = false;
|
|
390
|
+
++_pos.flag.list_id;
|
|
391
|
+
} else if (! _list.hasFlag(_data, fid) || _list._flag_names[fid] == nullptr) {
|
|
392
|
+
valid = false;
|
|
393
|
+
++_pos.flag.flag;
|
|
394
|
+
}
|
|
395
|
+
carry();
|
|
396
|
+
} while (_pos.flag != null_flag && ! valid);
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
public:
|
|
400
|
+
bool operator!=(const named_flag_itr& o) const { return _pos.flag != o._pos.flag; }
|
|
401
|
+
|
|
402
|
+
named_flag_itr(const list_table& list, const data_t* filter)
|
|
403
|
+
: _list{list}
|
|
404
|
+
, _data{filter}
|
|
405
|
+
, _pos{null_flag, nullptr} {};
|
|
406
|
+
|
|
407
|
+
named_flag_itr(const list_table& list, const data_t* filter, int)
|
|
408
|
+
: _list{list}, _data{filter}, _pos{{0,0},list._flag_names[0]}
|
|
409
|
+
{
|
|
410
|
+
goToValid();
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
const auto* operator->() const { return &_pos; }
|
|
414
|
+
|
|
415
|
+
const auto& operator*() const { return _pos; }
|
|
416
|
+
|
|
417
|
+
const named_flag_itr& operator++()
|
|
418
|
+
{
|
|
419
|
+
if (_pos.flag == null_flag)
|
|
420
|
+
return *this;
|
|
421
|
+
++_pos.flag.flag;
|
|
422
|
+
carry();
|
|
423
|
+
if (_pos.flag == null_flag)
|
|
424
|
+
return *this;
|
|
425
|
+
goToValid();
|
|
426
|
+
return *this;
|
|
427
|
+
}
|
|
428
|
+
};
|
|
429
|
+
|
|
430
|
+
auto named_flags(list filter = list(-1)) const
|
|
431
|
+
{
|
|
432
|
+
const data_t* f = filter.lid < 0 ? nullptr : getPtr(filter.lid);
|
|
433
|
+
|
|
434
|
+
struct {
|
|
435
|
+
named_flag_itr _begin;
|
|
436
|
+
named_flag_itr _end;
|
|
437
|
+
|
|
438
|
+
named_flag_itr begin() const { return _begin; }
|
|
439
|
+
|
|
440
|
+
named_flag_itr end() const { return _end; }
|
|
441
|
+
} res{named_flag_itr(*this, f, 0), named_flag_itr(*this, f)};
|
|
442
|
+
|
|
443
|
+
return res;
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
#ifdef INK_ENABLE_STL
|
|
447
|
+
std::ostream& write(std::ostream&, list) const;
|
|
448
|
+
#endif
|
|
449
|
+
};
|
|
450
|
+
} // namespace ink::runtime::internal
|
|
@@ -0,0 +1,40 @@
|
|
|
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 "stack.h"
|
|
8
|
+
#include "value.h"
|
|
9
|
+
#include "operations.h"
|
|
10
|
+
|
|
11
|
+
namespace ink::runtime::internal {
|
|
12
|
+
|
|
13
|
+
float floor(float f) {
|
|
14
|
+
if (f >= 0.f) {
|
|
15
|
+
return static_cast<float>(static_cast<int>(f));
|
|
16
|
+
}
|
|
17
|
+
return static_cast<float>(static_cast<int>(f) - 1);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
float ceil(float f) {
|
|
21
|
+
if(f - floor(f) == 0) { return f; }
|
|
22
|
+
return static_cast<float>(static_cast<int>(f) + 1);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
void operation<Command::FLOOR, value_type::float32, void>::operator()(
|
|
26
|
+
basic_eval_stack& stack, value* vals)
|
|
27
|
+
{
|
|
28
|
+
inkAssert(vals[0].type() == value_type::float32, "Expected floating point number to floor.");
|
|
29
|
+
stack.push(value{}.set<value_type::float32>(
|
|
30
|
+
floor(vals->get<value_type::float32>())));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
void operation<Command::CEILING, value_type::float32, void>::operator()(
|
|
34
|
+
basic_eval_stack& stack, value* vals)
|
|
35
|
+
{
|
|
36
|
+
inkAssert(vals[0].type() == value_type::float32, "Expected floating point number to ceil.");
|
|
37
|
+
stack.push(value{}.set<value_type::float32>(
|
|
38
|
+
ceil(vals->get<value_type::float32>())));
|
|
39
|
+
}
|
|
40
|
+
}
|