csstokenizer: Add save() and restore()

We'll need that to check if property values contain variables.
This commit is contained in:
Alice Mikhaylenko 2024-03-20 22:05:13 +04:00
parent 46ab71fc8a
commit 2437a551ec
2 changed files with 26 additions and 0 deletions

View File

@ -36,6 +36,9 @@ struct _GtkCssTokenizer
const char *end;
GtkCssLocation position;
GtkCssLocation saved_position;
const char *saved_data;
};
void
@ -1484,3 +1487,23 @@ gtk_css_tokenizer_read_token (GtkCssTokenizer *tokenizer,
}
}
void
gtk_css_tokenizer_save (GtkCssTokenizer *tokenizer)
{
g_assert (!tokenizer->saved_data);
tokenizer->saved_position = tokenizer->position;
tokenizer->saved_data = tokenizer->data;
}
void
gtk_css_tokenizer_restore (GtkCssTokenizer *tokenizer)
{
g_assert (tokenizer->saved_data);
tokenizer->position = tokenizer->saved_position;
tokenizer->data = tokenizer->saved_data;
gtk_css_location_init (&tokenizer->saved_position);
tokenizer->saved_data = NULL;
}

View File

@ -148,5 +148,8 @@ gboolean gtk_css_tokenizer_read_token (GtkCssTokenizer
GtkCssToken *token,
GError **error);
void gtk_css_tokenizer_save (GtkCssTokenizer *tokenizer);
void gtk_css_tokenizer_restore (GtkCssTokenizer *tokenizer);
G_END_DECLS