Add introspection annotations in gregex.c

Also, make the new getters follow the style of other GRegex getters,
and take a const GRegex *.
This commit is contained in:
Matthias Clasen 2010-08-08 21:29:26 -04:00
parent 14e0ad7c53
commit f9a4b4ecc7
2 changed files with 100 additions and 96 deletions

View File

@ -691,7 +691,7 @@ g_match_info_is_partial_match (const GMatchInfo *match_info)
* Use g_regex_check_replacement() to find out whether @string_to_expand * Use g_regex_check_replacement() to find out whether @string_to_expand
* contains references. * contains references.
* *
* Returns: the expanded string, or %NULL if an error occurred * Returns: (allow-none): the expanded string, or %NULL if an error occurred
* *
* Since: 2.14 * Since: 2.14
*/ */
@ -753,8 +753,8 @@ g_match_info_expand_references (const GMatchInfo *match_info,
* The string is fetched from the string passed to the match function, * The string is fetched from the string passed to the match function,
* so you cannot call this function after freeing the string. * so you cannot call this function after freeing the string.
* *
* Returns: The matched substring, or %NULL if an error occurred. * Returns: (allow-none): The matched substring, or %NULL if an error
* You have to free the string yourself * occurred. You have to free the string yourself
* *
* Since: 2.14 * Since: 2.14
*/ */
@ -786,8 +786,10 @@ g_match_info_fetch (const GMatchInfo *match_info,
* g_match_info_fetch_pos: * g_match_info_fetch_pos:
* @match_info: #GMatchInfo structure * @match_info: #GMatchInfo structure
* @match_num: number of the sub expression * @match_num: number of the sub expression
* @start_pos: pointer to location where to store the start position * @start_pos: (out) (allow-none): pointer to location where to store
* @end_pos: pointer to location where to store the end position * the start position, or %NULL
* @end_pos: (out) (allow-none): pointer to location where to store
* the end position, or %NULL
* *
* Retrieves the position in bytes of the @match_num<!-- -->'th capturing * Retrieves the position in bytes of the @match_num<!-- -->'th capturing
* parentheses. 0 is the full text of the match, 1 is the first * parentheses. 0 is the full text of the match, 1 is the first
@ -882,8 +884,8 @@ get_matched_substring_number (const GMatchInfo *match_info,
* The string is fetched from the string passed to the match function, * The string is fetched from the string passed to the match function,
* so you cannot call this function after freeing the string. * so you cannot call this function after freeing the string.
* *
* Returns: The matched substring, or %NULL if an error occurred. * Returns: (allow-none): The matched substring, or %NULL if an error
* You have to free the string yourself * occurred. You have to free the string yourself
* *
* Since: 2.14 * Since: 2.14
*/ */
@ -909,8 +911,10 @@ g_match_info_fetch_named (const GMatchInfo *match_info,
* g_match_info_fetch_named_pos: * g_match_info_fetch_named_pos:
* @match_info: #GMatchInfo structure * @match_info: #GMatchInfo structure
* @name: name of the subexpression * @name: name of the subexpression
* @start_pos: pointer to location where to store the start position * @start_pos: (out) (allow-none): pointer to location where to store
* @end_pos: pointer to location where to store the end position * the start position, or %NULL
* @end_pos: (out) (allow-none): pointer to location where to store
* the end position, or %NULL
* *
* Retrieves the position in bytes of the capturing parentheses named @name. * Retrieves the position in bytes of the capturing parentheses named @name.
* *
@ -918,9 +922,9 @@ g_match_info_fetch_named (const GMatchInfo *match_info,
* (e.g. sub pattern "X", matching "b" against "(?P&lt;X&gt;a)?b") * (e.g. sub pattern "X", matching "b" against "(?P&lt;X&gt;a)?b")
* then @start_pos and @end_pos are set to -1 and %TRUE is returned. * then @start_pos and @end_pos are set to -1 and %TRUE is returned.
* *
* Returns: %TRUE if the position was fetched, %FALSE otherwise. If * Returns: %TRUE if the position was fetched, %FALSE otherwise.
* the position cannot be fetched, @start_pos and @end_pos are left * If the position cannot be fetched, @start_pos and @end_pos
* unchanged * are left unchanged.
* *
* Since: 2.14 * Since: 2.14
*/ */
@ -963,9 +967,9 @@ g_match_info_fetch_named_pos (const GMatchInfo *match_info,
* The strings are fetched from the string passed to the match function, * The strings are fetched from the string passed to the match function,
* so you cannot call this function after freeing the string. * so you cannot call this function after freeing the string.
* *
* Returns: a %NULL-terminated array of gchar * pointers. It must be * Returns: (allow-none): a %NULL-terminated array of gchar * pointers.
* freed using g_strfreev(). If the previous match failed %NULL is * It must be freed using g_strfreev(). If the previous match failed
* returned * %NULL is returned
* *
* Since: 2.14 * Since: 2.14
*/ */
@ -1277,7 +1281,7 @@ g_regex_get_capture_count (const GRegex *regex)
* Since: 2.26 * Since: 2.26
*/ */
GRegexCompileFlags GRegexCompileFlags
g_regex_get_compile_flags (GRegex *regex) g_regex_get_compile_flags (const GRegex *regex)
{ {
g_return_val_if_fail (regex != NULL, 0); g_return_val_if_fail (regex != NULL, 0);
@ -1295,7 +1299,7 @@ g_regex_get_compile_flags (GRegex *regex)
* Since: 2.26 * Since: 2.26
*/ */
GRegexMatchFlags GRegexMatchFlags
g_regex_get_match_flags (GRegex *regex) g_regex_get_match_flags (const GRegex *regex)
{ {
g_return_val_if_fail (regex != NULL, 0); g_return_val_if_fail (regex != NULL, 0);
@ -1346,8 +1350,8 @@ g_regex_match_simple (const gchar *pattern,
* @regex: a #GRegex structure from g_regex_new() * @regex: a #GRegex structure from g_regex_new()
* @string: the string to scan for matches * @string: the string to scan for matches
* @match_options: match options * @match_options: match options
* @match_info: pointer to location where to store the #GMatchInfo, * @match_info: (out) (allow-none): pointer to location where to store
* or %NULL if you do not need it * the #GMatchInfo, or %NULL if you do not need it
* *
* Scans for a match in string for the pattern in @regex. * Scans for a match in string for the pattern in @regex.
* The @match_options are combined with the match options specified * The @match_options are combined with the match options specified
@ -1405,12 +1409,12 @@ g_regex_match (const GRegex *regex,
/** /**
* g_regex_match_full: * g_regex_match_full:
* @regex: a #GRegex structure from g_regex_new() * @regex: a #GRegex structure from g_regex_new()
* @string: the string to scan for matches * @string: (array length=string_len): the string to scan for matches
* @string_len: the length of @string, or -1 if @string is nul-terminated * @string_len: the length of @string, or -1 if @string is nul-terminated
* @start_position: starting index of the string to match * @start_position: starting index of the string to match
* @match_options: match options * @match_options: match options
* @match_info: pointer to location where to store the #GMatchInfo, * @match_info: (out) (allow-none): pointer to location where to store
* or %NULL if you do not need it * the #GMatchInfo, or %NULL if you do not need it
* @error: location to store the error occuring, or %NULL to ignore errors * @error: location to store the error occuring, or %NULL to ignore errors
* *
* Scans for a match in string for the pattern in @regex. * Scans for a match in string for the pattern in @regex.
@ -1501,8 +1505,8 @@ g_regex_match_full (const GRegex *regex,
* @regex: a #GRegex structure from g_regex_new() * @regex: a #GRegex structure from g_regex_new()
* @string: the string to scan for matches * @string: the string to scan for matches
* @match_options: match options * @match_options: match options
* @match_info: pointer to location where to store the #GMatchInfo, * @match_info: (out) (allow-none): pointer to location where to store
* or %NULL if you do not need it * the #GMatchInfo, or %NULL if you do not need it
* *
* Using the standard algorithm for regular expression matching only * Using the standard algorithm for regular expression matching only
* the longest match in the string is retrieved. This function uses * the longest match in the string is retrieved. This function uses
@ -1536,12 +1540,12 @@ g_regex_match_all (const GRegex *regex,
/** /**
* g_regex_match_all_full: * g_regex_match_all_full:
* @regex: a #GRegex structure from g_regex_new() * @regex: a #GRegex structure from g_regex_new()
* @string: the string to scan for matches * @string: (array length=string_len): the string to scan for matches
* @string_len: the length of @string, or -1 if @string is nul-terminated * @string_len: the length of @string, or -1 if @string is nul-terminated
* @start_position: starting index of the string to match * @start_position: starting index of the string to match
* @match_options: match options * @match_options: match options
* @match_info: pointer to location where to store the #GMatchInfo, * @match_info: (out) (allow-none): pointer to location where to store
* or %NULL if you do not need it * the #GMatchInfo, or %NULL if you do not need it
* @error: location to store the error occuring, or %NULL to ignore errors * @error: location to store the error occuring, or %NULL to ignore errors
* *
* Using the standard algorithm for regular expression matching only * Using the standard algorithm for regular expression matching only
@ -1775,7 +1779,7 @@ g_regex_split (const GRegex *regex,
/** /**
* g_regex_split_full: * g_regex_split_full:
* @regex: a #GRegex structure * @regex: a #GRegex structure
* @string: the string to split with the pattern * @string: (array length=string_len): the string to split with the pattern
* @string_len: the length of @string, or -1 if @string is nul-terminated * @string_len: the length of @string, or -1 if @string is nul-terminated
* @start_position: starting index of the string to match * @start_position: starting index of the string to match
* @match_options: match time option flags * @match_options: match time option flags
@ -2405,7 +2409,7 @@ interpolation_list_needs_match (GList *list)
/** /**
* g_regex_replace: * g_regex_replace:
* @regex: a #GRegex structure * @regex: a #GRegex structure
* @string: the string to perform matches against * @string: (array length=string_len): the string to perform matches against
* @string_len: the length of @string, or -1 if @string is nul-terminated * @string_len: the length of @string, or -1 if @string is nul-terminated
* @start_position: starting index of the string to match * @start_position: starting index of the string to match
* @replacement: text to replace each match with * @replacement: text to replace each match with
@ -2517,7 +2521,7 @@ literal_replacement (const GMatchInfo *match_info,
/** /**
* g_regex_replace_literal: * g_regex_replace_literal:
* @regex: a #GRegex structure * @regex: a #GRegex structure
* @string: the string to perform matches against * @string: (array length=string_len): the string to perform matches against
* @string_len: the length of @string, or -1 if @string is nul-terminated * @string_len: the length of @string, or -1 if @string is nul-terminated
* @start_position: starting index of the string to match * @start_position: starting index of the string to match
* @replacement: text to replace each match with * @replacement: text to replace each match with
@ -2560,7 +2564,7 @@ g_regex_replace_literal (const GRegex *regex,
/** /**
* g_regex_replace_eval: * g_regex_replace_eval:
* @regex: a #GRegex structure from g_regex_new() * @regex: a #GRegex structure from g_regex_new()
* @string: string to perform matches against * @string (array length=string_len): string to perform matches against
* @string_len: the length of @string, or -1 if @string is nul-terminated * @string_len: the length of @string, or -1 if @string is nul-terminated
* @start_position: starting index of the string to match * @start_position: starting index of the string to match
* @match_options: options for the match * @match_options: options for the match
@ -2672,7 +2676,7 @@ g_regex_replace_eval (const GRegex *regex,
/** /**
* g_regex_check_replacement: * g_regex_check_replacement:
* @replacement: the replacement string * @replacement: the replacement string
* @has_references: location to store information about * @has_references: (out) (allow-none): location to store information about
* references in @replacement or %NULL * references in @replacement or %NULL
* @error: location to store error * @error: location to store error
* *
@ -2717,7 +2721,7 @@ g_regex_check_replacement (const gchar *replacement,
/** /**
* g_regex_escape_string: * g_regex_escape_string:
* @string: the string to escape * @string: (array length=length): the string to escape
* @length: the length of @string, or -1 if @string is nul-terminated * @length: the length of @string, or -1 if @string is nul-terminated
* *
* Escapes the special characters used for regular expressions * Escapes the special characters used for regular expressions

View File

@ -140,8 +140,8 @@ gint g_regex_get_string_number (const GRegex *regex,
gchar *g_regex_escape_string (const gchar *string, gchar *g_regex_escape_string (const gchar *string,
gint length); gint length);
GRegexCompileFlags g_regex_get_compile_flags (GRegex *regex); GRegexCompileFlags g_regex_get_compile_flags (const GRegex *regex);
GRegexMatchFlags g_regex_get_match_flags (GRegex *regex); GRegexMatchFlags g_regex_get_match_flags (const GRegex *regex);
/* Matching. */ /* Matching. */
gboolean g_regex_match_simple (const gchar *pattern, gboolean g_regex_match_simple (const gchar *pattern,