hayro_syntax/content/
ops_generated.rs

1// THIS FILE IS AUTO-GENERATED, DO NOT EDIT MANUALLY
2
3#[derive(Debug, PartialEq, Clone)]
4pub struct BeginCompatibility;
5op0!(BeginCompatibility, "BX");
6
7#[derive(Debug, PartialEq, Clone)]
8pub struct EndCompatibility;
9op0!(EndCompatibility, "EX");
10
11#[derive(Debug, PartialEq, Clone)]
12pub struct SaveState;
13op0!(SaveState, "q");
14
15#[derive(Debug, PartialEq, Clone)]
16pub struct RestoreState;
17op0!(RestoreState, "Q");
18
19#[derive(Debug, PartialEq, Clone)]
20pub struct Transform(
21    pub Number,
22    pub Number,
23    pub Number,
24    pub Number,
25    pub Number,
26    pub Number,
27);
28op6!(Transform, "cm");
29
30#[derive(Debug, PartialEq, Clone)]
31pub struct LineWidth(pub Number);
32op1!(LineWidth, "w");
33
34#[derive(Debug, PartialEq, Clone)]
35pub struct LineCap(pub Number);
36op1!(LineCap, "J");
37
38#[derive(Debug, PartialEq, Clone)]
39pub struct LineJoin(pub Number);
40op1!(LineJoin, "j");
41
42#[derive(Debug, PartialEq, Clone)]
43pub struct MiterLimit(pub Number);
44op1!(MiterLimit, "M");
45
46#[derive(Debug, PartialEq, Clone)]
47pub struct DashPattern<'a>(
48    pub Array<'a>,
49    pub Number,
50);
51op2!(DashPattern<'a>, "d");
52
53#[derive(Debug, PartialEq, Clone)]
54pub struct RenderingIntent<'a>(pub Name<'a>);
55op1!(RenderingIntent<'a>, "ri");
56
57#[derive(Debug, PartialEq, Clone)]
58pub struct FlatnessTolerance(pub Number);
59op1!(FlatnessTolerance, "i");
60
61#[derive(Debug, PartialEq, Clone)]
62pub struct SetGraphicsState<'a>(pub Name<'a>);
63op1!(SetGraphicsState<'a>, "gs");
64
65#[derive(Debug, PartialEq, Clone)]
66pub struct MoveTo(
67    pub Number,
68    pub Number,
69);
70op2!(MoveTo, "m");
71
72#[derive(Debug, PartialEq, Clone)]
73pub struct LineTo(
74    pub Number,
75    pub Number,
76);
77op2!(LineTo, "l");
78
79#[derive(Debug, PartialEq, Clone)]
80pub struct CubicTo(
81    pub Number,
82    pub Number,
83    pub Number,
84    pub Number,
85    pub Number,
86    pub Number,
87);
88op6!(CubicTo, "c");
89
90#[derive(Debug, PartialEq, Clone)]
91pub struct CubicStartTo(
92    pub Number,
93    pub Number,
94    pub Number,
95    pub Number,
96);
97op4!(CubicStartTo, "v");
98
99#[derive(Debug, PartialEq, Clone)]
100pub struct CubicEndTo(
101    pub Number,
102    pub Number,
103    pub Number,
104    pub Number,
105);
106op4!(CubicEndTo, "y");
107
108#[derive(Debug, PartialEq, Clone)]
109pub struct ClosePath;
110op0!(ClosePath, "h");
111
112#[derive(Debug, PartialEq, Clone)]
113pub struct RectPath(
114    pub Number,
115    pub Number,
116    pub Number,
117    pub Number,
118);
119op4!(RectPath, "re");
120
121#[derive(Debug, PartialEq, Clone)]
122pub struct StrokePath;
123op0!(StrokePath, "S");
124
125#[derive(Debug, PartialEq, Clone)]
126pub struct CloseAndStrokePath;
127op0!(CloseAndStrokePath, "s");
128
129#[derive(Debug, PartialEq, Clone)]
130pub struct FillPathNonZero;
131op0!(FillPathNonZero, "f");
132
133#[derive(Debug, PartialEq, Clone)]
134pub struct FillPathNonZeroCompatibility;
135op0!(FillPathNonZeroCompatibility, "F");
136
137#[derive(Debug, PartialEq, Clone)]
138pub struct FillPathEvenOdd;
139op0!(FillPathEvenOdd, "f*");
140
141#[derive(Debug, PartialEq, Clone)]
142pub struct FillAndStrokeNonZero;
143op0!(FillAndStrokeNonZero, "B");
144
145#[derive(Debug, PartialEq, Clone)]
146pub struct FillAndStrokeEvenOdd;
147op0!(FillAndStrokeEvenOdd, "B*");
148
149#[derive(Debug, PartialEq, Clone)]
150pub struct CloseFillAndStrokeNonZero;
151op0!(CloseFillAndStrokeNonZero, "b");
152
153#[derive(Debug, PartialEq, Clone)]
154pub struct CloseFillAndStrokeEvenOdd;
155op0!(CloseFillAndStrokeEvenOdd, "b*");
156
157#[derive(Debug, PartialEq, Clone)]
158pub struct EndPath;
159op0!(EndPath, "n");
160
161#[derive(Debug, PartialEq, Clone)]
162pub struct ClipNonZero;
163op0!(ClipNonZero, "W");
164
165#[derive(Debug, PartialEq, Clone)]
166pub struct ClipEvenOdd;
167op0!(ClipEvenOdd, "W*");
168
169#[derive(Debug, PartialEq, Clone)]
170pub struct ColorSpaceStroke<'a>(pub Name<'a>);
171op1!(ColorSpaceStroke<'a>, "CS");
172
173#[derive(Debug, PartialEq, Clone)]
174pub struct ColorSpaceNonStroke<'a>(pub Name<'a>);
175op1!(ColorSpaceNonStroke<'a>, "cs");
176
177#[derive(Debug, PartialEq, Clone)]
178pub struct StrokeColor(pub SmallVec<[Number; OPERANDS_THRESHOLD]>);
179op_all!(StrokeColor, "SC");
180
181#[derive(Debug, PartialEq, Clone)]
182pub struct NonStrokeColor(pub SmallVec<[Number; OPERANDS_THRESHOLD]>);
183op_all!(NonStrokeColor, "sc");
184
185#[derive(Debug, PartialEq, Clone)]
186pub struct StrokeColorDeviceGray(pub Number);
187op1!(StrokeColorDeviceGray, "G");
188
189#[derive(Debug, PartialEq, Clone)]
190pub struct NonStrokeColorDeviceGray(pub Number);
191op1!(NonStrokeColorDeviceGray, "g");
192
193#[derive(Debug, PartialEq, Clone)]
194pub struct StrokeColorDeviceRgb(
195    pub Number,
196    pub Number,
197    pub Number,
198);
199op3!(StrokeColorDeviceRgb, "RG");
200
201#[derive(Debug, PartialEq, Clone)]
202pub struct NonStrokeColorDeviceRgb(
203    pub Number,
204    pub Number,
205    pub Number,
206);
207op3!(NonStrokeColorDeviceRgb, "rg");
208
209#[derive(Debug, PartialEq, Clone)]
210pub struct StrokeColorCmyk(
211    pub Number,
212    pub Number,
213    pub Number,
214    pub Number,
215);
216op4!(StrokeColorCmyk, "K");
217
218#[derive(Debug, PartialEq, Clone)]
219pub struct NonStrokeColorCmyk(
220    pub Number,
221    pub Number,
222    pub Number,
223    pub Number,
224);
225op4!(NonStrokeColorCmyk, "k");
226
227#[derive(Debug, PartialEq, Clone)]
228pub struct Shading<'a>(pub Name<'a>);
229op1!(Shading<'a>, "sh");
230
231#[derive(Debug, PartialEq, Clone)]
232pub struct XObject<'a>(pub Name<'a>);
233op1!(XObject<'a>, "Do");
234
235#[derive(Debug, PartialEq, Clone)]
236pub struct InlineImage<'a>(pub Stream<'a>);
237op1!(InlineImage<'a>, "BI");
238
239#[derive(Debug, PartialEq, Clone)]
240pub struct CharacterSpacing(pub Number);
241op1!(CharacterSpacing, "Tc");
242
243#[derive(Debug, PartialEq, Clone)]
244pub struct WordSpacing(pub Number);
245op1!(WordSpacing, "Tw");
246
247#[derive(Debug, PartialEq, Clone)]
248pub struct HorizontalScaling(pub Number);
249op1!(HorizontalScaling, "Tz");
250
251#[derive(Debug, PartialEq, Clone)]
252pub struct TextLeading(pub Number);
253op1!(TextLeading, "TL");
254
255#[derive(Debug, PartialEq, Clone)]
256pub struct TextFont<'a>(
257    pub Name<'a>,
258    pub Number,
259);
260op2!(TextFont<'a>, "Tf");
261
262#[derive(Debug, PartialEq, Clone)]
263pub struct TextRenderingMode(pub Number);
264op1!(TextRenderingMode, "Tr");
265
266#[derive(Debug, PartialEq, Clone)]
267pub struct TextRise(pub Number);
268op1!(TextRise, "Ts");
269
270#[derive(Debug, PartialEq, Clone)]
271pub struct BeginText;
272op0!(BeginText, "BT");
273
274#[derive(Debug, PartialEq, Clone)]
275pub struct EndText;
276op0!(EndText, "ET");
277
278#[derive(Debug, PartialEq, Clone)]
279pub struct NextLine(
280    pub Number,
281    pub Number,
282);
283op2!(NextLine, "Td");
284
285#[derive(Debug, PartialEq, Clone)]
286pub struct NextLineAndSetLeading(
287    pub Number,
288    pub Number,
289);
290op2!(NextLineAndSetLeading, "TD");
291
292#[derive(Debug, PartialEq, Clone)]
293pub struct SetTextMatrix(
294    pub Number,
295    pub Number,
296    pub Number,
297    pub Number,
298    pub Number,
299    pub Number,
300);
301op6!(SetTextMatrix, "Tm");
302
303#[derive(Debug, PartialEq, Clone)]
304pub struct NextLineUsingLeading;
305op0!(NextLineUsingLeading, "T*");
306
307#[derive(Debug, PartialEq, Clone)]
308pub struct ShowText<'a>(pub string::String<'a>);
309op1!(ShowText<'a>, "Tj");
310
311#[derive(Debug, PartialEq, Clone)]
312pub struct NextLineAndShowText<'a>(pub string::String<'a>);
313op1!(NextLineAndShowText<'a>, "'");
314
315#[derive(Debug, PartialEq, Clone)]
316pub struct ShowTextWithParameters<'a>(
317    pub Number,
318    pub Number,
319    pub string::String<'a>,
320);
321op3!(ShowTextWithParameters<'a>, "\"");
322
323#[derive(Debug, PartialEq, Clone)]
324pub struct ShowTexts<'a>(pub Array<'a>);
325op1!(ShowTexts<'a>, "TJ");
326
327#[derive(Debug, PartialEq, Clone)]
328pub struct ColorGlyph(
329    pub Number,
330    pub Number,
331);
332op2!(ColorGlyph, "d0");
333
334#[derive(Debug, PartialEq, Clone)]
335pub struct ShapeGlyph(
336    pub Number,
337    pub Number,
338    pub Number,
339    pub Number,
340    pub Number,
341    pub Number,
342);
343op6!(ShapeGlyph, "d1");
344
345#[derive(Debug, PartialEq, Clone)]
346pub struct MarkedContentPoint<'a>(pub Name<'a>);
347op1!(MarkedContentPoint<'a>, "MP");
348
349#[derive(Debug, PartialEq, Clone)]
350pub struct MarkedContentPointWithProperties<'a>(
351    pub Name<'a>,
352    pub Object<'a>,
353);
354op2!(MarkedContentPointWithProperties<'a>, "DP");
355
356#[derive(Debug, PartialEq, Clone)]
357pub struct BeginMarkedContent<'a>(pub Name<'a>);
358op1!(BeginMarkedContent<'a>, "BMC");
359
360#[derive(Debug, PartialEq, Clone)]
361pub struct BeginMarkedContentWithProperties<'a>(
362    pub Name<'a>,
363    pub Object<'a>,
364);
365op2!(BeginMarkedContentWithProperties<'a>, "BDC");
366
367#[derive(Debug, PartialEq, Clone)]
368pub struct EndMarkedContent;
369op0!(EndMarkedContent, "EMC");
370
371#[derive(Debug, PartialEq, Clone)]
372pub enum TypedOperation<'a> {
373    BeginCompatibility(BeginCompatibility),
374    EndCompatibility(EndCompatibility),
375    SaveState(SaveState),
376    RestoreState(RestoreState),
377    Transform(Transform),
378    LineWidth(LineWidth),
379    LineCap(LineCap),
380    LineJoin(LineJoin),
381    MiterLimit(MiterLimit),
382    DashPattern(DashPattern<'a>),
383    RenderingIntent(RenderingIntent<'a>),
384    FlatnessTolerance(FlatnessTolerance),
385    SetGraphicsState(SetGraphicsState<'a>),
386    MoveTo(MoveTo),
387    LineTo(LineTo),
388    CubicTo(CubicTo),
389    CubicStartTo(CubicStartTo),
390    CubicEndTo(CubicEndTo),
391    ClosePath(ClosePath),
392    RectPath(RectPath),
393    StrokePath(StrokePath),
394    CloseAndStrokePath(CloseAndStrokePath),
395    FillPathNonZero(FillPathNonZero),
396    FillPathNonZeroCompatibility(FillPathNonZeroCompatibility),
397    FillPathEvenOdd(FillPathEvenOdd),
398    FillAndStrokeNonZero(FillAndStrokeNonZero),
399    FillAndStrokeEvenOdd(FillAndStrokeEvenOdd),
400    CloseFillAndStrokeNonZero(CloseFillAndStrokeNonZero),
401    CloseFillAndStrokeEvenOdd(CloseFillAndStrokeEvenOdd),
402    EndPath(EndPath),
403    ClipNonZero(ClipNonZero),
404    ClipEvenOdd(ClipEvenOdd),
405    ColorSpaceStroke(ColorSpaceStroke<'a>),
406    ColorSpaceNonStroke(ColorSpaceNonStroke<'a>),
407    StrokeColor(StrokeColor),
408    StrokeColorNamed(StrokeColorNamed<'a>),
409    NonStrokeColor(NonStrokeColor),
410    NonStrokeColorNamed(NonStrokeColorNamed<'a>),
411    StrokeColorDeviceGray(StrokeColorDeviceGray),
412    NonStrokeColorDeviceGray(NonStrokeColorDeviceGray),
413    StrokeColorDeviceRgb(StrokeColorDeviceRgb),
414    NonStrokeColorDeviceRgb(NonStrokeColorDeviceRgb),
415    StrokeColorCmyk(StrokeColorCmyk),
416    NonStrokeColorCmyk(NonStrokeColorCmyk),
417    Shading(Shading<'a>),
418    XObject(XObject<'a>),
419    InlineImage(InlineImage<'a>),
420    CharacterSpacing(CharacterSpacing),
421    WordSpacing(WordSpacing),
422    HorizontalScaling(HorizontalScaling),
423    TextLeading(TextLeading),
424    TextFont(TextFont<'a>),
425    TextRenderingMode(TextRenderingMode),
426    TextRise(TextRise),
427    BeginText(BeginText),
428    EndText(EndText),
429    NextLine(NextLine),
430    NextLineAndSetLeading(NextLineAndSetLeading),
431    SetTextMatrix(SetTextMatrix),
432    NextLineUsingLeading(NextLineUsingLeading),
433    ShowText(ShowText<'a>),
434    NextLineAndShowText(NextLineAndShowText<'a>),
435    ShowTextWithParameters(ShowTextWithParameters<'a>),
436    ShowTexts(ShowTexts<'a>),
437    ColorGlyph(ColorGlyph),
438    ShapeGlyph(ShapeGlyph),
439    MarkedContentPoint(MarkedContentPoint<'a>),
440    MarkedContentPointWithProperties(MarkedContentPointWithProperties<'a>),
441    BeginMarkedContent(BeginMarkedContent<'a>),
442    BeginMarkedContentWithProperties(BeginMarkedContentWithProperties<'a>),
443    EndMarkedContent(EndMarkedContent),
444    Fallback,
445}
446
447impl<'a> TypedOperation<'a> {
448    pub(crate) fn dispatch(operation: &Operation<'a>) -> Option<TypedOperation<'a>> {
449        let op_name = operation.operator.as_ref();
450        Some(match op_name {
451            b"BX" => BeginCompatibility::from_stack(&operation.operands)?.into(),
452            b"EX" => EndCompatibility::from_stack(&operation.operands)?.into(),
453            b"q" => SaveState::from_stack(&operation.operands)?.into(),
454            b"Q" => RestoreState::from_stack(&operation.operands)?.into(),
455            b"cm" => Transform::from_stack(&operation.operands)?.into(),
456            b"w" => LineWidth::from_stack(&operation.operands)?.into(),
457            b"J" => LineCap::from_stack(&operation.operands)?.into(),
458            b"j" => LineJoin::from_stack(&operation.operands)?.into(),
459            b"M" => MiterLimit::from_stack(&operation.operands)?.into(),
460            b"d" => DashPattern::from_stack(&operation.operands)?.into(),
461            b"ri" => RenderingIntent::from_stack(&operation.operands)?.into(),
462            b"i" => FlatnessTolerance::from_stack(&operation.operands)?.into(),
463            b"gs" => SetGraphicsState::from_stack(&operation.operands)?.into(),
464            b"m" => MoveTo::from_stack(&operation.operands)?.into(),
465            b"l" => LineTo::from_stack(&operation.operands)?.into(),
466            b"c" => CubicTo::from_stack(&operation.operands)?.into(),
467            b"v" => CubicStartTo::from_stack(&operation.operands)?.into(),
468            b"y" => CubicEndTo::from_stack(&operation.operands)?.into(),
469            b"h" => ClosePath::from_stack(&operation.operands)?.into(),
470            b"re" => RectPath::from_stack(&operation.operands)?.into(),
471            b"S" => StrokePath::from_stack(&operation.operands)?.into(),
472            b"s" => CloseAndStrokePath::from_stack(&operation.operands)?.into(),
473            b"f" => FillPathNonZero::from_stack(&operation.operands)?.into(),
474            b"F" => FillPathNonZeroCompatibility::from_stack(&operation.operands)?.into(),
475            b"f*" => FillPathEvenOdd::from_stack(&operation.operands)?.into(),
476            b"B" => FillAndStrokeNonZero::from_stack(&operation.operands)?.into(),
477            b"B*" => FillAndStrokeEvenOdd::from_stack(&operation.operands)?.into(),
478            b"b" => CloseFillAndStrokeNonZero::from_stack(&operation.operands)?.into(),
479            b"b*" => CloseFillAndStrokeEvenOdd::from_stack(&operation.operands)?.into(),
480            b"n" => EndPath::from_stack(&operation.operands)?.into(),
481            b"W" => ClipNonZero::from_stack(&operation.operands)?.into(),
482            b"W*" => ClipEvenOdd::from_stack(&operation.operands)?.into(),
483            b"CS" => ColorSpaceStroke::from_stack(&operation.operands)?.into(),
484            b"cs" => ColorSpaceNonStroke::from_stack(&operation.operands)?.into(),
485            b"SC" => StrokeColor::from_stack(&operation.operands)?.into(),
486            b"SCN" => StrokeColorNamed::from_stack(&operation.operands)?.into(),
487            b"sc" => NonStrokeColor::from_stack(&operation.operands)?.into(),
488            b"scn" => NonStrokeColorNamed::from_stack(&operation.operands)?.into(),
489            b"G" => StrokeColorDeviceGray::from_stack(&operation.operands)?.into(),
490            b"g" => NonStrokeColorDeviceGray::from_stack(&operation.operands)?.into(),
491            b"RG" => StrokeColorDeviceRgb::from_stack(&operation.operands)?.into(),
492            b"rg" => NonStrokeColorDeviceRgb::from_stack(&operation.operands)?.into(),
493            b"K" => StrokeColorCmyk::from_stack(&operation.operands)?.into(),
494            b"k" => NonStrokeColorCmyk::from_stack(&operation.operands)?.into(),
495            b"sh" => Shading::from_stack(&operation.operands)?.into(),
496            b"Do" => XObject::from_stack(&operation.operands)?.into(),
497            b"BI" => InlineImage::from_stack(&operation.operands)?.into(),
498            b"Tc" => CharacterSpacing::from_stack(&operation.operands)?.into(),
499            b"Tw" => WordSpacing::from_stack(&operation.operands)?.into(),
500            b"Tz" => HorizontalScaling::from_stack(&operation.operands)?.into(),
501            b"TL" => TextLeading::from_stack(&operation.operands)?.into(),
502            b"Tf" => TextFont::from_stack(&operation.operands)?.into(),
503            b"Tr" => TextRenderingMode::from_stack(&operation.operands)?.into(),
504            b"Ts" => TextRise::from_stack(&operation.operands)?.into(),
505            b"BT" => BeginText::from_stack(&operation.operands)?.into(),
506            b"ET" => EndText::from_stack(&operation.operands)?.into(),
507            b"Td" => NextLine::from_stack(&operation.operands)?.into(),
508            b"TD" => NextLineAndSetLeading::from_stack(&operation.operands)?.into(),
509            b"Tm" => SetTextMatrix::from_stack(&operation.operands)?.into(),
510            b"T*" => NextLineUsingLeading::from_stack(&operation.operands)?.into(),
511            b"Tj" => ShowText::from_stack(&operation.operands)?.into(),
512            b"'" => NextLineAndShowText::from_stack(&operation.operands)?.into(),
513            b"\"" => ShowTextWithParameters::from_stack(&operation.operands)?.into(),
514            b"TJ" => ShowTexts::from_stack(&operation.operands)?.into(),
515            b"d0" => ColorGlyph::from_stack(&operation.operands)?.into(),
516            b"d1" => ShapeGlyph::from_stack(&operation.operands)?.into(),
517            b"MP" => MarkedContentPoint::from_stack(&operation.operands)?.into(),
518            b"DP" => MarkedContentPointWithProperties::from_stack(&operation.operands)?.into(),
519            b"BMC" => BeginMarkedContent::from_stack(&operation.operands)?.into(),
520            b"BDC" => BeginMarkedContentWithProperties::from_stack(&operation.operands)?.into(),
521            b"EMC" => EndMarkedContent::from_stack(&operation.operands)?.into(),
522            _ => return Self::Fallback.into(),
523        })
524    }
525}