more detailed message (HH)
[luatex.git] / source / texk / web2c / luatexdir / tex / texnodes.h
blob93670b7f5b3a1281da82907c37ca9a136be4b000
1 /* texnodes.h
3 Copyright 2006-2008 Taco Hoekwater <taco@luatex.org>
5 This file is part of LuaTeX.
7 LuaTeX is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2 of the License, or (at your
10 option) any later version.
12 LuaTeX is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
15 License for more details.
17 You should have received a copy of the GNU General Public License along
18 with LuaTeX; if not, see <http://www.gnu.org/licenses/>. */
21 #include <stdarg.h>
23 #ifndef __NODES_H__
24 # define __NODES_H__
26 /* these are in texlang.c */
28 # define set_vlink(a,b) vlink(a)=b
29 # define get_vlink(a) vlink(a)
30 # define get_character(a) character(a)
32 extern halfword insert_discretionary(halfword t, halfword pre, halfword post, halfword replace, int penalty);
33 extern halfword insert_syllable_discretionary(halfword t, lang_variables * lan);
34 extern halfword insert_word_discretionary(halfword t, lang_variables * lan);
35 extern halfword insert_complex_discretionary(halfword t, lang_variables * lan, halfword pre, halfword post, halfword replace);
36 extern halfword insert_character(halfword t, int n);
37 extern void set_disc_field(halfword f, halfword t);
39 # define varmemcast(a) (memory_word *)(a)
41 extern memory_word *volatile varmem;
42 extern halfword var_mem_max;
44 extern halfword get_node(int s);
45 extern void free_node(halfword p, int s);
46 extern void init_node_mem(int s);
47 extern void dump_node_mem(void);
48 extern void undump_node_mem(void);
50 # define max_halfword 0x3FFFFFFF
51 # define max_dimen 0x3FFFFFFF
52 # ifndef null
53 # define null 0
54 # endif
55 # define null_flag -0x40000000
56 # define zero_glue 0
57 # define normal 0
59 # define vinfo(a) varmem[(a)].hh.v.LH
60 # define vlink(a) varmem[(a)].hh.v.RH
61 # define type(a) varmem[(a)].hh.u.B0
62 # define subtype(a) varmem[(a)].hh.u.B1
63 # define node_attr(a) vinfo((a)+1)
64 # define alink(a) vlink((a)+1)
66 # define node_size(a) varmem[(a)].hh.v.LH
68 # define rlink(a) vlink((a)+1) /* aka alink() */
69 # define tlink(a) vinfo((a)+1) /* overlaps with node_attr() */
71 /* really special head node pointers that only need links */
73 # define temp_node_size 2
75 /* attribute lists */
77 # define UNUSED_ATTRIBUTE -0x7FFFFFFF /* as low as it goes */
79 /* it is convenient to have attribute list nodes and attribute node
80 * be the same size
83 # define attribute_node_size 2
84 # define cache_disabled max_halfword
86 # define attr_list_ref(a) vinfo((a)+1) /* the reference count */
87 # define attribute_id(a) vinfo((a)+1)
88 # define attribute_value(a) vlink((a)+1)
90 # define assign_attribute_ref(n,p) do { \
91 node_attr(n) = p;attr_list_ref(p)++; \
92 } while (0)
94 # define add_node_attr_ref(a) do { \
95 if (a!=null) attr_list_ref((a))++; \
96 } while (0)
98 # define replace_attribute_list(a,b) do { \
99 delete_attribute_ref(node_attr(a)); \
100 node_attr(a)=b; \
101 } while (0)
103 extern void update_attribute_cache(void);
104 extern halfword copy_attribute_list(halfword n);
105 extern halfword do_set_attribute(halfword p, int i, int val);
107 # define width_offset 2
108 # define depth_offset 3
109 # define height_offset 4
110 # define list_offset 6
112 typedef enum {
113 cond_math_glue = 98, /* special |subtype| to suppress glue in the next node */
114 mu_glue, /* |subtype| for math glue */
115 a_leaders, /* |subtype| for aligned leaders */
116 c_leaders, /* |subtype| for centered leaders */
117 x_leaders, /* |subtype| for expanded leaders */
118 g_leaders /* |subtype| for global (page) leaders */
119 } glue_subtypes;
121 /* normal nodes */
123 # define inf_bad 10000 /* infinitely bad value */
124 # define inf_penalty inf_bad /* ``infinite'' penalty value */
125 # define eject_penalty -(inf_penalty) /* ``negatively infinite'' penalty value */
127 # define penalty_node_size 3
128 # define penalty(a) vlink((a)+2)
131 # define glue_node_size 4
132 # define glue_ptr(a) vinfo((a)+2)
133 # define leader_ptr(a) vlink((a)+2)
134 # define synctex_tag_glue(a) vinfo((a)+3)
135 # define synctex_line_glue(a) vlink((a)+3)
138 # define glue_node_size 7
139 # define glue_spec_size 5
140 /* define width(a) vinfo((a)+2) */
141 /* define leader_ptr(a) vlink((a)+2) */
142 # define shrink(a) vinfo((a)+3)
143 # define stretch(a) vlink((a)+3)
144 # define stretch_order(a) vinfo((a)+4)
145 # define shrink_order(a) vlink((a)+4)
146 # define leader_ptr(a) vlink((a)+5) /* should be in vlink((a)+2) but fails */
147 # define synctex_tag_glue(a) vinfo((a)+6)
148 # define synctex_line_glue(a) vlink((a)+6)
150 #define glue_is_zero(p) \
151 ((p == null) || (width(p) == 0 && stretch(p) == 0 && shrink(p) == 0))
153 #define reset_glue_to_zero(p) \
154 if (p != null) { \
155 width(p) = 0; \
156 stretch(p) = 0; \
157 shrink(p) = 0; \
158 stretch_order(p) = 0; \
159 shrink_order(p) = 0; \
162 #define copy_glue_values(p,q) \
163 if (q == null) { \
164 width(p) = 0; \
165 stretch(p) = 0; \
166 shrink(p) = 0; \
167 stretch_order(p) = 0; \
168 shrink_order(p) = 0; \
169 } else { \
170 width(p) = width(q); \
171 stretch(p) = stretch(q); \
172 shrink(p) = shrink(q); \
173 stretch_order(p) = stretch_order(q); \
174 shrink_order(p) = shrink_order(q); \
179 disc nodes could eventually be smaller, because the indirect
180 pointers are not really needed (8 instead of 10).
183 typedef enum {
184 discretionary_disc = 0,
185 explicit_disc,
186 automatic_disc,
187 syllable_disc,
188 init_disc, /* first of a duo of syllable_discs */
189 select_disc, /* second of a duo of syllable_discs */
190 } discretionary_subtypes;
192 # define disc_node_size 11
193 # define pre_break_head(a) ((a)+5)
194 # define post_break_head(a) ((a)+7)
195 # define no_break_head(a) ((a)+9)
197 # define disc_penalty(a) vlink((a)+2)
198 # define pre_break(a) vinfo((a)+3)
199 # define post_break(a) vlink((a)+3)
200 # define no_break(a) vlink((a)+4)
202 # define vlink_pre_break(a) vlink(pre_break_head(a))
203 # define vlink_post_break(a) vlink(post_break_head(a))
204 # define vlink_no_break(a) vlink(no_break_head(a))
206 # define tlink_pre_break(a) tlink(pre_break_head(a))
207 # define tlink_post_break(a) tlink(post_break_head(a))
208 # define tlink_no_break(a) tlink(no_break_head(a))
210 typedef enum {
211 font_kern = 0,
212 explicit_kern, /* |subtype| of kern nodes from \.{\\kern} and \.{\\/} */
213 accent_kern, /* |subtype| of kern nodes from accents */
214 italic_kern,
215 } kern_subtypes;
217 # define kern_node_size 5
218 # define ex_kern(a) vinfo((a)+3) /* expansion factor (hz) */
219 # define synctex_tag_kern(a) vinfo((a)+4)
220 # define synctex_line_kern(a) vlink((a)+4)
222 # define box_node_size 9
224 /* todo, make an enum of this */
226 typedef enum {
227 unknown_list = 0,
228 line_list = 1, /* paragraph lines */
229 hbox_list = 2, /* \.{\\hbox} */
230 indent_list = 3, /* indentation box */
231 align_row_list = 4, /* row from a \.{\\halign} or \.{\\valign} */
232 align_cell_list = 5, /* cell from a \.{\\halign} or \.{\\valign} */
233 equation_list = 6, /* display equation */
234 equation_number_list = 7, /* display equation number */
235 } list_subtypes ;
237 # define width(a) varmem[(a)+2].cint
238 # define depth(a) varmem[(a)+3].cint
239 # define height(a) varmem[(a)+4].cint
240 # define shift_amount(a) vlink((a)+5)
241 # define box_dir(a) vinfo((a)+5)
242 # define list_ptr(a) vlink((a)+6)
243 # define glue_order(a) subtype((a)+6)
244 # define glue_sign(a) type((a)+6)
245 # define glue_set(a) varmem[(a)+7].gr
246 # define synctex_tag_box(a) vinfo((a)+8)
247 # define synctex_line_box(a) vlink((a)+8)
249 /* unset nodes */
251 # define glue_stretch(a) varmem[(a)+7].cint
252 # define glue_shrink shift_amount
253 # define span_count subtype
255 typedef enum {
256 normal_rule = 0,
257 box_rule,
258 image_rule,
259 empty_rule,
260 user_rule,
261 } rule_subtypes;
263 # define rule_node_size 8
264 # define rule_dir(a) vlink((a)+5)
265 # define rule_index(a) vinfo((a)+6)
266 # define rule_transform(a) vlink((a)+6)
267 # define synctex_tag_rule(a) vinfo((a)+7)
268 # define synctex_line_rule(a) vlink((a)+7)
270 # define mark_node_size 3
271 # define mark_ptr(a) vlink((a)+2)
272 # define mark_class(a) vinfo((a)+2)
274 # define adjust_node_size 3
275 # define adjust_pre subtype
276 # define adjust_ptr(a) vlink(a+2)
278 # define glyph_node_size 6
279 # define character(a) vinfo((a)+2)
280 # define font(a) vlink((a)+2)
281 # define lang_data(a) vinfo((a)+3)
282 # define lig_ptr(a) vlink((a)+3)
283 # define x_displace(a) vinfo((a)+4)
284 # define y_displace(a) vlink((a)+4)
285 # define ex_glyph(a) vinfo((a)+5) /* expansion factor (hz) */
286 # define x_advance(a) vlink((a)+5)
288 # define is_char_node(a) (a!=null && type(a)==glyph_node)
290 # define char_lang(a) ((const int)(signed short)(((signed int)((unsigned)lang_data(a)&0x7FFF0000)<<1)>>17))
291 # define char_lhmin(a) ((const int)(((unsigned)lang_data(a) & 0x0000FF00)>>8))
292 # define char_rhmin(a) ((const int)(((unsigned)lang_data(a) & 0x000000FF)))
293 # define char_uchyph(a) ((const int)(((unsigned)lang_data(a) & 0x80000000)>>31))
295 # define make_lang_data(a,b,c,d) (a>0 ? (1<<31): 0)+ \
296 (b<<16)+ (((c>0 && c<256) ? c : 255)<<8)+(((d>0 && d<256) ? d : 255))
298 # define init_lang_data(a) lang_data(a)=256+1
300 # define set_char_lang(a,b) lang_data(a)=make_lang_data(char_uchyph(a),b,char_lhmin(a),char_rhmin(a))
301 # define set_char_lhmin(a,b) lang_data(a)=make_lang_data(char_uchyph(a),char_lang(a),b,char_rhmin(a))
302 # define set_char_rhmin(a,b) lang_data(a)=make_lang_data(char_uchyph(a),char_lang(a),char_lhmin(a),b)
303 # define set_char_uchyph(a,b) lang_data(a)=make_lang_data(b,char_lang(a),char_lhmin(a),char_rhmin(a))
305 # define margin_kern_node_size 4
306 # define margin_char(a) vlink((a)+3)
308 /*@# {|subtype| of marginal kerns}*/
310 # define left_side 0
311 # define right_side 1
313 # define before 0 /* |subtype| for math node that introduces a formula */
314 # define after 1 /* |subtype| for math node that winds up a formula */
316 # define math_node_size 7
317 /* define width(a) vinfo((a)+2) */
318 /* overlaps width */
319 /* define shrink(a) vinfo((a)+3) */
320 /* define stretch(a) vlink((a)+3) */
321 /* define stretch_order(a) vinfo((a)+4) */
322 /* define shrink_order(a) vlink((a)+4) */
323 /* leader_ptr slot */
324 # define surround(a) vinfo((a)+5)
325 # define synctex_tag_math(a) vinfo((a)+6)
326 # define synctex_line_math(a) vlink((a)+6)
328 # define ins_node_size 6
329 # define float_cost(a) varmem[(a)+2].cint
330 # define ins_ptr(a) vinfo((a)+5)
331 # define split_top_ptr(a) vlink((a)+5)
333 # define page_ins_node_size 5
335 /* height = 4 */
337 typedef enum {
338 hlist_node = 0,
339 vlist_node,
340 rule_node,
341 ins_node,
342 mark_node,
343 adjust_node,
344 boundary_node,
345 disc_node,
346 whatsit_node,
347 #define last_preceding_break_node whatsit_node
348 local_par_node,
349 dir_node,
350 #define last_non_discardable_node dir_node
351 math_node,
352 glue_node,
353 kern_node,
354 penalty_node,
355 unset_node,
356 style_node,
357 choice_node,
358 simple_noad,
359 radical_noad,
360 fraction_noad,
361 accent_noad,
362 fence_noad,
363 math_char_node, /* kernel fields */
364 sub_box_node,
365 sub_mlist_node,
366 math_text_char_node,
367 delim_node, /* shield fields */
368 margin_kern_node,
369 glyph_node,
370 align_record_node,
371 pseudo_file_node,
372 pseudo_line_node,
373 inserting_node,
374 split_up_node,
375 expr_node,
376 nesting_node,
377 span_node,
378 attribute_node,
379 glue_spec_node,
380 attribute_list_node,
381 temp_node,
382 align_stack_node,
383 movement_node,
384 if_node,
385 unhyphenated_node,
386 hyphenated_node,
387 delta_node,
388 passive_node,
389 shape_node,
390 } node_types;
392 # define MAX_NODE_TYPE shape_node /* 60 */
395 TH: these two defines still need checking. The node ordering in luatex is not
396 quite the same as in tex82, HH: but it's probably ok
401 # define precedes_break(a) \
402 # (type(a)<math_node && \
403 # (type(a)!=whatsit_node || (subtype(a)!=dir_node && subtype(a)!=local_par_node)))
408 # define precedes_break(a) (type(a)<math_node)
409 # define non_discardable(a) (type(a)<math_node || type(a) == dir_node || type(a) == local_par_node)
412 # define precedes_break(a) (type(a)<=last_preceding_break_node)
413 # define non_discardable(a) (type(a)<=last_non_discardable_node)
415 # define known_node_type(i) ( i >= 0 && i <= MAX_NODE_TYPE)
417 # define last_known_node temp_node /* used by \lastnodetype */
419 # define movement_node_size 3
420 # define expr_node_size 3
421 # define if_node_size 2
422 # define align_stack_node_size 6
423 # define nesting_node_size 2
425 # define span_node_size 3
426 # define span_span(a) vlink((a)+1)
427 # define span_link(a) vinfo((a)+1)
429 # define pseudo_file_node_size 2
430 # define pseudo_lines(a) vlink((a)+1)
432 # define nodetype_has_attributes(t) (((t)<=glyph_node) && ((t)!=unset_node))
434 # define nodetype_has_subtype(t) ((t)!=attribute_list_node && (t)!=attribute_node && (t)!=glue_spec_node)
435 # define nodetype_has_prev(t) nodetype_has_subtype((t))
438 style and choice nodes; style nodes can be smaller, the information is encoded in
439 |subtype|, but choice nodes are on-the-spot converted to style nodes
442 # define style_node_size 4
443 # define display_mlist(a) vinfo((a)+2) /* mlist to be used in display style */
444 # define text_mlist(a) vlink((a)+2) /* mlist to be used in text style */
445 # define script_mlist(a) vinfo((a)+3) /* mlist to be used in script style */
446 # define script_script_mlist(a) vlink((a)+3) /* mlist to be used in scriptscript style */
449 because noad types get changed when processing we need to make sure some if the node
450 sizes match and that we don't share slots with different properties
452 once it's sorted out we can go smaller and also adapt the flush etc code to it
455 /* regular noads */
457 # define noad_size 8
458 # define new_hlist(a) vlink((a)+2) /* the translation of an mlist */
459 # define nucleus(a) vinfo((a)+2) /* the |nucleus| field of a noad */
460 # define supscr(a) vlink((a)+3) /* the |supscr| field of a noad */
461 # define subscr(a) vinfo((a)+3) /* the |subscr| field of a noad */
462 # define noaditalic(a) vlink((a)+4)
463 # define noadwidth(a) vinfo((a)+4)
464 # define noadheight(a) vlink((a)+5)
465 # define noaddepth(a) vinfo((a)+5)
466 # define noadextra1(a) vlink((a)+6) /* we need to match delimiter (saves copy) */
467 # define noadextra2(a) vinfo((a)+6)
468 # define noadextra3(a) vlink((a)+7) /* see (!) below */
469 # define noadextra4(a) vinfo((a)+7)
471 /* accent noads */
473 # define accent_noad_size 8
474 # define top_accent_chr(a) vinfo((a)+6) /* the |top_accent_chr| field of an accent noad */
475 # define bot_accent_chr(a) vlink((a)+6) /* the |bot_accent_chr| field of an accent noad */
476 # define overlay_accent_chr(a) vinfo((a)+7) /* the |overlay_accent_chr| field of an accent noad */
477 # define accentfraction(a) vlink((a)+7)
479 /* left and right noads */
481 # define fence_noad_size 8 /* needs to match noad size */
482 # define delimiteritalic(a) vlink((a)+4)
483 /* define delimiterwidth(a) vinfo((a)+4) */
484 # define delimiterheight(a) vlink((a)+5)
485 # define delimiterdepth(a) vinfo((a)+5)
486 # define delimiter(a) vlink((a)+6) /* |delimiter| field in left and right noads */
487 # define delimiteroptions(a) vinfo((a)+6)
488 # define delimiterclass(a) vlink((a)+7) /* (!) we could probably pack some more in 6 */
489 # define delimiterextra1(a) vinfo((a)+7) /* not used */
491 /* when dimensions then axis else noaxis */
493 typedef enum {
494 noad_option_set = 0x08,
495 noad_option_unused_1 = 0x00 + 0x08,
496 noad_option_unused_2 = 0x01 + 0x08,
497 noad_option_axis = 0x02 + 0x08,
498 noad_option_no_axis = 0x04 + 0x08,
499 noad_option_exact = 0x10 + 0x08,
500 noad_option_left = 0x11 + 0x08,
501 noad_option_middle = 0x12 + 0x08,
502 noad_option_right = 0x14 + 0x08,
503 } delimiter_options ;
505 # define delimiteroptionset(a) ((delimiteroptions(a) & noad_option_set ) == noad_option_set )
506 # define delimiteraxis(a) ((delimiteroptions(a) & noad_option_axis ) == noad_option_axis )
507 # define delimiternoaxis(a) ((delimiteroptions(a) & noad_option_no_axis) == noad_option_no_axis)
508 # define delimiterexact(a) ((delimiteroptions(a) & noad_option_exact ) == noad_option_exact )
510 /* subtype of fence noads */
512 # define left_noad_side 1
513 # define middle_noad_side 2
514 # define right_noad_side 3
515 # define no_noad_side 4
517 /* fraction noads */
519 # define fraction_noad_size 7
520 # define thickness(a) vlink((a)+2) /* |thickness| field in a fraction noad */
521 # define numerator(a) vlink((a)+3) /* |numerator| field in a fraction noad */
522 # define denominator(a) vinfo((a)+3) /* |denominator| field in a fraction noad */
523 # define left_delimiter(a) vlink((a)+5) /* first delimiter field of a noad */
524 # define right_delimiter(a) vinfo((a)+5) /* second delimiter field of a fraction noad */
525 # define middle_delimiter(a) vlink((a)+6)
526 # define fractionoptions(a) vinfo((a)+6)
528 # define fractionoptionset(a) ((fractionoptions(a) & noad_option_set ) == noad_option_set )
529 # define fractionexact(a) ((fractionoptions(a) & noad_option_exact ) == noad_option_exact )
530 # define fractionnoaxis(a) ((fractionoptions(a) & noad_option_no_axis) == noad_option_no_axis)
532 /* radical noads */
533 /* this is like a fraction, but it only stores a |left_delimiter| */
535 # define radical_noad_size 7
536 # define radicalwidth(a) vinfo((a)+4)
537 # define degree(a) vlink((a)+6) /* the root degree in a radical noad */
538 # define radicaloptions(a) vinfo((a)+6)
540 # define radicaloptionset(a) ((radicaloptions(a) & noad_option_set ) == noad_option_set)
541 # define radicalexact(a) ((radicaloptions(a) & noad_option_exact ) == noad_option_exact)
542 # define radicalleft(a) ((radicaloptions(a) & noad_option_left ) == noad_option_left)
543 # define radicalmiddle(a) ((radicaloptions(a) & noad_option_middle) == noad_option_middle)
544 # define radicalright(a) ((radicaloptions(a) & noad_option_right ) == noad_option_right)
546 /* accessors for the |nucleus|-style node fields */
548 # define math_kernel_node_size 3
549 # define math_fam(a) vinfo((a)+2)
550 # define math_character(a) vlink((a)+2)
551 # define math_list(a) vlink((a)+2)
553 /* accessors for the |delimiter|-style two-word subnode fields */
555 # define math_shield_node_size 4 /* not used yet */
557 # define small_fam(A) vinfo((A)+2) /* |fam| for ``small'' delimiter */
558 # define small_char(A) vlink((A)+2) /* |character| for ``small'' delimiter */
559 # define large_fam(A) vinfo((A)+3) /* |fam| for ``large'' delimiter */
560 # define large_char(A) vlink((A)+3) /* |character| for ``large'' delimiter */
562 /* we should have the codes in a separate enum: extension_codes */
564 /* be careful: must be in sync with whatsit_node_data[] ! (at least) */
566 typedef enum {
567 /* core */
568 open_node = 0,
569 write_node,
570 close_node,
571 special_node,
572 use_box_resource_node,
573 use_image_resource_node,
574 save_pos_node,
575 late_lua_node,
576 user_defined_node,
577 /* dvi backend */
578 dvi_literal_node = 15,
579 /* pdf backend */
580 pdf_literal_node = 16,
581 pdf_refobj_node,
582 pdf_annot_node,
583 pdf_start_link_node,
584 pdf_end_link_node,
585 pdf_dest_node,
586 pdf_action_node,
587 pdf_thread_node,
588 pdf_start_thread_node,
589 pdf_end_thread_node,
590 pdf_thread_data_node,
591 pdf_link_data_node,
592 pdf_colorstack_node,
593 pdf_setmatrix_node,
594 pdf_save_node,
595 pdf_restore_node,
596 } whatsit_types;
598 # define first_common_whatsit 0
599 # define last_common_whatsit user_defined_node
600 # define backend_first_dvi_whatsit 15
601 # define backend_last_dvi_whatsit 15
602 # define backend_first_pdf_whatsit 16
603 # define backend_last_pdf_whatsit 31
605 # define MAX_WHATSIT_TYPE 32
607 # define known_whatsit_type(i) ( \
608 (i >= first_common_whatsit && i <= last_common_whatsit) || \
609 (i >= backend_first_dvi_whatsit && i <= backend_last_dvi_whatsit) || \
610 (i >= backend_first_pdf_whatsit && i <= backend_last_pdf_whatsit) \
613 # define get_node_size(i,j) (i!=whatsit_node ? node_data[i].size : whatsit_node_data[j].size)
614 # define get_node_name(i,j) (i!=whatsit_node ? node_data[i].name : whatsit_node_data[j].name)
615 # define get_etex_code(i) (node_data[i].etex)
617 # define GLYPH_CHARACTER (1 << 0)
618 # define GLYPH_LIGATURE (1 << 1)
619 # define GLYPH_GHOST (1 << 2)
620 # define GLYPH_LEFT (1 << 3)
621 # define GLYPH_RIGHT (1 << 4)
623 # define is_character(p) ((subtype(p)) & GLYPH_CHARACTER)
624 # define is_ligature(p) ((subtype(p)) & GLYPH_LIGATURE )
625 # define is_ghost(p) ((subtype(p)) & GLYPH_GHOST )
627 # define is_simple_character(p) (is_character(p) && !is_ligature(p) && !is_ghost(p))
629 # define is_leftboundary(p) (is_ligature(p) && ((subtype(p)) & GLYPH_LEFT ))
630 # define is_rightboundary(p) (is_ligature(p) && ((subtype(p)) & GLYPH_RIGHT ))
631 # define is_leftghost(p) (is_ghost(p) && ((subtype(p)) & GLYPH_LEFT ))
632 # define is_rightghost(p) (is_ghost(p) && ((subtype(p)) & GLYPH_RIGHT ))
635 # define set_is_glyph(p) subtype(p) = (quarterword) (subtype(p) & ~GLYPH_CHARACTER)
636 # define set_is_character(p) subtype(p) = (quarterword) (subtype(p) | GLYPH_CHARACTER)
637 # define set_is_ligature(p) subtype(p) = (quarterword) (subtype(p) | GLYPH_LIGATURE)
638 # define set_is_ghost(p) subtype(p) = (quarterword) (subtype(p) |GLYPH_GHOST)
640 # define set_to_glyph(p) subtype(p) = (quarterword)(subtype(p) & 0xFF00)
641 # define set_to_character(p) subtype(p) = (quarterword)((subtype(p) & 0xFF00) | GLYPH_CHARACTER)
642 # define set_to_ligature(p) subtype(p) = (quarterword)((subtype(p) & 0xFF00) | GLYPH_LIGATURE)
643 # define set_to_ghost(p) subtype(p) = (quarterword)((subtype(p) & 0xFF00) | GLYPH_GHOST)
645 # define set_is_leftboundary(p) { set_to_ligature(p); subtype(p) |= GLYPH_LEFT; }
646 # define set_is_rightboundary(p) { set_to_ligature(p); subtype(p) |= GLYPH_RIGHT; }
647 # define set_is_leftghost(p) { set_to_ghost(p); subtype(p) |= GLYPH_LEFT; }
648 # define set_is_rightghost(p) { set_to_ghost(p); subtype(p) |= GLYPH_RIGHT; }
650 typedef enum {
651 cancel_boundary = 0,
652 user_boundary,
653 protrusion_boundary,
654 word_boundary,
655 } boundary_subtypes ;
657 # define boundary_node_size 3
658 # define boundary_value(a) vinfo((a)+2)
660 # define special_node_size 3
662 # define dir_node_size 5
663 # define dir_dir(a) vinfo((a)+2)
664 # define dir_level(a) vlink((a)+2)
665 # define dir_refpos_h(a) vinfo((a)+3)
666 # define dir_refpos_v(a) vlink((a)+3)
667 # define dir_cur_h(a) vinfo((a)+4)
668 # define dir_cur_v(a) vlink((a)+4)
670 # define write_node_size 3
671 # define close_node_size 3
672 # define write_tokens(a) vlink(a+2)
673 # define write_stream(a) vinfo(a+2)
675 # define open_node_size 4
676 # define open_name(a) vlink((a)+2)
677 # define open_area(a) vinfo((a)+3)
678 # define open_ext(a) vlink((a)+3)
680 # define late_lua_node_size 4
681 # define late_lua_data(a) vlink((a)+2)
682 # define late_lua_reg(a) vinfo((a)+2)
683 # define late_lua_name(a) vlink((a)+3)
684 # define late_lua_type(a) subtype((a)+3)
686 # define save_pos_node_size 3
688 # define local_par_size 6
690 # define local_pen_inter(a) vinfo((a)+2)
691 # define local_pen_broken(a) vlink((a)+2)
692 # define local_box_left(a) vlink((a)+3)
693 # define local_box_left_width(a) vinfo((a)+3)
694 # define local_box_right(a) vlink((a)+4)
695 # define local_box_right_width(a) vinfo((a)+4)
696 # define local_par_dir(a) vinfo((a)+5)
698 /* type of literal data */
700 # define lua_refid_literal 1 /* not a |normal| string */
702 /* begin of pdf backend nodes */
704 /* literal ctm types */
706 typedef enum {
707 set_origin = 0,
708 direct_page,
709 direct_always,
710 scan_special,
711 } ctm_transform_modes;
713 # define pdf_refobj_node_size 3
715 # define pdf_obj_objnum(a) vinfo((a) + 2)
717 # define pdf_annot_node_size 8
718 # define pdf_dest_node_size 8
719 # define pdf_thread_node_size 8
722 when a whatsit node representing annotation is created, words |1..3| are
723 width, height and depth of this annotation; after shipping out words |1..4|
724 are rectangle specification of annotation. For whatsit node representing
725 destination |pdf_ann_left| and |pdf_ann_top| are used for some types of destinations
729 coordinates of destinations/threads/annotations (in whatsit node)
732 # define pdf_ann_left(a) varmem[(a) + 2].cint
733 # define pdf_ann_top(a) varmem[(a) + 3].cint
734 # define pdf_ann_right(a) varmem[(a) + 4].cint
735 # define pdf_ann_bottom(a) varmem[(a) + 5].cint
737 # define pdf_literal_data(a) vlink((a)+2)
738 # define pdf_literal_mode(a) type((a)+2)
739 # define pdf_literal_type(a) subtype((a)+2)
741 # define pdf_annot_data(a) vinfo((a) + 6)
742 # define pdf_link_attr(a) vinfo((a) + 6)
743 # define pdf_link_action(a) vlink((a) + 6)
744 # define pdf_annot_objnum(a) varmem[(a) + 7].cint
745 # define pdf_link_objnum(a) varmem[(a) + 7].cint
747 # define pdf_dest_type(a) type((a) + 6)
748 # define pdf_dest_named_id(a) subtype((a) + 6)
749 # define pdf_dest_id(a) vlink((a) + 6)
750 # define pdf_dest_xyz_zoom(a) vinfo((a) + 7)
751 # define pdf_dest_objnum(a) vlink((a) + 7)
753 # define pdf_thread_named_id(a) subtype((a) + 6)
754 # define pdf_thread_id(a) vlink((a) + 6)
755 # define pdf_thread_attr(a) vinfo((a) + 7)
757 # define pdf_end_link_node_size 3
758 # define pdf_end_thread_node_size 3
760 # define pdf_setmatrix_node_size 3
761 # define pdf_save_node_size 3
762 # define pdf_restore_node_size 3
764 # define pdf_colorstack_node_size 4
765 # define pdf_colorstack_stack(a) vlink((a)+2)
766 # define pdf_colorstack_cmd(a) vinfo((a)+2)
767 # define pdf_colorstack_data(a) vlink((a)+3)
768 # define pdf_setmatrix_data(a) vlink((a)+2)
770 typedef enum {
771 pdf_action_page = 0,
772 pdf_action_goto,
773 pdf_action_thread,
774 pdf_action_user
775 } pdf_action_type;
777 typedef enum {
778 pdf_window_notset,
779 pdf_window_new,
780 pdf_window_nonew,
781 } pdf_window_type;
783 # define pdf_action_size 6
785 # define pdf_action_type(a) vlink((a)+2) /* enum pdf_action_type */
786 # define pdf_action_named_id(a) vinfo((a)+2) /* boolean */
787 # define pdf_action_id(a) vlink((a)+3) /* number or toks */
788 # define pdf_action_file(a) vinfo((a)+3) /* toks */
789 # define pdf_action_new_window(a) vlink((a)+4) /* enum pdf_window_type */
790 # define pdf_action_tokens(a) vinfo((a)+4) /* toks */
791 # define pdf_action_refcount(a) vlink((a)+5) /* number */
793 typedef enum {
794 colorstack_set = 0,
795 colorstack_push,
796 colorstack_pop,
797 colorstack_current
798 } colorstack_commands;
800 # define colorstack_data colorstack_push /* last value where data field is set */
802 /* end of pdf backend nodes */
804 /* user defined nodes */
806 # define user_defined_node_size 4
807 # define user_node_type(a) vinfo((a)+2)
808 # define user_node_id(a) vlink((a)+2)
809 # define user_node_value(a) vinfo((a)+3)
811 /* node sused in the parbuilder */
813 # define active_node_size 4 /*number of words in extended active nodes */
814 # define fitness subtype /*|very_loose_fit..tight_fit| on final line for this break */
815 # define break_node(a) vlink((a)+1) /*pointer to the corresponding passive node */
816 # define line_number(a) vinfo((a)+1) /*line that begins at this breakpoint */
817 # define total_demerits(a) varmem[(a)+2].cint /* the quantity that \TeX\ minimizes */
818 # define active_short(a) vinfo(a+3) /* |shortfall| of this line */
819 # define active_glue(a) vlink(a+3) /*corresponding glue stretch or shrink */
821 # define passive_node_size 7
822 # define cur_break(a) vlink((a)+1) /*in passive node, points to position of this breakpoint */
823 # define prev_break(a) vinfo((a)+1) /*points to passive node that should precede this one */
824 # define passive_pen_inter(a) vinfo((a)+2)
825 # define passive_pen_broken(a) vlink((a)+2)
826 # define passive_left_box(a) vlink((a)+3)
827 # define passive_left_box_width(a) vinfo((a)+3)
828 # define passive_last_left_box(a) vlink((a)+4)
829 # define passive_last_left_box_width(a) vinfo((a)+4)
830 # define passive_right_box(a) vlink((a)+5)
831 # define passive_right_box_width(a) vinfo((a)+5)
832 # define serial(a) vlink((a)+6) /* serial number for symbolic identification */
834 # define delta_node_size 10 /* 8 fields, stored in a+1..9 */
836 /* helpers */
838 # define couple_nodes(a,b) {assert(b!=null);vlink(a)=b;alink(b)=a;}
839 # define try_couple_nodes(a,b) if (b==null) vlink(a)=b; else {couple_nodes(a,b);}
840 # define uncouple_node(a) {assert(a!=null);vlink(a)=null;alink(a)=null;}
842 # define cache_disabled max_halfword
844 extern void delete_attribute_ref(halfword b);
845 extern void reset_node_properties(halfword b);
846 extern void reassign_attribute(halfword n,halfword new);
847 extern void build_attribute_list(halfword b);
848 extern halfword current_attribute_list(void);
850 extern int unset_attribute(halfword n, int c, int w);
851 extern void set_attribute(halfword n, int c, int w);
852 extern int has_attribute(halfword n, int c, int w);
854 extern halfword new_span_node(halfword n, int c, scaled w);
856 extern void print_short_node_contents(halfword n);
857 extern void show_node_list(int i);
858 extern pointer actual_box_width(pointer r, scaled base_width);
860 /* from luanode.c */
862 typedef struct _node_info {
863 int id;
864 int size;
865 const char **fields;
866 const char *name;
867 int etex;
868 } node_info;
870 extern node_info node_data[];
871 extern node_info whatsit_node_data[];
873 extern const char *node_subtypes_glue[];
874 extern const char *node_subtypes_mathglue[];
875 extern const char *node_subtypes_leader[];
876 extern const char *node_subtypes_fill[];
877 extern const char *node_subtypes_boundary[];
878 extern const char *node_subtypes_penalty[];
879 extern const char *node_subtypes_kern[];
880 extern const char *node_subtypes_rule[];
881 extern const char *node_subtypes_glyph[];
882 extern const char *node_subtypes_disc[];
883 extern const char *node_subtypes_marginkern[];
884 extern const char *node_subtypes_list[];
885 extern const char *node_subtypes_adjust[];
886 extern const char *node_subtypes_math[];
887 extern const char *node_subtypes_noad[];
888 extern const char *node_subtypes_radical[];
889 extern const char *node_subtypes_accent[];
890 extern const char *node_subtypes_fence[];
892 extern const char *node_subtypes_pdf_destination[];
893 extern const char *node_subtypes_pdf_literal[];
895 extern halfword new_node(int i, int j);
896 extern void flush_node_list(halfword);
897 extern void flush_node(halfword);
898 extern halfword do_copy_node_list(halfword, halfword);
899 extern halfword copy_node_list(halfword);
900 extern halfword copy_node(const halfword);
901 extern void check_node(halfword);
902 extern void fix_node_list(halfword);
903 extern int fix_node_lists;
904 extern char *sprint_node_mem_usage(void);
905 extern halfword raw_glyph_node(void);
906 extern halfword new_glyph_node(void);
907 extern int valid_node(halfword);
909 extern void flush_node_wrapup_dvi(halfword);
910 extern void flush_node_wrapup_pdf(halfword);
911 extern void copy_node_wrapup_dvi(halfword, halfword); /* original target */
912 extern void copy_node_wrapup_pdf(halfword, halfword); /* original target */
913 extern void check_node_wrapup_dvi(halfword); /* DEBUG_NODES mode */
914 extern void check_node_wrapup_pdf(halfword); /* DEBUG_NODES mode */
915 extern void show_node_wrapup_dvi(halfword);
916 extern void show_node_wrapup_pdf(halfword);
918 typedef enum {
919 normal_g = 0,
920 sfi,
921 fil,
922 fill,
923 filll
924 } glue_orders;
926 # define zero_glue 0
927 # define sfi_glue zero_glue+glue_spec_size
928 # define fil_glue sfi_glue+glue_spec_size
929 # define fill_glue fil_glue+glue_spec_size
930 # define ss_glue fill_glue+glue_spec_size
931 # define fil_neg_glue ss_glue+glue_spec_size
932 # define page_ins_head fil_neg_glue+glue_spec_size
933 # define contrib_head page_ins_head+temp_node_size
934 # define page_head contrib_head+temp_node_size
935 # define temp_head page_head+temp_node_size
936 # define hold_head temp_head+temp_node_size
937 # define adjust_head hold_head+temp_node_size
938 # define pre_adjust_head adjust_head+temp_node_size
939 # define active pre_adjust_head+temp_node_size
940 # define align_head active+active_node_size
941 # define end_span align_head+temp_node_size
942 # define begin_point end_span+span_node_size
943 # define end_point begin_point+glyph_node_size
944 # define var_mem_stat_max (end_point+glyph_node_size-1)
946 # define stretching 1
947 # define shrinking 2
949 # define is_running(A) ((A)==null_flag) /* tests for a running dimension */
951 extern halfword tail_of_list(halfword p);
953 extern int var_used;
955 # define cache_disabled max_halfword
957 extern int max_used_attr;
958 extern halfword attr_list_cache;
960 extern halfword new_null_box(void);
961 extern halfword new_rule(int s);
962 extern halfword new_glyph(int f, int c);
963 extern quarterword norm_min(int h);
964 extern halfword new_char(int f, int c);
965 extern scaled glyph_width(halfword p);
966 extern scaled glyph_height(halfword p);
967 extern scaled glyph_depth(halfword p);
968 extern halfword new_disc(void);
969 extern halfword new_math(scaled w, int s);
970 extern halfword new_spec(halfword p);
971 extern halfword new_param_glue(int n);
972 extern halfword new_glue(halfword q);
973 extern halfword new_skip_param(int n);
974 extern halfword new_kern(scaled w);
975 extern halfword new_penalty(int m);
977 extern int lua_properties_enabled ;
978 extern int lua_properties_level ;
979 extern int lua_properties_use_metatable ;
981 #define local_inter_line_penalty int_par(local_inter_line_penalty_code)
982 #define local_broken_penalty int_par(local_broken_penalty_code)
983 #define local_left_box equiv(local_left_box_base)
984 #define local_right_box equiv(local_right_box_base)
986 extern halfword make_local_par_node(int mode);
988 #endif