1 | /* GSK - The GIMP Toolkit |
2 | * Copyright (C) 2011 Benjamin Otte <otte@gnome.org> |
3 | * |
4 | * This library is free software; you can redistribute it and/or |
5 | * modify it under the terms of the GNU Lesser General Public |
6 | * License as published by the Free Software Foundation; either |
7 | * version 2 of the License, or (at your option) any later version. |
8 | * |
9 | * This library is distributed in the hope that it will be useful, |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 | * Lesser General Public License for more details. |
13 | * |
14 | * You should have received a copy of the GNU Lesser General Public |
15 | * License along with this library. If not, see <http://www.gnu.org/licenses/>. |
16 | */ |
17 | |
18 | #ifndef __GTK_CSS_TOKENIZER_PRIVATE_H__ |
19 | #define __GTK_CSS_TOKENIZER_PRIVATE_H__ |
20 | |
21 | #include <glib.h> |
22 | |
23 | #include <gtk/css/gtkcsslocation.h> |
24 | |
25 | G_BEGIN_DECLS |
26 | |
27 | typedef enum { |
28 | /* no content */ |
29 | GTK_CSS_TOKEN_EOF, |
30 | GTK_CSS_TOKEN_WHITESPACE, |
31 | GTK_CSS_TOKEN_OPEN_PARENS, |
32 | GTK_CSS_TOKEN_CLOSE_PARENS, |
33 | GTK_CSS_TOKEN_OPEN_SQUARE, |
34 | GTK_CSS_TOKEN_CLOSE_SQUARE, |
35 | GTK_CSS_TOKEN_OPEN_CURLY, |
36 | GTK_CSS_TOKEN_CLOSE_CURLY, |
37 | GTK_CSS_TOKEN_COMMA, |
38 | GTK_CSS_TOKEN_COLON, |
39 | GTK_CSS_TOKEN_SEMICOLON, |
40 | GTK_CSS_TOKEN_CDO, |
41 | GTK_CSS_TOKEN_CDC, |
42 | GTK_CSS_TOKEN_INCLUDE_MATCH, |
43 | GTK_CSS_TOKEN_DASH_MATCH, |
44 | GTK_CSS_TOKEN_PREFIX_MATCH, |
45 | GTK_CSS_TOKEN_SUFFIX_MATCH, |
46 | GTK_CSS_TOKEN_SUBSTRING_MATCH, |
47 | GTK_CSS_TOKEN_COLUMN, |
48 | GTK_CSS_TOKEN_BAD_STRING, |
49 | GTK_CSS_TOKEN_BAD_URL, |
50 | , |
51 | /* delim */ |
52 | GTK_CSS_TOKEN_DELIM, |
53 | /* string */ |
54 | GTK_CSS_TOKEN_STRING, |
55 | GTK_CSS_TOKEN_IDENT, |
56 | GTK_CSS_TOKEN_FUNCTION, |
57 | GTK_CSS_TOKEN_AT_KEYWORD, |
58 | GTK_CSS_TOKEN_HASH_UNRESTRICTED, |
59 | GTK_CSS_TOKEN_HASH_ID, |
60 | GTK_CSS_TOKEN_URL, |
61 | /* number */ |
62 | GTK_CSS_TOKEN_SIGNED_INTEGER, |
63 | GTK_CSS_TOKEN_SIGNLESS_INTEGER, |
64 | GTK_CSS_TOKEN_SIGNED_NUMBER, |
65 | GTK_CSS_TOKEN_SIGNLESS_NUMBER, |
66 | GTK_CSS_TOKEN_PERCENTAGE, |
67 | /* dimension */ |
68 | GTK_CSS_TOKEN_SIGNED_INTEGER_DIMENSION, |
69 | GTK_CSS_TOKEN_SIGNLESS_INTEGER_DIMENSION, |
70 | GTK_CSS_TOKEN_SIGNED_DIMENSION, |
71 | GTK_CSS_TOKEN_SIGNLESS_DIMENSION |
72 | } GtkCssTokenType; |
73 | |
74 | typedef union _GtkCssToken GtkCssToken; |
75 | typedef struct _GtkCssTokenizer GtkCssTokenizer; |
76 | |
77 | typedef struct _GtkCssStringToken GtkCssStringToken; |
78 | typedef struct _GtkCssDelimToken GtkCssDelimToken; |
79 | typedef struct _GtkCssNumberToken GtkCssNumberToken; |
80 | typedef struct _GtkCssDimensionToken GtkCssDimensionToken; |
81 | |
82 | struct _GtkCssStringToken { |
83 | GtkCssTokenType type; |
84 | char *string; |
85 | }; |
86 | |
87 | struct _GtkCssDelimToken { |
88 | GtkCssTokenType type; |
89 | gunichar delim; |
90 | }; |
91 | |
92 | struct _GtkCssNumberToken { |
93 | GtkCssTokenType type; |
94 | double number; |
95 | }; |
96 | |
97 | struct _GtkCssDimensionToken { |
98 | GtkCssTokenType type; |
99 | double value; |
100 | char *dimension; |
101 | }; |
102 | |
103 | union _GtkCssToken { |
104 | GtkCssTokenType type; |
105 | GtkCssStringToken string; |
106 | GtkCssDelimToken delim; |
107 | GtkCssNumberToken number; |
108 | GtkCssDimensionToken dimension; |
109 | }; |
110 | |
111 | void gtk_css_token_clear (GtkCssToken *token); |
112 | |
113 | gboolean gtk_css_token_is_finite (const GtkCssToken *token) G_GNUC_PURE; |
114 | gboolean gtk_css_token_is_preserved (const GtkCssToken *token, |
115 | GtkCssTokenType *out_closing) G_GNUC_PURE; |
116 | #define gtk_css_token_is(token, _type) ((token)->type == (_type)) |
117 | gboolean gtk_css_token_is_ident (const GtkCssToken *token, |
118 | const char *ident) G_GNUC_PURE; |
119 | gboolean gtk_css_token_is_function (const GtkCssToken *token, |
120 | const char *ident) G_GNUC_PURE; |
121 | gboolean gtk_css_token_is_delim (const GtkCssToken *token, |
122 | gunichar delim) G_GNUC_PURE; |
123 | |
124 | void gtk_css_token_print (const GtkCssToken *token, |
125 | GString *string); |
126 | char * gtk_css_token_to_string (const GtkCssToken *token); |
127 | |
128 | GtkCssTokenizer * gtk_css_tokenizer_new (GBytes *bytes); |
129 | |
130 | GtkCssTokenizer * gtk_css_tokenizer_ref (GtkCssTokenizer *tokenizer); |
131 | void gtk_css_tokenizer_unref (GtkCssTokenizer *tokenizer); |
132 | |
133 | const GtkCssLocation * gtk_css_tokenizer_get_location (GtkCssTokenizer *tokenizer) G_GNUC_CONST; |
134 | |
135 | gboolean gtk_css_tokenizer_read_token (GtkCssTokenizer *tokenizer, |
136 | GtkCssToken *token, |
137 | GError **error); |
138 | |
139 | G_END_DECLS |
140 | |
141 | #endif /* __GTK_CSS_TOKENIZER_PRIVATE_H__ */ |
142 | |