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,327 @@
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 "config.h"
10
+ #include "list.h"
11
+ #include "traits.h"
12
+ #include "system.h"
13
+ #include "types.h"
14
+
15
+ #ifdef INK_ENABLE_UNREAL
16
+ # include "../InkVar.h"
17
+ #endif
18
+
19
+ namespace ink::runtime::internal
20
+ {
21
+ class basic_eval_stack;
22
+ class string_table;
23
+ class list_table;
24
+
25
+ class callback_base
26
+ {
27
+ public:
28
+ virtual void call(ink::runtime::value, ink::optional<ink::runtime::value>) = 0;
29
+ };
30
+
31
+ template<typename F>
32
+ class callback final : public callback_base
33
+ {
34
+ using traits = function_traits<F>;
35
+ static_assert(traits::arity < 3);
36
+
37
+ template<ink::runtime::value::Type Ty>
38
+ void call_functor(ink::runtime::value new_val, ink::optional<ink::runtime::value> old_val)
39
+ {
40
+ if constexpr (traits::arity == 2) {
41
+ if (old_val.has_value()) {
42
+ functor(
43
+ new_val.get<Ty>(),
44
+ typename traits::template argument<1>::type{old_val.value().get<Ty>()}
45
+ );
46
+ } else {
47
+ functor(new_val.get<Ty>(), ink::nullopt);
48
+ }
49
+ } else {
50
+ functor(new_val.get<Ty>());
51
+ }
52
+ }
53
+
54
+ public:
55
+ callback(const callback&) = delete;
56
+ callback(callback&&) = delete;
57
+ callback& operator=(const callback&) = delete;
58
+ callback& operator=(callback&&) = delete;
59
+
60
+ callback(F functor)
61
+ : functor(functor)
62
+ {
63
+ }
64
+
65
+ virtual void call(ink::runtime::value new_val, ink::optional<ink::runtime::value> old_val)
66
+ {
67
+ using value = ink::runtime::value;
68
+ auto check_type = [&new_val, &old_val](value::Type type) {
69
+ inkAssert(
70
+ new_val.type == type, "Missmatch type for variable observer: expected %i, got %i",
71
+ static_cast<int>(type), static_cast<int>(new_val.type)
72
+ );
73
+ if constexpr (traits::arity == 2) {
74
+ // inkAssert(!old_val.has_value() || old_val.value().type == type,
75
+ // "Missmatch type for variable observers old value: expected optional<%i> got
76
+ // optional<%i>", static_cast<int>(type), static_cast<int>(old_val.value().type));
77
+ }
78
+ };
79
+ if constexpr (traits::arity > 0) {
80
+ using arg_t = typename remove_cvref<typename traits::template argument<0>::type>::type;
81
+ if constexpr (is_same<arg_t, value>::value) {
82
+ if constexpr (traits::arity == 2) {
83
+ functor(new_val, old_val);
84
+ } else {
85
+ functor(new_val);
86
+ }
87
+ } else if constexpr (is_same<arg_t, bool>::value) {
88
+ check_type(value::Type::Bool);
89
+ call_functor<value::Type::Bool>(new_val, old_val);
90
+ } else if constexpr (is_same<arg_t, uint32_t>::value) {
91
+ check_type(value::Type::Uint32);
92
+ call_functor<value::Type::Uint32>(new_val, old_val);
93
+ } else if constexpr (is_same<arg_t, int32_t>::value) {
94
+ check_type(value::Type::Int32);
95
+ call_functor<value::Type::Int32>(new_val, old_val);
96
+ } else if constexpr (is_same<arg_t, const char*>::value) {
97
+ check_type(value::Type::String);
98
+ call_functor<value::Type::String>(new_val, old_val);
99
+ } else if constexpr (is_same<arg_t, float>::value) {
100
+ check_type(value::Type::Float);
101
+ call_functor<value::Type::Float>(new_val, old_val);
102
+ } else if constexpr (is_same<arg_t, list_interface*>::value) {
103
+ check_type(value::Type::List);
104
+ call_functor<value::Type::List>(new_val, old_val);
105
+ } else {
106
+ static_assert(
107
+ always_false<arg_t>::value, "Unsupported value for variable observer callback!"
108
+ );
109
+ }
110
+ } else {
111
+ functor();
112
+ }
113
+ }
114
+
115
+ private:
116
+ F functor;
117
+ };
118
+
119
+ // base function container with virtual callback methods
120
+ class function_base
121
+ {
122
+ public:
123
+ function_base(bool lookaheadSafe)
124
+ : _lookaheadSafe(lookaheadSafe)
125
+ {
126
+ }
127
+
128
+ virtual ~function_base() {}
129
+
130
+ // calls the underlying function object taking parameters from a stack
131
+ // TODO: remove ?
132
+ #ifdef INK_ENABLE_UNREAL
133
+ virtual void
134
+ call(basic_eval_stack* stack, size_t length, string_table& strings, list_table& lists)
135
+ = 0;
136
+ #else
137
+ virtual void
138
+ call(basic_eval_stack* stack, size_t length, string_table& strings, list_table& lists)
139
+ = 0;
140
+ #endif
141
+
142
+ bool lookaheadSafe() const { return _lookaheadSafe; }
143
+
144
+ protected:
145
+ bool _lookaheadSafe;
146
+ // used to hide basic_eval_stack and value definitions
147
+ template<typename T>
148
+ static T pop(basic_eval_stack* stack, list_table& lists);
149
+
150
+ // used to hide basic_eval_stack and value definitions
151
+ template<typename T>
152
+ static void push(basic_eval_stack* stack, const T& value);
153
+
154
+ static void push_void(basic_eval_stack* stack);
155
+
156
+ // string special push
157
+ static void push_string(basic_eval_stack* stack, const char* dynamic_string);
158
+
159
+ // used to hide string_table definitions
160
+ static char* allocate(string_table& strings, ink::size_t len);
161
+ };
162
+
163
+ // Stores a Callable function object and forwards calls to it
164
+ template<typename F>
165
+ class function : public function_base
166
+ {
167
+ public:
168
+ function(F functor, bool lookaheadSafe)
169
+ : function_base(lookaheadSafe)
170
+ , functor(functor)
171
+ {
172
+ }
173
+
174
+ // calls the underlying function using arguments on the stack
175
+ virtual void call(
176
+ basic_eval_stack* stack, size_t length, string_table& strings, list_table& lists
177
+ ) override
178
+ {
179
+ call(stack, length, strings, lists, GenSeq<traits::arity>());
180
+ }
181
+
182
+ private:
183
+ // Callable functor object
184
+ F functor;
185
+
186
+ // function traits
187
+ using traits = function_traits<F>;
188
+
189
+ // argument types
190
+ template<int index>
191
+ using arg_type = typename function_traits<F>::template argument<index>::type;
192
+
193
+ // pops an argument from the stack using the function-type
194
+ template<int index>
195
+ arg_type<index> pop_arg(basic_eval_stack* stack, list_table& lists)
196
+ {
197
+ // todo - type assert?
198
+ return pop<arg_type<index>>(stack, lists);
199
+ }
200
+
201
+ static constexpr bool is_array_call()
202
+ {
203
+ if constexpr (traits::arity == 2) {
204
+ return is_same<
205
+ const ink::runtime::value*, typename traits::template argument<1>::type>::value;
206
+ }
207
+ return false;
208
+ }
209
+
210
+ template<size_t... Is>
211
+ void
212
+ call(basic_eval_stack* stack, size_t length, string_table& strings, list_table& lists, seq<Is...>)
213
+ {
214
+ inkAssert(
215
+ is_array_call() || sizeof...(Is) == length,
216
+ "Attempting to call functor with too few/many arguments"
217
+ );
218
+ static_assert(sizeof...(Is) == traits::arity);
219
+ if_t<is_array_call(), value[config::maxArrayCallArity], char> vals;
220
+ if constexpr (is_array_call()) {
221
+ inkAssert(
222
+ length <= config::maxArrayCallArity,
223
+ "AIttampt to call array call with more arguments then supportet, please change in "
224
+ "config"
225
+ );
226
+ for (size_t i = 0; i < length; ++i) {
227
+ vals[i] = pop<ink::runtime::value>(stack, lists);
228
+ }
229
+ }
230
+ // void functions
231
+ if constexpr (is_same<void, typename traits::return_type>::value) {
232
+ // Just evaluevaluatelate
233
+ if constexpr (is_array_call()) {
234
+ functor(length, vals);
235
+ } else {
236
+ functor(pop_arg<Is>(stack, lists)...);
237
+ }
238
+
239
+ // Ink expects us to push something
240
+ push_void(stack);
241
+ } else {
242
+ typename traits::return_type res;
243
+ if constexpr (is_array_call()) {
244
+ res = functor(length, vals);
245
+ } else {
246
+ res = functor(pop_arg<Is>(stack, lists)...);
247
+ }
248
+ if constexpr (is_string<typename traits::return_type>::value) {
249
+ // SPECIAL: The result of the functor is a string type
250
+ // in order to store it in the inkcpp interpreter we
251
+ // need to store it in our allocated string table
252
+ // Get string length
253
+ size_t len = string_handler<typename traits::return_type>::length(res);
254
+
255
+ // Get source and allocate buffer
256
+ char* buffer = allocate(strings, len + 1);
257
+ string_handler<typename traits::return_type>::src_copy(res, buffer);
258
+
259
+ // push string result
260
+ push_string(stack, buffer);
261
+ } else if constexpr (is_same<value, remove_cvref<typename traits::return_type>>::value) {
262
+ if (res.type() == ink::runtime::value::Type::String) {
263
+ auto src = res.template get<ink::runtime::value::Type::String>();
264
+ size_t len = string_handler<decltype(src)>::length(src);
265
+ char* buffer = allocate(strings, len + 1);
266
+ string_handler<decltype(src)>::src_copy(src, buffer);
267
+ push_string(stack, buffer);
268
+ } else {
269
+ push(stack, res);
270
+ }
271
+ } else {
272
+ // Evaluate and push the result onto the stack
273
+ push(stack, res);
274
+ }
275
+ }
276
+ }
277
+ };
278
+
279
+ #ifdef INK_ENABLE_UNREAL
280
+ template<typename D>
281
+ class function_array_delegate : public function_base
282
+ {
283
+ public:
284
+ function_array_delegate(const D& del, bool lookaheadSafe)
285
+ : function_base(lookaheadSafe)
286
+ , invocableDelegate(del)
287
+ {
288
+ }
289
+
290
+ // calls the underlying delegate using arguments on the stack
291
+ virtual void call(
292
+ basic_eval_stack* stack, size_t length, string_table& strings, list_table& lists
293
+ ) override
294
+ {
295
+ constexpr bool RET_VOID
296
+ = is_same<typename function_traits<decltype(&D::Execute)>::return_type, void>::value;
297
+ // Create variable array
298
+ TArray<FInkVar> variables;
299
+ for (size_t i = 0; i < length; i++) {
300
+ variables.Add(pop<FInkVar>(stack, lists));
301
+ }
302
+ if constexpr (RET_VOID) {
303
+ invocableDelegate.Execute(variables);
304
+ push(stack, 0);
305
+ } else {
306
+
307
+ auto ret = invocableDelegate.Execute(variables);
308
+ ink::runtime::value result = ret.to_value();
309
+ if (result.type == ink::runtime::value::Type::String) {
310
+ const char* src = result.get<ink::runtime::value::Type::String>();
311
+ size_t len = string_handler<const char*>::length(src);
312
+ char* buffer = allocate(strings, len + 1);
313
+ char* ptr = buffer;
314
+ while (*src != '\0')
315
+ *(ptr++) = *(src++);
316
+ *ptr = 0;
317
+ result = ink::runtime::value(buffer);
318
+ }
319
+ push(stack, result);
320
+ }
321
+ }
322
+
323
+ private:
324
+ D invocableDelegate;
325
+ };
326
+ #endif
327
+ } // namespace ink::runtime::internal
@@ -0,0 +1,196 @@
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 "types.h"
10
+ #include "functional.h"
11
+
12
+ namespace ink::runtime
13
+ {
14
+ class snapshot;
15
+
16
+ /**
17
+ * Represents a global store to be shared amongst ink runners.
18
+ * Stores global variable values, visit counts, turn counts, etc.
19
+ */
20
+ class globals_interface
21
+ {
22
+ public:
23
+ /**
24
+ * @brief Access global variable of Ink runner.
25
+ * @param name name of variable, as defined in InkScript
26
+ * @tparam T c++ type of variable
27
+ * @return nullopt if variable won't exist or type won't match
28
+ */
29
+ template<typename T>
30
+ optional<T> get(const char* name) const
31
+ {
32
+ static_assert(internal::always_false<T>::value, "Requested Type is not supported");
33
+ }
34
+
35
+ /**
36
+ * @brief Write new value in global store.
37
+ * @param name name of variable, as defined in InkScript
38
+ * @param val
39
+ * @tparam T c++ type of variable
40
+ * @retval true on success
41
+ */
42
+ template<typename T>
43
+ bool set(const char* name, const T& val)
44
+ {
45
+ static_assert(internal::always_false<T>::value, "Requested Type is not supported");
46
+ return false;
47
+ }
48
+
49
+ /**
50
+ * @brief Observers global variable.
51
+ *
52
+ * Calls callback with `value` or with casted value if it is one of
53
+ * values variants. The callback will also be called with the current value
54
+ * when the observe is bind.
55
+ * @param name of variable to observe
56
+ * @param callback functor with:
57
+ * * 0 arguments
58
+ * * 1 argument: `new_value`
59
+ * * 2 arguments: `new_value`, `ink::optional<old_value>`: first time call will not contain a
60
+ * old_value
61
+ */
62
+ template<typename F>
63
+ void observe(const char* name, F callback)
64
+ {
65
+ internal_observe(hash_string(name), new internal::callback(callback));
66
+ }
67
+
68
+ /** create a snapshot of the current runtime state.
69
+ * (inclusive all runners assoziated with this globals)
70
+ */
71
+ virtual snapshot* create_snapshot() const = 0;
72
+
73
+ virtual ~globals_interface() = default;
74
+
75
+ protected:
76
+ /** @private */
77
+ virtual optional<value> get_var(hash_t name) const = 0;
78
+ /** @private */
79
+ virtual bool set_var(hash_t name, const value& val) = 0;
80
+ /** @private */
81
+ virtual void internal_observe(hash_t name, internal::callback_base* callback) = 0;
82
+ };
83
+
84
+ /** @name Instanciations */
85
+ ///@{
86
+ /** getter and setter instanciations for supported types */
87
+ template<>
88
+ inline optional<value> globals_interface::get<value>(const char* name) const
89
+ {
90
+ return get_var(hash_string(name));
91
+ }
92
+
93
+ template<>
94
+ inline bool globals_interface::set<value>(const char* name, const value& val)
95
+ {
96
+ return set_var(hash_string(name), val);
97
+ }
98
+
99
+ template<>
100
+ inline optional<bool> globals_interface::get<bool>(const char* name) const
101
+ {
102
+ auto var = get_var(hash_string(name));
103
+ if (var && var->type == value::Type::Bool) {
104
+ return {var->get<value::Type::Bool>()};
105
+ }
106
+ return nullopt;
107
+ }
108
+
109
+ template<>
110
+ inline bool globals_interface::set<bool>(const char* name, const bool& val)
111
+ {
112
+ return set_var(hash_string(name), value(val));
113
+ }
114
+
115
+ template<>
116
+ inline optional<uint32_t> globals_interface::get<uint32_t>(const char* name) const
117
+ {
118
+ auto var = get_var(hash_string(name));
119
+ if (var && var->type == value::Type::Uint32) {
120
+ return {var->get<value::Type::Uint32>()};
121
+ }
122
+ return nullopt;
123
+ }
124
+
125
+ template<>
126
+ inline bool globals_interface::set<uint32_t>(const char* name, const uint32_t& val)
127
+ {
128
+ return set_var(hash_string(name), value(val));
129
+ }
130
+
131
+ template<>
132
+ inline optional<int32_t> globals_interface::get<int32_t>(const char* name) const
133
+ {
134
+ auto var = get_var(hash_string(name));
135
+ if (var && var->type == value::Type::Int32) {
136
+ return {var->get<value::Type::Int32>()};
137
+ }
138
+ return nullopt;
139
+ }
140
+
141
+ template<>
142
+ inline bool globals_interface::set<int32_t>(const char* name, const int32_t& val)
143
+ {
144
+ return set_var(hash_string(name), value(val));
145
+ }
146
+
147
+ template<>
148
+ inline optional<float> globals_interface::get<float>(const char* name) const
149
+ {
150
+ auto var = get_var(hash_string(name));
151
+ if (var && var->type == value::Type::Float) {
152
+ return {var->get<value::Type::Float>()};
153
+ }
154
+ return nullopt;
155
+ }
156
+
157
+ template<>
158
+ inline bool globals_interface::set<float>(const char* name, const float& val)
159
+ {
160
+ return set_var(hash_string(name), value(val));
161
+ }
162
+
163
+ template<>
164
+ inline optional<const char*> globals_interface::get<const char*>(const char* name) const
165
+ {
166
+ auto var = get_var(hash_string(name));
167
+ if (var && var->type == value::Type::String) {
168
+ return {var->get<value::Type::String>()};
169
+ }
170
+ return nullopt;
171
+ }
172
+
173
+ template<>
174
+ inline bool globals_interface::set<const char*>(const char* name, const char* const& val)
175
+ {
176
+ return set_var(hash_string(name), value(val));
177
+ }
178
+
179
+ template<>
180
+ inline optional<list> globals_interface::get<list>(const char* name) const
181
+ {
182
+ auto var = get_var(hash_string(name));
183
+ if (var && var->type == value::Type::List) {
184
+ return {var->get<value::Type::List>()};
185
+ }
186
+ return nullopt;
187
+ }
188
+
189
+ template<>
190
+ inline bool globals_interface::set<list>(const char* name, const list& val)
191
+ {
192
+ return set_var(hash_string(name), value(val));
193
+ }
194
+
195
+ ///@}
196
+ } // namespace ink::runtime
@@ -0,0 +1,187 @@
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
+
11
+ #ifdef INK_ENABLE_STL
12
+ # include <ostream>
13
+ #endif
14
+
15
+ #ifdef INK_BUILD_CLIB
16
+ struct InkListIter;
17
+ struct HInkList;
18
+ int ink_list_flags(const HInkList*, InkListIter*);
19
+ int ink_list_flags_from(const HInkList*, const char*, InkListIter*);
20
+ int ink_list_iter_next(InkListIter*);
21
+ #endif
22
+
23
+ namespace ink::runtime
24
+ {
25
+ namespace internal
26
+ {
27
+ class list_table;
28
+ } // namespace internal
29
+
30
+ /** Interface for accessing a Ink list.
31
+ *
32
+ * Every function which takes a flag name can also be feed with
33
+ * a full flag name in the format `listName.flagName`
34
+ * @code
35
+ * using namespace ink::runtime;
36
+ * list l = globals.get<list>("list_var");
37
+ * l.add("flagName");
38
+ * l.add("listName.FlagName")
39
+ * globals.set("list_var", l);
40
+ * @endcode
41
+ */
42
+ class list_interface
43
+ {
44
+ public:
45
+ list_interface()
46
+ : _list_table{nullptr}
47
+ , _list{-1}
48
+ {
49
+ }
50
+
51
+ /** iterater for flags in a list
52
+ * @todo implement `operator->`
53
+ */
54
+ class iterator
55
+ {
56
+ const char* _flag_name;
57
+ const char* _list_name;
58
+ const list_interface& _list;
59
+ int _i;
60
+ bool _one_list_iterator; ///< iterates only though values of one list
61
+ friend list_interface;
62
+ #ifdef INK_BUILD_CLIB
63
+ friend int ::ink_list_flags(const HInkList*, InkListIter*);
64
+ friend int ::ink_list_flags_from(const HInkList*, const char*, InkListIter*);
65
+ friend int ::ink_list_iter_next(InkListIter* self);
66
+ #endif
67
+
68
+ protected:
69
+ /** @private */
70
+ iterator(
71
+ const char* flag_name, const list_interface& list, size_t i, bool one_list_only = false
72
+ )
73
+ : _flag_name(flag_name)
74
+ , _list(list)
75
+ , _i(i)
76
+ , _one_list_iterator(one_list_only)
77
+ {
78
+ }
79
+
80
+ public:
81
+ /** contains flag data */
82
+ struct Flag {
83
+ const char* flag_name; ///< name of the flag
84
+ const char* list_name; ///< name of the list
85
+ #ifdef INK_ENABLE_STL
86
+ /** serelization operator
87
+ * @param os
88
+ * @param flag
89
+ */
90
+ friend std::ostream& operator<<(std::ostream& os, const Flag& flag)
91
+ {
92
+ os << flag.list_name << "(" << flag.flag_name << ")";
93
+ return os;
94
+ }
95
+ #endif
96
+ };
97
+
98
+ /** access value the iterator is pointing to */
99
+ Flag operator*() const { return Flag{ _flag_name, _list_name }; };
100
+
101
+ /** continue iterator to next value */
102
+ iterator& operator++()
103
+ {
104
+ _list.next(_flag_name, _list_name, _i, _one_list_iterator);
105
+ return *this;
106
+ }
107
+
108
+ /** checks if iterator points not to the same element
109
+ * @param itr other iterator
110
+ */
111
+ bool operator!=(const iterator& itr) const { return itr._i != _i; }
112
+
113
+ /** checks if iterator points to the same element
114
+ * @param itr other iterator
115
+ */
116
+ bool operator==(const iterator& itr) const { return itr._i == _i; }
117
+ };
118
+
119
+ /** checks if a flag is contained in the list */
120
+ virtual bool contains(const char* flag) const
121
+ {
122
+ inkAssert(false, "Not implemented function from interfaces is called!");
123
+ return false;
124
+ };
125
+
126
+ /** add a flag to list */
127
+ virtual void add(const char* flag)
128
+ {
129
+ inkAssert(false, "Not implemented function from interface is called!");
130
+ };
131
+
132
+ /** removes a flag from list */
133
+ virtual void remove(const char* flag)
134
+ {
135
+ inkAssert(false, "Not implemented function from interface is called!");
136
+ };
137
+
138
+ /** begin iterator for contained flags in list */
139
+ virtual iterator begin() const
140
+ {
141
+ inkAssert(false, "Not implemented function from interface is called!");
142
+ return new_iterator(nullptr, -1);
143
+ };
144
+
145
+ /** returns a iterator over elements of the given list */
146
+ virtual iterator begin(const char* list_name) const
147
+ {
148
+ inkAssert(false, "Not implemented function from interface is called!");
149
+ return new_iterator(nullptr, -1);
150
+ }
151
+
152
+ /** end iterator for contained flags in list */
153
+ virtual iterator end() const
154
+ {
155
+ inkAssert(false, "Not implemented function from interface is called!");
156
+ return new_iterator(nullptr, -1);
157
+ };
158
+
159
+ private:
160
+ friend iterator;
161
+
162
+ virtual void
163
+ next(const char*& flag_name, const char*& list_name, int& i, bool _one_list_iterator) const
164
+ {
165
+ inkAssert(false, "Not implemented funciton from interface is called!");
166
+ };
167
+
168
+ protected:
169
+ /** @private */
170
+ iterator new_iterator(const char* flag_name, int i, bool one_list_only = false) const
171
+ {
172
+ return iterator(flag_name, *this, i, one_list_only);
173
+ }
174
+
175
+ /** @private */
176
+ list_interface(internal::list_table& table, int list)
177
+ : _list_table{&table}
178
+ , _list{list}
179
+ {
180
+ }
181
+
182
+ /** @private */
183
+ internal::list_table* _list_table;
184
+ /** @private */
185
+ int _list;
186
+ };
187
+ } // namespace ink::runtime