beta-0.89.2
[luatex.git] / source / texk / web2c / luatexdir / tex / texnodes.h
blobd5198b92f037f2247bf763a731028c78302beba3
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 llink(a) vinfo((a)+1) /* overlaps with node_attr() */
71 # define add_glue_ref(a) glue_ref_count(a)++ /* new reference to a glue spec */
73 /* really special head node pointers that only need links */
75 # define temp_node_size 2
77 /* attribute lists */
79 # define UNUSED_ATTRIBUTE -0x7FFFFFFF /* as low as it goes */
81 /* it is convenient to have attribute list nodes and attribute node
82 * be the same size
85 # define attribute_node_size 2
86 # define cache_disabled max_halfword
88 # define attr_list_ref(a) vinfo((a)+1) /* the reference count */
89 # define attribute_id(a) vinfo((a)+1)
90 # define attribute_value(a) vlink((a)+1)
92 # define assign_attribute_ref(n,p) do { \
93 node_attr(n) = p;attr_list_ref(p)++; \
94 } while (0)
96 # define add_node_attr_ref(a) do { \
97 if (a!=null) attr_list_ref((a))++; \
98 } while (0)
100 # define replace_attribute_list(a,b) do { \
101 delete_attribute_ref(node_attr(a)); \
102 node_attr(a)=b; \
103 } while (0)
105 extern void update_attribute_cache(void);
106 extern halfword copy_attribute_list(halfword n);
107 extern halfword do_set_attribute(halfword p, int i, int val);
109 /* a glue spec */
110 # define glue_spec_size 4
111 # define stretch(a) vlink((a)+1)
112 /* width == a+2 */
113 # define shrink(a) vinfo((a)+1)
114 # define stretch_order(a) type((a)+3)
115 # define shrink_order(a) subtype((a)+3)
116 # define glue_ref_count(a) vlink((a)+3)
118 # define width_offset 2
119 # define depth_offset 3
120 # define height_offset 4
121 # define list_offset 6
123 typedef enum {
124 cond_math_glue = 98, /* special |subtype| to suppress glue in the next node */
125 mu_glue, /* |subtype| for math glue */
126 a_leaders, /* |subtype| for aligned leaders */
127 c_leaders, /* |subtype| for centered leaders */
128 x_leaders, /* |subtype| for expanded leaders */
129 g_leaders /* |subtype| for global (page) leaders */
130 } glue_subtypes;
132 /* normal nodes */
134 # define inf_bad 10000 /* infinitely bad value */
135 # define inf_penalty inf_bad /* ``infinite'' penalty value */
136 # define eject_penalty -(inf_penalty) /* ``negatively infinite'' penalty value */
138 # define penalty_node_size 3
139 # define penalty(a) vlink((a)+2)
141 # define glue_node_size 4
142 # define glue_ptr(a) vinfo((a)+2)
143 # define leader_ptr(a) vlink((a)+2)
144 # define synctex_tag_glue(a) vinfo((a)+3)
145 # define synctex_line_glue(a) vlink((a)+3)
148 disc nodes could eventually be smaller, because the indirect
149 pointers are not really needed (8 instead of 10).
152 typedef enum {
153 discretionary_disc = 0,
154 explicit_disc,
155 automatic_disc,
156 syllable_disc,
157 init_disc, /* first of a duo of syllable_discs */
158 select_disc, /* second of a duo of syllable_discs */
159 } discretionary_subtypes;
161 # define disc_node_size 11
162 # define pre_break_head(a) ((a)+5)
163 # define post_break_head(a) ((a)+7)
164 # define no_break_head(a) ((a)+9)
166 # define disc_penalty(a) vlink((a)+2)
167 # define pre_break(a) vinfo((a)+3)
168 # define post_break(a) vlink((a)+3)
169 # define no_break(a) vlink((a)+4)
170 # define tlink llink
172 # define vlink_pre_break(a) vlink(pre_break_head(a))
173 # define vlink_post_break(a) vlink(post_break_head(a))
174 # define vlink_no_break(a) vlink(no_break_head(a))
176 # define tlink_pre_break(a) tlink(pre_break_head(a))
177 # define tlink_post_break(a) tlink(post_break_head(a))
178 # define tlink_no_break(a) tlink(no_break_head(a))
180 typedef enum {
181 font_kern = 0,
182 explicit_kern, /* |subtype| of kern nodes from \.{\\kern} and \.{\\/} */
183 accent_kern, /* |subtype| of kern nodes from accents */
184 italic_kern,
185 } kern_subtypes;
187 # define kern_node_size 5
188 # define ex_kern(a) vinfo((a)+3) /* expansion factor (hz) */
189 # define synctex_tag_kern(a) vinfo((a)+4)
190 # define synctex_line_kern(a) vlink((a)+4)
192 # define box_node_size 9
194 /* todo, make an enum of this */
196 typedef enum {
197 unknown_list = 0,
198 line_list = 1, /* paragraph lines */
199 hbox_list = 2, /* \.{\\hbox} */
200 indent_list = 3, /* indentation box */
201 align_row_list = 4, /* row from a \.{\\halign} or \.{\\valign} */
202 align_cell_list = 5, /* cell from a \.{\\halign} or \.{\\valign} */
203 equation_list = 6, /* display equation */
204 equation_number_list = 7, /* display equation number */
205 } list_subtypes ;
207 # define width(a) varmem[(a)+2].cint
208 # define depth(a) varmem[(a)+3].cint
209 # define height(a) varmem[(a)+4].cint
210 # define shift_amount(a) vlink((a)+5)
211 # define box_dir(a) vinfo((a)+5)
212 # define list_ptr(a) vlink((a)+6)
213 # define glue_order(a) subtype((a)+6)
214 # define glue_sign(a) type((a)+6)
215 # define glue_set(a) varmem[(a)+7].gr
216 # define synctex_tag_box(a) vinfo((a)+8)
217 # define synctex_line_box(a) vlink((a)+8)
219 /* unset nodes */
221 # define glue_stretch(a) varmem[(a)+7].cint
222 # define glue_shrink shift_amount
223 # define span_count subtype
225 typedef enum {
226 normal_rule = 0,
227 box_rule,
228 image_rule,
229 empty_rule,
230 user_rule,
231 } rule_subtypes;
233 # define rule_node_size 8
234 # define rule_dir(a) vlink((a)+5)
235 # define rule_index(a) vinfo((a)+6)
236 # define rule_transform(a) vlink((a)+6)
237 # define synctex_tag_rule(a) vinfo((a)+7)
238 # define synctex_line_rule(a) vlink((a)+7)
240 # define mark_node_size 3
241 # define mark_ptr(a) vlink((a)+2)
242 # define mark_class(a) vinfo((a)+2)
244 # define adjust_node_size 3
245 # define adjust_pre subtype
246 # define adjust_ptr(a) vlink(a+2)
248 # define glyph_node_size 6
249 # define character(a) vinfo((a)+2)
250 # define font(a) vlink((a)+2)
251 # define lang_data(a) vinfo((a)+3)
252 # define lig_ptr(a) vlink((a)+3)
253 # define x_displace(a) vinfo((a)+4)
254 # define y_displace(a) vlink((a)+4)
255 # define ex_glyph(a) vinfo((a)+5) /* expansion factor (hz) */
257 # define is_char_node(a) (a!=null && type(a)==glyph_node)
259 # define char_lang(a) ((const int)(signed short)(((signed int)((unsigned)lang_data(a)&0x7FFF0000)<<1)>>17))
260 # define char_lhmin(a) ((const int)(((unsigned)lang_data(a) & 0x0000FF00)>>8))
261 # define char_rhmin(a) ((const int)(((unsigned)lang_data(a) & 0x000000FF)))
262 # define char_uchyph(a) ((const int)(((unsigned)lang_data(a) & 0x80000000)>>31))
264 # define make_lang_data(a,b,c,d) (a>0 ? (1<<31): 0)+ \
265 (b<<16)+ (((c>0 && c<256) ? c : 255)<<8)+(((d>0 && d<256) ? d : 255))
267 # define init_lang_data(a) lang_data(a)=256+1
269 # define set_char_lang(a,b) lang_data(a)=make_lang_data(char_uchyph(a),b,char_lhmin(a),char_rhmin(a))
270 # define set_char_lhmin(a,b) lang_data(a)=make_lang_data(char_uchyph(a),char_lang(a),b,char_rhmin(a))
271 # define set_char_rhmin(a,b) lang_data(a)=make_lang_data(char_uchyph(a),char_lang(a),char_lhmin(a),b)
272 # define set_char_uchyph(a,b) lang_data(a)=make_lang_data(b,char_lang(a),char_lhmin(a),char_rhmin(a))
274 # define margin_kern_node_size 4
275 # define margin_char(a) vlink((a)+3)
277 /*@# {|subtype| of marginal kerns}*/
279 # define left_side 0
280 # define right_side 1
282 # define before 0 /* |subtype| for math node that introduces a formula */
283 # define after 1 /* |subtype| for math node that winds up a formula */
285 # define math_node_size 4
286 # define surround(a) vlink((a)+2)
287 /* also: glue_ptr(a) vinfo((a)+2) */
288 # define synctex_tag_math(a) vinfo((a)+3)
289 # define synctex_line_math(a) vlink((a)+3)
291 # define ins_node_size 6
292 # define float_cost(a) varmem[(a)+2].cint
293 # define ins_ptr(a) vinfo((a)+5)
294 # define split_top_ptr(a) vlink((a)+5)
296 # define page_ins_node_size 5
298 /* height = 4 */
300 typedef enum {
301 hlist_node = 0,
302 vlist_node,
303 rule_node,
304 ins_node,
305 mark_node,
306 adjust_node,
307 boundary_node,
308 disc_node,
309 whatsit_node,
310 #define last_preceding_break_node whatsit_node
311 local_par_node,
312 dir_node,
313 #define last_non_discardable_node dir_node
314 math_node,
315 glue_node,
316 kern_node,
317 penalty_node,
318 unset_node,
319 style_node,
320 choice_node,
321 simple_noad,
322 radical_noad,
323 fraction_noad,
324 accent_noad,
325 fence_noad,
326 math_char_node, /* kernel fields */
327 sub_box_node,
328 sub_mlist_node,
329 math_text_char_node,
330 delim_node, /* shield fields */
331 margin_kern_node,
332 glyph_node,
333 align_record_node,
334 pseudo_file_node,
335 pseudo_line_node,
336 inserting_node,
337 split_up_node,
338 expr_node,
339 nesting_node,
340 span_node,
341 attribute_node,
342 glue_spec_node,
343 attribute_list_node,
344 temp_node,
345 align_stack_node,
346 movement_node,
347 if_node,
348 unhyphenated_node,
349 hyphenated_node,
350 delta_node,
351 passive_node,
352 shape_node,
353 } node_types;
355 # define MAX_NODE_TYPE shape_node /* 60 */
358 TH: these two defines still need checking. The node ordering in luatex is not
359 quite the same as in tex82, HH: but it's probably ok
364 # define precedes_break(a) \
365 # (type(a)<math_node && \
366 # (type(a)!=whatsit_node || (subtype(a)!=dir_node && subtype(a)!=local_par_node)))
371 # define precedes_break(a) (type(a)<math_node)
372 # define non_discardable(a) (type(a)<math_node || type(a) == dir_node || type(a) == local_par_node)
375 # define precedes_break(a) (type(a)<=last_preceding_break_node)
376 # define non_discardable(a) (type(a)<=last_non_discardable_node)
378 # define known_node_type(i) ( i >= 0 && i <= MAX_NODE_TYPE)
380 # define last_known_node temp_node /* used by \lastnodetype */
382 # define movement_node_size 3
383 # define expr_node_size 3
384 # define if_node_size 2
385 # define align_stack_node_size 6
386 # define nesting_node_size 2
388 # define span_node_size 3
389 # define span_span(a) vlink((a)+1)
390 # define span_link(a) vinfo((a)+1)
392 # define pseudo_file_node_size 2
393 # define pseudo_lines(a) vlink((a)+1)
395 # define nodetype_has_attributes(t) (((t)<=glyph_node) && ((t)!=unset_node))
397 # define nodetype_has_subtype(t) ((t)!=attribute_list_node && (t)!=attribute_node && (t)!=glue_spec_node)
398 # define nodetype_has_prev(t) nodetype_has_subtype((t))
401 style and choice nodes; style nodes can be smaller, the information is encoded in
402 |subtype|, but choice nodes are on-the-spot converted to style nodes
405 # define style_node_size 4
406 # define display_mlist(a) vinfo((a)+2) /* mlist to be used in display style */
407 # define text_mlist(a) vlink((a)+2) /* mlist to be used in text style */
408 # define script_mlist(a) vinfo((a)+3) /* mlist to be used in script style */
409 # define script_script_mlist(a) vlink((a)+3) /* mlist to be used in scriptscript style */
412 because noad types get changed when processing we need to make sure some if the node
413 sizes match and that we don't share slots with different properties
415 once it's sorted out we can go smaller and also adapt the flush etc code to it
418 /* regular noads */
420 # define noad_size 8
421 # define new_hlist(a) vlink((a)+2) /* the translation of an mlist */
422 # define nucleus(a) vinfo((a)+2) /* the |nucleus| field of a noad */
423 # define supscr(a) vlink((a)+3) /* the |supscr| field of a noad */
424 # define subscr(a) vinfo((a)+3) /* the |subscr| field of a noad */
425 # define noaditalic(a) vlink((a)+4)
426 # define noadwidth(a) vinfo((a)+4)
427 # define noadheight(a) vlink((a)+5)
428 # define noaddepth(a) vinfo((a)+5)
429 # define noadextra1(a) vlink((a)+6) /* we need to match delimiter (saves copy) */
430 # define noadextra2(a) vinfo((a)+6)
431 # define noadextra3(a) vlink((a)+7) /* see (!) below */
432 # define noadextra4(a) vinfo((a)+7)
434 /* accent noads */
436 # define accent_noad_size 8
437 # define top_accent_chr(a) vinfo((a)+6) /* the |top_accent_chr| field of an accent noad */
438 # define bot_accent_chr(a) vlink((a)+6) /* the |bot_accent_chr| field of an accent noad */
439 # define overlay_accent_chr(a) vinfo((a)+7) /* the |overlay_accent_chr| field of an accent noad */
440 # define accentfraction(a) vlink((a)+7)
442 /* left and right noads */
444 # define fence_noad_size 8 /* needs to match noad size */
445 # define delimiteritalic(a) vlink((a)+4)
446 /* define delimiterwidth(a) vinfo((a)+4) */
447 # define delimiterheight(a) vlink((a)+5)
448 # define delimiterdepth(a) vinfo((a)+5)
449 # define delimiter(a) vlink((a)+6) /* |delimiter| field in left and right noads */
450 # define delimiteroptions(a) vinfo((a)+6)
451 # define delimiterclass(a) vlink((a)+7) /* (!) we could probably pack some more in 6 */
452 # define delimiterextra1(a) vinfo((a)+7) /* not used */
454 /* when dimensions then axis else noaxis */
456 typedef enum {
457 noad_option_set = 0x08,
458 noad_option_unused_1 = 0x00 + 0x08,
459 noad_option_unused_2 = 0x01 + 0x08,
460 noad_option_axis = 0x02 + 0x08,
461 noad_option_no_axis = 0x04 + 0x08,
462 noad_option_exact = 0x10 + 0x08,
463 noad_option_left = 0x11 + 0x08,
464 noad_option_middle = 0x12 + 0x08,
465 noad_option_right = 0x14 + 0x08,
466 } delimiter_options ;
468 # define delimiteroptionset(a) ((delimiteroptions(a) & noad_option_set ) == noad_option_set )
469 # define delimiteraxis(a) ((delimiteroptions(a) & noad_option_axis ) == noad_option_axis )
470 # define delimiternoaxis(a) ((delimiteroptions(a) & noad_option_no_axis) == noad_option_no_axis)
471 # define delimiterexact(a) ((delimiteroptions(a) & noad_option_exact ) == noad_option_exact )
473 /* subtype of fence noads */
475 # define left_noad_side 1
476 # define middle_noad_side 2
477 # define right_noad_side 3
478 # define no_noad_side 4
480 /* fraction noads */
482 # define fraction_noad_size 7
483 # define thickness(a) vlink((a)+2) /* |thickness| field in a fraction noad */
484 # define numerator(a) vlink((a)+3) /* |numerator| field in a fraction noad */
485 # define denominator(a) vinfo((a)+3) /* |denominator| field in a fraction noad */
486 # define left_delimiter(a) vlink((a)+5) /* first delimiter field of a noad */
487 # define right_delimiter(a) vinfo((a)+5) /* second delimiter field of a fraction noad */
488 # define middle_delimiter(a) vlink((a)+6)
489 # define fractionoptions(a) vinfo((a)+6)
491 # define fractionoptionset(a) ((fractionoptions(a) & noad_option_set ) == noad_option_set )
492 # define fractionexact(a) ((fractionoptions(a) & noad_option_exact ) == noad_option_exact )
493 # define fractionnoaxis(a) ((fractionoptions(a) & noad_option_no_axis) == noad_option_no_axis)
495 /* radical noads */
496 /* this is like a fraction, but it only stores a |left_delimiter| */
498 # define radical_noad_size 7
499 # define radicalwidth(a) vinfo((a)+4)
500 # define degree(a) vlink((a)+6) /* the root degree in a radical noad */
501 # define radicaloptions(a) vinfo((a)+6)
503 # define radicaloptionset(a) ((radicaloptions(a) & noad_option_set ) == noad_option_set)
504 # define radicalexact(a) ((radicaloptions(a) & noad_option_exact ) == noad_option_exact)
505 # define radicalleft(a) ((radicaloptions(a) & noad_option_left ) == noad_option_left)
506 # define radicalmiddle(a) ((radicaloptions(a) & noad_option_middle) == noad_option_middle)
507 # define radicalright(a) ((radicaloptions(a) & noad_option_right ) == noad_option_right)
509 /* accessors for the |nucleus|-style node fields */
511 # define math_kernel_node_size 3
512 # define math_fam(a) vinfo((a)+2)
513 # define math_character(a) vlink((a)+2)
514 # define math_list(a) vlink((a)+2)
516 /* accessors for the |delimiter|-style two-word subnode fields */
518 # define math_shield_node_size 4 /* not used yet */
520 # define small_fam(A) vinfo((A)+2) /* |fam| for ``small'' delimiter */
521 # define small_char(A) vlink((A)+2) /* |character| for ``small'' delimiter */
522 # define large_fam(A) vinfo((A)+3) /* |fam| for ``large'' delimiter */
523 # define large_char(A) vlink((A)+3) /* |character| for ``large'' delimiter */
525 /* we should have the codes in a separate enum: extension_codes */
527 /* be careful: must be in sync with whatsit_node_data[] ! (at least) */
529 typedef enum {
530 /* core */
531 open_node = 0,
532 write_node,
533 close_node,
534 special_node,
535 use_box_resource_node,
536 use_image_resource_node,
537 save_pos_node,
538 late_lua_node,
539 user_defined_node,
540 /* dvi backend */
541 dvi_literal_node = 15,
542 /* pdf backend */
543 pdf_literal_node = 16,
544 pdf_refobj_node,
545 pdf_annot_node,
546 pdf_start_link_node,
547 pdf_end_link_node,
548 pdf_dest_node,
549 pdf_action_node,
550 pdf_thread_node,
551 pdf_start_thread_node,
552 pdf_end_thread_node,
553 pdf_thread_data_node,
554 pdf_link_data_node,
555 pdf_colorstack_node,
556 pdf_setmatrix_node,
557 pdf_save_node,
558 pdf_restore_node,
559 } whatsit_types;
561 # define first_common_whatsit 0
562 # define last_common_whatsit user_defined_node
563 # define backend_first_dvi_whatsit 15
564 # define backend_last_dvi_whatsit 15
565 # define backend_first_pdf_whatsit 16
566 # define backend_last_pdf_whatsit 31
568 # define MAX_WHATSIT_TYPE 32
570 # define known_whatsit_type(i) ( \
571 (i >= first_common_whatsit && i <= last_common_whatsit) || \
572 (i >= backend_first_dvi_whatsit && i <= backend_last_dvi_whatsit) || \
573 (i >= backend_first_pdf_whatsit && i <= backend_last_pdf_whatsit) \
576 # define get_node_size(i,j) (i!=whatsit_node ? node_data[i].size : whatsit_node_data[j].size)
577 # define get_node_name(i,j) (i!=whatsit_node ? node_data[i].name : whatsit_node_data[j].name)
578 # define get_etex_code(i) (node_data[i].etex)
580 # define GLYPH_CHARACTER (1 << 0)
581 # define GLYPH_LIGATURE (1 << 1)
582 # define GLYPH_GHOST (1 << 2)
583 # define GLYPH_LEFT (1 << 3)
584 # define GLYPH_RIGHT (1 << 4)
586 # define is_character(p) ((subtype(p)) & GLYPH_CHARACTER)
587 # define is_ligature(p) ((subtype(p)) & GLYPH_LIGATURE )
588 # define is_ghost(p) ((subtype(p)) & GLYPH_GHOST )
590 # define is_simple_character(p) (is_character(p) && !is_ligature(p) && !is_ghost(p))
592 # define is_leftboundary(p) (is_ligature(p) && ((subtype(p)) & GLYPH_LEFT ))
593 # define is_rightboundary(p) (is_ligature(p) && ((subtype(p)) & GLYPH_RIGHT ))
594 # define is_leftghost(p) (is_ghost(p) && ((subtype(p)) & GLYPH_LEFT ))
595 # define is_rightghost(p) (is_ghost(p) && ((subtype(p)) & GLYPH_RIGHT ))
598 # define set_is_glyph(p) subtype(p) = (quarterword) (subtype(p) & ~GLYPH_CHARACTER)
599 # define set_is_character(p) subtype(p) = (quarterword) (subtype(p) | GLYPH_CHARACTER)
600 # define set_is_ligature(p) subtype(p) = (quarterword) (subtype(p) | GLYPH_LIGATURE)
601 # define set_is_ghost(p) subtype(p) = (quarterword) (subtype(p) |GLYPH_GHOST)
603 # define set_to_glyph(p) subtype(p) = (quarterword)(subtype(p) & 0xFF00)
604 # define set_to_character(p) subtype(p) = (quarterword)((subtype(p) & 0xFF00) | GLYPH_CHARACTER)
605 # define set_to_ligature(p) subtype(p) = (quarterword)((subtype(p) & 0xFF00) | GLYPH_LIGATURE)
606 # define set_to_ghost(p) subtype(p) = (quarterword)((subtype(p) & 0xFF00) | GLYPH_GHOST)
608 # define set_is_leftboundary(p) { set_to_ligature(p); subtype(p) |= GLYPH_LEFT; }
609 # define set_is_rightboundary(p) { set_to_ligature(p); subtype(p) |= GLYPH_RIGHT; }
610 # define set_is_leftghost(p) { set_to_ghost(p); subtype(p) |= GLYPH_LEFT; }
611 # define set_is_rightghost(p) { set_to_ghost(p); subtype(p) |= GLYPH_RIGHT; }
613 typedef enum {
614 cancel_boundary = 0,
615 user_boundary
616 } boundary_subtypes ;
618 # define boundary_size 3
619 # define boundary_value(a) vinfo((a)+2)
621 # define special_node_size 3
623 # define dir_node_size 6
624 # define dir_dir(a) vinfo((a)+2)
625 # define dir_level(a) vlink((a)+2)
626 # define dir_dvi_ptr(a) vinfo((a)+3)
627 # define dir_dvi_h(a) vlink((a)+3) /* obsolete */
628 # define dir_refpos_h(a) vinfo((a)+4)
629 # define dir_refpos_v(a) vlink((a)+4)
630 # define dir_cur_h(a) vinfo((a)+5)
631 # define dir_cur_v(a) vlink((a)+5)
633 # define write_node_size 3
634 # define close_node_size 3
635 # define write_tokens(a) vlink(a+2)
636 # define write_stream(a) vinfo(a+2)
638 # define open_node_size 4
639 # define open_name(a) vlink((a)+2)
640 # define open_area(a) vinfo((a)+3)
641 # define open_ext(a) vlink((a)+3)
643 # define late_lua_node_size 4
644 # define late_lua_data(a) vlink((a)+2)
645 # define late_lua_reg(a) vinfo((a)+2)
646 # define late_lua_name(a) vlink((a)+3)
647 # define late_lua_type(a) subtype((a)+3)
649 # define save_pos_node_size 3
651 # define local_par_size 6
653 # define local_pen_inter(a) vinfo((a)+2)
654 # define local_pen_broken(a) vlink((a)+2)
655 # define local_box_left(a) vlink((a)+3)
656 # define local_box_left_width(a) vinfo((a)+3)
657 # define local_box_right(a) vlink((a)+4)
658 # define local_box_right_width(a) vinfo((a)+4)
659 # define local_par_dir(a) vinfo((a)+5)
661 /* type of literal data */
663 # define lua_refid_literal 1 /* not a |normal| string */
665 /* begin of pdf backend nodes */
667 /* literal ctm types */
669 typedef enum {
670 set_origin = 0,
671 direct_page,
672 direct_always,
673 scan_special,
674 } ctm_transform_modes;
676 # define pdf_refobj_node_size 3
678 # define pdf_obj_objnum(a) vinfo((a) + 2)
680 # define pdf_annot_node_size 8
681 # define pdf_dest_node_size 8
682 # define pdf_thread_node_size 8
685 when a whatsit node representing annotation is created, words |1..3| are
686 width, height and depth of this annotation; after shipping out words |1..4|
687 are rectangle specification of annotation. For whatsit node representing
688 destination |pdf_ann_left| and |pdf_ann_top| are used for some types of destinations
692 coordinates of destinations/threads/annotations (in whatsit node)
695 # define pdf_ann_left(a) varmem[(a) + 2].cint
696 # define pdf_ann_top(a) varmem[(a) + 3].cint
697 # define pdf_ann_right(a) varmem[(a) + 4].cint
698 # define pdf_ann_bottom(a) varmem[(a) + 5].cint
700 # define pdf_literal_data(a) vlink((a)+2)
701 # define pdf_literal_mode(a) type((a)+2)
702 # define pdf_literal_type(a) subtype((a)+2)
704 # define pdf_annot_data(a) vinfo((a) + 6)
705 # define pdf_link_attr(a) vinfo((a) + 6)
706 # define pdf_link_action(a) vlink((a) + 6)
707 # define pdf_annot_objnum(a) varmem[(a) + 7].cint
708 # define pdf_link_objnum(a) varmem[(a) + 7].cint
710 # define pdf_dest_type(a) type((a) + 6)
711 # define pdf_dest_named_id(a) subtype((a) + 6)
712 # define pdf_dest_id(a) vlink((a) + 6)
713 # define pdf_dest_xyz_zoom(a) vinfo((a) + 7)
714 # define pdf_dest_objnum(a) vlink((a) + 7)
716 # define pdf_thread_named_id(a) subtype((a) + 6)
717 # define pdf_thread_id(a) vlink((a) + 6)
718 # define pdf_thread_attr(a) vinfo((a) + 7)
720 # define pdf_end_link_node_size 3
721 # define pdf_end_thread_node_size 3
723 # define pdf_setmatrix_node_size 3
724 # define pdf_save_node_size 3
725 # define pdf_restore_node_size 3
727 # define pdf_colorstack_node_size 4
728 # define pdf_colorstack_stack(a) vlink((a)+2)
729 # define pdf_colorstack_cmd(a) vinfo((a)+2)
730 # define pdf_colorstack_data(a) vlink((a)+3)
731 # define pdf_setmatrix_data(a) vlink((a)+2)
733 typedef enum {
734 pdf_action_page = 0,
735 pdf_action_goto,
736 pdf_action_thread,
737 pdf_action_user
738 } pdf_action_type;
740 typedef enum {
741 pdf_window_notset,
742 pdf_window_new,
743 pdf_window_nonew,
744 } pdf_window_type;
746 # define pdf_action_size 6
748 # define pdf_action_type(a) vlink((a)+2) /* enum pdf_action_type */
749 # define pdf_action_named_id(a) vinfo((a)+2) /* boolean */
750 # define pdf_action_id(a) vlink((a)+3) /* number or toks */
751 # define pdf_action_file(a) vinfo((a)+3) /* toks */
752 # define pdf_action_new_window(a) vlink((a)+4) /* enum pdf_window_type */
753 # define pdf_action_tokens(a) vinfo((a)+4) /* toks */
754 # define pdf_action_refcount(a) vlink((a)+5) /* number */
756 typedef enum {
757 colorstack_set = 0,
758 colorstack_push,
759 colorstack_pop,
760 colorstack_current
761 } colorstack_commands;
763 # define colorstack_data colorstack_push /* last value where data field is set */
765 /* end of pdf backend nodes */
767 /* user defined nodes */
769 # define user_defined_node_size 4
770 # define user_node_type(a) vinfo((a)+2)
771 # define user_node_id(a) vlink((a)+2)
772 # define user_node_value(a) vinfo((a)+3)
774 /* node sused in the parbuilder */
776 # define active_node_size 4 /*number of words in extended active nodes */
777 # define fitness subtype /*|very_loose_fit..tight_fit| on final line for this break */
778 # define break_node(a) vlink((a)+1) /*pointer to the corresponding passive node */
779 # define line_number(a) vinfo((a)+1) /*line that begins at this breakpoint */
780 # define total_demerits(a) varmem[(a)+2].cint /* the quantity that \TeX\ minimizes */
781 # define active_short(a) vinfo(a+3) /* |shortfall| of this line */
782 # define active_glue(a) vlink(a+3) /*corresponding glue stretch or shrink */
784 # define passive_node_size 7
785 # define cur_break(a) vlink((a)+1) /*in passive node, points to position of this breakpoint */
786 # define prev_break(a) vinfo((a)+1) /*points to passive node that should precede this one */
787 # define passive_pen_inter(a) vinfo((a)+2)
788 # define passive_pen_broken(a) vlink((a)+2)
789 # define passive_left_box(a) vlink((a)+3)
790 # define passive_left_box_width(a) vinfo((a)+3)
791 # define passive_last_left_box(a) vlink((a)+4)
792 # define passive_last_left_box_width(a) vinfo((a)+4)
793 # define passive_right_box(a) vlink((a)+5)
794 # define passive_right_box_width(a) vinfo((a)+5)
795 # define serial(a) vlink((a)+6) /* serial number for symbolic identification */
797 # define delta_node_size 10 /* 8 fields, stored in a+1..9 */
799 /* helpers */
801 # define couple_nodes(a,b) {assert(b!=null);vlink(a)=b;alink(b)=a;}
802 # define try_couple_nodes(a,b) if (b==null) vlink(a)=b; else {couple_nodes(a,b);}
803 # define uncouple_node(a) {assert(a!=null);vlink(a)=null;alink(a)=null;}
805 # define cache_disabled max_halfword
807 extern void delete_attribute_ref(halfword b);
808 extern void reset_node_properties(halfword b);
809 extern void reassign_attribute(halfword n,halfword new);
810 extern void build_attribute_list(halfword b);
811 extern halfword current_attribute_list(void);
813 extern int unset_attribute(halfword n, int c, int w);
814 extern void set_attribute(halfword n, int c, int w);
815 extern int has_attribute(halfword n, int c, int w);
817 extern halfword new_span_node(halfword n, int c, scaled w);
819 extern void print_short_node_contents(halfword n);
820 extern void show_node_list(int i);
821 extern pointer actual_box_width(pointer r, scaled base_width);
823 /* from luanode.c */
825 typedef struct _node_info {
826 int id;
827 int size;
828 const char **fields;
829 const char *name;
830 int etex;
831 } node_info;
833 extern node_info node_data[];
834 extern node_info whatsit_node_data[];
836 extern const char *node_subtypes_glue[];
837 extern const char *node_subtypes_leader[];
838 extern const char *node_subtypes_fill[];
839 extern const char *node_subtypes_penalty[];
840 extern const char *node_subtypes_kern[];
841 extern const char *node_subtypes_rule[];
842 extern const char *node_subtypes_glyph[];
843 extern const char *node_subtypes_disc[];
844 extern const char *node_subtypes_marginkern[];
845 extern const char *node_subtypes_list[];
846 extern const char *node_subtypes_math[];
847 extern const char *node_subtypes_noad[];
848 extern const char *node_subtypes_radical[];
849 extern const char *node_subtypes_accent[];
850 extern const char *node_subtypes_fence[];
852 extern const char *node_subtypes_pdf_destination[];
853 extern const char *node_subtypes_pdf_literal[];
855 extern halfword new_node(int i, int j);
856 extern void flush_node_list(halfword);
857 extern void flush_node(halfword);
858 extern halfword do_copy_node_list(halfword, halfword);
859 extern halfword copy_node_list(halfword);
860 extern halfword copy_node(const halfword);
861 extern void check_node(halfword);
862 extern void fix_node_list(halfword);
863 extern int fix_node_lists;
864 extern char *sprint_node_mem_usage(void);
865 extern halfword raw_glyph_node(void);
866 extern halfword new_glyph_node(void);
867 extern int valid_node(halfword);
869 extern void flush_node_wrapup_dvi(halfword);
870 extern void flush_node_wrapup_pdf(halfword);
871 extern void copy_node_wrapup_dvi(halfword, halfword); /* original target */
872 extern void copy_node_wrapup_pdf(halfword, halfword); /* original target */
873 extern void check_node_wrapup_dvi(halfword); /* DEBUG_NODES mode */
874 extern void check_node_wrapup_pdf(halfword); /* DEBUG_NODES mode */
875 extern void show_node_wrapup_dvi(halfword);
876 extern void show_node_wrapup_pdf(halfword);
878 typedef enum {
879 normal_g = 0,
880 sfi,
881 fil,
882 fill,
883 filll
884 } glue_orders;
886 # define zero_glue 0
887 # define sfi_glue zero_glue+glue_spec_size
888 # define fil_glue sfi_glue+glue_spec_size
889 # define fill_glue fil_glue+glue_spec_size
890 # define ss_glue fill_glue+glue_spec_size
891 # define fil_neg_glue ss_glue+glue_spec_size
892 # define page_ins_head fil_neg_glue+glue_spec_size
893 # define contrib_head page_ins_head+temp_node_size
894 # define page_head contrib_head+temp_node_size
895 # define temp_head page_head+temp_node_size
896 # define hold_head temp_head+temp_node_size
897 # define adjust_head hold_head+temp_node_size
898 # define pre_adjust_head adjust_head+temp_node_size
899 # define active pre_adjust_head+temp_node_size
900 # define align_head active+active_node_size
901 # define end_span align_head+temp_node_size
902 # define begin_point end_span+span_node_size
903 # define end_point begin_point+glyph_node_size
904 # define var_mem_stat_max (end_point+glyph_node_size-1)
906 # define stretching 1
907 # define shrinking 2
909 # define is_running(A) ((A)==null_flag) /* tests for a running dimension */
911 extern halfword tail_of_list(halfword p);
912 extern void delete_glue_ref(halfword p);
914 extern int var_used;
915 extern halfword temp_ptr;
917 # define cache_disabled max_halfword
919 extern int max_used_attr;
920 extern halfword attr_list_cache;
922 extern halfword new_null_box(void);
923 extern halfword new_rule(int s);
924 extern halfword new_glyph(int f, int c);
925 extern quarterword norm_min(int h);
926 extern halfword new_char(int f, int c);
927 extern scaled glyph_width(halfword p);
928 extern scaled glyph_height(halfword p);
929 extern scaled glyph_depth(halfword p);
930 extern halfword new_disc(void);
931 extern halfword new_math(scaled w, int s);
932 extern halfword new_spec(halfword p);
933 extern halfword new_param_glue(int n);
934 extern halfword new_glue(halfword q);
935 extern halfword new_skip_param(int n);
936 extern halfword new_kern(scaled w);
937 extern halfword new_penalty(int m);
939 extern int lua_properties_enabled ;
940 extern int lua_properties_level ;
941 extern int lua_properties_use_metatable ;
943 #define local_inter_line_penalty int_par(local_inter_line_penalty_code)
944 #define local_broken_penalty int_par(local_broken_penalty_code)
945 #define local_left_box equiv(local_left_box_base)
946 #define local_right_box equiv(local_right_box_base)
948 extern halfword make_local_par_node(void);
950 #endif