blob: bcc90aa1c310560d4eb5aae2f94032d370d9fc31 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
#ifndef DL_DVI_FILE_HH
#define DL_DVI_FILE_HH
#include "dl-dvi-program.hh"
#include <map>
#include <list>
#include <algorithm>
#include "dl-dvi-fontdefinition.hh"
#include "dl-loader.hh"
namespace DviLib
{
const uint N_PAGE_COUNTERS = 10; // \count0 ... \count9
class DviPageHeader : public RefCounted
{
public:
int count[N_PAGE_COUNTERS];
uint address; // address of this page, not the preceding
};
class DviPage : public AbstractDviProgram
{
DviProgram& program;
DviFontMap *fontmap;
int count[N_PAGE_COUNTERS]; // \count0 ... \count9
public:
DviPage (DviProgram& p, int c[N_PAGE_COUNTERS], DviFontMap *fontmap) :
program (p)
{
this->fontmap = fontmap;
this->fontmap->ref();
for (uint i = 0; i < N_PAGE_COUNTERS; ++i)
count[i] = c[i];
}
virtual void execute (DviRuntime& runtime)
{
runtime.push();
runtime.fontmap (fontmap);
cout << "page " << (int)fontmap << endl;
program.execute (runtime);
runtime.pop();
}
int get_page_count (int i) { return count[i]; }
};
enum DviType
{
NORMAL_DVI = 2, // FIXME: this should be 2
TEX_XET_DVI = 2 // FIXME: is this correct?
};
class DviFilePreamble : public RefCounted
{
public:
// preamble
DviType type;
uint magnification;
uint numerator;
uint denominator;
string comment;
};
class DviFilePostamble : public RefCounted
{
public:
// postamble
DviType type;
uint magnification;
uint numerator;
uint denominator;
uint last_page_address;
uint max_height;
uint max_width;
uint stack_height;
DviFontMap *fontmap;
};
class DviFile : public RefCounted
{
AbstractLoader &loader;
DviFilePreamble *preamble;
DviFilePostamble *postamble;
uint n_pages;
map <uint, DviPageHeader *> page_headers;
map <uint, DviPage *> pages;
public:
DviFile (AbstractLoader& l);
DviPage *get_page (uint n); /* unref it when done */
~DviFile (void) {}
uint get_n_pages () { return n_pages; }
DviFontdefinition *get_fontdefinition (uint n)
{
return postamble->fontmap->get_fontdefinition (n);
}
uint get_numerator () { return postamble->numerator; }
uint get_denominator () { return postamble->denominator; }
uint get_magnification () { return postamble->magnification; }
};
}
#endif // DL_DVI_FILE_HH
|