kreuzberg 4.0.0.pre.rc.6 → 4.0.0.rc1

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 (175) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +0 -6
  3. data/.rubocop.yaml +534 -1
  4. data/Gemfile +2 -1
  5. data/Gemfile.lock +11 -11
  6. data/README.md +5 -10
  7. data/examples/async_patterns.rb +0 -1
  8. data/ext/kreuzberg_rb/extconf.rb +0 -10
  9. data/ext/kreuzberg_rb/native/Cargo.toml +15 -23
  10. data/ext/kreuzberg_rb/native/build.rs +2 -0
  11. data/ext/kreuzberg_rb/native/include/ieeefp.h +1 -1
  12. data/ext/kreuzberg_rb/native/include/msvc_compat/strings.h +1 -1
  13. data/ext/kreuzberg_rb/native/include/strings.h +2 -2
  14. data/ext/kreuzberg_rb/native/include/unistd.h +1 -1
  15. data/ext/kreuzberg_rb/native/src/lib.rs +16 -75
  16. data/kreuzberg.gemspec +14 -57
  17. data/lib/kreuzberg/cache_api.rb +0 -1
  18. data/lib/kreuzberg/cli.rb +2 -2
  19. data/lib/kreuzberg/config.rb +2 -9
  20. data/lib/kreuzberg/errors.rb +7 -75
  21. data/lib/kreuzberg/extraction_api.rb +0 -1
  22. data/lib/kreuzberg/setup_lib_path.rb +0 -1
  23. data/lib/kreuzberg/version.rb +1 -1
  24. data/lib/kreuzberg.rb +0 -21
  25. data/pkg/kreuzberg-4.0.0.rc1.gem +0 -0
  26. data/sig/kreuzberg.rbs +3 -55
  27. data/spec/binding/cli_proxy_spec.rb +4 -2
  28. data/spec/binding/cli_spec.rb +11 -12
  29. data/spec/examples.txt +104 -0
  30. data/spec/fixtures/config.yaml +1 -0
  31. data/spec/spec_helper.rb +1 -1
  32. data/vendor/kreuzberg/Cargo.toml +42 -112
  33. data/vendor/kreuzberg/README.md +2 -2
  34. data/vendor/kreuzberg/build.rs +4 -18
  35. data/vendor/kreuzberg/src/bin/profile_extract.rs +455 -0
  36. data/vendor/kreuzberg/src/cache/mod.rs +3 -27
  37. data/vendor/kreuzberg/src/core/batch_mode.rs +0 -60
  38. data/vendor/kreuzberg/src/core/extractor.rs +81 -202
  39. data/vendor/kreuzberg/src/core/io.rs +2 -4
  40. data/vendor/kreuzberg/src/core/mime.rs +12 -2
  41. data/vendor/kreuzberg/src/core/mod.rs +1 -4
  42. data/vendor/kreuzberg/src/core/pipeline.rs +33 -111
  43. data/vendor/kreuzberg/src/embeddings.rs +16 -125
  44. data/vendor/kreuzberg/src/error.rs +1 -1
  45. data/vendor/kreuzberg/src/extraction/docx.rs +1 -1
  46. data/vendor/kreuzberg/src/extraction/image.rs +13 -13
  47. data/vendor/kreuzberg/src/extraction/libreoffice.rs +1 -0
  48. data/vendor/kreuzberg/src/extraction/mod.rs +5 -9
  49. data/vendor/kreuzberg/src/extraction/office_metadata/mod.rs +0 -2
  50. data/vendor/kreuzberg/src/extraction/pandoc/batch.rs +275 -0
  51. data/vendor/kreuzberg/src/extraction/pandoc/mime_types.rs +178 -0
  52. data/vendor/kreuzberg/src/extraction/pandoc/mod.rs +491 -0
  53. data/vendor/kreuzberg/src/extraction/pandoc/server.rs +496 -0
  54. data/vendor/kreuzberg/src/extraction/pandoc/subprocess.rs +1188 -0
  55. data/vendor/kreuzberg/src/extraction/pandoc/version.rs +162 -0
  56. data/vendor/kreuzberg/src/extractors/archive.rs +0 -21
  57. data/vendor/kreuzberg/src/extractors/docx.rs +128 -16
  58. data/vendor/kreuzberg/src/extractors/email.rs +0 -14
  59. data/vendor/kreuzberg/src/extractors/excel.rs +20 -19
  60. data/vendor/kreuzberg/src/extractors/html.rs +154 -137
  61. data/vendor/kreuzberg/src/extractors/image.rs +4 -7
  62. data/vendor/kreuzberg/src/extractors/mod.rs +9 -106
  63. data/vendor/kreuzberg/src/extractors/pandoc.rs +201 -0
  64. data/vendor/kreuzberg/src/extractors/pdf.rs +15 -12
  65. data/vendor/kreuzberg/src/extractors/pptx.rs +3 -17
  66. data/vendor/kreuzberg/src/extractors/structured.rs +0 -14
  67. data/vendor/kreuzberg/src/extractors/text.rs +5 -23
  68. data/vendor/kreuzberg/src/extractors/xml.rs +0 -7
  69. data/vendor/kreuzberg/src/keywords/rake.rs +1 -0
  70. data/vendor/kreuzberg/src/lib.rs +1 -4
  71. data/vendor/kreuzberg/src/mcp/mod.rs +1 -1
  72. data/vendor/kreuzberg/src/mcp/server.rs +3 -5
  73. data/vendor/kreuzberg/src/ocr/processor.rs +2 -18
  74. data/vendor/kreuzberg/src/pdf/error.rs +1 -1
  75. data/vendor/kreuzberg/src/pdf/table.rs +44 -17
  76. data/vendor/kreuzberg/src/pdf/text.rs +3 -0
  77. data/vendor/kreuzberg/src/plugins/extractor.rs +5 -8
  78. data/vendor/kreuzberg/src/plugins/ocr.rs +11 -2
  79. data/vendor/kreuzberg/src/plugins/processor.rs +1 -2
  80. data/vendor/kreuzberg/src/plugins/registry.rs +0 -13
  81. data/vendor/kreuzberg/src/plugins/validator.rs +8 -9
  82. data/vendor/kreuzberg/src/stopwords/mod.rs +2 -2
  83. data/vendor/kreuzberg/src/types.rs +12 -42
  84. data/vendor/kreuzberg/tests/batch_orchestration.rs +5 -19
  85. data/vendor/kreuzberg/tests/batch_processing.rs +3 -15
  86. data/vendor/kreuzberg/tests/chunking_offset_demo.rs +92 -0
  87. data/vendor/kreuzberg/tests/concurrency_stress.rs +1 -17
  88. data/vendor/kreuzberg/tests/config_features.rs +0 -18
  89. data/vendor/kreuzberg/tests/config_loading_tests.rs +39 -15
  90. data/vendor/kreuzberg/tests/core_integration.rs +7 -24
  91. data/vendor/kreuzberg/tests/csv_integration.rs +81 -71
  92. data/vendor/kreuzberg/tests/docx_metadata_extraction_test.rs +25 -23
  93. data/vendor/kreuzberg/tests/pandoc_integration.rs +503 -0
  94. data/vendor/kreuzberg/tests/pipeline_integration.rs +1 -0
  95. data/vendor/kreuzberg/tests/plugin_postprocessor_test.rs +1 -0
  96. data/vendor/kreuzberg/tests/registry_integration_tests.rs +22 -1
  97. data/vendor/kreuzberg/tests/security_validation.rs +1 -12
  98. metadata +25 -90
  99. data/.rubocop.yml +0 -538
  100. data/ext/kreuzberg_rb/native/Cargo.lock +0 -6535
  101. data/lib/kreuzberg/error_context.rb +0 -32
  102. data/vendor/kreuzberg/benches/otel_overhead.rs +0 -48
  103. data/vendor/kreuzberg/src/extraction/markdown.rs +0 -213
  104. data/vendor/kreuzberg/src/extraction/office_metadata/odt_properties.rs +0 -287
  105. data/vendor/kreuzberg/src/extractors/bibtex.rs +0 -469
  106. data/vendor/kreuzberg/src/extractors/docbook.rs +0 -502
  107. data/vendor/kreuzberg/src/extractors/epub.rs +0 -707
  108. data/vendor/kreuzberg/src/extractors/fictionbook.rs +0 -491
  109. data/vendor/kreuzberg/src/extractors/fictionbook.rs.backup2 +0 -738
  110. data/vendor/kreuzberg/src/extractors/jats.rs +0 -1051
  111. data/vendor/kreuzberg/src/extractors/jupyter.rs +0 -367
  112. data/vendor/kreuzberg/src/extractors/latex.rs +0 -652
  113. data/vendor/kreuzberg/src/extractors/markdown.rs +0 -700
  114. data/vendor/kreuzberg/src/extractors/odt.rs +0 -628
  115. data/vendor/kreuzberg/src/extractors/opml.rs +0 -634
  116. data/vendor/kreuzberg/src/extractors/orgmode.rs +0 -528
  117. data/vendor/kreuzberg/src/extractors/rst.rs +0 -576
  118. data/vendor/kreuzberg/src/extractors/rtf.rs +0 -810
  119. data/vendor/kreuzberg/src/extractors/security.rs +0 -484
  120. data/vendor/kreuzberg/src/extractors/security_tests.rs +0 -367
  121. data/vendor/kreuzberg/src/extractors/typst.rs +0 -650
  122. data/vendor/kreuzberg/src/panic_context.rs +0 -154
  123. data/vendor/kreuzberg/tests/api_extract_multipart.rs +0 -52
  124. data/vendor/kreuzberg/tests/bibtex_parity_test.rs +0 -421
  125. data/vendor/kreuzberg/tests/docbook_extractor_tests.rs +0 -498
  126. data/vendor/kreuzberg/tests/docx_vs_pandoc_comparison.rs +0 -370
  127. data/vendor/kreuzberg/tests/epub_native_extractor_tests.rs +0 -275
  128. data/vendor/kreuzberg/tests/fictionbook_extractor_tests.rs +0 -228
  129. data/vendor/kreuzberg/tests/html_table_test.rs +0 -551
  130. data/vendor/kreuzberg/tests/instrumentation_test.rs +0 -139
  131. data/vendor/kreuzberg/tests/jats_extractor_tests.rs +0 -639
  132. data/vendor/kreuzberg/tests/jupyter_extractor_tests.rs +0 -704
  133. data/vendor/kreuzberg/tests/latex_extractor_tests.rs +0 -496
  134. data/vendor/kreuzberg/tests/markdown_extractor_tests.rs +0 -490
  135. data/vendor/kreuzberg/tests/odt_extractor_tests.rs +0 -695
  136. data/vendor/kreuzberg/tests/opml_extractor_tests.rs +0 -616
  137. data/vendor/kreuzberg/tests/orgmode_extractor_tests.rs +0 -822
  138. data/vendor/kreuzberg/tests/rst_extractor_tests.rs +0 -692
  139. data/vendor/kreuzberg/tests/rtf_extractor_tests.rs +0 -776
  140. data/vendor/kreuzberg/tests/typst_behavioral_tests.rs +0 -1259
  141. data/vendor/kreuzberg/tests/typst_extractor_tests.rs +0 -647
  142. data/vendor/rb-sys/.cargo-ok +0 -1
  143. data/vendor/rb-sys/.cargo_vcs_info.json +0 -6
  144. data/vendor/rb-sys/Cargo.lock +0 -393
  145. data/vendor/rb-sys/Cargo.toml +0 -70
  146. data/vendor/rb-sys/Cargo.toml.orig +0 -57
  147. data/vendor/rb-sys/LICENSE-APACHE +0 -190
  148. data/vendor/rb-sys/LICENSE-MIT +0 -21
  149. data/vendor/rb-sys/bin/release.sh +0 -21
  150. data/vendor/rb-sys/build/features.rs +0 -108
  151. data/vendor/rb-sys/build/main.rs +0 -246
  152. data/vendor/rb-sys/build/stable_api_config.rs +0 -153
  153. data/vendor/rb-sys/build/version.rs +0 -48
  154. data/vendor/rb-sys/readme.md +0 -36
  155. data/vendor/rb-sys/src/bindings.rs +0 -21
  156. data/vendor/rb-sys/src/hidden.rs +0 -11
  157. data/vendor/rb-sys/src/lib.rs +0 -34
  158. data/vendor/rb-sys/src/macros.rs +0 -371
  159. data/vendor/rb-sys/src/memory.rs +0 -53
  160. data/vendor/rb-sys/src/ruby_abi_version.rs +0 -38
  161. data/vendor/rb-sys/src/special_consts.rs +0 -31
  162. data/vendor/rb-sys/src/stable_api/compiled.c +0 -179
  163. data/vendor/rb-sys/src/stable_api/compiled.rs +0 -257
  164. data/vendor/rb-sys/src/stable_api/ruby_2_6.rs +0 -316
  165. data/vendor/rb-sys/src/stable_api/ruby_2_7.rs +0 -316
  166. data/vendor/rb-sys/src/stable_api/ruby_3_0.rs +0 -324
  167. data/vendor/rb-sys/src/stable_api/ruby_3_1.rs +0 -317
  168. data/vendor/rb-sys/src/stable_api/ruby_3_2.rs +0 -315
  169. data/vendor/rb-sys/src/stable_api/ruby_3_3.rs +0 -326
  170. data/vendor/rb-sys/src/stable_api/ruby_3_4.rs +0 -327
  171. data/vendor/rb-sys/src/stable_api.rs +0 -261
  172. data/vendor/rb-sys/src/symbol.rs +0 -31
  173. data/vendor/rb-sys/src/tracking_allocator.rs +0 -332
  174. data/vendor/rb-sys/src/utils.rs +0 -89
  175. data/vendor/rb-sys/src/value_type.rs +0 -7
