📄 xlc_codegen.c
字号:
cg_st.cgst_rightmost_pixel = 0; cg_st.cgst_sixel_buffer_empty = TRUE;cg_st.cgst_first_row = TRUE;/* Init VAX font table */font_init();/* * Initialize variables for tracking the VM used for downloaded and * spaced fonts. */cg_st.cgst_vm_downloaded_used = cg_st.cgst_vm_spaced_used = 0;/* Init dll font table */cg_st.cgst_next_element_for_swap = 0;for (boxnumber = 0; boxnumber < DLL_FONT_TABLE_SIZE; boxnumber++) { dll_font_table [boxnumber] .dll_active = INACTIVE; }/* Init spacing font table */for (boxnumber = 0; boxnumber < SPACING_FONT_TABLE_SIZE; boxnumber++) { spacing_font_table [boxnumber] .space_active = INACTIVE; }/* Put ps_st onto stack */ old_ps_stack_ptr = stack_ptr; /* Save old stack pointer */ stack_ptr++; /* Increment stack pointer */ /* Copy last ps_st into top of stack */ ps_st[stack_ptr] = ps_st[old_ps_stack_ptr];}ps_init_subjob ()/************************************************************************** * * ps_init_subjob is called for every subjob to open the Translator * dictionary, setup any debug information, and perform the save and * scale operations to prepare for translated data. * **************************************************************************/{/* Open TRN$XLATE_DICT to define cache limit, init sixelfont, * perform setpacking, and get the current input tray. */ps_str ("TRN$XLATE_DICT begin\n");/**** **** setpacking and setcachelimit are done here instead of in the prologue **** so that non-ANSI jobs will not be adversely effected by the state of **** the PS machine when the prologue is preloaded by the symbiont. ****/ps_str (str_setpacking);ps_str (str_setcachelimit);/* * Get the current paper tray to print from. Printing is restored to this * tray on a RIS. */ ps_str (str_finddefpapertray);/* * Set up the sixel font compression mapping. This needs to be done before * any PostScript 'saves' (and especially 'restores') are done; It is not * included as part of the prologue as constant data, since part of it * has to be built for consistent sixel compression mapping. */init_sixel_font_keys(); /* Close the Translator dictionary (TRN$XLATE_DICT) */ps_str (str_end);ps_str ("\f"); /* A <ff> to quickly find the end of the preamble */ps_str ("\n");/* Open the Translator dictionary. */ps_str ("TRN$XLATE_DICT begin\n");/* Start the translated output on a new line. */ps_str ("\nvmstatus pop /dllvminit exch def pop\n");PS_VM_TRACE_MACRO ("(Save level 1) dm0\n",cg_st.cgst_vm_size);M$SAVE(); /* Close Preamble level. Move stack to DLL level */PS_VM_TRACE_MACRO ("(Save level 2) dm0\n",cg_st.cgst_vm_size);M$SAVE(); /* Close DLL level. Move stack to Spaced level */PS_VM_TRACE_MACRO ("(Save level 3) dm0\n",cg_st.cgst_vm_size);M$SAVE(); /* Close Spaced level. Move stack to Define level */PS_VM_TRACE_MACRO ("(Save level 4) dm0\n",cg_st.cgst_vm_size);M$SAVE(); /* Close Define level. Move stack to Page level */ps_str (str_scale);}dispose_prologue (decbind)/************************************************************************* * * dispose_prologue () sends the ANSI prologue to the PS machine. If * the prologue is being preloaded for future use, the Translator does * not "bind" to the PostScript operators. * ************************************************************************/BOOLEAN decbind;{/* * Output the initial save if the prologue is going down to the * PostScript machine with the file. *//* * To fix the invalidrestore problems. The initial save has been * moved to xlc_main (). *//* if (decbind) ps_str ("save\n"); *//* Output the error handler only if ERROR_HANDLER is defined <>0 in dbug.h */#if ERROR_HANDLER ps_str (str_error_handler); /* <--- FOR DEBUG ONLY!!! */#endif/* Output the time stamp and version number of this prologue */ps_str (str_time_date_and_version);/* * If the prologue is going down to the PS machine with the file, then * bind to all the PostScript operators defined in the prologue. */if (decbind) ps_str (str_decbind);else ps_str (str_decbind_null);/* Now output the meat of the prologue */ps_str (str_prologue); }/* * * dispose_showpage * */dispose_showpage (){ /* Let's empty the sixel buffer, so we forget them */ sixel_empty_sixel_buffer ();if ((cur_ps_st -> curchar.ap.xval != cur_ps_st -> curchar.ap.xval) || (cur_ps_st -> curchar.ap.yval != cur_ps_st -> curchar.ap.yval) || (ALLCLOSED != cur_ps_st -> open)) { M$CLOSE_ALL(); M$CHECK_STATE_CHANGE_AP(cur_ps_st -> curchar.ap.xval,cur_ps_st -> curchar.ap.yval); M$CHECK_STATE_CHANGE_OPEN(ALLCLOSED,0); }/* Output the object and *//* Update ps_st based on objects impact */while (stack_ptr > PAGE-1) { M$RESTORE(); /* Restore back to page-1 level */ }M$OUTPUT_SHOWPAGE();M$SAVE();ps_str (str_scale);M$UPDATE_SHOWPAGE();}/* * * dispose_condshowpg * */dispose_condshowpg (){ if ( cg_st.cgst_wpf) dispose_showpage ();}dispose_eof ()/******************************************************************dispose_eof performs the final "restore" bringing the PS stateback to BAREUNIT******************************************************************/{ /* ps_str (" restore "); /* Return to base level */}dispose_end_of_subjob ()/**********************************************************************dispose_end_of_subjob closes all open PS states, does a final showpage ifneccessary, and closed the Translator dictionary (TRN$XLATE_DICT).***********************************************************************/{if ((ALLCLOSED != cur_ps_st -> open)) { M$CLOSE_ALL(); M$CHECK_STATE_CHANGE_OPEN(ALLCLOSED,0); }/* * Empty the sixel buffer, so we forget them */sixel_empty_sixel_buffer (); /* If the Translator is processing a setup module (i.e. the reset * exit bit is off) reset the active position to the top of the * page before doing the showpage. *//* Test to see if showpage command should be sent */while (stack_ptr > (PAGE - 1)) { M$RESTORE(); /* Restore back to preamble level */ }if (cg_st.cgst_wpf & cg_st.cgst_last_showpage) { /* Output the final showpage */ M$OUTPUT_SHOWPAGE(); cg_st.cgst_wpf = FALSE; }if (cg_st.cgst_last_showpage) { /* The last item sent after the last showpage is a newsheet */ ps_str(str_exec_newsheet); }while (stack_ptr > BAREUNIT+1) { M$RESTORE(); /* Restore back to entry level +1 */ }ps_str (" ");ps_str (str_end); /* Close Translator Dictionary *//* * An invalidrestore error message is received when printing jobs * with multilple files using setup. This is because the DPS * symbiont sends down device control library modules between * the first and second subjob. This leaves the PostScript * context in a state where a restore will produce the error * message. For the time being this problem will be fixed * by placing a save and restore around every subjob. */ps_str (" restore "); /* Return to base level */}/* * * process_char * */DEF process_char(glyph_ptr)PGLYPH glyph_ptr;{cg_st.cgst_wpf = TRUE;if ( (vax_font_table_box_number[glyph_ptr -> char_data.char_font] != cur_ps_st -> curchar.char_data.char_font) || (glyph_ptr -> font_data.horizontal_spacing != cur_ps_st -> curchar.font_data.horizontal_spacing) || (1 != cur_ps_st -> scale_factor.xval) || (1 != cur_ps_st -> scale_factor.yval) || (cg_st.cgst_orientation != cur_ps_st -> orientation) || (cg_st.cgst_sheet_len != cur_ps_st -> sheet_len) || (cg_st.cgst_origin.xval != cur_ps_st -> origin.xval) || (cg_st.cgst_origin.yval != cur_ps_st -> origin.yval) || (glyph_ptr -> attr_data.attr_baseline_offset != cur_ps_st -> curchar.attr_data.attr_baseline_offset) || (glyph_ptr -> font_data.algorithmic_attributes != cur_ps_st -> curchar.font_data.algorithmic_attributes) || (SHOWOPEN != cur_ps_st -> open)) { M$CLOSE_ALL(); M$CHECK_STATE_CHANGE_FONT(glyph_ptr -> char_data.char_font, glyph_ptr -> font_data.horizontal_spacing); M$CHECK_STATE_CHANGE_SCALE(1,1); M$CHECK_STATE_CHANGE_ORIENT(cg_st.cgst_orientation, cg_st.cgst_sheet_len); M$CHECK_STATE_CHANGE_ORIGIN(cg_st.cgst_origin.xval, cg_st.cgst_origin.yval); M$CHECK_STATE_CHANGE_AP(glyph_ptr -> ap.xval,glyph_ptr -> ap.yval); M$CHECK_STATE_CHANGE_ATTRS(glyph_ptr -> font_data.algorithmic_attributes, glyph_ptr -> attr_data.attr_baseline_offset); M$CHECK_STATE_CHANGE_OPEN(SHOWOPEN, glyph_ptr -> font_data.algorithmic_attributes); } else if ( (glyph_ptr -> ap.xval != cur_ps_st -> curchar.ap.xval) || (glyph_ptr -> ap.yval != cur_ps_st -> curchar.ap.yval) ) { /* ** Patch the AP since it is such a common fault. This will avoid ** the overhead usually created for a AP fault. This was handled ** in three steps (using J171 as an example). ** ** 1) Close the current show ** 2) Update the AP ** 3) Open the show */ /* ** 1) Closing the current show. We steal the top of M$CLOSE_SHOW */ ps_char ('\)'); if (cur_ps_st -> curchar.font_data.algorithmic_attributes & (UL | OVERLINE | DOU_UL)) { oprintf(" %d", (cur_ps_st->curchar.attr_data.attr_baseline_offset - cur_ps_st->curchar.ap.yval)); }; ps_str (close_show_str [(cur_ps_st -> curchar.font_data.algorithmic_attributes & (UL | OVERLINE | DOU_UL | ITALIC | BOLD | STRIKE))]); /* ** 2) Update the AP. Taken from M$SET_AP. The restore is from ** the M$RESTORE that followed the closing above. It comes ** as a freebie here (no additional call needed), so we take it. ** We also have to lie to the VAX stack that minics PS stack. */ oprintf (str_restore_moveto, glyph_ptr ->ap.xval, glyph_ptr ->ap.yval ); ps_st[(stack_ptr -1)].curchar.ap.xval = cur_ps_st->curchar.ap.xval = glyph_ptr-> ap.xval ; ps_st[(stack_ptr -1)].curchar.ap.yval = cur_ps_st->curchar.ap.yval = glyph_ptr-> ap.yval ; /* ** 3) Open the SHOW. Sorta from M$OPEN_SHOW (more a matter of ** following the lead of J171. */ ps_str (str_save_open_show) ; } /* Output the object and */ /* Update ps_st based on objects impact */ { UBYTE tmp_local_cache = mapping_tables [vax_font_table_mapping_index[glyph_ptr->char_data.char_font]] [glyph_ptr->char_data.char_code] ; M$PS_SCHAR (tmp_local_cache) ; } M$UPDATE_AP_R(glyph_ptr -> char_data.char_width); return(TRUE);}/* * * dispose_vchar * */dispose_vchar (glyph_ptr)GLYPH *glyph_ptr;{ /* Set all desired states in desired_st table *//* Check for any state changes *//* If any changes update ps_st and issue PS command */if ( (vax_font_table_box_number [glyph_ptr -> char_data.char_font] != cur_ps_st -> curchar.char_data.char_font) || (glyph_ptr -> font_data.horizontal_spacing != cur_ps_st -> curchar.font_data.horizontal_spacing) || (1 != cur_ps_st -> scale_factor.xval) || (1 != cur_ps_st -> scale_factor.yval) || (cg_st.cgst_orientation != cur_ps_st -> orientation) || (cg_st.cgst_sheet_len != cur_ps_st -> sheet_len) || (cg_st.cgst_origin.xval != cur_ps_st -> origin.xval) || (cg_st.cgst_origin.yval != cur_ps_st -> origin.yval) || (glyph_ptr -> ap.xval != cur_ps_st -> curchar.ap.xval) || (glyph_ptr -> ap.yval != cur_ps_st -> curchar.ap.yval) || (glyph_ptr -> attr_data.attr_baseline_offset != cur_ps_st -> curchar.attr_data.attr_baseline_offset) || (glyph_ptr -> font_data.algorithmic_attributes != cur_ps_st -> curchar.font_data.algorithmic_attributes) || (ALLCLOSED != cur_ps_st -> open)) { M$CLOSE_ALL(); M$CHECK_STATE_CHANGE_FONT(glyph_ptr -> char_data.char_font, cur_ps_st -> curchar.font_data.horizontal_spacing); M$CHECK_STATE_CHANGE_SCALE(1, 1); M$CHECK_STATE_CHANGE_ORIENT(cg_st.cgst_orientation, cg_st.cgst_sheet_len); M$CHECK_STATE_CHANGE_ORIGIN(cg_st.cgst_origin.xval, cg_st.cgst_origin.yval); M$CHECK_STATE_CHANGE_AP(glyph_ptr -> ap.xval,glyph_ptr -> ap.yval); M$CHECK_STATE_CHANGE_ATTRS(cg_st.cgst_origin.xval, glyph_ptr -> attr_data.attr_baseline_offset); M$CHECK_STATE_CHANGE_OPEN(ALLCLOSED,cg_st.cgst_origin.xval); }/* Output the object and *//* Update ps_st based on objects impact */{ /* Super kludge to avoid a compile error in macro string length. The ** compiler could not handle the text for 'tmp', so a caching is done ** with a local var. */ LONG tmp= (glyph_ptr->attr_data.attr_baseline_offset-glyph_ptr->ap.yval);M$OUTPUT_VCHAR(glyph_ptr->font_data.algorithmic_attributes, glyph_ptr->char_data.char_width, glyph_ptr->char_data.char_code, tmp);}M$UPDATE_AP_A(-1,-1); /* The routines doing VCHAR loose the active position, (there is no current point left * so we cannot do an update ap relative as would seem the case, * but have to set the active position to undefined (-1, -1) using * an update ap absolute */}/* * * dispose_decvec *
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -