kreuzberg 4.0.0.pre.rc.6

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 (330) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +14 -0
  3. data/.rspec +3 -0
  4. data/.rubocop.yaml +1 -0
  5. data/.rubocop.yml +538 -0
  6. data/Gemfile +8 -0
  7. data/Gemfile.lock +157 -0
  8. data/README.md +426 -0
  9. data/Rakefile +25 -0
  10. data/Steepfile +47 -0
  11. data/examples/async_patterns.rb +341 -0
  12. data/ext/kreuzberg_rb/extconf.rb +45 -0
  13. data/ext/kreuzberg_rb/native/Cargo.lock +6535 -0
  14. data/ext/kreuzberg_rb/native/Cargo.toml +44 -0
  15. data/ext/kreuzberg_rb/native/README.md +425 -0
  16. data/ext/kreuzberg_rb/native/build.rs +15 -0
  17. data/ext/kreuzberg_rb/native/include/ieeefp.h +11 -0
  18. data/ext/kreuzberg_rb/native/include/msvc_compat/strings.h +14 -0
  19. data/ext/kreuzberg_rb/native/include/strings.h +20 -0
  20. data/ext/kreuzberg_rb/native/include/unistd.h +47 -0
  21. data/ext/kreuzberg_rb/native/src/lib.rs +2998 -0
  22. data/extconf.rb +28 -0
  23. data/kreuzberg.gemspec +148 -0
  24. data/lib/kreuzberg/api_proxy.rb +142 -0
  25. data/lib/kreuzberg/cache_api.rb +46 -0
  26. data/lib/kreuzberg/cli.rb +55 -0
  27. data/lib/kreuzberg/cli_proxy.rb +127 -0
  28. data/lib/kreuzberg/config.rb +691 -0
  29. data/lib/kreuzberg/error_context.rb +32 -0
  30. data/lib/kreuzberg/errors.rb +118 -0
  31. data/lib/kreuzberg/extraction_api.rb +85 -0
  32. data/lib/kreuzberg/mcp_proxy.rb +186 -0
  33. data/lib/kreuzberg/ocr_backend_protocol.rb +113 -0
  34. data/lib/kreuzberg/post_processor_protocol.rb +86 -0
  35. data/lib/kreuzberg/result.rb +216 -0
  36. data/lib/kreuzberg/setup_lib_path.rb +80 -0
  37. data/lib/kreuzberg/validator_protocol.rb +89 -0
  38. data/lib/kreuzberg/version.rb +5 -0
  39. data/lib/kreuzberg.rb +103 -0
  40. data/sig/kreuzberg/internal.rbs +184 -0
  41. data/sig/kreuzberg.rbs +520 -0
  42. data/spec/binding/cache_spec.rb +227 -0
  43. data/spec/binding/cli_proxy_spec.rb +85 -0
  44. data/spec/binding/cli_spec.rb +55 -0
  45. data/spec/binding/config_spec.rb +345 -0
  46. data/spec/binding/config_validation_spec.rb +283 -0
  47. data/spec/binding/error_handling_spec.rb +213 -0
  48. data/spec/binding/errors_spec.rb +66 -0
  49. data/spec/binding/plugins/ocr_backend_spec.rb +307 -0
  50. data/spec/binding/plugins/postprocessor_spec.rb +269 -0
  51. data/spec/binding/plugins/validator_spec.rb +274 -0
  52. data/spec/fixtures/config.toml +39 -0
  53. data/spec/fixtures/config.yaml +41 -0
  54. data/spec/fixtures/invalid_config.toml +4 -0
  55. data/spec/smoke/package_spec.rb +178 -0
  56. data/spec/spec_helper.rb +42 -0
  57. data/vendor/kreuzberg/Cargo.toml +204 -0
  58. data/vendor/kreuzberg/README.md +175 -0
  59. data/vendor/kreuzberg/benches/otel_overhead.rs +48 -0
  60. data/vendor/kreuzberg/build.rs +474 -0
  61. data/vendor/kreuzberg/src/api/error.rs +81 -0
  62. data/vendor/kreuzberg/src/api/handlers.rs +199 -0
  63. data/vendor/kreuzberg/src/api/mod.rs +79 -0
  64. data/vendor/kreuzberg/src/api/server.rs +353 -0
  65. data/vendor/kreuzberg/src/api/types.rs +170 -0
  66. data/vendor/kreuzberg/src/cache/mod.rs +1167 -0
  67. data/vendor/kreuzberg/src/chunking/mod.rs +677 -0
  68. data/vendor/kreuzberg/src/core/batch_mode.rs +95 -0
  69. data/vendor/kreuzberg/src/core/config.rs +1032 -0
  70. data/vendor/kreuzberg/src/core/extractor.rs +1024 -0
  71. data/vendor/kreuzberg/src/core/io.rs +329 -0
  72. data/vendor/kreuzberg/src/core/mime.rs +605 -0
  73. data/vendor/kreuzberg/src/core/mod.rs +45 -0
  74. data/vendor/kreuzberg/src/core/pipeline.rs +984 -0
  75. data/vendor/kreuzberg/src/embeddings.rs +432 -0
  76. data/vendor/kreuzberg/src/error.rs +431 -0
  77. data/vendor/kreuzberg/src/extraction/archive.rs +954 -0
  78. data/vendor/kreuzberg/src/extraction/docx.rs +40 -0
  79. data/vendor/kreuzberg/src/extraction/email.rs +854 -0
  80. data/vendor/kreuzberg/src/extraction/excel.rs +688 -0
  81. data/vendor/kreuzberg/src/extraction/html.rs +553 -0
  82. data/vendor/kreuzberg/src/extraction/image.rs +368 -0
  83. data/vendor/kreuzberg/src/extraction/libreoffice.rs +563 -0
  84. data/vendor/kreuzberg/src/extraction/markdown.rs +213 -0
  85. data/vendor/kreuzberg/src/extraction/mod.rs +81 -0
  86. data/vendor/kreuzberg/src/extraction/office_metadata/app_properties.rs +398 -0
  87. data/vendor/kreuzberg/src/extraction/office_metadata/core_properties.rs +247 -0
  88. data/vendor/kreuzberg/src/extraction/office_metadata/custom_properties.rs +240 -0
  89. data/vendor/kreuzberg/src/extraction/office_metadata/mod.rs +130 -0
  90. data/vendor/kreuzberg/src/extraction/office_metadata/odt_properties.rs +287 -0
  91. data/vendor/kreuzberg/src/extraction/pptx.rs +3000 -0
  92. data/vendor/kreuzberg/src/extraction/structured.rs +490 -0
  93. data/vendor/kreuzberg/src/extraction/table.rs +328 -0
  94. data/vendor/kreuzberg/src/extraction/text.rs +269 -0
  95. data/vendor/kreuzberg/src/extraction/xml.rs +333 -0
  96. data/vendor/kreuzberg/src/extractors/archive.rs +446 -0
  97. data/vendor/kreuzberg/src/extractors/bibtex.rs +469 -0
  98. data/vendor/kreuzberg/src/extractors/docbook.rs +502 -0
  99. data/vendor/kreuzberg/src/extractors/docx.rs +367 -0
  100. data/vendor/kreuzberg/src/extractors/email.rs +143 -0
  101. data/vendor/kreuzberg/src/extractors/epub.rs +707 -0
  102. data/vendor/kreuzberg/src/extractors/excel.rs +343 -0
  103. data/vendor/kreuzberg/src/extractors/fictionbook.rs +491 -0
  104. data/vendor/kreuzberg/src/extractors/fictionbook.rs.backup2 +738 -0
  105. data/vendor/kreuzberg/src/extractors/html.rs +393 -0
  106. data/vendor/kreuzberg/src/extractors/image.rs +198 -0
  107. data/vendor/kreuzberg/src/extractors/jats.rs +1051 -0
  108. data/vendor/kreuzberg/src/extractors/jupyter.rs +367 -0
  109. data/vendor/kreuzberg/src/extractors/latex.rs +652 -0
  110. data/vendor/kreuzberg/src/extractors/markdown.rs +700 -0
  111. data/vendor/kreuzberg/src/extractors/mod.rs +365 -0
  112. data/vendor/kreuzberg/src/extractors/odt.rs +628 -0
  113. data/vendor/kreuzberg/src/extractors/opml.rs +634 -0
  114. data/vendor/kreuzberg/src/extractors/orgmode.rs +528 -0
  115. data/vendor/kreuzberg/src/extractors/pdf.rs +493 -0
  116. data/vendor/kreuzberg/src/extractors/pptx.rs +248 -0
  117. data/vendor/kreuzberg/src/extractors/rst.rs +576 -0
  118. data/vendor/kreuzberg/src/extractors/rtf.rs +810 -0
  119. data/vendor/kreuzberg/src/extractors/security.rs +484 -0
  120. data/vendor/kreuzberg/src/extractors/security_tests.rs +367 -0
  121. data/vendor/kreuzberg/src/extractors/structured.rs +140 -0
  122. data/vendor/kreuzberg/src/extractors/text.rs +260 -0
  123. data/vendor/kreuzberg/src/extractors/typst.rs +650 -0
  124. data/vendor/kreuzberg/src/extractors/xml.rs +135 -0
  125. data/vendor/kreuzberg/src/image/dpi.rs +164 -0
  126. data/vendor/kreuzberg/src/image/mod.rs +6 -0
  127. data/vendor/kreuzberg/src/image/preprocessing.rs +417 -0
  128. data/vendor/kreuzberg/src/image/resize.rs +89 -0
  129. data/vendor/kreuzberg/src/keywords/config.rs +154 -0
  130. data/vendor/kreuzberg/src/keywords/mod.rs +237 -0
  131. data/vendor/kreuzberg/src/keywords/processor.rs +267 -0
  132. data/vendor/kreuzberg/src/keywords/rake.rs +293 -0
  133. data/vendor/kreuzberg/src/keywords/types.rs +68 -0
  134. data/vendor/kreuzberg/src/keywords/yake.rs +163 -0
  135. data/vendor/kreuzberg/src/language_detection/mod.rs +942 -0
  136. data/vendor/kreuzberg/src/lib.rs +105 -0
  137. data/vendor/kreuzberg/src/mcp/mod.rs +32 -0
  138. data/vendor/kreuzberg/src/mcp/server.rs +1968 -0
  139. data/vendor/kreuzberg/src/ocr/cache.rs +469 -0
  140. data/vendor/kreuzberg/src/ocr/error.rs +37 -0
  141. data/vendor/kreuzberg/src/ocr/hocr.rs +216 -0
  142. data/vendor/kreuzberg/src/ocr/mod.rs +58 -0
  143. data/vendor/kreuzberg/src/ocr/processor.rs +863 -0
  144. data/vendor/kreuzberg/src/ocr/table/mod.rs +4 -0
  145. data/vendor/kreuzberg/src/ocr/table/tsv_parser.rs +144 -0
  146. data/vendor/kreuzberg/src/ocr/tesseract_backend.rs +450 -0
  147. data/vendor/kreuzberg/src/ocr/types.rs +393 -0
  148. data/vendor/kreuzberg/src/ocr/utils.rs +47 -0
  149. data/vendor/kreuzberg/src/ocr/validation.rs +206 -0
  150. data/vendor/kreuzberg/src/panic_context.rs +154 -0
  151. data/vendor/kreuzberg/src/pdf/error.rs +122 -0
  152. data/vendor/kreuzberg/src/pdf/images.rs +139 -0
  153. data/vendor/kreuzberg/src/pdf/metadata.rs +346 -0
  154. data/vendor/kreuzberg/src/pdf/mod.rs +50 -0
  155. data/vendor/kreuzberg/src/pdf/rendering.rs +369 -0
  156. data/vendor/kreuzberg/src/pdf/table.rs +393 -0
  157. data/vendor/kreuzberg/src/pdf/text.rs +158 -0
  158. data/vendor/kreuzberg/src/plugins/extractor.rs +1013 -0
  159. data/vendor/kreuzberg/src/plugins/mod.rs +209 -0
  160. data/vendor/kreuzberg/src/plugins/ocr.rs +620 -0
  161. data/vendor/kreuzberg/src/plugins/processor.rs +642 -0
  162. data/vendor/kreuzberg/src/plugins/registry.rs +1337 -0
  163. data/vendor/kreuzberg/src/plugins/traits.rs +258 -0
  164. data/vendor/kreuzberg/src/plugins/validator.rs +956 -0
  165. data/vendor/kreuzberg/src/stopwords/mod.rs +1470 -0
  166. data/vendor/kreuzberg/src/text/mod.rs +19 -0
  167. data/vendor/kreuzberg/src/text/quality.rs +697 -0
  168. data/vendor/kreuzberg/src/text/string_utils.rs +217 -0
  169. data/vendor/kreuzberg/src/text/token_reduction/cjk_utils.rs +164 -0
  170. data/vendor/kreuzberg/src/text/token_reduction/config.rs +100 -0
  171. data/vendor/kreuzberg/src/text/token_reduction/core.rs +796 -0
  172. data/vendor/kreuzberg/src/text/token_reduction/filters.rs +902 -0
  173. data/vendor/kreuzberg/src/text/token_reduction/mod.rs +160 -0
  174. data/vendor/kreuzberg/src/text/token_reduction/semantic.rs +619 -0
  175. data/vendor/kreuzberg/src/text/token_reduction/simd_text.rs +147 -0
  176. data/vendor/kreuzberg/src/types.rs +903 -0
  177. data/vendor/kreuzberg/src/utils/mod.rs +17 -0
  178. data/vendor/kreuzberg/src/utils/quality.rs +959 -0
  179. data/vendor/kreuzberg/src/utils/string_utils.rs +381 -0
  180. data/vendor/kreuzberg/stopwords/af_stopwords.json +53 -0
  181. data/vendor/kreuzberg/stopwords/ar_stopwords.json +482 -0
  182. data/vendor/kreuzberg/stopwords/bg_stopwords.json +261 -0
  183. data/vendor/kreuzberg/stopwords/bn_stopwords.json +400 -0
  184. data/vendor/kreuzberg/stopwords/br_stopwords.json +1205 -0
  185. data/vendor/kreuzberg/stopwords/ca_stopwords.json +280 -0
  186. data/vendor/kreuzberg/stopwords/cs_stopwords.json +425 -0
  187. data/vendor/kreuzberg/stopwords/da_stopwords.json +172 -0
  188. data/vendor/kreuzberg/stopwords/de_stopwords.json +622 -0
  189. data/vendor/kreuzberg/stopwords/el_stopwords.json +849 -0
  190. data/vendor/kreuzberg/stopwords/en_stopwords.json +1300 -0
  191. data/vendor/kreuzberg/stopwords/eo_stopwords.json +175 -0
  192. data/vendor/kreuzberg/stopwords/es_stopwords.json +734 -0
  193. data/vendor/kreuzberg/stopwords/et_stopwords.json +37 -0
  194. data/vendor/kreuzberg/stopwords/eu_stopwords.json +100 -0
  195. data/vendor/kreuzberg/stopwords/fa_stopwords.json +801 -0
  196. data/vendor/kreuzberg/stopwords/fi_stopwords.json +849 -0
  197. data/vendor/kreuzberg/stopwords/fr_stopwords.json +693 -0
  198. data/vendor/kreuzberg/stopwords/ga_stopwords.json +111 -0
  199. data/vendor/kreuzberg/stopwords/gl_stopwords.json +162 -0
  200. data/vendor/kreuzberg/stopwords/gu_stopwords.json +226 -0
  201. data/vendor/kreuzberg/stopwords/ha_stopwords.json +41 -0
  202. data/vendor/kreuzberg/stopwords/he_stopwords.json +196 -0
  203. data/vendor/kreuzberg/stopwords/hi_stopwords.json +227 -0
  204. data/vendor/kreuzberg/stopwords/hr_stopwords.json +181 -0
  205. data/vendor/kreuzberg/stopwords/hu_stopwords.json +791 -0
  206. data/vendor/kreuzberg/stopwords/hy_stopwords.json +47 -0
  207. data/vendor/kreuzberg/stopwords/id_stopwords.json +760 -0
  208. data/vendor/kreuzberg/stopwords/it_stopwords.json +634 -0
  209. data/vendor/kreuzberg/stopwords/ja_stopwords.json +136 -0
  210. data/vendor/kreuzberg/stopwords/kn_stopwords.json +84 -0
  211. data/vendor/kreuzberg/stopwords/ko_stopwords.json +681 -0
  212. data/vendor/kreuzberg/stopwords/ku_stopwords.json +64 -0
  213. data/vendor/kreuzberg/stopwords/la_stopwords.json +51 -0
  214. data/vendor/kreuzberg/stopwords/lt_stopwords.json +476 -0
  215. data/vendor/kreuzberg/stopwords/lv_stopwords.json +163 -0
  216. data/vendor/kreuzberg/stopwords/ml_stopwords.json +1 -0
  217. data/vendor/kreuzberg/stopwords/mr_stopwords.json +101 -0
  218. data/vendor/kreuzberg/stopwords/ms_stopwords.json +477 -0
  219. data/vendor/kreuzberg/stopwords/ne_stopwords.json +490 -0
  220. data/vendor/kreuzberg/stopwords/nl_stopwords.json +415 -0
  221. data/vendor/kreuzberg/stopwords/no_stopwords.json +223 -0
  222. data/vendor/kreuzberg/stopwords/pl_stopwords.json +331 -0
  223. data/vendor/kreuzberg/stopwords/pt_stopwords.json +562 -0
  224. data/vendor/kreuzberg/stopwords/ro_stopwords.json +436 -0
  225. data/vendor/kreuzberg/stopwords/ru_stopwords.json +561 -0
  226. data/vendor/kreuzberg/stopwords/si_stopwords.json +193 -0
  227. data/vendor/kreuzberg/stopwords/sk_stopwords.json +420 -0
  228. data/vendor/kreuzberg/stopwords/sl_stopwords.json +448 -0
  229. data/vendor/kreuzberg/stopwords/so_stopwords.json +32 -0
  230. data/vendor/kreuzberg/stopwords/st_stopwords.json +33 -0
  231. data/vendor/kreuzberg/stopwords/sv_stopwords.json +420 -0
  232. data/vendor/kreuzberg/stopwords/sw_stopwords.json +76 -0
  233. data/vendor/kreuzberg/stopwords/ta_stopwords.json +129 -0
  234. data/vendor/kreuzberg/stopwords/te_stopwords.json +54 -0
  235. data/vendor/kreuzberg/stopwords/th_stopwords.json +118 -0
  236. data/vendor/kreuzberg/stopwords/tl_stopwords.json +149 -0
  237. data/vendor/kreuzberg/stopwords/tr_stopwords.json +506 -0
  238. data/vendor/kreuzberg/stopwords/uk_stopwords.json +75 -0
  239. data/vendor/kreuzberg/stopwords/ur_stopwords.json +519 -0
  240. data/vendor/kreuzberg/stopwords/vi_stopwords.json +647 -0
  241. data/vendor/kreuzberg/stopwords/yo_stopwords.json +62 -0
  242. data/vendor/kreuzberg/stopwords/zh_stopwords.json +796 -0
  243. data/vendor/kreuzberg/stopwords/zu_stopwords.json +31 -0
  244. data/vendor/kreuzberg/tests/api_extract_multipart.rs +52 -0
  245. data/vendor/kreuzberg/tests/api_tests.rs +966 -0
  246. data/vendor/kreuzberg/tests/archive_integration.rs +543 -0
  247. data/vendor/kreuzberg/tests/batch_orchestration.rs +556 -0
  248. data/vendor/kreuzberg/tests/batch_processing.rs +316 -0
  249. data/vendor/kreuzberg/tests/bibtex_parity_test.rs +421 -0
  250. data/vendor/kreuzberg/tests/concurrency_stress.rs +525 -0
  251. data/vendor/kreuzberg/tests/config_features.rs +598 -0
  252. data/vendor/kreuzberg/tests/config_loading_tests.rs +415 -0
  253. data/vendor/kreuzberg/tests/core_integration.rs +510 -0
  254. data/vendor/kreuzberg/tests/csv_integration.rs +414 -0
  255. data/vendor/kreuzberg/tests/docbook_extractor_tests.rs +498 -0
  256. data/vendor/kreuzberg/tests/docx_metadata_extraction_test.rs +122 -0
  257. data/vendor/kreuzberg/tests/docx_vs_pandoc_comparison.rs +370 -0
  258. data/vendor/kreuzberg/tests/email_integration.rs +325 -0
  259. data/vendor/kreuzberg/tests/epub_native_extractor_tests.rs +275 -0
  260. data/vendor/kreuzberg/tests/error_handling.rs +393 -0
  261. data/vendor/kreuzberg/tests/fictionbook_extractor_tests.rs +228 -0
  262. data/vendor/kreuzberg/tests/format_integration.rs +159 -0
  263. data/vendor/kreuzberg/tests/helpers/mod.rs +142 -0
  264. data/vendor/kreuzberg/tests/html_table_test.rs +551 -0
  265. data/vendor/kreuzberg/tests/image_integration.rs +253 -0
  266. data/vendor/kreuzberg/tests/instrumentation_test.rs +139 -0
  267. data/vendor/kreuzberg/tests/jats_extractor_tests.rs +639 -0
  268. data/vendor/kreuzberg/tests/jupyter_extractor_tests.rs +704 -0
  269. data/vendor/kreuzberg/tests/keywords_integration.rs +479 -0
  270. data/vendor/kreuzberg/tests/keywords_quality.rs +509 -0
  271. data/vendor/kreuzberg/tests/latex_extractor_tests.rs +496 -0
  272. data/vendor/kreuzberg/tests/markdown_extractor_tests.rs +490 -0
  273. data/vendor/kreuzberg/tests/mime_detection.rs +428 -0
  274. data/vendor/kreuzberg/tests/ocr_configuration.rs +510 -0
  275. data/vendor/kreuzberg/tests/ocr_errors.rs +676 -0
  276. data/vendor/kreuzberg/tests/ocr_quality.rs +627 -0
  277. data/vendor/kreuzberg/tests/ocr_stress.rs +469 -0
  278. data/vendor/kreuzberg/tests/odt_extractor_tests.rs +695 -0
  279. data/vendor/kreuzberg/tests/opml_extractor_tests.rs +616 -0
  280. data/vendor/kreuzberg/tests/orgmode_extractor_tests.rs +822 -0
  281. data/vendor/kreuzberg/tests/pdf_integration.rs +43 -0
  282. data/vendor/kreuzberg/tests/pipeline_integration.rs +1411 -0
  283. data/vendor/kreuzberg/tests/plugin_ocr_backend_test.rs +771 -0
  284. data/vendor/kreuzberg/tests/plugin_postprocessor_test.rs +560 -0
  285. data/vendor/kreuzberg/tests/plugin_system.rs +921 -0
  286. data/vendor/kreuzberg/tests/plugin_validator_test.rs +783 -0
  287. data/vendor/kreuzberg/tests/registry_integration_tests.rs +586 -0
  288. data/vendor/kreuzberg/tests/rst_extractor_tests.rs +692 -0
  289. data/vendor/kreuzberg/tests/rtf_extractor_tests.rs +776 -0
  290. data/vendor/kreuzberg/tests/security_validation.rs +415 -0
  291. data/vendor/kreuzberg/tests/stopwords_integration_test.rs +888 -0
  292. data/vendor/kreuzberg/tests/test_fastembed.rs +609 -0
  293. data/vendor/kreuzberg/tests/typst_behavioral_tests.rs +1259 -0
  294. data/vendor/kreuzberg/tests/typst_extractor_tests.rs +647 -0
  295. data/vendor/kreuzberg/tests/xlsx_metadata_extraction_test.rs +87 -0
  296. data/vendor/rb-sys/.cargo-ok +1 -0
  297. data/vendor/rb-sys/.cargo_vcs_info.json +6 -0
  298. data/vendor/rb-sys/Cargo.lock +393 -0
  299. data/vendor/rb-sys/Cargo.toml +70 -0
  300. data/vendor/rb-sys/Cargo.toml.orig +57 -0
  301. data/vendor/rb-sys/LICENSE-APACHE +190 -0
  302. data/vendor/rb-sys/LICENSE-MIT +21 -0
  303. data/vendor/rb-sys/bin/release.sh +21 -0
  304. data/vendor/rb-sys/build/features.rs +108 -0
  305. data/vendor/rb-sys/build/main.rs +246 -0
  306. data/vendor/rb-sys/build/stable_api_config.rs +153 -0
  307. data/vendor/rb-sys/build/version.rs +48 -0
  308. data/vendor/rb-sys/readme.md +36 -0
  309. data/vendor/rb-sys/src/bindings.rs +21 -0
  310. data/vendor/rb-sys/src/hidden.rs +11 -0
  311. data/vendor/rb-sys/src/lib.rs +34 -0
  312. data/vendor/rb-sys/src/macros.rs +371 -0
  313. data/vendor/rb-sys/src/memory.rs +53 -0
  314. data/vendor/rb-sys/src/ruby_abi_version.rs +38 -0
  315. data/vendor/rb-sys/src/special_consts.rs +31 -0
  316. data/vendor/rb-sys/src/stable_api/compiled.c +179 -0
  317. data/vendor/rb-sys/src/stable_api/compiled.rs +257 -0
  318. data/vendor/rb-sys/src/stable_api/ruby_2_6.rs +316 -0
  319. data/vendor/rb-sys/src/stable_api/ruby_2_7.rs +316 -0
  320. data/vendor/rb-sys/src/stable_api/ruby_3_0.rs +324 -0
  321. data/vendor/rb-sys/src/stable_api/ruby_3_1.rs +317 -0
  322. data/vendor/rb-sys/src/stable_api/ruby_3_2.rs +315 -0
  323. data/vendor/rb-sys/src/stable_api/ruby_3_3.rs +326 -0
  324. data/vendor/rb-sys/src/stable_api/ruby_3_4.rs +327 -0
  325. data/vendor/rb-sys/src/stable_api.rs +261 -0
  326. data/vendor/rb-sys/src/symbol.rs +31 -0
  327. data/vendor/rb-sys/src/tracking_allocator.rs +332 -0
  328. data/vendor/rb-sys/src/utils.rs +89 -0
  329. data/vendor/rb-sys/src/value_type.rs +7 -0
  330. metadata +536 -0
