Skip to content

Commit

Permalink
Add \memberof annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
amomchilov committed Sep 16, 2024
1 parent f544151 commit 63f4205
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 3 deletions.
19 changes: 18 additions & 1 deletion include/prism.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,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 +63,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 +80,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 +101,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 +118,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 +128,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 \memberof pm_buffer_t
*/
void pm_serialize_comment_list(pm_parser_t *parser, pm_list_t *list, pm_buffer_t *buffer);

Expand All @@ -129,6 +137,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 \memberof pm_buffer_t
*/
void pm_serialize_encoding(const pm_encoding_t *encoding, pm_buffer_t *buffer);

Expand All @@ -138,6 +147,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 \memberof pm_buffer_t
*/
void pm_serialize_content(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer);

Expand All @@ -147,6 +157,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 \memberof pm_node
*/
PRISM_EXPORTED_FUNCTION void pm_serialize(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer);

Expand All @@ -157,6 +168,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 \memberof 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 +179,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 +190,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 +202,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 +215,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 \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 +245,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 \memberof 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
9 changes: 9 additions & 0 deletions include/prism/node.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
/**
* Loop through each node in the node list, writing each node to the given
* pm_node_t pointer.
* \public \related pm_node_list
*/
#define PM_NODE_LIST_FOREACH(list, index, node) \
for (size_t index = 0; index < (list)->size && ((node) = (list)->nodes[index]); index++)
Expand All @@ -22,6 +23,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 +32,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 +41,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 +58,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_parser
*/
PRISM_EXPORTED_FUNCTION void pm_node_destroy(pm_parser_t *parser, struct pm_node *node);

Expand All @@ -61,6 +67,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 +119,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 \related 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 +131,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 \related 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 @@ -192,6 +192,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 @@ -200,6 +201,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 @@ -208,6 +210,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 @@ -216,6 +219,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 @@ -224,6 +228,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 @@ -232,6 +237,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 @@ -240,6 +246,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 @@ -252,6 +259,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 @@ -269,6 +277,7 @@ PRISM_EXPORTED_FUNCTION void pm_options_main_script_set(pm_options_t *options, b
* @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 @@ -278,6 +287,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 @@ -288,6 +298,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 @@ -297,13 +308,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 \memberof 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
5 changes: 3 additions & 2 deletions include/prism/regexp.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
#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.
*/
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.
*/
typedef void (*pm_regexp_error_callback_t)(const uint8_t *start, const uint8_t *end, const char *message, void *data);

Expand All @@ -37,6 +37,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 \related 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
2 changes: 2 additions & 0 deletions include/prism/util/pm_integer.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ void pm_integers_reduce(pm_integer_t *numerator, pm_integer_t *denominator);
*
* @param buffer The buffer to append the string to.
* @param integer The integer to convert to a string.
* \public \memberof pm_integer_t
*/
PRISM_EXPORTED_FUNCTION void pm_integer_string(pm_buffer_t *buffer, const pm_integer_t *integer);

Expand All @@ -120,6 +121,7 @@ PRISM_EXPORTED_FUNCTION void pm_integer_string(pm_buffer_t *buffer, const pm_int
* the integer exceeds the size of a single node in the linked list.
*
* @param integer The integer to free.
* \public \memberof pm_integer_t
*/
PRISM_EXPORTED_FUNCTION void pm_integer_free(pm_integer_t *integer);

Expand Down
Loading

0 comments on commit 63f4205

Please sign in to comment.