1 | // sass.hpp must go before all system headers to get the |
2 | // __EXTENSIONS__ fix on Solaris. |
3 | #include "sass.hpp" |
4 | |
5 | #include "ast.hpp" |
6 | #include "color_maps.hpp" |
7 | #include "util_string.hpp" |
8 | |
9 | namespace Sass { |
10 | |
11 | namespace ColorNames |
12 | { |
13 | const char aliceblue [] = "aliceblue" ; |
14 | const char antiquewhite [] = "antiquewhite" ; |
15 | const char cyan [] = "cyan" ; |
16 | const char aqua [] = "aqua" ; |
17 | const char aquamarine [] = "aquamarine" ; |
18 | const char azure [] = "azure" ; |
19 | const char beige [] = "beige" ; |
20 | const char bisque [] = "bisque" ; |
21 | const char black [] = "black" ; |
22 | const char blanchedalmond [] = "blanchedalmond" ; |
23 | const char blue [] = "blue" ; |
24 | const char blueviolet [] = "blueviolet" ; |
25 | const char brown [] = "brown" ; |
26 | const char burlywood [] = "burlywood" ; |
27 | const char cadetblue [] = "cadetblue" ; |
28 | const char chartreuse [] = "chartreuse" ; |
29 | const char chocolate [] = "chocolate" ; |
30 | const char coral [] = "coral" ; |
31 | const char cornflowerblue [] = "cornflowerblue" ; |
32 | const char cornsilk [] = "cornsilk" ; |
33 | const char crimson [] = "crimson" ; |
34 | const char darkblue [] = "darkblue" ; |
35 | const char darkcyan [] = "darkcyan" ; |
36 | const char darkgoldenrod [] = "darkgoldenrod" ; |
37 | const char darkgray [] = "darkgray" ; |
38 | const char darkgrey [] = "darkgrey" ; |
39 | const char darkgreen [] = "darkgreen" ; |
40 | const char darkkhaki [] = "darkkhaki" ; |
41 | const char darkmagenta [] = "darkmagenta" ; |
42 | const char darkolivegreen [] = "darkolivegreen" ; |
43 | const char darkorange [] = "darkorange" ; |
44 | const char darkorchid [] = "darkorchid" ; |
45 | const char darkred [] = "darkred" ; |
46 | const char darksalmon [] = "darksalmon" ; |
47 | const char darkseagreen [] = "darkseagreen" ; |
48 | const char darkslateblue [] = "darkslateblue" ; |
49 | const char darkslategray [] = "darkslategray" ; |
50 | const char darkslategrey [] = "darkslategrey" ; |
51 | const char darkturquoise [] = "darkturquoise" ; |
52 | const char darkviolet [] = "darkviolet" ; |
53 | const char deeppink [] = "deeppink" ; |
54 | const char deepskyblue [] = "deepskyblue" ; |
55 | const char dimgray [] = "dimgray" ; |
56 | const char dimgrey [] = "dimgrey" ; |
57 | const char dodgerblue [] = "dodgerblue" ; |
58 | const char firebrick [] = "firebrick" ; |
59 | const char floralwhite [] = "floralwhite" ; |
60 | const char forestgreen [] = "forestgreen" ; |
61 | const char magenta [] = "magenta" ; |
62 | const char fuchsia [] = "fuchsia" ; |
63 | const char gainsboro [] = "gainsboro" ; |
64 | const char ghostwhite [] = "ghostwhite" ; |
65 | const char gold [] = "gold" ; |
66 | const char goldenrod [] = "goldenrod" ; |
67 | const char gray [] = "gray" ; |
68 | const char grey [] = "grey" ; |
69 | const char green [] = "green" ; |
70 | const char greenyellow [] = "greenyellow" ; |
71 | const char honeydew [] = "honeydew" ; |
72 | const char hotpink [] = "hotpink" ; |
73 | const char indianred [] = "indianred" ; |
74 | const char indigo [] = "indigo" ; |
75 | const char ivory [] = "ivory" ; |
76 | const char khaki [] = "khaki" ; |
77 | const char lavender [] = "lavender" ; |
78 | const char lavenderblush [] = "lavenderblush" ; |
79 | const char lawngreen [] = "lawngreen" ; |
80 | const char lemonchiffon [] = "lemonchiffon" ; |
81 | const char lightblue [] = "lightblue" ; |
82 | const char lightcoral [] = "lightcoral" ; |
83 | const char lightcyan [] = "lightcyan" ; |
84 | const char lightgoldenrodyellow [] = "lightgoldenrodyellow" ; |
85 | const char lightgray [] = "lightgray" ; |
86 | const char lightgrey [] = "lightgrey" ; |
87 | const char lightgreen [] = "lightgreen" ; |
88 | const char lightpink [] = "lightpink" ; |
89 | const char lightsalmon [] = "lightsalmon" ; |
90 | const char lightseagreen [] = "lightseagreen" ; |
91 | const char lightskyblue [] = "lightskyblue" ; |
92 | const char lightslategray [] = "lightslategray" ; |
93 | const char lightslategrey [] = "lightslategrey" ; |
94 | const char lightsteelblue [] = "lightsteelblue" ; |
95 | const char lightyellow [] = "lightyellow" ; |
96 | const char lime [] = "lime" ; |
97 | const char limegreen [] = "limegreen" ; |
98 | const char linen [] = "linen" ; |
99 | const char maroon [] = "maroon" ; |
100 | const char mediumaquamarine [] = "mediumaquamarine" ; |
101 | const char mediumblue [] = "mediumblue" ; |
102 | const char mediumorchid [] = "mediumorchid" ; |
103 | const char mediumpurple [] = "mediumpurple" ; |
104 | const char mediumseagreen [] = "mediumseagreen" ; |
105 | const char mediumslateblue [] = "mediumslateblue" ; |
106 | const char mediumspringgreen [] = "mediumspringgreen" ; |
107 | const char mediumturquoise [] = "mediumturquoise" ; |
108 | const char mediumvioletred [] = "mediumvioletred" ; |
109 | const char midnightblue [] = "midnightblue" ; |
110 | const char mintcream [] = "mintcream" ; |
111 | const char mistyrose [] = "mistyrose" ; |
112 | const char moccasin [] = "moccasin" ; |
113 | const char navajowhite [] = "navajowhite" ; |
114 | const char navy [] = "navy" ; |
115 | const char oldlace [] = "oldlace" ; |
116 | const char olive [] = "olive" ; |
117 | const char olivedrab [] = "olivedrab" ; |
118 | const char orange [] = "orange" ; |
119 | const char orangered [] = "orangered" ; |
120 | const char orchid [] = "orchid" ; |
121 | const char palegoldenrod [] = "palegoldenrod" ; |
122 | const char palegreen [] = "palegreen" ; |
123 | const char paleturquoise [] = "paleturquoise" ; |
124 | const char palevioletred [] = "palevioletred" ; |
125 | const char papayawhip [] = "papayawhip" ; |
126 | const char peachpuff [] = "peachpuff" ; |
127 | const char peru [] = "peru" ; |
128 | const char pink [] = "pink" ; |
129 | const char plum [] = "plum" ; |
130 | const char powderblue [] = "powderblue" ; |
131 | const char purple [] = "purple" ; |
132 | const char red [] = "red" ; |
133 | const char rosybrown [] = "rosybrown" ; |
134 | const char royalblue [] = "royalblue" ; |
135 | const char saddlebrown [] = "saddlebrown" ; |
136 | const char salmon [] = "salmon" ; |
137 | const char sandybrown [] = "sandybrown" ; |
138 | const char seagreen [] = "seagreen" ; |
139 | const char seashell [] = "seashell" ; |
140 | const char sienna [] = "sienna" ; |
141 | const char silver [] = "silver" ; |
142 | const char skyblue [] = "skyblue" ; |
143 | const char slateblue [] = "slateblue" ; |
144 | const char slategray [] = "slategray" ; |
145 | const char slategrey [] = "slategrey" ; |
146 | const char snow [] = "snow" ; |
147 | const char springgreen [] = "springgreen" ; |
148 | const char steelblue [] = "steelblue" ; |
149 | const char tan [] = "tan" ; |
150 | const char teal [] = "teal" ; |
151 | const char thistle [] = "thistle" ; |
152 | const char tomato [] = "tomato" ; |
153 | const char turquoise [] = "turquoise" ; |
154 | const char violet [] = "violet" ; |
155 | const char wheat [] = "wheat" ; |
156 | const char white [] = "white" ; |
157 | const char whitesmoke [] = "whitesmoke" ; |
158 | const char yellow [] = "yellow" ; |
159 | const char yellowgreen [] = "yellowgreen" ; |
160 | const char rebeccapurple [] = "rebeccapurple" ; |
161 | const char transparent [] = "transparent" ; |
162 | } |
163 | |
164 | namespace Colors { |
165 | const SourceSpan color_table("[COLOR TABLE]" ); |
166 | const Color_RGBA aliceblue(color_table, 240, 248, 255, 1); |
167 | const Color_RGBA antiquewhite(color_table, 250, 235, 215, 1); |
168 | const Color_RGBA cyan(color_table, 0, 255, 255, 1); |
169 | const Color_RGBA aqua(color_table, 0, 255, 255, 1); |
170 | const Color_RGBA aquamarine(color_table, 127, 255, 212, 1); |
171 | const Color_RGBA azure(color_table, 240, 255, 255, 1); |
172 | const Color_RGBA beige(color_table, 245, 245, 220, 1); |
173 | const Color_RGBA bisque(color_table, 255, 228, 196, 1); |
174 | const Color_RGBA black(color_table, 0, 0, 0, 1); |
175 | const Color_RGBA blanchedalmond(color_table, 255, 235, 205, 1); |
176 | const Color_RGBA blue(color_table, 0, 0, 255, 1); |
177 | const Color_RGBA blueviolet(color_table, 138, 43, 226, 1); |
178 | const Color_RGBA brown(color_table, 165, 42, 42, 1); |
179 | const Color_RGBA burlywood(color_table, 222, 184, 135, 1); |
180 | const Color_RGBA cadetblue(color_table, 95, 158, 160, 1); |
181 | const Color_RGBA chartreuse(color_table, 127, 255, 0, 1); |
182 | const Color_RGBA chocolate(color_table, 210, 105, 30, 1); |
183 | const Color_RGBA coral(color_table, 255, 127, 80, 1); |
184 | const Color_RGBA cornflowerblue(color_table, 100, 149, 237, 1); |
185 | const Color_RGBA cornsilk(color_table, 255, 248, 220, 1); |
186 | const Color_RGBA crimson(color_table, 220, 20, 60, 1); |
187 | const Color_RGBA darkblue(color_table, 0, 0, 139, 1); |
188 | const Color_RGBA darkcyan(color_table, 0, 139, 139, 1); |
189 | const Color_RGBA darkgoldenrod(color_table, 184, 134, 11, 1); |
190 | const Color_RGBA darkgray(color_table, 169, 169, 169, 1); |
191 | const Color_RGBA darkgrey(color_table, 169, 169, 169, 1); |
192 | const Color_RGBA darkgreen(color_table, 0, 100, 0, 1); |
193 | const Color_RGBA darkkhaki(color_table, 189, 183, 107, 1); |
194 | const Color_RGBA darkmagenta(color_table, 139, 0, 139, 1); |
195 | const Color_RGBA darkolivegreen(color_table, 85, 107, 47, 1); |
196 | const Color_RGBA darkorange(color_table, 255, 140, 0, 1); |
197 | const Color_RGBA darkorchid(color_table, 153, 50, 204, 1); |
198 | const Color_RGBA darkred(color_table, 139, 0, 0, 1); |
199 | const Color_RGBA darksalmon(color_table, 233, 150, 122, 1); |
200 | const Color_RGBA darkseagreen(color_table, 143, 188, 143, 1); |
201 | const Color_RGBA darkslateblue(color_table, 72, 61, 139, 1); |
202 | const Color_RGBA darkslategray(color_table, 47, 79, 79, 1); |
203 | const Color_RGBA darkslategrey(color_table, 47, 79, 79, 1); |
204 | const Color_RGBA darkturquoise(color_table, 0, 206, 209, 1); |
205 | const Color_RGBA darkviolet(color_table, 148, 0, 211, 1); |
206 | const Color_RGBA deeppink(color_table, 255, 20, 147, 1); |
207 | const Color_RGBA deepskyblue(color_table, 0, 191, 255, 1); |
208 | const Color_RGBA dimgray(color_table, 105, 105, 105, 1); |
209 | const Color_RGBA dimgrey(color_table, 105, 105, 105, 1); |
210 | const Color_RGBA dodgerblue(color_table, 30, 144, 255, 1); |
211 | const Color_RGBA firebrick(color_table, 178, 34, 34, 1); |
212 | const Color_RGBA floralwhite(color_table, 255, 250, 240, 1); |
213 | const Color_RGBA forestgreen(color_table, 34, 139, 34, 1); |
214 | const Color_RGBA magenta(color_table, 255, 0, 255, 1); |
215 | const Color_RGBA fuchsia(color_table, 255, 0, 255, 1); |
216 | const Color_RGBA gainsboro(color_table, 220, 220, 220, 1); |
217 | const Color_RGBA ghostwhite(color_table, 248, 248, 255, 1); |
218 | const Color_RGBA gold(color_table, 255, 215, 0, 1); |
219 | const Color_RGBA goldenrod(color_table, 218, 165, 32, 1); |
220 | const Color_RGBA gray(color_table, 128, 128, 128, 1); |
221 | const Color_RGBA grey(color_table, 128, 128, 128, 1); |
222 | const Color_RGBA green(color_table, 0, 128, 0, 1); |
223 | const Color_RGBA greenyellow(color_table, 173, 255, 47, 1); |
224 | const Color_RGBA honeydew(color_table, 240, 255, 240, 1); |
225 | const Color_RGBA hotpink(color_table, 255, 105, 180, 1); |
226 | const Color_RGBA indianred(color_table, 205, 92, 92, 1); |
227 | const Color_RGBA indigo(color_table, 75, 0, 130, 1); |
228 | const Color_RGBA ivory(color_table, 255, 255, 240, 1); |
229 | const Color_RGBA khaki(color_table, 240, 230, 140, 1); |
230 | const Color_RGBA lavender(color_table, 230, 230, 250, 1); |
231 | const Color_RGBA lavenderblush(color_table, 255, 240, 245, 1); |
232 | const Color_RGBA lawngreen(color_table, 124, 252, 0, 1); |
233 | const Color_RGBA lemonchiffon(color_table, 255, 250, 205, 1); |
234 | const Color_RGBA lightblue(color_table, 173, 216, 230, 1); |
235 | const Color_RGBA lightcoral(color_table, 240, 128, 128, 1); |
236 | const Color_RGBA lightcyan(color_table, 224, 255, 255, 1); |
237 | const Color_RGBA lightgoldenrodyellow(color_table, 250, 250, 210, 1); |
238 | const Color_RGBA lightgray(color_table, 211, 211, 211, 1); |
239 | const Color_RGBA lightgrey(color_table, 211, 211, 211, 1); |
240 | const Color_RGBA lightgreen(color_table, 144, 238, 144, 1); |
241 | const Color_RGBA lightpink(color_table, 255, 182, 193, 1); |
242 | const Color_RGBA lightsalmon(color_table, 255, 160, 122, 1); |
243 | const Color_RGBA lightseagreen(color_table, 32, 178, 170, 1); |
244 | const Color_RGBA lightskyblue(color_table, 135, 206, 250, 1); |
245 | const Color_RGBA lightslategray(color_table, 119, 136, 153, 1); |
246 | const Color_RGBA lightslategrey(color_table, 119, 136, 153, 1); |
247 | const Color_RGBA lightsteelblue(color_table, 176, 196, 222, 1); |
248 | const Color_RGBA lightyellow(color_table, 255, 255, 224, 1); |
249 | const Color_RGBA lime(color_table, 0, 255, 0, 1); |
250 | const Color_RGBA limegreen(color_table, 50, 205, 50, 1); |
251 | const Color_RGBA linen(color_table, 250, 240, 230, 1); |
252 | const Color_RGBA maroon(color_table, 128, 0, 0, 1); |
253 | const Color_RGBA mediumaquamarine(color_table, 102, 205, 170, 1); |
254 | const Color_RGBA mediumblue(color_table, 0, 0, 205, 1); |
255 | const Color_RGBA mediumorchid(color_table, 186, 85, 211, 1); |
256 | const Color_RGBA mediumpurple(color_table, 147, 112, 219, 1); |
257 | const Color_RGBA mediumseagreen(color_table, 60, 179, 113, 1); |
258 | const Color_RGBA mediumslateblue(color_table, 123, 104, 238, 1); |
259 | const Color_RGBA mediumspringgreen(color_table, 0, 250, 154, 1); |
260 | const Color_RGBA mediumturquoise(color_table, 72, 209, 204, 1); |
261 | const Color_RGBA mediumvioletred(color_table, 199, 21, 133, 1); |
262 | const Color_RGBA midnightblue(color_table, 25, 25, 112, 1); |
263 | const Color_RGBA mintcream(color_table, 245, 255, 250, 1); |
264 | const Color_RGBA mistyrose(color_table, 255, 228, 225, 1); |
265 | const Color_RGBA moccasin(color_table, 255, 228, 181, 1); |
266 | const Color_RGBA navajowhite(color_table, 255, 222, 173, 1); |
267 | const Color_RGBA navy(color_table, 0, 0, 128, 1); |
268 | const Color_RGBA oldlace(color_table, 253, 245, 230, 1); |
269 | const Color_RGBA olive(color_table, 128, 128, 0, 1); |
270 | const Color_RGBA olivedrab(color_table, 107, 142, 35, 1); |
271 | const Color_RGBA orange(color_table, 255, 165, 0, 1); |
272 | const Color_RGBA orangered(color_table, 255, 69, 0, 1); |
273 | const Color_RGBA orchid(color_table, 218, 112, 214, 1); |
274 | const Color_RGBA palegoldenrod(color_table, 238, 232, 170, 1); |
275 | const Color_RGBA palegreen(color_table, 152, 251, 152, 1); |
276 | const Color_RGBA paleturquoise(color_table, 175, 238, 238, 1); |
277 | const Color_RGBA palevioletred(color_table, 219, 112, 147, 1); |
278 | const Color_RGBA papayawhip(color_table, 255, 239, 213, 1); |
279 | const Color_RGBA peachpuff(color_table, 255, 218, 185, 1); |
280 | const Color_RGBA peru(color_table, 205, 133, 63, 1); |
281 | const Color_RGBA pink(color_table, 255, 192, 203, 1); |
282 | const Color_RGBA plum(color_table, 221, 160, 221, 1); |
283 | const Color_RGBA powderblue(color_table, 176, 224, 230, 1); |
284 | const Color_RGBA purple(color_table, 128, 0, 128, 1); |
285 | const Color_RGBA red(color_table, 255, 0, 0, 1); |
286 | const Color_RGBA rosybrown(color_table, 188, 143, 143, 1); |
287 | const Color_RGBA royalblue(color_table, 65, 105, 225, 1); |
288 | const Color_RGBA saddlebrown(color_table, 139, 69, 19, 1); |
289 | const Color_RGBA salmon(color_table, 250, 128, 114, 1); |
290 | const Color_RGBA sandybrown(color_table, 244, 164, 96, 1); |
291 | const Color_RGBA seagreen(color_table, 46, 139, 87, 1); |
292 | const Color_RGBA seashell(color_table, 255, 245, 238, 1); |
293 | const Color_RGBA sienna(color_table, 160, 82, 45, 1); |
294 | const Color_RGBA silver(color_table, 192, 192, 192, 1); |
295 | const Color_RGBA skyblue(color_table, 135, 206, 235, 1); |
296 | const Color_RGBA slateblue(color_table, 106, 90, 205, 1); |
297 | const Color_RGBA slategray(color_table, 112, 128, 144, 1); |
298 | const Color_RGBA slategrey(color_table, 112, 128, 144, 1); |
299 | const Color_RGBA snow(color_table, 255, 250, 250, 1); |
300 | const Color_RGBA springgreen(color_table, 0, 255, 127, 1); |
301 | const Color_RGBA steelblue(color_table, 70, 130, 180, 1); |
302 | const Color_RGBA tan(color_table, 210, 180, 140, 1); |
303 | const Color_RGBA teal(color_table, 0, 128, 128, 1); |
304 | const Color_RGBA thistle(color_table, 216, 191, 216, 1); |
305 | const Color_RGBA tomato(color_table, 255, 99, 71, 1); |
306 | const Color_RGBA turquoise(color_table, 64, 224, 208, 1); |
307 | const Color_RGBA violet(color_table, 238, 130, 238, 1); |
308 | const Color_RGBA wheat(color_table, 245, 222, 179, 1); |
309 | const Color_RGBA white(color_table, 255, 255, 255, 1); |
310 | const Color_RGBA whitesmoke(color_table, 245, 245, 245, 1); |
311 | const Color_RGBA yellow(color_table, 255, 255, 0, 1); |
312 | const Color_RGBA yellowgreen(color_table, 154, 205, 50, 1); |
313 | const Color_RGBA rebeccapurple(color_table, 102, 51, 153, 1); |
314 | const Color_RGBA transparent(color_table, 0, 0, 0, 0); |
315 | } |
316 | |
317 | static const auto* const colors_to_names = new std::unordered_map<int, const char*> { |
318 | { 240 * 0x10000 + 248 * 0x100 + 255, ColorNames::aliceblue }, |
319 | { 250 * 0x10000 + 235 * 0x100 + 215, ColorNames::antiquewhite }, |
320 | { 0 * 0x10000 + 255 * 0x100 + 255, ColorNames::cyan }, |
321 | { 127 * 0x10000 + 255 * 0x100 + 212, ColorNames::aquamarine }, |
322 | { 240 * 0x10000 + 255 * 0x100 + 255, ColorNames::azure }, |
323 | { 245 * 0x10000 + 245 * 0x100 + 220, ColorNames::beige }, |
324 | { 255 * 0x10000 + 228 * 0x100 + 196, ColorNames::bisque }, |
325 | { 0 * 0x10000 + 0 * 0x100 + 0, ColorNames::black }, |
326 | { 255 * 0x10000 + 235 * 0x100 + 205, ColorNames::blanchedalmond }, |
327 | { 0 * 0x10000 + 0 * 0x100 + 255, ColorNames::blue }, |
328 | { 138 * 0x10000 + 43 * 0x100 + 226, ColorNames::blueviolet }, |
329 | { 165 * 0x10000 + 42 * 0x100 + 42, ColorNames::brown }, |
330 | { 222 * 0x10000 + 184 * 0x100 + 135, ColorNames::burlywood }, |
331 | { 95 * 0x10000 + 158 * 0x100 + 160, ColorNames::cadetblue }, |
332 | { 127 * 0x10000 + 255 * 0x100 + 0, ColorNames::chartreuse }, |
333 | { 210 * 0x10000 + 105 * 0x100 + 30, ColorNames::chocolate }, |
334 | { 255 * 0x10000 + 127 * 0x100 + 80, ColorNames::coral }, |
335 | { 100 * 0x10000 + 149 * 0x100 + 237, ColorNames::cornflowerblue }, |
336 | { 255 * 0x10000 + 248 * 0x100 + 220, ColorNames::cornsilk }, |
337 | { 220 * 0x10000 + 20 * 0x100 + 60, ColorNames::crimson }, |
338 | { 0 * 0x10000 + 0 * 0x100 + 139, ColorNames::darkblue }, |
339 | { 0 * 0x10000 + 139 * 0x100 + 139, ColorNames::darkcyan }, |
340 | { 184 * 0x10000 + 134 * 0x100 + 11, ColorNames::darkgoldenrod }, |
341 | { 169 * 0x10000 + 169 * 0x100 + 169, ColorNames::darkgray }, |
342 | { 0 * 0x10000 + 100 * 0x100 + 0, ColorNames::darkgreen }, |
343 | { 189 * 0x10000 + 183 * 0x100 + 107, ColorNames::darkkhaki }, |
344 | { 139 * 0x10000 + 0 * 0x100 + 139, ColorNames::darkmagenta }, |
345 | { 85 * 0x10000 + 107 * 0x100 + 47, ColorNames::darkolivegreen }, |
346 | { 255 * 0x10000 + 140 * 0x100 + 0, ColorNames::darkorange }, |
347 | { 153 * 0x10000 + 50 * 0x100 + 204, ColorNames::darkorchid }, |
348 | { 139 * 0x10000 + 0 * 0x100 + 0, ColorNames::darkred }, |
349 | { 233 * 0x10000 + 150 * 0x100 + 122, ColorNames::darksalmon }, |
350 | { 143 * 0x10000 + 188 * 0x100 + 143, ColorNames::darkseagreen }, |
351 | { 72 * 0x10000 + 61 * 0x100 + 139, ColorNames::darkslateblue }, |
352 | { 47 * 0x10000 + 79 * 0x100 + 79, ColorNames::darkslategray }, |
353 | { 0 * 0x10000 + 206 * 0x100 + 209, ColorNames::darkturquoise }, |
354 | { 148 * 0x10000 + 0 * 0x100 + 211, ColorNames::darkviolet }, |
355 | { 255 * 0x10000 + 20 * 0x100 + 147, ColorNames::deeppink }, |
356 | { 0 * 0x10000 + 191 * 0x100 + 255, ColorNames::deepskyblue }, |
357 | { 105 * 0x10000 + 105 * 0x100 + 105, ColorNames::dimgray }, |
358 | { 30 * 0x10000 + 144 * 0x100 + 255, ColorNames::dodgerblue }, |
359 | { 178 * 0x10000 + 34 * 0x100 + 34, ColorNames::firebrick }, |
360 | { 255 * 0x10000 + 250 * 0x100 + 240, ColorNames::floralwhite }, |
361 | { 34 * 0x10000 + 139 * 0x100 + 34, ColorNames::forestgreen }, |
362 | { 255 * 0x10000 + 0 * 0x100 + 255, ColorNames::magenta }, |
363 | { 220 * 0x10000 + 220 * 0x100 + 220, ColorNames::gainsboro }, |
364 | { 248 * 0x10000 + 248 * 0x100 + 255, ColorNames::ghostwhite }, |
365 | { 255 * 0x10000 + 215 * 0x100 + 0, ColorNames::gold }, |
366 | { 218 * 0x10000 + 165 * 0x100 + 32, ColorNames::goldenrod }, |
367 | { 128 * 0x10000 + 128 * 0x100 + 128, ColorNames::gray }, |
368 | { 0 * 0x10000 + 128 * 0x100 + 0, ColorNames::green }, |
369 | { 173 * 0x10000 + 255 * 0x100 + 47, ColorNames::greenyellow }, |
370 | { 240 * 0x10000 + 255 * 0x100 + 240, ColorNames::honeydew }, |
371 | { 255 * 0x10000 + 105 * 0x100 + 180, ColorNames::hotpink }, |
372 | { 205 * 0x10000 + 92 * 0x100 + 92, ColorNames::indianred }, |
373 | { 75 * 0x10000 + 0 * 0x100 + 130, ColorNames::indigo }, |
374 | { 255 * 0x10000 + 255 * 0x100 + 240, ColorNames::ivory }, |
375 | { 240 * 0x10000 + 230 * 0x100 + 140, ColorNames::khaki }, |
376 | { 230 * 0x10000 + 230 * 0x100 + 250, ColorNames::lavender }, |
377 | { 255 * 0x10000 + 240 * 0x100 + 245, ColorNames::lavenderblush }, |
378 | { 124 * 0x10000 + 252 * 0x100 + 0, ColorNames::lawngreen }, |
379 | { 255 * 0x10000 + 250 * 0x100 + 205, ColorNames::lemonchiffon }, |
380 | { 173 * 0x10000 + 216 * 0x100 + 230, ColorNames::lightblue }, |
381 | { 240 * 0x10000 + 128 * 0x100 + 128, ColorNames::lightcoral }, |
382 | { 224 * 0x10000 + 255 * 0x100 + 255, ColorNames::lightcyan }, |
383 | { 250 * 0x10000 + 250 * 0x100 + 210, ColorNames::lightgoldenrodyellow }, |
384 | { 211 * 0x10000 + 211 * 0x100 + 211, ColorNames::lightgray }, |
385 | { 144 * 0x10000 + 238 * 0x100 + 144, ColorNames::lightgreen }, |
386 | { 255 * 0x10000 + 182 * 0x100 + 193, ColorNames::lightpink }, |
387 | { 255 * 0x10000 + 160 * 0x100 + 122, ColorNames::lightsalmon }, |
388 | { 32 * 0x10000 + 178 * 0x100 + 170, ColorNames::lightseagreen }, |
389 | { 135 * 0x10000 + 206 * 0x100 + 250, ColorNames::lightskyblue }, |
390 | { 119 * 0x10000 + 136 * 0x100 + 153, ColorNames::lightslategray }, |
391 | { 176 * 0x10000 + 196 * 0x100 + 222, ColorNames::lightsteelblue }, |
392 | { 255 * 0x10000 + 255 * 0x100 + 224, ColorNames::lightyellow }, |
393 | { 0 * 0x10000 + 255 * 0x100 + 0, ColorNames::lime }, |
394 | { 50 * 0x10000 + 205 * 0x100 + 50, ColorNames::limegreen }, |
395 | { 250 * 0x10000 + 240 * 0x100 + 230, ColorNames::linen }, |
396 | { 128 * 0x10000 + 0 * 0x100 + 0, ColorNames::maroon }, |
397 | { 102 * 0x10000 + 205 * 0x100 + 170, ColorNames::mediumaquamarine }, |
398 | { 0 * 0x10000 + 0 * 0x100 + 205, ColorNames::mediumblue }, |
399 | { 186 * 0x10000 + 85 * 0x100 + 211, ColorNames::mediumorchid }, |
400 | { 147 * 0x10000 + 112 * 0x100 + 219, ColorNames::mediumpurple }, |
401 | { 60 * 0x10000 + 179 * 0x100 + 113, ColorNames::mediumseagreen }, |
402 | { 123 * 0x10000 + 104 * 0x100 + 238, ColorNames::mediumslateblue }, |
403 | { 0 * 0x10000 + 250 * 0x100 + 154, ColorNames::mediumspringgreen }, |
404 | { 72 * 0x10000 + 209 * 0x100 + 204, ColorNames::mediumturquoise }, |
405 | { 199 * 0x10000 + 21 * 0x100 + 133, ColorNames::mediumvioletred }, |
406 | { 25 * 0x10000 + 25 * 0x100 + 112, ColorNames::midnightblue }, |
407 | { 245 * 0x10000 + 255 * 0x100 + 250, ColorNames::mintcream }, |
408 | { 255 * 0x10000 + 228 * 0x100 + 225, ColorNames::mistyrose }, |
409 | { 255 * 0x10000 + 228 * 0x100 + 181, ColorNames::moccasin }, |
410 | { 255 * 0x10000 + 222 * 0x100 + 173, ColorNames::navajowhite }, |
411 | { 0 * 0x10000 + 0 * 0x100 + 128, ColorNames::navy }, |
412 | { 253 * 0x10000 + 245 * 0x100 + 230, ColorNames::oldlace }, |
413 | { 128 * 0x10000 + 128 * 0x100 + 0, ColorNames::olive }, |
414 | { 107 * 0x10000 + 142 * 0x100 + 35, ColorNames::olivedrab }, |
415 | { 255 * 0x10000 + 165 * 0x100 + 0, ColorNames::orange }, |
416 | { 255 * 0x10000 + 69 * 0x100 + 0, ColorNames::orangered }, |
417 | { 218 * 0x10000 + 112 * 0x100 + 214, ColorNames::orchid }, |
418 | { 238 * 0x10000 + 232 * 0x100 + 170, ColorNames::palegoldenrod }, |
419 | { 152 * 0x10000 + 251 * 0x100 + 152, ColorNames::palegreen }, |
420 | { 175 * 0x10000 + 238 * 0x100 + 238, ColorNames::paleturquoise }, |
421 | { 219 * 0x10000 + 112 * 0x100 + 147, ColorNames::palevioletred }, |
422 | { 255 * 0x10000 + 239 * 0x100 + 213, ColorNames::papayawhip }, |
423 | { 255 * 0x10000 + 218 * 0x100 + 185, ColorNames::peachpuff }, |
424 | { 205 * 0x10000 + 133 * 0x100 + 63, ColorNames::peru }, |
425 | { 255 * 0x10000 + 192 * 0x100 + 203, ColorNames::pink }, |
426 | { 221 * 0x10000 + 160 * 0x100 + 221, ColorNames::plum }, |
427 | { 176 * 0x10000 + 224 * 0x100 + 230, ColorNames::powderblue }, |
428 | { 128 * 0x10000 + 0 * 0x100 + 128, ColorNames::purple }, |
429 | { 255 * 0x10000 + 0 * 0x100 + 0, ColorNames::red }, |
430 | { 188 * 0x10000 + 143 * 0x100 + 143, ColorNames::rosybrown }, |
431 | { 65 * 0x10000 + 105 * 0x100 + 225, ColorNames::royalblue }, |
432 | { 139 * 0x10000 + 69 * 0x100 + 19, ColorNames::saddlebrown }, |
433 | { 250 * 0x10000 + 128 * 0x100 + 114, ColorNames::salmon }, |
434 | { 244 * 0x10000 + 164 * 0x100 + 96, ColorNames::sandybrown }, |
435 | { 46 * 0x10000 + 139 * 0x100 + 87, ColorNames::seagreen }, |
436 | { 255 * 0x10000 + 245 * 0x100 + 238, ColorNames::seashell }, |
437 | { 160 * 0x10000 + 82 * 0x100 + 45, ColorNames::sienna }, |
438 | { 192 * 0x10000 + 192 * 0x100 + 192, ColorNames::silver }, |
439 | { 135 * 0x10000 + 206 * 0x100 + 235, ColorNames::skyblue }, |
440 | { 106 * 0x10000 + 90 * 0x100 + 205, ColorNames::slateblue }, |
441 | { 112 * 0x10000 + 128 * 0x100 + 144, ColorNames::slategray }, |
442 | { 255 * 0x10000 + 250 * 0x100 + 250, ColorNames::snow }, |
443 | { 0 * 0x10000 + 255 * 0x100 + 127, ColorNames::springgreen }, |
444 | { 70 * 0x10000 + 130 * 0x100 + 180, ColorNames::steelblue }, |
445 | { 210 * 0x10000 + 180 * 0x100 + 140, ColorNames::tan }, |
446 | { 0 * 0x10000 + 128 * 0x100 + 128, ColorNames::teal }, |
447 | { 216 * 0x10000 + 191 * 0x100 + 216, ColorNames::thistle }, |
448 | { 255 * 0x10000 + 99 * 0x100 + 71, ColorNames::tomato }, |
449 | { 64 * 0x10000 + 224 * 0x100 + 208, ColorNames::turquoise }, |
450 | { 238 * 0x10000 + 130 * 0x100 + 238, ColorNames::violet }, |
451 | { 245 * 0x10000 + 222 * 0x100 + 179, ColorNames::wheat }, |
452 | { 255 * 0x10000 + 255 * 0x100 + 255, ColorNames::white }, |
453 | { 245 * 0x10000 + 245 * 0x100 + 245, ColorNames::whitesmoke }, |
454 | { 255 * 0x10000 + 255 * 0x100 + 0, ColorNames::yellow }, |
455 | { 154 * 0x10000 + 205 * 0x100 + 50, ColorNames::yellowgreen }, |
456 | { 102 * 0x10000 + 51 * 0x100 + 153, ColorNames::rebeccapurple } |
457 | }; |
458 | |
459 | static const auto *const names_to_colors = new std::unordered_map<sass::string, const Color_RGBA*> |
460 | { |
461 | { ColorNames::aliceblue, &Colors::aliceblue }, |
462 | { ColorNames::antiquewhite, &Colors::antiquewhite }, |
463 | { ColorNames::cyan, &Colors::cyan }, |
464 | { ColorNames::aqua, &Colors::aqua }, |
465 | { ColorNames::aquamarine, &Colors::aquamarine }, |
466 | { ColorNames::azure, &Colors::azure }, |
467 | { ColorNames::beige, &Colors::beige }, |
468 | { ColorNames::bisque, &Colors::bisque }, |
469 | { ColorNames::black, &Colors::black }, |
470 | { ColorNames::blanchedalmond, &Colors::blanchedalmond }, |
471 | { ColorNames::blue, &Colors::blue }, |
472 | { ColorNames::blueviolet, &Colors::blueviolet }, |
473 | { ColorNames::brown, &Colors::brown }, |
474 | { ColorNames::burlywood, &Colors::burlywood }, |
475 | { ColorNames::cadetblue, &Colors::cadetblue }, |
476 | { ColorNames::chartreuse, &Colors::chartreuse }, |
477 | { ColorNames::chocolate, &Colors::chocolate }, |
478 | { ColorNames::coral, &Colors::coral }, |
479 | { ColorNames::cornflowerblue, &Colors::cornflowerblue }, |
480 | { ColorNames::cornsilk, &Colors::cornsilk }, |
481 | { ColorNames::crimson, &Colors::crimson }, |
482 | { ColorNames::darkblue, &Colors::darkblue }, |
483 | { ColorNames::darkcyan, &Colors::darkcyan }, |
484 | { ColorNames::darkgoldenrod, &Colors::darkgoldenrod }, |
485 | { ColorNames::darkgray, &Colors::darkgray }, |
486 | { ColorNames::darkgrey, &Colors::darkgrey }, |
487 | { ColorNames::darkgreen, &Colors::darkgreen }, |
488 | { ColorNames::darkkhaki, &Colors::darkkhaki }, |
489 | { ColorNames::darkmagenta, &Colors::darkmagenta }, |
490 | { ColorNames::darkolivegreen, &Colors::darkolivegreen }, |
491 | { ColorNames::darkorange, &Colors::darkorange }, |
492 | { ColorNames::darkorchid, &Colors::darkorchid }, |
493 | { ColorNames::darkred, &Colors::darkred }, |
494 | { ColorNames::darksalmon, &Colors::darksalmon }, |
495 | { ColorNames::darkseagreen, &Colors::darkseagreen }, |
496 | { ColorNames::darkslateblue, &Colors::darkslateblue }, |
497 | { ColorNames::darkslategray, &Colors::darkslategray }, |
498 | { ColorNames::darkslategrey, &Colors::darkslategrey }, |
499 | { ColorNames::darkturquoise, &Colors::darkturquoise }, |
500 | { ColorNames::darkviolet, &Colors::darkviolet }, |
501 | { ColorNames::deeppink, &Colors::deeppink }, |
502 | { ColorNames::deepskyblue, &Colors::deepskyblue }, |
503 | { ColorNames::dimgray, &Colors::dimgray }, |
504 | { ColorNames::dimgrey, &Colors::dimgrey }, |
505 | { ColorNames::dodgerblue, &Colors::dodgerblue }, |
506 | { ColorNames::firebrick, &Colors::firebrick }, |
507 | { ColorNames::floralwhite, &Colors::floralwhite }, |
508 | { ColorNames::forestgreen, &Colors::forestgreen }, |
509 | { ColorNames::magenta, &Colors::magenta }, |
510 | { ColorNames::fuchsia, &Colors::fuchsia }, |
511 | { ColorNames::gainsboro, &Colors::gainsboro }, |
512 | { ColorNames::ghostwhite, &Colors::ghostwhite }, |
513 | { ColorNames::gold, &Colors::gold }, |
514 | { ColorNames::goldenrod, &Colors::goldenrod }, |
515 | { ColorNames::gray, &Colors::gray }, |
516 | { ColorNames::grey, &Colors::grey }, |
517 | { ColorNames::green, &Colors::green }, |
518 | { ColorNames::greenyellow, &Colors::greenyellow }, |
519 | { ColorNames::honeydew, &Colors::honeydew }, |
520 | { ColorNames::hotpink, &Colors::hotpink }, |
521 | { ColorNames::indianred, &Colors::indianred }, |
522 | { ColorNames::indigo, &Colors::indigo }, |
523 | { ColorNames::ivory, &Colors::ivory }, |
524 | { ColorNames::khaki, &Colors::khaki }, |
525 | { ColorNames::lavender, &Colors::lavender }, |
526 | { ColorNames::lavenderblush, &Colors::lavenderblush }, |
527 | { ColorNames::lawngreen, &Colors::lawngreen }, |
528 | { ColorNames::lemonchiffon, &Colors::lemonchiffon }, |
529 | { ColorNames::lightblue, &Colors::lightblue }, |
530 | { ColorNames::lightcoral, &Colors::lightcoral }, |
531 | { ColorNames::lightcyan, &Colors::lightcyan }, |
532 | { ColorNames::lightgoldenrodyellow, &Colors::lightgoldenrodyellow }, |
533 | { ColorNames::lightgray, &Colors::lightgray }, |
534 | { ColorNames::lightgrey, &Colors::lightgrey }, |
535 | { ColorNames::lightgreen, &Colors::lightgreen }, |
536 | { ColorNames::lightpink, &Colors::lightpink }, |
537 | { ColorNames::lightsalmon, &Colors::lightsalmon }, |
538 | { ColorNames::lightseagreen, &Colors::lightseagreen }, |
539 | { ColorNames::lightskyblue, &Colors::lightskyblue }, |
540 | { ColorNames::lightslategray, &Colors::lightslategray }, |
541 | { ColorNames::lightslategrey, &Colors::lightslategrey }, |
542 | { ColorNames::lightsteelblue, &Colors::lightsteelblue }, |
543 | { ColorNames::lightyellow, &Colors::lightyellow }, |
544 | { ColorNames::lime, &Colors::lime }, |
545 | { ColorNames::limegreen, &Colors::limegreen }, |
546 | { ColorNames::linen, &Colors::linen }, |
547 | { ColorNames::maroon, &Colors::maroon }, |
548 | { ColorNames::mediumaquamarine, &Colors::mediumaquamarine }, |
549 | { ColorNames::mediumblue, &Colors::mediumblue }, |
550 | { ColorNames::mediumorchid, &Colors::mediumorchid }, |
551 | { ColorNames::mediumpurple, &Colors::mediumpurple }, |
552 | { ColorNames::mediumseagreen, &Colors::mediumseagreen }, |
553 | { ColorNames::mediumslateblue, &Colors::mediumslateblue }, |
554 | { ColorNames::mediumspringgreen, &Colors::mediumspringgreen }, |
555 | { ColorNames::mediumturquoise, &Colors::mediumturquoise }, |
556 | { ColorNames::mediumvioletred, &Colors::mediumvioletred }, |
557 | { ColorNames::midnightblue, &Colors::midnightblue }, |
558 | { ColorNames::mintcream, &Colors::mintcream }, |
559 | { ColorNames::mistyrose, &Colors::mistyrose }, |
560 | { ColorNames::moccasin, &Colors::moccasin }, |
561 | { ColorNames::navajowhite, &Colors::navajowhite }, |
562 | { ColorNames::navy, &Colors::navy }, |
563 | { ColorNames::oldlace, &Colors::oldlace }, |
564 | { ColorNames::olive, &Colors::olive }, |
565 | { ColorNames::olivedrab, &Colors::olivedrab }, |
566 | { ColorNames::orange, &Colors::orange }, |
567 | { ColorNames::orangered, &Colors::orangered }, |
568 | { ColorNames::orchid, &Colors::orchid }, |
569 | { ColorNames::palegoldenrod, &Colors::palegoldenrod }, |
570 | { ColorNames::palegreen, &Colors::palegreen }, |
571 | { ColorNames::paleturquoise, &Colors::paleturquoise }, |
572 | { ColorNames::palevioletred, &Colors::palevioletred }, |
573 | { ColorNames::papayawhip, &Colors::papayawhip }, |
574 | { ColorNames::peachpuff, &Colors::peachpuff }, |
575 | { ColorNames::peru, &Colors::peru }, |
576 | { ColorNames::pink, &Colors::pink }, |
577 | { ColorNames::plum, &Colors::plum }, |
578 | { ColorNames::powderblue, &Colors::powderblue }, |
579 | { ColorNames::purple, &Colors::purple }, |
580 | { ColorNames::red, &Colors::red }, |
581 | { ColorNames::rosybrown, &Colors::rosybrown }, |
582 | { ColorNames::royalblue, &Colors::royalblue }, |
583 | { ColorNames::saddlebrown, &Colors::saddlebrown }, |
584 | { ColorNames::salmon, &Colors::salmon }, |
585 | { ColorNames::sandybrown, &Colors::sandybrown }, |
586 | { ColorNames::seagreen, &Colors::seagreen }, |
587 | { ColorNames::seashell, &Colors::seashell }, |
588 | { ColorNames::sienna, &Colors::sienna }, |
589 | { ColorNames::silver, &Colors::silver }, |
590 | { ColorNames::skyblue, &Colors::skyblue }, |
591 | { ColorNames::slateblue, &Colors::slateblue }, |
592 | { ColorNames::slategray, &Colors::slategray }, |
593 | { ColorNames::slategrey, &Colors::slategrey }, |
594 | { ColorNames::snow, &Colors::snow }, |
595 | { ColorNames::springgreen, &Colors::springgreen }, |
596 | { ColorNames::steelblue, &Colors::steelblue }, |
597 | { ColorNames::tan, &Colors::tan }, |
598 | { ColorNames::teal, &Colors::teal }, |
599 | { ColorNames::thistle, &Colors::thistle }, |
600 | { ColorNames::tomato, &Colors::tomato }, |
601 | { ColorNames::turquoise, &Colors::turquoise }, |
602 | { ColorNames::violet, &Colors::violet }, |
603 | { ColorNames::wheat, &Colors::wheat }, |
604 | { ColorNames::white, &Colors::white }, |
605 | { ColorNames::whitesmoke, &Colors::whitesmoke }, |
606 | { ColorNames::yellow, &Colors::yellow }, |
607 | { ColorNames::yellowgreen, &Colors::yellowgreen }, |
608 | { ColorNames::rebeccapurple, &Colors::rebeccapurple }, |
609 | { ColorNames::transparent, &Colors::transparent } |
610 | }; |
611 | |
612 | const Color_RGBA* name_to_color(const char* key) |
613 | { |
614 | return name_to_color(sass::string(key)); |
615 | } |
616 | |
617 | const Color_RGBA* name_to_color(const sass::string& key) |
618 | { |
619 | // case insensitive lookup. See #2462 |
620 | sass::string lower = key; |
621 | Util::ascii_str_tolower(s: &lower); |
622 | |
623 | auto p = names_to_colors->find(x: lower); |
624 | if (p != names_to_colors->end()) { |
625 | return p->second; |
626 | } |
627 | return nullptr; |
628 | } |
629 | |
630 | const char* color_to_name(const int key) |
631 | { |
632 | auto p = colors_to_names->find(x: key); |
633 | if (p != colors_to_names->end()) { |
634 | return p->second; |
635 | } |
636 | return nullptr; |
637 | } |
638 | |
639 | const char* color_to_name(const double key) |
640 | { |
641 | return color_to_name(key: (int)key); |
642 | } |
643 | |
644 | const char* color_to_name(const Color_RGBA& c) |
645 | { |
646 | double key = c.r() * 0x10000 |
647 | + c.g() * 0x100 |
648 | + c.b(); |
649 | return color_to_name(key); |
650 | } |
651 | |
652 | } |
653 | |