@@ -0,0 +1,153 @@
1
+ use rb_sys_build::{RbConfig, RubyEngine};
2
+
3
+ use crate::{
4
+ features::is_env_variable_defined,
5
+ version::{MIN_SUPPORTED_STABLE_VERSION, Version},
6
+ };
7
+ use std::{convert::TryFrom, error::Error, path::Path};
8
+
9
+ pub fn setup(rb_config: &RbConfig) -> Result<(), Box<dyn Error>> {
10
+ let ruby_version = Version::current(rb_config);
11
+ let ruby_engine = rb_config.ruby_engine();
12
+ let strategy = Strategy::try_from((ruby_engine, ruby_version))?;
13
+
14
+ strategy.apply()?;
15
+
16
+ Ok(())
17
+ }
18
+
19
+ #[derive(Debug)]
20
+ enum Strategy {
21
+ RustOnly(Version),
22
+ CompiledOnly,
23
+ RustThenCompiled(Version),
24
+ Testing(Version),
25
+ }
26
+
27
+ impl TryFrom<(RubyEngine, Version)> for Strategy {
28
+ type Error = Box<dyn Error>;
29
+
30
+ fn try_from((engine, current_ruby_version): (RubyEngine, Version)) -> Result<Self, Self::Error> {
31
+ let mut strategy = None;
32
+
33
+ match engine {
34
+ RubyEngine::TruffleRuby => {
35
+ return Ok(Strategy::CompiledOnly);
36
+ }
37
+ RubyEngine::JRuby => {
38
+ return Err("JRuby is not supported".into());
39
+ }
40
+ RubyEngine::Mri => {}
41
+ }
42
+
43
+ if current_ruby_version.is_stable() {
44
+ strategy = Some(Strategy::RustOnly(current_ruby_version));
45
+ } else {
46
+ maybe_warn_old_ruby_version(current_ruby_version);
47
+ }
48
+
49
+ if is_fallback_enabled() {
50
+ strategy = Some(Strategy::RustThenCompiled(current_ruby_version));
51
+ }
52
+
53
+ if is_testing() {
54
+ strategy = Some(Strategy::Testing(current_ruby_version));
55
+ }
56
+
57
+ if is_force_enabled() {
58
+ strategy = Some(Strategy::CompiledOnly);
59
+ }
60
+
61
+ if let Some(strategy) = strategy {
62
+ return Ok(strategy);
63
+ }
64
+
65
+ Err("Stable API is needed but could not find a candidate. Try enabling the `stable-api-compiled-fallback` feature in rb-sys.".into())
66
+ }
67
+ }
68
+
69
+ impl Strategy {
70
+ fn apply(self) -> Result<(), Box<dyn Error>> {
71
+ println!("cargo:rustc-check-cfg=cfg(stable_api_include_rust_impl)");
72
+ println!("cargo:rustc-check-cfg=cfg(stable_api_enable_compiled_mod)");
73
+ println!("cargo:rustc-check-cfg=cfg(stable_api_export_compiled_as_api)");
74
+ println!("cargo:rustc-check-cfg=cfg(stable_api_has_rust_impl)");
75
+ match self {
76
+ Strategy::RustOnly(current_ruby_version) => {
77
+ if current_ruby_version.is_stable() {
78
+ println!("cargo:rustc-cfg=stable_api_include_rust_impl");
79
+ } else {
80
+ return Err(format!("A stable Ruby API is needed but could not find a candidate. If you are using a stable version of Ruby, try upgrading rb-sys. Otherwise if you are testing against ruby-head or Ruby < {}, enable the `stable-api-compiled-fallback` feature in rb-sys.", MIN_SUPPORTED_STABLE_VERSION).into());
81
+ }
82
+ }
83
+ Strategy::CompiledOnly => {
84
+ compile()?;
85
+ println!("cargo:rustc-cfg=stable_api_enable_compiled_mod");
86
+ println!("cargo:rustc-cfg=stable_api_export_compiled_as_api");
87
+ }
88
+ Strategy::RustThenCompiled(current_ruby_version) => {
89
+ if current_ruby_version.is_stable() {
90
+ println!("cargo:rustc-cfg=stable_api_has_rust_impl");
91
+ println!("cargo:rustc-cfg=stable_api_include_rust_impl");
92
+ } else {
93
+ compile()?;
94
+ println!("cargo:rustc-cfg=stable_api_enable_compiled_mod");
95
+ println!("cargo:rustc-cfg=stable_api_export_compiled_as_api");
96
+ }
97
+ }
98
+ Strategy::Testing(current_ruby_version) => {
99
+ compile()?;
100
+
101
+ println!("cargo:rustc-cfg=stable_api_enable_compiled_mod");
102
+
103
+ if current_ruby_version.is_stable() {
104
+ println!("cargo:rustc-cfg=stable_api_include_rust_impl");
105
+ } else {
106
+ println!("cargo:rustc-cfg=stable_api_export_compiled_as_api");
107
+ }
108
+ }
109
+ };
110
+
111
+ Ok(())
112
+ }
113
+ }
114
+
115
+ fn is_fallback_enabled() -> bool {
116
+ println!("cargo:rerun-if-env-changed=RB_SYS_STABLE_API_COMPILED_FALLBACK");
117
+
118
+ is_env_variable_defined("CARGO_FEATURE_STABLE_API_COMPILED_FALLBACK")
119
+ || cfg!(rb_sys_use_stable_api_compiled_fallback)
120
+ || is_env_variable_defined("RB_SYS_STABLE_API_COMPILED_FALLBACK")
121
+ }
122
+
123
+ fn is_force_enabled() -> bool {
124
+ println!("cargo:rerun-if-env-changed=RB_SYS_STABLE_API_COMPILED_FORCE");
125
+
126
+ is_env_variable_defined("CARGO_FEATURE_STABLE_API_COMPILED_FORCE")
127
+ || cfg!(rb_sys_force_stable_api_compiled)
128
+ || is_env_variable_defined("RB_SYS_STABLE_API_COMPILED_FORCE")
129
+ }
130
+
131
+ fn is_testing() -> bool {
132
+ is_env_variable_defined("CARGO_FEATURE_STABLE_API_COMPILED_TESTING")
133
+ }
134
+
135
+ fn maybe_warn_old_ruby_version(current_ruby_version: Version) {
136
+ if current_ruby_version < MIN_SUPPORTED_STABLE_VERSION {
137
+ println!(
138
+ "cargo:warning=Support for Ruby {} will be removed in a future release.",
139
+ current_ruby_version
140
+ );
141
+ }
142
+ }
143
+
144
+ fn compile() -> Result<(), Box<dyn Error>> {
145
+ eprintln!("INFO: Compiling the stable API compiled module");
146
+ let mut build = rb_sys_build::cc::Build::new();
147
+ let crate_dir = Path::new(env!("CARGO_MANIFEST_DIR"));
148
+ let path = crate_dir.join("src").join("stable_api").join("compiled.c");
149
+ eprintln!("cargo:rerun-if-changed={}", path.display());
150
+
151
+ build.file(path);
152
+ build.try_compile("compiled")
153
+ }
@@ -0,0 +1,48 @@
1
+ use crate::RbConfig;
2
+
3
+ #[allow(dead_code)]
4
+ pub const LATEST_STABLE_VERSION: Version = Version::new(3, 4);
5
+ #[allow(dead_code)]
6
+ pub const MIN_SUPPORTED_STABLE_VERSION: Version = Version::new(2, 6);
7
+
8
+ #[derive(Debug, PartialEq, Eq, PartialOrd, Clone, Copy)]
9
+ pub struct Version(u32, u32);
10
+
11
+ impl Version {
12
+ pub const fn new(major: u32, minor: u32) -> Self {
13
+ Self(major, minor)
14
+ }
15
+
16
+ pub fn major(&self) -> u32 {
17
+ self.0
18
+ }
19
+
20
+ pub fn minor(&self) -> u32 {
21
+ self.1
22
+ }
23
+
24
+ pub fn current(rbconfig: &RbConfig) -> Version {
25
+ match (rbconfig.get("MAJOR"), rbconfig.get("MINOR")) {
26
+ (Some(major), Some(minor)) => Version::new(major.parse::<u32>().unwrap(), minor.parse::<u32>().unwrap()),
27
+ _ => {
28
+ // Try to parse out the first 3 components of the version string (for truffleruby)
29
+ let version_string = rbconfig.get("ruby_version").expect("ruby_version");
30
+ let mut parts = version_string.split('.').map(|s| s.parse::<u32>());
31
+ let major = parts.next().expect("major").unwrap();
32
+ let minor = parts.next().expect("minor").unwrap();
33
+ Version::new(major, minor)
34
+ }
35
+ }
36
+ }
37
+
38
+ #[allow(dead_code)]
39
+ pub fn is_stable(&self) -> bool {
40
+ *self >= MIN_SUPPORTED_STABLE_VERSION && *self <= LATEST_STABLE_VERSION
41
+ }
42
+ }
43
+
44
+ impl std::fmt::Display for Version {
45
+ fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
46
+ write!(f, "{}.{}", self.0, self.1)
47
+ }
48
+ }
@@ -0,0 +1,36 @@
1
+ # rb-sys
2
+
3
+ [![Join the discussion](https://img.shields.io/badge/slack-chat-blue.svg)](https://join.slack.com/t/oxidize-rb/shared_invite/zt-16zv5tqte-Vi7WfzxCesdo2TqF_RYBCw)
4
+
5
+ Autogenerated Rust bindings for Ruby. Uses the [`rust-bindgen`](https://github.com/rust-lang/rust-bindgen) crate to
6
+ generate bindings from the `ruby.h` header.
7
+
8
+ ## Notice
9
+
10
+ This is a very low-level library. If you are looking to write a gem in Rust, you should probably use
11
+ https://github.com/matsadler/magnus crate, with the `rb-sys-interop` feature.
12
+
13
+ If you actually _need_ raw/unsafe bindings to libruby, then this crate is for you!
14
+
15
+ ## Documentation
16
+
17
+ For comprehensive documentation, please refer to the [Ruby on Rust Book](https://oxidize-rb.github.io/rb-sys/), which
18
+ includes:
19
+
20
+ - [API Reference for rb-sys Features](https://oxidize-rb.github.io/rb-sys/api-reference/rb-sys-features.html)
21
+ - [Usage examples and tutorials](https://oxidize-rb.github.io/rb-sys/introduction.html)
22
+ - [Memory management guidance](https://oxidize-rb.github.io/rb-sys/memory-management.html)
23
+
24
+ ## License
25
+
26
+ Licensed under either of
27
+
28
+ - Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
29
+ - MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
30
+
31
+ at your option.
32
+
33
+ ### Contribution
34
+
35
+ Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as
36
+ defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
@@ -0,0 +1,21 @@
1
+ //! Raw bindings to libruby, generated by bindgen.
2
+ //!
3
+ //! This module contains the raw bindings to libruby, generated by bindgen.
4
+
5
+ #![allow(non_upper_case_globals)]
6
+ #![allow(non_camel_case_types)]
7
+ #![allow(non_snake_case)]
8
+ #![allow(unknown_lints)]
9
+ #![allow(deref_nullptr)]
10
+ #![warn(unknown_lints)]
11
+ #![allow(clippy::all)]
12
+ #![allow(rustdoc::broken_intra_doc_links)]
13
+ #![allow(rustdoc::invalid_rust_codeblocks)]
14
+ #![allow(rustdoc::invalid_html_tags)]
15
+ #![allow(deprecated)]
16
+ #![allow(dead_code)]
17
+
18
+ include!(env!("RB_SYS_BINDINGS_PATH"));
19
+
20
+ pub use uncategorized::*;
21
+ pub use unstable::*;
@@ -0,0 +1,11 @@
1
+ //! Hidden symbols from Ruby that we need to link to, not exposed to users.
2
+ //!
3
+ //! Note: Using these symbols is an absolute last resort. Try to use the
4
+ //! official Ruby C API if at all possible.
5
+
6
+ extern "C" {
7
+ /// A pointer to the current Ruby VM.
8
+ #[cfg(all(ruby_gt_2_4, ruby_lte_3_2))]
9
+ #[cfg(ruby_engine = "mri")]
10
+ pub(crate) static ruby_current_vm_ptr: *mut crate::ruby_vm_t;
11
+ }
@@ -0,0 +1,34 @@
1
+ #![allow(rustdoc::bare_urls)]
2
+ #![doc = include_str!("../readme.md")]
3
+
4
+ pub mod bindings;
5
+ #[cfg(feature = "stable-api")]
6
+ pub mod macros;
7
+ pub mod memory;
8
+ pub mod special_consts;
9
+ #[cfg(feature = "stable-api")]
10
+ pub mod stable_api;
11
+ pub mod symbol;
12
+ pub mod tracking_allocator;
13
+ pub mod value_type;
14
+
15
+ mod hidden;
16
+ mod ruby_abi_version;
17
+ mod utils;
18
+
19
+ pub use bindings::*;
20
+ #[cfg(feature = "stable-api")]
21
+ pub use macros::*;
22
+ pub use ruby_abi_version::*;
23
+ pub use special_consts::*;
24
+ #[cfg(feature = "stable-api")]
25
+ pub use stable_api::StableApiDefinition;
26
+ pub use value_type::*;
27
+
28
+ #[deprecated(since = "0.9.79", note = "Use `VALUE` instead")]
29
+ pub type Value = VALUE;
30
+ #[deprecated(since = "0.9.79", note = "Use `VALUE` instead")]
31
+ pub type RubyValue = VALUE;
32
+
33
+ #[cfg(use_global_allocator)]
34
+ set_global_tracking_allocator!();
@@ -0,0 +1,371 @@
1
+ //! Implementation of Ruby macros.
2
+ //!
3
+ //! Since macros are rely on the C preprocessor, or defined as `inline` C
4
+ //! functions, they are not available when linking libruby. In order to use the
5
+ //! libruby macros from Rust, `rb-sys` implements them using the following
6
+ //! strategies:
7
+ //!
8
+ //! 1. For stable versions of Ruby, the macros are implemented as Rust functions
9
+ //! 2. For ruby-head, the macros are implemented as C functions that are linked
10
+ //! into the crate.
11
+
12
+ #![allow(rustdoc::broken_intra_doc_links)]
13
+ #![allow(non_upper_case_globals)]
14
+ #![allow(non_snake_case)]
15
+
16
+ use crate::StableApiDefinition;
17
+ use crate::VALUE;
18
+ use crate::rb_data_type_t;
19
+ use crate::ruby_value_type;
20
+ use crate::stable_api::get_default as api;
21
+ use std::ffi::c_void;
22
+ use std::os::raw::{c_char, c_long};
23
+
24
+ /// Emulates Ruby's "if" statement.
25
+ ///
26
+ /// - @param[in] obj An arbitrary ruby object.
27
+ /// - @retval false `obj` is either ::RUBY_Qfalse or ::RUBY_Qnil.
28
+ /// - @retval true Anything else.
29
+ ///
30
+ /// ```
31
+ /// use rb_sys::special_consts::*;
32
+ ///
33
+ /// assert!(!TEST(Qfalse));
34
+ /// assert!(!TEST(Qnil));
35
+ /// assert!(TEST(Qtrue));
36
+ /// ```
37
+ #[inline]
38
+ pub fn TEST<T: Into<VALUE>>(obj: T) -> bool {
39
+ api().rb_test(obj.into())
40
+ }
41
+
42
+ /// Checks if the given object is nil.
43
+ ///
44
+ /// - @param[in] obj An arbitrary ruby object.
45
+ /// - @retval true `obj` is ::RUBY_Qnil.
46
+ /// - @retval false Anything else.
47
+ ///
48
+ /// ### Example
49
+ ///
50
+ /// ```
51
+ /// use rb_sys::special_consts::*;
52
+ ///
53
+ /// assert!(NIL_P(Qnil));
54
+ /// assert!(!NIL_P(Qtrue));
55
+ /// ```
56
+ #[inline]
57
+ pub fn NIL_P<T: Into<VALUE>>(obj: T) -> bool {
58
+ api().nil_p(obj.into())
59
+ }
60
+
61
+ /// Checks if the given object is a so-called Fixnum.
62
+ ///
63
+ /// - @param[in] obj An arbitrary ruby object.
64
+ /// - @retval true `obj` is a Fixnum.
65
+ /// - @retval false Anything else.
66
+ /// - @note Fixnum was a thing in the 20th century, but it is rather an implementation detail today.
67
+ #[inline]
68
+ pub fn FIXNUM_P<T: Into<VALUE>>(obj: T) -> bool {
69
+ api().fixnum_p(obj.into())
70
+ }
71
+
72
+ /// Checks if the given object is a static symbol.
73
+ ///
74
+ /// - @param[in] obj An arbitrary ruby object.
75
+ /// - @retval true `obj` is a static symbol
76
+ /// - @retval false Anything else.
77
+ /// - @see RB_DYNAMIC_SYM_P()
78
+ /// - @see RB_SYMBOL_P()
79
+ /// - @note These days there are static and dynamic symbols, just like we once had Fixnum/Bignum back in the old days.
80
+ #[inline]
81
+ pub fn STATIC_SYM_P<T: Into<VALUE>>(obj: T) -> bool {
82
+ api().static_sym_p(obj.into())
83
+ }
84
+
85
+ /// Get the backend storage of a Ruby array.
86
+ ///
87
+ /// ### Safety
88
+ ///
89
+ /// This function is unsafe because it dereferences a raw pointer and returns
90
+ /// raw pointers to Ruby memory. The caller must ensure that the pointer stays live
91
+ /// for the duration of usage the the underlying array (by either GC marking or
92
+ /// keeping the RArray on the stack).
93
+ ///
94
+ /// - @param[in] a An object of ::RArray.
95
+ /// - @return Its backend storage.
96
+ #[inline]
97
+ pub unsafe fn RARRAY_CONST_PTR<T: Into<VALUE>>(obj: T) -> *const VALUE {
98
+ api().rarray_const_ptr(obj.into())
99
+ }
100
+
101
+ /// Get the length of a Ruby array.
102
+ ///
103
+ /// ### Safety
104
+ ///
105
+ /// This function is unsafe because it dereferences a raw pointer in order to
106
+ /// access internal Ruby memory.
107
+ ///
108
+ /// - @param[in] a An object of ::RArray.
109
+ /// - @return Its length.
110
+ #[inline]
111
+ pub unsafe fn RARRAY_LEN<T: Into<VALUE>>(obj: T) -> c_long {
112
+ api().rarray_len(obj.into())
113
+ }
114
+
115
+ /// Get the length of a Ruby string.
116
+ ///
117
+ /// ### Safety
118
+ ///
119
+ /// This function is unsafe because it dereferences a raw pointer in order to
120
+ /// access internal Ruby memory.
121
+ ///
122
+ /// - @param[in] a An object of ::RString.
123
+ /// - @return Its length.
124
+ #[inline]
125
+ pub unsafe fn RSTRING_LEN<T: Into<VALUE>>(obj: T) -> c_long {
126
+ api().rstring_len(obj.into())
127
+ }
128
+
129
+ /// Get the backend storage of a Ruby string.
130
+ ///
131
+ /// ### Safety
132
+ ///
133
+ /// This function is unsafe because it dereferences a raw pointer and returns
134
+ /// raw pointers to Ruby memory.
135
+ ///
136
+ /// - @param[in] a An object of ::RString.
137
+ /// - @return Its backend storage
138
+ #[inline]
139
+ pub unsafe fn RSTRING_PTR<T: Into<VALUE>>(obj: T) -> *const c_char {
140
+ api().rstring_ptr(obj.into())
141
+ }
142
+
143
+ /// Checks if the given object is a so-called Flonum.
144
+ ///
145
+ /// @param[in] obj An arbitrary ruby object.
146
+ /// @retval true `obj` is a Flonum.
147
+ /// @retval false Anything else.
148
+ /// @see RB_FLOAT_TYPE_P()
149
+ /// @note These days there are Flonums and non-Flonum floats, just like we
150
+ /// once had Fixnum/Bignum back in the old days.
151
+ #[inline]
152
+ pub fn FLONUM_P<T: Into<VALUE>>(#[allow(unused)] obj: T) -> bool {
153
+ api().flonum_p(obj.into())
154
+ }
155
+
156
+ /// Checks if the given object is an immediate i.e. an object which has no
157
+ /// corresponding storage inside of the object space.
158
+ ///
159
+ /// @param[in] obj An arbitrary ruby object.
160
+ /// @retval true `obj` is a Flonum.
161
+ /// @retval false Anything else.
162
+ /// @see RB_FLOAT_TYPE_P()
163
+ /// @note The concept of "immediate" is purely C specific.
164
+ #[inline]
165
+ pub fn IMMEDIATE_P<T: Into<VALUE>>(obj: T) -> bool {
166
+ api().immediate_p(obj.into())
167
+ }
168
+
169
+ /// Checks if the given object is of enum ::ruby_special_consts.
170
+ ///
171
+ /// @param[in] obj An arbitrary ruby object.
172
+ /// @retval true `obj` is a special constant.
173
+ /// @retval false Anything else.
174
+ ///
175
+ /// ### Example
176
+ ///
177
+ /// ```
178
+ /// use rb_sys::special_consts::*;
179
+ ///
180
+ /// assert!(SPECIAL_CONST_P(Qnil));
181
+ /// assert!(SPECIAL_CONST_P(Qtrue));
182
+ /// assert!(SPECIAL_CONST_P(Qfalse));
183
+ /// ```
184
+ #[inline]
185
+ pub fn SPECIAL_CONST_P<T: Into<VALUE>>(obj: T) -> bool {
186
+ api().special_const_p(obj.into())
187
+ }
188
+
189
+ /// Queries the type of the object.
190
+ ///
191
+ /// @param[in] obj Object in question.
192
+ /// @pre `obj` must not be a special constant.
193
+ /// @return The type of `obj`.
194
+ ///
195
+ /// # Safety
196
+ /// This function is unsafe because it could dereference a raw pointer when
197
+ /// attemping to access the underlying [`RBasic`] struct.
198
+ #[inline]
199
+ pub unsafe fn RB_BUILTIN_TYPE(obj: VALUE) -> ruby_value_type {
200
+ api().builtin_type(obj)
201
+ }
202
+
203
+ /// Queries if the object is an instance of ::rb_cInteger.
204
+ ///
205
+ /// @param[in] obj Object in question.
206
+ /// @retval true It is.
207
+ /// @retval false It isn't.
208
+ ///
209
+ /// # Safety
210
+ /// This function is unsafe because it could dereference a raw pointer when
211
+ /// attemping to access the underlying [`RBasic`] struct.
212
+ #[inline]
213
+ pub unsafe fn RB_INTEGER_TYPE_P(obj: VALUE) -> bool {
214
+ api().integer_type_p(obj)
215
+ }
216
+
217
+ /// Queries if the object is a dynamic symbol.
218
+ ///
219
+ /// @param[in] obj Object in question.
220
+ /// @retval true It is.
221
+ /// @retval false It isn't.
222
+ ///
223
+ /// # Safety
224
+ /// This function is unsafe because it could dereference a raw pointer when
225
+ /// attemping to access the underlying [`RBasic`] struct.
226
+ #[inline]
227
+ pub unsafe fn RB_DYNAMIC_SYM_P(obj: VALUE) -> bool {
228
+ api().dynamic_sym_p(obj)
229
+ }
230
+
231
+ /// Queries if the object is an instance of ::rb_cSymbol.
232
+ ///
233
+ /// @param[in] obj Object in question.
234
+ /// @retval true It is.
235
+ /// @retval false It isn't.
236
+ ///
237
+ /// # Safety
238
+ /// This function is unsafe because it could dereference a raw pointer when
239
+ /// attemping to access the underlying [`RBasic`] struct.
240
+ #[inline]
241
+ pub unsafe fn RB_SYMBOL_P(obj: VALUE) -> bool {
242
+ api().symbol_p(obj)
243
+ }
244
+
245
+ /// Identical to RB_BUILTIN_TYPE(), except it can also accept special constants.
246
+ ///
247
+ /// @param[in] obj Object in question.
248
+ /// @return The type of `obj`.
249
+ ///
250
+ /// # Safety
251
+ /// This function is unsafe because it could dereference a raw pointer when
252
+ /// attemping to access the underlying [`RBasic`] struct.
253
+ #[inline]
254
+ pub unsafe fn RB_TYPE(value: VALUE) -> ruby_value_type {
255
+ api().rb_type(value)
256
+ }
257
+
258
+ /// Queries if the given object is of given type.
259
+ ///
260
+ /// @param[in] obj An object.
261
+ /// @param[in] t A type.
262
+ /// @retval true `obj` is of type `t`.
263
+ /// @retval false Otherwise.
264
+ ///
265
+ /// # Safety
266
+ /// This function is unsafe because it could dereference a raw pointer when
267
+ /// attemping to access the underlying [`RBasic`] struct.
268
+ #[inline]
269
+ #[cfg(ruby_engine = "mri")] // truffleruby provides its own implementation
270
+ pub unsafe fn RB_TYPE_P(obj: VALUE, ty: ruby_value_type) -> bool {
271
+ api().type_p(obj, ty)
272
+ }
273
+
274
+ /// Queries if the object is an instance of ::rb_cFloat.
275
+ ///
276
+ /// @param[in] obj Object in question.
277
+ /// @retval true It is.
278
+ /// @retval false It isn't.
279
+ ///
280
+ /// # Safety
281
+ /// This function is unsafe because it could dereference a raw pointer when
282
+ /// attemping to access the underlying [`RBasic`] struct.
283
+ #[inline]
284
+ pub unsafe fn RB_FLOAT_TYPE_P(obj: VALUE) -> bool {
285
+ api().float_type_p(obj)
286
+ }
287
+
288
+ /// Checks if the given object is an RTypedData.
289
+ ///
290
+ /// @param[in] obj Object in question.
291
+ /// @retval true It is an RTypedData.
292
+ /// @retval false It isn't an RTypedData.
293
+ ///
294
+ /// # Safety
295
+ /// This function is unsafe because it could dereference a raw pointer when
296
+ /// accessing the underlying data structure.
297
+ #[inline]
298
+ pub unsafe fn RTYPEDDATA_P(obj: VALUE) -> bool {
299
+ api().rtypeddata_p(obj)
300
+ }
301
+
302
+ /// Checks if the given RTypedData is embedded.
303
+ ///
304
+ /// @param[in] obj An RTypedData object.
305
+ /// @retval true The data is embedded in the object itself.
306
+ /// @retval false The data is stored separately.
307
+ ///
308
+ /// # Safety
309
+ /// This function is unsafe because it could dereference a raw pointer when
310
+ /// accessing the underlying data structure. The caller must ensure the object
311
+ /// is a valid RTypedData.
312
+ #[inline]
313
+ pub unsafe fn RTYPEDDATA_EMBEDDED_P(obj: VALUE) -> bool {
314
+ api().rtypeddata_embedded_p(obj)
315
+ }
316
+
317
+ /// Gets the data type information from an RTypedData object.
318
+ ///
319
+ /// @param[in] obj An RTypedData object.
320
+ /// @return Pointer to the rb_data_type_t structure for this object.
321
+ ///
322
+ /// # Safety
323
+ /// This function is unsafe because it dereferences a raw pointer to get
324
+ /// access to the underlying data type. The caller must ensure the object
325
+ /// is a valid RTypedData.
326
+ #[inline]
327
+ pub unsafe fn RTYPEDDATA_TYPE(obj: VALUE) -> *const rb_data_type_t {
328
+ api().rtypeddata_type(obj)
329
+ }
330
+
331
+ /// Gets the data pointer from an RTypedData object.
332
+ ///
333
+ /// @param[in] obj An RTypedData object.
334
+ /// @return Pointer to the wrapped C struct.
335
+ ///
336
+ /// # Safety
337
+ /// This function is unsafe because it dereferences a raw pointer to get
338
+ /// access to the underlying data. The caller must ensure the object
339
+ /// is a valid RTypedData.
340
+ #[inline]
341
+ pub unsafe fn RTYPEDDATA_GET_DATA(obj: VALUE) -> *mut c_void {
342
+ api().rtypeddata_get_data(obj)
343
+ }
344
+
345
+ /// Checks if the bignum is positive.
346
+ ///
347
+ /// @param[in] b An object of RBignum.
348
+ /// @retval false `b` is less than zero.
349
+ /// @retval true Otherwise.
350
+ ///
351
+ /// # Safety
352
+ /// This function is unsafe because it could dereference a raw pointer when
353
+ /// accessing the underlying bignum structure.
354
+ #[inline]
355
+ pub unsafe fn RBIGNUM_POSITIVE_P(b: VALUE) -> bool {
356
+ api().bignum_positive_p(b)
357
+ }
358
+
359
+ /// Checks if the bignum is negative.
360
+ ///
361
+ /// @param[in] b An object of RBignum.
362
+ /// @retval true `b` is less than zero.
363
+ /// @retval false Otherwise.
364
+ ///
365
+ /// # Safety
366
+ /// This function is unsafe because it could dereference a raw pointer when
367
+ /// accessing the underlying bignum structure.
368
+ #[inline]
369
+ pub unsafe fn RBIGNUM_NEGATIVE_P(b: VALUE) -> bool {
370
+ api().bignum_negative_p(b)
371
+ }