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,160 @@
1
+ {
2
+ "inkVersion": 21,
3
+ "root": [
4
+ [
5
+ {
6
+ "->": "start"
7
+ },
8
+ [
9
+ "done",
10
+ {
11
+ "#f": 5,
12
+ "#n": "g-0"
13
+ }
14
+ ],
15
+ null
16
+ ],
17
+ "done",
18
+ {
19
+ "start": [
20
+ [
21
+ "^Once upon a time...",
22
+ "\n",
23
+ [
24
+ "ev",
25
+ {
26
+ "^->": "start.0.2.$r1"
27
+ },
28
+ {
29
+ "temp=": "$r"
30
+ },
31
+ "str",
32
+ {
33
+ "->": ".^.s"
34
+ },
35
+ [
36
+ {
37
+ "#n": "$r1"
38
+ }
39
+ ],
40
+ "/str",
41
+ "/ev",
42
+ {
43
+ "*": ".^.^.c-0",
44
+ "flg": 18
45
+ },
46
+ {
47
+ "s": [
48
+ "^There were two choices.",
49
+ {
50
+ "->": "$r",
51
+ "var": true
52
+ },
53
+ null
54
+ ]
55
+ }
56
+ ],
57
+ [
58
+ "ev",
59
+ {
60
+ "^->": "start.0.3.$r1"
61
+ },
62
+ {
63
+ "temp=": "$r"
64
+ },
65
+ "str",
66
+ {
67
+ "->": ".^.s"
68
+ },
69
+ [
70
+ {
71
+ "#n": "$r1"
72
+ }
73
+ ],
74
+ "/str",
75
+ "/ev",
76
+ {
77
+ "*": ".^.^.c-1",
78
+ "flg": 18
79
+ },
80
+ {
81
+ "s": [
82
+ "^There were four lines of content.",
83
+ {
84
+ "->": "$r",
85
+ "var": true
86
+ },
87
+ null
88
+ ]
89
+ }
90
+ ],
91
+ {
92
+ "c-0": [
93
+ "ev",
94
+ {
95
+ "^->": "start.0.c-0.$r2"
96
+ },
97
+ "/ev",
98
+ {
99
+ "temp=": "$r"
100
+ },
101
+ {
102
+ "->": ".^.^.2.s"
103
+ },
104
+ [
105
+ {
106
+ "#n": "$r2"
107
+ }
108
+ ],
109
+ "\n",
110
+ {
111
+ "->": ".^.^.g-0"
112
+ },
113
+ {
114
+ "#f": 5
115
+ }
116
+ ],
117
+ "c-1": [
118
+ "ev",
119
+ {
120
+ "^->": "start.0.c-1.$r2"
121
+ },
122
+ "/ev",
123
+ {
124
+ "temp=": "$r"
125
+ },
126
+ {
127
+ "->": ".^.^.3.s"
128
+ },
129
+ [
130
+ {
131
+ "#n": "$r2"
132
+ }
133
+ ],
134
+ "\n",
135
+ {
136
+ "->": ".^.^.g-0"
137
+ },
138
+ {
139
+ "#f": 5
140
+ }
141
+ ],
142
+ "g-0": [
143
+ "^They lived happily ever after.",
144
+ "\n",
145
+ "end",
146
+ {
147
+ "#f": 5
148
+ }
149
+ ]
150
+ }
151
+ ],
152
+ {
153
+ "#f": 1
154
+ }
155
+ ],
156
+ "#f": 1
157
+ }
158
+ ],
159
+ "listDefs": {}
160
+ }
@@ -0,0 +1,54 @@
1
+ # Container Metadata
2
+
3
+ Even though the inkcpp binary compiler flattens the hierarchical JSON structure into a flat sequence of commands with diverts, we still need to maintain some metadata about the container structure so we can properly record visit counts.
4
+
5
+ ## Container Instructions Layout
6
+
7
+ Only containers which have visit or turn tracking flags are recorded in any way. All other containers may as well no longer exist.
8
+
9
+ The first command at the start of any container is a {{START_CONTAINER_MARKER}}.
10
+
11
+ Inline child container are written in-place as the interpreter should enter them normally when it reaches them.
12
+
13
+ Named containers specified in a container's meta-data are compiled in order after we finish writing out all commands for the parent container.
14
+ * Before writing any of them, we write a {{DIVERT}} command which jumps to {{END_CONTAINER_MARKER}} for the parent below. This way we don't wander into these child containers when we run out of content in our own container.
15
+ * After writing each named child, we write a similar {{DIVERT}} as above. This way, when any of these containers finish, the interpreter does not wander into their siblings.
16
+ * Both these diverts are written with a special {{DIVERT_IS_FALLTHROUGH}} flag. Its important will be clear later.
17
+
18
+ After writing all these named children, the last command, a {{END_CONTAINER_MARKER}} is written.
19
+
20
+ ## Container Start/End Instruction
21
+
22
+ {{START_CONTAINER_MARKER}} and {{END_CONTAINER_MARKER}} both have a {{container_t}} argument to uniquely identify the container starting or ending. These numbers have no relation to the original container names. They are assigned sequentially starting from 0 to each container which requires tracking.
23
+
24
+ The {{START}} command pushes that container ID onto the current container stack. {{END}} pops them.
25
+
26
+ TODO: Notes on implied DONE and the done IP cache.
27
+
28
+ ## Container Map
29
+
30
+ A "container map" is included in the ink binary metadata before any instructions. It's an array in the following format:
31
+
32
+ 32-bit instruction offset (offset_t)
33
+ 32-bit container id (container_t)
34
+
35
+ The array is terminated with a 0xFFFFFFFF.
36
+
37
+ Each container has two entries in the array: one for its start and one for its end. There is no distinction between start and end in the array.
38
+
39
+ The "start" offset points to the instruction just after the {{START_CONTAINER_MARKER}} command. If you were to jump to it, you'd avoid hitting the {{START_CONTAINER_MARKER}} next step.
40
+
41
+ The "end" offset points to the instruction just after the {{END_CONTAINER_MARKER}} instruction. If you were to jump to it, you'd avoid hitting the {{END_CONTAINER_MARKER}} next step.
42
+
43
+ The container map is used for handling visit counts that result from an interpreter jump (caused by a {{DIVERT}} or selecting a choice). In normal execution, the {{START_CONTAINER_MARKER}} and {{END_CONTAINER_MARKER}} are pushing/popping container indicies and updating visit counts. If we jump, we're passing over all these commands. We need a way of both updating the visit counts (for each new container we enter) and updating our own container stack so the interpreter knows where it is in the container hierarchy.
44
+
45
+ ### Jump Algorithm
46
+
47
+ 1. Determine if we are jumping forward (dest > ip) or backward (ip < dest)
48
+ 2. Linear search the container map, starting from the beginning for a forward jump or the end for a backward jump
49
+ * Find the entry just "before" the current pointer.
50
+
51
+
52
+ ### Special: "Falling Through" Diverts
53
+
54
+ TODO: Can we simplify jump algorithm here? Are there certain guarantees?
@@ -0,0 +1,69 @@
1
+ [##](##) general construction:
2
+
3
+ + A list is a bit vector!
4
+ + Further we will call each bit vector which represents a list a _flag_.
5
+ + Each flag is tide to a number, which is equal to the position in the bit vector, which we will call _flag value_
6
+ + Each flag has a string representation, further be called _key_.
7
+ + Each multi list is associated to zero ore more list types
8
+ + when adding a new element the list type of that element get added to associated lists
9
+ + when removing the last element of an list type then the type get removed from associated lists
10
+ + __except:__ the list of associated types will be empty, than nothing happen
11
+ + -> only an empty initialized list has no d list
12
+ + each list key will be an element variable at global scope -> no two keys can have the same name
13
+ + a list_type is a variable defined with `LIST` therefore mentioned in the `declList` section of the InkJson
14
+
15
+ ## List operators
16
+
17
+ + `+(list lh,list rh)` lh = lh ∪ rh
18
+ + `+(list, fag)` add the element to the list
19
+ + `L^(list lh, flag rh)` (interesection) creates an empty list or a list with rh set if it's part of lh
20
+ + `L^(list lh, list rh)` (interesection) = lh ∩ rh
21
+ + `-(list lh, list rh)` remove elements lh = lh / (lh ∩ rh)
22
+ + `-(list lh, flag rh)` removes element from list
23
+ + `+(list l, int i)` l << i (bits get shifted out)
24
+ + `-(list l, int i)` l >> i (bits get shifted out)
25
+ + `LIST_COUNT(list l)` returns the number of flags sets
26
+ + `LIST_MIN(list l)` returns the flag with the lowest numerical representation which is set
27
+ + `LIST_MAX(list l)` return the flag with the highest numerical representation which is set
28
+ + `lrnd(list l)` return a random flag which is set
29
+ + for the user it is `LIST_RANDOM`, but in InkJson it is called `lrnd`
30
+ + `LIST_ALL(list l)` returns a list which all elements of associated list of l
31
+ + `LIST_INVERT(list l)` returns a list which each flag is toggeld of all associated lists
32
+ + `<(list lh, list rh)` return true if `LIST_MAX(lh) < LIST_MIN(rh)`
33
+ + `>(list lh, list rh)` returns true if `LIST_MIN(lh) > LIST_MAX(rh)`
34
+ + `==(list lh, list rh)` returns true if the setted flags of both are equal
35
+ + `!=(list lh, list rh)` return true if `lh == rh` returns false
36
+ + `>=(list lh, list rh)` returns true if `LIST_MAX(lh) >= LIST_MAX(rh) && LIST_MIN(lh) >= LIST_MIN(rh)`
37
+ + `<=(list lh, list rh)` returns true if `LIST_MAX(lh) <= LIST_MAX(rh) && LIST_MIN(lh) <= LIST_MIN(rh)`
38
+ + `?(list lh, entry rh)` returns true if rh is element of lh
39
+ + `?(list lh, list rh)` returns true if every flag of rh is set in lh
40
+ + `!?(list lh, entry rh)` returns `not ?(lh,rh)`
41
+ + `!?(list lh, list rh)` returns `not ? (lh,rh)`
42
+
43
+ ## Datatype
44
+
45
+ + Each list has a id(`listId`), this mapping is arbitrary. To allow usage as array index we start with 0 an increased it for each list_type
46
+ + A flag is identified by `flagId`, it's correspond to the flag value. (flagId - min flagId of that list = flag value)
47
+
48
+ ### list_element
49
+
50
+ `uint32_t` with bit[0-15] are the listId and bit[16-31] the flag value.
51
+
52
+ ### list
53
+
54
+ `uint32_t` position in list_table
55
+
56
+ ### list_table
57
+
58
+ Datatype to manage lists (similar to string_table)
59
+
60
+ It contains:
61
+
62
+ + a reference to the string_table
63
+ + A array `keys` which maps each flagId to an key, who lives in string_table
64
+ + A array `flag_start` which maps each listId to an offset, which leads to value 0 for that list in the entry bitmap.
65
+ + A array `fids` which maps each listId to the flagId for the value 0 of that list (used to get key from keys).
66
+ + A array of entries, each entry contains:
67
+ + a bitmap, where 1 represent that the list is associated to the corresponding list
68
+ + a bitmap, where 1 represent that the list contains the flag
69
+ + the two bitmaps are WORD align for better memory access
@@ -0,0 +1,35 @@
1
+ Operations are everything which works only on the evaluation stack!
2
+ (eg. ADD, NOT, EQUAL, etc.)
3
+
4
+ To use them include `executioner.h`, this will take care of including the other
5
+ needed header in the correct order.
6
+
7
+ The `executioner` need to instantiation time all resources needed for all
8
+ supported operations (a string_table for now).
9
+
10
+ Then you can execute a command with the call operator of the `executioner`.
11
+ `void operator()(Command, eval_stack&)`
12
+
13
+ The executioner then iterates through a compile time created and optimization
14
+ list of all types. To determine how many arguments needed
15
+ (with `size_t command_num_args(Command)`) and then finds the matching operator
16
+ for the value type.
17
+
18
+ Type casting is solved with a cast matrix, where each entry is defined with:
19
+ `template<> constexpr value_type cast<value_type,value_type> = value_type`
20
+ `template<> constexpr value_type cast<t1,t2> = resulting_type`
21
+
22
+ ! At the moment we must ensure that `(int)(t1) < (int)(t2)`!
23
+
24
+ The gain:
25
+
26
+ * Operation handling can be separated in different files
27
+ (`numeric_operations.h, string_operations.h`). The value class only knows what
28
+ data it contains, and not how to handle it => adding new types or operators
29
+ is know possible without changing many `switch cases`.
30
+ * Values are acquired with `get<value_type>()` witch allows changing type
31
+ without breaking unnoticed code.
32
+ * Not one huge file.
33
+ * The `executioner` knows the resources for the operations
34
+ => no need to pass a string_table to each add.
35
+ * everything is without virtualisation => no/negligible runtime overhead.
@@ -0,0 +1,24 @@
1
+ Tags are accessible via runner functions:
2
+
3
+ - `bool has_tags()` are there any tags now?
4
+ - `size_t num_tags()` how many tags are there right now?
5
+ - `const char* get_tag(size_t i)` get string value of tag
6
+
7
+ Tags are acquired until a choice appears. After choosing the acquired tags will
8
+ be cleared.
9
+ ```
10
+ # Tag1
11
+ # Tag 2
12
+ Some Text # Tag3
13
+ * A # Tag 4
14
+ * B # Tag 5
15
+ - out # Tag6
16
+ ```
17
+
18
+ Will produce:
19
+ > Some Text: Tag1, Tag2, Tag3
20
+ > * A
21
+ > * B
22
+ > <1
23
+ > A
24
+ > out: Tag4, Tag6
@@ -0,0 +1,28 @@
1
+ In which I figure out what in the nine fucks ink is doing to whitespace so I can emulate it.
2
+
3
+ There seem to be _numerous_ places in which ink deals with whitespace so I will just document each here and try to figure out what they're doing and why.
4
+
5
+ # Push To Output Stream
6
+
7
+ Ink processes whitespace in strings as they are added to the output stream. See _PushToOutputStream_ and _PushToOutputStreamIndividual_ in StoryState.cs.
8
+
9
+ ## PushToOutputStream
10
+
11
+ Calls _TrySplittingHeadTailWhitespace_ on incoming strings in case they contain newlines. I'm not really sure *how* this could happen since newlines are split off by the Ink compiler already. How could a newline possibly be in an incoming string? I guess maybe if it's stored in a variable? Seems like quite the edge case.
12
+
13
+ DECISION: NOT IMPLEMENTING. Will review if the case comes up.
14
+
15
+ After running this split, the split strings are sent to _PushToOutputStreamIndividual_.
16
+
17
+ ## PushToOutputStreamIndividual
18
+
19
+ Lots going on here.
20
+
21
+ First, if the incoming element is glue, trim newlines from the output stream.
22
+
23
+ ALREADY IMPLEMENTED. See *basic_stream::append(const data&)*.
24
+
25
+ Otherwise, for text:
26
+
27
+ 1. We trim whitespace at the _beginning_ and _ending_ of function calls (not tunnels). This is made more complicated by glue.
28
+
@@ -0,0 +1,3 @@
1
+ In the future, there'll be machinery in here to run the ink-proof tests as a test phase during build. For now, it just houses the ink-proof submodule so we can generate the HTML page for it on master.
2
+
3
+ See windows_builds.yml in the .github folder
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env python3
2
+
3
+ import os
4
+ import sys
5
+ import shutil
6
+
7
+ ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
8
+ PATH = os.path.join(ROOT, 'deps', 'inkcpp', 'inkcpp_cl')
9
+ ARGS = ["inkcpp_cl", "--ommit-choice-tags", "-p"] + sys.argv[1:]
10
+ os.execv(PATH, ARGS)
11
+ sleep(2)
12
+
@@ -0,0 +1,63 @@
1
+ [project]
2
+ name = "inkcpp-py"
3
+ readme = "README.md"
4
+ license = { file = "LICENSE.txt" }
5
+ keywords = ["ink", "inkpp", "inklecate"]
6
+ dynamic = ["version", "description", "authors", "requires-python"]
7
+
8
+ [project.urls]
9
+ Repository = "https://github.com/JBenda/inkcpp.git"
10
+ Issues = "https://github.com/JBenda/inkcpp/issues"
11
+
12
+ [build-system]
13
+ requires = [
14
+ "setuptools>=42",
15
+ "wheel",
16
+ "ninja",
17
+ "cmake>=3.16",
18
+ ]
19
+ build-backend = "setuptools.build_meta"
20
+
21
+ [tool.mypy]
22
+ files = "setup.py"
23
+ python_version = "3.7"
24
+ strict = true
25
+ show_error_codes = true
26
+ enable_error_code = ["ignore-without-code", "redundant-expr", "truthy-bool"]
27
+ warn_unreachable = true
28
+
29
+ [[tool.mypy.overrides]]
30
+ module = ["ninja"]
31
+ ignore_missing_imports = true
32
+
33
+ [tool.pytest.ini_options]
34
+ # minversion = "6.0"
35
+ # addopts = ["-ra", "--showlocals", "--strict-markers", "--strict-config"]
36
+ # xfail_strict = true
37
+ # filterwarnings = [
38
+ # "error",
39
+ # "ignore:(ast.Str|Attribute s|ast.NameConstant|ast.Num) is deprecated:DeprecationWarning:_pytest",
40
+ # ]
41
+ testpaths = ["inkcpp_py/tests"]
42
+ addopts = [
43
+ "--import-mode=importlib",
44
+ ]
45
+
46
+ # [tool.cibuildwheel]
47
+ # test-command = "pytest {project}/tests"
48
+ # test-extras = ["test"]
49
+ # test-skip = ["*universal2:arm64"]
50
+ # Setuptools bug causes collision between pypy and cpython artifacts
51
+ # before-build = "rm -rf {project}/build"
52
+
53
+ [tool.ruff]
54
+ target-version = "py37"
55
+
56
+ [tool.ruff.lint]
57
+ extend-select = [
58
+ "B", # flake8-bugbear
59
+ "I", # isort
60
+ "PGH", # pygrep-hooks
61
+ "RUF", # Ruff-specific
62
+ "UP", # pyupgrade
63
+ ]
@@ -0,0 +1,166 @@
1
+ # based on https://github.com/pybind/cmake_example/blob/master/setup.py
2
+
3
+ import os
4
+ import re
5
+ import sys
6
+ import subprocess
7
+ import glob
8
+ import json
9
+ from pathlib import Path
10
+ from setuptools import Extension, setup
11
+ from setuptools.command.build_ext import build_ext
12
+
13
+
14
+ # echo "[\n$(find shared/** inkcpp/** inkcpp_compiler/** inkcpp_py/** -not -path '*/.*' | tr '\n' ' ' | sed -e 's/[^ ]\+/"\0"/g' -e 's/[[:blank:]]*$//' -e 's/ /,\n/g')\n]"
15
+ # + "CMakeLists.txt"
16
+
17
+ # Convert distutils Windows platform specifiers to CMake -A arguments
18
+ PLAT_TO_CMAKE = {
19
+ "win32": "Win32",
20
+ "win-amd64": "x64",
21
+ "win-arm32": "ARM",
22
+ "win-arm64": "ARM64",
23
+ }
24
+
25
+ def src_files(dir):
26
+ dir = os.fsencode(dir)
27
+ files = []
28
+ for file in os.listdir(dir):
29
+ if file[0] == '.':
30
+ continue
31
+ file = os.path.join(dir, file)
32
+ if os.path.isdir(file):
33
+ files += src_files(file)
34
+ else:
35
+ files.append(file.decode("utf-8"))
36
+ return files
37
+
38
+ def glob_src_files():
39
+ files = []
40
+ dirs = ['./inkcpp', './inkcpp_compiler', './inkcpp_py', './shared']
41
+ for dir in dirs:
42
+ files += src_files(dir)
43
+ return files
44
+
45
+
46
+ class CMakeExtension(Extension):
47
+ def __init__(self, name: str, sourcedir: str = "") -> None:
48
+ src_files = glob_src_files()
49
+ # src_files = json.load(open('inkcpp_py/sources.json'))
50
+ src_files += ["CMakeLists.txt", "Config.cmake.in"]
51
+ super().__init__(name, sources=src_files)
52
+ self.sourcedir = os.fspath(Path(sourcedir).resolve())
53
+
54
+ class CMakeBuild(build_ext):
55
+ def build_extension(self, ext: CMakeExtension) -> None:
56
+ # Must be in this form due to bug in .resolve() only fixed in Python 3.10+
57
+ ext_fullpath = Path.cwd() / self.get_ext_fullpath(ext.name)
58
+ extdir = ext_fullpath.parent.resolve()
59
+
60
+ # Using this requires trailing slash for auto-detection & inclusion of
61
+ # auxiliary "native" libs
62
+
63
+ debug = int(os.environ.get("DEBUG", 0)) if self.debug is None else self.debug
64
+ cfg = "Debug" if debug else "Release"
65
+
66
+ # CMake lets you override the generator - we need to check this.
67
+ # Can be set with Conda-Build, for example.
68
+ cmake_generator = os.environ.get("CMAKE_GENERATOR", "")
69
+
70
+ # Set Python_EXECUTABLE instead if you use PYBIND11_FINDPYTHON
71
+ # EXAMPLE_VERSION_INFO shows you how to pass a value into the C++ code
72
+ # from Python.
73
+ cmake_args = [
74
+ f"-DCMAKE_LIBRARY_OUTPUT_DIRECTORY={extdir}{os.sep}",
75
+ f"-DPYTHON_EXECUTABLE={sys.executable}",
76
+ f"-DCMAKE_BUILD_TYPE={cfg}", # not used on MSVC, but no harm
77
+ f"-DINKCPP_PY=ON",
78
+ f"-DWHEEL_BUILD=ON",
79
+ ]
80
+ build_args = [
81
+ f"--target=inkcpp_py",
82
+ ]
83
+ # Adding CMake arguments set as environment variable
84
+ # (needed e.g. to build for ARM OSx on conda-forge)
85
+ if "CMAKE_ARGS" in os.environ:
86
+ cmake_args += [item for item in os.environ["CMAKE_ARGS"].split(" ") if item]
87
+
88
+ if self.compiler.compiler_type != "msvc":
89
+ # Using Ninja-build since it a) is available as a wheel and b)
90
+ # multithreads automatically. MSVC would require all variables be
91
+ # exported for Ninja to pick it up, which is a little tricky to do.
92
+ # Users can override the generator with CMAKE_GENERATOR in CMake
93
+ # 3.15+.
94
+ if not cmake_generator or cmake_generator == "Ninja":
95
+ try:
96
+ import ninja
97
+
98
+ ninja_executable_path = Path(ninja.BIN_DIR) / "ninja"
99
+ cmake_args += [
100
+ "-GNinja",
101
+ f"-DCMAKE_MAKE_PROGRAM:FILEPATH={ninja_executable_path}",
102
+ ]
103
+ except ImportError:
104
+ pass
105
+
106
+ else:
107
+ # Single config generators are handled "normally"
108
+ single_config = any(x in cmake_generator for x in {"NMake", "Ninja"})
109
+
110
+ # CMake allows an arch-in-generator style for backward compatibility
111
+ contains_arch = any(x in cmake_generator for x in {"ARM", "Win64"})
112
+
113
+ # Specify the arch if using MSVC generator, but only if it doesn't
114
+ # contain a backward-compatibility arch spec already in the
115
+ # generator name.
116
+ if not single_config and not contains_arch:
117
+ cmake_args += ["-A", PLAT_TO_CMAKE[self.plat_name]]
118
+
119
+ # Multi-config generators have a different way to specify configs
120
+ if not single_config:
121
+ cmake_args += [
122
+ f"-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_{cfg.upper()}={extdir}"
123
+ ]
124
+ build_args += ["--config", cfg]
125
+
126
+ if sys.platform.startswith("darwin"):
127
+ # Cross-compile support for macOS - respect ARCHFLAGS if set
128
+ archs = re.findall(r"-arch (\S+)", os.environ.get("ARCHFLAGS", ""))
129
+ if archs:
130
+ cmake_args += ["-DCMAKE_OSX_ARCHITECTURES={}".format(";".join(archs))]
131
+
132
+ # Set CMAKE_BUILD_PARALLEL_LEVEL to control the parallel build level
133
+ # across all generators.
134
+ if "CMAKE_BUILD_PARALLEL_LEVEL" not in os.environ:
135
+ # self.parallel is a Python 3 only way to set parallel jobs by hand
136
+ # using -j in the build_ext call, not supported by pip or PyPA-build.
137
+ if hasattr(self, "parallel") and self.parallel:
138
+ # CMake 3.12+ only.
139
+ build_args += [f"-j{self.parallel}"]
140
+
141
+ build_temp = Path(self.build_temp) / ext.name
142
+ if not build_temp.exists():
143
+ build_temp.mkdir(parents=True)
144
+
145
+ print([f for f in os.listdir(ext.sourcedir)])
146
+ print("'{}'".format(ext.sourcedir), cmake_args)
147
+ subprocess.run(
148
+ ["cmake", ext.sourcedir, *cmake_args], cwd=build_temp, check=True
149
+ )
150
+ subprocess.run(
151
+ ["cmake", "--build", ".", *build_args], cwd=build_temp, check=True
152
+ )
153
+
154
+ setup(
155
+ name="inkcpp-py",
156
+ version="0.1.6",
157
+ author="Julian Benda",
158
+ author_email="julian.benda@ovgu.de",
159
+ description="Python bindings for InkCPP a Inkle runtime written in C++",
160
+ long_description="For all issues and ideas please visit the repository at https://github.com/JBenda/inkcpp",
161
+ zip_safe=False,
162
+ ext_modules=[CMakeExtension("inkcpp_py")],
163
+ cmdclass={"build_ext": CMakeBuild},
164
+ python_requires=">=3.7",
165
+ py_modules=[],
166
+ )
@@ -0,0 +1,14 @@
1
+ add_library(inkcpp_shared INTERFACE)
2
+
3
+ target_include_directories(inkcpp_shared
4
+ INTERFACE
5
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/public>
6
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/private>
7
+ $<INSTALL_INTERFACE:inkcpp>
8
+ )
9
+ FILE(GLOB PUBLIC_HEADERS "public/*")
10
+ set_target_properties(inkcpp_shared PROPERTIES PUBLIC_HEADER "${PUBLIC_HEADERS}")
11
+
12
+ # Unreal installation
13
+ install(DIRECTORY "public/" DESTINATION "inkcpp/Source/shared/Public" COMPONENT unreal EXCLUDE_FROM_ALL)
14
+ install(DIRECTORY "private/" DESTINATION "inkcpp/Source/shared/Private/" COMPONENT unreal EXCLUDE_FROM_ALL)