rbs 4.0.1.dev.1 → 4.0.1.dev.2
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/lib/rbs/version.rb +1 -1
- data/rbs.gemspec +2 -2
- metadata +1 -17
- data/rust/.gitignore +0 -1
- data/rust/Cargo.lock +0 -378
- data/rust/Cargo.toml +0 -7
- data/rust/ruby-rbs/Cargo.toml +0 -22
- data/rust/ruby-rbs/build.rs +0 -764
- data/rust/ruby-rbs/examples/locations.rs +0 -60
- data/rust/ruby-rbs/src/lib.rs +0 -1
- data/rust/ruby-rbs/src/node/mod.rs +0 -742
- data/rust/ruby-rbs/tests/sanity.rs +0 -47
- data/rust/ruby-rbs/vendor/rbs/config.yml +0 -1
- data/rust/ruby-rbs-sys/Cargo.toml +0 -23
- data/rust/ruby-rbs-sys/build.rs +0 -204
- data/rust/ruby-rbs-sys/src/lib.rs +0 -50
- data/rust/ruby-rbs-sys/vendor/rbs/include +0 -1
- data/rust/ruby-rbs-sys/vendor/rbs/src +0 -1
- data/rust/ruby-rbs-sys/wrapper.h +0 -1
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
use std::path::Path;
|
|
2
|
-
|
|
3
|
-
use ruby_rbs::node::parse;
|
|
4
|
-
|
|
5
|
-
fn collect_rbs_files(dir: &Path) -> Vec<std::path::PathBuf> {
|
|
6
|
-
let mut files = Vec::new();
|
|
7
|
-
|
|
8
|
-
for entry in std::fs::read_dir(dir).unwrap() {
|
|
9
|
-
let entry = entry.unwrap();
|
|
10
|
-
let path = entry.path();
|
|
11
|
-
|
|
12
|
-
if path.is_dir() {
|
|
13
|
-
files.extend(collect_rbs_files(&path));
|
|
14
|
-
} else if path.extension().is_some_and(|ext| ext == "rbs") {
|
|
15
|
-
files.push(path);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
files
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
#[test]
|
|
23
|
-
fn all_included_rbs_can_be_parsed() {
|
|
24
|
-
let repo_root = Path::new(env!("CARGO_MANIFEST_DIR")).join("../..");
|
|
25
|
-
let dirs = [repo_root.join("core"), repo_root.join("stdlib")];
|
|
26
|
-
|
|
27
|
-
let mut files: Vec<_> = dirs.iter().flat_map(|d| collect_rbs_files(d)).collect();
|
|
28
|
-
files.sort();
|
|
29
|
-
assert!(!files.is_empty());
|
|
30
|
-
|
|
31
|
-
let mut failures = Vec::new();
|
|
32
|
-
|
|
33
|
-
for file in &files {
|
|
34
|
-
let content = std::fs::read_to_string(file).unwrap();
|
|
35
|
-
|
|
36
|
-
if let Err(e) = parse(content.as_bytes()) {
|
|
37
|
-
failures.push(format!("{}: {}", file.display(), e));
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
assert!(
|
|
42
|
-
failures.is_empty(),
|
|
43
|
-
"Failed to parse {} RBS file(s):\n{}",
|
|
44
|
-
failures.len(),
|
|
45
|
-
failures.join("\n")
|
|
46
|
-
);
|
|
47
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
../../../../config.yml
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
[package]
|
|
2
|
-
name = "ruby-rbs-sys"
|
|
3
|
-
version = "0.2.0"
|
|
4
|
-
edition = "2024"
|
|
5
|
-
license = "BSD-2-Clause"
|
|
6
|
-
description = "Low-level FFI bindings for RBS -- the type signature language for Ruby programs"
|
|
7
|
-
homepage = "https://github.com/ruby/rbs"
|
|
8
|
-
repository = "https://github.com/ruby/rbs.git"
|
|
9
|
-
readme = "../../README.md"
|
|
10
|
-
include = [
|
|
11
|
-
"src/**/*",
|
|
12
|
-
"vendor/**/*",
|
|
13
|
-
"build.rs",
|
|
14
|
-
"wrapper.h",
|
|
15
|
-
"Cargo.toml",
|
|
16
|
-
]
|
|
17
|
-
|
|
18
|
-
[lib]
|
|
19
|
-
doctest = false
|
|
20
|
-
|
|
21
|
-
[build-dependencies]
|
|
22
|
-
bindgen = "0.72.0"
|
|
23
|
-
cc = "1.2.29"
|
data/rust/ruby-rbs-sys/build.rs
DELETED
|
@@ -1,204 +0,0 @@
|
|
|
1
|
-
use std::{
|
|
2
|
-
env,
|
|
3
|
-
error::Error,
|
|
4
|
-
fs,
|
|
5
|
-
path::{Path, PathBuf},
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
fn main() -> Result<(), Box<dyn Error>> {
|
|
9
|
-
let manifest_dir = Path::new(env!("CARGO_MANIFEST_DIR"));
|
|
10
|
-
let vendor_rbs = manifest_dir.join("vendor/rbs");
|
|
11
|
-
let include = vendor_rbs.join("include");
|
|
12
|
-
let c_src = vendor_rbs.join("src");
|
|
13
|
-
|
|
14
|
-
build(&include, &c_src)?;
|
|
15
|
-
|
|
16
|
-
let bindings = generate_bindings(&include)?;
|
|
17
|
-
write_bindings(&bindings)?;
|
|
18
|
-
|
|
19
|
-
Ok(())
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
fn build(include_dir: &Path, src_dir: &Path) -> Result<(), Box<dyn Error>> {
|
|
23
|
-
let mut build = cc::Build::new();
|
|
24
|
-
|
|
25
|
-
build.include(include_dir);
|
|
26
|
-
|
|
27
|
-
// Suppress unused parameter warnings from C code
|
|
28
|
-
build.flag_if_supported("-Wno-unused-parameter");
|
|
29
|
-
|
|
30
|
-
build.files(source_files(src_dir)?);
|
|
31
|
-
build.try_compile("rbs")?;
|
|
32
|
-
|
|
33
|
-
Ok(())
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
fn source_files<P: AsRef<Path>>(root_dir: P) -> Result<Vec<String>, Box<dyn Error>> {
|
|
37
|
-
let mut files = Vec::new();
|
|
38
|
-
|
|
39
|
-
for entry in fs::read_dir(root_dir.as_ref()).map_err(|e| {
|
|
40
|
-
format!(
|
|
41
|
-
"Failed to read source directory {:?}: {e}",
|
|
42
|
-
root_dir.as_ref()
|
|
43
|
-
)
|
|
44
|
-
})? {
|
|
45
|
-
let entry = entry.map_err(|e| format!("Failed to read directory entry: {e}"))?;
|
|
46
|
-
let path = entry.path();
|
|
47
|
-
|
|
48
|
-
if path.is_file() {
|
|
49
|
-
let path_str = path
|
|
50
|
-
.to_str()
|
|
51
|
-
.ok_or_else(|| format!("Invalid UTF-8 in filename: {path:?}"))?;
|
|
52
|
-
|
|
53
|
-
if Path::new(path_str)
|
|
54
|
-
.extension()
|
|
55
|
-
.is_some_and(|ext| ext.eq_ignore_ascii_case("c"))
|
|
56
|
-
{
|
|
57
|
-
files.push(path_str.to_string());
|
|
58
|
-
}
|
|
59
|
-
} else if path.is_dir() {
|
|
60
|
-
files.extend(source_files(path)?);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
Ok(files)
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
fn generate_bindings(include_path: &Path) -> Result<bindgen::Bindings, Box<dyn Error>> {
|
|
68
|
-
let bindings = bindgen::Builder::default()
|
|
69
|
-
.header("wrapper.h")
|
|
70
|
-
.clang_arg(format!("-I{}", include_path.display()))
|
|
71
|
-
.parse_callbacks(Box::new(bindgen::CargoCallbacks::new()))
|
|
72
|
-
.generate_comments(true)
|
|
73
|
-
// Core types
|
|
74
|
-
.allowlist_type("rbs_ast_annotation_t")
|
|
75
|
-
.allowlist_type("rbs_ast_bool_t")
|
|
76
|
-
.allowlist_type("rbs_ast_comment_t")
|
|
77
|
-
.allowlist_type("rbs_ast_declarations_class_alias_t")
|
|
78
|
-
.allowlist_type("rbs_ast_declarations_class_super_t")
|
|
79
|
-
.allowlist_type("rbs_ast_declarations_class_t")
|
|
80
|
-
.allowlist_type("rbs_ast_declarations_constant_t")
|
|
81
|
-
.allowlist_type("rbs_ast_declarations_global_t")
|
|
82
|
-
.allowlist_type("rbs_ast_declarations_interface_t")
|
|
83
|
-
.allowlist_type("rbs_ast_declarations_module_alias_t")
|
|
84
|
-
.allowlist_type("rbs_ast_declarations_module_self_t")
|
|
85
|
-
.allowlist_type("rbs_ast_declarations_module_t")
|
|
86
|
-
.allowlist_type("rbs_ast_declarations_type_alias_t")
|
|
87
|
-
.allowlist_type("rbs_ast_directives_use_single_clause_t")
|
|
88
|
-
.allowlist_type("rbs_ast_directives_use_t")
|
|
89
|
-
.allowlist_type("rbs_ast_directives_use_wildcard_clause_t")
|
|
90
|
-
.allowlist_type("rbs_ast_integer_t")
|
|
91
|
-
.allowlist_type("rbs_attr_ivar_name_t")
|
|
92
|
-
.allowlist_type("rbs_ast_members_alias_t")
|
|
93
|
-
.allowlist_type("rbs_ast_members_attr_accessor_t")
|
|
94
|
-
.allowlist_type("rbs_ast_members_attr_reader_t")
|
|
95
|
-
.allowlist_type("rbs_ast_members_attr_writer_t")
|
|
96
|
-
.allowlist_type("rbs_ast_members_class_instance_variable_t")
|
|
97
|
-
.allowlist_type("rbs_ast_members_class_variable_t")
|
|
98
|
-
.allowlist_type("rbs_ast_members_extend_t")
|
|
99
|
-
.allowlist_type("rbs_ast_members_include_t")
|
|
100
|
-
.allowlist_type("rbs_ast_members_instance_variable_t")
|
|
101
|
-
.allowlist_type("rbs_ast_members_method_definition_overload_t")
|
|
102
|
-
.allowlist_type("rbs_ast_members_method_definition_t")
|
|
103
|
-
.allowlist_type("rbs_ast_members_prepend_t")
|
|
104
|
-
.allowlist_type("rbs_ast_members_private_t")
|
|
105
|
-
.allowlist_type("rbs_ast_members_public_t")
|
|
106
|
-
.allowlist_type("rbs_ast_ruby_annotations_class_alias_annotation_t")
|
|
107
|
-
.allowlist_type("rbs_ast_ruby_annotations_colon_method_type_annotation_t")
|
|
108
|
-
.allowlist_type("rbs_ast_ruby_annotations_instance_variable_annotation_t")
|
|
109
|
-
.allowlist_type("rbs_ast_ruby_annotations_method_types_annotation_t")
|
|
110
|
-
.allowlist_type("rbs_ast_ruby_annotations_module_alias_annotation_t")
|
|
111
|
-
.allowlist_type("rbs_ast_ruby_annotations_node_type_assertion_t")
|
|
112
|
-
.allowlist_type("rbs_ast_ruby_annotations_return_type_annotation_t")
|
|
113
|
-
.allowlist_type("rbs_ast_ruby_annotations_skip_annotation_t")
|
|
114
|
-
.allowlist_type("rbs_ast_ruby_annotations_type_application_annotation_t")
|
|
115
|
-
.allowlist_type("rbs_ast_ruby_annotations_block_param_type_annotation_t")
|
|
116
|
-
.allowlist_type("rbs_ast_ruby_annotations_param_type_annotation_t")
|
|
117
|
-
.allowlist_type("rbs_ast_ruby_annotations_splat_param_type_annotation_t")
|
|
118
|
-
.allowlist_type("rbs_ast_ruby_annotations_double_splat_param_type_annotation_t")
|
|
119
|
-
.allowlist_type("rbs_ast_string_t")
|
|
120
|
-
.allowlist_type("rbs_ast_symbol_t")
|
|
121
|
-
.allowlist_type("rbs_ast_type_param_t")
|
|
122
|
-
.allowlist_type("rbs_encoding_t")
|
|
123
|
-
.allowlist_type("rbs_encoding_type_t")
|
|
124
|
-
.allowlist_type("rbs_location_range")
|
|
125
|
-
.allowlist_type("rbs_location_range_list_t")
|
|
126
|
-
.allowlist_type("rbs_location_range_list_node_t")
|
|
127
|
-
.allowlist_type("rbs_method_type_t")
|
|
128
|
-
.allowlist_type("rbs_namespace_t")
|
|
129
|
-
.allowlist_type("rbs_node_list_t")
|
|
130
|
-
.allowlist_type("rbs_signature_t")
|
|
131
|
-
.allowlist_type("rbs_string_t")
|
|
132
|
-
.allowlist_type("rbs_type_name_t")
|
|
133
|
-
.allowlist_type("rbs_types_alias_t")
|
|
134
|
-
.allowlist_type("rbs_types_bases_any_t")
|
|
135
|
-
.allowlist_type("rbs_types_bases_bool_t")
|
|
136
|
-
.allowlist_type("rbs_types_bases_bottom_t")
|
|
137
|
-
.allowlist_type("rbs_types_bases_class_t")
|
|
138
|
-
.allowlist_type("rbs_types_bases_instance_t")
|
|
139
|
-
.allowlist_type("rbs_types_bases_nil_t")
|
|
140
|
-
.allowlist_type("rbs_types_bases_self_t")
|
|
141
|
-
.allowlist_type("rbs_types_bases_top_t")
|
|
142
|
-
.allowlist_type("rbs_types_bases_void_t")
|
|
143
|
-
.allowlist_type("rbs_types_block_t")
|
|
144
|
-
.allowlist_type("rbs_types_class_instance_t")
|
|
145
|
-
.allowlist_type("rbs_types_class_singleton_t")
|
|
146
|
-
.allowlist_type("rbs_types_function_param_t")
|
|
147
|
-
.allowlist_type("rbs_types_function_t")
|
|
148
|
-
.allowlist_type("rbs_types_interface_t")
|
|
149
|
-
.allowlist_type("rbs_types_intersection_t")
|
|
150
|
-
.allowlist_type("rbs_types_literal_t")
|
|
151
|
-
.allowlist_type("rbs_types_optional_t")
|
|
152
|
-
.allowlist_type("rbs_types_proc_t")
|
|
153
|
-
.allowlist_type("rbs_types_record_field_type_t")
|
|
154
|
-
.allowlist_type("rbs_types_record_t")
|
|
155
|
-
.allowlist_type("rbs_types_tuple_t")
|
|
156
|
-
.allowlist_type("rbs_types_union_t")
|
|
157
|
-
.allowlist_type("rbs_types_untyped_function_t")
|
|
158
|
-
.allowlist_type("rbs_types_variable_t")
|
|
159
|
-
.constified_enum_module("rbs_alias_kind")
|
|
160
|
-
.constified_enum_module("rbs_attribute_kind")
|
|
161
|
-
.constified_enum_module("rbs_attribute_visibility")
|
|
162
|
-
.constified_enum_module("rbs_encoding_type_t")
|
|
163
|
-
.constified_enum_module("rbs_attr_ivar_name_tag")
|
|
164
|
-
.constified_enum_module("rbs_method_definition_kind")
|
|
165
|
-
.constified_enum_module("rbs_method_definition_visibility")
|
|
166
|
-
.constified_enum_module("rbs_node_type")
|
|
167
|
-
.constified_enum_module("rbs_type_param_variance")
|
|
168
|
-
// Encodings
|
|
169
|
-
.allowlist_var("rbs_encodings")
|
|
170
|
-
// Parser functions
|
|
171
|
-
.allowlist_function("rbs_parse_signature")
|
|
172
|
-
.allowlist_function("rbs_parser_free")
|
|
173
|
-
.allowlist_function("rbs_parser_new")
|
|
174
|
-
// String functions
|
|
175
|
-
.allowlist_function("rbs_string_new")
|
|
176
|
-
// Location functions
|
|
177
|
-
.allowlist_function("rbs_location_range_list_new")
|
|
178
|
-
.allowlist_function("rbs_location_range_list_append")
|
|
179
|
-
// Constant pool functions
|
|
180
|
-
.allowlist_function("rbs_constant_pool_free")
|
|
181
|
-
.allowlist_function("rbs_constant_pool_id_to_constant")
|
|
182
|
-
.allowlist_function("rbs_constant_pool_init")
|
|
183
|
-
.generate()
|
|
184
|
-
.map_err(|_| "Unable to generate rbs bindings")?;
|
|
185
|
-
|
|
186
|
-
Ok(bindings)
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
fn write_bindings(bindings: &bindgen::Bindings) -> Result<(), Box<dyn Error>> {
|
|
190
|
-
let out_path = PathBuf::from(
|
|
191
|
-
env::var("OUT_DIR").map_err(|e| format!("OUT_DIR environment variable not set: {e}"))?,
|
|
192
|
-
);
|
|
193
|
-
|
|
194
|
-
bindings
|
|
195
|
-
.write_to_file(out_path.join("bindings.rs"))
|
|
196
|
-
.map_err(|e| {
|
|
197
|
-
format!(
|
|
198
|
-
"Failed to write bindings to {:?}: {e}",
|
|
199
|
-
out_path.join("bindings.rs")
|
|
200
|
-
)
|
|
201
|
-
})?;
|
|
202
|
-
|
|
203
|
-
Ok(())
|
|
204
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
#![allow(
|
|
2
|
-
clippy::useless_transmute,
|
|
3
|
-
clippy::missing_safety_doc,
|
|
4
|
-
clippy::ptr_offset_with_cast,
|
|
5
|
-
dead_code,
|
|
6
|
-
non_camel_case_types,
|
|
7
|
-
non_upper_case_globals,
|
|
8
|
-
non_snake_case
|
|
9
|
-
)]
|
|
10
|
-
pub mod bindings {
|
|
11
|
-
include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
#[cfg(test)]
|
|
15
|
-
mod tests {
|
|
16
|
-
use super::bindings::*;
|
|
17
|
-
|
|
18
|
-
use rbs_encoding_type_t::RBS_ENCODING_UTF_8;
|
|
19
|
-
|
|
20
|
-
#[test]
|
|
21
|
-
fn test_rbs_parser_bindings() {
|
|
22
|
-
let rbs_code = r#"
|
|
23
|
-
class User
|
|
24
|
-
attr_reader name: String
|
|
25
|
-
def initialize: (String) -> void
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
module Authentication
|
|
29
|
-
def authenticate: (String, String) -> bool
|
|
30
|
-
end
|
|
31
|
-
"#;
|
|
32
|
-
|
|
33
|
-
let bytes = rbs_code.as_bytes();
|
|
34
|
-
let start_ptr = bytes.as_ptr() as *const std::os::raw::c_char;
|
|
35
|
-
let end_ptr = unsafe { start_ptr.add(bytes.len()) } as *const std::os::raw::c_char;
|
|
36
|
-
|
|
37
|
-
let rbs_string = unsafe { rbs_string_new(start_ptr, end_ptr) };
|
|
38
|
-
let encoding_ptr =
|
|
39
|
-
unsafe { &rbs_encodings[RBS_ENCODING_UTF_8 as usize] as *const rbs_encoding_t };
|
|
40
|
-
let parser = unsafe { rbs_parser_new(rbs_string, encoding_ptr, 0, bytes.len() as i32) };
|
|
41
|
-
|
|
42
|
-
let mut signature: *mut rbs_signature_t = std::ptr::null_mut();
|
|
43
|
-
let result = unsafe { rbs_parse_signature(parser, &mut signature) };
|
|
44
|
-
|
|
45
|
-
assert!(result, "Failed to parse RBS signature");
|
|
46
|
-
assert!(!signature.is_null(), "Signature should not be null");
|
|
47
|
-
|
|
48
|
-
unsafe { rbs_parser_free(parser) };
|
|
49
|
-
}
|
|
50
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
../../../../include
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
../../../../src
|
data/rust/ruby-rbs-sys/wrapper.h
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
#include "rbs.h"
|