1
4
5# ifndef LMT_TEXNODES_H
6# define LMT_TEXNODES_H
7
8
90
91typedef enum node_types {
92 hlist_node,
93 vlist_node,
94 rule_node,
95 insert_node,
96 mark_node,
97 adjust_node,
98 boundary_node,
99 disc_node,
100 whatsit_node,
101
102 par_node,
103 dir_node,
104
105 math_node,
106 glue_node,
107 kern_node,
108 penalty_node,
109 style_node,
110 choice_node,
111 parameter_node,
112 simple_noad,
113 radical_noad,
114 fraction_noad,
115 accent_noad,
116 fence_noad,
117 math_char_node,
118 math_text_char_node,
119 sub_box_node,
120 sub_mlist_node,
121 delimiter_node,
122 glyph_node,
123
124 unset_node,
125 specification_node,
126 align_record_node,
127 attribute_node,
128 glue_spec_node,
129 temp_node,
130 split_node,
131
132 expression_node,
133 lmtx_expression_node,
134 rpn_expression_node,
135 loop_state_node,
136 math_spec_node,
137 font_spec_node,
138 nesting_node,
139 span_node,
140 align_stack_node,
141
142 if_node,
143
144 unhyphenated_node,
145 hyphenated_node,
146
147 delta_node,
148
149 passive_node,
150} node_types;
151
152# define first_nodetype hlist_node
153# define last_nodetype passive_node
154
155
156
157# define max_chain_size 40
158
159# define unknown_node_type -1
160# define unknown_node_subtype -1
161
162
163
164typedef struct node_memory_state_info {
165 memoryword *nodes;
166
167 char *nodesizes;
168 halfword free_chain[max_chain_size];
169 memory_data nodes_data;
170 int reserved;
171 int padding;
172 int node_properties_id;
173 int lua_properties_level;
174 halfword attribute_cache;
175 halfword max_used_attribute;
176 int node_properties_table_size;
177} node_memory_state_info;
178
179extern node_memory_state_info lmt_node_memory_state;
180
181typedef enum field_types {
182 nil_field,
183 integer_field,
184 dimension_field,
185 glue_field,
186 number_field,
187 string_field,
188 boolean_field,
189 function_field,
190 node_field,
191 node_list_field,
192 token_field,
193 token_list_field,
194 attribute_field,
195} field_types;
196
197extern halfword tex_get_node (int size);
198extern void tex_free_node (halfword p, int size);
199extern void tex_dump_node_mem (dumpstream f);
200extern void tex_undump_node_mem (dumpstream f);
201extern int tex_used_node_count (void);
202extern int tex_free_node_count (void);
203extern void tex_initialize_node_mem (void);
204extern void tex_initialize_nodes (void);
205
206extern void lmt_nodelib_initialize (void);
207
208extern void tex_dump_specification_data (dumpstream f);
209extern void tex_undump_specification_data (dumpstream f);
210
211
269
270# define mvalue(a,b) lmt_node_memory_state.nodes[a+b].P
271# define lvalue(a,b) lmt_node_memory_state.nodes[a+b].L
272# define dvalue(a,b) lmt_node_memory_state.nodes[a+b].D
273
274# define vinfo(a,b) lmt_node_memory_state.nodes[a+b].half0
275# define vlink(a,b) lmt_node_memory_state.nodes[a+b].half1
276
277# define vinfo0(a,b) lmt_node_memory_state.nodes[a+b].quart00
278# define vinfo1(a,b) lmt_node_memory_state.nodes[a+b].quart01
279# define vlink0(a,b) lmt_node_memory_state.nodes[a+b].quart10
280# define vlink1(a,b) lmt_node_memory_state.nodes[a+b].quart11
281
282# define vinfo0s(a,b) lmt_node_memory_state.nodes[a+b].short00
283# define vinfo1s(a,b) lmt_node_memory_state.nodes[a+b].short01
284# define vlink0s(a,b) lmt_node_memory_state.nodes[a+b].short10
285# define vlink1s(a,b) lmt_node_memory_state.nodes[a+b].short11
286
287# define vinfo00(a,b) lmt_node_memory_state.nodes[a+b].single00
288# define vinfo01(a,b) lmt_node_memory_state.nodes[a+b].single01
289# define vinfo02(a,b) lmt_node_memory_state.nodes[a+b].single02
290# define vinfo03(a,b) lmt_node_memory_state.nodes[a+b].single03
291# define vlink00(a,b) lmt_node_memory_state.nodes[a+b].single10
292# define vlink01(a,b) lmt_node_memory_state.nodes[a+b].single11
293# define vlink02(a,b) lmt_node_memory_state.nodes[a+b].single12
294# define vlink03(a,b) lmt_node_memory_state.nodes[a+b].single13
295
296
310
311# define node_type(a) vinfo0(a,0)
312# define node_subtype(a) vinfo1(a,0)
313
314# define node_next(a) vlink(a,0)
315# define node_prev(a) vlink(a,1)
316# define node_attr(a) vinfo(a,1)
317
318# define node_head(a) vlink(a,0)
319# define node_tail(a) vinfo(a,1)
320
321
367
368
400
401
407
408# define temp_node_size 2
409
410
422
423# define attribute_node_size 2
424# define attribute_unset(a) vinfo(a,1)
425# define attribute_index(a) vinfo0(a,1)
426# define attribute_detail(a) vinfo1(a,1)
427# define attribute_count(a) vlink(a,1)
428# define attribute_value(a) vlink(a,1)
429
430typedef enum attribute_subtypes {
431 attribute_list_subtype,
432 attribute_value_subtype,
433} attribute_subtypes;
434
435# define last_attribute_subtype attribute_value_subtype
436
437
441
442# define penalty_node_size 5
443# define penalty_amount(a) vlink(a,2)
444# define penalty_options(a) vinfo(a,2)
445# define penalty_tnuoma(a) vlink(a,3)
446# define penalty_used(a) vinfo(a,3)
447# define penalty_belongs_to(a) vlink(a,4)
448# define penalty_reserved(a) vinfo(a,4)
449
450static inline void tex_add_penalty_option (halfword a, halfword r) { penalty_options(a) |= r; }
451static inline void tex_remove_penalty_option (halfword a, halfword r) { penalty_options(a) &= ~r; }
452static inline int tex_has_penalty_option (halfword a, halfword r) { return (penalty_options(a) & r) == r; }
453
454typedef enum penalty_option_codes {
455 penalty_option_normal = 0x0000,
456 penalty_option_math_forward = 0x0001,
457 penalty_option_math_backward = 0x0002,
458 penalty_option_orphaned = 0x0004,
459 penalty_option_widowed = 0x0008,
460 penalty_option_clubbed = 0x0010,
461 penalty_option_toddlered = 0x0020,
462 penalty_option_widow = 0x0040,
463 penalty_option_club = 0x0080,
464 penalty_option_broken = 0x0100,
465 penalty_option_shaping = 0x0200,
466 penalty_option_double = 0x0400,
467 penalty_option_double_used = 0x0800,
468 penalty_option_factor_used = 0x1000,
469 penalty_option_end_of_par = 0x2000,
470 penalty_option_in_insert = 0x4000,
471 penalty_option_final_balance = 0x8000,
472} penalty_option_codes;
473
474typedef enum penalty_subtypes {
475 user_penalty_subtype,
476 linebreak_penalty_subtype,
477 line_penalty_subtype,
478 word_penalty_subtype,
479 orphan_penalty_subtype,
480 toddler_penalty_subtype,
481 single_line_penalty_subtype,
482 final_penalty_subtype,
483 math_pre_penalty_subtype,
484 math_post_penalty_subtype,
485 before_display_penalty_subtype,
486 after_display_penalty_subtype,
487 equation_number_penalty_subtype,
488 discretionary_penalty_subtype,
489} penalty_subtypes;
490
491# define last_penalty_subtype discretionary_penalty_subtype
492
493
498
499typedef enum glue_subtypes {
500 user_skip_glue,
501 line_skip_glue,
502 baseline_skip_glue,
503 par_skip_glue,
504 above_display_skip_glue,
505 below_display_skip_glue,
506 above_display_short_skip_glue,
507 below_display_short_skip_glue,
508 left_skip_glue,
509 right_skip_glue,
510 top_skip_glue,
511 bottom_skip_glue,
512 split_top_skip_glue,
513 tab_skip_glue,
514 space_skip_glue,
515 xspace_skip_glue,
516 zero_space_skip_glue,
517 par_fill_left_skip_glue,
518 par_fill_right_skip_glue,
519 par_init_left_skip_glue,
520 par_init_right_skip_glue,
521 indent_skip_glue,
522 left_hang_skip_glue,
523 right_hang_skip_glue,
524 correction_skip_glue,
525 inter_math_skip_glue,
526 ignored_glue,
527 page_glue,
528
529 math_skip_glue,
530 thin_mu_skip_glue,
531 med_mu_skip_glue,
532 thick_mu_skip_glue,
533
534 conditional_math_glue,
535 rulebased_math_glue,
536 mu_glue,
537
538 a_leaders,
539 c_leaders,
540 x_leaders,
541 g_leaders,
542 u_leaders,
543} glue_subtypes;
544
545# define last_glue_subtype u_leaders
546
547typedef enum skip_glue_codes_alias {
548 par_fill_skip_glue = par_fill_right_skip_glue,
549} skip_glue_codes_alias;
550
551# define is_leader(a) (node_subtype(a) >= a_leaders)
552
553# define glue_node_size 8
554# define glue_spec_size 5
555# define glue_options(a) vinfo(a,2)
556# define glue_amount(a) vlink(a,2)
557# define glue_stretch(a) vinfo(a,3)
558# define glue_shrink(a) vlink(a,3)
559# define glue_stretch_order(a) vinfo(a,4)
560# define glue_shrink_order(a) vlink(a,4)
561# define glue_font(a) vinfo(a,5)
562# define glue_data(a) vlink(a,5)
563# define glue_leader_ptr(a) vinfo(a,6)
564# define glue_callback(a) vlink(a,6)
565# define glue_belongs_to(a) vinfo(a,7)
566# define glue_reserved(a) vlink(a,7)
567
568typedef enum glue_option_codes {
569 glue_option_normal = 0x0000,
570 glue_option_no_auto_break = 0x0001,
571 glue_option_has_factor = 0x0002,
572 glue_option_is_limited = 0x0004,
573 glue_option_limit = 0x0008,
574 glue_option_u_leaders_line = 0x0010,
575 glue_option_set_discardable = 0x0020,
576 glue_option_reset_discardable = 0x0040,
577 glue_option_non_discardable = 0x0080,
578 glue_option_in_insert = 0x0100,
579} glue_option_codes;
580
581static inline void tex_add_glue_option (halfword a, halfword r) { glue_options(a) |= r; }
582static inline void tex_remove_glue_option (halfword a, halfword r) { glue_options(a) &= ~r; }
583static inline int tex_has_glue_option (halfword a, halfword r) { return (glue_options(a) & r) == r; }
584
585typedef enum math_subtypes {
586 begin_inline_math,
587 end_inline_math,
588 begin_broken_math,
589 end_broken_math,
590} math_subtypes;
591
592# define last_math_subtype end_broken_math
593
594
597
598# define math_node_size 7
599# define math_surround(a) vinfo(a,2)
600# define math_amount(a) vlink(a,2)
601# define math_stretch(a) vinfo(a,3)
602# define math_shrink(a) vlink(a,3)
603# define math_stretch_order(a) vinfo(a,4)
604# define math_shrink_order(a) vlink(a,4)
605# define math_penalty(a) vinfo(a,5)
606# define math_options(a) vlink(a,5)
607# define math_tolerance(a) vinfo(a,6)
608# define math_pre_tolerance(a) vlink(a,6)
609
610static inline void tex_add_math_option (halfword a, halfword r) { math_options(a) |= r; }
611static inline void tex_remove_math_option (halfword a, halfword r) { math_options(a) &= ~r; }
612static inline int tex_has_math_option (halfword a, halfword r) { return (math_options(a) & r) == r; }
613
614typedef enum math_option_codes {
615 math_option_normal = 0x0000,
616 math_option_short = 0x0001,
617 math_option_orphaned = 0x0002,
618 math_option_display = 0x0004,
619 math_option_cramped = 0x0008,
620} math_option_codes;
621
622
623
624static inline int tex_glue_is_zero(halfword g)
625{
626 return (! g) || ((glue_amount(g) == 0) && (glue_stretch(g) == 0) && (glue_shrink(g) == 0));
627}
628
629static inline int tex_math_glue_is_zero(halfword g)
630{
631 return (! g) || ((math_amount(g) == 0) && (math_stretch(g) == 0) && (math_shrink(g) == 0));
632}
633
634static inline int tex_same_glue(halfword a, halfword b)
635{
636 return
637 (a == b)
638 || (a && b && glue_amount(a) == glue_amount(b)
639 && glue_stretch(a) == glue_stretch(b)
640 && glue_shrink(a) == glue_shrink(b)
641 && glue_stretch_order(a) == glue_stretch_order(b)
642 && glue_shrink_order(a) == glue_shrink_order(b)
643 )
644 ;
645}
646
647static inline void tex_reset_glue_to_zero(halfword target)
648{
649 if (target) {
650 glue_amount(target) = 0;
651 glue_stretch(target) = 0;
652 glue_shrink(target) = 0;
653 glue_stretch_order(target) = 0;
654 glue_shrink_order(target) = 0;
655 }
656}
657
658static inline void tex_reset_math_glue_to_zero(halfword target)
659{
660 if (target) {
661 math_amount(target) = 0;
662 math_stretch(target) = 0;
663 math_shrink(target) = 0;
664 math_stretch_order(target) = 0;
665 math_shrink_order(target) = 0;
666 }
667}
668
669static inline void tex_copy_glue_values(halfword target, halfword source)
670{
671 if (source) {
672 glue_amount(target) = glue_amount(source);
673 glue_stretch(target) = glue_stretch(source);
674 glue_shrink(target) = glue_shrink(source);
675 glue_stretch_order(target) = glue_stretch_order(source);
676 glue_shrink_order(target) = glue_shrink_order(source);
677 } else {
678 glue_amount(target) = 0;
679 glue_stretch(target) = 0;
680 glue_shrink(target) = 0;
681 glue_stretch_order(target) = 0;
682 glue_shrink_order(target) = 0;
683 }
684}
685
686static inline int tex_is_par_init_glue(halfword n)
687{
688 switch (node_subtype(n)) {
689 case indent_skip_glue:
690 case par_init_left_skip_glue:
691 case par_init_right_skip_glue:
692 return 1;
693 default:
694 return 0;
695 }
696}
697
698
703
704typedef enum kern_subtypes {
705 explicit_kern_subtype,
706 accent_kern_subtype,
707 font_kern_subtype,
708 italic_kern_subtype,
709 left_margin_kern_subtype,
710 right_margin_kern_subtype,
711 left_correction_kern_subtype,
712 right_correction_kern_subtype,
713 space_font_kern_subtype,
714 explicit_math_kern_subtype,
715 math_shape_kern_subtype,
716 left_math_slack_kern_subtype,
717 right_math_slack_kern_subtype,
718 horizontal_math_kern_subtype,
719 vertical_math_kern_subtype,
720} kern_subtypes;
721
722# define last_kern_subtype vertical_math_kern_subtype
723
724# define font_related_kern(s) (s >= font_kern_subtype && s <= space_font_kern_subtype)
725
726# define kern_node_size 4
727# define kern_amount(a) vlink(a,2)
728# define kern_expansion(a) vinfo(a,2)
729# define kern_options(a) vlink(a,3)
730# define kern_belongs_to(a) vinfo(a,3)
731
732typedef enum kern_option_codes {
733 kern_option_normal = 0x0000,
734 kern_option_in_insert = 0x0001,
735} kern_option_codes;
736
737
738
739
740
741
769
770
777
778# define nesting_node_size 2
779
780typedef enum nesting_subtypes {
781 pre_break_code,
782 post_break_code,
783 no_break_code,
784 insert_head_code,
785 unset_nesting_code,
786} nesting_subtypes;
787
788# define last_nesting_subtype unset_nesting_code
789
790
791
792typedef enum discretionary_subtypes {
793 normal_discretionary_code,
794 explicit_discretionary_code,
795 automatic_discretionary_code,
796 mathematics_discretionary_code,
797 syllable_discretionary_code,
798} discretionary_subtypes;
799
800# define last_discretionary_subtype syllable_discretionary_code
801# define last_discretionary_code automatic_discretionary_code
802
803typedef enum disc_option_codes {
804 disc_option_normal_word = 0x00000000,
805 disc_option_pre_word = 0x00000001,
806 disc_option_post_word = 0x00000002,
807 disc_option_orphaned = 0x00000004,
808 disc_option_prefer_break = 0x00000010,
809 disc_option_prefer_nobreak = 0x00000020,
810
811 disc_option_no_italic_correction = 0x00000040,
812 disc_option_no_zero_italic_correction = 0x00000080,
813
814 disc_option_user_first = 0x00010000,
815 disc_option_user_last = 0x40000000,
816
817 disc_option_valid = 0x4FFF0FFF,
818} disc_option_codes;
819
820# define first_disc_option disc_option_prefer_break
821# define last_disc_option disc_option_prefer_nobreak
822
823# define disc_node_size 13
824# define disc_no_break(a) vlink(a,2)
825# define disc_pre_break(a) vlink(a,3)
826# define disc_post_break(a) vlink(a,4)
827
828
829
830# define disc_penalty(a) vinfo(a,11)
831# define disc_options(a) vlink(a,11)
832# define disc_class(a) vinfo(a,12)
833# define disc_orphaned(a) vlink(a,12)
834
835# define set_disc_penalty(a,b) disc_penalty(a) = b
836# define set_disc_class(a,b) disc_class(a) = b
837# define set_disc_options(a,b) disc_options(a) = b
838# define set_disc_option(a,b) disc_options(a) |= b
839
840# define has_disc_option(a,b) ((disc_options(a) & b) == b)
841
842# define unset_disc_class -1
843
844static inline void tex_add_disc_option (halfword a, halfword r) { disc_options(a) |= r; }
845static inline void tex_remove_disc_option (halfword a, halfword r) { disc_options(a) &= ~r; }
846static inline int tex_has_disc_option (halfword a, halfword r) { return (disc_options(a) & r) == r; }
847
848
852
853# define disc_pre_break_node(a) (a+5)
854# define disc_post_break_node(a) (a+7)
855# define disc_no_break_node(a) (a+9)
856
857# define disc_pre_break_head(a) node_head(disc_pre_break_node(a))
858# define disc_post_break_head(a) node_head(disc_post_break_node(a))
859# define disc_no_break_head(a) node_head(disc_no_break_node(a))
860
861# define disc_pre_break_tail(a) node_tail(disc_pre_break_node(a))
862# define disc_post_break_tail(a) node_tail(disc_post_break_node(a))
863# define disc_no_break_tail(a) node_tail(disc_no_break_node(a))
864
865extern void tex_set_disc_field (halfword target, halfword location, halfword source);
866extern void tex_check_disc_field (halfword target);
867extern void tex_set_discpart (halfword d, halfword h, halfword t, halfword code);
868extern halfword tex_flatten_discretionaries (halfword head, int *count, int nest);
869extern void tex_soften_hyphens (halfword head, int *found, int *replaced);
870
871typedef enum uleader_locations {
872 uleader_filtered_hpack,
873 uleader_lua,
874 uleader_before_vpack,
875 uleader_after_vpack,
876 uleader_post_linebreak,
877} uleader_locations;
878
879extern int tex_flatten_leaders (halfword box, int grp, int just_pack, int location, int checkline);
880extern halfword tex_harden_spaces (halfword head, halfword tolerance, int *count);
881
882
901
902
903
904typedef enum list_subtypes {
905 unknown_list,
906 line_list,
907 hbox_list,
908 indent_list,
909 container_list,
910 align_row_list,
911 align_cell_list,
912 equation_list,
913 equation_number_list,
914 math_list_list,
915 math_char_list,
916 math_pack_list,
917 math_h_extensible_list,
918 math_v_extensible_list,
919 math_h_delimiter_list,
920 math_v_delimiter_list,
921 math_over_delimiter_list,
922 math_under_delimiter_list,
923 math_numerator_list,
924 math_denominator_list,
925 math_modifier_list,
926 math_fraction_list,
927 math_nucleus_list,
928 math_sup_list,
929 math_sub_list,
930 math_prime_list,
931 math_pre_post_sup_list,
932 math_pre_post_sub_list,
933 math_degree_list,
934 math_scripts_list,
935 math_over_list,
936 math_under_list,
937 math_accent_list,
938 math_radical_list,
939 math_fence_list,
940 math_rule_list,
941 math_ghost_list,
942 math_text_list,
943 insert_result_list,
944 local_list,
945 local_left_list,
946 local_right_list,
947 local_middle_list,
948 balance_slot_list,
949 balance_list,
950 spacing_list,
951} list_subtypes;
952
953# define last_list_subtype spacing_list
954# define noad_class_list_base 0x0100
955
956typedef enum list_anchors {
957 left_origin_anchor = 0x001,
958 left_height_anchor = 0x002,
959 left_depth_anchor = 0x003,
960 right_origin_anchor = 0x004,
961 right_height_anchor = 0x005,
962 right_depth_anchor = 0x006,
963 center_origin_anchor = 0x007,
964 center_height_anchor = 0x008,
965 center_depth_anchor = 0x009,
966 halfway_total_anchor = 0x00A,
967 halfway_height_anchor = 0x00B,
968 halfway_depth_anchor = 0x00C,
969 halfway_left_anchor = 0x00D,
970 halfway_right_anchor = 0x00E,
971} list_anchors;
972
973typedef enum list_signs {
974 negate_x_anchor = 0x100,
975 negate_y_anchor = 0x200,
976} list_signs;
977
978typedef enum list_geometries {
979 no_geometry = 0x0,
980 offset_geometry = 0x1,
981 orientation_geometry = 0x2,
982 anchor_geometry = 0x4,
983} list_geometries;
984
985typedef enum list_balance_states {
986 balance_state_inserts = 0x01,
987 balance_state_discards = 0x02,
988 balance_state_uinserts = 0x04,
989} list_balance_states;
990
991# define box_node_size 17
992# define box_width(a) vlink(a,2)
993# define box_w_offset(a) vinfo(a,2)
994# define box_depth(a) vlink(a,3)
995# define box_d_offset(a) vinfo(a,3)
996# define box_height(a) vlink(a,4)
997# define box_h_offset(a) vinfo(a,4)
998# define box_list(a) vlink(a,5)
999# define box_shift_amount(a) vinfo(a,5)
1000# define box_glue_order(a) vlink(a,6)
1001# define box_glue_sign(a) vinfo01(a,6)
1002# define box_balance_state(a) vinfo02(a,6)
1003# define box_reserved_1(a) vinfo03(a,6)
1004# define box_reserved_2(a) vinfo04(a,6)
1005# define box_glue_set(a) dvalue(a,7)
1006# define box_dir(a) vlink00(a,8)
1007# define box_package_state(a) vlink01(a,8)
1008# define box_options(a) vlink02(a,8)
1009# define box_geometry(a) vlink03(a,8)
1010# define box_orientation(a) vinfo(a,8)
1011# define box_x_offset(a) vlink(a,9)
1012# define box_y_offset(a) vinfo(a,9)
1013# define box_pre_migrated(a) vlink(a,10)
1014# define box_post_migrated(a) vinfo(a,10)
1015# define box_pre_adjusted(a) vlink(a,11)
1016# define box_post_adjusted(a) vinfo(a,11)
1017# define box_source_anchor(a) vlink(a,12)
1018# define box_target_anchor(a) vinfo(a,12)
1019# define box_anchor(a) vlink(a,13)
1020# define box_index(a) vinfo(a,13)
1021# define box_except(a) vlink(a,14)
1022# define box_exdepth(a) vinfo(a,14)
1023# define box_discardable(a) vlink(a,15)
1024# define box_reserved(a) vinfo(a,15)
1025# define box_input_file(a) vlink(a,16)
1026# define box_input_line(a) vinfo(a,16)
1027
1028# define box_total(a) (box_height(a) + box_depth(a))
1029
1030static inline void tex_set_box_geometry (halfword b, halfword g) { box_geometry(b) |= (singleword) g; }
1031static inline void tex_unset_box_geometry (halfword b, halfword g) { box_geometry(b) &= (singleword) ~g; }
1032static inline int tex_has_geometry (halfword g, halfword f) { return ((singleword) g & (singleword) f) == (singleword) f; }
1033static inline int tex_has_box_geometry (halfword b, halfword g) { return (box_geometry(b) & (singleword) g) == (singleword) g; }
1034
1035
1036
1037typedef enum box_pre_post_states {
1038 has_pre_adjust = 0x1,
1039 has_post_adjust = 0x2,
1040 has_pre_migrated = 0x4,
1041 has_post_migrated = 0x8,
1042} box_pre_post_states;
1043
1044typedef enum box_insert_states {
1045 has_inserts = 0x1,
1046 has_inserts_with_content = 0x2,
1047 has_inserts_with_height = 0x4,
1048} box_insert_states;
1049
1050
1051
1052typedef enum package_states {
1053 unknown_package_state = 0x00,
1054 hbox_package_state = 0x01,
1055 vbox_package_state = 0x02,
1056 vtop_package_state = 0x03,
1057 dbox_package_state = 0x04,
1058
1059} package_states;
1060
1061typedef enum package_dimension_states {
1062 package_dimension_not_set = 0x00,
1063 package_dimension_size_set = 0x10,
1064} package_dimension_states;
1065
1066typedef enum package_leader_states {
1067 package_u_leader_not_set = 0x00,
1068 package_u_leader_set = 0x20,
1069 package_u_leader_delayed = 0x40,
1070 package_u_leader_found = 0x80,
1071} package_leader_states;
1072
1073# define set_box_package_state(p,s) box_package_state(p) |= s
1074# define has_box_package_state(p,s) ((box_package_state(p) & s) == s)
1075# define is_box_package_state(p,s) ((p & s) == s)
1076
1077typedef enum box_option_flags {
1078 box_option_no_math_axis = 0x01,
1079 box_option_discardable = 0x02,
1080
1081} box_option_flags;
1082
1083static inline void tex_add_box_option (halfword a, halfword r) { box_options(a) |= r; }
1084static inline void tex_remove_box_option (halfword a, halfword r) { box_options(a) &= ~r; }
1085static inline int tex_has_box_option (halfword a, halfword r) { return (box_options(a) & r) == r; }
1086
1087
1091
1092# define unset_node_size box_node_size
1093# define box_glue_stretch(a) box_w_offset(a)
1094# define box_glue_shrink(a) box_h_offset(a)
1095# define box_span_count(a) box_d_offset(a)
1096# define box_size(a) box_orientation(a)
1097
1098
1102
1103# define align_record_size box_node_size
1104# define align_record_span_ptr(a) box_w_offset(a)
1105# define align_record_cmd(a) box_h_offset(a)
1106# define align_record_chr(a) box_d_offset(a)
1107# define align_record_pre_part(a) box_x_offset(a)
1108# define align_record_post_part(a) box_y_offset(a)
1109# define align_record_dimension(a) box_orientation(a)
1110# define align_record_pre_local(a) box_pre_migrated(a)
1111# define align_record_post_local(a) box_post_migrated(a)
1112
1113
1119
1120# define span_node_size 3
1121# define span_span(a) vinfo(a,1)
1122# define span_unused(a) vlink(a,1)
1123# define span_width(a) vlink(a,2)
1124# define span_ptr(a) vinfo(a,2)
1125
1126
1130
1131typedef enum rule_subtypes {
1132 normal_rule_subtype,
1133 empty_rule_subtype,
1134 strut_rule_subtype,
1135 virtual_rule_subtype,
1136
1137 outline_rule_subtype,
1138 user_rule_subtype,
1139 math_over_rule_subtype,
1140 math_under_rule_subtype,
1141 math_fraction_rule_subtype,
1142 math_radical_rule_subtype,
1143 box_rule_subtype,
1144 image_rule_subtype,
1145 spacing_rule_subtype,
1146} rule_subtypes;
1147
1148typedef enum rule_codes {
1149 normal_rule_code,
1150 empty_rule_code,
1151 strut_rule_code,
1152 virtual_rule_code,
1153} rule_codes;
1154
1155typedef enum rule_option_codes {
1156 rule_option_horizontal = 0x01,
1157 rule_option_vertical = 0x02,
1158 rule_option_thickness = 0x04,
1159 rule_option_running = 0x08,
1160 rule_option_discardable = 0x10,
1161 rule_option_valid = 0x1F,
1162} rule_option_codes;
1163
1164# define last_rule_subtype spacing_rule_subtype
1165# define first_rule_code normal_rule_code
1166# define last_rule_code strut_rule_code
1167
1168# define rule_node_size 9
1169# define rule_width(a) vlink(a,2)
1170# define rule_x_offset(a) vinfo(a,2)
1171# define rule_depth(a) vlink(a,3)
1172# define rule_y_offset(a) vinfo(a,3)
1173# define rule_height(a) vlink(a,4)
1174# define rule_data(a) vinfo(a,4)
1175# define rule_options(a) vlink(a,5)
1176# define rule_thickness(a) vinfo(a,5)
1177# define rule_left(a) vinfo(a,6)
1178# define rule_right(a) vlink(a,6)
1179# define rule_extra_1(a) vinfo(a,7)
1180# define rule_extra_2(a) vlink(a,7)
1181# define rule_discardable(a) vinfo(a,8)
1182# define rule_reserved(a) vlink(a,8)
1183
1184# define rule_line_on rule_extra_1
1185# define rule_line_off rule_extra_2
1186
1187# define rule_strut_font rule_extra_1
1188# define rule_strut_character rule_extra_2
1189
1190# define rule_virtual_width rule_left
1191# define rule_virtual_height rule_right
1192# define rule_virtual_depth rule_extra_1
1193# define rule_virtual_unused rule_extra_2
1194
1195# define rule_total(a) (rule_height(a) + rule_depth(a))
1196
1197# define set_rule_options(a,b) rule_options(a) |= b
1198
1199
1241
1242
1253
1254# define glyph_node_size 14
1255# define glyph_character(a) vinfo(a,2)
1256# define glyph_font(a) vlink(a,2)
1257# define glyph_data(a) vinfo(a,3)
1258# define glyph_state(a) vlink(a,3)
1259# define glyph_language(a) vinfo0(a,4)
1260# define glyph_script(a) vinfo1(a,4)
1261# define glyph_control(a) vlink0(a,4)
1262# define glyph_disccode(a) vlink1(a,4)
1263
1264
1265# define glyph_options(a) vinfo(a,5)
1266# define glyph_hyphenate(a) vlink(a,5)
1267# define glyph_protected(a) vinfo00(a,6)
1268# define glyph_lhmin(a) vinfo01(a,6)
1269# define glyph_rhmin(a) vinfo02(a,6)
1270# define glyph_discpart(a) vinfo03(a,6)
1271# define glyph_expansion(a) vlink(a,6)
1272# define glyph_x_scale(a) vinfo(a,7)
1273# define glyph_y_scale(a) vlink(a,7)
1274# define glyph_scale(a) vinfo(a,8)
1275# define glyph_raise(a) vlink(a,8)
1276# define glyph_left(a) vinfo(a,9)
1277# define glyph_right(a) vlink(a,9)
1278# define glyph_x_offset(a) vinfo(a,10)
1279# define glyph_y_offset(a) vlink(a,10)
1280# define glyph_weight(a) vinfo(a,11)
1281# define glyph_slant(a) vlink(a,11)
1282# define glyph_properties(a) vinfo0(a,12)
1283# define glyph_group(a) vinfo1(a,12)
1284# define glyph_index(a) vlink(a,12)
1285# define glyph_input_file(a) vinfo(a,13)
1286# define glyph_input_line(a) vlink(a,13)
1287
1288# define get_glyph_data(a) ((halfword) glyph_data(a))
1289# define get_glyph_state(a) ((halfword) glyph_state(a))
1290# define get_glyph_language(a) ((quarterword) glyph_language(a))
1291# define get_glyph_script(a) ((quarterword) glyph_script(a))
1292# define get_glyph_control(a) ((quarterword) glyph_control(a))
1293# define get_glyph_disccode(a) ((quarterword) glyph_disccode(a))
1294# define get_glyph_x_scale(a) ((halfword) glyph_x_scale(a))
1295# define get_glyph_y_scale(a) ((halfword) glyph_y_scale(a))
1296# define get_glyph_scale(a) ((halfword) glyph_scale(a))
1297# define get_glyph_raise(a) ((halfword) glyph_raise(a))
1298# define get_glyph_lhmin(a) ((halfword) glyph_lhmin(a))
1299# define get_glyph_rhmin(a) ((halfword) glyph_rhmin(a))
1300# define get_glyph_left(a) ((halfword) glyph_left(a))
1301# define get_glyph_right(a) ((halfword) glyph_right(a))
1302# define get_glyph_hyphenate(a) ((halfword) glyph_hyphenate(a))
1303# define get_glyph_options(a) ((halfword) glyph_options(a))
1304# define get_glyph_discpart(a) ((halfword) (glyph_discpart(a) & 0xF))
1305# define get_glyph_discafter(a) ((halfword) ( (glyph_discpart(a) >> 4) & 0xF))
1306
1307# define set_glyph_data(a,b) glyph_data(a) = b
1308# define set_glyph_state(a,b) glyph_state(a) = b
1309# define set_glyph_language(a,b) glyph_language(a) = (quarterword) b
1310# define set_glyph_script(a,b) glyph_script(a) = (quarterword) b
1311# define set_glyph_control(a,b) glyph_control(a) = (quarterword) b
1312# define set_glyph_disccode(a,b) glyph_disccode(a) = (quarterword) b
1313# define set_glyph_x_scale(a,b) glyph_x_scale(a) = b
1314# define set_glyph_y_scale(a,b) glyph_y_scale(a) = b
1315# define set_glyph_x_offset(a,b) glyph_x_offset(a) = b
1316# define set_glyph_y_offset(a,b) glyph_y_offset(a) = b
1317# define set_glyph_slant(a,b) glyph_slant(a) = b
1318# define set_glyph_weight(a,b) glyph_weight(a) = b
1319# define set_glyph_scale(a,b) glyph_scale(a) = b
1320# define set_glyph_raise(a,b) glyph_raise(a) = b
1321# define set_glyph_left(a,b) glyph_left(a) = b
1322# define set_glyph_right(a,b) glyph_right(a) = b
1323# define set_glyph_lhmin(a,b) glyph_lhmin(a) = ((singleword) (b))
1324# define set_glyph_rhmin(a,b) glyph_rhmin(a) = ((singleword) (b))
1325# define set_glyph_hyphenate(a,b) glyph_hyphenate(a) = ((halfword) (b))
1326# define set_glyph_options(a,b) glyph_options(a) = ((halfword) (b))
1327# define set_glyph_discpart(a,b) glyph_discpart(a) = (glyph_discpart(a) | (singleword) ((b) & 0xF) )
1328# define set_glyph_discafter(a,b) glyph_discpart(a) = (glyph_discpart(a) | (singleword) (((b) & 0xF) << 4))
1329
1330# define get_glyph_dohyph(a) (hyphenation_permitted(glyph_hyphenate(a), syllable_hyphenation_mode ) || hyphenation_permitted(glyph_hyphenate(a), force_handler_hyphenation_mode))
1331# define get_glyph_uchyph(a) (hyphenation_permitted(glyph_hyphenate(a), uppercase_hyphenation_mode) || hyphenation_permitted(glyph_hyphenate(a), force_handler_hyphenation_mode))
1332
1333
1334# define set_glyph_uchyph(a,b) glyph_hyphenate(a) = ((halfword) flip_hyphenation_mode(glyph_hyphenate(a),uppercase_hyphenation_mode))
1335
1336typedef enum glyph_subtypes {
1337
1338 glyph_unset_subtype,
1339
1340 glyph_character_subtype,
1341 glyph_ligature_subtype,
1342
1343 glyph_math_delimiter_subtype,
1344 glyph_math_extensible_subtype,
1345
1346 glyph_math_ordinary_subtype,
1347 glyph_math_operator_subtype,
1348 glyph_math_binary_subtype,
1349 glyph_math_relation_subtype,
1350 glyph_math_open_subtype,
1351 glyph_math_close_subtype,
1352 glyph_math_punctuation_subtype,
1353 glyph_math_variable_subtype,
1354 glyph_math_active_subtype,
1355 glyph_math_inner_subtype,
1356 glyph_math_under_subtype,
1357 glyph_math_over_subtype,
1358 glyph_math_fraction_subtype,
1359 glyph_math_radical_subtype,
1360 glyph_math_middle_subtype,
1361 glyph_math_prime_subtype,
1362 glyph_math_accent_subtype,
1363 glyph_math_fenced_subtype,
1364 glyph_math_ghost_subtype,
1365
1366 glyph_math_vcenter_subtype,
1367
1368 glyph_math_extra_subtype = 31,
1369} glyph_subtypes;
1370
1371# define glyph_node_is_text(g) (node_subtype(g) <= glyph_ligature_subtype)
1372
1373# define last_glyph_subtype glyph_math_accent_subtype
1374
1375
1376
1377typedef enum glyph_discpart_codes {
1378 glyph_discpart_unset = 0x0,
1379 glyph_discpart_pre = 0x1,
1380 glyph_discpart_post = 0x2,
1381 glyph_discpart_replace = 0x3,
1382 glyph_discpart_always = 0x4,
1383} glyph_discpart_codes;
1384
1385typedef enum glyph_disc_codes {
1386 glyph_disc_normal = 0x1,
1387 glyph_disc_explicit = 0x2,
1388 glyph_disc_automatic = 0x3,
1389 glyph_disc_mathematics = 0x4,
1390 glyph_disc_syllable = 0x5,
1391} glyph_disc_codes;
1392
1393typedef enum glyph_option_codes {
1394
1395 glyph_option_normal_glyph = 0x00000000,
1396 glyph_option_no_left_ligature = 0x00000001,
1397 glyph_option_no_right_ligature = 0x00000002,
1398 glyph_option_no_left_kern = 0x00000004,
1399 glyph_option_no_right_kern = 0x00000008,
1400 glyph_option_no_expansion = 0x00000010,
1401 glyph_option_no_protrusion = 0x00000020,
1402 glyph_option_no_italic_correction = 0x00000040,
1403 glyph_option_no_zero_italic_correction = 0x00000080,
1404
1405 glyph_option_apply_x_offset = 0x00000100,
1406 glyph_option_apply_y_offset = 0x00000200,
1407
1408 glyph_option_math_discretionary = 0x00000400,
1409 glyph_option_math_italics_too = 0x00000800,
1410 glyph_option_math_artifact = 0x00001000,
1411
1412 glyph_option_weight_less = 0x00002000,
1413 glyph_option_space_factor_overload = 0x00004000,
1414
1415 glyph_option_check_toddler = 0x00008000,
1416 glyph_option_check_twin = 0x00010000,
1417 glyph_option_is_toddler = 0x00020000,
1418
1419 glyph_option_is_continuation = 0x00040000,
1420
1421 glyph_option_user_first = 0x00100000,
1422 glyph_option_user_last = 0x40000000,
1423
1424 glyph_option_system = 0x0001FFFF,
1425 glyph_option_user = 0x4FF00000,
1426
1427 glyph_option_valid = glyph_option_system
1428 | glyph_option_user,
1429} glyph_option_codes;
1430
1431typedef enum auto_discretionary_codes {
1432 auto_discretionary_normal = 0x0001,
1433 auto_discretionary_italic = 0x0002,
1434} auto_discretionary_codes;
1435
1436static inline void tex_add_glyph_option (halfword a, halfword r) { glyph_options(a) |= r; }
1437static inline void tex_remove_glyph_option (halfword a, halfword r) { glyph_options(a) &= ~r; }
1438static inline int tex_has_glyph_option (halfword a, halfword r) { return (glyph_options(a) & r) == r; }
1439
1440
1445
1446
1447
1448
1449
1450
1451typedef enum glyph_protection_codes {
1452 glyph_unprotected_code = 0x0,
1453 glyph_protected_text_code = 0x1,
1454 glyph_protected_math_code = 0x2,
1455} glyph_protection_codes;
1456
1457
1460
1461# define mark_node_size 3
1462# define mark_ptr(a) vlink(a,2)
1463# define mark_index(a) vinfo(a,2)
1464
1465typedef enum mark_codes {
1466 set_mark_value_code,
1467 reset_mark_value_code,
1468} mark_codes;
1469
1470# define last_mark_subtype reset_mark_value_code
1471
1472
1476
1477typedef enum adjust_subtypes {
1478 pre_adjust_code,
1479 post_adjust_code,
1480 local_adjust_code,
1481} adjust_subtypes;
1482
1483typedef enum adjust_options {
1484 adjust_option_none = 0x00,
1485 adjust_option_before = 0x01,
1486 adjust_option_baseline = 0x02,
1487 adjust_option_depth_before = 0x04,
1488 adjust_option_depth_after = 0x08,
1489 adjust_option_depth_check = 0x10,
1490 adjust_option_depth_last = 0x20,
1491 adjust_option_except = 0x40,
1492} adjust_options;
1493
1494# define last_adjust_subtype local_adjust_code
1495
1496# define adjust_node_size 5
1497# define adjust_list(a) vlink(a,2)
1498# define adjust_options(a) vinfo(a,2)
1499# define adjust_index(a) vlink(a,3)
1500# define adjust_except(a) vinfo(a,3)
1501# define adjust_depth_before(a) vlink(a,4)
1502# define adjust_depth_after(a) vinfo(a,4)
1503
1504# define has_adjust_option(p,o) ((adjust_options(p) & o) == o)
1505
1506
1513
1514typedef enum insert_options {
1515 insert_option_in_insert = 0x01,
1516} insert_options;
1517
1518# define insert_node_size 9
1519# define insert_index(a) vinfo(a,2)
1520# define insert_float_cost(a) vlink(a,2)
1521# define insert_identifier(a) vinfo(a,3)
1522# define insert_max_depth(a) vlink(a,3)
1523# define insert_options(a) vinfo(a,4)
1524# define insert_total_height(a) vlink(a,4)
1525# define insert_list(a) vinfo(a,5)
1526# define insert_split_top(a) vlink(a,5)
1527# define insert_line_height(a) vinfo(a,6)
1528# define insert_line_depth(a) vlink(a,6)
1529# define insert_stretch(a) vinfo(a,7)
1530# define insert_shrink(a) vlink(a,7)
1531# define insert_callback(a) vinfo(a,8)
1532# define insert_belongs_to(a) vlink(a,8)
1533
1534# define insert_first_box(a) (a + 5)
1535
1536# define split_node_size 5
1537# define split_insert_index(a) vinfo(a,2)
1538# define split_broken(a) vlink(a,2)
1539# define split_broken_insert(a) vinfo(a,3)
1540# define split_last_insert(a) vlink(a,3)
1541# define split_best_insert(a) vinfo(a,4)
1542# define split_height(a) vlink(a,4)
1543
1544typedef enum split_subtypes {
1545 normal_split_subtype,
1546 insert_split_subtype,
1547} split_subtypes;
1548
1549# define last_split_subtype insert_split_subtype
1550
1551
1555
1556# define last_preceding_break_node whatsit_node
1557# define last_non_discardable_node dir_node
1558# define last_node_with_attributes glyph_node
1559# define last_complex_node align_record_node
1560# define max_node_type passive_node
1561
1562# define precedes_break(a) (node_type(a) <= last_preceding_break_node)
1563# define precedes_kern(a) ((node_type(a) == kern_node) && (node_subtype(a) == font_kern_subtype || node_subtype(a) == accent_kern_subtype || node_subtype(a) == math_shape_kern_subtype))
1564# define precedes_dir(a) ((node_type(a) == dir_node) && normalize_line_mode_option(break_after_dir_mode))
1565# define non_discardable(a) (node_type(a) <= last_non_discardable_node)
1566
1567static inline int tex_nodetype_is_complex (halfword t) { return t <= last_complex_node; }
1568static inline int tex_nodetype_has_attributes (halfword t) { return t <= last_node_with_attributes; }
1569static inline int tex_nodetype_has_subtype (halfword t) { return t != glue_spec_node && t != math_spec_node && t != font_spec_node; }
1570static inline int tex_nodetype_has_prev (halfword t) { return t != glue_spec_node && t != math_spec_node && t != font_spec_node && t != attribute_node; }
1571static inline int tex_nodetype_has_next (halfword t) { return t != glue_spec_node && t != math_spec_node && t != font_spec_node; }
1572static inline int tex_nodetype_is_valid (halfword t) { return (t >= 0) && (t <= max_node_type); }
1573static inline int tex_nodetype_is_visible (halfword t) { return (t >= 0) && (t <= max_node_type) && lmt_interface.node_data[t].visible; }
1574
1575
1582
1583# define get_node_size(i) (lmt_interface.node_data[i].size)
1584# define get_node_name(i) (lmt_interface.node_data[i].name)
1585
1586
1587
1594
1595
1596
1597# define expression_node_size 3
1598# define expression_type(a) vinfo00(a,1)
1599# define expression_state(a) vinfo01(a,1)
1600# define expression_result(a) vinfo02(a,1)
1601# define expression_reserved(a) vinfo03(a,1)
1602# define expression_expression(a) vlink(a,1)
1603# define expression_term(a) vlink(a,2)
1604# define expression_numerator(a) vinfo(a,2)
1605
1606
1607
1608# define lmtx_expression_node_size 6
1609# define lmtx_expression_type(a) vinfo00(a,1)
1610# define lmtx_expression_state(a) vinfo01(a,1)
1611# define lmtx_expression_result(a) vinfo02(a,1)
1612# define lmtx_expression_negate(a) vinfo03(a,1)
1613# define lmtx_expression_type_expression(a) vlink(a,1)
1614# define lmtx_expression_type_term(a) vinfo(a,2)
1615# define lmtx_expression_type_numerator(a) vlink(a,2)
1616# define lmtx_expression_expression(a) lvalue(a,3)
1617# define lmtx_expression_term(a) lvalue(a,4)
1618# define lmtx_expression_numerator(a) lvalue(a,5)
1619
1620
1621
1622# define rpn_expression_node_size 3
1623# define rpn_expression_type(a) vinfo00(a,1)
1624# define rpn_expression_state(a) vinfo01(a,1)
1625# define rpn_expression_result(a) vinfo02(a,1)
1626# define rpn_expression_negate(a) vinfo03(a,1)
1627# define rpn_expression_entry(a) lvalue(a,2)
1628
1629
1632
1633# define loop_state_node_size 2
1634# define loop_state_count(a) vinfo(a,1)
1635
1636
1642
1643typedef enum fontspec_states {
1644 font_spec_scale_set = 0x0001,
1645 font_spec_x_scale_set = 0x0002,
1646 font_spec_y_scale_set = 0x0004,
1647 font_spec_slant_set = 0x0008,
1648 font_spec_weight_set = 0x0010,
1649 font_spec_all_set = 0x001F,
1650} font_spec_states;
1651
1652# define font_spec_node_size 5
1653# define font_spec_state(a) vinfo(a,1)
1654# define font_spec_identifier(a) vinfo(a,2)
1655# define font_spec_scale(a) vlink(a,2)
1656# define font_spec_x_scale(a) vinfo(a,3)
1657# define font_spec_y_scale(a) vlink(a,3)
1658# define font_spec_slant(a) vinfo(a,4)
1659# define font_spec_weight(a) vlink(a,4)
1660
1661# define font_spec_property_is_set(a,b) ((font_spec_state(a) & b) == b)
1662
1663static inline int tex_same_fontspec(halfword a, halfword b)
1664{
1665 return
1666 (a == b)
1667 || (a && b && font_spec_state(a) == font_spec_state(b)
1668 && font_spec_identifier(a) == font_spec_identifier(b)
1669 && font_spec_scale(a) == font_spec_scale(b)
1670 && font_spec_x_scale(a) == font_spec_x_scale(b)
1671 && font_spec_y_scale(a) == font_spec_y_scale(b)
1672 && font_spec_slant(a) == font_spec_slant(b)
1673 && font_spec_weight(a) == font_spec_weight(b)
1674 )
1675 ;
1676}
1677
1678
1682
1683# define math_spec_node_size 3
1684# define math_spec_class(a) vinfo00(a,1)
1685# define math_spec_family(a) vinfo01(a,1)
1686# define math_spec_character(a) vlink(a,1)
1687# define math_spec_properties(a) vinfo0(a,2)
1688# define math_spec_group(a) vinfo1(a,2)
1689# define math_spec_index(a) vlink(a,2)
1690
1691# define math_spec_value(a) (((math_spec_class(a) & 0x3F) << 12) + ((math_spec_family(a) & 0x3F) << 8) + (math_spec_character(a) & 0xFF))
1692
1693static inline int tex_same_mathspec(halfword a, halfword b)
1694{
1695 return
1696 (a == b)
1697 || (a && b && math_spec_class(a) == math_spec_class(b)
1698 && math_spec_family(a) == math_spec_family(b)
1699 && math_spec_character(a) == math_spec_character(b)
1700 && math_spec_properties(a) == math_spec_properties(b)
1701 && math_spec_group(a) == math_spec_group(b)
1702 && math_spec_index(a) == math_spec_index(b)
1703 )
1704 ;
1705}
1706
1707
1710
1711# define align_stack_node_size 16
1712# define align_stack_align_ptr(a) vinfo(a,1)
1713# define align_stack_cur_align(a) vlink(a,1)
1714# define align_stack_preamble(a) vinfo(a,2)
1715# define align_stack_cur_span(a) vlink(a,2)
1716# define align_stack_cur_loop(a) vinfo(a,3)
1717# define align_stack_wrap_source(a) vlink(a,3)
1718# define align_stack_align_state(a) vinfo(a,4)
1719# define align_stack_no_align_level(a) vlink(a,4)
1720# define align_stack_cur_post_adjust_head(a) vinfo(a,5)
1721# define align_stack_cur_post_adjust_tail(a) vlink(a,5)
1722# define align_stack_cur_pre_adjust_head(a) vinfo(a,6)
1723# define align_stack_cur_pre_adjust_tail(a) vlink(a,6)
1724# define align_stack_cur_post_migrate_head(a) vinfo(a,7)
1725# define align_stack_cur_post_migrate_tail(a) vlink(a,7)
1726# define align_stack_cur_pre_migrate_head(a) vinfo(a,8)
1727# define align_stack_cur_pre_migrate_tail(a) vlink(a,8)
1728# define align_stack_options(a) vinfo(a,9)
1729# define align_stack_attr_list(a) vlink(a,9)
1730# define align_stack_callback(a) vinfo(a,10)
1731# define align_stack_data(a) vlink(a,10)
1732
1733# define align_stack_row_attrlist(a) vinfo(a,11)
1734# define align_stack_row_orientation(a) vlink(a,11)
1735# define align_stack_row_yoffset(a) vinfo(a,12)
1736# define align_stack_row_xoffset(a) vlink(a,12)
1737# define align_stack_row_ymove(a) vinfo(a,13)
1738# define align_stack_row_xmove(a) vlink(a,13)
1739# define align_stack_row_shift(a) vinfo(a,14)
1740# define align_stack_row_source(a) vlink(a,14)
1741# define align_stack_row_target(a) vinfo(a,15)
1742# define align_stack_row_anchor(a) vlink(a,15)
1743
1744
1748
1749# define if_node_size 3
1750# define if_limit_type(a) vinfo0(a,1)
1751# define if_limit_subtype(a) vinfo1(a,1)
1752# define if_limit_unless(a) vinfo00(a,2)
1753# define if_limit_step(a) vinfo01(a,2)
1754# define if_limit_stepunless(a) vinfo02(a,2)
1755# define if_limit_unused(a) vinfo03(a,2)
1756# define if_limit_line(a) vlink(a,2)
1757
1758
1774
1775# define specification_node_size 4
1776# define specification_count(a) vlink(a,0)
1777# define specification_options(a) vinfo(a,1)
1778# define specification_size(a) vlink(a,1)
1779# define specification_pointer(a) (mvalue(a,2))
1780# define specification_anything_1(a) vinfo(a,3)
1781# define specification_anything_2(a) vlink(a,3)
1782
1783
1799
1800# define style_node_size 3
1801# define style_style node_subtype
1802# define style_scale(a) vinfo(a,2)
1803# define style_reserved(a) vlink(a,2)
1804
1805# define choice_node_size 5
1806
1807# define choice_display_mlist(a) vinfo(a,2)
1808# define choice_text_mlist(a) vlink(a,2)
1809# define choice_script_mlist(a) vinfo(a,3)
1810# define choice_script_script_mlist(a) vlink(a,3)
1811# define choice_class(a) vinfo(a,4)
1812# define choice_unused(a) vlink(a,4)
1813
1814# define choice_pre_break choice_display_mlist
1815# define choice_post_break choice_text_mlist
1816# define choice_no_break choice_script_mlist
1817
1818# define parameter_node_size 3
1819# define parameter_style node_subtype
1820# define parameter_name(a) vinfo(a,2)
1821# define parameter_value(a) vlink(a,2)
1822
1823typedef enum simple_choice_subtypes {
1824 normal_choice_subtype,
1825 discretionary_choice_subtype,
1826} simple_choice_subtypes;
1827
1828# define last_choice_subtype discretionary_choice_subtype
1829
1830
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896# define noad_size 18
1897# define noad_new_hlist(a) vlink(a,2)
1898# define noad_nucleus(a) vinfo(a,2)
1899# define noad_supscr(a) vlink(a,3)
1900# define noad_subscr(a) vinfo(a,3)
1901# define noad_supprescr(a) vlink(a,4)
1902# define noad_subprescr(a) vinfo(a,4)
1903# define noad_italic(a) vlink(a,5)
1904# define noad_width(a) vinfo(a,5)
1905# define noad_height(a) vlink(a,6)
1906# define noad_depth(a) vinfo(a,6)
1907
1908
1909
1910
1911
1912
1913# define noad_options(a) lvalue(a,7)
1914# define noad_style(a) vlink00(a,8)
1915# define noad_family(a) vlink01(a,8)
1916# define noad_script_state(a) vlink02(a,8)
1917# define noad_analyzed(a) vlink03(a,8)
1918# define noad_class_main(a) vinfo00(a,8)
1919# define noad_class_left(a) vinfo01(a,8)
1920# define noad_class_right(a) vinfo02(a,8)
1921# define noad_script_order(a) vinfo03(a,8)
1922# define noad_source(a) vlink(a,9)
1923# define noad_prime(a) vinfo(a,9)
1924# define noad_left_slack(a) vlink(a,10)
1925# define noad_right_slack(a) vinfo(a,10)
1926# define noad_subshift(a) vinfo(a,11)
1927# define noad_supshift(a) vlink(a,11)
1928# define noad_primeshift(a) vlink(a,12)
1929# define noad_script_kern(a) vinfo(a,12)
1930# define noad_extra_attr(a) vlink(a,13)
1931# define noad_reserved(a) vinfo(a,13)
1932# define noad_extra_1(a) vlink(a,14)
1933# define noad_extra_2(a) vinfo(a,14)
1934# define noad_extra_3(a) vlink(a,15)
1935# define noad_extra_4(a) vinfo(a,15)
1936# define noad_extra_5(a) vlink(a,16)
1937# define noad_extra_6(a) vinfo(a,16)
1938# define noad_extra_7(a) vlink(a,17)
1939# define noad_extra_70(a) vlink0(a,17)
1940# define noad_extra_71(a) vlink1(a,17)
1941# define noad_extra_8(a) vinfo(a,17)
1942# define noad_extra_80(a) vinfo0(a,17)
1943# define noad_extra_81(a) vinfo1(a,17)
1944
1945# define noad_total(a) (noad_height(a) + noad_depth(a))
1946
1947# define noad_has_postscripts(a) (noad_subscr(a) || noad_supscr(a))
1948# define noad_has_prescripts(a) (noad_subprescr(a) || noad_supprescr(a))
1949# define noad_has_scripts(a) (noad_has_postscripts(a) || noad_has_prescripts(a) || noad_prime(a))
1950# define noad_has_following_scripts(a) (noad_subscr(a) || noad_supscr(a) || noad_prime(a))
1951# define noad_has_superscripts(a) (noad_supprescr(a) || noad_supscr(a) || noad_prime(a))
1952# define noad_has_subscripts(a) (noad_subprescr(a) || noad_subscr(a))
1953
1954# define noad_has_scriptstate(a,s) ((noad_script_state(a) & s) == s)
1955
1956# define unset_noad_class 0xFE
1957
1958typedef enum noad_script_states {
1959 post_super_script_state = 0x01,
1960 post_sub_script_state = 0x02,
1961 pre_super_script_state = 0x04,
1962 pre_sub_script_state = 0x08,
1963 prime_script_state = 0x10,
1964} noad_script_states;
1965
1966typedef enum noad_script_locations {
1967 prime_unknown_location,
1968 prime_at_begin_location,
1969 prime_above_sub_location,
1970 prime_at_end_location,
1971} noad_prime_locations;
1972
1973typedef enum noad_script_order {
1974 script_unknown_first,
1975 script_primescript_first,
1976 script_subscript_first,
1977 script_superscript_first,
1978} noad_script_order;
1979
1980typedef struct noad_classes {
1981 singleword main;
1982 singleword left;
1983 singleword right;
1984} noad_classes;
1985
1986static inline void tex_reset_noad_classes(halfword n)
1987{
1988 noad_class_main(n) = (singleword) unset_noad_class;
1989 noad_class_left(n) = (singleword) unset_noad_class;
1990 noad_class_right(n) = (singleword) unset_noad_class;
1991 noad_analyzed(n) = (singleword) unset_noad_class;
1992}
1993
1994static inline void tex_set_noad_classes(halfword n, halfword c)
1995{
1996 noad_class_main(n) = (singleword) (c & 0xFF);
1997 noad_class_left(n) = (singleword) (c & 0xFF);
1998 noad_class_right(n) = (singleword) (c & 0xFF);
1999}
2000
2001# define set_noad_main_class(n,c) noad_class_main(n) = (singleword) (c & 0xFF)
2002# define set_noad_left_class(n,c) noad_class_left(n) = (singleword) (c & 0xFF)
2003# define set_noad_right_class(n,c) noad_class_right(n) = (singleword) (c & 0xFF)
2004
2005# define get_noad_main_class(n) (noad_class_main(n))
2006# define get_noad_left_class(n) (noad_class_left(n))
2007# define get_noad_right_class(n) (noad_class_right(n))
2008
2009# define set_noad_style(n,s) noad_style(n) = (singleword) (s & 0xFF)
2010# define set_noad_family(n,f) noad_family(n) = (singleword) (f & 0xFF)
2011
2012
2020
2021
2022
2023
2024typedef enum noad_options {
2025
2026 noad_option_axis = 0x00000001,
2027 noad_option_no_axis = 0x00000002,
2028 noad_option_exact = 0x00000004,
2029 noad_option_left = 0x00000008,
2030 noad_option_middle = 0x00000010,
2031 noad_option_right = 0x00000020,
2032 noad_option_adapt_to_left_size = 0x00000040,
2033 noad_option_adapt_to_right_size = 0x00000080,
2034 noad_option_no_sub_script = 0x00000100,
2035 noad_option_no_super_script = 0x00000200,
2036 noad_option_no_sub_pre_script = 0x00000400,
2037 noad_option_no_super_pre_script = 0x00000800,
2038 noad_option_no_script = 0x00001000,
2039 noad_option_no_overflow = 0x00002000,
2040 noad_option_void = 0x00004000,
2041 noad_option_phantom = 0x00008000,
2042 noad_option_openup_height = 0x00010000,
2043 noad_option_openup_depth = 0x00020000,
2044 noad_option_limits = 0x00040000,
2045 noad_option_no_limits = 0x00080000,
2046 noad_option_prefer_font_thickness = 0x00100000,
2047 noad_option_no_ruling = 0x00200000,
2048 noad_option_indexed_sub_script = 0x00400000,
2049 noad_option_indexed_super_script = 0x00800000,
2050 noad_option_indexed_sub_pre_script = 0x01000000,
2051 noad_option_indexed_super_pre_script = 0x02000000,
2052 noad_option_unpack_list = 0x04000000,
2053 noad_option_no_check = 0x08000000,
2054 noad_option_auto = 0x10000000,
2055 noad_option_unroll_list = 0x20000000,
2056 noad_option_followed_by_space = 0x40000000,
2057 noad_option_proportional = 0x80000000,
2058
2059} noad_options;
2060
2061
2062
2063# define noad_option_source_on_nucleus (uint64_t) 0x0000000100000000
2064# define noad_option_fixed_super_or_sub_script (uint64_t) 0x0000000200000000
2065# define noad_option_fixed_super_and_sub_script (uint64_t) 0x0000000400000000
2066# define noad_option_auto_base (uint64_t) 0x0000000800000000
2067# define noad_option_stretch (uint64_t) 0x0000001000000000
2068# define noad_option_shrink (uint64_t) 0x0000002000000000
2069# define noad_option_center (uint64_t) 0x0000004000000000
2070# define noad_option_scale (uint64_t) 0x0000008000000000
2071# define noad_option_keep_base (uint64_t) 0x0000010000000000
2072# define noad_option_single (uint64_t) 0x0000020000000000
2073# define noad_option_no_rule (uint64_t) 0x0000040000000000
2074# define noad_option_auto_middle (uint64_t) 0x0000080000000000
2075# define noad_option_reflected (uint64_t) 0x0000100000000000
2076# define noad_option_continuation (uint64_t) 0x0000200000000000
2077# define noad_option_inherit_class (uint64_t) 0x0000400000000000
2078# define noad_option_discard_shape_kern (uint64_t) 0x0000800000000000
2079# define noad_option_realign_scripts (uint64_t) 0x0001000000000000
2080# define noad_option_ignore_empty_sub_script (uint64_t) 0x0002000000000000
2081# define noad_option_ignore_empty_super_script (uint64_t) 0x0004000000000000
2082# define noad_option_ignore_empty_prime_script (uint64_t) 0x0008000000000000
2083# define noad_option_continuation_head (uint64_t) 0x0010000000000000
2084# define noad_option_continuation_kernel (uint64_t) 0x0020000000000000
2085# define noad_option_reorder_pre_scripts (uint64_t) 0x0040000000000000
2086# define noad_option_ignore (uint64_t) 0x0080000000000000
2087# define noad_option_no_more_scripts (uint64_t) 0x0100000000000000
2088# define noad_option_carry_over_classes (uint64_t) 0x0200000000000000
2089# define noad_option_use_callback (uint64_t) 0x0400000000000000
2090
2091# define has_option(a,b) (((a) & (b)) == (b))
2092# define unset_option(a,b) ((a) & ~(b))
2093
2094static inline void tex_add_noad_option (halfword a, uint64_t r) { noad_options(a) |= r; }
2095static inline void tex_remove_noad_option (halfword a, uint64_t r) { noad_options(a) &= ~r; }
2096static inline int tex_has_noad_option (halfword a, uint64_t r) { return (noad_options(a) & r) == r; }
2097
2098static inline int has_noad_no_script_option(halfword n, halfword option)
2099{
2100 switch (node_type(n)) {
2101 case simple_noad:
2102 case accent_noad:
2103 case radical_noad:
2104 case fence_noad:
2105 case fraction_noad:
2106 return has_option(noad_options(n), option) || has_option(noad_options(n), noad_option_no_script);
2107 }
2108 return 0;
2109}
2110
2111# define has_noad_option_nosubscript(a) has_noad_no_script_option(a, noad_option_no_sub_script)
2112# define has_noad_option_nosupscript(a) has_noad_no_script_option(a, noad_option_no_super_script)
2113# define has_noad_option_nosubprescript(a) has_noad_no_script_option(a, noad_option_no_sub_pre_script)
2114# define has_noad_option_nosupprescript(a) has_noad_no_script_option(a, noad_option_no_super_pre_script)
2115
2116# define has_noad_option_indexedsubscript(a) (has_option(noad_options(a), noad_option_indexed_sub_script))
2117# define has_noad_option_indexedsupscript(a) (has_option(noad_options(a), noad_option_indexed_super_script))
2118# define has_noad_option_indexedsubprescript(a) (has_option(noad_options(a), noad_option_indexed_sub_pre_script))
2119# define has_noad_option_indexedsupprescript(a) (has_option(noad_options(a), noad_option_indexed_super_pre_script))
2120# define has_noad_option_axis(a) (has_option(noad_options(a), noad_option_axis))
2121# define has_noad_option_exact(a) (has_option(noad_options(a), noad_option_exact))
2122# define has_noad_option_noaxis(a) (has_option(noad_options(a), noad_option_no_axis))
2123# define has_noad_option_openupheight(a) (has_option(noad_options(a), noad_option_openup_height))
2124# define has_noad_option_openupdepth(a) (has_option(noad_options(a), noad_option_openup_depth))
2125# define has_noad_option_adapttoleft(a) (has_option(noad_options(a), noad_option_adapt_to_left_size))
2126# define has_noad_option_adapttoright(a) (has_option(noad_options(a), noad_option_adapt_to_right_size))
2127# define has_noad_option_limits(a) (has_option(noad_options(a), noad_option_limits))
2128# define has_noad_option_nolimits(a) (has_option(noad_options(a), noad_option_no_limits))
2129# define has_noad_option_nooverflow(a) (has_option(noad_options(a), noad_option_no_overflow))
2130# define has_noad_option_preferfontthickness(a) (has_option(noad_options(a), noad_option_prefer_font_thickness))
2131# define has_noad_option_noruling(a) (has_option(noad_options(a), noad_option_no_ruling))
2132# define has_noad_option_unpacklist(a) (has_option(noad_options(a), noad_option_unpack_list))
2133# define has_noad_option_nocheck(a) (has_option(noad_options(a), noad_option_no_check))
2134# define has_noad_option_exact(a) (has_option(noad_options(a), noad_option_exact))
2135# define has_noad_option_left(a) (has_option(noad_options(a), noad_option_left))
2136# define has_noad_option_middle(a) (has_option(noad_options(a), noad_option_middle))
2137# define has_noad_option_right(a) (has_option(noad_options(a), noad_option_right))
2138# define has_noad_option_auto(a) (has_option(noad_options(a), noad_option_auto))
2139# define has_noad_option_phantom(a) (has_option(noad_options(a), noad_option_phantom))
2140# define has_noad_option_void(a) (has_option(noad_options(a), noad_option_void))
2141# define has_noad_option_unrolllist(a) (has_option(noad_options(a), noad_option_unroll_list))
2142# define has_noad_option_followedbyspace(a) (has_option(noad_options(a), noad_option_followed_by_space))
2143# define has_noad_option_proportional(a) (has_option(noad_options(a), noad_option_proportional))
2144# define has_noad_option_center(a) (has_option(noad_options(a), noad_option_center))
2145# define has_noad_option_source_on_nucleus(a) (has_option(noad_options(a), noad_option_source_on_nucleus))
2146# define has_noad_option_fixed_super_or_sub_script(a) (has_option(noad_options(a), noad_option_fixed_super_or_sub_script))
2147# define has_noad_option_fixed_super_and_sub_script(a) (has_option(noad_options(a), noad_option_fixed_super_and_sub_script))
2148# define has_noad_option_stretch(a) (has_option(noad_options(a), noad_option_stretch))
2149# define has_noad_option_shrink(a) (has_option(noad_options(a), noad_option_shrink))
2150# define has_noad_option_auto_base(a) (has_option(noad_options(a), noad_option_auto_base))
2151# define has_noad_option_scale(a) (has_option(noad_options(a), noad_option_scale))
2152# define has_noad_option_keep_base(a) (has_option(noad_options(a), noad_option_keep_base))
2153# define has_noad_option_single(a) (has_option(noad_options(a), noad_option_single))
2154# define has_noad_option_norule(a) (has_option(noad_options(a), noad_option_no_rule))
2155# define has_noad_option_auto_middle(a) (has_option(noad_options(a), noad_option_auto_middle))
2156# define has_noad_option_reflected(a) (has_option(noad_options(a), noad_option_reflected))
2157# define has_noad_option_continuation(a) (has_option(noad_options(a), noad_option_continuation))
2158# define has_noad_option_inherit_class(a) (has_option(noad_options(a), noad_option_inherit_class))
2159# define has_noad_option_discard_shape_kern(a) (has_option(noad_options(a), noad_option_discard_shape_kern))
2160# define has_noad_option_realign_scripts(a) (has_option(noad_options(a), noad_option_realign_scripts))
2161# define has_noad_option_ignore_empty_sub_script(a) (has_option(noad_options(a), noad_option_ignore_empty_sub_script))
2162# define has_noad_option_ignore_empty_super_script(a) (has_option(noad_options(a), noad_option_ignore_empty_super_script))
2163# define has_noad_option_ignore_empty_prime_script(a) (has_option(noad_options(a), noad_option_ignore_empty_prime_script))
2164# define has_noad_option_continuation_head(a) (has_option(noad_options(a), noad_option_continuation_head))
2165# define has_noad_option_continuation_kernel(a) (has_option(noad_options(a), noad_option_continuation_kernel))
2166# define has_noad_option_reorder_pre_scripts(a) (has_option(noad_options(a), noad_option_reorder_pre_scripts))
2167# define has_noad_option_ignore(a) (has_option(noad_options(a), noad_option_ignore))
2168# define has_noad_option_no_more_scripts(a) (has_option(noad_options(a), noad_option_no_more_scripts))
2169# define has_noad_option_carry_over_classes(a) (has_option(noad_options(a), noad_option_carry_over_classes))
2170# define has_noad_option_use_callback(a) (has_option(noad_options(a), noad_option_use_callback))
2171
2172typedef enum double_atom_options {
2173 inherit_class_double_atom_option = 0x01,
2174 discard_shape_kern_double_atom_option = 0x02,
2175 realign_scripts_double_atom_option = 0x04,
2176 reorder_double_pre_script_atom_option = 0x08,
2177} double_atom_options;
2178
2179
2183
2184typedef enum simple_noad_subtypes {
2185 ordinary_noad_subtype,
2186 operator_noad_subtype,
2187 binary_noad_subtype,
2188 relation_noad_subtype,
2189 open_noad_subtype,
2190 close_noad_subtype,
2191 punctuation_noad_subtype,
2192 variable_noad_subtype,
2193 active_noad_subtype,
2194 inner_noad_subtype,
2195 under_noad_subtype,
2196 over_noad_subtype,
2197 fraction_noad_subtype,
2198 radical_noad_subtype,
2199 middle_noad_subtype,
2200 prime_noad_subtype,
2201 accent_noad_subtype,
2202 fenced_noad_subtype,
2203 ghost_noad_subtype,
2204 vcenter_noad_subtype,
2205} simple_noad_subtypes;
2206
2207# define last_noad_type vcenter_noad_subtype
2208# define last_noad_subtype vcenter_noad_subtype
2209
2210typedef enum math_component_types {
2211 math_component_ordinary_code,
2212 math_component_operator_code,
2213 math_component_binary_code,
2214 math_component_relation_code,
2215 math_component_open_code,
2216 math_component_close_code,
2217 math_component_punctuation_code,
2218 math_component_variable_code,
2219 math_component_inner_code,
2220 math_component_under_code,
2221 math_component_over_code,
2222 math_component_fraction_code,
2223 math_component_radical_code,
2224 math_component_middle_code,
2225 math_component_prime_code,
2226 math_component_accent_code,
2227 math_component_fenced_code,
2228 math_component_ghost_code,
2229 math_component_atom_code,
2230} math_component_types;
2231
2232# define first_math_component_type math_component_ordinary_code
2233# define last_math_component_type math_component_accent_code
2234
2235
2239
2240typedef enum math_modifier_types {
2241 display_limits_modifier_code,
2242 limits_modifier_code,
2243 no_limits_modifier_code,
2244 adapt_to_left_modifier_code,
2245 adapt_to_right_modifier_code,
2246 axis_modifier_code,
2247 no_axis_modifier_code,
2248 phantom_modifier_code,
2249 void_modifier_code,
2250 source_modifier_code,
2251 openup_height_modifier_code,
2252 openup_depth_modifier_code,
2253} math_modifier_types;
2254
2255# define first_math_modifier_code display_limits_modifier_code
2256# define last_math_modifier_code openup_depth_modifier_code
2257
2258
2259
2260# define accent_noad_size noad_size
2261# define accent_top_character noad_extra_1
2262# define accent_bottom_character noad_extra_2
2263# define accent_middle_character noad_extra_3
2264# define accent_fraction noad_extra_4
2265# define accent_top_overshoot noad_extra_5
2266# define accent_bot_overshoot noad_extra_6
2267
2268typedef enum math_accent_subtypes {
2269
2270 bothflexible_accent_subtype,
2271 fixedtop_accent_subtype,
2272 fixedbottom_accent_subtype,
2273 fixedboth_accent_subtype,
2274} math_accent_subtypes;
2275
2276# define last_accent_subtype fixedboth_accent_subtype
2277
2278
2282
2283# define fence_noad_size noad_size
2284# define fence_delimiter noad_extra_1
2285# define fence_nesting_factor noad_extra_2
2286# define fence_delimiter_top noad_extra_3
2287# define fence_delimiter_bottom noad_extra_4
2288# define fence_top_overshoot noad_extra_5
2289# define fence_bottom_overshoot noad_extra_6
2290# define fence_delimiter_variant noad_extra_7
2291
2292typedef enum fence_subtypes {
2293 unset_fence_side,
2294 left_fence_side,
2295 middle_fence_side,
2296 right_fence_side,
2297 left_operator_side,
2298 no_fence_side,
2299 extended_left_fence_side,
2300 extended_middle_fence_side,
2301 extended_right_fence_side,
2302} fence_subtypes;
2303
2304# define last_fence_subtype extended_right_fence_side
2305# define first_fence_code left_fence_side
2306# define last_fence_code extended_right_fence_side
2307
2308
2318
2319# define fraction_noad_size noad_size
2320# define fraction_rule_thickness noad_extra_1
2321# define fraction_left_delimiter noad_extra_2
2322# define fraction_right_delimiter noad_extra_3
2323# define fraction_middle_delimiter noad_extra_4
2324# define fraction_h_factor noad_extra_5
2325# define fraction_v_factor noad_extra_6
2326# define fraction_numerator noad_extra_7
2327# define fraction_denominator noad_extra_8
2328
2329typedef enum fraction_subtypes {
2330 over_fraction_subtype,
2331 atop_fraction_subtype,
2332 above_fraction_subtype,
2333 skewed_fraction_subtype,
2334 stretched_fraction_subtype,
2335} fraction_subtypes;
2336
2337# define valid_fraction_subtype(s) (s >= over_fraction_subtype && s <= stretched_fraction_subtype)
2338
2339# define last_fraction_subtype stretched_fraction_subtype
2340
2341
2345
2346# define radical_noad_size noad_size
2347# define radical_degree noad_extra_1
2348# define radical_left_delimiter noad_extra_2
2349# define radical_right_delimiter noad_extra_3
2350# define radical_size noad_extra_4
2351# define radical_height noad_extra_5
2352# define radical_depth noad_extra_6
2353# define radical_top_delimiter noad_extra_7
2354# define radical_bottom_delimiter noad_extra_8
2355
2356typedef enum radical_subtypes {
2357 normal_radical_subtype,
2358 radical_radical_subtype,
2359 root_radical_subtype,
2360 rooted_radical_subtype,
2361 under_delimiter_radical_subtype,
2362 over_delimiter_radical_subtype,
2363 delimiter_under_radical_subtype,
2364 delimiter_over_radical_subtype,
2365 delimited_radical_subtype,
2366 h_extensible_radical_subtype,
2367} radical_subtypes;
2368
2369# define last_radical_subtype h_extensible_radical_subtype
2370# define last_radical_code h_extensible_radical_subtype
2371
2372
2380
2381typedef enum math_kernel_options {
2382 math_kernel_no_italic_correction = 0x0001,
2383 math_kernel_no_left_pair_kern = 0x0002,
2384 math_kernel_no_right_pair_kern = 0x0004,
2385 math_kernel_auto_discretionary = 0x0008,
2386 math_kernel_full_discretionary = 0x0010,
2387 math_kernel_ignored_character = 0x0020,
2388 math_kernel_is_large_operator = 0x0040,
2389 math_kernel_has_italic_shape = 0x0080,
2390} math_kernel_options;
2391
2392# define math_kernel_node_size 5
2393# define kernel_math_family(a) vinfo(a,2)
2394# define kernel_math_character(a) vlink(a,2)
2395# define kernel_math_options(a) vinfo(a,3)
2396# define kernel_math_list(a) vlink(a,3)
2397# define kernel_math_properties(a) vinfo0(a,4)
2398# define kernel_math_group(a) vinfo1(a,4)
2399# define kernel_math_index(a) vlink(a,4)
2400
2401
2402
2403# define kernel_math_small_family vinfo00(a,2)
2404# define kernel_math_large_family vinfo01(a,2)
2405# define kernel_math_small_character vlink(a,2)
2406# define kernel_math_large_character vinfo02(a,2)
2407
2408# define math_kernel_node_has_option(a,b) ((kernel_math_options(a) & b) == b)
2409# define math_kernel_node_set_option(a,b) kernel_math_options(a) = (kernel_math_options(a) | b)
2410
2411
2416
2417# define math_delimiter_node_size 5
2418# define delimiter_small_family(a) vinfo(a,2)
2419# define delimiter_small_character(a) vlink(a,2)
2420# define delimiter_large_family(a) vinfo(a,3)
2421# define delimiter_large_character(a) vlink(a,3)
2422# define delimiter_math_properties(a) vinfo0(a,4)
2423# define delimiter_math_group(a) vinfo1(a,4)
2424# define delimiter_math_index(a) vlink(a,4)
2425
2426
2432
2433typedef enum boundary_subtypes {
2434 cancel_boundary,
2435 user_boundary,
2436 protrusion_boundary,
2437 word_boundary,
2438 page_boundary,
2439 math_boundary,
2440 optional_boundary,
2441 lua_boundary,
2442 par_boundary,
2443 adjust_boundary,
2444 balance_boundary,
2445} boundary_subtypes;
2446
2447typedef enum protrusion_boundary_options {
2448 protrusion_skip_none,
2449 protrusion_skip_next,
2450 protrusion_skip_previous,
2451 protrusion_skip_both,
2452} protrusion_boundary_options;
2453
2454typedef enum math_boundary_options {
2455
2456 begin_math_implicit_boundary,
2457 end_math_implicit_boundary,
2458
2459 begin_math_explicit_boundary,
2460 end_math_explicit_boundary,
2461} math_boundary_options;
2462
2463# define last_boundary_subtype word_boundary
2464# define last_boundary_code optional_boundary
2465
2466# define boundary_node_size 3
2467# define boundary_data(a) vinfo(a,2)
2468# define boundary_reserved(a) vlink(a,2)
2469
2470typedef enum dir_subtypes {
2471 normal_dir_subtype,
2472 cancel_dir_subtype,
2473} dir_subtypes;
2474
2475# define last_dir_subtype cancel_dir_subtype
2476
2477# define dir_node_size 3
2478# define dir_direction(a) vinfo(a,2)
2479# define dir_level(a) vlink(a,2)
2480
2481
2499
2500typedef enum par_categories {
2501 par_none_category = 0x00000000,
2502 par_hsize_category = 0x00000001,
2503 par_skip_category = 0x00000002,
2504 par_hang_category = 0x00000004,
2505 par_indent_category = 0x00000008,
2506 par_par_fill_category = 0x00000010,
2507 par_adjust_category = 0x00000020,
2508 par_protrude_category = 0x00000040,
2509 par_tolerance_category = 0x00000080,
2510 par_stretch_category = 0x00000100,
2511 par_looseness_category = 0x00000200,
2512 par_last_line_category = 0x00000400,
2513 par_line_penalty_category = 0x00000800,
2514 par_club_penalty_category = 0x00001000,
2515 par_widow_penalty_category = 0x00002000,
2516 par_display_penalty_category = 0x00004000,
2517 par_broken_penalty_category = 0x00008000,
2518 par_demerits_category = 0x00010000,
2519 par_shape_category = 0x00020000,
2520 par_line_category = 0x00040000,
2521 par_hyphenation_category = 0x00080000,
2522 par_shaping_penalty_category = 0x00100000,
2523 par_orphan_penalty_category = 0x00200000,
2524 par_toddler_penalty_category = 0x00400000,
2525 par_emergency_category = 0x00800000,
2526 par_par_passes_category = 0x01000000,
2527 par_single_line_penalty_category = 0x02000000,
2528 par_hyphen_penalty_category = 0x04000000,
2529 par_ex_hyphen_penalty_category = 0x08000000,
2530 par_line_break_checks_category = 0x10000000,
2531 par_twin_demerits_category = 0x20000000,
2532 par_fitness_classes_category = 0x40000000,
2533 par_all_category = 0x7FFFFFFF,
2534} par_categories;
2535
2536typedef enum par_codes {
2537 par_none_code,
2538 par_hsize_code,
2539 par_left_skip_code,
2540 par_right_skip_code,
2541 par_hang_indent_code,
2542 par_hang_after_code,
2543 par_par_indent_code,
2544 par_par_fill_left_skip_code,
2545 par_par_fill_right_skip_code,
2546 par_par_init_left_skip_code,
2547 par_par_init_right_skip_code,
2548 par_emergency_left_skip_code,
2549 par_emergency_right_skip_code,
2550 par_adjust_spacing_code,
2551 par_protrude_chars_code,
2552 par_pre_tolerance_code,
2553 par_tolerance_code,
2554 par_emergency_stretch_code,
2555 par_looseness_code,
2556 par_last_line_fit_code,
2557 par_line_penalty_code,
2558 par_inter_line_penalty_code,
2559 par_club_penalty_code,
2560 par_widow_penalty_code,
2561 par_display_widow_penalty_code,
2562 par_left_twin_demerits_code,
2563 par_right_twin_demerits_code,
2564 par_broken_penalty_code,
2565 par_adj_demerits_code,
2566 par_double_hyphen_demerits_code,
2567 par_final_hyphen_demerits_code,
2568 par_par_shape_code,
2569 par_inter_line_penalties_code,
2570 par_club_penalties_code,
2571 par_widow_penalties_code,
2572 par_display_widow_penalties_code,
2573 par_broken_penalties_code,
2574 par_orphan_penalties_code,
2575 par_toddler_penalties_code,
2576 par_fitness_classes_code,
2577 par_adjacent_demerits_code,
2578 par_orphan_line_factors_code,
2579 par_baseline_skip_code,
2580 par_line_skip_code,
2581 par_line_skip_limit_code,
2582 par_adjust_spacing_step_code,
2583 par_adjust_spacing_shrink_code,
2584 par_adjust_spacing_stretch_code,
2585 par_hyphenation_mode_code,
2586 par_shaping_penalties_mode_code,
2587 par_shaping_penalty_code,
2588 par_emergency_extra_stretch_code,
2589 par_par_passes_code,
2590 par_line_break_checks_code,
2591 par_single_line_penalty_code,
2592 par_hyphen_penalty_code,
2593 par_ex_hyphen_penalty_code,
2594 par_n_of_codes,
2595} par_codes;
2596
2597static int par_category_to_codes[par_n_of_codes] = {
2598 par_none_category,
2599 par_hsize_category,
2600 par_skip_category,
2601 par_skip_category,
2602 par_hang_category,
2603 par_hang_category,
2604 par_indent_category,
2605 par_par_fill_category,
2606 par_par_fill_category,
2607 par_par_fill_category,
2608 par_par_fill_category,
2609 par_emergency_category,
2610 par_emergency_category,
2611 par_adjust_category,
2612 par_protrude_category,
2613 par_tolerance_category,
2614 par_tolerance_category,
2615 par_stretch_category,
2616 par_looseness_category,
2617 par_last_line_category,
2618 par_line_penalty_category,
2619 par_line_penalty_category,
2620 par_club_penalty_category,
2621 par_widow_penalty_category,
2622 par_display_penalty_category,
2623 par_twin_demerits_category,
2624 par_twin_demerits_category,
2625 par_broken_penalty_category,
2626 par_demerits_category,
2627 par_demerits_category,
2628 par_demerits_category,
2629 par_shape_category,
2630 par_line_penalty_category,
2631 par_club_penalty_category,
2632 par_widow_penalty_category,
2633 par_display_penalty_category,
2634 par_broken_penalty_category,
2635 par_orphan_penalty_category,
2636 par_toddler_penalty_category,
2637 par_fitness_classes_category,
2638 par_demerits_category,
2639 par_orphan_penalty_category,
2640 par_line_category,
2641 par_line_category,
2642 par_line_category,
2643 par_adjust_category,
2644 par_adjust_category,
2645 par_adjust_category,
2646 par_hyphenation_category,
2647 par_shaping_penalty_category,
2648 par_shaping_penalty_category,
2649 par_emergency_category,
2650 par_par_passes_category,
2651 par_line_break_checks_category,
2652 par_single_line_penalty_category,
2653 par_hyphen_penalty_category,
2654 par_ex_hyphen_penalty_category,
2655};
2656
2657
2658typedef enum par_options {
2659 par_option_synchronize = 0x01,
2660} par_options;
2661
2662
2663
2664# define par_node_size 35
2665
2666# define par_dir(a) vlink00(a, 2)
2667# define par_options(a) vlink01(a, 2)
2668# define par_box_left(a) vinfo(a, 2)
2669# define par_box_left_width(a) vlink(a, 3)
2670# define par_box_right(a) vinfo(a, 3)
2671# define par_box_right_width(a) vlink(a, 4)
2672# define par_box_middle(a) vinfo(a, 4)
2673# define par_par_passes(a) vlink(a, 5)
2674# define par_line_break_checks(a) vinfo(a, 5)
2675# define par_state(a) vlink(a, 6)
2676# define par_prev_graf(a) vinfo(a, 6)
2677# define par_hsize(a) vlink(a, 7)
2678# define par_left_skip(a) vinfo(a, 7)
2679# define par_right_skip(a) vlink(a, 8)
2680# define par_hang_indent(a) vinfo(a, 8)
2681# define par_hang_after(a) vlink(a, 9)
2682# define par_par_indent(a) vinfo(a, 9)
2683# define par_par_fill_left_skip(a) vlink(a,10)
2684# define par_par_fill_right_skip(a) vinfo(a,10)
2685# define par_adjust_spacing(a) vlink(a,11)
2686# define par_protrude_chars(a) vinfo(a,11)
2687# define par_pre_tolerance(a) vlink(a,12)
2688# define par_tolerance(a) vinfo(a,12)
2689# define par_emergency_stretch(a) vlink(a,13)
2690# define par_looseness(a) vinfo(a,13)
2691# define par_last_line_fit(a) vlink(a,14)
2692# define par_line_penalty(a) vinfo(a,14)
2693# define par_inter_line_penalty(a) vlink(a,15)
2694# define par_club_penalty(a) vinfo(a,15)
2695# define par_widow_penalty(a) vlink(a,16)
2696# define par_display_widow_penalty(a) vinfo(a,16)
2697# define par_orphan_penalty(a) vlink(a,17)
2698# define par_toddler_penalties(a) vinfo(a,17)
2699# define par_broken_penalty(a) vlink(a,18)
2700# define par_adj_demerits(a) vinfo(a,18)
2701# define par_double_hyphen_demerits(a) vlink(a,19)
2702# define par_final_hyphen_demerits(a) vinfo(a,19)
2703# define par_par_shape(a) vlink(a,20)
2704# define par_inter_line_penalties(a) vinfo(a,20)
2705# define par_club_penalties(a) vlink(a,21)
2706# define par_widow_penalties(a) vinfo(a,21)
2707# define par_display_widow_penalties(a) vlink(a,22)
2708# define par_broken_penalties(a) vinfo(a,22)
2709# define par_orphan_penalties(a) vlink(a,23)
2710# define par_single_line_penalty(a) vinfo(a,23)
2711# define par_baseline_skip(a) vlink(a,24)
2712# define par_line_skip(a) vinfo(a,24)
2713# define par_line_skip_limit(a) vlink(a,25)
2714# define par_adjust_spacing_step(a) vinfo(a,25)
2715# define par_adjust_spacing_shrink(a) vlink(a,26)
2716# define par_adjust_spacing_stretch(a) vinfo(a,26)
2717# define par_end_par_tokens(a) vlink(a,27)
2718# define par_hyphenation_mode(a) vinfo(a,27)
2719# define par_shaping_penalties_mode(a) vlink(a,28)
2720# define par_shaping_penalty(a) vinfo(a,28)
2721# define par_par_init_left_skip(a) vlink(a,29)
2722# define par_par_init_right_skip(a) vinfo(a,29)
2723# define par_emergency_left_skip(a) vlink(a,30)
2724# define par_emergency_right_skip(a) vinfo(a,30)
2725# define par_emergency_extra_stretch(a) vlink(a,31)
2726# define par_fitness_classes(a) vinfo(a,31)
2727# define par_adjacent_demerits(a) vlink(a,32)
2728# define par_hyphen_penalty(a) vinfo(a,32)
2729# define par_ex_hyphen_penalty(a) vlink(a,33)
2730# define par_left_twin_demerits(a) vinfo(a,33)
2731# define par_right_twin_demerits(a) vlink(a,34)
2732# define par_orphan_line_factors(a) vinfo(a,34)
2733
2734
2738
2739
2740
2741
2742typedef enum par_subtypes {
2743 vmode_par_par_subtype,
2744 local_box_par_subtype,
2745 hmode_par_par_subtype,
2746 parameter_par_subtype,
2747 local_break_par_subtype,
2748 math_par_subtype,
2749} par_subtypes;
2750
2751# define last_par_subtype math_par_subtype
2752
2753static inline int tex_is_start_of_par_node(halfword n)
2754{
2755 return ( n && (node_type(n) == par_node) && (node_subtype(n) == vmode_par_par_subtype || node_subtype(n) == hmode_par_par_subtype) );
2756}
2757
2758extern halfword tex_get_par_par (halfword p, halfword what);
2759extern void tex_set_par_par (halfword p, halfword what, halfword v, int force);
2760extern void tex_snapshot_par (halfword p, halfword what);
2761extern halfword tex_find_par_par (halfword head);
2762
2763extern void tex_update_par_par (halfword cmd, halfword index);
2764
2765static inline int tex_par_state_is_set (halfword p, halfword what) { return (par_state(p) & par_category_to_codes[what]) == par_category_to_codes[what]; }
2766static inline void tex_set_par_state (halfword p, halfword what) { par_state(p) |= par_category_to_codes[what]; }
2767static inline int tex_par_to_be_set (halfword state, halfword what) { return (state & par_category_to_codes[what]) == par_category_to_codes[what]; }
2768
2769
2775
2776# define whatsit_node_size 2
2777
2778
2805
2806
2812
2813# define active_node_size 6
2814
2815# define active_fitness(a) vinfo1(a,0)
2816# define active_break_node(a) vlink(a,1)
2817# define active_line_number(a) vinfo(a,1)
2818# define active_total_demerits(a) vlink(a,2)
2819# define active_line_width(a) vinfo(a,2)
2820# define active_glue(a) vlink(a,3)
2821# define active_short(a) vinfo(a,3)
2822# define active_quality(a) vlink(a,4)
2823# define active_deficiency(a) vinfo(a,4)
2824# define active_n_of_fitness_classes(a) vlink(a,5)
2825# define active_reserved(a) vinfo(a,5)
2826
2827# define active_page_number(a) vinfo(a,1)
2828# define active_page_height(a) vinfo(a,2)
2829
2830# define passive_node_size 12
2831# define passive_fitness(a) vinfo1(a,0)
2832# define passive_cur_break(a) vlink(a,1)
2833# define passive_prev_break(a) vinfo(a,1)
2834# define passive_interline_penalty(a) vlink(a,2)
2835# define passive_broken_penalty(a) vinfo(a,2)
2836# define passive_left_box(a) vlink(a,3)
2837# define passive_left_box_width(a) vinfo(a,3)
2838# define passive_last_left_box(a) vlink(a,4)
2839# define passive_last_left_box_width(a) vinfo(a,4)
2840# define passive_right_box(a) vlink(a,5)
2841# define passive_right_box_width(a) vinfo(a,5)
2842# define passive_serial(a) vlink(a,6)
2843# define passive_middle_box(a) vinfo(a,6)
2844# define passive_quality(a) vlink(a,7)
2845# define passive_deficiency(a) vinfo(a,7)
2846# define passive_demerits(a) vlink(a,8)
2847# define passive_par_node(a) vinfo(a,8)
2848# define passive_badness(a) vlink(a,9)
2849# define passive_n_of_fitness_classes(a) vinfo(a,9)
2850# define passive_ref_count(a) vlink(a,10)
2851# define passive_reserved(a) vinfo(a,10)
2852# define passive_factor(a) dvalue(a,11)
2853
2854# define delta_node_size 6
2855# define delta_field_total_glue(d) vinfo(d,1)
2856# define delta_field_total_stretch(d) vlink(d,2)
2857# define delta_field_total_shrink(d) vinfo(d,2)
2858# define delta_field_total_fi_amount(d) vlink(d,3)
2859# define delta_field_total_fil_amount(d) vinfo(d,3)
2860# define delta_field_total_fill_amount(d) vlink(d,4)
2861# define delta_field_total_filll_amount(d) vinfo(d,4)
2862# define delta_field_font_shrink(d) vlink(d,5)
2863# define delta_field_font_stretch(d) vinfo(d,5)
2864
2865
2868
2869static inline void tex_couple_nodes(int a, int b)
2870{
2871 node_next(a) = b;
2872 node_prev(b) = a;
2873}
2874
2875static inline void tex_try_couple_nodes(int a, int b)
2876{
2877 if (b) {
2878 if (a) {
2879 node_next(a) = b;
2880 }
2881 node_prev(b) = a;
2882 } else if (a) {
2883 node_next(a) = null;
2884 }
2885}
2886
2887static inline void tex_uncouple_node(int a)
2888{
2889 node_next(a) = null;
2890 node_prev(a) = null;
2891}
2892
2893static inline halfword tex_head_of_node_list(halfword n)
2894{
2895 while (node_prev(n)) {
2896 n = node_prev(n);
2897 }
2898 return n;
2899}
2900
2901static inline halfword tex_tail_of_node_list(halfword n)
2902{
2903 while (node_next(n)) {
2904 n = node_next(n);
2905 }
2906 return n;
2907}
2908
2909
2915
2916# define attribute_cache_disabled max_halfword
2917# define current_attribute_state lmt_node_memory_state.attribute_cache
2918
2919extern halfword tex_copy_attribute_list (halfword attr);
2920extern halfword tex_copy_attribute_list_set (halfword attr, int index, int value);
2921extern halfword tex_patch_attribute_list (halfword attr, int index, int value);
2922extern halfword tex_merge_attribute_list (halfword first, halfword second);
2923extern void tex_dereference_attribute_list (halfword attr);
2924extern void tex_build_attribute_list (halfword target);
2925extern halfword tex_current_attribute_list (void);
2926extern int tex_unset_attribute (halfword target, int index, int value);
2927extern void tex_unset_attributes (halfword first, halfword last, int index);
2928extern void tex_set_attribute (halfword target, int index, int value);
2929extern int tex_has_attribute (halfword target, int index, int value);
2930
2931extern void tex_reset_node_properties (halfword target);
2932
2933# define get_attribute_list(target) \
2934 node_attr(target)
2935
2936
2943
2944static inline void add_attribute_reference(halfword a)
2945{
2946 if (a && a != attribute_cache_disabled) {
2947 ++attribute_count(a);
2948 }
2949}
2950
2951
2958
2959static inline void delete_attribute_reference(halfword a)
2960{
2961 if (a && a != attribute_cache_disabled) {
2962 tex_dereference_attribute_list(a);
2963 }
2964}
2965
2966# define remove_attribute_list(target) do { \
2967 halfword old_a = node_attr(target); \
2968 delete_attribute_reference(old_a); \
2969 node_attr(target) = null; \
2970} while (0)
2971
2972
2982
2983
2984
2985# define wipe_attribute_list_only(target) \
2986 node_attr(target) = null;
2987
2988
2992
2993static inline void tex_attach_attribute_list_copy(halfword target, halfword source)
2994{
2995 if (source) {
2996 halfword a_new = node_attr(source);
2997 halfword a_old = node_attr(target);
2998 node_attr(target) = a_new;
2999 add_attribute_reference(a_new);
3000 delete_attribute_reference(a_old);
3001 }
3002}
3003
3004static inline void tex_attach_attribute_list_attribute(halfword target, halfword a_new)
3005{
3006 if (a_new) {
3007 halfword a_old = node_attr(target);
3008 if (a_old != a_new) {
3009 node_attr(target) = a_new;
3010 add_attribute_reference(a_new);
3011 delete_attribute_reference(a_old);
3012 }
3013 }
3014}
3015
3016# define attach_current_attribute_list tex_build_attribute_list
3017
3018# define set_current_attribute_state(v) do { \
3019 current_attribute_state = v; \
3020} while (0)
3021
3022
3040
3041extern void tex_change_attribute_register(halfword a, halfword id, halfword value);
3042
3043
3047
3048extern void tex_print_short_node_contents (halfword n);
3049extern const char *tex_aux_subtype_str (halfword n);
3050extern void tex_show_node_list (halfword n, int threshold, int max);
3051extern halfword tex_actual_box_width (halfword r, scaled base_width);
3052extern void tex_print_name (halfword p, const char *what);
3053extern void tex_print_node_list (halfword n, const char *what, int threshold, int max);
3054
3055
3056extern void tex_print_extended_subtype (halfword p, quarterword s);
3057extern void tex_aux_show_dictionary (halfword p, halfword properties, halfword group, halfword index, halfword font, halfword character);
3058
3059
3062
3063extern halfword tex_new_node (quarterword i, quarterword j);
3064extern void tex_flush_node_list (halfword n);
3065extern void tex_flush_node (halfword n);
3066extern halfword tex_copy_node_list (halfword n, halfword e);
3067extern halfword tex_copy_node (halfword n);
3068extern halfword tex_copy_node_only (halfword n);
3069
3070
3071
3075
3076typedef enum glue_orders {
3077 normal_glue_order,
3078 fi_glue_order,
3079 fil_glue_order,
3080 fill_glue_order,
3081 filll_glue_order
3082} glue_orders;
3083
3084typedef enum glue_amounts {
3085
3086 total_advance_amount = 1,
3087 total_stretch_amount = 2,
3088 total_fi_amount = 3,
3089 total_fil_amount = 4,
3090 total_fill_amount = 5,
3091 total_filll_amount = 6,
3092 total_shrink_amount = 7,
3093 font_stretch_amount = 8,
3094 font_shrink_amount = 9,
3095
3096 max_height_amount = 10,
3097 max_depth_amount = 11,
3098
3099 n_of_glue_amounts = 12,
3100} glue_amounts;
3101
3102# define min_glue_order normal_glue_order
3103# define max_glue_order filll_glue_order
3104
3105typedef enum glue_signs {
3106 normal_glue_sign,
3107 stretching_glue_sign,
3108 shrinking_glue_sign
3109} glue_signs;
3110
3111# define min_glue_sign normal_glue_sign
3112# define max_glue_sign shrinking_glue_sign
3113
3114# define normal_glue_multiplier 0.0
3115
3116static inline singleword tex_checked_glue_sign (halfword sign) { return ((sign < min_glue_sign ) || (sign > max_glue_sign )) ? normal_glue_sign : (singleword) sign ; }
3117static inline halfword tex_checked_glue_order (halfword order) { return ((order < min_glue_order) || (order > max_glue_order)) ? normal_glue_order : order; }
3118
3119
3137
3138# define fi_glue (zero_glue + glue_spec_size)
3139# define fi_l_glue (fi_glue + glue_spec_size)
3140# define fi_ll_glue (fi_l_glue + glue_spec_size)
3141# define fi_ss_glue (fi_ll_glue + glue_spec_size)
3142# define fi_l_neg_glue (fi_ss_glue + glue_spec_size)
3143
3144# define page_insert_head (fi_l_neg_glue + glue_spec_size)
3145# define contribute_head (page_insert_head + split_node_size)
3146# define page_head (contribute_head + temp_node_size)
3147# define temp_head (page_head + glue_node_size)
3148# define hold_head (temp_head + temp_node_size)
3149# define post_adjust_head (hold_head + temp_node_size)
3150# define pre_adjust_head (post_adjust_head + temp_node_size)
3151# define post_migrate_head (pre_adjust_head + temp_node_size)
3152# define pre_migrate_head (post_migrate_head + temp_node_size)
3153# define align_head (pre_migrate_head + temp_node_size)
3154# define active_head (align_head + temp_node_size)
3155# define end_span (active_head + active_node_size)
3156# define begin_period (end_span + span_node_size)
3157# define end_period (begin_period + glyph_node_size)
3158
3159# define last_reserved (end_period + glyph_node_size - 1)
3160
3161
3162
3163extern int tex_list_has_glyph (halfword list);
3164
3165extern halfword tex_new_null_box_node (quarterword type, quarterword subtype);
3166extern halfword tex_new_rule_node (quarterword subtype);
3167extern halfword tex_new_glyph_node (quarterword subtype, halfword fnt, halfword chr, halfword parent);
3168extern halfword tex_new_char_node (quarterword subtype, halfword fnt, halfword chr, int all);
3169extern halfword tex_new_text_glyph (halfword fnt, halfword chr);
3170extern halfword tex_new_disc_node (quarterword subtype);
3171extern halfword tex_new_glue_spec_node (halfword param);
3172extern halfword tex_new_param_glue_node (quarterword param, quarterword subtype);
3173extern halfword tex_new_glue_node (halfword qlue, quarterword subtype);
3174extern halfword tex_new_kern_node (scaled width, quarterword subtype);
3175extern halfword tex_new_penalty_node (halfword penalty, quarterword subtype);
3176extern halfword tex_new_par_node (quarterword subtype);
3177
3178extern halfword tex_new_temp_node (void);
3179
3180extern scaled tex_glyph_width (halfword p);
3181extern scaled tex_glyph_height (halfword p);
3182extern scaled tex_glyph_depth (halfword p);
3183extern scaled tex_glyph_total (halfword p);
3184extern scaledwhd tex_glyph_dimensions (halfword p);
3185extern int tex_glyph_has_dimensions (halfword p);
3186extern scaled tex_glyph_width_ex (halfword p);
3187extern scaledwhd tex_glyph_dimensions_ex (halfword p);
3188
3189extern halfword tex_kern_dimension (halfword p);
3190extern halfword tex_kern_dimension_ex (halfword p);
3191
3192extern scaled tex_effective_glue (halfword parent, halfword glue);
3193
3194extern scaledwhd tex_pack_dimensions (halfword p);
3195
3196extern halfword tex_list_node_mem_usage (void);
3197extern halfword tex_reversed_node_list (halfword list);
3198extern int tex_n_of_used_nodes (int counts[]);
3199
3200# define _valid_node_(p) ((p > lmt_node_memory_state.reserved) && (p < lmt_node_memory_state.nodes_data.allocated) && (lmt_node_memory_state.nodesizes[p] > 0))
3201
3202static inline int tex_valid_node(halfword n)
3203{
3204 return n && _valid_node_(n) ? n : null;
3205}
3206
3207
3208
3209static inline int tex_math_skip_boundary(halfword n)
3210{
3211 return (n && node_type(n) == glue_node
3212 && (node_subtype(n) == space_skip_glue ||
3213 node_subtype(n) == xspace_skip_glue ||
3214 node_subtype(n) == zero_space_skip_glue));
3215}
3216
3217typedef enum special_node_list_types {
3218 page_insert_list_type,
3219 contribute_list_type,
3220 page_list_type,
3221 temp_list_type,
3222 hold_list_type,
3223 post_adjust_list_type,
3224 pre_adjust_list_type,
3225 post_migrate_list_type,
3226 pre_migrate_list_type,
3227 align_list_type,
3228
3229 page_discards_list_type,
3230 split_discards_list_type,
3231
3232} special_node_list_types;
3233
3234extern int tex_is_special_node_list (halfword n, int *istail);
3235extern halfword tex_get_special_node_list (special_node_list_types list, halfword *tail);
3236extern void tex_set_special_node_list (special_node_list_types list, halfword head);
3237
3238# endif
3239
3240 |