hayro_syntax/content/
ops_generated.rs

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