Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion include/rbs/ast.h
Original file line number Diff line number Diff line change
Expand Up @@ -941,12 +941,20 @@ typedef struct rbs_types_variable {

typedef union rbs_ast_ruby_annotations {
rbs_node_t base;
rbs_ast_ruby_annotations_block_param_type_annotation_t block_param_type_annotation;
rbs_ast_ruby_annotations_class_alias_annotation_t class_alias_annotation;
rbs_ast_ruby_annotations_colon_method_type_annotation_t colon_method_type_annotation;
rbs_ast_ruby_annotations_double_splat_param_type_annotation_t double_splat_param_type_annotation;
rbs_ast_ruby_annotations_instance_variable_annotation_t instance_variable_annotation;
rbs_ast_ruby_annotations_method_types_annotation_t method_types_annotation;
rbs_ast_ruby_annotations_module_alias_annotation_t module_alias_annotation;
rbs_ast_ruby_annotations_module_self_annotation_t module_self_annotation;
rbs_ast_ruby_annotations_node_type_assertion_t node_type_assertion;
rbs_ast_ruby_annotations_param_type_annotation_t param_type_annotation;
rbs_ast_ruby_annotations_return_type_annotation_t return_type_annotation;
rbs_ast_ruby_annotations_skip_annotation_t skip_annotation;
rbs_ast_ruby_annotations_param_type_annotation_t param_type_annotation;
rbs_ast_ruby_annotations_splat_param_type_annotation_t splat_param_type_annotation;
rbs_ast_ruby_annotations_type_application_annotation_t type_application_annotation;
} rbs_ast_ruby_annotations_t;

/// `rbs_ast_symbol_t` models user-defined identifiers like class names, method names, etc.
Expand Down
17 changes: 4 additions & 13 deletions rust/ruby-rbs-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,19 +103,10 @@ fn generate_bindings(include_path: &Path) -> Result<bindgen::Bindings, Box<dyn E
.allowlist_type("rbs_ast_members_prepend_t")
.allowlist_type("rbs_ast_members_private_t")
.allowlist_type("rbs_ast_members_public_t")
.allowlist_type("rbs_ast_ruby_annotations_class_alias_annotation_t")
.allowlist_type("rbs_ast_ruby_annotations_colon_method_type_annotation_t")
.allowlist_type("rbs_ast_ruby_annotations_instance_variable_annotation_t")
.allowlist_type("rbs_ast_ruby_annotations_method_types_annotation_t")
.allowlist_type("rbs_ast_ruby_annotations_module_alias_annotation_t")
.allowlist_type("rbs_ast_ruby_annotations_node_type_assertion_t")
.allowlist_type("rbs_ast_ruby_annotations_return_type_annotation_t")
.allowlist_type("rbs_ast_ruby_annotations_skip_annotation_t")
.allowlist_type("rbs_ast_ruby_annotations_type_application_annotation_t")
.allowlist_type("rbs_ast_ruby_annotations_block_param_type_annotation_t")
.allowlist_type("rbs_ast_ruby_annotations_param_type_annotation_t")
.allowlist_type("rbs_ast_ruby_annotations_splat_param_type_annotation_t")
.allowlist_type("rbs_ast_ruby_annotations_double_splat_param_type_annotation_t")
// Match every `rbs_ast_ruby_annotations_*` struct (and the union itself)
// so newly added annotation kinds do not require edits here. This keeps the
// Rust bindings in sync with `config.yml` automatically.
.allowlist_type("rbs_ast_ruby_annotations_.*")
.allowlist_type("rbs_ast_string_t")
.allowlist_type("rbs_ast_symbol_t")
.allowlist_type("rbs_ast_type_param_t")
Expand Down
9 changes: 3 additions & 6 deletions templates/include/rbs/ast.h.erb
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,9 @@ typedef struct <%= node.c_name %> {
<%- end -%>
typedef union rbs_ast_ruby_annotations {
rbs_node_t base;
rbs_ast_ruby_annotations_colon_method_type_annotation_t colon_method_type_annotation;
rbs_ast_ruby_annotations_method_types_annotation_t method_types_annotation;
rbs_ast_ruby_annotations_node_type_assertion_t node_type_assertion;
rbs_ast_ruby_annotations_return_type_annotation_t return_type_annotation;
rbs_ast_ruby_annotations_skip_annotation_t skip_annotation;
rbs_ast_ruby_annotations_param_type_annotation_t param_type_annotation;
<%- annotation_nodes.each do |node| -%>
<%= node.c_type_name %> <%= node.c_name.delete_prefix("rbs_ast_ruby_annotations_") %>;
<%- end -%>
} rbs_ast_ruby_annotations_t;

/// `rbs_ast_symbol_t` models user-defined identifiers like class names, method names, etc.
Expand Down
11 changes: 9 additions & 2 deletions templates/template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -385,9 +385,16 @@ def locals
Node.new(node, fields, locations, constructor_params)
end

sorted_nodes = nodes.sort_by { _1.descr.ruby_full_name }

annotation_nodes = sorted_nodes
.select { _1.descr.ruby_full_name.start_with?("RBS::AST::Ruby::Annotations::") }
.sort_by(&:c_name)

{
nodes: nodes.sort_by { _1.descr.ruby_full_name },
enums: enum_desc
nodes: sorted_nodes,
enums: enum_desc,
annotation_nodes: annotation_nodes,
}
end
end
Expand Down