@@ -1,53 +0,0 @@
1
- /// Prevents premature destruction of local objects.
2
- ///
3
- /// Ruby's garbage collector is conservative; it scans the C level machine stack as well.
4
- /// Possible in-use Ruby objects must remain visible on stack, to be properly marked as such.
5
- /// However, Rust's compiler optimizations might remove the references to these objects from
6
- /// the stack when they are not being used directly.
7
- ///
8
- /// Consider the following example:
9
- ///
10
- /// ```ignore
11
- /// use rb_sys::{rb_str_new_cstr, rb_str_cat_cstr, RSTRING_PTR, rb_gc_guard};
12
- ///
13
- /// unsafe {
14
- /// let s = rb_str_new_cstr(" world\0".as_ptr() as _);
15
- /// let sptr = RSTRING_PTR(s);
16
- /// let t = rb_str_new_cstr("hello,\0".as_ptr() as _); // Possible GC invocation
17
- /// let u = rb_str_cat_cstr(t, sptr);
18
- /// rb_gc_guard!(s); // ensure `s` (and thus `sptr`) do not get GC-ed
19
- /// }
20
- /// ```
21
- ///
22
- /// In this example, without the `rb_gc_guard!`, the last use of `s` is before the last use
23
- /// of `sptr`. Compilers could think `s` and `t` are allowed to overlap. That would
24
- /// eliminate `s` from the stack, while `sptr` is still in use. If our GC runs at that
25
- /// very moment, `s` gets swept out, which also destroys `sptr`.
26
- ///
27
- /// In order to prevent this scenario, `rb_gc_guard!` must be placed after the last use
28
- /// of `sptr`. Placing `rb_gc_guard!` before dereferencing `sptr` would be of no use.
29
- ///
30
- /// Using the `rb_gc_guard!` macro has the following advantages:
31
- ///
32
- /// - the intent of the macro use is clear.
33
- ///
34
- /// - `rb_gc_guard!` only affects its call site, without negatively affecting other systems.
35
- ///
36
- /// # Example
37
- /// ```no_run
38
- /// use rb_sys::{rb_utf8_str_new_cstr, rb_gc_guard};
39
- ///
40
- /// let my_string = unsafe { rb_utf8_str_new_cstr("hello world\0".as_ptr() as _) };
41
- /// let _ = rb_gc_guard!(my_string);
42
- /// ```
43
- #[macro_export]
44
- macro_rules! rb_gc_guard {
45
- ($v:expr) => {{
46
- unsafe {
47
- let val: $crate::VALUE = $v;
48
- let rb_gc_guarded_ptr = std::ptr::read_volatile(&&val);
49
- std::arch::asm!("/* {0} */", in(reg) rb_gc_guarded_ptr);
50
- *rb_gc_guarded_ptr
51
- }
52
- }};
53
- }
@@ -1,38 +0,0 @@
1
- //! Helper to define the `ruby_abi_version` function needed for extensions.
2
- //!
3
- //! Since Ruby 3.2, gems are required to define a `ruby_abi_version` function.
4
- //! For C extensions, this is done transparently by including `ruby.h`, but for
5
- //! Rust we have to define it ourselves. This is enabled automatically by when
6
- //! compiling a gem.
7
-
8
- #[doc(hidden)]
9
- #[cfg(not(has_ruby_abi_version))]
10
- pub const __RB_SYS_RUBY_ABI_VERSION: std::os::raw::c_ulonglong = 0;
11
-
12
- #[doc(hidden)]
13
- #[cfg(has_ruby_abi_version)]
14
- pub const __RB_SYS_RUBY_ABI_VERSION: std::os::raw::c_ulonglong = crate::RUBY_ABI_VERSION as _;
15
-
16
- #[doc(hidden)]
17
- #[no_mangle]
18
- #[allow(unused)]
19
- pub extern "C" fn ruby_abi_version() -> std::os::raw::c_ulonglong {
20
- __RB_SYS_RUBY_ABI_VERSION
21
- }
22
-
23
- #[doc(hidden)]
24
- #[no_mangle]
25
- #[allow(unused)]
26
- #[cfg(ruby_engine = "truffleruby")]
27
- pub extern "C" fn rb_tr_abi_version() -> *const std::os::raw::c_char {
28
- crate::TRUFFLERUBY_ABI_VERSION.as_ptr() as *const _
29
- }
30
-
31
- #[deprecated(
32
- since = "0.9.102",
33
- note = "You no longer need to invoke this macro, the `ruby_abi_version` function is defined automatically."
34
- )]
35
- #[macro_export]
36
- macro_rules! ruby_abi_version {
37
- () => {};
38
- }
@@ -1,31 +0,0 @@
1
- #![allow(rustdoc::broken_intra_doc_links)]
2
- #![allow(non_upper_case_globals)]
3
- #![allow(non_snake_case)]
4
-
5
- //! Definitions for Ruby's special constants.
6
- //!
7
- //! Makes it easier to reference important Ruby constants, without having to dig
8
- //! around in bindgen's output.
9
-
10
- use std::ffi::c_long;
11
-
12
- use crate::{VALUE, ruby_special_consts};
13
-
14
- pub const Qfalse: ruby_special_consts = ruby_special_consts::RUBY_Qfalse;
15
- pub const Qtrue: ruby_special_consts = ruby_special_consts::RUBY_Qtrue;
16
- pub const Qnil: ruby_special_consts = ruby_special_consts::RUBY_Qnil;
17
- pub const Qundef: ruby_special_consts = ruby_special_consts::RUBY_Qundef;
18
- pub const IMMEDIATE_MASK: ruby_special_consts = ruby_special_consts::RUBY_IMMEDIATE_MASK;
19
- pub const FIXNUM_FLAG: ruby_special_consts = ruby_special_consts::RUBY_FIXNUM_FLAG;
20
- pub const FIXNUM_MIN: c_long = c_long::MIN / 2;
21
- pub const FIXNUM_MAX: c_long = c_long::MAX / 2;
22
- pub const FLONUM_MASK: ruby_special_consts = ruby_special_consts::RUBY_FLONUM_MASK;
23
- pub const FLONUM_FLAG: ruby_special_consts = ruby_special_consts::RUBY_FLONUM_FLAG;
24
- pub const SYMBOL_FLAG: ruby_special_consts = ruby_special_consts::RUBY_SYMBOL_FLAG;
25
-
26
- #[allow(clippy::from_over_into)]
27
- impl Into<VALUE> for ruby_special_consts {
28
- fn into(self) -> VALUE {
29
- self as VALUE
30
- }
31
- }
@@ -1,179 +0,0 @@
1
- #include "ruby.h"
2
- #include "ruby/ruby.h"
3
- #include "ruby/intern.h"
4
- #include "ruby/version.h"
5
-
6
- // Check that we have Ruby API version macros
7
- #if !defined(RUBY_API_VERSION_MAJOR)
8
- #error "RUBY_API_VERSION_MAJOR is not defined, Ruby headers might not be configured correctly"
9
- #endif
10
-
11
- #if !defined(RUBY_API_VERSION_MINOR)
12
- #error "RUBY_API_VERSION_MINOR is not defined, Ruby headers might not be configured correctly"
13
- #endif
14
-
15
- // Define a macro to check for Ruby 3.3+
16
- #if RUBY_API_VERSION_MAJOR > 3 || (RUBY_API_VERSION_MAJOR == 3 && RUBY_API_VERSION_MINOR >= 3)
17
- #define RUBY_VERSION_AT_LEAST_3_3 1
18
- #else
19
- #define RUBY_VERSION_AT_LEAST_3_3 0
20
- #endif
21
-
22
- long impl_rstring_len(VALUE obj)
23
- {
24
- return RSTRING_LEN(obj);
25
- }
26
-
27
- char *
28
- impl_rstring_ptr(VALUE obj)
29
- {
30
- return RSTRING_PTR(obj);
31
- }
32
-
33
- long impl_rarray_len(VALUE obj)
34
- {
35
- return RARRAY_LEN(obj);
36
- }
37
-
38
- const VALUE *
39
- impl_rarray_const_ptr(VALUE obj)
40
- {
41
- return RARRAY_CONST_PTR(obj);
42
- }
43
-
44
- VALUE
45
- impl_rbasic_class(VALUE obj)
46
- {
47
- return RBASIC_CLASS(obj);
48
- }
49
-
50
- int impl_frozen_p(VALUE obj)
51
- {
52
- return RB_OBJ_FROZEN(obj);
53
- }
54
-
55
- int impl_special_const_p(VALUE obj)
56
- {
57
- return SPECIAL_CONST_P(obj);
58
- }
59
-
60
- int impl_bignum_positive_p(VALUE obj)
61
- {
62
- return RBIGNUM_POSITIVE_P(obj);
63
- }
64
-
65
- int impl_bignum_negative_p(VALUE obj)
66
- {
67
- return RBIGNUM_NEGATIVE_P(obj);
68
- }
69
-
70
- enum ruby_value_type
71
- impl_builtin_type(VALUE obj)
72
- {
73
- return RB_BUILTIN_TYPE(obj);
74
- }
75
-
76
- int impl_nil_p(VALUE obj)
77
- {
78
- return NIL_P(obj);
79
- }
80
-
81
- int impl_fixnum_p(VALUE obj)
82
- {
83
- return FIXNUM_P(obj);
84
- }
85
-
86
- int impl_static_sym_p(VALUE obj)
87
- {
88
- return STATIC_SYM_P(obj);
89
- }
90
-
91
- int impl_flonum_p(VALUE obj)
92
- {
93
- return FLONUM_P(obj);
94
- }
95
-
96
- int impl_immediate_p(VALUE obj)
97
- {
98
- return IMMEDIATE_P(obj);
99
- }
100
-
101
- int impl_rb_test(VALUE obj)
102
- {
103
- return RB_TEST(obj);
104
- }
105
-
106
- int impl_type_p(VALUE obj, enum ruby_value_type type)
107
- {
108
- return RB_TYPE_P(obj, type);
109
- }
110
-
111
- int impl_dynamic_sym_p(VALUE obj)
112
- {
113
- return RB_DYNAMIC_SYM_P(obj);
114
- }
115
-
116
- int impl_symbol_p(VALUE obj)
117
- {
118
- return RB_SYMBOL_P(obj);
119
- }
120
-
121
- int impl_float_type_p(VALUE obj)
122
- {
123
- return RB_FLOAT_TYPE_P(obj);
124
- }
125
-
126
- enum ruby_value_type
127
- impl_rb_type(VALUE obj)
128
- {
129
- return rb_type(obj);
130
- }
131
-
132
- int impl_integer_type_p(VALUE obj)
133
- {
134
- return RB_INTEGER_TYPE_P(obj);
135
- }
136
-
137
- int impl_rstring_interned_p(VALUE obj)
138
- {
139
- Check_Type(obj, T_STRING);
140
-
141
- return !(FL_TEST(obj, RSTRING_FSTR) == 0);
142
- }
143
-
144
- void impl_thread_sleep(struct timeval time)
145
- {
146
- rb_thread_wait_for(time);
147
- }
148
-
149
- // RTypedData implementations
150
- int impl_rtypeddata_p(VALUE obj)
151
- {
152
- return RTYPEDDATA_P(obj);
153
- }
154
-
155
- int impl_rtypeddata_embedded_p(VALUE obj)
156
- {
157
- #if RUBY_VERSION_AT_LEAST_3_3
158
- return RTYPEDDATA_EMBEDDED_P(obj);
159
- #else
160
- // On Ruby versions before 3.3, embedded typed data is not supported
161
- return 0;
162
- #endif
163
- }
164
-
165
- const struct rb_data_type_struct *
166
- impl_rtypeddata_type(VALUE obj)
167
- {
168
- return RTYPEDDATA_TYPE(obj);
169
- }
170
-
171
- void *
172
- impl_rtypeddata_get_data(VALUE obj)
173
- {
174
- #if RUBY_VERSION_AT_LEAST_3_3
175
- return RTYPEDDATA_GET_DATA(obj);
176
- #else
177
- return RTYPEDDATA(obj)->data;
178
- #endif
179
- }
@@ -1,257 +0,0 @@
1
- use super::StableApiDefinition;
2
- use crate::{RUBY_API_VERSION_MAJOR, RUBY_API_VERSION_MINOR, VALUE, ruby_value_type, timeval};
3
- use std::{
4
- ffi::c_void,
5
- os::raw::{c_char, c_long},
6
- ptr::NonNull,
7
- time::Duration,
8
- };
9
-
10
- #[allow(dead_code)]
11
- extern "C" {
12
- #[link_name = "impl_rstring_len"]
13
- fn impl_rstring_len(str: VALUE) -> c_long;
14
-
15
- #[link_name = "impl_rstring_ptr"]
16
- fn impl_rstring_ptr(str: VALUE) -> *const c_char;
17
-
18
- #[link_name = "impl_rarray_len"]
19
- fn impl_rarray_len(ary: VALUE) -> c_long;
20
-
21
- #[link_name = "impl_rarray_const_ptr"]
22
- fn impl_rarray_const_ptr(ary: VALUE) -> *const VALUE;
23
-
24
- #[link_name = "impl_rbasic_class"]
25
- fn impl_rbasic_class(obj: VALUE) -> VALUE;
26
-
27
- #[link_name = "impl_frozen_p"]
28
- fn impl_frozen_p(obj: VALUE) -> bool;
29
-
30
- #[link_name = "impl_special_const_p"]
31
- fn impl_special_const_p(value: VALUE) -> bool;
32
-
33
- #[link_name = "impl_bignum_positive_p"]
34
- fn impl_bignum_positive_p(obj: VALUE) -> bool;
35
-
36
- #[link_name = "impl_bignum_negative_p"]
37
- fn impl_bignum_negative_p(obj: VALUE) -> bool;
38
-
39
- #[link_name = "impl_builtin_type"]
40
- fn impl_builtin_type(obj: VALUE) -> ruby_value_type;
41
-
42
- #[link_name = "impl_nil_p"]
43
- fn impl_nil_p(obj: VALUE) -> bool;
44
-
45
- #[link_name = "impl_fixnum_p"]
46
- fn impl_fixnum_p(obj: VALUE) -> bool;
47
-
48
- #[link_name = "impl_static_sym_p"]
49
- fn impl_static_sym_p(obj: VALUE) -> bool;
50
-
51
- #[link_name = "impl_flonum_p"]
52
- fn impl_flonum_p(obj: VALUE) -> bool;
53
-
54
- #[link_name = "impl_immediate_p"]
55
- fn impl_immediate_p(obj: VALUE) -> bool;
56
-
57
- #[link_name = "impl_rb_test"]
58
- fn impl_rb_test(obj: VALUE) -> bool;
59
-
60
- #[link_name = "impl_type_p"]
61
- fn impl_type_p(obj: VALUE, ty: ruby_value_type) -> bool;
62
-
63
- #[link_name = "impl_dynamic_sym_p"]
64
- fn impl_dynamic_sym_p(obj: VALUE) -> bool;
65
-
66
- #[link_name = "impl_symbol_p"]
67
- fn impl_symbol_p(obj: VALUE) -> bool;
68
-
69
- #[link_name = "impl_float_type_p"]
70
- fn impl_float_type_p(obj: VALUE) -> bool;
71
-
72
- #[link_name = "impl_rb_type"]
73
- fn impl_rb_type(obj: VALUE) -> ruby_value_type;
74
-
75
- #[link_name = "impl_integer_type_p"]
76
- fn impl_integer_type_p(obj: VALUE) -> bool;
77
-
78
- #[link_name = "impl_rstring_interned_p"]
79
- fn impl_rstring_interned_p(obj: VALUE) -> bool;
80
-
81
- #[link_name = "impl_thread_sleep"]
82
- fn impl_thread_sleep(interval: timeval);
83
-
84
- // RTypedData functions
85
- #[link_name = "impl_rtypeddata_p"]
86
- fn impl_rtypeddata_p(obj: VALUE) -> bool;
87
-
88
- #[link_name = "impl_rtypeddata_embedded_p"]
89
- fn impl_rtypeddata_embedded_p(obj: VALUE) -> bool;
90
-
91
- #[link_name = "impl_rtypeddata_type"]
92
- fn impl_rtypeddata_type(obj: VALUE) -> *const crate::rb_data_type_t;
93
-
94
- #[link_name = "impl_rtypeddata_get_data"]
95
- fn impl_rtypeddata_get_data(obj: VALUE) -> *mut c_void;
96
- }
97
-
98
- pub struct Definition;
99
-
100
- impl StableApiDefinition for Definition {
101
- const VERSION_MAJOR: u32 = RUBY_API_VERSION_MAJOR;
102
- const VERSION_MINOR: u32 = RUBY_API_VERSION_MINOR;
103
-
104
- #[inline]
105
- unsafe fn rstring_len(&self, obj: VALUE) -> std::os::raw::c_long {
106
- impl_rstring_len(obj)
107
- }
108
-
109
- #[inline]
110
- unsafe fn rstring_ptr(&self, obj: VALUE) -> *const std::os::raw::c_char {
111
- impl_rstring_ptr(obj)
112
- }
113
-
114
- #[inline]
115
- unsafe fn rarray_len(&self, obj: VALUE) -> std::os::raw::c_long {
116
- impl_rarray_len(obj)
117
- }
118
-
119
- #[inline]
120
- unsafe fn rarray_const_ptr(&self, obj: VALUE) -> *const VALUE {
121
- impl_rarray_const_ptr(obj)
122
- }
123
-
124
- #[inline]
125
- unsafe fn rbasic_class(&self, obj: VALUE) -> Option<NonNull<VALUE>> {
126
- NonNull::<VALUE>::new(impl_rbasic_class(obj) as _)
127
- }
128
-
129
- unsafe fn frozen_p(&self, obj: VALUE) -> bool {
130
- impl_frozen_p(obj)
131
- }
132
-
133
- #[inline]
134
- fn special_const_p(&self, value: VALUE) -> bool {
135
- unsafe { impl_special_const_p(value) }
136
- }
137
-
138
- #[inline]
139
- unsafe fn bignum_positive_p(&self, obj: VALUE) -> bool {
140
- impl_bignum_positive_p(obj)
141
- }
142
-
143
- #[inline]
144
- unsafe fn bignum_negative_p(&self, obj: VALUE) -> bool {
145
- impl_bignum_negative_p(obj)
146
- }
147
-
148
- #[inline]
149
- unsafe fn builtin_type(&self, obj: VALUE) -> ruby_value_type {
150
- impl_builtin_type(obj)
151
- }
152
-
153
- #[inline]
154
- fn nil_p(&self, obj: VALUE) -> bool {
155
- unsafe { impl_nil_p(obj) }
156
- }
157
-
158
- #[inline]
159
- fn fixnum_p(&self, obj: VALUE) -> bool {
160
- unsafe { impl_fixnum_p(obj) }
161
- }
162
-
163
- #[inline]
164
- fn static_sym_p(&self, obj: VALUE) -> bool {
165
- unsafe { impl_static_sym_p(obj) }
166
- }
167
-
168
- #[inline]
169
- fn flonum_p(&self, obj: VALUE) -> bool {
170
- unsafe { impl_flonum_p(obj) }
171
- }
172
-
173
- #[inline]
174
- fn immediate_p(&self, obj: VALUE) -> bool {
175
- unsafe { impl_immediate_p(obj) }
176
- }
177
-
178
- #[inline]
179
- fn rb_test(&self, obj: VALUE) -> bool {
180
- unsafe { impl_rb_test(obj) }
181
- }
182
-
183
- #[inline]
184
- unsafe fn type_p(&self, obj: VALUE, ty: ruby_value_type) -> bool {
185
- impl_type_p(obj, ty)
186
- }
187
-
188
- #[inline]
189
- unsafe fn dynamic_sym_p(&self, obj: VALUE) -> bool {
190
- impl_dynamic_sym_p(obj)
191
- }
192
-
193
- #[inline]
194
- unsafe fn symbol_p(&self, obj: VALUE) -> bool {
195
- impl_symbol_p(obj)
196
- }
197
-
198
- #[inline]
199
- unsafe fn float_type_p(&self, obj: VALUE) -> bool {
200
- impl_float_type_p(obj)
201
- }
202
-
203
- #[inline]
204
- unsafe fn rb_type(&self, obj: VALUE) -> crate::ruby_value_type {
205
- impl_rb_type(obj)
206
- }
207
-
208
- #[inline]
209
- unsafe fn integer_type_p(&self, obj: VALUE) -> bool {
210
- impl_integer_type_p(obj)
211
- }
212
-
213
- #[inline]
214
- unsafe fn rstring_interned_p(&self, obj: VALUE) -> bool {
215
- impl_rstring_interned_p(obj)
216
- }
217
-
218
- #[inline]
219
- fn thread_sleep(&self, duration: Duration) {
220
- let seconds = duration.as_secs() as _;
221
- let microseconds = duration.subsec_micros() as _;
222
-
223
- let time = crate::timeval {
224
- tv_sec: seconds,
225
- tv_usec: microseconds,
226
- };
227
-
228
- unsafe { impl_thread_sleep(time) }
229
- }
230
-
231
- #[inline]
232
- unsafe fn rtypeddata_p(&self, obj: VALUE) -> bool {
233
- impl_rtypeddata_p(obj)
234
- }
235
-
236
- #[inline]
237
- #[cfg(ruby_gte_3_3)]
238
- unsafe fn rtypeddata_embedded_p(&self, obj: VALUE) -> bool {
239
- impl_rtypeddata_embedded_p(obj)
240
- }
241
-
242
- #[inline]
243
- #[cfg(ruby_lt_3_3)]
244
- unsafe fn rtypeddata_embedded_p(&self, _obj: VALUE) -> bool {
245
- false
246
- }
247
-
248
- #[inline]
249
- unsafe fn rtypeddata_type(&self, obj: VALUE) -> *const crate::rb_data_type_t {
250
- impl_rtypeddata_type(obj)
251
- }
252
-
253
- #[inline]
254
- unsafe fn rtypeddata_get_data(&self, obj: VALUE) -> *mut c_void {
255
- impl_rtypeddata_get_data(obj)
256
- }
257
- }