Skip to content

Commit

Permalink
Add \memberof annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
amomchilov committed Aug 30, 2024
1 parent acc0b79 commit ba6d3b5
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 3 deletions.
20 changes: 19 additions & 1 deletion include/prism.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
* The prism version and the serialization format.
*
* @returns The prism version as a constant string.
* \public \memberof pm_parser
*/
PRISM_EXPORTED_FUNCTION const char * pm_version(void);

Expand All @@ -53,6 +54,7 @@ PRISM_EXPORTED_FUNCTION const char * pm_version(void);
* @param source The source to parse.
* @param size The size of the source.
* @param options The optional options to use when parsing.
* \public \memberof pm_parser
*/
PRISM_EXPORTED_FUNCTION void pm_parser_init(pm_parser_t *parser, const uint8_t *source, size_t size, const pm_options_t *options);

Expand All @@ -62,13 +64,15 @@ PRISM_EXPORTED_FUNCTION void pm_parser_init(pm_parser_t *parser, const uint8_t *
*
* @param parser The parser to register the callback with.
* @param callback The callback to register.
* \public \memberof pm_parser
*/
PRISM_EXPORTED_FUNCTION void pm_parser_register_encoding_changed_callback(pm_parser_t *parser, pm_encoding_changed_callback_t callback);

/**
* Free any memory associated with the given parser.
*
* @param parser The parser to free.
* \public \memberof pm_parser
*/
PRISM_EXPORTED_FUNCTION void pm_parser_free(pm_parser_t *parser);

Expand All @@ -77,13 +81,15 @@ PRISM_EXPORTED_FUNCTION void pm_parser_free(pm_parser_t *parser);
*
* @param parser The parser to use.
* @return The AST representing the source.
* \public \memberof pm_parser
*/
PRISM_EXPORTED_FUNCTION pm_node_t * pm_parse(pm_parser_t *parser);

/**
* This function is used in pm_parse_stream to retrieve a line of input from a
* This function is used in pm_parse_stream() to retrieve a line of input from a
* stream. It closely mirrors that of fgets so that fgets can be used as the
* default implementation.
* \public \memberof pm_parser
*/
typedef char * (pm_parse_stream_fgets_t)(char *string, int size, void *stream);

Expand All @@ -96,6 +102,7 @@ typedef char * (pm_parse_stream_fgets_t)(char *string, int size, void *stream);
* @param fgets The function to use to read from the stream.
* @param options The optional options to use when parsing.
* @return The AST representing the source.
* \public \memberof pm_parser
*/
PRISM_EXPORTED_FUNCTION pm_node_t * pm_parse_stream(pm_parser_t *parser, pm_buffer_t *buffer, void *stream, pm_parse_stream_fgets_t *fgets, const pm_options_t *options);

Expand All @@ -112,6 +119,7 @@ PRISM_EXPORTED_FUNCTION pm_node_t * pm_parse_stream(pm_parser_t *parser, pm_buff
* @param stream The stream to parse.
* @param fgets The function to use to read from the stream.
* @param data The optional data to pass to the parser.
* \public \relatedalso pm_buffer_t
*/
PRISM_EXPORTED_FUNCTION void pm_serialize_parse_stream(pm_buffer_t *buffer, void *stream, pm_parse_stream_fgets_t *fgets, const char *data);

Expand All @@ -121,6 +129,7 @@ PRISM_EXPORTED_FUNCTION void pm_serialize_parse_stream(pm_buffer_t *buffer, void
* @param parser The parser to serialize.
* @param list The list of comments to serialize.
* @param buffer The buffer to serialize to.
* \public \relatedalso pm_buffer_t \relatedalso pm_list_t
*/
void pm_serialize_comment_list(pm_parser_t *parser, pm_list_t *list, pm_buffer_t *buffer);

Expand All @@ -129,6 +138,7 @@ void pm_serialize_comment_list(pm_parser_t *parser, pm_list_t *list, pm_buffer_t
*
* @param encoding The encoding to serialize.
* @param buffer The buffer to serialize to.
* \public \relatedalso pm_buffer_t \relatedalso pm_encoding_t
*/
void pm_serialize_encoding(const pm_encoding_t *encoding, pm_buffer_t *buffer);

Expand All @@ -138,6 +148,7 @@ void pm_serialize_encoding(const pm_encoding_t *encoding, pm_buffer_t *buffer);
* @param parser The parser to serialize.
* @param node The node to serialize.
* @param buffer The buffer to serialize to.
* \public \relatedalso pm_buffer_t \relatedalso pm_parser \relatedalso pm_node
*/
void pm_serialize_content(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer);

Expand All @@ -147,6 +158,7 @@ void pm_serialize_content(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buf
* @param parser The parser to serialize.
* @param node The node to serialize.
* @param buffer The buffer to serialize to.
* \public \relatedalso pm_buffer_t \relatedalso pm_parser \relatedalso pm_node
*/
PRISM_EXPORTED_FUNCTION void pm_serialize(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer);

Expand All @@ -157,6 +169,7 @@ PRISM_EXPORTED_FUNCTION void pm_serialize(pm_parser_t *parser, pm_node_t *node,
* @param source The source to parse.
* @param size The size of the source.
* @param data The optional data to pass to the parser.
* \public \relatedalso pm_buffer_t
*/
PRISM_EXPORTED_FUNCTION void pm_serialize_parse(pm_buffer_t *buffer, const uint8_t *source, size_t size, const char *data);

Expand All @@ -167,6 +180,7 @@ PRISM_EXPORTED_FUNCTION void pm_serialize_parse(pm_buffer_t *buffer, const uint8
* @param source The source to parse.
* @param size The size of the source.
* @param data The optional data to pass to the parser.
* \public \relatedalso pm_buffer_t
*/
PRISM_EXPORTED_FUNCTION void pm_serialize_parse_comments(pm_buffer_t *buffer, const uint8_t *source, size_t size, const char *data);

Expand All @@ -177,6 +191,7 @@ PRISM_EXPORTED_FUNCTION void pm_serialize_parse_comments(pm_buffer_t *buffer, co
* @param size The size of the source.
* @param buffer The buffer to serialize to.
* @param data The optional data to pass to the lexer.
* \public \relatedalso pm_buffer_t
*/
PRISM_EXPORTED_FUNCTION void pm_serialize_lex(pm_buffer_t *buffer, const uint8_t *source, size_t size, const char *data);

Expand All @@ -188,6 +203,7 @@ PRISM_EXPORTED_FUNCTION void pm_serialize_lex(pm_buffer_t *buffer, const uint8_t
* @param source The source to parse.
* @param size The size of the source.
* @param data The optional data to pass to the parser.
* \public \relatedalso pm_buffer_t
*/
PRISM_EXPORTED_FUNCTION void pm_serialize_parse_lex(pm_buffer_t *buffer, const uint8_t *source, size_t size, const char *data);

Expand All @@ -200,6 +216,7 @@ PRISM_EXPORTED_FUNCTION void pm_serialize_parse_lex(pm_buffer_t *buffer, const u
* @param size The size of the source.
* @param data The optional data to pass to the parser.
* @return True if the source parses without errors or warnings.
* \public \static \memberof pm_parser
*/
PRISM_EXPORTED_FUNCTION bool pm_parse_success_p(const uint8_t *source, size_t size, const char *data);

Expand Down Expand Up @@ -229,6 +246,7 @@ const char * pm_token_type_human(pm_token_type_t token_type);
* @param buffer The buffer to serialize to.
* @param parser The parser that parsed the node.
* @param node The node to serialize.
* \public \relatedalso pm_buffer_t \relatedalso pm_parser \relatedalso pm_node
*/
PRISM_EXPORTED_FUNCTION void pm_dump_json(pm_buffer_t *buffer, const pm_parser_t *parser, const pm_node_t *node);

Expand Down
8 changes: 8 additions & 0 deletions include/prism/node.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
*
* @param list The list to append to.
* @param node The node to append.
* \private \memberof pm_node_list
*/
void pm_node_list_append(pm_node_list_t *list, pm_node_t *node);

Expand All @@ -30,6 +31,7 @@ void pm_node_list_append(pm_node_list_t *list, pm_node_t *node);
*
* @param list The list to prepend to.
* @param node The node to prepend.
* \private \memberof pm_node_list
*/
void pm_node_list_prepend(pm_node_list_t *list, pm_node_t *node);

Expand All @@ -38,13 +40,15 @@ void pm_node_list_prepend(pm_node_list_t *list, pm_node_t *node);
*
* @param list The list to concatenate onto.
* @param other The list to concatenate.
* \private \memberof pm_node_list
*/
void pm_node_list_concat(pm_node_list_t *list, pm_node_list_t *other);

/**
* Free the internal memory associated with the given node list.
*
* @param list The list to free.
* \private \memberof pm_node_list
*/
void pm_node_list_free(pm_node_list_t *list);

Expand All @@ -53,6 +57,7 @@ void pm_node_list_free(pm_node_list_t *list);
*
* @param parser The parser that owns the node.
* @param node The node to deallocate.
* \public \memberof pm_node \relatedalso pm_parser
*/
PRISM_EXPORTED_FUNCTION void pm_node_destroy(pm_parser_t *parser, struct pm_node *node);

Expand All @@ -61,6 +66,7 @@ PRISM_EXPORTED_FUNCTION void pm_node_destroy(pm_parser_t *parser, struct pm_node
*
* @param node_type The node type to convert to a string.
* @return A string representation of the given node type.
* \public \memberof pm_node
*/
PRISM_EXPORTED_FUNCTION const char * pm_node_type_to_str(pm_node_type_t node_type);

Expand Down Expand Up @@ -112,6 +118,7 @@ PRISM_EXPORTED_FUNCTION const char * pm_node_type_to_str(pm_node_type_t node_typ
* @param node The root node to start visiting from.
* @param visitor The callback to call for each node in the subtree.
* @param data An opaque pointer that is passed to the visitor callback.
* \public \memberof pm_node
*/
PRISM_EXPORTED_FUNCTION void pm_visit_node(const pm_node_t *node, bool (*visitor)(const pm_node_t *node, void *data), void *data);

Expand All @@ -123,6 +130,7 @@ PRISM_EXPORTED_FUNCTION void pm_visit_node(const pm_node_t *node, bool (*visitor
* @param node The node to visit the children of.
* @param visitor The callback to call for each child node.
* @param data An opaque pointer that is passed to the visitor callback.
* \public \memberof pm_node
*/
PRISM_EXPORTED_FUNCTION void pm_visit_child_nodes(const pm_node_t *node, bool (*visitor)(const pm_node_t *node, void *data), void *data);

Expand Down
13 changes: 13 additions & 0 deletions include/prism/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ static const uint8_t PM_OPTIONS_COMMAND_LINE_X = 0x20;
* @param shebang_callback The shebang callback to set.
* @param shebang_callback_data Any additional data that should be passed along
* to the callback.
* \public \memberof pm_options
*/
PRISM_EXPORTED_FUNCTION void pm_options_shebang_callback_set(pm_options_t *options, pm_options_shebang_callback_t shebang_callback, void *shebang_callback_data);

Expand All @@ -193,6 +194,7 @@ PRISM_EXPORTED_FUNCTION void pm_options_shebang_callback_set(pm_options_t *optio
*
* @param options The options struct to set the filepath on.
* @param filepath The filepath to set.
* \public \memberof pm_options
*/
PRISM_EXPORTED_FUNCTION void pm_options_filepath_set(pm_options_t *options, const char *filepath);

Expand All @@ -201,6 +203,7 @@ PRISM_EXPORTED_FUNCTION void pm_options_filepath_set(pm_options_t *options, cons
*
* @param options The options struct to set the line on.
* @param line The line to set.
* \public \memberof pm_options
*/
PRISM_EXPORTED_FUNCTION void pm_options_line_set(pm_options_t *options, int32_t line);

Expand All @@ -209,6 +212,7 @@ PRISM_EXPORTED_FUNCTION void pm_options_line_set(pm_options_t *options, int32_t
*
* @param options The options struct to set the encoding on.
* @param encoding The encoding to set.
* \public \memberof pm_options
*/
PRISM_EXPORTED_FUNCTION void pm_options_encoding_set(pm_options_t *options, const char *encoding);

Expand All @@ -217,6 +221,7 @@ PRISM_EXPORTED_FUNCTION void pm_options_encoding_set(pm_options_t *options, cons
*
* @param options The options struct to set the encoding_locked value on.
* @param encoding_locked The encoding_locked value to set.
* \public \memberof pm_options
*/
PRISM_EXPORTED_FUNCTION void pm_options_encoding_locked_set(pm_options_t *options, bool encoding_locked);

Expand All @@ -225,6 +230,7 @@ PRISM_EXPORTED_FUNCTION void pm_options_encoding_locked_set(pm_options_t *option
*
* @param options The options struct to set the frozen string literal value on.
* @param frozen_string_literal The frozen string literal value to set.
* \public \memberof pm_options
*/
PRISM_EXPORTED_FUNCTION void pm_options_frozen_string_literal_set(pm_options_t *options, bool frozen_string_literal);

Expand All @@ -233,6 +239,7 @@ PRISM_EXPORTED_FUNCTION void pm_options_frozen_string_literal_set(pm_options_t *
*
* @param options The options struct to set the command line option on.
* @param command_line The command_line value to set.
* \public \memberof pm_options
*/
PRISM_EXPORTED_FUNCTION void pm_options_command_line_set(pm_options_t *options, uint8_t command_line);

Expand All @@ -245,6 +252,7 @@ PRISM_EXPORTED_FUNCTION void pm_options_command_line_set(pm_options_t *options,
* @param version The version to set.
* @param length The length of the version string.
* @return Whether or not the version was parsed successfully.
* \public \memberof pm_options
*/
PRISM_EXPORTED_FUNCTION bool pm_options_version_set(pm_options_t *options, const char *version, size_t length);

Expand All @@ -254,6 +262,7 @@ PRISM_EXPORTED_FUNCTION bool pm_options_version_set(pm_options_t *options, const
* @param options The options struct to initialize the scopes array on.
* @param scopes_count The number of scopes to allocate.
* @return Whether or not the scopes array was initialized successfully.
* \public \memberof pm_options
*/
PRISM_EXPORTED_FUNCTION bool pm_options_scopes_init(pm_options_t *options, size_t scopes_count);

Expand All @@ -263,6 +272,7 @@ PRISM_EXPORTED_FUNCTION bool pm_options_scopes_init(pm_options_t *options, size_
* @param options The options struct to get the scope from.
* @param index The index of the scope to get.
* @return A pointer to the scope at the given index.
* \public \memberof pm_options
*/
PRISM_EXPORTED_FUNCTION const pm_options_scope_t * pm_options_scope_get(const pm_options_t *options, size_t index);

Expand All @@ -273,6 +283,7 @@ PRISM_EXPORTED_FUNCTION const pm_options_scope_t * pm_options_scope_get(const pm
* @param scope The scope struct to initialize.
* @param locals_count The number of locals to allocate.
* @return Whether or not the scope was initialized successfully.
* \public \memberof pm_options
*/
PRISM_EXPORTED_FUNCTION bool pm_options_scope_init(pm_options_scope_t *scope, size_t locals_count);

Expand All @@ -282,13 +293,15 @@ PRISM_EXPORTED_FUNCTION bool pm_options_scope_init(pm_options_scope_t *scope, si
* @param scope The scope struct to get the local from.
* @param index The index of the local to get.
* @return A pointer to the local at the given index.
* \public \memberof pm_options
*/
PRISM_EXPORTED_FUNCTION const pm_string_t * pm_options_scope_local_get(const pm_options_scope_t *scope, size_t index);

/**
* Free the internal memory associated with the options.
*
* @param options The options struct whose internal memory should be freed.
* \public \memberof pm_options
*/
PRISM_EXPORTED_FUNCTION void pm_options_free(pm_options_t *options);

Expand Down
1 change: 1 addition & 0 deletions include/prism/prettyprint.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ void pm_prettyprint(void);
* @param output_buffer The buffer to write the pretty-printed AST to.
* @param parser The parser that parsed the AST.
* @param node The root node of the AST to pretty-print.
* \public \relatedalso pm_buffer_t \relatedalso pm_parser \relatedalso pm_node
*/
PRISM_EXPORTED_FUNCTION void pm_prettyprint(pm_buffer_t *output_buffer, const pm_parser_t *parser, const pm_node_t *node);

Expand Down
7 changes: 5 additions & 2 deletions include/prism/regexp.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@
#include <string.h>

/**
* This callback is called when a named capture group is found.
* This callback is called by pm_regexp_parse() when a named capture group is found.
* \public \memberof pm_parser
*/
typedef void (*pm_regexp_name_callback_t)(const pm_string_t *name, void *data);

/**
* This callback is called when a parse error is found.
* This callback is called by pm_regexp_parse() when a parse error is found.
* \public \memberof pm_parser
*/
typedef void (*pm_regexp_error_callback_t)(const uint8_t *start, const uint8_t *end, const char *message, void *data);

Expand All @@ -37,6 +39,7 @@ typedef void (*pm_regexp_error_callback_t)(const uint8_t *start, const uint8_t *
* @param name_data The optional data to pass to the name callback.
* @param error_callback The callback to call when a parse error is found.
* @param error_data The data to pass to the error callback.
* \public \memberof pm_parser
*/
PRISM_EXPORTED_FUNCTION void pm_regexp_parse(pm_parser_t *parser, const uint8_t *source, size_t size, bool extended_mode, pm_regexp_name_callback_t name_callback, void *name_data, pm_regexp_error_callback_t error_callback, void *error_data);

Expand Down
5 changes: 5 additions & 0 deletions include/prism/util/pm_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ typedef struct {
* Return the size of the pm_buffer_t struct.
*
* @returns The size of the pm_buffer_t struct.
* \public \static \memberof pm_buffer_t
*/
PRISM_EXPORTED_FUNCTION size_t pm_buffer_sizeof(void);

Expand All @@ -51,6 +52,7 @@ bool pm_buffer_init_capacity(pm_buffer_t *buffer, size_t capacity);
*
* @param buffer The buffer to initialize.
* @returns True if the buffer was initialized successfully, false otherwise.
* \public \memberof pm_buffer_t
*/
PRISM_EXPORTED_FUNCTION bool pm_buffer_init(pm_buffer_t *buffer);

Expand All @@ -59,6 +61,7 @@ PRISM_EXPORTED_FUNCTION bool pm_buffer_init(pm_buffer_t *buffer);
*
* @param buffer The buffer to get the value of.
* @returns The value of the buffer.
* \public \memberof pm_buffer_t
*/
PRISM_EXPORTED_FUNCTION char * pm_buffer_value(const pm_buffer_t *buffer);

Expand All @@ -67,6 +70,7 @@ PRISM_EXPORTED_FUNCTION char * pm_buffer_value(const pm_buffer_t *buffer);
*
* @param buffer The buffer to get the length of.
* @returns The length of the buffer.
* \public \memberof pm_buffer_t
*/
PRISM_EXPORTED_FUNCTION size_t pm_buffer_length(const pm_buffer_t *buffer);

Expand Down Expand Up @@ -212,6 +216,7 @@ void pm_buffer_insert(pm_buffer_t *buffer, size_t index, const char *value, size
* Free the memory associated with the buffer.
*
* @param buffer The buffer to free.
* \public \memberof pm_buffer_t
*/
PRISM_EXPORTED_FUNCTION void pm_buffer_free(pm_buffer_t *buffer);

Expand Down
Loading

0 comments on commit ba6d3b5

Please sign in to comment.