Constify rb_global_parser_config

This commit is contained in:
Nobuyoshi Nakada 2024-01-14 17:55:11 +09:00
parent 4e5754a459
commit 0610f555ea
No known key found for this signature in database
GPG Key ID: 3582D74E1FEE4465
5 changed files with 10 additions and 10 deletions

4
node.c
View File

@ -53,7 +53,7 @@ init_node_buffer_list(node_buffer_list_t * nb, node_buffer_elem_t *head, void *x
#ifdef UNIVERSAL_PARSER #ifdef UNIVERSAL_PARSER
static node_buffer_t * static node_buffer_t *
rb_node_buffer_new(rb_parser_config_t *config) rb_node_buffer_new(const rb_parser_config_t *config)
#else #else
static node_buffer_t * static node_buffer_t *
rb_node_buffer_new(void) rb_node_buffer_new(void)
@ -318,7 +318,7 @@ rb_ast_delete_node(rb_ast_t *ast, NODE *n)
#ifdef UNIVERSAL_PARSER #ifdef UNIVERSAL_PARSER
rb_ast_t * rb_ast_t *
rb_ast_new(rb_parser_config_t *config) rb_ast_new(const rb_parser_config_t *config)
{ {
node_buffer_t *nb = rb_node_buffer_new(config); node_buffer_t *nb = rb_node_buffer_new(config);
return config->ast_new((VALUE)nb); return config->ast_new((VALUE)nb);

4
node.h
View File

@ -43,14 +43,14 @@ struct node_buffer_struct {
// Array, whose entry is array // Array, whose entry is array
VALUE tokens; VALUE tokens;
#ifdef UNIVERSAL_PARSER #ifdef UNIVERSAL_PARSER
rb_parser_config_t *config; const rb_parser_config_t *config;
#endif #endif
}; };
RUBY_SYMBOL_EXPORT_BEGIN RUBY_SYMBOL_EXPORT_BEGIN
#ifdef UNIVERSAL_PARSER #ifdef UNIVERSAL_PARSER
rb_ast_t *rb_ast_new(rb_parser_config_t *config); rb_ast_t *rb_ast_new(const rb_parser_config_t *config);
#else #else
rb_ast_t *rb_ast_new(void); rb_ast_t *rb_ast_new(void);
#endif #endif

View File

@ -611,7 +611,7 @@ struct parser_params {
struct lex_context ctxt; struct lex_context ctxt;
#ifdef UNIVERSAL_PARSER #ifdef UNIVERSAL_PARSER
rb_parser_config_t *config; const rb_parser_config_t *config;
#endif #endif
/* compile_option */ /* compile_option */
signed int frozen_string_literal:2; /* -1: not specified, 0: false, 1: true */ signed int frozen_string_literal:2; /* -1: not specified, 0: false, 1: true */
@ -15989,7 +15989,7 @@ rb_reserved_word(const char *str, unsigned int len)
#ifdef UNIVERSAL_PARSER #ifdef UNIVERSAL_PARSER
rb_parser_t * rb_parser_t *
rb_ruby_parser_allocate(rb_parser_config_t *config) rb_ruby_parser_allocate(const rb_parser_config_t *config)
{ {
/* parser_initialize expects fields to be set to 0 */ /* parser_initialize expects fields to be set to 0 */
rb_parser_t *p = (rb_parser_t *)config->calloc(1, sizeof(rb_parser_t)); rb_parser_t *p = (rb_parser_t *)config->calloc(1, sizeof(rb_parser_t));
@ -15998,7 +15998,7 @@ rb_ruby_parser_allocate(rb_parser_config_t *config)
} }
rb_parser_t * rb_parser_t *
rb_ruby_parser_new(rb_parser_config_t *config) rb_ruby_parser_new(const rb_parser_config_t *config)
{ {
/* parser_initialize expects fields to be set to 0 */ /* parser_initialize expects fields to be set to 0 */
rb_parser_t *p = rb_ruby_parser_allocate(config); rb_parser_t *p = rb_ruby_parser_allocate(config);

View File

@ -484,7 +484,7 @@ extern VALUE rb_eArgError;
extern VALUE rb_mRubyVMFrozenCore; extern VALUE rb_mRubyVMFrozenCore;
VALUE rb_node_case_when_optimizable_literal(const NODE *const node); VALUE rb_node_case_when_optimizable_literal(const NODE *const node);
rb_parser_config_t rb_global_parser_config = (rb_parser_config_t) { static const rb_parser_config_t rb_global_parser_config = {
.malloc = ruby_xmalloc, .malloc = ruby_xmalloc,
.calloc = ruby_xcalloc, .calloc = ruby_xcalloc,
.realloc = ruby_xrealloc, .realloc = ruby_xrealloc,

View File

@ -1439,8 +1439,8 @@ void rb_ruby_parser_free(void *ptr);
rb_ast_t* rb_ruby_parser_compile_string(rb_parser_t *p, const char *f, VALUE s, int line); rb_ast_t* rb_ruby_parser_compile_string(rb_parser_t *p, const char *f, VALUE s, int line);
#ifdef UNIVERSAL_PARSER #ifdef UNIVERSAL_PARSER
rb_parser_t *rb_ruby_parser_allocate(rb_parser_config_t *config); rb_parser_t *rb_ruby_parser_allocate(const rb_parser_config_t *config);
rb_parser_t *rb_ruby_parser_new(rb_parser_config_t *config); rb_parser_t *rb_ruby_parser_new(const rb_parser_config_t *config);
#endif #endif
long rb_parser_string_length(rb_parser_string_t *str); long rb_parser_string_length(rb_parser_string_t *str);