cssparser: Get rid of _gtk_css_parser_begins_with()

Replace it with calls to gtk_css_parser_has_token().
This commit is contained in:
Benjamin Otte 2019-03-24 03:56:31 +01:00
parent 904a9d0c98
commit 684b6459f1
11 changed files with 25 additions and 38 deletions

View File

@ -361,7 +361,7 @@ gtk_css_calc_value_parse_product (GtkCssParser *parser,
if (result == NULL)
return NULL;
while (_gtk_css_parser_begins_with (parser, '*') || _gtk_css_parser_begins_with (parser, '/'))
while (TRUE)
{
if (actual_flags != GTK_CSS_PARSE_NUMBER && !is_number (result))
actual_flags = GTK_CSS_PARSE_NUMBER;
@ -391,8 +391,7 @@ gtk_css_calc_value_parse_product (GtkCssParser *parser,
}
else
{
g_assert_not_reached ();
goto fail;
break;
}
}
@ -419,7 +418,7 @@ gtk_css_calc_value_parse_sum (GtkCssParser *parser,
if (result == NULL)
return NULL;
while (_gtk_css_parser_begins_with (parser, '+') || _gtk_css_parser_begins_with (parser, '-'))
while (TRUE)
{
GtkCssValue *next, *temp;
@ -439,8 +438,7 @@ gtk_css_calc_value_parse_sum (GtkCssParser *parser,
}
else
{
g_assert_not_reached ();
goto fail;
break;
}
temp = gtk_css_number_value_add (result, next);

View File

@ -846,7 +846,7 @@ gtk_css_filter_value_parse (GtkCssParser *parser)
return NULL;
}
g_array_append_val (array, filter);
} while (!_gtk_css_parser_begins_with (parser, ';'));
} while (!gtk_css_parser_has_token (parser, GTK_CSS_TOKEN_SEMICOLON));
value = gtk_css_filter_value_alloc (array->len);
memcpy (value->filters, array->data, sizeof (GtkCssFilter) * array->len);

View File

