Handle rbs_node and rbs_node_list types#59
Conversation
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
vinistock
left a comment
There was a problem hiding this comment.
Just a point about the type method name, but otherwise it looks good
rust/ruby-rbs/build.rs
Outdated
| } | ||
| "rbs_node" => { | ||
| let (function_name, field_name) = match field.name.as_str() { | ||
| "type" => ("r#type", "type_"), |
There was a problem hiding this comment.
Does this mean that the method will be created with the name type? If so, I'd vote for us to use type_.
Since type is a reserved keyword, invoking the method might prove a little odd, especially if we end up having to use the raw identifier syntax (r#type()).
There was a problem hiding this comment.
We would have to use the raw indentifier syntax. I agree it's odd.
I'll change it to type_ like bindgen does
This adds support for `rbs_node` and `rbs_node_list` field types in the bindings generator. This enables access to child nodes and node lists from parent AST nodes. We handle fields named `type` (which is a Rust keyword) by escaping the accessor method to `r#type()` and correctly mapping to the underlying `type_` field in the C struct.
3d63b58 to
245bf8d
Compare
Enable nested AST traversal by exposing rbs_node and rbs_node_list fields Nested structure traversal (e.g., class members, constant types) depends on access to rbs_node and rbs_node_list fields. Making these fields accessible aligns the Rust bindings with the C API. Fields named "type" are accessible via type_ to avoid a Rust keyword collision
Enable nested AST traversal by exposing rbs_node and rbs_node_list fields Nested structure traversal (e.g., class members, constant types) depends on access to rbs_node and rbs_node_list fields. Making these fields accessible aligns the Rust bindings with the C API. Fields named "type" are accessible via type_ to avoid a Rust keyword collision
Enable nested AST traversal by exposing rbs_node and rbs_node_list fields Nested structure traversal (e.g., class members, constant types) depends on access to rbs_node and rbs_node_list fields. Making these fields accessible aligns the Rust bindings with the C API. Fields named "type" are accessible via type_ to avoid a Rust keyword collision

This PR implements support for
rbs_nodeandrbs_node_listfield types, which were missed in the initial Node/NodeList implementation (#57).Changes:
rbs_nodeandrbs_node_listinbuild.rs.typeby escaping the accessor tor#type()and mapping to the underlyingtype_C field.NodeListconstructor to work with the generated accessors.This enables traversal of nested AST structures (e.g. accessing a class's members or a constant's type) which was previously not possible through the bindings.