Ruby 3.3.6p108 (2024-11-05 revision 75015d4c1f6965b5e85e96fb309f1f2129f933c0)
|
The options that can be passed to parsing. More...
#include "prism/defines.h"
#include "prism/util/pm_string.h"
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
Go to the source code of this file.
Data Structures | |
struct | pm_options_scope |
A scope of locals surrounding the code that is being parsed. More... | |
struct | pm_options_t |
The options that can be passed to the parser. More... | |
Typedefs | |
typedef struct pm_options_scope | pm_options_scope_t |
A scope of locals surrounding the code that is being parsed. | |
Functions | |
PRISM_EXPORTED_FUNCTION void | pm_options_filepath_set (pm_options_t *options, const char *filepath) |
Set the filepath option on the given options struct. | |
PRISM_EXPORTED_FUNCTION void | pm_options_line_set (pm_options_t *options, int32_t line) |
Set the line option on the given options struct. | |
PRISM_EXPORTED_FUNCTION void | pm_options_encoding_set (pm_options_t *options, const char *encoding) |
Set the encoding option on the given options struct. | |
PRISM_EXPORTED_FUNCTION void | pm_options_frozen_string_literal_set (pm_options_t *options, bool frozen_string_literal) |
Set the frozen string literal option on the given options struct. | |
PRISM_EXPORTED_FUNCTION void | pm_options_suppress_warnings_set (pm_options_t *options, bool suppress_warnings) |
Set the suppress warnings option on the given options struct. | |
PRISM_EXPORTED_FUNCTION void | pm_options_scopes_init (pm_options_t *options, size_t scopes_count) |
Allocate and zero out the scopes array on the given options struct. | |
PRISM_EXPORTED_FUNCTION const pm_options_scope_t * | pm_options_scope_get (const pm_options_t *options, size_t index) |
Return a pointer to the scope at the given index within the given options. | |
PRISM_EXPORTED_FUNCTION void | pm_options_scope_init (pm_options_scope_t *scope, size_t locals_count) |
Create a new options scope struct. | |
PRISM_EXPORTED_FUNCTION const pm_string_t * | pm_options_scope_local_get (const pm_options_scope_t *scope, size_t index) |
Return a pointer to the local at the given index within the given scope. | |
PRISM_EXPORTED_FUNCTION void | pm_options_free (pm_options_t *options) |
Free the internal memory associated with the options. | |
void | pm_options_read (pm_options_t *options, const char *data) |
Deserialize an options struct from the given binary string. | |
The options that can be passed to parsing.
Definition in file options.h.
typedef struct pm_options_scope pm_options_scope_t |
A scope of locals surrounding the code that is being parsed.
PRISM_EXPORTED_FUNCTION void pm_options_encoding_set | ( | pm_options_t * | options, |
const char * | encoding ) |
PRISM_EXPORTED_FUNCTION void pm_options_filepath_set | ( | pm_options_t * | options, |
const char * | filepath ) |
PRISM_EXPORTED_FUNCTION void pm_options_free | ( | pm_options_t * | options | ) |
PRISM_EXPORTED_FUNCTION void pm_options_frozen_string_literal_set | ( | pm_options_t * | options, |
bool | frozen_string_literal ) |
PRISM_EXPORTED_FUNCTION void pm_options_line_set | ( | pm_options_t * | options, |
int32_t | line ) |
void pm_options_read | ( | pm_options_t * | options, |
const char * | data ) |
Deserialize an options struct from the given binary string.
This is used to pass options to the parser from an FFI call so that consumers of the library from an FFI perspective don't have to worry about the structure of our options structs. Since the source of these calls will be from Ruby implementation internals we assume it is from a trusted source.
data
is assumed to be a valid pointer pointing to well-formed data. The layout of this data should be the same every time, and is described below:
# bytes | field |
---|---|
4 | the length of the filepath |
... | the filepath bytes |
4 | the line number |
4 | the length the encoding |
... | the encoding bytes |
1 | frozen string literal |
1 | suppress warnings |
4 | the number of scopes |
... | the scopes |
Each scope is layed out as follows:
# bytes | field |
---|---|
4 | the number of locals |
... | the locals |
Each local is layed out as follows:
# bytes | field |
---|---|
4 | the length of the local |
... | the local bytes |
Some additional things to note about this layout:
Encoding.find
in Ruby.options | The options struct to deserialize into. |
data | The binary string to deserialize from. |
This is used to pass options to the parser from an FFI call so that consumers of the library from an FFI perspective don't have to worry about the structure of our options structs. Since the source of these calls will be from Ruby implementation internals we assume it is from a trusted source.
PRISM_EXPORTED_FUNCTION const pm_options_scope_t * pm_options_scope_get | ( | const pm_options_t * | options, |
size_t | index ) |
PRISM_EXPORTED_FUNCTION void pm_options_scope_init | ( | pm_options_scope_t * | scope, |
size_t | locals_count ) |
Create a new options scope struct.
This will hold a set of locals that are in scope surrounding the code that is being parsed.
scope | The scope struct to initialize. |
locals_count | The number of locals to allocate. |
This will hold a set of locals that are in scope surrounding the code that is being parsed.
PRISM_EXPORTED_FUNCTION const pm_string_t * pm_options_scope_local_get | ( | const pm_options_scope_t * | scope, |
size_t | index ) |
PRISM_EXPORTED_FUNCTION void pm_options_scopes_init | ( | pm_options_t * | options, |
size_t | scopes_count ) |
PRISM_EXPORTED_FUNCTION void pm_options_suppress_warnings_set | ( | pm_options_t * | options, |
bool | suppress_warnings ) |