Skip to content

Commit d9e359f

Browse files
authored
Merge pull request #3991 from ruby/expose-options
Expose parse options to Rust
2 parents 8e79053 + 0f1500c commit d9e359f

3 files changed

Lines changed: 406 additions & 16 deletions

File tree

include/prism/util/pm_string.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ void pm_string_owned_init(pm_string_t *string, uint8_t *source, size_t length);
9494
* @param source The source of the string.
9595
* @param length The length of the string.
9696
*/
97-
void pm_string_constant_init(pm_string_t *string, const char *source, size_t length);
97+
PRISM_EXPORTED_FUNCTION void pm_string_constant_init(pm_string_t *string, const char *source, size_t length);
9898

9999
/**
100100
* Represents the result of calling pm_string_mapped_init or

rust/ruby-prism-sys/build/main.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,9 @@ fn generate_bindings(ruby_include_path: &Path) -> bindgen::Bindings {
120120
.allowlist_type("pm_magic_comment_t")
121121
.allowlist_type("pm_node_t")
122122
.allowlist_type("pm_node_type")
123+
.allowlist_type("pm_options_t")
124+
.allowlist_type("pm_options_scope_t")
125+
.allowlist_type("pm_options_version_t")
123126
.allowlist_type("pm_parser_t")
124127
.allowlist_type("pm_string_t")
125128
.allowlist_type(r"^pm_\w+_node_t")
@@ -128,20 +131,38 @@ fn generate_bindings(ruby_include_path: &Path) -> bindgen::Bindings {
128131
.rustified_non_exhaustive_enum("pm_comment_type_t")
129132
.rustified_non_exhaustive_enum(r"pm_\w+_flags")
130133
.rustified_non_exhaustive_enum("pm_node_type")
134+
.rustified_non_exhaustive_enum("pm_options_version_t")
131135
// Functions
132136
.allowlist_function("pm_arena_free")
133137
.allowlist_function("pm_list_empty_p")
134138
.allowlist_function("pm_list_free")
139+
.allowlist_function("pm_options_command_line_set")
140+
.allowlist_function("pm_options_encoding_locked_set")
141+
.allowlist_function("pm_options_encoding_set")
142+
.allowlist_function("pm_options_filepath_set")
143+
.allowlist_function("pm_options_free")
144+
.allowlist_function("pm_options_frozen_string_literal_set")
145+
.allowlist_function("pm_options_line_set")
146+
.allowlist_function("pm_options_main_script_set")
147+
.allowlist_function("pm_options_partial_script_set")
148+
.allowlist_function("pm_options_scope_forwarding_set")
149+
.allowlist_function("pm_options_scope_get")
150+
.allowlist_function("pm_options_scope_init")
151+
.allowlist_function("pm_options_scope_local_get")
152+
.allowlist_function("pm_options_scopes_init")
135153
.allowlist_function("pm_parse")
136154
.allowlist_function("pm_parser_free")
137155
.allowlist_function("pm_parser_init")
138156
.allowlist_function("pm_size_to_native")
157+
.allowlist_function("pm_string_constant_init")
139158
.allowlist_function("pm_string_free")
140159
.allowlist_function("pm_string_length")
141160
.allowlist_function("pm_string_source")
142161
.allowlist_function("pm_version")
143162
// Vars
144163
.allowlist_var(r"^pm_encoding\S+")
164+
.allowlist_var(r"^PM_OPTIONS_COMMAND_LINE_\w+")
165+
.allowlist_var(r"^PM_OPTIONS_SCOPE_FORWARDING_\w+")
145166
.generate()
146167
.expect("Unable to generate prism bindings")
147168
}

0 commit comments

Comments
 (0)