@ -257,7 +257,7 @@ parse_declaration (GtkCssKeyframes *keyframes,
return FALSE;
if (!_gtk_css_parser_try (parser, ";", TRUE) &&
!_gtk_css_parser_begins_with (parser, '}'))
!gtk_css_parser_has_token (parser, GTK_CSS_TOKEN_CLOSE_CURLY))
{
_gtk_css_parser_error (parser, "Junk at end of value");
_gtk_css_value_unref (value);
@ -333,7 +333,7 @@ _gtk_css_keyframes_parse (GtkCssParser *parser)
keyframes = gtk_css_keyframes_new ();
while (!_gtk_css_parser_begins_with (parser, '}'))
while (!gtk_css_parser_has_token (parser, GTK_CSS_TOKEN_CLOSE_CURLY))
{
if (_gtk_css_parser_try (parser, "from", TRUE))
progress = 0;

View File

@ -98,15 +98,6 @@ _gtk_css_parser_is_eof (GtkCssParser *parser)
return *parser->data == 0;
}
gboolean
_gtk_css_parser_begins_with (GtkCssParser *parser,
char c)
{
g_return_val_if_fail (GTK_IS_CSS_PARSER (parser), TRUE);
return *parser->data == c;
}
gboolean
_gtk_css_parser_has_prefix (GtkCssParser *parser,
const char *prefix)

View File

@ -50,8 +50,6 @@ GFile * _gtk_css_parser_get_file_for_path (GtkCssParser *parser
const char *path);
gboolean _gtk_css_parser_is_eof (GtkCssParser *parser);
gboolean _gtk_css_parser_begins_with (GtkCssParser *parser,
char c);
gboolean _gtk_css_parser_has_prefix (GtkCssParser *parser,
const char *prefix);
gboolean gtk_css_parser_has_token (GtkCssParser *parser,

View File

@ -1049,8 +1049,8 @@ parse_declaration (GtkCssScanner *scanner,
return;
}
if (!_gtk_css_parser_begins_with (scanner->parser, ';') &&
!_gtk_css_parser_begins_with (scanner->parser, '}') &&
if (!gtk_css_parser_has_token (scanner->parser, GTK_CSS_TOKEN_SEMICOLON) &&
!gtk_css_parser_has_token (scanner->parser, GTK_CSS_TOKEN_CLOSE_CURLY) &&
!_gtk_css_parser_is_eof (scanner->parser))
{
gtk_css_provider_error (scanner->provider,
@ -1100,7 +1100,7 @@ check_for_semicolon:
if (!_gtk_css_parser_try (scanner->parser, ";", TRUE))
{
if (!_gtk_css_parser_begins_with (scanner->parser, '}') &&
if (!gtk_css_parser_has_token (scanner->parser, GTK_CSS_TOKEN_CLOSE_CURLY) &&
!_gtk_css_parser_is_eof (scanner->parser))
{
gtk_css_provider_error_literal (scanner->provider,
@ -1118,7 +1118,7 @@ parse_declarations (GtkCssScanner *scanner,
GtkCssRuleset *ruleset)
{
while (!_gtk_css_parser_is_eof (scanner->parser) &&
!_gtk_css_parser_begins_with (scanner->parser, '}'))
!gtk_css_parser_has_token (scanner->parser, GTK_CSS_TOKEN_CLOSE_CURLY))
{
parse_declaration (scanner, ruleset);
}
@ -1178,7 +1178,7 @@ parse_ruleset (GtkCssScanner *scanner)
static void
parse_statement (GtkCssScanner *scanner)
{
if (_gtk_css_parser_begins_with (scanner->parser, '@'))
if (gtk_css_parser_has_token (scanner->parser, GTK_CSS_TOKEN_AT_KEYWORD))
parse_at_keyword (scanner);
else
parse_ruleset (scanner);

View File

@ -1264,8 +1264,8 @@ _gtk_css_selector_parse (GtkCssParser *parser)
while ((selector = parse_simple_selector (parser, selector)) &&
!_gtk_css_parser_is_eof (parser) &&
!_gtk_css_parser_begins_with (parser, ',') &&
!_gtk_css_parser_begins_with (parser, '{'))
!gtk_css_parser_has_token (parser, GTK_CSS_TOKEN_COMMA) &&
!gtk_css_parser_has_token (parser, GTK_CSS_TOKEN_OPEN_CURLY))
{
if (_gtk_css_parser_try (parser, "+", TRUE))
selector = gtk_css_selector_new (&GTK_CSS_SELECTOR_ADJACENT, selector);

View File

@ -205,9 +205,9 @@ static gboolean
value_is_done_parsing (GtkCssParser *parser)
{
return _gtk_css_parser_is_eof (parser) ||
_gtk_css_parser_begins_with (parser, ',') ||
_gtk_css_parser_begins_with (parser, ';') ||
_gtk_css_parser_begins_with (parser, '}');
gtk_css_parser_has_token (parser, GTK_CSS_TOKEN_COMMA) ||
gtk_css_parser_has_token (parser, GTK_CSS_TOKEN_SEMICOLON) ||
gtk_css_parser_has_token (parser, GTK_CSS_TOKEN_CLOSE_CURLY);
}
GtkCssValue *

View File

@ -51,9 +51,9 @@ static gboolean
value_is_done_parsing (GtkCssParser *parser)
{
return _gtk_css_parser_is_eof (parser) ||
_gtk_css_parser_begins_with (parser, ',') ||
_gtk_css_parser_begins_with (parser, ';') ||
_gtk_css_parser_begins_with (parser, '}');
gtk_css_parser_has_token (parser, GTK_CSS_TOKEN_COMMA) ||
gtk_css_parser_has_token (parser, GTK_CSS_TOKEN_SEMICOLON) ||
gtk_css_parser_has_token (parser, GTK_CSS_TOKEN_CLOSE_CURLY);
}
static gboolean
@ -617,7 +617,7 @@ parse_one_transition (GtkCssShorthandProperty *shorthand,
{
/* the image part */
if (values[2] == NULL &&
gtk_css_number_value_can_parse (parser) && !_gtk_css_parser_begins_with (parser, '-'))
gtk_css_number_value_can_parse (parser))
{
GtkCssValue *number = _gtk_css_number_value_parse (parser, GTK_CSS_PARSE_TIME);

View File

@ -466,9 +466,9 @@ static gboolean
value_is_done_parsing (GtkCssParser *parser)
{
return _gtk_css_parser_is_eof (parser) ||
_gtk_css_parser_begins_with (parser, ',') ||
_gtk_css_parser_begins_with (parser, ';') ||
_gtk_css_parser_begins_with (parser, '}');
gtk_css_parser_has_token (parser, GTK_CSS_TOKEN_COMMA) ||
gtk_css_parser_has_token (parser, GTK_CSS_TOKEN_SEMICOLON) ||
gtk_css_parser_has_token (parser, GTK_CSS_TOKEN_CLOSE_CURLY);
}
static GtkCssValue *

View File

@ -1179,7 +1179,7 @@ _gtk_css_transform_value_parse (GtkCssParser *parser)
return NULL;
}
g_array_append_val (array, transform);
} while (!_gtk_css_parser_begins_with (parser, ';'));
} while (!gtk_css_parser_has_token (parser, GTK_CSS_TOKEN_SEMICOLON));
value = gtk_css_transform_value_alloc (array->len);
memcpy (value->transforms, array->data, sizeof (GtkCssTransform) * array->len);