diff options
author | HASUMI Hitoshi <hasumikin@gmail.com> | 2024-04-27 16:28:52 +0900 |
---|---|---|
committer | Yuichiro Kaneko <spiketeika@gmail.com> | 2024-04-28 12:08:21 +0900 |
commit | ddd8da4b6ba3dfcca21ca710e7cef2fa3b9632d7 (patch) | |
tree | a1549d2a8b59ec0b5a7b187d804c3b594a7c0108 /spec/ruby/library/net-http/httpresponse | |
parent | 8ad0b2cd310b4ca5af9a24610117a05acc35bcae (diff) |
[Universal parser] Improve AST structure
This patch moves `ast->node_buffer->config` to `ast->config` aiming to improve readability and maintainability of the source.
## Background
We could not add the `config` field to the `rb_ast_t *` due to the five-word restriction of the IMEMO object.
But it is now doable by merging https://github.com/ruby/ruby/pull/10618
## About assigning `&rb_global_parser_config` to `ast->config` in `ast_alloc()`
The approach of not setting `ast->config` in `ast_alloc()` means that the client, CRuby in this scenario, that directly calls `ast_alloc()` will be responsible for releasing it if a resource that is passed to AST needs to be released.
However, we have put on hold whether we can guarantee the above so far, thus, this patch looks like that.
```
// ruby_parser.c
static VALUE
ast_alloc(void)
{
rb_ast_t *ast;
VALUE vast = TypedData_Make_Struct(0, rb_ast_t, &ast_data_type, ast);
#ifdef UNIVERSAL_PARSER
ast = (rb_ast_t *)DATA_PTR(vast);
ast->config = &rb_global_parser_config;
#endif
return vast;
}
```
Diffstat (limited to 'spec/ruby/library/net-http/httpresponse')
0 files changed, 0 insertions, 0 deletions