inkcpp_rb 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (273) hide show
  1. checksums.yaml +7 -0
  2. data/.ruby-version +1 -0
  3. data/CHANGELOG.md +1 -0
  4. data/Gemfile +10 -0
  5. data/Gemfile.lock +84 -0
  6. data/LICENSE +7 -0
  7. data/README.md +3 -0
  8. data/Rakefile +16 -0
  9. data/bin/console +15 -0
  10. data/bin/setup +10 -0
  11. data/bin/tapioca +29 -0
  12. data/ext/inkcpp_rb/extconf.rb +19 -0
  13. data/ext/inkcpp_rb/inkcpp/.clang-format +99 -0
  14. data/ext/inkcpp_rb/inkcpp/.github/FUNDING.yml +1 -0
  15. data/ext/inkcpp_rb/inkcpp/.github/workflows/build.yml +344 -0
  16. data/ext/inkcpp_rb/inkcpp/.github/workflows/release.yml +49 -0
  17. data/ext/inkcpp_rb/inkcpp/.gitignore +25 -0
  18. data/ext/inkcpp_rb/inkcpp/.gitmodules +9 -0
  19. data/ext/inkcpp_rb/inkcpp/CMakeLists.txt +170 -0
  20. data/ext/inkcpp_rb/inkcpp/CODE_OF_CONDUCT.md +76 -0
  21. data/ext/inkcpp_rb/inkcpp/CONTRIBUTING.md +55 -0
  22. data/ext/inkcpp_rb/inkcpp/Config.cmake.in +2 -0
  23. data/ext/inkcpp_rb/inkcpp/Documentation/cmake_example/CMakeLists.txt +13 -0
  24. data/ext/inkcpp_rb/inkcpp/Documentation/cmake_example/main.c +38 -0
  25. data/ext/inkcpp_rb/inkcpp/Documentation/cmake_example/main.cpp +40 -0
  26. data/ext/inkcpp_rb/inkcpp/Documentation/cmake_example/test.ink +8 -0
  27. data/ext/inkcpp_rb/inkcpp/Documentation/cmake_example/test.ink.json +1 -0
  28. data/ext/inkcpp_rb/inkcpp/Documentation/cmake_example.zip +0 -0
  29. data/ext/inkcpp_rb/inkcpp/Documentation/unreal/InkCPP_DEMO.zip +0 -0
  30. data/ext/inkcpp_rb/inkcpp/Documentation/unreal/imgs/CreateThread.png +0 -0
  31. data/ext/inkcpp_rb/inkcpp/Documentation/unreal/imgs/HandleChoice.png +0 -0
  32. data/ext/inkcpp_rb/inkcpp/Documentation/unreal/imgs/ListElementOf.png +0 -0
  33. data/ext/inkcpp_rb/inkcpp/Documentation/unreal/imgs/MinimalRuntime.png +0 -0
  34. data/ext/inkcpp_rb/inkcpp/Documentation/unreal/imgs/MinimalThread.png +0 -0
  35. data/ext/inkcpp_rb/inkcpp/Documentation/unreal/imgs/ObseverChange.png +0 -0
  36. data/ext/inkcpp_rb/inkcpp/Documentation/unreal/imgs/TagListGetValue.png +0 -0
  37. data/ext/inkcpp_rb/inkcpp/Documentation/unreal/imgs/YieldResume.png +0 -0
  38. data/ext/inkcpp_rb/inkcpp/Doxyfile +2825 -0
  39. data/ext/inkcpp_rb/inkcpp/LICENSE.txt +22 -0
  40. data/ext/inkcpp_rb/inkcpp/Minimal.runsettings +8 -0
  41. data/ext/inkcpp_rb/inkcpp/README.md +192 -0
  42. data/ext/inkcpp_rb/inkcpp/inkcpp/CMakeLists.txt +67 -0
  43. data/ext/inkcpp_rb/inkcpp/inkcpp/array.h +481 -0
  44. data/ext/inkcpp_rb/inkcpp/inkcpp/avl_array.h +833 -0
  45. data/ext/inkcpp_rb/inkcpp/inkcpp/casting.h +93 -0
  46. data/ext/inkcpp_rb/inkcpp/inkcpp/choice.cpp +54 -0
  47. data/ext/inkcpp_rb/inkcpp/inkcpp/collections/restorable.cpp +124 -0
  48. data/ext/inkcpp_rb/inkcpp/inkcpp/collections/restorable.h +406 -0
  49. data/ext/inkcpp_rb/inkcpp/inkcpp/container_operations.cpp +52 -0
  50. data/ext/inkcpp_rb/inkcpp/inkcpp/container_operations.h +34 -0
  51. data/ext/inkcpp_rb/inkcpp/inkcpp/executioner.h +179 -0
  52. data/ext/inkcpp_rb/inkcpp/inkcpp/functional.cpp +86 -0
  53. data/ext/inkcpp_rb/inkcpp/inkcpp/functions.cpp +54 -0
  54. data/ext/inkcpp_rb/inkcpp/inkcpp/functions.h +40 -0
  55. data/ext/inkcpp_rb/inkcpp/inkcpp/globals_impl.cpp +289 -0
  56. data/ext/inkcpp_rb/inkcpp/inkcpp/globals_impl.h +149 -0
  57. data/ext/inkcpp_rb/inkcpp/inkcpp/header.cpp +44 -0
  58. data/ext/inkcpp_rb/inkcpp/inkcpp/include/choice.h +106 -0
  59. data/ext/inkcpp_rb/inkcpp/inkcpp/include/functional.h +327 -0
  60. data/ext/inkcpp_rb/inkcpp/inkcpp/include/globals.h +196 -0
  61. data/ext/inkcpp_rb/inkcpp/inkcpp/include/list.h +187 -0
  62. data/ext/inkcpp_rb/inkcpp/inkcpp/include/runner.h +291 -0
  63. data/ext/inkcpp_rb/inkcpp/inkcpp/include/snapshot.h +61 -0
  64. data/ext/inkcpp_rb/inkcpp/inkcpp/include/story.h +219 -0
  65. data/ext/inkcpp_rb/inkcpp/inkcpp/include/story_ptr.h +233 -0
  66. data/ext/inkcpp_rb/inkcpp/inkcpp/include/traits.h +270 -0
  67. data/ext/inkcpp_rb/inkcpp/inkcpp/include/types.h +169 -0
  68. data/ext/inkcpp_rb/inkcpp/inkcpp/list_impl.cpp +79 -0
  69. data/ext/inkcpp_rb/inkcpp/inkcpp/list_impl.h +39 -0
  70. data/ext/inkcpp_rb/inkcpp/inkcpp/list_operations.cpp +276 -0
  71. data/ext/inkcpp_rb/inkcpp/inkcpp/list_operations.h +356 -0
  72. data/ext/inkcpp_rb/inkcpp/inkcpp/list_table.cpp +841 -0
  73. data/ext/inkcpp_rb/inkcpp/inkcpp/list_table.h +450 -0
  74. data/ext/inkcpp_rb/inkcpp/inkcpp/numeric_operations.cpp +40 -0
  75. data/ext/inkcpp_rb/inkcpp/inkcpp/numeric_operations.h +529 -0
  76. data/ext/inkcpp_rb/inkcpp/inkcpp/operation_bases.h +164 -0
  77. data/ext/inkcpp_rb/inkcpp/inkcpp/operations.h +100 -0
  78. data/ext/inkcpp_rb/inkcpp/inkcpp/output.cpp +528 -0
  79. data/ext/inkcpp_rb/inkcpp/inkcpp/output.h +153 -0
  80. data/ext/inkcpp_rb/inkcpp/inkcpp/platform.h +22 -0
  81. data/ext/inkcpp_rb/inkcpp/inkcpp/random.h +38 -0
  82. data/ext/inkcpp_rb/inkcpp/inkcpp/runner_impl.cpp +1396 -0
  83. data/ext/inkcpp_rb/inkcpp/inkcpp/runner_impl.h +336 -0
  84. data/ext/inkcpp_rb/inkcpp/inkcpp/simple_restorable_stack.h +335 -0
  85. data/ext/inkcpp_rb/inkcpp/inkcpp/snapshot_impl.cpp +182 -0
  86. data/ext/inkcpp_rb/inkcpp/inkcpp/snapshot_impl.h +91 -0
  87. data/ext/inkcpp_rb/inkcpp/inkcpp/snapshot_interface.h +57 -0
  88. data/ext/inkcpp_rb/inkcpp/inkcpp/stack.cpp +618 -0
  89. data/ext/inkcpp_rb/inkcpp/inkcpp/stack.h +243 -0
  90. data/ext/inkcpp_rb/inkcpp/inkcpp/story_impl.cpp +361 -0
  91. data/ext/inkcpp_rb/inkcpp/inkcpp/story_impl.h +92 -0
  92. data/ext/inkcpp_rb/inkcpp/inkcpp/story_ptr.cpp +75 -0
  93. data/ext/inkcpp_rb/inkcpp/inkcpp/string_operations.cpp +125 -0
  94. data/ext/inkcpp_rb/inkcpp/inkcpp/string_operations.h +67 -0
  95. data/ext/inkcpp_rb/inkcpp/inkcpp/string_table.cpp +149 -0
  96. data/ext/inkcpp_rb/inkcpp/inkcpp/string_table.h +47 -0
  97. data/ext/inkcpp_rb/inkcpp/inkcpp/string_utils.h +207 -0
  98. data/ext/inkcpp_rb/inkcpp/inkcpp/system.cpp +39 -0
  99. data/ext/inkcpp_rb/inkcpp/inkcpp/tuple.hpp +151 -0
  100. data/ext/inkcpp_rb/inkcpp/inkcpp/value.cpp +279 -0
  101. data/ext/inkcpp_rb/inkcpp/inkcpp/value.h +666 -0
  102. data/ext/inkcpp_rb/inkcpp/inkcpp_c/CMakeLists.txt +62 -0
  103. data/ext/inkcpp_rb/inkcpp/inkcpp_c/include/inkcpp.h +393 -0
  104. data/ext/inkcpp_rb/inkcpp/inkcpp_c/inkcpp.cpp +344 -0
  105. data/ext/inkcpp_rb/inkcpp/inkcpp_c/inkcpp_c.pc.in +10 -0
  106. data/ext/inkcpp_rb/inkcpp/inkcpp_c/tests/ExternalFunction.c +56 -0
  107. data/ext/inkcpp_rb/inkcpp/inkcpp_c/tests/Globals.c +98 -0
  108. data/ext/inkcpp_rb/inkcpp/inkcpp_c/tests/Lists.c +73 -0
  109. data/ext/inkcpp_rb/inkcpp/inkcpp_c/tests/Observer.c +36 -0
  110. data/ext/inkcpp_rb/inkcpp/inkcpp_c/tests/Snapshot.c +65 -0
  111. data/ext/inkcpp_rb/inkcpp/inkcpp_cl/CMakeLists.txt +49 -0
  112. data/ext/inkcpp_rb/inkcpp/inkcpp_cl/inkcpp_cl.cpp +215 -0
  113. data/ext/inkcpp_rb/inkcpp/inkcpp_cl/test.cpp +209 -0
  114. data/ext/inkcpp_rb/inkcpp/inkcpp_cl/test.h +8 -0
  115. data/ext/inkcpp_rb/inkcpp/inkcpp_compiler/CMakeLists.txt +37 -0
  116. data/ext/inkcpp_rb/inkcpp/inkcpp_compiler/binary_emitter.cpp +446 -0
  117. data/ext/inkcpp_rb/inkcpp/inkcpp_compiler/binary_emitter.h +70 -0
  118. data/ext/inkcpp_rb/inkcpp/inkcpp_compiler/binary_stream.cpp +166 -0
  119. data/ext/inkcpp_rb/inkcpp/inkcpp_compiler/binary_stream.h +79 -0
  120. data/ext/inkcpp_rb/inkcpp/inkcpp_compiler/command.cpp +107 -0
  121. data/ext/inkcpp_rb/inkcpp/inkcpp_compiler/compiler.cpp +96 -0
  122. data/ext/inkcpp_rb/inkcpp/inkcpp_compiler/emitter.cpp +62 -0
  123. data/ext/inkcpp_rb/inkcpp/inkcpp_compiler/emitter.h +104 -0
  124. data/ext/inkcpp_rb/inkcpp/inkcpp_compiler/include/compilation_results.h +22 -0
  125. data/ext/inkcpp_rb/inkcpp/inkcpp_compiler/include/compiler.h +44 -0
  126. data/ext/inkcpp_rb/inkcpp/inkcpp_compiler/json.hpp +24596 -0
  127. data/ext/inkcpp_rb/inkcpp/inkcpp_compiler/json_compiler.cpp +411 -0
  128. data/ext/inkcpp_rb/inkcpp/inkcpp_compiler/json_compiler.h +62 -0
  129. data/ext/inkcpp_rb/inkcpp/inkcpp_compiler/list_data.cpp +47 -0
  130. data/ext/inkcpp_rb/inkcpp/inkcpp_compiler/list_data.h +70 -0
  131. data/ext/inkcpp_rb/inkcpp/inkcpp_compiler/reporter.cpp +107 -0
  132. data/ext/inkcpp_rb/inkcpp/inkcpp_compiler/reporter.h +55 -0
  133. data/ext/inkcpp_rb/inkcpp/inkcpp_py/CMakeLists.txt +19 -0
  134. data/ext/inkcpp_rb/inkcpp/inkcpp_py/example.py +78 -0
  135. data/ext/inkcpp_rb/inkcpp/inkcpp_py/src/module.cpp +317 -0
  136. data/ext/inkcpp_rb/inkcpp/inkcpp_py/tests/conftest.py +53 -0
  137. data/ext/inkcpp_rb/inkcpp/inkcpp_py/tests/test_ExternalFunctions.py +35 -0
  138. data/ext/inkcpp_rb/inkcpp/inkcpp_py/tests/test_Globals.py +40 -0
  139. data/ext/inkcpp_rb/inkcpp/inkcpp_py/tests/test_Lists.py +43 -0
  140. data/ext/inkcpp_rb/inkcpp/inkcpp_py/tests/test_Observer.py +27 -0
  141. data/ext/inkcpp_rb/inkcpp/inkcpp_py/tests/test_Snapshot.py +57 -0
  142. data/ext/inkcpp_rb/inkcpp/inkcpp_py/unreal_example.ink +71 -0
  143. data/ext/inkcpp_rb/inkcpp/inkcpp_test/Array.cpp +115 -0
  144. data/ext/inkcpp_rb/inkcpp/inkcpp_test/CMakeLists.txt +117 -0
  145. data/ext/inkcpp_rb/inkcpp/inkcpp_test/Callstack.cpp +392 -0
  146. data/ext/inkcpp_rb/inkcpp/inkcpp_test/EmptyStringForDivert.cpp +36 -0
  147. data/ext/inkcpp_rb/inkcpp/inkcpp_test/ExternalFunctionsExecuteProperly.cpp +34 -0
  148. data/ext/inkcpp_rb/inkcpp/inkcpp_test/FallbackFunction.cpp +77 -0
  149. data/ext/inkcpp_rb/inkcpp/inkcpp_test/Globals.cpp +73 -0
  150. data/ext/inkcpp_rb/inkcpp/inkcpp_test/InkyJson.cpp +34 -0
  151. data/ext/inkcpp_rb/inkcpp/inkcpp_test/LabelCondition.cpp +60 -0
  152. data/ext/inkcpp_rb/inkcpp/inkcpp_test/Lists.cpp +144 -0
  153. data/ext/inkcpp_rb/inkcpp/inkcpp_test/LookaheadSafe.cpp +46 -0
  154. data/ext/inkcpp_rb/inkcpp/inkcpp_test/Main.cpp +7 -0
  155. data/ext/inkcpp_rb/inkcpp/inkcpp_test/MoveTo.cpp +95 -0
  156. data/ext/inkcpp_rb/inkcpp/inkcpp_test/NewLines.cpp +76 -0
  157. data/ext/inkcpp_rb/inkcpp/inkcpp_test/NoEarlyTags.cpp +33 -0
  158. data/ext/inkcpp_rb/inkcpp/inkcpp_test/Observer.cpp +245 -0
  159. data/ext/inkcpp_rb/inkcpp/inkcpp_test/Pointer.cpp +191 -0
  160. data/ext/inkcpp_rb/inkcpp/inkcpp_test/Restorable.cpp +294 -0
  161. data/ext/inkcpp_rb/inkcpp/inkcpp_test/SpaceAfterBracketChoice.cpp +45 -0
  162. data/ext/inkcpp_rb/inkcpp/inkcpp_test/Stack.cpp +224 -0
  163. data/ext/inkcpp_rb/inkcpp/inkcpp_test/Tags.cpp +131 -0
  164. data/ext/inkcpp_rb/inkcpp/inkcpp_test/ThirdTierChoiceAfterBrackets.cpp +38 -0
  165. data/ext/inkcpp_rb/inkcpp/inkcpp_test/UTF8.cpp +56 -0
  166. data/ext/inkcpp_rb/inkcpp/inkcpp_test/Value.cpp +210 -0
  167. data/ext/inkcpp_rb/inkcpp/inkcpp_test/catch.hpp +17970 -0
  168. data/ext/inkcpp_rb/inkcpp/inkcpp_test/ink/AHF.ink +7 -0
  169. data/ext/inkcpp_rb/inkcpp/inkcpp_test/ink/ChoiceBracketStory.ink +7 -0
  170. data/ext/inkcpp_rb/inkcpp/inkcpp_test/ink/EmptyStringForDivert.ink +13 -0
  171. data/ext/inkcpp_rb/inkcpp/inkcpp_test/ink/ExternalFunctionsExecuteProperly.ink +11 -0
  172. data/ext/inkcpp_rb/inkcpp/inkcpp_test/ink/FallBack.ink +15 -0
  173. data/ext/inkcpp_rb/inkcpp/inkcpp_test/ink/GlobalStory.ink +9 -0
  174. data/ext/inkcpp_rb/inkcpp/inkcpp_test/ink/LabelConditionStory.ink +5 -0
  175. data/ext/inkcpp_rb/inkcpp/inkcpp_test/ink/LinesStory.ink +42 -0
  176. data/ext/inkcpp_rb/inkcpp/inkcpp_test/ink/ListLogicStory.ink +40 -0
  177. data/ext/inkcpp_rb/inkcpp/inkcpp_test/ink/ListStory.ink +8 -0
  178. data/ext/inkcpp_rb/inkcpp/inkcpp_test/ink/LookaheadSafe.ink +14 -0
  179. data/ext/inkcpp_rb/inkcpp/inkcpp_test/ink/MoveTo.ink +36 -0
  180. data/ext/inkcpp_rb/inkcpp/inkcpp_test/ink/NoEarlyTags.ink +19 -0
  181. data/ext/inkcpp_rb/inkcpp/inkcpp_test/ink/ObserverStory.ink +8 -0
  182. data/ext/inkcpp_rb/inkcpp/inkcpp_test/ink/SimpleStoryFlow.ink +65 -0
  183. data/ext/inkcpp_rb/inkcpp/inkcpp_test/ink/TagsStory.ink +22 -0
  184. data/ext/inkcpp_rb/inkcpp/inkcpp_test/ink/TheIntercept.ink +1686 -0
  185. data/ext/inkcpp_rb/inkcpp/inkcpp_test/ink/ThirdTierChoiceAfterBracketsStory.ink +13 -0
  186. data/ext/inkcpp_rb/inkcpp/inkcpp_test/ink/UTF-8-demo.txt +212 -0
  187. data/ext/inkcpp_rb/inkcpp/inkcpp_test/ink/UTF8Story.ink +218 -0
  188. data/ext/inkcpp_rb/inkcpp/inkcpp_test/ink/simple-1.1.1-inklecate.json +154 -0
  189. data/ext/inkcpp_rb/inkcpp/inkcpp_test/ink/simple-1.1.1-inky.json +160 -0
  190. data/ext/inkcpp_rb/inkcpp/notes/ArchitectureNotes.md +54 -0
  191. data/ext/inkcpp_rb/inkcpp/notes/ListNotes.md +69 -0
  192. data/ext/inkcpp_rb/inkcpp/notes/OperationNotes.md +35 -0
  193. data/ext/inkcpp_rb/inkcpp/notes/TagsNotes.md +24 -0
  194. data/ext/inkcpp_rb/inkcpp/notes/WhitespaceNotes.md +28 -0
  195. data/ext/inkcpp_rb/inkcpp/proofing/README.md +3 -0
  196. data/ext/inkcpp_rb/inkcpp/proofing/inkcpp_runtime_driver +12 -0
  197. data/ext/inkcpp_rb/inkcpp/pyproject.toml +63 -0
  198. data/ext/inkcpp_rb/inkcpp/setup.py +166 -0
  199. data/ext/inkcpp_rb/inkcpp/shared/CMakeLists.txt +14 -0
  200. data/ext/inkcpp_rb/inkcpp/shared/private/command.h +172 -0
  201. data/ext/inkcpp_rb/inkcpp/shared/private/header.h +46 -0
  202. data/ext/inkcpp_rb/inkcpp/shared/public/config.h +53 -0
  203. data/ext/inkcpp_rb/inkcpp/shared/public/system.h +307 -0
  204. data/ext/inkcpp_rb/inkcpp/shared/public/version.h +14 -0
  205. data/ext/inkcpp_rb/inkcpp/tests/TestAllSequenceTypes.ink +59 -0
  206. data/ext/inkcpp_rb/inkcpp/tests/TestArithmetic.ink +17 -0
  207. data/ext/inkcpp_rb/inkcpp/tests/TestBasicStringLiterals.ink +8 -0
  208. data/ext/inkcpp_rb/inkcpp/tests/TestBasicTunnel.ink +10 -0
  209. data/ext/inkcpp_rb/inkcpp/tests/TestBlanksInInlineSequences.ink +51 -0
  210. data/ext/inkcpp_rb/inkcpp/tests/TestCallStackEvaluation.ink +15 -0
  211. data/ext/inkcpp_rb/inkcpp/tests/TestChoiceCount.ink +15 -0
  212. data/ext/inkcpp_rb/inkcpp/tests/TestChoiceDivertsToDone.ink +6 -0
  213. data/ext/inkcpp_rb/inkcpp/tests/TestChoiceWithBracketsOnly.ink +9 -0
  214. data/ext/inkcpp_rb/inkcpp/tests/TestCompareDivertTargets.ink +26 -0
  215. data/ext/inkcpp_rb/inkcpp/tests/TestComplexTunnels.ink +22 -0
  216. data/ext/inkcpp_rb/inkcpp/tests/TestConditionalChoiceInWeave.ink +19 -0
  217. data/ext/inkcpp_rb/inkcpp/tests/TestTunnelOnwardsAfterTunnel.ink +17 -0
  218. data/ext/inkcpp_rb/inkcpp/unreal/CMakeLists.txt +51 -0
  219. data/ext/inkcpp_rb/inkcpp/unreal/UE_example.ink +92 -0
  220. data/ext/inkcpp_rb/inkcpp/unreal/blueprint_filter.js +377 -0
  221. data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Resources/Icon128.png +0 -0
  222. data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp/Private/InkAsset.cpp +47 -0
  223. data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp/Private/InkChoice.cpp +40 -0
  224. data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp/Private/InkList.cpp +86 -0
  225. data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp/Private/InkRuntime.cpp +265 -0
  226. data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp/Private/InkThread.cpp +239 -0
  227. data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp/Private/InkVar.cpp +143 -0
  228. data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp/Private/TagList.cpp +95 -0
  229. data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp/Private/inkcpp.cpp +13 -0
  230. data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp/Public/InkAsset.h +50 -0
  231. data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp/Public/InkChoice.h +58 -0
  232. data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp/Public/InkDelegates.h +139 -0
  233. data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp/Public/InkList.h +102 -0
  234. data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp/Public/InkRuntime.h +177 -0
  235. data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp/Public/InkSnapshot.h +30 -0
  236. data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp/Public/InkThread.h +215 -0
  237. data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp/Public/InkVar.h +245 -0
  238. data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp/Public/TagList.h +77 -0
  239. data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp/Public/inkcpp.h +217 -0
  240. data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp/inkcpp.Build.cs +62 -0
  241. data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp_editor/Private/InkAssetFactory.cpp +237 -0
  242. data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp_editor/Private/InkAssetFactory.h +43 -0
  243. data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp_editor/Private/inkcpp_editor.cpp +13 -0
  244. data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp_editor/Private/inklecate_cmd.cpp.in +24 -0
  245. data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp_editor/Public/inkcpp_editor.h +9 -0
  246. data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp_editor/inkcpp_editor.Build.cs +61 -0
  247. data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/inkcpp.uplugin +44 -0
  248. data/ext/inkcpp_rb/inkcpp/unreal/render.css +1 -0
  249. data/ext/inkcpp_rb/inkcpp_rb.cpp +321 -0
  250. data/inkcpp_rb.gemspec +54 -0
  251. data/rbi/inkcpp_rb.rbi +211 -0
  252. data/sorbet/config +4 -0
  253. data/sorbet/rbi/annotations/.gitattributes +1 -0
  254. data/sorbet/rbi/annotations/minitest.rbi +119 -0
  255. data/sorbet/rbi/gems/.gitattributes +1 -0
  256. data/sorbet/rbi/gems/benchmark@0.4.0.rbi +618 -0
  257. data/sorbet/rbi/gems/erubi@1.13.1.rbi +155 -0
  258. data/sorbet/rbi/gems/minitest@5.25.4.rbi +1547 -0
  259. data/sorbet/rbi/gems/netrc@0.11.0.rbi +159 -0
  260. data/sorbet/rbi/gems/parallel@1.26.3.rbi +291 -0
  261. data/sorbet/rbi/gems/prism@1.3.0.rbi +40040 -0
  262. data/sorbet/rbi/gems/rake-compiler@1.2.8.rbi +9 -0
  263. data/sorbet/rbi/gems/rake@13.2.1.rbi +3033 -0
  264. data/sorbet/rbi/gems/rbi@0.2.2.rbi +4527 -0
  265. data/sorbet/rbi/gems/rice@4.3.3.rbi +44 -0
  266. data/sorbet/rbi/gems/spoom@1.5.0.rbi +4932 -0
  267. data/sorbet/rbi/gems/tapioca@0.16.7.rbi +3611 -0
  268. data/sorbet/rbi/gems/thor@1.3.2.rbi +4378 -0
  269. data/sorbet/rbi/gems/yard-sorbet@0.9.0.rbi +435 -0
  270. data/sorbet/rbi/gems/yard@0.9.37.rbi +18379 -0
  271. data/sorbet/tapioca/config.yml +13 -0
  272. data/sorbet/tapioca/require.rb +4 -0
  273. metadata +400 -0
