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,49 @@
1
+ # Create executable
2
+ add_executable(inkcpp_cl inkcpp_cl.cpp test.h test.cpp)
3
+
4
+ # Include compiler and runtime libraries
5
+ target_link_libraries(inkcpp_cl PUBLIC inkcpp inkcpp_compiler inkcpp_shared)
6
+
7
+ # For https://en.cppreference.com/w/cpp/filesystem#Notes
8
+ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
9
+ if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "9.1")
10
+ target_link_libraries(inkcpp_cl PRIVATE stdc++fs)
11
+ endif()
12
+ elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
13
+ if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "9.0")
14
+ target_link_libraries(inkcpp_cl PRIVATE stdc++fs)
15
+ endif()
16
+ endif()
17
+
18
+ # Install
19
+ install(TARGETS inkcpp_cl DESTINATION . COMPONENT cl EXCLUDE_FROM_ALL)
20
+ string(TOUPPER "${INKCPP_INKLECATE}" inkcpp_inklecate_upper)
21
+ unset(inklecate_dir)
22
+ if((inkcpp_inklecate_upper STREQUAL "ALL") OR (inkcpp_inklecate_upper STREQUAL "OS"))
23
+ if(UNIX AND NOT APPLE)
24
+ FetchContent_GetProperties(inklecate_linux)
25
+ if(inklecate_linux_POPULATED)
26
+ set(inklecate_dir "${inklecate_linux_SOURCE_DIR}")
27
+ else()
28
+ message(WARNING "Inklecate for this OS was not downloaded successfully, and will therfore not be packat with cl")
29
+ endif(inklecate_linux_POPULATED)
30
+ elseif(APPLE)
31
+ if(inklecate_mac_POPULATED)
32
+ set(inklecate_dir "${inklecate_mac_SOURCE_DIR}")
33
+ else()
34
+ message(WARNING "Inklecate for this OS was not downloaded successfully, and will therfore not be packat with cl")
35
+ endif(inklecate_mac_POPULATED)
36
+ elseif(MSYS OR MINGW OR WIN32 OR CYGWIN)
37
+ if(inklecate_windows_POPULATED)
38
+ set(inklecate_dir "${inklecate_windows_SOURCE_DIR}")
39
+ else()
40
+ message(WARNING "Inklecate for this OS was not downloaded successfully, and will therfore not be packat with cl")
41
+ endif(inklecate_windows_POPULATED)
42
+ else()
43
+ message(WARNING "Failed to determine OS for bundling inklecate with command line application!")
44
+ endif()
45
+ if(inklecate_dir)
46
+ file(GLOB inklecate_files "${inklecate_dir}/*")
47
+ install(FILES ${inklecate_files} DESTINATION . COMPONENT cl EXCLUDE_FROM_ALL)
48
+ endif(inklecate_dir)
49
+ endif((inkcpp_inklecate_upper STREQUAL "ALL") OR (inkcpp_inklecate_upper STREQUAL "OS"))
@@ -0,0 +1,215 @@
1
+ // inkcpp_cl.cpp : This file contains the 'main' function. Program execution begins and ends there.
2
+ //
3
+
4
+ #include <iostream>
5
+ #include <fstream>
6
+ #include <regex>
7
+
8
+ #include <story.h>
9
+ #include <runner.h>
10
+ #include <compiler.h>
11
+ #include <choice.h>
12
+ #include <globals.h>
13
+ #include <snapshot.h>
14
+
15
+ #include "test.h"
16
+
17
+ void usage()
18
+ {
19
+ using namespace std;
20
+ cout << "Usage: inkcpp_cl <options> <json file>\n"
21
+ << "\t-o <filename>:\tOutput file name\n"
22
+ << "\t-p [<snapshot_file>]:\tPlay mode\n\toptional snapshot file to load\n\tto create a "
23
+ "snapshot file enter '-1' as choice\n"
24
+ << "\t--ommit-choice-tags:\tdo not print tags after choices, primarly used to be compatible "
25
+ "with inkclecat output"
26
+ << "\t--inklecate <path-to-inklecate>:\toverwrites INKLECATE enviroment variable\n"
27
+ << endl;
28
+ }
29
+
30
+ int main(int argc, const char** argv)
31
+ {
32
+ // Usage
33
+ if (argc == 1) {
34
+ usage();
35
+ return 1;
36
+ }
37
+
38
+ // Parse options
39
+ std::string outputFilename;
40
+ bool playMode = false, testMode = false, testDirectory = false, ommit_choice_tags = false;
41
+ std::string snapshotFile;
42
+ const char* inklecateOverwrite = nullptr;
43
+ for (int i = 1; i < argc - 1; i++) {
44
+ std::string option = argv[i];
45
+ if (option == "-o") {
46
+ outputFilename = argv[i + 1];
47
+ i += 1;
48
+ } else if (option == "-p") {
49
+ playMode = true;
50
+ if (i + 1 < argc - 1 && argv[i + 1][0] != '-') {
51
+ ++i;
52
+ snapshotFile = argv[i];
53
+ }
54
+ } else if (option == "--ommit-choice-tags") {
55
+ ommit_choice_tags = true;
56
+ } else if (option == "-t") {
57
+ testMode = true;
58
+ } else if (option == "-td") {
59
+ testMode = true;
60
+ testDirectory = true;
61
+ } else if (option == "--inklecate") {
62
+ if (i + 1 < argc - 1 && argv[i + 1][0] != '-') {
63
+ ++i;
64
+ inklecateOverwrite = argv[i];
65
+ }
66
+ } else {
67
+ std::cerr << "Unrecognized option: '" << option << "'\n";
68
+ }
69
+ }
70
+
71
+ // Get input filename
72
+ std::string inputFilename = argv[argc - 1];
73
+
74
+ // Test mode
75
+ // if (testMode) {
76
+ // bool result;
77
+ // if (testDirectory) {
78
+ // result = test_directory(inputFilename);
79
+ // } else {
80
+ // result = test(inputFilename);
81
+ // }
82
+
83
+ // return result ? 0 : -1;
84
+ // }
85
+
86
+ // If output filename not specified, use input filename as guideline
87
+ if (outputFilename.empty()) {
88
+ outputFilename = std::regex_replace(inputFilename, std::regex("\\.[^\\.]+$"), ".bin");
89
+ }
90
+
91
+ // If input filename is an .ink file
92
+ int val = inputFilename.find(".ink");
93
+ bool json_file_is_tmp_file = false;
94
+ if (val == inputFilename.length() - 4) {
95
+ // Create temporary filename
96
+ std::string jsonFile = std::regex_replace(inputFilename, std::regex("\\.[^\\.]+$"), ".tmp");
97
+
98
+ // Then we need to do a compilation with inklecate
99
+ try {
100
+ inklecate(inputFilename, jsonFile, inklecateOverwrite);
101
+ } catch (const std::exception& e) {
102
+ std::cerr << "Inklecate Error: " << e.what() << std::endl;
103
+ return 1;
104
+ }
105
+
106
+ // New input is the json file
107
+ json_file_is_tmp_file = true;
108
+ inputFilename = jsonFile;
109
+ }
110
+
111
+ // Open file and compile
112
+ try {
113
+ ink::compiler::compilation_results results;
114
+ std::ofstream fout(outputFilename, std::ios::binary | std::ios::out);
115
+ ink::compiler::run(inputFilename.c_str(), fout, &results);
116
+ fout.close();
117
+ if (json_file_is_tmp_file) {
118
+ remove(inputFilename.c_str());
119
+ }
120
+
121
+ // Report errors
122
+ for (auto& warn : results.warnings) {
123
+ std::cerr << "WARNING: " << warn << '\n';
124
+ }
125
+ for (auto& err : results.errors) {
126
+ std::cerr << "ERROR: " << err << '\n';
127
+ }
128
+
129
+ if (results.errors.size() > 0 && playMode) {
130
+ std::cerr << "Cancelling play mode. Errors detected in compilation" << std::endl;
131
+ return -1;
132
+ }
133
+ } catch (std::exception& e) {
134
+ if (json_file_is_tmp_file) {
135
+ remove(inputFilename.c_str());
136
+ }
137
+ std::cerr << "Unhandled InkBin compiler exception: " << e.what() << std::endl;
138
+ return 1;
139
+ }
140
+
141
+ if (! playMode) {
142
+ return 0;
143
+ }
144
+
145
+ // Run the story
146
+ try {
147
+ using namespace ink::runtime;
148
+
149
+ // Load story
150
+ std::unique_ptr<story> myInk{story::from_file(outputFilename.c_str())};
151
+
152
+ // Start runner
153
+ runner thread;
154
+ if (snapshotFile.size()) {
155
+ auto snap_ptr = snapshot::from_file(snapshotFile.c_str());
156
+ thread = myInk->new_runner_from_snapshot(*snap_ptr);
157
+ delete snap_ptr;
158
+ } else {
159
+ thread = myInk->new_runner();
160
+ }
161
+
162
+ while (true) {
163
+ while (thread->can_continue()) {
164
+ std::cout << thread->getline();
165
+ if (thread->has_tags()) {
166
+ std::cout << "# tags: ";
167
+ for (int i = 0; i < thread->num_tags(); ++i) {
168
+ if (i != 0) {
169
+ std::cout << ", ";
170
+ }
171
+ std::cout << thread->get_tag(i);
172
+ }
173
+ std::cout << std::endl;
174
+ }
175
+ }
176
+ if (thread->has_choices()) {
177
+ // Extra end line
178
+ std::cout << std::endl;
179
+
180
+ int index = 1;
181
+ for (const ink::runtime::choice& c : *thread) {
182
+ std::cout << index++ << ": " << c.text();
183
+ if (! ommit_choice_tags && c.has_tags()) {
184
+ std::cout << "\n\t";
185
+ for (size_t i = 0; i < c.num_tags(); ++i) {
186
+ std::cout << "# " << c.get_tag(i) << " ";
187
+ }
188
+ }
189
+ std::cout << std::endl;
190
+ }
191
+
192
+ int c = 0;
193
+ std::cout << "?> ";
194
+ std::cin >> c;
195
+ if (c == -1) {
196
+ snapshot* snap = thread->create_snapshot();
197
+ snap->write_to_file(
198
+ std::regex_replace(inputFilename, std::regex("\\.[^\\.]+$"), ".snap").c_str()
199
+ );
200
+ delete snap;
201
+ break;
202
+ }
203
+ thread->choose(c - 1);
204
+ continue;
205
+ }
206
+
207
+ // out of content
208
+ break;
209
+ }
210
+ } catch (const std::exception& e) {
211
+ std::cerr << "Unhandled ink runtime exception: " << e.what() << std::endl;
212
+ return 1;
213
+ }
214
+ return 0;
215
+ }
@@ -0,0 +1,209 @@
1
+ #include "test.h"
2
+
3
+ #include <fstream>
4
+ #include <sstream>
5
+ #include <regex>
6
+ #include <filesystem>
7
+ #include <cstdlib>
8
+
9
+ #include <globals.h>
10
+ #include <runner.h>
11
+ #include <story.h>
12
+ #include <compiler.h>
13
+ #include <choice.h>
14
+
15
+ void inklecate(
16
+ const std::string& inkFilename, const std::string& jsonFilename, const char* inklecateOverwrite
17
+ )
18
+ {
19
+ // Get environment specific inklecate invocation command
20
+
21
+ const char* inklecateCmd = nullptr;
22
+ if (inklecateCmd == nullptr) {
23
+ if (inklecateOverwrite) {
24
+ inklecateCmd = inklecateOverwrite;
25
+ }
26
+ }
27
+ if (inklecateCmd == nullptr) {
28
+ std::getenv("INKLECATE");
29
+ }
30
+ if (inklecateCmd == nullptr)
31
+ inklecateCmd = "inklecate";
32
+
33
+ // Create command
34
+ std::stringstream cmd;
35
+ cmd << inklecateCmd << " -o \"" << jsonFilename << "\" \"" << inkFilename << "\"";
36
+
37
+ // Run
38
+ int result = std::system(cmd.str().c_str());
39
+ if (result != 0) {
40
+ std::stringstream msg; msg << "Inklecate failed with exit code " << result;
41
+ throw std::runtime_error(msg.str());
42
+ }
43
+ }
44
+
45
+ void load_file(const std::string& filename, std::string& result)
46
+ {
47
+ // Open file
48
+ std::ifstream file(filename.c_str());
49
+
50
+ // Get size
51
+ file.seekg(0, std::ios::end);
52
+ result.reserve(file.tellg());
53
+ file.seekg(0, std::ios::beg);
54
+
55
+ // Load into string
56
+ result.assign(std::istreambuf_iterator<char>(file), std::istreambuf_iterator<char>());
57
+
58
+ // Close
59
+ file.close();
60
+ }
61
+
62
+ bool test(const std::string& inkFilename)
63
+ {
64
+ using namespace ink::runtime;
65
+
66
+ std::cout << std::filesystem::path(inkFilename).filename().string() << std::endl;
67
+
68
+ // Compile into a temporary json file
69
+ inklecate(inkFilename, "test.tmp", nullptr);
70
+
71
+ // Compile into binary
72
+ ink::compiler::compilation_results results;
73
+ ink::compiler::run("test.tmp", "test.bin", &results);
74
+
75
+ std::vector<std::string> expectations;
76
+ std::vector<int> choices;
77
+ std::vector<std::string> choiceStrings;
78
+
79
+ {
80
+ // Load entire ink file into memory
81
+ std::string inkFile;
82
+ load_file(inkFilename, inkFile);
83
+
84
+ // Check for ignore
85
+ if (inkFile.find("//IGNORE") == 0)
86
+ {
87
+ std::cout << "IGNORED" << std::endl;
88
+ return true;
89
+ }
90
+
91
+ // Check for compile errors post ignore
92
+ if (results.errors.size() > 0)
93
+ {
94
+ for (auto& error : results.errors)
95
+ {
96
+ std::cerr << "ERROR: " << error << std::endl;
97
+ }
98
+ return false;
99
+ }
100
+
101
+ // Load expectations
102
+ auto reg = std::regex("\\/\\*\\*[ \t]*(\\d+(:.+)?)?[ \t]*\n((.|\n)*?)\\*\\*\\/");
103
+ auto iter = std::sregex_iterator(inkFile.begin(), inkFile.end(), reg);
104
+ auto end = std::sregex_iterator();
105
+
106
+ // Go through them
107
+ for (; iter != end; ++iter)
108
+ {
109
+ if ((*iter)[1].matched)
110
+ {
111
+ expectations.push_back((*iter)[3].str());
112
+ choices.push_back(atoi((*iter)[1].str().c_str()));
113
+
114
+ if ((*iter)[2].matched)
115
+ choiceStrings.push_back((*iter)[2].str().substr(1));
116
+ else
117
+ choiceStrings.push_back("");
118
+ }
119
+ else
120
+ {
121
+ expectations.push_back((*iter)[3].str());
122
+ }
123
+ }
124
+
125
+ std::reverse(expectations.begin(), expectations.end());
126
+ std::reverse(choices.begin(), choices.end());
127
+ }
128
+
129
+ // Load story
130
+ auto file = story::from_file("test.bin");
131
+ auto runner = file->new_runner();
132
+
133
+ while (true)
134
+ {
135
+ // Run continuously
136
+ std::string output = runner->getall();
137
+
138
+ // Check against expectatins
139
+ if (expectations.size() == 0)
140
+ {
141
+ std::cout << "FAIL: Extra content detected in ink file:\n"
142
+ << output;
143
+ return false;
144
+ }
145
+
146
+ // Check against expectations
147
+ std::string expect = *expectations.rbegin();
148
+ expectations.pop_back();
149
+ bool success = output == expect;
150
+ if (!success)
151
+ {
152
+ std::cout << "FAIL: Mismatch\n";
153
+ std::cout << "== Expected ==\n"
154
+ << expect;
155
+ std::cout << "\n== Actual ==\n"
156
+ << output;
157
+ return false;
158
+ }
159
+
160
+ if (runner->has_choices())
161
+ {
162
+ if (choices.size() == 0)
163
+ {
164
+ std::cout << "FAIL: Encountered choice without choice index" << std::endl;
165
+ return false;
166
+ }
167
+
168
+ // Pick choice
169
+ int choice = *choices.rbegin();
170
+ choices.pop_back();
171
+
172
+ // Make sure text matches
173
+ std::string choiceStr = *choiceStrings.rbegin();
174
+ choiceStrings.pop_back();
175
+ if (choiceStr != "" && runner->get_choice(choice)->text() != choiceStr)
176
+ {
177
+ std::cout << "FAIL: CHOICE MISMATCH\n";
178
+
179
+ std::cout << "== Expected ==\n"
180
+ << choiceStr << "\n"
181
+ << "== Actual ==\n"
182
+ << runner->get_choice(choice)->text() << std::endl;
183
+ return false;
184
+ }
185
+
186
+ runner->choose(choice);
187
+ }
188
+ else
189
+ break;
190
+ }
191
+
192
+ std::cout << "SUCCESS!" << std::endl;
193
+ return true;
194
+ }
195
+
196
+ bool test_directory(const std::string& directory)
197
+ {
198
+ for (auto p : std::filesystem::directory_iterator(directory))
199
+ {
200
+ if (p.path().extension() == ".ink")
201
+ {
202
+ bool success = test(p.path().string());
203
+ if (!success)
204
+ return false;
205
+ }
206
+ }
207
+
208
+ return true;
209
+ }
@@ -0,0 +1,8 @@
1
+ #include <string>
2
+
3
+ void inklecate(
4
+ const std::string& inkFilename, const std::string& jsonFilename, const char* inkclecateOverwrite
5
+ );
6
+ // TODO: reevaluate in ink file test mechanism
7
+ // bool test(const std::string& inkFilename);
8
+ // bool test_directory(const std::string& directory);
@@ -0,0 +1,37 @@
1
+ list(APPEND SOURCES
2
+ compiler.cpp binary_stream.h binary_stream.cpp json.hpp
3
+ json_compiler.h json_compiler.cpp
4
+ emitter.h emitter.cpp
5
+ reporter.h reporter.cpp
6
+ binary_emitter.h binary_emitter.cpp
7
+ list_data.h list_data.cpp
8
+ command.cpp
9
+ )
10
+ add_definitions(-DINK_EXPOSE_JSON)
11
+ add_library(inkcpp_compiler_o OBJECT ${SOURCES})
12
+ add_library(inkcpp_compiler $<TARGET_OBJECTS:inkcpp_compiler_o>)
13
+
14
+ target_include_directories(inkcpp_compiler_o PUBLIC
15
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
16
+ $<INSTALL_INTERFACE:include>
17
+ )
18
+ target_include_directories(inkcpp_compiler PUBLIC
19
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
20
+ $<INSTALL_INTERFACE:include>
21
+ )
22
+ FILE(GLOB PUBLIC_HEADERS "include/*")
23
+ set_target_properties(inkcpp_compiler PROPERTIES PUBLIC_HEADER "${PUBLIC_HEADERS}")
24
+
25
+ target_link_libraries(inkcpp_compiler PRIVATE inkcpp_shared)
26
+ target_link_libraries(inkcpp_compiler_o PRIVATE inkcpp_shared)
27
+
28
+ # Make sure this project and all dependencies use the C++17 standard
29
+ target_compile_features(inkcpp_compiler PUBLIC cxx_std_17)
30
+ target_compile_features(inkcpp_compiler PUBLIC cxx_std_17)
31
+
32
+ # Unreal installation
33
+ list(REMOVE_ITEM SOURCES "json.hpp")
34
+ install(FILES "json.hpp" DESTINATION "inkcpp/Source/ThirdParty/Private/"
35
+ COMPONENT unreal EXCLUDE_FROM_ALL)
36
+ install(DIRECTORY "include/" DESTINATION "inkcpp/Source/inkcpp_editor/Private/ink/" COMPONENT unreal EXCLUDE_FROM_ALL)
37
+ install(FILES ${SOURCES} DESTINATION "inkcpp/Source/inkcpp_editor/Private/ink/" COMPONENT unreal EXCLUDE_FROM_ALL)