Skip to content
This repository was archived by the owner on Nov 5, 2024. It is now read-only.

Commit 16b29f0

Browse files
committed
constify immutable arguments in a few places; move decoded_input.h above loc.h in merge_headers script
1 parent e3ecdc9 commit 16b29f0

File tree

5 files changed

+7
-7
lines changed

5 files changed

+7
-7
lines changed

codegen/examples/merge_headers.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ const HEADERS: &[&str] = &[
33
"string.h",
44
"bytes.h",
55
"source_line.h",
6+
"decoded_input.h",
67
"loc.h",
78
"token_ids.h",
89
"token.h",
910
"comment.h",
1011
"magic_comment.h",
11-
"decoded_input.h",
1212
"nodes.h",
1313
"messages.h",
1414
"diagnostic.h",

diagnostic.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ typedef struct LIB_RUBY_PARSER_Diagnostic
4242
Return owned NULL-terminated string.
4343
*/
4444
char *LIB_RUBY_PARSER_render_diagnostic(
45-
LIB_RUBY_PARSER_Diagnostic *diagnostic,
46-
LIB_RUBY_PARSER_DecodedInput *input);
45+
const LIB_RUBY_PARSER_Diagnostic *diagnostic,
46+
const LIB_RUBY_PARSER_DecodedInput *input);
4747

4848
/*
4949
Diagnostic destructor.

ruby-parser-c/src/diagnostic.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ pub extern "C" fn LIB_RUBY_PARSER_drop_diagnostic_list(diagnostic_list: *mut Vec
4242

4343
#[no_mangle]
4444
pub extern "C" fn LIB_RUBY_PARSER_render_diagnostic(
45-
diagnostic: *mut Diagnostic,
46-
input: *mut DecodedInput,
45+
diagnostic: *const Diagnostic,
46+
input: *const DecodedInput,
4747
) -> *mut i8 {
4848
let diagnostic = unsafe { diagnostic.as_ref().unwrap() };
4949
let input = unsafe { input.as_ref().unwrap() };

ruby-parser-c/src/token.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ pub extern "C" fn lib_ruby_parser__test__make_token_eq(
3030
}
3131

3232
#[no_mangle]
33-
pub extern "C" fn LIB_RUBY_PARSER_token_name(token: *mut Token) -> *mut i8 {
33+
pub extern "C" fn LIB_RUBY_PARSER_token_name(token: *const Token) -> *mut i8 {
3434
let token = unsafe { token.as_ref().unwrap() };
3535
let token_name = token.token_name();
3636
std::ffi::CString::new(token_name).unwrap().into_raw()

token.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ typedef struct LIB_RUBY_PARSER_Token
1919
/*
2020
Returns token name (like "kDEF") for a given token.
2121
*/
22-
char *LIB_RUBY_PARSER_token_name(LIB_RUBY_PARSER_Token *token);
22+
char *LIB_RUBY_PARSER_token_name(const LIB_RUBY_PARSER_Token *token);
2323
/*
2424
Token destructor.
2525
Just like Rust/C++ destructor it performs cleanup of "embedded" resources.

0 commit comments

Comments
 (0)