1// This file is autogenerated. Do not edit it!
2// See ./codegen for details.
3
4/// An element ID.
5#[allow(missing_docs)]
6#[derive(Clone, Copy, PartialEq)]
7pub enum EId {
8 A,
9 Circle,
10 ClipPath,
11 Defs,
12 Ellipse,
13 FeBlend,
14 FeColorMatrix,
15 FeComponentTransfer,
16 FeComposite,
17 FeConvolveMatrix,
18 FeDiffuseLighting,
19 FeDisplacementMap,
20 FeDistantLight,
21 FeDropShadow,
22 FeFlood,
23 FeFuncA,
24 FeFuncB,
25 FeFuncG,
26 FeFuncR,
27 FeGaussianBlur,
28 FeImage,
29 FeMerge,
30 FeMergeNode,
31 FeMorphology,
32 FeOffset,
33 FePointLight,
34 FeSpecularLighting,
35 FeSpotLight,
36 FeTile,
37 FeTurbulence,
38 Filter,
39 G,
40 Image,
41 Line,
42 LinearGradient,
43 Marker,
44 Mask,
45 Path,
46 Pattern,
47 Polygon,
48 Polyline,
49 RadialGradient,
50 Rect,
51 Stop,
52 Style,
53 Svg,
54 Switch,
55 Symbol,
56 Text,
57 TextPath,
58 Tref,
59 Tspan,
60 Use,
61}
62
63static ELEMENTS: Map<EId> = Map {
64 key: 732231254413039614,
65 disps: &[
66 (0, 12),
67 (1, 11),
68 (10, 26),
69 (2, 42),
70 (1, 19),
71 (0, 5),
72 (1, 13),
73 (8, 50),
74 (0, 0),
75 (1, 0),
76 (7, 45),
77 ],
78 entries: &[
79 ("feFlood", EId::FeFlood),
80 ("radialGradient", EId::RadialGradient),
81 ("feImage", EId::FeImage),
82 ("stop", EId::Stop),
83 ("fePointLight", EId::FePointLight),
84 ("feConvolveMatrix", EId::FeConvolveMatrix),
85 ("feComposite", EId::FeComposite),
86 ("clipPath", EId::ClipPath),
87 ("feMerge", EId::FeMerge),
88 ("defs", EId::Defs),
89 ("mask", EId::Mask),
90 ("svg", EId::Svg),
91 ("symbol", EId::Symbol),
92 ("linearGradient", EId::LinearGradient),
93 ("feSpecularLighting", EId::FeSpecularLighting),
94 ("feFuncB", EId::FeFuncB),
95 ("filter", EId::Filter),
96 ("feFuncG", EId::FeFuncG),
97 ("circle", EId::Circle),
98 ("g", EId::G),
99 ("tref", EId::Tref),
100 ("feFuncA", EId::FeFuncA),
101 ("image", EId::Image),
102 ("text", EId::Text),
103 ("line", EId::Line),
104 ("pattern", EId::Pattern),
105 ("use", EId::Use),
106 ("feDropShadow", EId::FeDropShadow),
107 ("feSpotLight", EId::FeSpotLight),
108 ("marker", EId::Marker),
109 ("style", EId::Style),
110 ("switch", EId::Switch),
111 ("tspan", EId::Tspan),
112 ("feColorMatrix", EId::FeColorMatrix),
113 ("feOffset", EId::FeOffset),
114 ("path", EId::Path),
115 ("feGaussianBlur", EId::FeGaussianBlur),
116 ("feTile", EId::FeTile),
117 ("feTurbulence", EId::FeTurbulence),
118 ("feMergeNode", EId::FeMergeNode),
119 ("feMorphology", EId::FeMorphology),
120 ("a", EId::A),
121 ("textPath", EId::TextPath),
122 ("ellipse", EId::Ellipse),
123 ("feComponentTransfer", EId::FeComponentTransfer),
124 ("feDistantLight", EId::FeDistantLight),
125 ("polyline", EId::Polyline),
126 ("polygon", EId::Polygon),
127 ("feBlend", EId::FeBlend),
128 ("feDisplacementMap", EId::FeDisplacementMap),
129 ("feDiffuseLighting", EId::FeDiffuseLighting),
130 ("rect", EId::Rect),
131 ("feFuncR", EId::FeFuncR),
132 ],
133};
134
135impl EId {
136 pub(crate) fn from_str(text: &str) -> Option<EId> {
137 ELEMENTS.get(key:text).cloned()
138 }
139
140 /// Returns the original string.
141 #[inline(never)]
142 pub fn to_str(self) -> &'static str {
143 ELEMENTS.key(&self)
144 }
145}
146
147impl std::fmt::Debug for EId {
148 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
149 write!(f, "{}", self.to_str())
150 }
151}
152
153impl std::fmt::Display for EId {
154 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
155 write!(f, "{:?}", self)
156 }
157}
158
159/// An attribute ID.
160#[allow(missing_docs)]
161#[derive(Clone, Copy, PartialEq)]
162pub enum AId {
163 AlignmentBaseline,
164 Amplitude,
165 Azimuth,
166 BaseFrequency,
167 BaselineShift,
168 Bias,
169 Class,
170 Clip,
171 ClipPath,
172 ClipRule,
173 ClipPathUnits,
174 Color,
175 ColorInterpolation,
176 ColorInterpolationFilters,
177 ColorProfile,
178 ColorRendering,
179 Cx,
180 Cy,
181 D,
182 DiffuseConstant,
183 Direction,
184 Display,
185 Divisor,
186 DominantBaseline,
187 Dx,
188 Dy,
189 EdgeMode,
190 Elevation,
191 EnableBackground,
192 Exponent,
193 Fill,
194 FillOpacity,
195 FillRule,
196 Filter,
197 FilterUnits,
198 FloodColor,
199 FloodOpacity,
200 Font,
201 FontFamily,
202 FontFeatureSettings,
203 FontKerning,
204 FontSize,
205 FontSizeAdjust,
206 FontStretch,
207 FontStyle,
208 FontSynthesis,
209 FontVariant,
210 FontVariantCaps,
211 FontVariantEastAsian,
212 FontVariantLigatures,
213 FontVariantNumeric,
214 FontVariantPosition,
215 FontWeight,
216 Fr,
217 Fx,
218 Fy,
219 GlyphOrientationHorizontal,
220 GlyphOrientationVertical,
221 GradientTransform,
222 GradientUnits,
223 Height,
224 Href,
225 Id,
226 ImageRendering,
227 In,
228 In2,
229 InlineSize,
230 Intercept,
231 Isolation,
232 K1,
233 K2,
234 K3,
235 K4,
236 KernelMatrix,
237 KernelUnitLength,
238 Kerning,
239 LengthAdjust,
240 LetterSpacing,
241 LightingColor,
242 LimitingConeAngle,
243 LineHeight,
244 MarkerEnd,
245 MarkerMid,
246 MarkerStart,
247 MarkerHeight,
248 MarkerUnits,
249 MarkerWidth,
250 Mask,
251 MaskBorder,
252 MaskBorderMode,
253 MaskBorderOutset,
254 MaskBorderRepeat,
255 MaskBorderSlice,
256 MaskBorderSource,
257 MaskBorderWidth,
258 MaskClip,
259 MaskComposite,
260 MaskImage,
261 MaskMode,
262 MaskOrigin,
263 MaskPosition,
264 MaskSize,
265 MaskType,
266 MaskContentUnits,
267 MaskUnits,
268 MixBlendMode,
269 Mode,
270 NumOctaves,
271 Offset,
272 Opacity,
273 Operator,
274 Order,
275 Orient,
276 Overflow,
277 PaintOrder,
278 Path,
279 PathLength,
280 PatternContentUnits,
281 PatternTransform,
282 PatternUnits,
283 Points,
284 PointsAtX,
285 PointsAtY,
286 PointsAtZ,
287 PreserveAlpha,
288 PreserveAspectRatio,
289 PrimitiveUnits,
290 R,
291 Radius,
292 RefX,
293 RefY,
294 RequiredExtensions,
295 RequiredFeatures,
296 Result,
297 Rotate,
298 Rx,
299 Ry,
300 Scale,
301 Seed,
302 ShapeImageThreshold,
303 ShapeInside,
304 ShapeMargin,
305 ShapePadding,
306 ShapeRendering,
307 ShapeSubtract,
308 Side,
309 Slope,
310 Space,
311 SpecularConstant,
312 SpecularExponent,
313 SpreadMethod,
314 StartOffset,
315 StdDeviation,
316 StitchTiles,
317 StopColor,
318 StopOpacity,
319 Stroke,
320 StrokeDasharray,
321 StrokeDashoffset,
322 StrokeLinecap,
323 StrokeLinejoin,
324 StrokeMiterlimit,
325 StrokeOpacity,
326 StrokeWidth,
327 Style,
328 SurfaceScale,
329 SystemLanguage,
330 TableValues,
331 TargetX,
332 TargetY,
333 TextAlign,
334 TextAlignLast,
335 TextAnchor,
336 TextDecoration,
337 TextDecorationColor,
338 TextDecorationFill,
339 TextDecorationLine,
340 TextDecorationStroke,
341 TextDecorationStyle,
342 TextIndent,
343 TextOrientation,
344 TextOverflow,
345 TextRendering,
346 TextUnderlinePosition,
347 TextLength,
348 Transform,
349 TransformBox,
350 TransformOrigin,
351 Type,
352 UnicodeBidi,
353 UnicodeRange,
354 Values,
355 VectorEffect,
356 ViewBox,
357 Visibility,
358 WhiteSpace,
359 Width,
360 WordSpacing,
361 WritingMode,
362 X,
363 X1,
364 X2,
365 XChannelSelector,
366 Y,
367 Y1,
368 Y2,
369 YChannelSelector,
370 Z,
371}
372
373static ATTRIBUTES: Map<AId> = Map {
374 key: 732231254413039614,
375 disps: &[
376 (63, 17),
377 (0, 1),
378 (0, 113),
379 (0, 21),
380 (0, 8),
381 (0, 23),
382 (0, 15),
383 (0, 3),
384 (40, 203),
385 (0, 3),
386 (0, 6),
387 (1, 31),
388 (0, 68),
389 (11, 161),
390 (0, 41),
391 (2, 58),
392 (7, 10),
393 (0, 0),
394 (0, 39),
395 (7, 73),
396 (0, 5),
397 (65, 30),
398 (0, 71),
399 (0, 28),
400 (0, 7),
401 (2, 99),
402 (0, 168),
403 (1, 79),
404 (0, 0),
405 (0, 3),
406 (0, 21),
407 (1, 9),
408 (0, 0),
409 (5, 171),
410 (0, 45),
411 (0, 18),
412 (99, 110),
413 (31, 206),
414 (5, 125),
415 (0, 14),
416 (0, 4),
417 (0, 83),
418 ],
419 entries: &[
420 ("mask-type", AId::MaskType),
421 ("markerWidth", AId::MarkerWidth),
422 ("textLength", AId::TextLength),
423 ("alignment-baseline", AId::AlignmentBaseline),
424 ("unicode-bidi", AId::UnicodeBidi),
425 ("dominant-baseline", AId::DominantBaseline),
426 ("orient", AId::Orient),
427 ("x", AId::X),
428 ("font-style", AId::FontStyle),
429 ("color-interpolation", AId::ColorInterpolation),
430 ("style", AId::Style),
431 ("clip-rule", AId::ClipRule),
432 ("bias", AId::Bias),
433 ("font-weight", AId::FontWeight),
434 ("fill", AId::Fill),
435 ("mask-border-outset", AId::MaskBorderOutset),
436 ("x1", AId::X1),
437 ("mask", AId::Mask),
438 ("height", AId::Height),
439 ("stroke", AId::Stroke),
440 ("transform", AId::Transform),
441 ("isolation", AId::Isolation),
442 ("fy", AId::Fy),
443 ("text-orientation", AId::TextOrientation),
444 ("stop-opacity", AId::StopOpacity),
445 ("fx", AId::Fx),
446 ("font-kerning", AId::FontKerning),
447 ("cx", AId::Cx),
448 ("maskContentUnits", AId::MaskContentUnits),
449 ("opacity", AId::Opacity),
450 ("filterUnits", AId::FilterUnits),
451 ("lengthAdjust", AId::LengthAdjust),
452 ("text-anchor", AId::TextAnchor),
453 ("stroke-miterlimit", AId::StrokeMiterlimit),
454 ("viewBox", AId::ViewBox),
455 ("visibility", AId::Visibility),
456 ("ry", AId::Ry),
457 (
458 "glyph-orientation-horizontal",
459 AId::GlyphOrientationHorizontal,
460 ),
461 ("gradientTransform", AId::GradientTransform),
462 ("markerUnits", AId::MarkerUnits),
463 ("shape-inside", AId::ShapeInside),
464 ("font-size", AId::FontSize),
465 ("yChannelSelector", AId::YChannelSelector),
466 ("clip-path", AId::ClipPath),
467 ("flood-color", AId::FloodColor),
468 ("marker-mid", AId::MarkerMid),
469 ("surfaceScale", AId::SurfaceScale),
470 ("color-profile", AId::ColorProfile),
471 ("requiredFeatures", AId::RequiredFeatures),
472 ("class", AId::Class),
473 ("startOffset", AId::StartOffset),
474 ("mask-origin", AId::MaskOrigin),
475 ("stdDeviation", AId::StdDeviation),
476 ("mode", AId::Mode),
477 ("overflow", AId::Overflow),
478 ("text-decoration-fill", AId::TextDecorationFill),
479 ("mask-border-mode", AId::MaskBorderMode),
480 ("divisor", AId::Divisor),
481 ("marker-start", AId::MarkerStart),
482 ("text-decoration-line", AId::TextDecorationLine),
483 ("preserveAlpha", AId::PreserveAlpha),
484 ("primitiveUnits", AId::PrimitiveUnits),
485 ("in", AId::In),
486 ("points", AId::Points),
487 ("pointsAtY", AId::PointsAtY),
488 ("specularExponent", AId::SpecularExponent),
489 ("shape-rendering", AId::ShapeRendering),
490 ("refY", AId::RefY),
491 ("clip", AId::Clip),
492 ("white-space", AId::WhiteSpace),
493 ("vector-effect", AId::VectorEffect),
494 ("image-rendering", AId::ImageRendering),
495 ("stitchTiles", AId::StitchTiles),
496 ("stroke-opacity", AId::StrokeOpacity),
497 ("shape-margin", AId::ShapeMargin),
498 ("y2", AId::Y2),
499 ("operator", AId::Operator),
500 ("pathLength", AId::PathLength),
501 ("order", AId::Order),
502 ("text-rendering", AId::TextRendering),
503 ("mask-border", AId::MaskBorder),
504 ("exponent", AId::Exponent),
505 (
506 "color-interpolation-filters",
507 AId::ColorInterpolationFilters,
508 ),
509 ("diffuseConstant", AId::DiffuseConstant),
510 ("space", AId::Space),
511 ("font-synthesis", AId::FontSynthesis),
512 ("direction", AId::Direction),
513 ("font-size-adjust", AId::FontSizeAdjust),
514 ("kerning", AId::Kerning),
515 ("flood-opacity", AId::FloodOpacity),
516 ("mask-border-source", AId::MaskBorderSource),
517 ("line-height", AId::LineHeight),
518 ("mix-blend-mode", AId::MixBlendMode),
519 ("scale", AId::Scale),
520 ("mask-image", AId::MaskImage),
521 ("dy", AId::Dy),
522 ("xChannelSelector", AId::XChannelSelector),
523 ("unicode-range", AId::UnicodeRange),
524 ("y", AId::Y),
525 ("fill-opacity", AId::FillOpacity),
526 ("mask-composite", AId::MaskComposite),
527 ("targetY", AId::TargetY),
528 ("writing-mode", AId::WritingMode),
529 ("transform-origin", AId::TransformOrigin),
530 ("font-variant-caps", AId::FontVariantCaps),
531 ("k2", AId::K2),
532 ("transform-box", AId::TransformBox),
533 ("text-decoration", AId::TextDecoration),
534 ("filter", AId::Filter),
535 ("enable-background", AId::EnableBackground),
536 ("word-spacing", AId::WordSpacing),
537 ("gradientUnits", AId::GradientUnits),
538 ("font-feature-settings", AId::FontFeatureSettings),
539 ("stroke-linecap", AId::StrokeLinecap),
540 ("rx", AId::Rx),
541 ("kernelUnitLength", AId::KernelUnitLength),
542 ("shape-image-threshold", AId::ShapeImageThreshold),
543 ("inline-size", AId::InlineSize),
544 ("edgeMode", AId::EdgeMode),
545 ("text-decoration-style", AId::TextDecorationStyle),
546 ("pointsAtZ", AId::PointsAtZ),
547 ("elevation", AId::Elevation),
548 ("tableValues", AId::TableValues),
549 ("kernelMatrix", AId::KernelMatrix),
550 ("patternTransform", AId::PatternTransform),
551 ("fill-rule", AId::FillRule),
552 ("color", AId::Color),
553 ("lighting-color", AId::LightingColor),
554 ("cy", AId::Cy),
555 ("fr", AId::Fr),
556 ("systemLanguage", AId::SystemLanguage),
557 ("text-indent", AId::TextIndent),
558 ("slope", AId::Slope),
559 ("font", AId::Font),
560 ("requiredExtensions", AId::RequiredExtensions),
561 ("href", AId::Href),
562 ("baseFrequency", AId::BaseFrequency),
563 ("stroke-dashoffset", AId::StrokeDashoffset),
564 ("text-decoration-stroke", AId::TextDecorationStroke),
565 ("display", AId::Display),
566 ("amplitude", AId::Amplitude),
567 ("mask-size", AId::MaskSize),
568 ("font-variant-ligatures", AId::FontVariantLigatures),
569 ("in2", AId::In2),
570 ("maskUnits", AId::MaskUnits),
571 ("k4", AId::K4),
572 ("shape-padding", AId::ShapePadding),
573 ("r", AId::R),
574 ("text-underline-position", AId::TextUnderlinePosition),
575 ("font-variant-east-asian", AId::FontVariantEastAsian),
576 ("z", AId::Z),
577 ("text-decoration-color", AId::TextDecorationColor),
578 ("intercept", AId::Intercept),
579 ("side", AId::Side),
580 ("x2", AId::X2),
581 ("mask-position", AId::MaskPosition),
582 ("pointsAtX", AId::PointsAtX),
583 ("patternUnits", AId::PatternUnits),
584 ("result", AId::Result),
585 ("baseline-shift", AId::BaselineShift),
586 ("stop-color", AId::StopColor),
587 ("k3", AId::K3),
588 ("stroke-dasharray", AId::StrokeDasharray),
589 ("y1", AId::Y1),
590 ("targetX", AId::TargetX),
591 ("stroke-width", AId::StrokeWidth),
592 ("limitingConeAngle", AId::LimitingConeAngle),
593 ("id", AId::Id),
594 ("mask-border-width", AId::MaskBorderWidth),
595 ("shape-subtract", AId::ShapeSubtract),
596 ("font-variant", AId::FontVariant),
597 ("glyph-orientation-vertical", AId::GlyphOrientationVertical),
598 ("offset", AId::Offset),
599 ("type", AId::Type),
600 ("numOctaves", AId::NumOctaves),
601 ("font-stretch", AId::FontStretch),
602 ("mask-clip", AId::MaskClip),
603 ("clipPathUnits", AId::ClipPathUnits),
604 ("path", AId::Path),
605 ("seed", AId::Seed),
606 ("font-variant-position", AId::FontVariantPosition),
607 ("rotate", AId::Rotate),
608 ("text-overflow", AId::TextOverflow),
609 ("mask-border-repeat", AId::MaskBorderRepeat),
610 ("stroke-linejoin", AId::StrokeLinejoin),
611 ("mask-mode", AId::MaskMode),
612 ("specularConstant", AId::SpecularConstant),
613 ("spreadMethod", AId::SpreadMethod),
614 ("letter-spacing", AId::LetterSpacing),
615 ("font-family", AId::FontFamily),
616 ("azimuth", AId::Azimuth),
617 ("refX", AId::RefX),
618 ("color-rendering", AId::ColorRendering),
619 ("values", AId::Values),
620 ("marker-end", AId::MarkerEnd),
621 ("font-variant-numeric", AId::FontVariantNumeric),
622 ("markerHeight", AId::MarkerHeight),
623 ("radius", AId::Radius),
624 ("width", AId::Width),
625 ("text-align-last", AId::TextAlignLast),
626 ("preserveAspectRatio", AId::PreserveAspectRatio),
627 ("patternContentUnits", AId::PatternContentUnits),
628 ("k1", AId::K1),
629 ("paint-order", AId::PaintOrder),
630 ("d", AId::D),
631 ("mask-border-slice", AId::MaskBorderSlice),
632 ("dx", AId::Dx),
633 ("text-align", AId::TextAlign),
634 ],
635};
636
637impl AId {
638 pub(crate) fn from_str(text: &str) -> Option<AId> {
639 ATTRIBUTES.get(key:text).cloned()
640 }
641
642 /// Returns the original string.
643 #[inline(never)]
644 pub fn to_str(self) -> &'static str {
645 ATTRIBUTES.key(&self)
646 }
647}
648
649impl std::fmt::Debug for AId {
650 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
651 write!(f, "{}", self.to_str())
652 }
653}
654
655impl std::fmt::Display for AId {
656 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
657 write!(f, "{:?}", self)
658 }
659}
660
661// A stripped down `phf` crate fork.
662//
663// https://github.com/sfackler/rust-phf
664
665struct Map<V: 'static> {
666 pub key: u64,
667 pub disps: &'static [(u32, u32)],
668 pub entries: &'static [(&'static str, V)],
669}
670
671impl<V: PartialEq> Map<V> {
672 fn get(&self, key: &str) -> Option<&V> {
673 let hash: u64 = hash(x:key, self.key);
674 let index: u32 = get_index(hash, self.disps, self.entries.len());
675 let entry: &(&str, V) = &self.entries[index as usize];
676 if entry.0 == key {
677 Some(&entry.1)
678 } else {
679 None
680 }
681 }
682
683 fn key(&self, value: &V) -> &'static str {
684 self.entries.iter().find(|kv: &&(&str, V)| kv.1 == *value).unwrap().0
685 }
686}
687
688#[inline]
689fn hash(x: &str, key: u64) -> u64 {
690 use std::hash::Hasher;
691
692 let mut hasher: SipHasher13 = siphasher::sip::SipHasher13::new_with_keys(key0:0, key1:key);
693 hasher.write(x.as_bytes());
694 hasher.finish()
695}
696
697#[inline]
698fn get_index(hash: u64, disps: &[(u32, u32)], len: usize) -> u32 {
699 let (g: u32, f1: u32, f2: u32) = split(hash);
700 let (d1: u32, d2: u32) = disps[(g % (disps.len() as u32)) as usize];
701 displace(f1, f2, d1, d2) % (len as u32)
702}
703
704#[inline]
705fn split(hash: u64) -> (u32, u32, u32) {
706 const BITS: u32 = 21;
707 const MASK: u64 = (1 << BITS) - 1;
708
709 (
710 (hash & MASK) as u32,
711 ((hash >> BITS) & MASK) as u32,
712 ((hash >> (2 * BITS)) & MASK) as u32,
713 )
714}
715
716#[inline]
717fn displace(f1: u32, f2: u32, d1: u32, d2: u32) -> u32 {
718 d2 + f1 * d1 + f2
719}
720