2 * PaperJam -- Common declarations
4 * (c) 2018 Martin Mares <mj@ucw.cz>
12 typedef unsigned int uint;
14 #define NONRET __attribute__((noreturn))
15 #define UNUSED __attribute__((unused))
16 #define FORMAT_CHECK(x,y,z) __attribute__((format(x,y,z)))
18 #include "pdf-tools.h"
20 /*** Representation of commands ***/
31 AT_TYPE_MASK = 0xffff,
32 AT_MANDATORY = 0x10000,
33 AT_POSITIONAL = 0x20000,
43 virtual bool given() { return false; }
44 virtual int as_int(int def) { return def; }
45 virtual double as_double(double def) { return def; }
46 virtual const string as_string(const string def) { return def; }
47 virtual string dump() { return "<undef>"; }
51 QPDFObjectHandle resources;
52 QPDFObjectHandle xobjects;
55 string new_resource(const string type);
56 out_context() { res_cnt = 0; }
61 double width; // Physical dimensions of media
63 BBox bbox; // Bounds useful contents
64 virtual void render(out_context *out UNUSED, pdf_matrix xform UNUSED) { abort(); }
65 page(double _w=0, double _h=0) : width(_w), height(_h) { }
74 struct empty_page : public page {
75 void render(out_context *out UNUSED, pdf_matrix xform UNUSED) { }
76 empty_page(double _w=0, double _h=0) : page(_w, _h) { };
80 virtual vector<page *> process(vector <page *> &pages UNUSED) = 0;
85 const arg_def *arg_defs;
87 cmd_exec *(*constructor)(cmd *cmd);
92 vector<arg_val *> args;
97 struct pipeline_selector {
102 struct pipeline_branch {
103 vector<pipeline_selector> selectors;
104 list<cmd *> commands;
108 vector<pipeline_branch *> branches;
115 extern const char *in_name, *out_name;
116 extern bool recalc_bbox;
117 extern int debug_mode;
118 extern int debug_indent;
120 void debug(const char *msg, ...) FORMAT_CHECK(printf, 1, 2);
121 void warn(const char *msg, ...) FORMAT_CHECK(printf, 1, 2);
122 void die(const char *msg, ...) FORMAT_CHECK(printf, 1, 2) NONRET;
126 void parse(const char *in, list<cmd *> &cmds);
131 extern const cmd_def cmd_table[];
135 void debug_pages(vector<page *> &pages);
136 void process(list<cmd *> &cmds);
137 vector<page *> run_command_list(list<cmd *> &cmds, vector<page *> &pages);
138 vector<BBox> gs_bboxes(const char *in);