@@ -0,0 +1,481 @@
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 "snapshot_interface.h"
10
+ #include "system.h"
11
+ #include "traits.h"
12
+
13
+ namespace ink::runtime::internal
14
+ {
15
+ template<typename T, bool dynamic, size_t initialCapacity>
16
+ class managed_array : public snapshot_interface
17
+ {
18
+ public:
19
+ managed_array()
20
+ : _static_data{}
21
+ , _capacity{initialCapacity}
22
+ , _size{0}
23
+ {
24
+ if constexpr (dynamic) {
25
+ _dynamic_data = new T[initialCapacity];
26
+ }
27
+ }
28
+
29
+ ~managed_array()
30
+ {
31
+ if constexpr (dynamic) {
32
+ delete[] _dynamic_data;
33
+ }
34
+ }
35
+
36
+ const T& operator[](size_t i) const { return data()[i]; }
37
+
38
+ T& operator[](size_t i) { return data()[i]; }
39
+
40
+ const T* data() const
41
+ {
42
+ if constexpr (dynamic) {
43
+ return _dynamic_data;
44
+ } else {
45
+ return _static_data;
46
+ }
47
+ }
48
+
49
+ T* data()
50
+ {
51
+ if constexpr (dynamic) {
52
+ return _dynamic_data;
53
+ } else {
54
+ return _static_data;
55
+ }
56
+ }
57
+
58
+ const T* begin() const { return data(); }
59
+
60
+ T* begin() { return data(); }
61
+
62
+ const T* end() const { return data() + _size; }
63
+
64
+ T* end() { return data() + _size; }
65
+
66
+ const T& back() const { return end()[-1]; }
67
+
68
+ T& back() { return end()[-1]; }
69
+
70
+ const size_t size() const { return _size; }
71
+
72
+ const size_t capacity() const { return _capacity; }
73
+
74
+ T& push()
75
+ {
76
+ if constexpr (dynamic) {
77
+ if (_size == _capacity) {
78
+ extend();
79
+ }
80
+ } else {
81
+ inkAssert(_size <= _capacity, "Stack Overflow!");
82
+ /// FIXME silent fail!!
83
+ }
84
+ return data()[_size++];
85
+ }
86
+
87
+ void clear() { _size = 0; }
88
+
89
+ void resize(size_t size)
90
+ {
91
+ if constexpr (dynamic) {
92
+ if (size > _capacity) {
93
+ extend(size);
94
+ }
95
+ } else {
96
+ inkAssert(size <= _size, "Only allow to reduce size");
97
+ }
98
+ _size = size;
99
+ }
100
+
101
+ void extend(size_t capacity = 0);
102
+
103
+ size_t snap(unsigned char* data, const snapper& snapper) const
104
+ {
105
+ inkAssert(! is_pointer<T>{}(), "here is a special case oversight");
106
+ unsigned char* ptr = data;
107
+ bool should_write = data != nullptr;
108
+ ptr = snap_write(ptr, _size, should_write);
109
+ for (const T& e : *this) {
110
+ if constexpr (is_base_of<snapshot_interface, T>::value) {
111
+ ptr += e.snap(data == nullptr ? nullptr : ptr, snapper);
112
+ } else {
113
+ ptr = snap_write(ptr, e, should_write);
114
+ }
115
+ }
116
+ return ptr - data;
117
+ }
118
+
119
+ const unsigned char* snap_load(const unsigned char* ptr, const loader& loader)
120
+ {
121
+ decltype(_size) size;
122
+ ptr = snap_read(ptr, size);
123
+ if constexpr (dynamic) {
124
+ resize(size);
125
+ } else {
126
+ inkAssert(size <= initialCapacity, "capacity of non dynamic array is to small vor snapshot!");
127
+ _size = size;
128
+ }
129
+ for (T& e : *this) {
130
+ if constexpr (is_base_of<snapshot_interface, T>::value) {
131
+ ptr = e.snap_load(ptr, loader);
132
+ } else {
133
+ ptr = snap_read(ptr, e);
134
+ }
135
+ }
136
+ return ptr;
137
+ }
138
+
139
+ private:
140
+ if_t<dynamic, char, T> _static_data[dynamic ? 1 : initialCapacity];
141
+ T* _dynamic_data = nullptr;
142
+ size_t _capacity;
143
+ size_t _size;
144
+ };
145
+
146
+ template<typename T, bool dynamic, size_t initialCapacity>
147
+ class managed_restorable_array : public managed_array<T, dynamic, initialCapacity>
148
+ {
149
+ using base = managed_array<T, dynamic, initialCapacity>;
150
+
151
+ public:
152
+ managed_restorable_array()
153
+ : base()
154
+ {
155
+ }
156
+
157
+ void restore() { base::resize(_last_size); }
158
+
159
+ void save() { _last_size = this->size(); }
160
+
161
+ void forgett() { _last_size = 0; }
162
+
163
+ bool has_changed() const { return base::size() != _last_size; }
164
+
165
+ size_t last_size() const { return _last_size; }
166
+
167
+ size_t snap(unsigned char* data, const snapshot_interface::snapper& snapper) const
168
+ {
169
+ unsigned char* ptr = data;
170
+ bool should_write = data != nullptr;
171
+ ptr += base::snap(ptr, snapper);
172
+ ptr = base::snap_write(ptr, _last_size, should_write);
173
+ return ptr - data;
174
+ }
175
+
176
+ const unsigned char* snap_load(const unsigned char* ptr, const snapshot_interface::loader& loader)
177
+ {
178
+ ptr = base::snap_load(ptr, loader);
179
+ ptr = base::snap_read(ptr, _last_size);
180
+ return ptr;
181
+ }
182
+
183
+ private:
184
+ size_t _last_size = 0;
185
+ };
186
+
187
+ template<typename T, bool dynamic, size_t initialCapacity>
188
+ void managed_array<T, dynamic, initialCapacity>::extend(size_t capacity)
189
+ {
190
+ static_assert(dynamic, "Can only extend if array is dynamic!");
191
+ size_t new_capacity = capacity > _capacity ? capacity : 1.5f * _capacity;
192
+ if (new_capacity < 5) {
193
+ new_capacity = 5;
194
+ }
195
+ T* new_data = new T[new_capacity];
196
+
197
+ for (size_t i = 0; i < _capacity; ++i) {
198
+ new_data[i] = _dynamic_data[i];
199
+ }
200
+
201
+ delete[] _dynamic_data;
202
+ _dynamic_data = new_data;
203
+ _capacity = new_capacity;
204
+ }
205
+
206
+ template<typename T>
207
+ class basic_restorable_array : public snapshot_interface
208
+ {
209
+ public:
210
+ basic_restorable_array(T* array, size_t capacity, T nullValue)
211
+ : _saved(false)
212
+ , _array(array)
213
+ , _temp(array + capacity / 2)
214
+ , _capacity(capacity / 2)
215
+ , _null(nullValue)
216
+ {
217
+ inkAssert(
218
+ capacity % 2 == 0,
219
+ "basic_restorable_array requires a datablock of even length to split into two arrays"
220
+ );
221
+
222
+ // zero out main array and put 'nulls' in the clear_temp()
223
+ inkZeroMemory(_array, _capacity * sizeof(T));
224
+ clear_temp();
225
+ }
226
+
227
+ // == Non-Copyable ==
228
+ basic_restorable_array(const basic_restorable_array<T>&) = delete;
229
+ basic_restorable_array<T>& operator=(const basic_restorable_array<T>&) = delete;
230
+
231
+ // set value by index
232
+ void set(size_t index, const T& value);
233
+
234
+ // get value by index
235
+ const T& get(size_t index) const;
236
+
237
+ // size of the array
238
+ inline size_t capacity() const { return _capacity; }
239
+
240
+ // only const indexing is supported due to save/restore system
241
+ inline const T& operator[](size_t index) const { return get(index); }
242
+
243
+ // == Save/Restore ==
244
+ void save();
245
+ void restore();
246
+ void forget();
247
+
248
+ // Resets all values and clears any save points
249
+ void clear(const T& value);
250
+
251
+ // snapshot interface
252
+ virtual size_t snap(unsigned char* data, const snapper&) const;
253
+ virtual const unsigned char* snap_load(const unsigned char* data, const loader&);
254
+
255
+ protected:
256
+ inline T* buffer() { return _array; }
257
+
258
+ void set_new_buffer(T* buffer, size_t capacity)
259
+ {
260
+ _array = buffer;
261
+ _temp = buffer + capacity / 2;
262
+ _capacity = capacity / 2;
263
+ }
264
+
265
+ private:
266
+ inline void check_index(size_t index) const
267
+ {
268
+ inkAssert(index < capacity(), "Index out of range!");
269
+ }
270
+
271
+ void clear_temp();
272
+
273
+ private:
274
+ bool _saved;
275
+
276
+ // real values live here
277
+ T* _array;
278
+
279
+ // we store values here when we're in save mode
280
+ // they're copied on a call to forget()
281
+ T* _temp;
282
+
283
+ // size of both _array and _temp
284
+ size_t _capacity;
285
+
286
+ // null
287
+ const T _null;
288
+ };
289
+
290
+
291
+ template<typename T>
292
+ inline void basic_restorable_array<T>::set(size_t index, const T& value)
293
+ {
294
+ check_index(index);
295
+ inkAssert(value != _null, "Can not add a value considered a 'null' to a restorable_array");
296
+
297
+ // If we're saved, store in second half of the array
298
+ if (_saved) {
299
+ _temp[index] = value;
300
+ } else {
301
+ // Otherwise, store in the main array
302
+ _array[index] = value;
303
+ }
304
+ }
305
+
306
+ template<typename T>
307
+ inline const T& basic_restorable_array<T>::get(size_t index) const
308
+ {
309
+ check_index(index);
310
+
311
+ // If we're in save mode and we have a value at that index, return that instead
312
+ if (_saved && _temp[index] != _null) {
313
+ return _temp[index];
314
+ }
315
+
316
+ // Otherwise, fall back on the real array
317
+ return _array[index];
318
+ }
319
+
320
+ template<typename T>
321
+ inline void basic_restorable_array<T>::save()
322
+ {
323
+ // Put us into save/restore mode
324
+ _saved = true;
325
+ }
326
+
327
+ template<typename T>
328
+ inline void basic_restorable_array<T>::restore()
329
+ {
330
+ clear_temp();
331
+
332
+ // Clear saved flag
333
+ _saved = false;
334
+ }
335
+
336
+ template<typename T>
337
+ inline void basic_restorable_array<T>::forget()
338
+ {
339
+ // Run through the _temp array
340
+ for (size_t i = 0; i < _capacity; i++) {
341
+ // Copy if there's values
342
+ if (_temp[i] != _null) {
343
+ _array[i] = _temp[i];
344
+ }
345
+
346
+ // Clear
347
+ _temp[i] = _null;
348
+ }
349
+ }
350
+
351
+ template<typename T>
352
+ inline void basic_restorable_array<T>::clear_temp()
353
+ {
354
+ // Run through the _temp array
355
+ for (size_t i = 0; i < _capacity; i++) {
356
+ // Clear
357
+ _temp[i] = _null;
358
+ }
359
+ }
360
+
361
+ template<typename T>
362
+ inline void basic_restorable_array<T>::clear(const T& value)
363
+ {
364
+ _saved = false;
365
+ for (size_t i = 0; i < _capacity; i++) {
366
+ _temp[i] = _null;
367
+ _array[i] = value;
368
+ }
369
+ }
370
+
371
+ template<typename T, size_t SIZE>
372
+ class fixed_restorable_array : public basic_restorable_array<T>
373
+ {
374
+ public:
375
+ fixed_restorable_array(const T& initial, const T& nullValue)
376
+ : basic_restorable_array<T>(_buffer, SIZE * 2, nullValue)
377
+ {
378
+ basic_restorable_array<T>::clear(initial);
379
+ }
380
+
381
+ private:
382
+ T _buffer[SIZE * 2];
383
+ };
384
+
385
+ template<typename T>
386
+ class allocated_restorable_array final : public basic_restorable_array<T>
387
+ {
388
+ using base = basic_restorable_array<T>;
389
+
390
+ public:
391
+ allocated_restorable_array(const T& initial, const T& nullValue)
392
+ : basic_restorable_array<T>(0, 0, nullValue)
393
+ , _initialValue{initial}
394
+ , _nullValue{nullValue}
395
+ , _buffer{nullptr}
396
+ {
397
+ }
398
+
399
+ allocated_restorable_array(size_t capacity, const T& initial, const T& nullValue)
400
+ : basic_restorable_array<T>(new T[capacity * 2], capacity * 2, nullValue)
401
+ , _initialValue{initial}
402
+ , _nullValue{nullValue}
403
+ {
404
+ _buffer = this->buffer();
405
+ this->clear(_initialValue);
406
+ }
407
+
408
+ void resize(size_t n)
409
+ {
410
+ size_t new_capacity = 2 * n;
411
+ T* new_buffer = new T[new_capacity];
412
+ if (_buffer) {
413
+ for (size_t i = 0; i < base::capacity(); ++i) {
414
+ new_buffer[i] = _buffer[i];
415
+ // copy temp
416
+ new_buffer[i + base::capacity()] = _buffer[i + base::capacity()];
417
+ }
418
+ delete[] _buffer;
419
+ }
420
+ for (size_t i = base::capacity(); i < new_capacity / 2; ++i) {
421
+ new_buffer[i] = _initialValue;
422
+ new_buffer[i + base::capacity()] = _nullValue;
423
+ }
424
+
425
+ _buffer = new_buffer;
426
+ this->set_new_buffer(_buffer, new_capacity);
427
+ }
428
+
429
+ virtual ~allocated_restorable_array()
430
+ {
431
+ if (_buffer) {
432
+ delete[] _buffer;
433
+ _buffer = nullptr;
434
+ }
435
+ }
436
+
437
+ private:
438
+ T _initialValue;
439
+ T _nullValue;
440
+ T* _buffer;
441
+ };
442
+
443
+ template<typename T>
444
+ inline size_t basic_restorable_array<T>::snap(unsigned char* data, const snapper& snapper) const
445
+ {
446
+ unsigned char* ptr = data;
447
+ bool should_write = data != nullptr;
448
+ ptr = snap_write(ptr, _saved, should_write);
449
+ ptr = snap_write(ptr, _capacity, should_write);
450
+ ptr = snap_write(ptr, _null, should_write);
451
+ for (size_t i = 0; i < _capacity; ++i) {
452
+ ptr = snap_write(ptr, _array[i], should_write);
453
+ ptr = snap_write(ptr, _temp[i], should_write);
454
+ }
455
+ return ptr - data;
456
+ }
457
+
458
+ template<typename T>
459
+ inline const unsigned char*
460
+ basic_restorable_array<T>::snap_load(const unsigned char* data, const loader& loader)
461
+ {
462
+ auto ptr = data;
463
+ ptr = snap_read(ptr, _saved);
464
+ decltype(_capacity) capacity;
465
+ ptr = snap_read(ptr, capacity);
466
+ if (buffer() == nullptr) {
467
+ static_cast<allocated_restorable_array<T>&>(*this).resize(capacity);
468
+ }
469
+ inkAssert(
470
+ _capacity >= capacity, "New config does not allow for necessary size used by this snapshot!"
471
+ );
472
+ T null;
473
+ ptr = snap_read(ptr, null);
474
+ inkAssert(null == _null, "null value is different to snapshot!");
475
+ for (size_t i = 0; i < _capacity; ++i) {
476
+ ptr = snap_read(ptr, _array[i]);
477
+ ptr = snap_read(ptr, _temp[i]);
478
+ }
479
+ return ptr;
480
+ }
481
+ } // namespace ink::runtime::internal