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.
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,243 @@
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 "value.h"
10
+ #include "collections/restorable.h"
11
+ #include "array.h"
12
+ #include "snapshot_impl.h"
13
+
14
+ namespace ink
15
+ {
16
+ namespace runtime
17
+ {
18
+ namespace internal
19
+ {
20
+ class string_table;
21
+
22
+ struct entry {
23
+ hash_t name = 0;
24
+ value data;
25
+ };
26
+
27
+ enum class frame_type : uint32_t {
28
+ function,
29
+ tunnel,
30
+ thread
31
+ };
32
+
33
+ class basic_stack : protected restorable<entry>
34
+ {
35
+ protected:
36
+ basic_stack(entry* data, size_t size);
37
+
38
+ // base class
39
+ using base = restorable<entry>;
40
+
41
+ public:
42
+ virtual ~basic_stack() = default;
43
+
44
+ // Sets existing value, or creates a new one at this callstack entry
45
+ void set(hash_t name, const value& val);
46
+
47
+ // Gets an existing value, or nullptr
48
+ const value* get(hash_t name) const;
49
+ value* get(hash_t name);
50
+ value* get_from_frame(int ci, hash_t name);
51
+
52
+ // pushes a new frame onto the stack
53
+ // @param eval if evaluation mode was active
54
+ template<frame_type>
55
+ void push_frame(offset_t return_to, bool eval);
56
+
57
+ // Pops a frame (and all temporary variables) from the callstack.
58
+ offset_t pop_frame(frame_type* type, bool& eval);
59
+
60
+ // Returns true if there are any frames on the stack
61
+ bool has_frame(frame_type* type = nullptr) const;
62
+
63
+ // Clears the entire stack
64
+ void clear();
65
+
66
+ // Garbage collection
67
+ void mark_used(string_table&, list_table&) const;
68
+
69
+ // == Threading ==
70
+
71
+ // Forks a new thread from the current callstack and returns that thread's unique id
72
+ thread_t fork_thread();
73
+
74
+ // Mark a thread as "done". It's callstack is still preserved until collapse_to_thread is
75
+ // called.
76
+ void complete_thread(thread_t thread);
77
+
78
+ // Collapses the callstack to the state of a single thread
79
+ void collapse_to_thread(thread_t thread);
80
+
81
+ // == Save/Restore ==
82
+ void save();
83
+ void restore();
84
+ void forget();
85
+
86
+ // replace all pointer in current frame with values from _stack
87
+ void fetch_values(basic_stack& _stack);
88
+ // push all values to other _stack
89
+ void push_values(basic_stack& _stack);
90
+
91
+ // snapshot interface
92
+ size_t snap(unsigned char* data, const snapper&) const;
93
+ const unsigned char* snap_load(const unsigned char* data, const loader&);
94
+
95
+ private:
96
+ entry& add(hash_t name, const value& val);
97
+ const entry* pop();
98
+
99
+ entry* do_thread_jump_pop(const iterator& jump);
100
+
101
+ // thread ids
102
+ thread_t _next_thread = 0;
103
+ thread_t _backup_next_thread = 0;
104
+
105
+ static const hash_t NulledHashId = ~0;
106
+ };
107
+
108
+ template<>
109
+ void basic_stack::push_frame<frame_type::function>(offset_t return_to, bool eval);
110
+ template<>
111
+ void basic_stack::push_frame<frame_type::tunnel>(offset_t return_to, bool eval);
112
+ template<>
113
+ void basic_stack::push_frame<frame_type::thread>(offset_t return_to, bool eval);
114
+
115
+ /**
116
+ * @brief stack for call history and temporary variables
117
+ * @tparam N initial capacity of stack
118
+ * @tparam Dynamic weather or not expand if stack is full
119
+ */
120
+ template<size_t N, bool Dynamic = false>
121
+ class stack : public basic_stack
122
+ {
123
+ public:
124
+ stack()
125
+ : basic_stack(&_stack[0], N)
126
+ {
127
+ }
128
+
129
+ private:
130
+ // stack
131
+ entry _stack[N];
132
+ };
133
+
134
+ template<size_t N>
135
+ class stack<N, true> : public basic_stack
136
+ {
137
+ public:
138
+ stack()
139
+ : basic_stack(nullptr, 0)
140
+ {
141
+ }
142
+
143
+ protected:
144
+ virtual void overflow(entry*& buffer, size_t& size) override
145
+ {
146
+ if (! buffer) {
147
+ buffer = _stack.data();
148
+ size = _stack.capacity();
149
+ } else {
150
+ _stack.extend();
151
+ buffer = _stack.data();
152
+ size = _stack.capacity();
153
+ }
154
+ }
155
+
156
+ private:
157
+ managed_array<entry, true, N> _stack;
158
+ };
159
+
160
+ class basic_eval_stack : protected restorable<value>
161
+ {
162
+ protected:
163
+ basic_eval_stack(value* data, size_t size);
164
+
165
+ using base = restorable<value>;
166
+
167
+ public:
168
+ virtual ~basic_eval_stack() = default;
169
+
170
+ // Push value onto the stack
171
+ void push(const value&);
172
+
173
+ // Pop a value off the stack
174
+ value pop();
175
+
176
+ // Gets the top value without popping
177
+ const value& top() const;
178
+
179
+ // Gets the top non null value without popping
180
+ const value& top_value() const;
181
+
182
+ // Check if the stack is empty
183
+ bool is_empty() const;
184
+
185
+ // Clear stack
186
+ void clear();
187
+
188
+ /** Mark used strings and lists for garbage collection */
189
+ void mark_used(string_table&, list_table&) const;
190
+
191
+ // == Save/Restore ==
192
+ void save();
193
+ void restore();
194
+ void forget();
195
+
196
+ // snapshot interface
197
+ size_t snap(unsigned char* data, const snapper& snapper) const
198
+ {
199
+ return base::snap(data, snapper);
200
+ }
201
+
202
+ const unsigned char* snap_load(const unsigned char* data, const loader& loader)
203
+ {
204
+ return base::snap_load(data, loader);
205
+ }
206
+ };
207
+
208
+ template<size_t N, bool dynamic = false>
209
+ class eval_stack : public basic_eval_stack
210
+ {
211
+ public:
212
+ eval_stack()
213
+ : basic_eval_stack(_stack, N)
214
+ {
215
+ }
216
+
217
+ private:
218
+ value _stack[N];
219
+ };
220
+
221
+ template<size_t N>
222
+ class eval_stack<N, true> : public basic_eval_stack
223
+ {
224
+ public:
225
+ eval_stack()
226
+ : basic_eval_stack(nullptr, 0)
227
+ {
228
+ }
229
+
230
+ protected:
231
+ virtual void overflow(value*& buffer, size_t& size) override
232
+ {
233
+ _stack.extend();
234
+ buffer = _stack.data();
235
+ size = _stack.capacity();
236
+ }
237
+
238
+ private:
239
+ managed_array<value, true, N> _stack;
240
+ };
241
+ } // namespace internal
242
+ } // namespace runtime
243
+ } // namespace ink
@@ -0,0 +1,361 @@
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_impl.h"
8
+ #include "platform.h"
9
+ #include "runner_impl.h"
10
+ #include "globals_impl.h"
11
+ #include "snapshot.h"
12
+ #include "snapshot_impl.h"
13
+ #include "snapshot_interface.h"
14
+ #include "version.h"
15
+
16
+ namespace ink::runtime
17
+ {
18
+ #ifdef INK_ENABLE_STL
19
+ story* story::from_file(const char* filename) { return new internal::story_impl(filename); }
20
+ #endif
21
+
22
+ story* story::from_binary(unsigned char* data, size_t length, bool freeOnDestroy)
23
+ {
24
+ return new internal::story_impl(data, length, freeOnDestroy);
25
+ }
26
+ } // namespace ink::runtime
27
+
28
+ namespace ink::runtime::internal
29
+ {
30
+
31
+ #ifdef INK_ENABLE_STL
32
+ unsigned char* read_file_into_memory(const char* filename, size_t* read)
33
+ {
34
+ using namespace std;
35
+
36
+ ifstream ifs(filename, ios::binary | ios::ate);
37
+
38
+ if (! ifs.is_open()) {
39
+ throw ink_exception("Failed to open file: " + std::string(filename));
40
+ }
41
+
42
+ ifstream::pos_type pos = ifs.tellg();
43
+ size_t length = ( size_t ) pos;
44
+ unsigned char* data = new unsigned char[length];
45
+ ifs.seekg(0, ios::beg);
46
+ ifs.read(( char* ) data, length);
47
+ ifs.close();
48
+
49
+ *read = ( size_t ) length;
50
+ return data;
51
+ }
52
+
53
+ story_impl::story_impl(const char* filename)
54
+ : _file(nullptr)
55
+ , _length(0)
56
+ , _string_table(nullptr)
57
+ , _instruction_data(nullptr)
58
+ , _managed(true)
59
+ {
60
+ // Load file into memory
61
+ _file = read_file_into_memory(filename, &_length);
62
+
63
+ // Find all the right data sections
64
+ setup_pointers();
65
+
66
+ // create story block
67
+ _block = new internal::ref_block();
68
+ _block->references = 1;
69
+ }
70
+ #endif
71
+
72
+ story_impl::story_impl(unsigned char* binary, size_t len, bool manage /*= true*/)
73
+ : _file(binary)
74
+ , _length(len)
75
+ , _managed(manage)
76
+ {
77
+ // Setup data section pointers
78
+ setup_pointers();
79
+
80
+ // create story block
81
+ _block = new internal::ref_block();
82
+ _block->references = 1;
83
+ }
84
+
85
+ story_impl::~story_impl()
86
+ {
87
+ // delete file memory if we're responsible for it
88
+ if (_file != nullptr && _managed)
89
+ delete[] _file;
90
+
91
+ // clear pointers
92
+ _file = nullptr;
93
+ _instruction_data = nullptr;
94
+ _string_table = nullptr;
95
+
96
+ // clear out our reference block
97
+ _block->valid = false;
98
+ internal::ref_block::remove_reference(_block);
99
+ _block = nullptr;
100
+ }
101
+
102
+ const char* story_impl::string(uint32_t index) const { return _string_table + index; }
103
+
104
+ bool story_impl::iterate_containers(
105
+ const uint32_t*& iterator, container_t& index, ip_t& offset, bool reverse
106
+ ) const
107
+ {
108
+ if (iterator == nullptr) {
109
+ // Empty check
110
+ if (_container_list_size == 0) {
111
+ return false;
112
+ }
113
+
114
+ // Start
115
+ iterator = reverse ? _container_list + (_container_list_size - 1) * 2 : _container_list;
116
+ } else {
117
+ // Range check
118
+ inkAssert(
119
+ iterator >= _container_list && iterator <= _container_list + _container_list_size * 2,
120
+ "Container fail"
121
+ );
122
+
123
+ // Advance
124
+ iterator += reverse ? -2 : 2;
125
+
126
+ // End?
127
+ if (iterator >= _container_list + _container_list_size * 2 || iterator < _container_list) {
128
+ iterator = nullptr;
129
+ index = 0;
130
+ offset = nullptr;
131
+ return false;
132
+ }
133
+ }
134
+
135
+ // Get metadata
136
+ index = *(iterator + 1);
137
+ offset = *iterator + instructions();
138
+ return true;
139
+ }
140
+
141
+ bool story_impl::get_container_id(ip_t offset, container_t& container_id) const
142
+ {
143
+ const uint32_t* iter = nullptr;
144
+ ip_t iter_offset = nullptr;
145
+ while (iterate_containers(iter, container_id, iter_offset)) {
146
+ if (iter_offset == offset)
147
+ return true;
148
+ }
149
+
150
+ return false;
151
+ }
152
+
153
+ CommandFlag story_impl::container_flag(ip_t offset) const
154
+ {
155
+ inkAssert(
156
+ (static_cast<Command>(offset[0]) == Command::START_CONTAINER_MARKER
157
+ || static_cast<Command>(offset[0]) == Command::END_CONTAINER_MARKER),
158
+ "Tried to fetch container flag from non container command!"
159
+ );
160
+ return static_cast<CommandFlag>(offset[1]);
161
+ }
162
+
163
+ CommandFlag story_impl::container_flag(container_t id) const
164
+ {
165
+ const uint32_t* iter = nullptr;
166
+ ip_t offset;
167
+ container_t c_id;
168
+ while (iterate_containers(iter, c_id, offset)) {
169
+ if (c_id == id) {
170
+ inkAssert(
171
+ static_cast<Command>(offset[0]) == Command::START_CONTAINER_MARKER,
172
+ "Container list pointer is invalid!"
173
+ );
174
+ return static_cast<CommandFlag>(offset[1]);
175
+ }
176
+ }
177
+ inkFail("Container not found -> can't fetch flag");
178
+ return CommandFlag::NO_FLAGS;
179
+ }
180
+
181
+ ip_t story_impl::find_offset_for(hash_t path) const
182
+ {
183
+ hash_t* iter = _container_hash_start;
184
+
185
+ while (iter != _container_hash_end) {
186
+ if (*iter == path) {
187
+ return instructions() + *( offset_t* ) (iter + 1);
188
+ }
189
+
190
+ iter += 2;
191
+ }
192
+
193
+ return nullptr;
194
+ }
195
+
196
+ globals story_impl::new_globals()
197
+ {
198
+ // create the new globals store
199
+ return globals(new globals_impl(this), _block);
200
+ }
201
+
202
+ globals story_impl::new_globals_from_snapshot(const snapshot& data)
203
+ {
204
+ const snapshot_impl& snapshot = reinterpret_cast<const snapshot_impl&>(data);
205
+ auto* globs = new globals_impl(this);
206
+ auto end = globs->snap_load(
207
+ snapshot.get_globals_snap(),
208
+ snapshot_interface::loader{
209
+ snapshot.strings(),
210
+ _string_table,
211
+ }
212
+ );
213
+ inkAssert(end == snapshot.get_runner_snap(0), "not all data were used for global reconstruction");
214
+ return globals(globs, _block);
215
+ }
216
+
217
+ runner story_impl::new_runner(globals store)
218
+ {
219
+ if (store == nullptr)
220
+ store = new_globals();
221
+ return runner(new runner_impl(this, store), _block);
222
+ }
223
+
224
+ runner story_impl::new_runner_from_snapshot(const snapshot& data, globals store, unsigned idx)
225
+ {
226
+ const snapshot_impl& snapshot = reinterpret_cast<const snapshot_impl&>(data);
227
+ if (store == nullptr)
228
+ store = new_globals_from_snapshot(snapshot);
229
+ auto* run = new runner_impl(this, store);
230
+ auto loader = snapshot_interface::loader{
231
+ snapshot.strings(),
232
+ _string_table,
233
+ };
234
+ // snapshot id is inverso of creation time, but creation time is the more intouitve numbering to
235
+ // use
236
+ idx = (data.num_runners() - idx - 1);
237
+ auto end = run->snap_load(snapshot.get_runner_snap(idx), loader);
238
+ inkAssert(
239
+ (idx + 1 < snapshot.num_runners() && end == snapshot.get_runner_snap(idx + 1))
240
+ || end == snapshot.get_data() + snapshot.get_data_len(),
241
+ "not all data were used for runner reconstruction"
242
+ );
243
+ return runner(run, _block);
244
+ }
245
+
246
+ void story_impl::setup_pointers()
247
+ {
248
+ using header = ink::internal::header;
249
+ _header = header::parse_header(reinterpret_cast<char*>(_file));
250
+
251
+ // String table is after the header
252
+ _string_table = ( char* ) _file + header::Size;
253
+
254
+ // Pass over strings
255
+ const char* ptr = _string_table;
256
+ if (*ptr == 0) // SPECIAL: No strings
257
+ {
258
+ ptr++;
259
+ } else
260
+ while (true) {
261
+ // Read until null terminator
262
+ while (*ptr != 0)
263
+ ptr++;
264
+
265
+ // Check next character
266
+ ptr++;
267
+
268
+ // Second null. Strings are done.
269
+ if (*ptr == 0) {
270
+ ptr++;
271
+ break;
272
+ }
273
+ }
274
+
275
+ // check if lists are defined
276
+ _list_meta = ptr;
277
+ if (list_flag flag = _header.read_list_flag(ptr); flag != null_flag) {
278
+ // skip list definitions
279
+ auto list_id = flag.list_id;
280
+ while (*ptr != 0) {
281
+ ++ptr;
282
+ }
283
+ ++ptr; // skip list name
284
+ do {
285
+ if (flag.list_id != list_id) {
286
+ list_id = flag.list_id;
287
+ while (*ptr != 0) {
288
+ ++ptr;
289
+ }
290
+ ++ptr; // skip list name
291
+ }
292
+ while (*ptr != 0) {
293
+ ++ptr;
294
+ }
295
+ ++ptr; // skip flag name
296
+ } while ((flag = _header.read_list_flag(ptr)) != null_flag);
297
+
298
+ _lists = reinterpret_cast<const list_flag*>(ptr);
299
+ // skip predefined lists
300
+ while (_header.read_list_flag(ptr) != null_flag) {
301
+ while (_header.read_list_flag(ptr) != null_flag)
302
+ ;
303
+ }
304
+ } else {
305
+ _list_meta = nullptr;
306
+ _lists = nullptr;
307
+ }
308
+ inkAssert(
309
+ _header.ink_bin_version_number == ink::InkBinVersion,
310
+ "invalid InkBinVerison! currently: %i you used %i", ink::InkBinVersion,
311
+ _header.ink_bin_version_number
312
+ );
313
+ inkAssert(
314
+ _header.endien == header::endian_types::same, "different endien support not yet implemented"
315
+ );
316
+
317
+
318
+ _num_containers = *( uint32_t* ) (ptr);
319
+ ptr += sizeof(uint32_t);
320
+
321
+ // Pass over the container data
322
+ _container_list_size = 0;
323
+ _container_list = ( uint32_t* ) (ptr);
324
+ while (true) {
325
+ uint32_t val = *( uint32_t* ) ptr;
326
+ if (val == ~0) {
327
+ ptr += sizeof(uint32_t);
328
+ break;
329
+ } else {
330
+ ptr += sizeof(uint32_t) * 2;
331
+ _container_list_size++;
332
+ }
333
+ }
334
+
335
+ // Next is the container hash map
336
+ _container_hash_start = ( hash_t* ) (ptr);
337
+ while (true) {
338
+ uint32_t val = *( uint32_t* ) ptr;
339
+ if (val == ~0) {
340
+ _container_hash_end = ( hash_t* ) (ptr);
341
+ ptr += sizeof(uint32_t);
342
+ break;
343
+ }
344
+
345
+ ptr += sizeof(uint32_t) * 2;
346
+ }
347
+
348
+ // After strings comes instruction data
349
+ _instruction_data = ( ip_t ) ptr;
350
+
351
+ // Debugging info
352
+ /*{
353
+ const uint32_t* iter = nullptr;
354
+ container_t index; ip_t offset;
355
+ while (this->iterate_containers(iter, index, offset))
356
+ {
357
+ std::clog << "Container #" << index << ": " << (int)offset << std::endl;
358
+ }
359
+ }*/
360
+ }
361
+ } // namespace ink::runtime::internal
@@ -0,0 +1,92 @@
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 <config.h>
11
+ #include "command.h"
12
+ #include "types.h"
13
+ #include "story.h"
14
+ #include "header.h"
15
+ #include "list_table.h"
16
+
17
+ namespace ink::runtime::internal
18
+ {
19
+ // Ink story. Constant once constructed. Can be shared safely between multiple runner instances
20
+ class story_impl : public story
21
+ {
22
+ public:
23
+
24
+ #ifdef INK_ENABLE_STL
25
+ story_impl(const char* filename);
26
+ #endif
27
+ // Create story from allocated binary data in memory. If manage is true, this class will delete
28
+ // the pointers on destruction
29
+ story_impl(unsigned char* binary, size_t len, bool manage = true);
30
+ virtual ~story_impl();
31
+
32
+ const char* string(uint32_t index) const;
33
+ inline const ip_t instructions() const { return _instruction_data; }
34
+ inline const ip_t end() const { return _file + _length; }
35
+
36
+ inline uint32_t num_containers() const { return _num_containers; }
37
+
38
+ const list_flag* lists() const { return _lists; }
39
+ const char* list_meta() const {
40
+ return _list_meta;
41
+ }
42
+
43
+ bool iterate_containers(const uint32_t*& iterator, container_t& index, ip_t& offset, bool reverse = false) const;
44
+ bool get_container_id(ip_t offset, container_t& container_id) const;
45
+ /// Get container flag from container offset (either start or end)
46
+ CommandFlag container_flag(ip_t offset) const;
47
+ CommandFlag container_flag(container_t id) const;
48
+
49
+ ip_t find_offset_for(hash_t path) const;
50
+
51
+ // Creates a new global store for use with runners executing this story
52
+ virtual globals new_globals() override;
53
+ virtual globals new_globals_from_snapshot(const snapshot&) override;
54
+ virtual runner new_runner(globals store = nullptr) override;
55
+ virtual runner new_runner_from_snapshot(const snapshot&, globals store = nullptr, unsigned idx = 0) override;
56
+
57
+ const ink::internal::header& get_header() const { return _header; }
58
+ private:
59
+ void setup_pointers();
60
+
61
+ private:
62
+ // file information
63
+ unsigned char* _file;
64
+ size_t _length;
65
+
66
+ ink::internal::header _header;
67
+
68
+ // string table
69
+ const char* _string_table;
70
+
71
+ const char* _list_meta;
72
+ const list_flag* _lists;
73
+
74
+ // container info
75
+ uint32_t* _container_list;
76
+ uint32_t _container_list_size;
77
+ uint32_t _num_containers;
78
+
79
+ // container hashes
80
+ hash_t* _container_hash_start;
81
+ hash_t* _container_hash_end;
82
+
83
+ // instruction info
84
+ ip_t _instruction_data;
85
+
86
+ // story block used to creat various weak pointers
87
+ ref_block* _block;
88
+
89
+ // whether we need to delete our binary data after we destruct
90
+ bool _managed;
91
+ };
92
+ }