2016-03-04 17:40:11 +00:00
|
|
|
/* GSK - The GIMP Toolkit
|
|
|
|
* Copyright (C) 2011 Benjamin Otte <otte@gnome.org>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __GTK_CSS_TOKENIZER_PRIVATE_H__
|
|
|
|
#define __GTK_CSS_TOKENIZER_PRIVATE_H__
|
|
|
|
|
|
|
|
#include <glib.h>
|
|
|
|
|
2019-03-23 02:27:56 +00:00
|
|
|
#include <gtk/css/gtkcsslocation.h>
|
|
|
|
|
2016-03-04 17:40:11 +00:00
|
|
|
G_BEGIN_DECLS
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
/* no content */
|
|
|
|
GTK_CSS_TOKEN_EOF,
|
|
|
|
GTK_CSS_TOKEN_WHITESPACE,
|
|
|
|
GTK_CSS_TOKEN_OPEN_PARENS,
|
|
|
|
GTK_CSS_TOKEN_CLOSE_PARENS,
|
|
|
|
GTK_CSS_TOKEN_OPEN_SQUARE,
|
|
|
|
GTK_CSS_TOKEN_CLOSE_SQUARE,
|
|
|
|
GTK_CSS_TOKEN_OPEN_CURLY,
|
|
|
|
GTK_CSS_TOKEN_CLOSE_CURLY,
|
|
|
|
GTK_CSS_TOKEN_COMMA,
|
|
|
|
GTK_CSS_TOKEN_COLON,
|
|
|
|
GTK_CSS_TOKEN_SEMICOLON,
|
|
|
|
GTK_CSS_TOKEN_CDO,
|
|
|
|
GTK_CSS_TOKEN_CDC,
|
|
|
|
GTK_CSS_TOKEN_INCLUDE_MATCH,
|
|
|
|
GTK_CSS_TOKEN_DASH_MATCH,
|
|
|
|
GTK_CSS_TOKEN_PREFIX_MATCH,
|
|
|
|
GTK_CSS_TOKEN_SUFFIX_MATCH,
|
|
|
|
GTK_CSS_TOKEN_SUBSTRING_MATCH,
|
|
|
|
GTK_CSS_TOKEN_COLUMN,
|
|
|
|
GTK_CSS_TOKEN_BAD_STRING,
|
|
|
|
GTK_CSS_TOKEN_BAD_URL,
|
|
|
|
GTK_CSS_TOKEN_COMMENT,
|
|
|
|
/* delim */
|
|
|
|
GTK_CSS_TOKEN_DELIM,
|
|
|
|
/* string */
|
|
|
|
GTK_CSS_TOKEN_STRING,
|
|
|
|
GTK_CSS_TOKEN_IDENT,
|
|
|
|
GTK_CSS_TOKEN_FUNCTION,
|
|
|
|
GTK_CSS_TOKEN_AT_KEYWORD,
|
|
|
|
GTK_CSS_TOKEN_HASH_UNRESTRICTED,
|
|
|
|
GTK_CSS_TOKEN_HASH_ID,
|
|
|
|
GTK_CSS_TOKEN_URL,
|
|
|
|
/* number */
|
|
|
|
GTK_CSS_TOKEN_SIGNED_INTEGER,
|
|
|
|
GTK_CSS_TOKEN_SIGNLESS_INTEGER,
|
|
|
|
GTK_CSS_TOKEN_SIGNED_NUMBER,
|
|
|
|
GTK_CSS_TOKEN_SIGNLESS_NUMBER,
|
|
|
|
GTK_CSS_TOKEN_PERCENTAGE,
|
|
|
|
/* dimension */
|
|
|
|
GTK_CSS_TOKEN_SIGNED_INTEGER_DIMENSION,
|
|
|
|
GTK_CSS_TOKEN_SIGNLESS_INTEGER_DIMENSION,
|
|
|
|
GTK_CSS_TOKEN_DIMENSION
|
|
|
|
} GtkCssTokenType;
|
|
|
|
|
|
|
|
typedef union _GtkCssToken GtkCssToken;
|
|
|
|
typedef struct _GtkCssTokenizer GtkCssTokenizer;
|
|
|
|
|
|
|
|
typedef struct _GtkCssStringToken GtkCssStringToken;
|
|
|
|
typedef struct _GtkCssDelimToken GtkCssDelimToken;
|
|
|
|
typedef struct _GtkCssNumberToken GtkCssNumberToken;
|
|
|
|
typedef struct _GtkCssDimensionToken GtkCssDimensionToken;
|
|
|
|
|
|
|
|
struct _GtkCssStringToken {
|
|
|
|
GtkCssTokenType type;
|
|
|
|
char *string;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct _GtkCssDelimToken {
|
|
|
|
GtkCssTokenType type;
|
|
|
|
gunichar delim;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct _GtkCssNumberToken {
|
|
|
|
GtkCssTokenType type;
|
|
|
|
double number;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct _GtkCssDimensionToken {
|
|
|
|
GtkCssTokenType type;
|
|
|
|
double value;
|
|
|
|
char *dimension;
|
|
|
|
};
|
|
|
|
|
|
|
|
union _GtkCssToken {
|
|
|
|
GtkCssTokenType type;
|
|
|
|
GtkCssStringToken string;
|
|
|
|
GtkCssDelimToken delim;
|
|
|
|
GtkCssNumberToken number;
|
|
|
|
GtkCssDimensionToken dimension;
|
|
|
|
};
|
|
|
|
|
|
|
|
void gtk_css_token_clear (GtkCssToken *token);
|
|
|
|
|
2020-01-24 12:17:09 +00:00
|
|
|
gboolean gtk_css_token_is_finite (const GtkCssToken *token) G_GNUC_PURE;
|
2019-03-18 04:32:05 +00:00
|
|
|
gboolean gtk_css_token_is_preserved (const GtkCssToken *token,
|
2020-01-24 12:17:09 +00:00
|
|
|
GtkCssTokenType *out_closing) G_GNUC_PURE;
|
2016-03-04 17:40:11 +00:00
|
|
|
#define gtk_css_token_is(token, _type) ((token)->type == (_type))
|
|
|
|
gboolean gtk_css_token_is_ident (const GtkCssToken *token,
|
2020-01-24 12:17:09 +00:00
|
|
|
const char *ident) G_GNUC_PURE;
|
2016-03-04 17:40:11 +00:00
|
|
|
gboolean gtk_css_token_is_function (const GtkCssToken *token,
|
2020-01-24 12:17:09 +00:00
|
|
|
const char *ident) G_GNUC_PURE;
|
2016-03-04 17:40:11 +00:00
|
|
|
gboolean gtk_css_token_is_delim (const GtkCssToken *token,
|
2020-01-24 12:17:09 +00:00
|
|
|
gunichar delim) G_GNUC_PURE;
|
2016-03-04 17:40:11 +00:00
|
|
|
|
|
|
|
void gtk_css_token_print (const GtkCssToken *token,
|
|
|
|
GString *string);
|
|
|
|
char * gtk_css_token_to_string (const GtkCssToken *token);
|
|
|
|
|
2019-03-15 03:00:21 +00:00
|
|
|
GtkCssTokenizer * gtk_css_tokenizer_new (GBytes *bytes);
|
2016-03-04 17:40:11 +00:00
|
|
|
|
|
|
|
GtkCssTokenizer * gtk_css_tokenizer_ref (GtkCssTokenizer *tokenizer);
|
|
|
|
void gtk_css_tokenizer_unref (GtkCssTokenizer *tokenizer);
|
|
|
|
|
|
|
|
const GtkCssLocation * gtk_css_tokenizer_get_location (GtkCssTokenizer *tokenizer);
|
|
|
|
|
2019-03-15 03:00:21 +00:00
|
|
|
gboolean gtk_css_tokenizer_read_token (GtkCssTokenizer *tokenizer,
|
|
|
|
GtkCssToken *token,
|
|
|
|
GError **error);
|
2016-03-04 17:40:11 +00:00
|
|
|
|
|
|
|
G_END_DECLS
|
|
|
|
|
|
|
|
#endif /* __GTK_CSS_TOKENIZER_PRIVATE_H__ */
|