fix getsup (HH)
[luatex.git] / source / texk / web2c / luatexdir / tex / texnodes.h
blobdda0925609e7ed9c7e02b8d552314e42fdc5922d
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 glue_is_positive(p) \
154 ((p == null) || (width(p) > 0))
156 #define reset_glue_to_zero(p) \
157 if (p != null) { \
158 width(p) = 0; \
159 stretch(p) = 0; \
160 shrink(p) = 0; \
161 stretch_order(p) = 0; \
162 shrink_order(p) = 0; \
165 #define copy_glue_values(p,q) \
166 if (q == null) { \
167 width(p) = 0; \
168 stretch(p) = 0; \
169 shrink(p) = 0; \
170 stretch_order(p) = 0; \
171 shrink_order(p) = 0; \
172 } else { \
173 width(p) = width(q); \
174 stretch(p) = stretch(q); \
175 shrink(p) = shrink(q); \
176 stretch_order(p) = stretch_order(q); \
177 shrink_order(p) = shrink_order(q); \
182 disc nodes could eventually be smaller, because the indirect
183 pointers are not really needed (8 instead of 10).
186 typedef enum {
187 discretionary_disc = 0,
188 explicit_disc,
189 automatic_disc,
190 syllable_disc,
191 init_disc, /* first of a duo of syllable_discs */
192 select_disc, /* second of a duo of syllable_discs */
193 } discretionary_subtypes;
195 # define disc_node_size 11
196 # define pre_break_head(a) ((a)+5)
197 # define post_break_head(a) ((a)+7)
198 # define no_break_head(a) ((a)+9)
200 # define disc_penalty(a) vlink((a)+2)
201 # define pre_break(a) vinfo((a)+3)
202 # define post_break(a) vlink((a)+3)
203 # define no_break(a) vlink((a)+4)
205 # define vlink_pre_break(a) vlink(pre_break_head(a))
206 # define vlink_post_break(a) vlink(post_break_head(a))
207 # define vlink_no_break(a) vlink(no_break_head(a))
209 # define tlink_pre_break(a) tlink(pre_break_head(a))
210 # define tlink_post_break(a) tlink(post_break_head(a))
211 # define tlink_no_break(a) tlink(no_break_head(a))
213 typedef enum {
214 font_kern = 0,
215 explicit_kern, /* |subtype| of kern nodes from \.{\\kern} and \.{\\/} */
216 accent_kern, /* |subtype| of kern nodes from accents */
217 italic_kern,
218 } kern_subtypes;
220 # define kern_node_size 5
221 # define ex_kern(a) vinfo((a)+3) /* expansion factor (hz) */
222 # define synctex_tag_kern(a) vinfo((a)+4)
223 # define synctex_line_kern(a) vlink((a)+4)
225 # define box_node_size 9
227 /* todo, make an enum of this */
229 typedef enum {
230 unknown_list = 0,
231 line_list = 1, /* paragraph lines */
232 hbox_list = 2, /* \.{\\hbox} */
233 indent_list = 3, /* indentation box */
234 align_row_list = 4, /* row from a \.{\\halign} or \.{\\valign} */
235 align_cell_list = 5, /* cell from a \.{\\halign} or \.{\\valign} */
236 equation_list = 6, /* display equation */
237 equation_number_list = 7, /* display equation number */
238 } list_subtypes ;
240 # define width(a) varmem[(a)+2].cint
241 # define depth(a) varmem[(a)+3].cint
242 # define height(a) varmem[(a)+4].cint
243 # define shift_amount(a) vlink((a)+5)
244 # define box_dir(a) vinfo((a)+5)
245 # define list_ptr(a) vlink((a)+6)
246 # define glue_order(a) subtype((a)+6)
247 # define glue_sign(a) type((a)+6)
248 # define glue_set(a) varmem[(a)+7].gr
249 # define synctex_tag_box(a) vinfo((a)+8)
250 # define synctex_line_box(a) vlink((a)+8)
252 /* unset nodes */
254 # define glue_stretch(a) varmem[(a)+7].cint
255 # define glue_shrink shift_amount
256 # define span_count subtype
258 typedef enum {
259 normal_rule = 0,
260 box_rule,
261 image_rule,
262 empty_rule,
263 user_rule,
264 math_over_rule,
265 math_under_rule,
266 math_fraction_rule,
267 math_radical_rule,
268 } rule_subtypes;
270 # define rule_node_size 8
271 # define rule_dir(a) vlink((a)+5)
272 # define rule_index(a) vinfo((a)+6)
273 # define rule_transform(a) vlink((a)+6)
274 # define synctex_tag_rule(a) vinfo((a)+7)
275 # define synctex_line_rule(a) vlink((a)+7)
277 # define rule_math_size rule_index
278 # define rule_math_font rule_transform
280 # define mark_node_size 3
281 # define mark_ptr(a) vlink((a)+2)
282 # define mark_class(a) vinfo((a)+2)
284 # define adjust_node_size 3
285 # define adjust_pre subtype
286 # define adjust_ptr(a) vlink(a+2)
288 # define glyph_node_size 6
289 # define character(a) vinfo((a)+2)
290 # define font(a) vlink((a)+2)
291 # define lang_data(a) vinfo((a)+3)
292 # define lig_ptr(a) vlink((a)+3)
293 # define x_displace(a) vinfo((a)+4)
294 # define y_displace(a) vlink((a)+4)
295 # define ex_glyph(a) vinfo((a)+5) /* expansion factor (hz) */
296 # define x_advance(a) vlink((a)+5)
298 # define is_char_node(a) (a!=null && type(a)==glyph_node)
300 # define char_lang(a) ((const int)(signed short)(((signed int)((unsigned)lang_data(a)&0x7FFF0000)<<1)>>17))
301 # define char_lhmin(a) ((const int)(((unsigned)lang_data(a) & 0x0000FF00)>>8))
302 # define char_rhmin(a) ((const int)(((unsigned)lang_data(a) & 0x000000FF)))
303 # define char_uchyph(a) ((const int)(((unsigned)lang_data(a) & 0x80000000)>>31))
305 # define make_lang_data(a,b,c,d) (a>0 ? (1<<31): 0)+ \
306 (b<<16)+ (((c>0 && c<256) ? c : 255)<<8)+(((d>0 && d<256) ? d : 255))
308 # define init_lang_data(a) lang_data(a)=256+1
310 # define set_char_lang(a,b) lang_data(a)=make_lang_data(char_uchyph(a),b,char_lhmin(a),char_rhmin(a))
311 # define set_char_lhmin(a,b) lang_data(a)=make_lang_data(char_uchyph(a),char_lang(a),b,char_rhmin(a))
312 # define set_char_rhmin(a,b) lang_data(a)=make_lang_data(char_uchyph(a),char_lang(a),char_lhmin(a),b)
313 # define set_char_uchyph(a,b) lang_data(a)=make_lang_data(b,char_lang(a),char_lhmin(a),char_rhmin(a))
315 # define margin_kern_node_size 4
316 # define margin_char(a) vlink((a)+3)
318 /*@# {|subtype| of marginal kerns}*/
320 # define left_side 0
321 # define right_side 1
323 # define before 0 /* |subtype| for math node that introduces a formula */
324 # define after 1 /* |subtype| for math node that winds up a formula */
326 # define math_node_size 7
327 /* define width(a) vinfo((a)+2) */
328 /* overlaps width */
329 /* define shrink(a) vinfo((a)+3) */
330 /* define stretch(a) vlink((a)+3) */
331 /* define stretch_order(a) vinfo((a)+4) */
332 /* define shrink_order(a) vlink((a)+4) */
333 /* leader_ptr slot */
334 # define surround(a) vinfo((a)+5)
335 # define synctex_tag_math(a) vinfo((a)+6)
336 # define synctex_line_math(a) vlink((a)+6)
338 # define ins_node_size 6
339 # define float_cost(a) varmem[(a)+2].cint
340 # define ins_ptr(a) vinfo((a)+5)
341 # define split_top_ptr(a) vlink((a)+5)
343 # define page_ins_node_size 5
345 /* height = 4 */
347 typedef enum {
348 hlist_node = 0,
349 vlist_node,
350 rule_node,
351 ins_node,
352 mark_node,
353 adjust_node,
354 boundary_node,
355 disc_node,
356 whatsit_node,
357 #define last_preceding_break_node whatsit_node
358 local_par_node,
359 dir_node,
360 #define last_non_discardable_node dir_node
361 math_node,
362 glue_node,
363 kern_node,
364 penalty_node,
365 unset_node,
366 style_node,
367 choice_node,
368 simple_noad,
369 radical_noad,
370 fraction_noad,
371 accent_noad,
372 fence_noad,
373 math_char_node, /* kernel fields */
374 sub_box_node,
375 sub_mlist_node,
376 math_text_char_node,
377 delim_node, /* shield fields */
378 margin_kern_node,
379 glyph_node, /* this and below have attributes */
380 align_record_node,
381 pseudo_file_node,
382 pseudo_line_node,
383 inserting_node,
384 split_up_node,
385 expr_node,
386 nesting_node,
387 span_node,
388 attribute_node,
389 glue_spec_node,
390 attribute_list_node,
391 temp_node,
392 align_stack_node,
393 movement_node,
394 if_node,
395 unhyphenated_node,
396 hyphenated_node,
397 delta_node,
398 passive_node,
399 shape_node,
400 } node_types;
402 # define MAX_NODE_TYPE shape_node /* 60 */
405 TH: these two defines still need checking. The node ordering in luatex is not
406 quite the same as in tex82, HH: but it's probably ok
411 # define precedes_break(a) \
412 # (type(a)<math_node && \
413 # (type(a)!=whatsit_node || (subtype(a)!=dir_node && subtype(a)!=local_par_node)))
418 # define precedes_break(a) (type(a)<math_node)
419 # define non_discardable(a) (type(a)<math_node || type(a) == dir_node || type(a) == local_par_node)
422 # define precedes_break(a) (type(a)<=last_preceding_break_node)
423 # define non_discardable(a) (type(a)<=last_non_discardable_node)
425 # define known_node_type(i) ( i >= 0 && i <= MAX_NODE_TYPE)
427 # define last_known_node temp_node /* used by \lastnodetype */
429 # define movement_node_size 3
430 # define if_node_size 2
431 # define align_stack_node_size 6
432 # define nesting_node_size 2
434 # define expr_node_size 3
435 # define expr_type(A) type((A)+1)
436 # define expr_state(A) subtype((A)+1) /* enum defined in scanning.w */
437 # define expr_e_field(A) vlink((A)+1) /* saved expression so far */
438 # define expr_t_field(A) vlink((A)+2) /* saved term so far */
439 # define expr_n_field(A) vinfo((A)+2) /* saved numerator */
441 # define span_node_size 3
442 # define span_span(a) vlink((a)+1)
443 # define span_link(a) vinfo((a)+1)
445 # define pseudo_file_node_size 2
446 # define pseudo_lines(a) vlink((a)+1)
448 # define nodetype_has_attributes(t) (((t)<=glyph_node) && ((t)!=unset_node))
450 # define nodetype_has_subtype(t) ((t)!=attribute_list_node && (t)!=attribute_node && (t)!=glue_spec_node)
451 # define nodetype_has_prev(t) nodetype_has_subtype((t))
454 style and choice nodes; style nodes can be smaller, the information is encoded in
455 |subtype|, but choice nodes are on-the-spot converted to style nodes
458 # define style_node_size 4
459 # define display_mlist(a) vinfo((a)+2) /* mlist to be used in display style */
460 # define text_mlist(a) vlink((a)+2) /* mlist to be used in text style */
461 # define script_mlist(a) vinfo((a)+3) /* mlist to be used in script style */
462 # define script_script_mlist(a) vlink((a)+3) /* mlist to be used in scriptscript style */
465 because noad types get changed when processing we need to make sure some if the node
466 sizes match and that we don't share slots with different properties
468 once it's sorted out we can go smaller and also adapt the flush etc code to it
471 /* regular noads */
473 # define noad_size 8
474 # define new_hlist(a) vlink((a)+2) /* the translation of an mlist */
475 # define nucleus(a) vinfo((a)+2) /* the |nucleus| field of a noad */
476 # define supscr(a) vlink((a)+3) /* the |supscr| field of a noad */
477 # define subscr(a) vinfo((a)+3) /* the |subscr| field of a noad */
478 # define noaditalic(a) vlink((a)+4)
479 # define noadwidth(a) vinfo((a)+4)
480 # define noadheight(a) vlink((a)+5)
481 # define noaddepth(a) vinfo((a)+5)
482 # define noadextra1(a) vlink((a)+6) /* we need to match delimiter (saves copy) */
483 # define noadextra2(a) vinfo((a)+6)
484 # define noadextra3(a) vlink((a)+7) /* see (!) below */
485 # define noadextra4(a) vinfo((a)+7)
487 /* accent noads */
489 # define accent_noad_size 8
490 # define top_accent_chr(a) vinfo((a)+6) /* the |top_accent_chr| field of an accent noad */
491 # define bot_accent_chr(a) vlink((a)+6) /* the |bot_accent_chr| field of an accent noad */
492 # define overlay_accent_chr(a) vinfo((a)+7) /* the |overlay_accent_chr| field of an accent noad */
493 # define accentfraction(a) vlink((a)+7)
495 /* left and right noads */
497 # define fence_noad_size 8 /* needs to match noad size */
498 # define delimiteritalic(a) vlink((a)+4)
499 /* define delimiterwidth(a) vinfo((a)+4) */
500 # define delimiterheight(a) vlink((a)+5)
501 # define delimiterdepth(a) vinfo((a)+5)
502 # define delimiter(a) vlink((a)+6) /* |delimiter| field in left and right noads */
503 # define delimiteroptions(a) vinfo((a)+6)
504 # define delimiterclass(a) vlink((a)+7) /* (!) we could probably pack some more in 6 */
505 # define delimiterextra1(a) vinfo((a)+7) /* not used */
507 /* when dimensions then axis else noaxis */
509 typedef enum {
510 noad_option_set = 0x08,
511 noad_option_unused_1 = 0x00 + 0x08,
512 noad_option_unused_2 = 0x01 + 0x08,
513 noad_option_axis = 0x02 + 0x08,
514 noad_option_no_axis = 0x04 + 0x08,
515 noad_option_exact = 0x10 + 0x08,
516 noad_option_left = 0x11 + 0x08,
517 noad_option_middle = 0x12 + 0x08,
518 noad_option_right = 0x14 + 0x08,
519 } delimiter_options ;
521 # define delimiteroptionset(a) ((delimiteroptions(a) & noad_option_set ) == noad_option_set )
522 # define delimiteraxis(a) ((delimiteroptions(a) & noad_option_axis ) == noad_option_axis )
523 # define delimiternoaxis(a) ((delimiteroptions(a) & noad_option_no_axis) == noad_option_no_axis)
524 # define delimiterexact(a) ((delimiteroptions(a) & noad_option_exact ) == noad_option_exact )
526 /* subtype of fence noads */
528 # define left_noad_side 1
529 # define middle_noad_side 2
530 # define right_noad_side 3
531 # define no_noad_side 4
533 /* fraction noads */
535 # define fraction_noad_size 7
536 # define thickness(a) vlink((a)+2) /* |thickness| field in a fraction noad */
537 # define numerator(a) vlink((a)+3) /* |numerator| field in a fraction noad */
538 # define denominator(a) vinfo((a)+3) /* |denominator| field in a fraction noad */
539 # define left_delimiter(a) vlink((a)+5) /* first delimiter field of a noad */
540 # define right_delimiter(a) vinfo((a)+5) /* second delimiter field of a fraction noad */
541 # define middle_delimiter(a) vlink((a)+6)
542 # define fractionoptions(a) vinfo((a)+6)
544 # define fractionoptionset(a) ((fractionoptions(a) & noad_option_set ) == noad_option_set )
545 # define fractionexact(a) ((fractionoptions(a) & noad_option_exact ) == noad_option_exact )
546 # define fractionnoaxis(a) ((fractionoptions(a) & noad_option_no_axis) == noad_option_no_axis)
548 /* radical noads */
549 /* this is like a fraction, but it only stores a |left_delimiter| */
551 # define radical_noad_size 7
552 # define radicalwidth(a) vinfo((a)+4)
553 # define degree(a) vlink((a)+6) /* the root degree in a radical noad */
554 # define radicaloptions(a) vinfo((a)+6)
556 # define radicaloptionset(a) ((radicaloptions(a) & noad_option_set ) == noad_option_set)
557 # define radicalexact(a) ((radicaloptions(a) & noad_option_exact ) == noad_option_exact)
558 # define radicalleft(a) ((radicaloptions(a) & noad_option_left ) == noad_option_left)
559 # define radicalmiddle(a) ((radicaloptions(a) & noad_option_middle) == noad_option_middle)
560 # define radicalright(a) ((radicaloptions(a) & noad_option_right ) == noad_option_right)
562 /* accessors for the |nucleus|-style node fields */
564 # define math_kernel_node_size 3
565 # define math_fam(a) vinfo((a)+2)
566 # define math_character(a) vlink((a)+2)
567 # define math_list(a) vlink((a)+2)
569 /* accessors for the |delimiter|-style two-word subnode fields */
571 # define math_shield_node_size 4 /* not used yet */
573 # define small_fam(A) vinfo((A)+2) /* |fam| for ``small'' delimiter */
574 # define small_char(A) vlink((A)+2) /* |character| for ``small'' delimiter */
575 # define large_fam(A) vinfo((A)+3) /* |fam| for ``large'' delimiter */
576 # define large_char(A) vlink((A)+3) /* |character| for ``large'' delimiter */
578 /* we should have the codes in a separate enum: extension_codes */
580 /* be careful: must be in sync with whatsit_node_data[] ! (at least) */
582 typedef enum {
583 /* core */
584 open_node = 0,
585 write_node,
586 close_node,
587 special_node,
588 use_box_resource_node,
589 use_image_resource_node,
590 save_pos_node,
591 late_lua_node,
592 user_defined_node,
593 /* dvi backend */
594 dvi_literal_node = 15,
595 /* pdf backend */
596 pdf_literal_node = 16,
597 pdf_refobj_node,
598 pdf_annot_node,
599 pdf_start_link_node,
600 pdf_end_link_node,
601 pdf_dest_node,
602 pdf_action_node,
603 pdf_thread_node,
604 pdf_start_thread_node,
605 pdf_end_thread_node,
606 pdf_thread_data_node,
607 pdf_link_data_node,
608 pdf_colorstack_node,
609 pdf_setmatrix_node,
610 pdf_save_node,
611 pdf_restore_node,
612 } whatsit_types;
614 # define first_common_whatsit 0
615 # define last_common_whatsit user_defined_node
616 # define backend_first_dvi_whatsit 15
617 # define backend_last_dvi_whatsit 15
618 # define backend_first_pdf_whatsit 16
619 # define backend_last_pdf_whatsit 31
621 # define MAX_WHATSIT_TYPE 32
623 # define known_whatsit_type(i) ( \
624 (i >= first_common_whatsit && i <= last_common_whatsit) || \
625 (i >= backend_first_dvi_whatsit && i <= backend_last_dvi_whatsit) || \
626 (i >= backend_first_pdf_whatsit && i <= backend_last_pdf_whatsit) \
629 # define get_node_size(i,j) (i!=whatsit_node ? node_data[i].size : whatsit_node_data[j].size)
630 # define get_node_name(i,j) (i!=whatsit_node ? node_data[i].name : whatsit_node_data[j].name)
631 # define get_etex_code(i) (node_data[i].etex)
633 # define GLYPH_CHARACTER (1 << 0)
634 # define GLYPH_LIGATURE (1 << 1)
635 # define GLYPH_GHOST (1 << 2)
636 # define GLYPH_LEFT (1 << 3)
637 # define GLYPH_RIGHT (1 << 4)
639 # define is_character(p) ((subtype(p)) & GLYPH_CHARACTER)
640 # define is_ligature(p) ((subtype(p)) & GLYPH_LIGATURE )
641 # define is_ghost(p) ((subtype(p)) & GLYPH_GHOST )
643 # define is_simple_character(p) (is_character(p) && !is_ligature(p) && !is_ghost(p))
645 # define is_leftboundary(p) (is_ligature(p) && ((subtype(p)) & GLYPH_LEFT ))
646 # define is_rightboundary(p) (is_ligature(p) && ((subtype(p)) & GLYPH_RIGHT ))
647 # define is_leftghost(p) (is_ghost(p) && ((subtype(p)) & GLYPH_LEFT ))
648 # define is_rightghost(p) (is_ghost(p) && ((subtype(p)) & GLYPH_RIGHT ))
651 # define set_is_glyph(p) subtype(p) = (quarterword) (subtype(p) & ~GLYPH_CHARACTER)
652 # define set_is_character(p) subtype(p) = (quarterword) (subtype(p) | GLYPH_CHARACTER)
653 # define set_is_ligature(p) subtype(p) = (quarterword) (subtype(p) | GLYPH_LIGATURE)
654 # define set_is_ghost(p) subtype(p) = (quarterword) (subtype(p) |GLYPH_GHOST)
656 # define set_to_glyph(p) subtype(p) = (quarterword)(subtype(p) & 0xFF00)
657 # define set_to_character(p) subtype(p) = (quarterword)((subtype(p) & 0xFF00) | GLYPH_CHARACTER)
658 # define set_to_ligature(p) subtype(p) = (quarterword)((subtype(p) & 0xFF00) | GLYPH_LIGATURE)
659 # define set_to_ghost(p) subtype(p) = (quarterword)((subtype(p) & 0xFF00) | GLYPH_GHOST)
661 # define set_is_leftboundary(p) { set_to_ligature(p); subtype(p) |= GLYPH_LEFT; }
662 # define set_is_rightboundary(p) { set_to_ligature(p); subtype(p) |= GLYPH_RIGHT; }
663 # define set_is_leftghost(p) { set_to_ghost(p); subtype(p) |= GLYPH_LEFT; }
664 # define set_is_rightghost(p) { set_to_ghost(p); subtype(p) |= GLYPH_RIGHT; }
666 typedef enum {
667 cancel_boundary = 0,
668 user_boundary,
669 protrusion_boundary,
670 word_boundary,
671 } boundary_subtypes ;
673 # define boundary_node_size 3
674 # define boundary_value(a) vinfo((a)+2)
676 # define special_node_size 3
678 # define dir_node_size 5
679 # define dir_dir(a) vinfo((a)+2)
680 # define dir_level(a) vlink((a)+2)
681 # define dir_refpos_h(a) vinfo((a)+3)
682 # define dir_refpos_v(a) vlink((a)+3)
683 # define dir_cur_h(a) vinfo((a)+4)
684 # define dir_cur_v(a) vlink((a)+4)
686 # define write_node_size 3
687 # define close_node_size 3
688 # define write_tokens(a) vlink(a+2)
689 # define write_stream(a) vinfo(a+2)
691 # define open_node_size 4
692 # define open_name(a) vlink((a)+2)
693 # define open_area(a) vinfo((a)+3)
694 # define open_ext(a) vlink((a)+3)
696 # define late_lua_node_size 4
697 # define late_lua_data(a) vlink((a)+2)
698 # define late_lua_reg(a) vinfo((a)+2)
699 # define late_lua_name(a) vlink((a)+3)
700 # define late_lua_type(a) subtype((a)+3)
702 # define save_pos_node_size 3
704 # define local_par_size 6
706 # define local_pen_inter(a) vinfo((a)+2)
707 # define local_pen_broken(a) vlink((a)+2)
708 # define local_box_left(a) vlink((a)+3)
709 # define local_box_left_width(a) vinfo((a)+3)
710 # define local_box_right(a) vlink((a)+4)
711 # define local_box_right_width(a) vinfo((a)+4)
712 # define local_par_dir(a) vinfo((a)+5)
714 /* type of literal data */
716 # define lua_refid_literal 1 /* not a |normal| string */
718 /* begin of pdf backend nodes */
720 /* literal ctm types */
722 typedef enum {
723 set_origin = 0,
724 direct_page,
725 direct_always,
726 direct_raw,
727 scan_special,
728 } ctm_transform_modes;
730 # define pdf_refobj_node_size 3
732 # define pdf_obj_objnum(a) vinfo((a) + 2)
734 # define pdf_annot_node_size 8
735 # define pdf_dest_node_size 8
736 # define pdf_thread_node_size 8
739 when a whatsit node representing annotation is created, words |1..3| are
740 width, height and depth of this annotation; after shipping out words |1..4|
741 are rectangle specification of annotation. For whatsit node representing
742 destination |pdf_ann_left| and |pdf_ann_top| are used for some types of destinations
746 coordinates of destinations/threads/annotations (in whatsit node)
749 # define pdf_ann_left(a) varmem[(a) + 2].cint
750 # define pdf_ann_top(a) varmem[(a) + 3].cint
751 # define pdf_ann_right(a) varmem[(a) + 4].cint
752 # define pdf_ann_bottom(a) varmem[(a) + 5].cint
754 # define pdf_literal_data(a) vlink((a)+2)
755 # define pdf_literal_mode(a) type((a)+2)
756 # define pdf_literal_type(a) subtype((a)+2)
758 # define pdf_annot_data(a) vinfo((a) + 6)
759 # define pdf_link_attr(a) vinfo((a) + 6)
760 # define pdf_link_action(a) vlink((a) + 6)
761 # define pdf_annot_objnum(a) varmem[(a) + 7].cint
762 # define pdf_link_objnum(a) varmem[(a) + 7].cint
764 # define pdf_dest_type(a) type((a) + 6)
765 # define pdf_dest_named_id(a) subtype((a) + 6)
766 # define pdf_dest_id(a) vlink((a) + 6)
767 # define pdf_dest_xyz_zoom(a) vinfo((a) + 7)
768 # define pdf_dest_objnum(a) vlink((a) + 7)
770 # define pdf_thread_named_id(a) subtype((a) + 6)
771 # define pdf_thread_id(a) vlink((a) + 6)
772 # define pdf_thread_attr(a) vinfo((a) + 7)
774 # define pdf_end_link_node_size 3
775 # define pdf_end_thread_node_size 3
777 # define pdf_setmatrix_node_size 3
778 # define pdf_save_node_size 3
779 # define pdf_restore_node_size 3
781 # define pdf_colorstack_node_size 4
782 # define pdf_colorstack_stack(a) vlink((a)+2)
783 # define pdf_colorstack_cmd(a) vinfo((a)+2)
784 # define pdf_colorstack_data(a) vlink((a)+3)
785 # define pdf_setmatrix_data(a) vlink((a)+2)
787 typedef enum {
788 pdf_action_page = 0,
789 pdf_action_goto,
790 pdf_action_thread,
791 pdf_action_user
792 } pdf_action_type;
794 typedef enum {
795 pdf_window_notset,
796 pdf_window_new,
797 pdf_window_nonew,
798 } pdf_window_type;
800 # define pdf_action_size 6
802 # define pdf_action_type(a) vlink((a)+2) /* enum pdf_action_type */
803 # define pdf_action_named_id(a) vinfo((a)+2) /* boolean */
804 # define pdf_action_id(a) vlink((a)+3) /* number or toks */
805 # define pdf_action_file(a) vinfo((a)+3) /* toks */
806 # define pdf_action_new_window(a) vlink((a)+4) /* enum pdf_window_type */
807 # define pdf_action_tokens(a) vinfo((a)+4) /* toks */
808 # define pdf_action_refcount(a) vlink((a)+5) /* number */
810 typedef enum {
811 colorstack_set = 0,
812 colorstack_push,
813 colorstack_pop,
814 colorstack_current
815 } colorstack_commands;
817 # define colorstack_data colorstack_push /* last value where data field is set */
819 /* end of pdf backend nodes */
821 /* user defined nodes */
823 # define user_defined_node_size 4
824 # define user_node_type(a) vinfo((a)+2)
825 # define user_node_id(a) vlink((a)+2)
826 # define user_node_value(a) vinfo((a)+3)
828 /* node sused in the parbuilder */
830 # define active_node_size 4 /*number of words in extended active nodes */
831 # define fitness subtype /*|very_loose_fit..tight_fit| on final line for this break */
832 # define break_node(a) vlink((a)+1) /*pointer to the corresponding passive node */
833 # define line_number(a) vinfo((a)+1) /*line that begins at this breakpoint */
834 # define total_demerits(a) varmem[(a)+2].cint /* the quantity that \TeX\ minimizes */
835 # define active_short(a) vinfo(a+3) /* |shortfall| of this line */
836 # define active_glue(a) vlink(a+3) /*corresponding glue stretch or shrink */
838 # define passive_node_size 7
839 # define cur_break(a) vlink((a)+1) /*in passive node, points to position of this breakpoint */
840 # define prev_break(a) vinfo((a)+1) /*points to passive node that should precede this one */
841 # define passive_pen_inter(a) vinfo((a)+2)
842 # define passive_pen_broken(a) vlink((a)+2)
843 # define passive_left_box(a) vlink((a)+3)
844 # define passive_left_box_width(a) vinfo((a)+3)
845 # define passive_last_left_box(a) vlink((a)+4)
846 # define passive_last_left_box_width(a) vinfo((a)+4)
847 # define passive_right_box(a) vlink((a)+5)
848 # define passive_right_box_width(a) vinfo((a)+5)
849 # define serial(a) vlink((a)+6) /* serial number for symbolic identification */
851 # define delta_node_size 10 /* 8 fields, stored in a+1..9 */
853 /* helpers */
855 # define couple_nodes(a,b) {assert(b!=null);vlink(a)=b;alink(b)=a;}
856 # define try_couple_nodes(a,b) if (b==null) vlink(a)=b; else {couple_nodes(a,b);}
857 # define uncouple_node(a) {assert(a!=null);vlink(a)=null;alink(a)=null;}
859 # define cache_disabled max_halfword
861 extern void delete_attribute_ref(halfword b);
862 extern void reset_node_properties(halfword b);
863 extern void reassign_attribute(halfword n,halfword new);
864 extern void build_attribute_list(halfword b);
865 extern halfword current_attribute_list(void);
867 extern int unset_attribute(halfword n, int c, int w);
868 extern void set_attribute(halfword n, int c, int w);
869 extern int has_attribute(halfword n, int c, int w);
871 extern halfword new_span_node(halfword n, int c, scaled w);
873 extern void print_short_node_contents(halfword n);
874 extern void show_node_list(int i);
875 extern pointer actual_box_width(pointer r, scaled base_width);
877 /* from luanode.c */
879 typedef struct _node_info {
880 int id;
881 int size;
882 const char **fields;
883 const char *name;
884 int etex;
885 } node_info;
887 extern node_info node_data[];
888 extern node_info whatsit_node_data[];
890 extern const char *node_subtypes_glue[];
891 extern const char *node_subtypes_mathglue[];
892 extern const char *node_subtypes_leader[];
893 extern const char *node_subtypes_fill[];
894 extern const char *node_subtypes_boundary[];
895 extern const char *node_subtypes_penalty[];
896 extern const char *node_subtypes_kern[];
897 extern const char *node_subtypes_rule[];
898 extern const char *node_subtypes_glyph[];
899 extern const char *node_subtypes_disc[];
900 extern const char *node_subtypes_marginkern[];
901 extern const char *node_subtypes_list[];
902 extern const char *node_subtypes_adjust[];
903 extern const char *node_subtypes_math[];
904 extern const char *node_subtypes_noad[];
905 extern const char *node_subtypes_radical[];
906 extern const char *node_subtypes_accent[];
907 extern const char *node_subtypes_fence[];
909 extern const char *node_subtypes_pdf_destination[];
910 extern const char *node_subtypes_pdf_literal[];
912 extern halfword new_node(int i, int j);
913 extern void flush_node_list(halfword);
914 extern void flush_node(halfword);
915 extern halfword do_copy_node_list(halfword, halfword);
916 extern halfword copy_node_list(halfword);
917 extern halfword copy_node(const halfword);
918 extern void check_node(halfword);
919 extern void fix_node_list(halfword);
920 extern int fix_node_lists;
921 extern char *sprint_node_mem_usage(void);
922 extern halfword raw_glyph_node(void);
923 extern halfword new_glyph_node(void);
924 extern int valid_node(halfword);
926 extern void flush_node_wrapup_dvi(halfword);
927 extern void flush_node_wrapup_pdf(halfword);
928 extern void copy_node_wrapup_dvi(halfword, halfword); /* original target */
929 extern void copy_node_wrapup_pdf(halfword, halfword); /* original target */
930 extern void check_node_wrapup_dvi(halfword); /* DEBUG_NODES mode */
931 extern void check_node_wrapup_pdf(halfword); /* DEBUG_NODES mode */
932 extern void show_node_wrapup_dvi(halfword);
933 extern void show_node_wrapup_pdf(halfword);
935 typedef enum {
936 normal_g = 0,
937 sfi,
938 fil,
939 fill,
940 filll
941 } glue_orders;
943 # define zero_glue 0
944 # define sfi_glue zero_glue+glue_spec_size
945 # define fil_glue sfi_glue+glue_spec_size
946 # define fill_glue fil_glue+glue_spec_size
947 # define ss_glue fill_glue+glue_spec_size
948 # define fil_neg_glue ss_glue+glue_spec_size
949 # define page_ins_head fil_neg_glue+glue_spec_size
951 # define contrib_head page_ins_head+temp_node_size
952 # define page_head contrib_head+temp_node_size
953 # define temp_head page_head+temp_node_size
954 # define hold_head temp_head+temp_node_size
955 # define adjust_head hold_head+temp_node_size
956 # define pre_adjust_head adjust_head+temp_node_size
957 # define active pre_adjust_head+temp_node_size
958 # define align_head active+active_node_size
959 # define end_span align_head+temp_node_size
960 # define begin_point end_span+span_node_size
961 # define end_point begin_point+glyph_node_size
962 # define var_mem_stat_max (end_point+glyph_node_size-1)
964 # define stretching 1
965 # define shrinking 2
967 # define last_normal_node shape_node
968 # define last_whatsit_node pdf_restore_node
970 # define is_running(A) ((A)==null_flag) /* tests for a running dimension */
972 extern halfword tail_of_list(halfword p);
974 extern int var_used;
976 # define cache_disabled max_halfword
978 extern int max_used_attr;
979 extern halfword attr_list_cache;
981 extern halfword new_null_box(void);
982 extern halfword new_rule(int s);
983 extern halfword new_glyph(int f, int c);
984 extern quarterword norm_min(int h);
985 extern halfword new_char(int f, int c);
986 extern scaled glyph_width(halfword p);
987 extern scaled glyph_height(halfword p);
988 extern scaled glyph_depth(halfword p);
989 extern halfword new_disc(void);
990 extern halfword new_math(scaled w, int s);
991 extern halfword new_spec(halfword p);
992 extern halfword new_param_glue(int n);
993 extern halfword new_glue(halfword q);
994 extern halfword new_skip_param(int n);
995 extern halfword new_kern(scaled w);
996 extern halfword new_penalty(int m);
998 extern int lua_properties_enabled ;
999 extern int lua_properties_level ;
1000 extern int lua_properties_use_metatable ;
1002 extern halfword make_local_par_node(int mode);
1004 #endif