itsi-server 0.2.21 → 0.2.23
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.
- checksums.yaml +4 -4
- data/Cargo.lock +25 -38
- data/Cargo.toml +4 -0
- data/Rakefile +39 -7
- data/ext/itsi_scheduler/Cargo.toml +1 -1
- data/ext/itsi_server/Cargo.lock +2 -2
- data/ext/itsi_server/Cargo.toml +1 -1
- data/ext/itsi_server/src/server/middleware_stack/mod.rs +3 -9
- data/ext/itsi_server/src/server/signal.rs +7 -5
- data/ext/itsi_server/src/services/itsi_http_service.rs +5 -8
- data/lib/itsi/server/native_extension.rb +34 -0
- data/lib/itsi/server/version.rb +1 -1
- data/lib/itsi/server.rb +10 -2
- data/vendor/rb-sys-build/.cargo-ok +1 -0
- data/vendor/rb-sys-build/.cargo_vcs_info.json +6 -0
- data/vendor/rb-sys-build/Cargo.lock +294 -0
- data/vendor/rb-sys-build/Cargo.toml +71 -0
- data/vendor/rb-sys-build/Cargo.toml.orig +32 -0
- data/vendor/rb-sys-build/LICENSE-APACHE +190 -0
- data/vendor/rb-sys-build/LICENSE-MIT +21 -0
- data/vendor/rb-sys-build/src/bindings/sanitizer.rs +185 -0
- data/vendor/rb-sys-build/src/bindings/stable_api.rs +247 -0
- data/vendor/rb-sys-build/src/bindings/wrapper.h +71 -0
- data/vendor/rb-sys-build/src/bindings.rs +280 -0
- data/vendor/rb-sys-build/src/cc.rs +421 -0
- data/vendor/rb-sys-build/src/lib.rs +12 -0
- data/vendor/rb-sys-build/src/rb_config/flags.rs +101 -0
- data/vendor/rb-sys-build/src/rb_config/library.rs +132 -0
- data/vendor/rb-sys-build/src/rb_config/search_path.rs +57 -0
- data/vendor/rb-sys-build/src/rb_config.rs +906 -0
- data/vendor/rb-sys-build/src/utils.rs +53 -0
- metadata +25 -11
- data/ext/itsi_server/target/release/build/clang-sys-0dae18670e690c25/out/common.rs +0 -355
- data/ext/itsi_server/target/release/build/clang-sys-0dae18670e690c25/out/dynamic.rs +0 -276
- data/ext/itsi_server/target/release/build/clang-sys-0dae18670e690c25/out/macros.rs +0 -49
- data/ext/itsi_server/target/release/build/oid-registry-71b994a322b296ec/out/oid_db.rs +0 -537
- data/ext/itsi_server/target/release/build/rb-sys-9f9831ab50fb86db/out/bindings-0.9.124-mri-arm64-darwin24-2.7.8.rs +0 -6234
- data/ext/itsi_server/target/release/build/rb-sys-9f9831ab50fb86db/out/bindings-0.9.124-mri-arm64-darwin24-3.4.5.rs +0 -8936
- data/ext/itsi_server/target/release/build/rb-sys-9f9831ab50fb86db/out/bindings-0.9.124-mri-arm64-darwin24-4.0.1.rs +0 -9060
- data/ext/itsi_server/target/release/build/typenum-11265e44e46de3b7/out/tests.rs +0 -20563
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
use regex::Regex;
|
|
2
|
+
use std::{
|
|
3
|
+
borrow::{Borrow, Cow},
|
|
4
|
+
error::Error,
|
|
5
|
+
};
|
|
6
|
+
use syn::{Attribute, Expr, Item, Lit, LitStr, Meta};
|
|
7
|
+
|
|
8
|
+
lazy_static::lazy_static! {
|
|
9
|
+
static ref URL_REGEX: Regex = Regex::new(r#"https?://[^\s'"]+"#).unwrap();
|
|
10
|
+
static ref DOC_SECTION_REGEX: Regex = Regex::new(r"^@(warning|internal|private|note)\s*").unwrap();
|
|
11
|
+
static ref PARAM_DIRECTIVE_REGEX: Regex = Regex::new(r"^(@\w+)\[(\S+)\]\s+(.*)$").unwrap();
|
|
12
|
+
static ref OTHER_DIRECTIVE_REGEX: Regex = Regex::new(r"^(@\w+)\s+(.*)$").unwrap();
|
|
13
|
+
static ref BARE_CODE_REF_REGEX: Regex = Regex::new(r"(\b)(rb_(\w|_)+)(\(|\))*").unwrap();
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/// Append a link directive to each foreign module to the given syntax tree.
|
|
17
|
+
pub fn add_link_ruby_directives(
|
|
18
|
+
syntax: &mut syn::File,
|
|
19
|
+
link_name: &str,
|
|
20
|
+
kind: &str,
|
|
21
|
+
) -> Result<(), Box<dyn Error>> {
|
|
22
|
+
for item in syntax.items.iter_mut() {
|
|
23
|
+
if let Item::ForeignMod(fmod) = item {
|
|
24
|
+
fmod.attrs.push(syn::parse_quote! {
|
|
25
|
+
#[link(name = #link_name, kind = #kind)]
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
Ok(())
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/// Converts all `*const rb_encoding` and `*const OnigEncodingTypeST` to *mut
|
|
34
|
+
/// _` to keep backwards compatibility with bindgen < 0.62.
|
|
35
|
+
pub fn ensure_backwards_compatible_encoding_pointers(syntax: &mut syn::File) {
|
|
36
|
+
for item in syntax.items.iter_mut() {
|
|
37
|
+
if let Item::ForeignMod(fmod) = item {
|
|
38
|
+
for item in fmod.items.iter_mut() {
|
|
39
|
+
if let syn::ForeignItem::Fn(f) = item {
|
|
40
|
+
if let syn::ReturnType::Type(_, ty) = &mut f.sig.output {
|
|
41
|
+
if let syn::Type::Ptr(ptr) = &mut **ty {
|
|
42
|
+
if let syn::Type::Path(path) = &*ptr.elem {
|
|
43
|
+
if path.path.segments.len() == 1
|
|
44
|
+
&& path.path.segments[0].ident == "OnigEncodingTypeST"
|
|
45
|
+
|| path.path.segments[0].ident == "rb_encoding"
|
|
46
|
+
{
|
|
47
|
+
ptr.mutability = Some(syn::token::Mut::default());
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/// Turn the cruby comments into rustdoc comments.
|
|
59
|
+
pub fn cleanup_docs(syntax: &mut syn::File, ruby_version: &str) -> Result<(), Box<dyn Error>> {
|
|
60
|
+
let footer = doc_footer(ruby_version);
|
|
61
|
+
|
|
62
|
+
for item in syntax.items.iter_mut() {
|
|
63
|
+
match item {
|
|
64
|
+
Item::ForeignMod(fmod) => {
|
|
65
|
+
for item in fmod.items.iter_mut() {
|
|
66
|
+
match item {
|
|
67
|
+
syn::ForeignItem::Fn(f) => clean_doc_attrs(&mut f.attrs, &footer),
|
|
68
|
+
syn::ForeignItem::Static(s) => clean_doc_attrs(&mut s.attrs, &footer),
|
|
69
|
+
syn::ForeignItem::Type(s) => clean_doc_attrs(&mut s.attrs, &footer),
|
|
70
|
+
_ => {}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
Item::Type(t) => clean_doc_attrs(&mut t.attrs, &footer),
|
|
75
|
+
Item::Struct(s) => {
|
|
76
|
+
clean_doc_attrs(&mut s.attrs, &footer);
|
|
77
|
+
|
|
78
|
+
for f in s.fields.iter_mut() {
|
|
79
|
+
clean_doc_attrs(&mut f.attrs, &footer);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
Item::Enum(e) => {
|
|
83
|
+
clean_doc_attrs(&mut e.attrs, &footer);
|
|
84
|
+
|
|
85
|
+
for v in e.variants.iter_mut() {
|
|
86
|
+
clean_doc_attrs(&mut v.attrs, &footer);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
Item::Union(u) => {
|
|
90
|
+
clean_doc_attrs(&mut u.attrs, &footer);
|
|
91
|
+
|
|
92
|
+
for u in u.fields.named.iter_mut() {
|
|
93
|
+
clean_doc_attrs(&mut u.attrs, &footer);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
_ => {}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
Ok(())
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
fn clean_doc_line(attr: &mut Attribute) -> bool {
|
|
104
|
+
if !attr.path().is_ident("doc") {
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
let mut deprecated: bool = false;
|
|
109
|
+
|
|
110
|
+
if let Meta::NameValue(name_value) = &mut attr.meta {
|
|
111
|
+
if let Expr::Lit(expr_lit) = &mut name_value.value {
|
|
112
|
+
if let Lit::Str(lit_str) = &mut expr_lit.lit {
|
|
113
|
+
let cleaned = lit_str.value();
|
|
114
|
+
let cleaned = cleaned.trim_matches('"').trim();
|
|
115
|
+
let cleaned = URL_REGEX.replace_all(cleaned, "<${0}>");
|
|
116
|
+
let cleaned =
|
|
117
|
+
DOC_SECTION_REGEX.replace_all(&cleaned, |captures: ®ex::Captures| {
|
|
118
|
+
if let Some(header) = captures.get(1) {
|
|
119
|
+
format!("---\n ### {}\n", capitalize(header.as_str())).into()
|
|
120
|
+
} else {
|
|
121
|
+
Cow::Borrowed("")
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
let cleaned = PARAM_DIRECTIVE_REGEX.replace(&cleaned, "- **$1** `$2` $3");
|
|
125
|
+
let cleaned = OTHER_DIRECTIVE_REGEX.replace(&cleaned, "- **$1** $2");
|
|
126
|
+
let mut cleaned = BARE_CODE_REF_REGEX.replace_all(&cleaned, "${1}[`${2}`]");
|
|
127
|
+
|
|
128
|
+
if cleaned.is_empty() {
|
|
129
|
+
cleaned = "\n".into();
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
if cleaned.contains("@deprecated") {
|
|
133
|
+
deprecated = true;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
*lit_str = LitStr::new(cleaned.borrow(), lit_str.span());
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
deprecated
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
fn clean_doc_attrs(attrs: &mut Vec<Attribute>, footer: &str) {
|
|
145
|
+
let mut deprecated: bool = false;
|
|
146
|
+
|
|
147
|
+
for attr in attrs.iter_mut() {
|
|
148
|
+
if clean_doc_line(attr) {
|
|
149
|
+
deprecated = true;
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
attrs.push(syn::parse_quote! {
|
|
154
|
+
#[doc = #footer]
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
if deprecated {
|
|
158
|
+
attrs.push(syn::parse_quote! {
|
|
159
|
+
#[deprecated]
|
|
160
|
+
})
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
fn doc_footer(ruby_version: &str) -> String {
|
|
165
|
+
format!(
|
|
166
|
+
"\n---\n\nGenerated by [rb-sys]({}) for Ruby {}",
|
|
167
|
+
env!("CARGO_PKG_REPOSITORY"),
|
|
168
|
+
ruby_version
|
|
169
|
+
)
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
fn capitalize(input: &str) -> Cow<'_, str> {
|
|
173
|
+
if let Some(first) = input.chars().next() {
|
|
174
|
+
if first.is_ascii_uppercase() && input[1..].chars().all(|c| c.is_ascii_lowercase()) {
|
|
175
|
+
Cow::Borrowed(input)
|
|
176
|
+
} else {
|
|
177
|
+
let mut result = String::with_capacity(input.len());
|
|
178
|
+
result.push(first.to_ascii_uppercase());
|
|
179
|
+
result.push_str(&input[1..].to_ascii_lowercase());
|
|
180
|
+
Cow::Owned(result)
|
|
181
|
+
}
|
|
182
|
+
} else {
|
|
183
|
+
Cow::Borrowed(input)
|
|
184
|
+
}
|
|
185
|
+
}
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
use std::vec;
|
|
2
|
+
|
|
3
|
+
use quote::ToTokens;
|
|
4
|
+
|
|
5
|
+
use crate::RbConfig;
|
|
6
|
+
|
|
7
|
+
const OPAQUE_STRUCTS: [&str; 4] = ["RString", "RArray", "RData", "RTypedData"];
|
|
8
|
+
|
|
9
|
+
const OPAQUE_STRUCTS_RUBY_3_3: [&str; 3] = [
|
|
10
|
+
"rb_matchext_struct",
|
|
11
|
+
"rb_internal_thread_event_data",
|
|
12
|
+
"rb_io_internal_buffer",
|
|
13
|
+
];
|
|
14
|
+
|
|
15
|
+
/// Generate opaque structs for the given bindings.
|
|
16
|
+
pub fn opaqueify_bindings(
|
|
17
|
+
rbconfig: &RbConfig,
|
|
18
|
+
bindings: bindgen::Builder,
|
|
19
|
+
wrapper_h: &mut String,
|
|
20
|
+
) -> bindgen::Builder {
|
|
21
|
+
let version_specific_opaque_structs =
|
|
22
|
+
get_version_specific_opaque_structs(rbconfig.major_minor());
|
|
23
|
+
let structs_to_opaque = OPAQUE_STRUCTS
|
|
24
|
+
.iter()
|
|
25
|
+
.chain(&version_specific_opaque_structs);
|
|
26
|
+
|
|
27
|
+
structs_to_opaque.fold(bindings, |bindings, name| {
|
|
28
|
+
gen_opaque_struct(bindings, name, wrapper_h)
|
|
29
|
+
})
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/// Categorize all bindings into stable, unstable, and internal.
|
|
33
|
+
pub fn categorize_bindings(syntax: &mut syn::File) {
|
|
34
|
+
let mut normal_items = Vec::new();
|
|
35
|
+
let mut unstable_items = Vec::new();
|
|
36
|
+
let mut internal_items = Vec::new();
|
|
37
|
+
let mut excluded_items = Vec::new();
|
|
38
|
+
let mut opaque_items = Vec::new();
|
|
39
|
+
let mut opaque_idents_to_swap = Vec::new();
|
|
40
|
+
|
|
41
|
+
for item in syntax.items.iter_mut() {
|
|
42
|
+
if let syn::Item::Struct(s) = item {
|
|
43
|
+
if s.ident.to_string().contains("rb_sys__Opaque__") {
|
|
44
|
+
let new_name = s.ident.to_string().replace("rb_sys__Opaque__", "");
|
|
45
|
+
s.ident = syn::Ident::new(&new_name, s.ident.span());
|
|
46
|
+
opaque_idents_to_swap.push(new_name);
|
|
47
|
+
|
|
48
|
+
opaque_items.push(item.clone());
|
|
49
|
+
} else {
|
|
50
|
+
normal_items.push(item.clone());
|
|
51
|
+
}
|
|
52
|
+
} else if let syn::Item::Type(t) = item {
|
|
53
|
+
if t.ident.to_string().contains("rb_sys__Opaque__") {
|
|
54
|
+
let new_name = t.ident.to_string().replace("rb_sys__Opaque__", "");
|
|
55
|
+
t.ident = syn::Ident::new(&new_name, t.ident.span());
|
|
56
|
+
opaque_idents_to_swap.push(new_name);
|
|
57
|
+
|
|
58
|
+
opaque_items.push(item.clone());
|
|
59
|
+
} else {
|
|
60
|
+
normal_items.push(item.clone());
|
|
61
|
+
}
|
|
62
|
+
} else {
|
|
63
|
+
if let syn::Item::Fn(ref mut f) = item {
|
|
64
|
+
if f.sig.ident.to_string().contains("bindgen_test_") {
|
|
65
|
+
let body = &mut f.block;
|
|
66
|
+
let code = body.clone().to_token_stream().to_string();
|
|
67
|
+
let new_code = code.replace("rb_sys__Opaque__", "super::stable::");
|
|
68
|
+
let new_code = syn::parse_str::<syn::Block>(&new_code).unwrap();
|
|
69
|
+
|
|
70
|
+
*body = syn::parse_quote! {
|
|
71
|
+
{
|
|
72
|
+
#[allow(unused)]
|
|
73
|
+
use super::internal::*;
|
|
74
|
+
#new_code;
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
normal_items.push(item.clone());
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
for item in normal_items.iter_mut() {
|
|
85
|
+
if let syn::Item::Type(ref mut t) = item {
|
|
86
|
+
if let Ok(syn::Type::Path(ref mut type_path)) =
|
|
87
|
+
syn::parse2::<syn::Type>(t.ty.to_token_stream())
|
|
88
|
+
{
|
|
89
|
+
if opaque_idents_to_swap.contains(&type_path.path.segments[0].ident.to_string()) {
|
|
90
|
+
let new_ident = syn::Ident::new(
|
|
91
|
+
&type_path.path.segments[0].ident.to_string(),
|
|
92
|
+
type_path.path.segments[0].ident.span(),
|
|
93
|
+
);
|
|
94
|
+
t.ty = syn::parse_quote! { crate::internal::#new_ident };
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
for mut item in normal_items {
|
|
101
|
+
if let syn::Item::Struct(s) = &mut item {
|
|
102
|
+
if opaque_idents_to_swap.contains(&s.ident.to_string()) {
|
|
103
|
+
internal_items.push(syn::Item::Struct(s.clone()));
|
|
104
|
+
s.attrs.push(syn::parse_quote! {
|
|
105
|
+
#[deprecated(note = "To improve API stability with ruby-head, direct usage of Ruby internal structs has been deprecated. To migrate, please replace the usage of this internal struct with its counterpart in the `rb_sys::stable` module. For example, instead of `use rb_sys::rb_sys__Opaque__ExampleStruct;`, use `use rb_sys::stable::ExampleStruct;`. If you need to access the internals of these items, you can use the provided `rb-sys::macros` instead.")]
|
|
106
|
+
});
|
|
107
|
+
unstable_items.push(item);
|
|
108
|
+
} else {
|
|
109
|
+
excluded_items.push(item);
|
|
110
|
+
}
|
|
111
|
+
} else if let syn::Item::Type(t) = &mut item {
|
|
112
|
+
if opaque_idents_to_swap.contains(&t.ident.to_string()) {
|
|
113
|
+
internal_items.push(syn::Item::Type(t.clone()));
|
|
114
|
+
t.attrs.push(syn::parse_quote! {
|
|
115
|
+
#[deprecated(note = "To improve API stability with ruby-head, direct usage of Ruby internal structs has been deprecated. To migrate, please replace the usage of this internal struct with its counterpart in the `rb_sys::stable` module. For example, instead of `use rb_sys::rb_sys__Opaque__ExampleStruct;`, use `use rb_sys::stable::ExampleStruct;`. If you need to access the internals of these items, you can use the provided `rb-sys::macros` instead.")]
|
|
116
|
+
});
|
|
117
|
+
unstable_items.push(item);
|
|
118
|
+
} else {
|
|
119
|
+
excluded_items.push(item);
|
|
120
|
+
}
|
|
121
|
+
} else {
|
|
122
|
+
excluded_items.push(item);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// Perform a pass on all std::fmt::Debug implementations to fully qualify opaque structs
|
|
127
|
+
for item in excluded_items.iter_mut() {
|
|
128
|
+
if let syn::Item::Impl(ref mut impl_item) = item {
|
|
129
|
+
if let Some((_, syn::Path { segments, .. }, _)) = impl_item.trait_.as_ref() {
|
|
130
|
+
if segments.iter().any(|segment| segment.ident == "Debug") {
|
|
131
|
+
if let syn::Type::Path(ref mut path) = *impl_item.self_ty {
|
|
132
|
+
if opaque_idents_to_swap.contains(&path.to_token_stream().to_string()) {
|
|
133
|
+
*impl_item.self_ty = syn::parse_quote! { crate::internal::#path };
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
*syntax = syn::parse_quote! {
|
|
142
|
+
/// Contains all items that are not yet categorized by ABI stability.
|
|
143
|
+
/// These items are candidates for promotion to `stable` or `unstable`
|
|
144
|
+
/// in the future.
|
|
145
|
+
pub mod uncategorized {
|
|
146
|
+
#(#excluded_items)*
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/// Contains all items that are considered unstable ABI and should be
|
|
150
|
+
/// avoided. Any items in this list offer a stable alternative for most
|
|
151
|
+
/// use cases.
|
|
152
|
+
pub mod unstable {
|
|
153
|
+
use super::uncategorized::*;
|
|
154
|
+
|
|
155
|
+
#(#unstable_items)*
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/// Contains all items that are considered stable ABI and are safe to
|
|
159
|
+
/// use. These items are intentionally opaque to prevent accidental
|
|
160
|
+
/// compatibility issues.
|
|
161
|
+
///
|
|
162
|
+
/// If you need to access the internals of these items, please open an
|
|
163
|
+
/// issue.
|
|
164
|
+
pub mod stable {
|
|
165
|
+
#(#opaque_items)*
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/// Unstable items for usage internally in rb_sys to avoid deprecated warnings.
|
|
169
|
+
#[allow(dead_code)]
|
|
170
|
+
pub (crate) mod internal {
|
|
171
|
+
use super::uncategorized::*;
|
|
172
|
+
|
|
173
|
+
#(#internal_items)*
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
fn gen_opaque_struct(
|
|
179
|
+
bindings: bindgen::Builder,
|
|
180
|
+
name: &str,
|
|
181
|
+
wrapper_h: &mut String,
|
|
182
|
+
) -> bindgen::Builder {
|
|
183
|
+
let struct_name = format!("rb_sys__Opaque__{}", name);
|
|
184
|
+
wrapper_h.push_str(&format!(
|
|
185
|
+
"struct {} {{ struct {} dummy; }};\n",
|
|
186
|
+
struct_name, name
|
|
187
|
+
));
|
|
188
|
+
|
|
189
|
+
bindings
|
|
190
|
+
.opaque_type(&struct_name)
|
|
191
|
+
.allowlist_type(struct_name)
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
fn get_version_specific_opaque_structs(major_minor: Option<(u32, u32)>) -> Vec<&'static str> {
|
|
195
|
+
let Some(major_minor) = major_minor else {
|
|
196
|
+
return vec![];
|
|
197
|
+
};
|
|
198
|
+
let mut result = vec![];
|
|
199
|
+
let (major, minor) = major_minor;
|
|
200
|
+
|
|
201
|
+
if major > 3 || (major == 3 && minor >= 3) {
|
|
202
|
+
result.extend(OPAQUE_STRUCTS_RUBY_3_3)
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
result
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
#[cfg(test)]
|
|
209
|
+
mod tests {
|
|
210
|
+
use super::*;
|
|
211
|
+
|
|
212
|
+
#[test]
|
|
213
|
+
fn test_get_version_specific_opaque_structs() {
|
|
214
|
+
// No version info
|
|
215
|
+
assert!(get_version_specific_opaque_structs(None).is_empty());
|
|
216
|
+
|
|
217
|
+
// Ruby 3.2.x - too old for 3.3 structs
|
|
218
|
+
assert!(get_version_specific_opaque_structs(Some((3, 2))).is_empty());
|
|
219
|
+
|
|
220
|
+
// Ruby 3.3.x - should include 3.3 structs
|
|
221
|
+
assert_eq!(
|
|
222
|
+
get_version_specific_opaque_structs(Some((3, 3))),
|
|
223
|
+
OPAQUE_STRUCTS_RUBY_3_3.to_vec()
|
|
224
|
+
);
|
|
225
|
+
|
|
226
|
+
// Ruby 3.4.x - should include 3.3 structs
|
|
227
|
+
assert_eq!(
|
|
228
|
+
get_version_specific_opaque_structs(Some((3, 4))),
|
|
229
|
+
OPAQUE_STRUCTS_RUBY_3_3.to_vec()
|
|
230
|
+
);
|
|
231
|
+
|
|
232
|
+
// Ruby 4.0.x - should include 3.3 structs (this was the bug!)
|
|
233
|
+
assert_eq!(
|
|
234
|
+
get_version_specific_opaque_structs(Some((4, 0))),
|
|
235
|
+
OPAQUE_STRUCTS_RUBY_3_3.to_vec()
|
|
236
|
+
);
|
|
237
|
+
|
|
238
|
+
// Ruby 4.1.x - should include 3.3 structs
|
|
239
|
+
assert_eq!(
|
|
240
|
+
get_version_specific_opaque_structs(Some((4, 1))),
|
|
241
|
+
OPAQUE_STRUCTS_RUBY_3_3.to_vec()
|
|
242
|
+
);
|
|
243
|
+
|
|
244
|
+
// Ruby 2.7.x - too old
|
|
245
|
+
assert!(get_version_specific_opaque_structs(Some((2, 7))).is_empty());
|
|
246
|
+
}
|
|
247
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
#include "ruby.h"
|
|
2
|
+
|
|
3
|
+
#ifdef HAVE_RUBY_DEBUG_H
|
|
4
|
+
#include "ruby/debug.h"
|
|
5
|
+
#endif
|
|
6
|
+
#ifdef HAVE_RUBY_DEFINES_H
|
|
7
|
+
#include "ruby/defines.h"
|
|
8
|
+
#endif
|
|
9
|
+
#ifdef HAVE_RUBY_ENCODING_H
|
|
10
|
+
#include "ruby/encoding.h"
|
|
11
|
+
#endif
|
|
12
|
+
#ifdef HAVE_RUBY_FIBER_SCHEDULER_H
|
|
13
|
+
#include "ruby/fiber/scheduler.h"
|
|
14
|
+
#endif
|
|
15
|
+
#ifdef HAVE_RUBY_INTERN_H
|
|
16
|
+
#include "ruby/intern.h"
|
|
17
|
+
#endif
|
|
18
|
+
#ifdef HAVE_RUBY_IO_H
|
|
19
|
+
#include "ruby/io.h"
|
|
20
|
+
#endif
|
|
21
|
+
#ifdef HAVE_RUBY_MEMORY_VIEW_H
|
|
22
|
+
#include "ruby/memory_view.h"
|
|
23
|
+
#endif
|
|
24
|
+
#ifdef HAVE_RUBY_MISSING_H
|
|
25
|
+
#include "ruby/missing.h"
|
|
26
|
+
#endif
|
|
27
|
+
#ifdef HAVE_RUBY_ONIGMO_H
|
|
28
|
+
#include "ruby/onigmo.h"
|
|
29
|
+
#endif
|
|
30
|
+
#ifdef HAVE_RUBY_ONIGURUMA_H
|
|
31
|
+
#include "ruby/oniguruma.h"
|
|
32
|
+
#endif
|
|
33
|
+
#ifdef HAVE_RUBY_RACTOR_H
|
|
34
|
+
#include "ruby/ractor.h"
|
|
35
|
+
#endif
|
|
36
|
+
#ifdef HAVE_RUBY_RANDOM_H
|
|
37
|
+
#include "ruby/random.h"
|
|
38
|
+
#endif
|
|
39
|
+
#ifdef HAVE_RUBY_RE_H
|
|
40
|
+
#include "ruby/re.h"
|
|
41
|
+
#endif
|
|
42
|
+
#ifdef HAVE_RUBY_REGEX_H
|
|
43
|
+
#include "ruby/regex.h"
|
|
44
|
+
#endif
|
|
45
|
+
#ifdef HAVE_RUBY_RUBY_H
|
|
46
|
+
#include "ruby/ruby.h"
|
|
47
|
+
#endif
|
|
48
|
+
#ifdef HAVE_RUBY_ST_H
|
|
49
|
+
#include "ruby/st.h"
|
|
50
|
+
#endif
|
|
51
|
+
#ifdef HAVE_RUBY_THREAD_H
|
|
52
|
+
#include "ruby/thread.h"
|
|
53
|
+
#endif
|
|
54
|
+
#ifdef HAVE_RUBY_THREAD_NATIVE_H
|
|
55
|
+
#include "ruby/thread_native.h"
|
|
56
|
+
#endif
|
|
57
|
+
#ifdef HAVE_RUBY_UTIL_H
|
|
58
|
+
#include "ruby/util.h"
|
|
59
|
+
#endif
|
|
60
|
+
#ifdef HAVE_RUBY_VERSION_H
|
|
61
|
+
#include "ruby/version.h"
|
|
62
|
+
#endif
|
|
63
|
+
#ifdef HAVE_RUBY_VM_H
|
|
64
|
+
#include "ruby/vm.h"
|
|
65
|
+
#endif
|
|
66
|
+
#ifdef HAVE_RUBY_WIN32_H
|
|
67
|
+
#include "ruby/win32.h"
|
|
68
|
+
#endif
|
|
69
|
+
#ifdef HAVE_RUBY_IO_BUFFER_H
|
|
70
|
+
#include "ruby/io/buffer.h"
|
|
71
|
+
#endif
|