Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: node templates #1

Closed
wants to merge 28 commits into from
Closed

WIP: node templates #1

wants to merge 28 commits into from

Conversation

Morriar
Copy link

@Morriar Morriar commented Oct 29, 2024

No description provided.

Signed-off-by: Alexandre Terrasa <[email protected]>
Ultimately we want to separate the pure C implementation files
(under `src/` and `include/`) from the Ruby extension files
(under `ext/rbs_extension`).

This change allow us to build the Ruby extension using files outside of
the `ext/rbs_extension` directory.

Signed-off-by: Alexandre Terrasa <[email protected]>
Generate the c/h code for constants definitions and objects initialization.
The generated files are generated under `src/` and `include/` as to not
conflict with the files from `ext/rbs_extension` and will soon replace
`constants.{h,c}` and `ruby_objs.{h,c}`.

We make sure the Rake task builds the required templates so we can compile
the extension.

Signed-off-by: Alexandre Terrasa <[email protected]>
Signed-off-by: Alexandre Terrasa <[email protected]>
Signed-off-by: Alexandre Terrasa <[email protected]>
Signed-off-by: Alexandre Terrasa <[email protected]>
Signed-off-by: Alexandre Terrasa <[email protected]>
Signed-off-by: Alexandre Terrasa <[email protected]>
Signed-off-by: Alexandre Terrasa <[email protected]>
Signed-off-by: Alexandre Terrasa <[email protected]>
Signed-off-by: Alexandre Terrasa <[email protected]>
Signed-off-by: Alexandre Terrasa <[email protected]>
@Morriar Morriar self-assigned this Oct 29, 2024
Comment on lines +1224 to +1226
if (unchecked) {
rb_funcall(param, rb_intern("unchecked!"), 0);
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's this about?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I needed to extract it from the ruby_objs code since we now generate it

Comment on lines +1788 to +1793
enum TokenType type;

member_range.start = state->current_token.range.start;
comment_pos = nonnull_pos_or(comment_pos, member_range.start);

type = state->current_token.type;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we drop the forward declaration?

Suggested change
enum TokenType type;
member_range.start = state->current_token.range.start;
comment_pos = nonnull_pos_or(comment_pos, member_range.start);
type = state->current_token.type;
enum TokenType type = state->current_token.type;
Suggested change
enum TokenType type;
member_range.start = state->current_token.range.start;
comment_pos = nonnull_pos_or(comment_pos, member_range.start);
type = state->current_token.type;
member_range.start = state->current_token.range.start;
comment_pos = nonnull_pos_or(comment_pos, member_range.start);
enum TokenType type = state->current_token.type;

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's the style of the original code, I'd prefer to follow it for now to avoid inconsistencies. We can clean all of it later 👍

Comment on lines +1842 to +1843
VALUE comment = get_comment(state, comment_pos.line);
switch (type)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this just an inlining of rbs_ast_members_mixin()?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, since we generate the specialized methods

extern VALUE <%= node.c_constant_name %>;
<%- end -%>

void rbs__init_constants();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is subtly incorrect: Prior to C23 (which we aren't using), this means "takes unspecified params", not "takes no parameters".

Suggested change
void rbs__init_constants();
void rbs__init_constants(void);

https://stackoverflow.com/a/51080

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kept the original definition, not sure if we want to change it right now?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, I'll keep it "as-is" in our first PR, and add this to our second

@amomchilov
Copy link

Merged upstream in ruby#2098

@amomchilov amomchilov closed this Nov 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants