static Bool try_roam_named_colors(GS_COLORinfo *colorInfo, NAMECACHE *sepname, EQUIVCOLOR equivs, Bool *foundEquivs, EXTRADATA *extraData) { OBJECT namedColorIntercept; Bool foundResource; /* Find out if the Roam NamedColor resource exists; it is an optional resource. * If it doesn't exist, just return success with foundEquivs unset. */ if (!run_ps_string((uint8*)"/Roam /NamedColorOrder resourcestatus")) { HQFAIL("Internal resourcestatus failed for Roam NamedColorOrder"); /* If this fails then the tidyup is handled by the client. */ return FALSE; } foundResource = oBool(*theTop(operandstack)); pop(&operandstack); if (!foundResource) return TRUE; /* pop the other 2 items left by a successful resourcestatus */ npop(2, &operandstack); /* The Roam resource exists so and set it in the gstate. Then attempt to * get equivalent colors using the named color interception. * NB1. The NamedColor databases used in this method can be quite different * to the ones used in the standard method. * NB2. The resource can be obtained via a PS callout and placed into a dict * ready for passing to setinterceptcolorspace, but it must be installed * into the correct colorInfo. */ if (!run_ps_string((uint8*)"<< /NamedColor /Roam /NamedColorOrder findresource >>")) { HQFAIL("Internal findresource failed for Roam NamedColorOrder"); /* If this fails then the tidyup is handled by the client. */ return FALSE; } Copy(&namedColorIntercept, theTop(operandstack)); pop(&operandstack); if (!gsc_setinterceptcolorspace(colorInfo, &namedColorIntercept)) return FALSE; return named_colors_common(colorInfo, sepname, equivs, foundEquivs, extraData->outputSpaceId, extraData->equivColorType); }
/* ---------------------------------------------------------------------------- function: loop_() author: Andrew Cave creation date: 22-Oct-1987 last modification: ##-###-#### arguments: none . description: See PostScript reference manual page 182. ---------------------------------------------------------------------------- */ Bool loop_(ps_context_t *pscontext) { OBJECT *o1 ; UNUSED_PARAM(ps_context_t *, pscontext) ; if ( isEmpty( operandstack )) return error_handler( STACKUNDERFLOW ) ; o1 = theTop( operandstack ) ; switch ( oType(*o1) ) { case OARRAY : case OPACKEDARRAY : if ( ! oExecutable(*o1) ) { pop( & operandstack ) ; return error_handler( STACKOVERFLOW ) ; } break ; /* Return stack overflow, as our stacks can grow ever so large. */ default: return error_handler( TYPECHECK ) ; } if ( ! oCanExec(*o1) && !object_access_override(o1) ) return error_handler( INVALIDACCESS ) ; if ( ! push( o1 , & executionstack )) return FALSE ; if ( ! xsetup_operator( NAME_xloop , 2 )) return FALSE ; pop( & operandstack ) ; return TRUE ; }
/* setxmlparams PS operator - sets current xml parameters. */ Bool setxmlparams_(ps_context_t *pscontext) { corecontext_t *context = ps_core_context(pscontext) ; OBJECT* odict ; /* Check there is a readable dict on top of operand stack */ if ( isEmpty(operandstack) ) { return error_handler(STACKUNDERFLOW) ; } odict = theTop(operandstack) ; if ( oType(*odict) != ODICTIONARY ) { return error_handler(TYPECHECK) ; } if ( !oCanRead(*oDict(*odict)) ) { if ( !object_access_override(odict) ) { return error_handler(INVALIDACCESS) ; } } /** \todo TODO - validate and merge new global xml parameters */ /* And add any other parameters registered with xmlparamlist */ if ( !setparams(context, odict, context->xmlparamlist) ) return FALSE ; /* remove dict from stack */ pop(&operandstack) ; return TRUE ; }
static Bool try_rcb_named_colors(GS_COLORinfo *colorInfo, NAMECACHE *sepname, EQUIVCOLOR equivs, Bool *foundEquivs, EXTRADATA *extraData) { OBJECT namedColorIntercept; /* Get the Recombine NamedColor resource and set it in the gstate. Then * attempt to get equivalent colors using the same methods as for non-recombine. * This is a low priority method if all else fails. NB. The NamedColor * databases used in this method can be quite different to the ones used in * the standard method above, often a superset just to allow the job to output. * NB. The resource can be obtained via a PS callout, but it must be installed * into the correct colorInfo. */ if (!run_ps_string((uint8*)"<< /NamedColor /Recombine /NamedColorOrder findresource >>")) { HQFAIL("Internal setting of Recombine NamedColorOrder resource failed"); return error_handler(UNDEFINED); } Copy(&namedColorIntercept, theTop(operandstack)); pop(&operandstack); if (!gsc_setinterceptcolorspace(colorInfo, &namedColorIntercept)) return FALSE; return named_colors_common(colorInfo, sepname, equivs, foundEquivs, extraData->outputSpaceId, extraData->equivColorType); }
/* ---------------------------------------------------------------------------- function: run_() author: Andrew Cave creation date: 22-Oct-1987 last modification: ##-###-#### arguments: none . description: See PostScript reference manual page 207. ---------------------------------------------------------------------------- */ Bool run_(ps_context_t *pscontext) { register OBJECT *o1 ; OBJECT fileo = OBJECT_NOTVM_NOTHING ; UNUSED_PARAM(ps_context_t *, pscontext) ; if ( isEmpty( operandstack )) return error_handler( STACKUNDERFLOW ) ; o1 = theTop( operandstack ) ; if ( oType(*o1) != OSTRING ) return error_handler( TYPECHECK) ; if ( !oCanRead(*o1) && !object_access_override(o1) ) return error_handler( INVALIDACCESS ) ; if ( !file_open(o1, SW_RDONLY|SW_FROMPS, READ_FLAG, FALSE, 0, &fileo) ) return FALSE ; SetRunFile(&fileo) ; theTags(fileo) = OFILE | EXECUTABLE | READ_ONLY ; currfileCache = NULL ; execStackSizeNotChanged = FALSE ; if ( ! push(&fileo, &executionstack) ) return FALSE; pop( & operandstack ) ; return TRUE ; }
Collection<ByteArray> OrSpans::getPayload() { Collection<ByteArray> result; SpansPtr theTop(top()); if (theTop && theTop->isPayloadAvailable()) { Collection<ByteArray> payload(theTop->getPayload()); result = Collection<ByteArray>::newInstance(payload.begin(), payload.end()); } return result; }
/* ---------------------------------------------------------------------------- function: ifelse_() author: Andrew Cave creation date: 22-Oct-1987 last modification: ##-###-#### arguments: none . description: See PostScript reference manual page 169. ---------------------------------------------------------------------------- */ Bool ifelse_(ps_context_t *pscontext) { register OBJECT *o1 , *o2 , *o3 ; UNUSED_PARAM(ps_context_t *, pscontext) ; if ( theStackSize( operandstack ) < 2 ) return error_handler( STACKUNDERFLOW ) ; o3 = theTop( operandstack ) ; o2 = ( & o3[ -1 ] ) ; o1 = ( & o3[ -2 ] ) ; if ( ! fastStackAccess( operandstack )) { o2 = stackindex( 1 , & operandstack ) ; o1 = stackindex( 2 , & operandstack ) ; } if ( oType(*o1) != OBOOLEAN ) return error_handler( TYPECHECK ) ; switch ( oType(*o2) ) { case OARRAY : case OPACKEDARRAY : break ; default: return error_handler( TYPECHECK ) ; } switch ( oType(*o3) ) { case OARRAY : case OPACKEDARRAY : if ( (!oCanExec(*o2) && !object_access_override(o2)) || (!oCanExec(*o3) && !object_access_override(o3)) ) return error_handler( INVALIDACCESS ) ; break ; default: return error_handler( TYPECHECK ) ; } if ( oBool(*o1) ) o3 = o2 ; if ( oExecutable(*o3) ) { execStackSizeNotChanged = FALSE ; if ( ! push( o3 , & executionstack )) return FALSE ; npop( 3 , & operandstack ) ; } else { Copy( o1 , o3 ) ; npop( 2 , & operandstack ) ; } return TRUE ; }
/* ---------------------------------------------------------------------------- function: exit_() author: Andrew Cave creation date: 22-Oct-1987 last modification: ##-###-#### arguments: none . description: See PostScript reference manual page 154. ---------------------------------------------------------------------------- */ Bool exit_(ps_context_t *pscontext) { register OBJECT *o1 ; execStackSizeNotChanged = FALSE ; while ( ! isEmpty( executionstack )) { o1 = theTop( executionstack ) ; switch ( oType(*o1) ) { case OARRAY: /* This case used to be explicitly represented as the first if-branch. Presumably it was explicitly different to the default for efficiency reasons, but that seems a bit spurious now. */ pop( & executionstack ) ; break ; case ONOTHING: /* Represents a looping context if len non-zero */ if ( theLen(*o1)) { npop( theLen(*o1), & executionstack ) ; return TRUE ; } pop( & executionstack ) ; break ; case ONULL : switch ( theLen(*o1)) { case ISINTERPRETEREXIT: oInteger(*o1) = NAME_exit; return TRUE; case ISPATHFORALL : path_free_list(thePathOf(*(PATHFORALL *)oOther(*o1)), mm_pool_temp) ; free_forallpath(oOther(*o1)) ; npop( 5 , & executionstack ) ; return TRUE ; } pop( & executionstack ) ; break ; case OMARK : /* Represents a stopped mark */ return error_handler( INVALIDEXIT ) ; case OFILE : /* Represents a run object - if length set to special value */ currfileCache = NULL ; if ( IsRunFile( o1 )) return error_handler( INVALIDEXIT ) ; default: pop( & executionstack ) ; } } return quit_(pscontext) ; }
static Bool inupath( int32 matrixok, int32 intype, int32 filltype ) { OMATRIX adjustment_matrix ; OBJECT *arg ; PATHINFO upath ; Bool has_matrix = FALSE ; int32 nargs = 0 ; Bool result ; if ( isEmpty(operandstack) ) return error_handler(STACKUNDERFLOW) ; arg = theTop(operandstack) ; if ( matrixok ) if ( (has_matrix = is_matrix_noerror(arg, & adjustment_matrix)) != (int32)0 ) nargs++ ; if ( theStackSize(operandstack) < nargs ) return error_handler(STACKUNDERFLOW) ; arg = stackindex(nargs++, &operandstack) ; if ( ! upath_to_path(arg, UPARSE_CLOSE, &upath) ) return FALSE ; /* don't bother stroking upath if it is degenerate, result is the same */ if ( intype == INSTROKE && thePath(upath) ) { /* convert to outline */ STROKE_PARAMS params ; set_gstate_stroke(¶ms, &upath, &upath, FALSE) ; /* replace path */ if ( has_matrix ) { params.usematrix = TRUE ; matrix_mult( &adjustment_matrix, &thegsPageCTM(*gstateptr), ¶ms.orig_ctm ) ; } if ( ! dostroke(¶ms, GSC_ILLEGAL, STROKE_NOT_VIGNETTE) ) { /* replaces original path */ path_free_list(thePath(upath), mm_pool_temp) ; /* dispose of original path on error */ return FALSE ; } HQASSERT(! thePath(upath) || theILineType(upath.lastline) == MYCLOSE || theILineType(upath.lastline) == CLOSEPATH, "Path from stroked dostroke is NULL") ; } result = inpath_common(filltype, thePath(upath), nargs) ; path_free_list(thePath(upath), mm_pool_temp) ; /* dispose of path */ return result ; }
Bool setuserlabel_(ps_context_t *pscontext) { OBJECT *theo; UNUSED_PARAM(ps_context_t *, pscontext) ; if ( isEmpty( operandstack )) return error_handler( STACKUNDERFLOW ); theo = theTop( operandstack ) ; if ( oType( *theo ) != OBOOLEAN ) return error_handler( TYPECHECK ); gstateptr->user_label = (uint8)oBool( *theo ); pop( & operandstack ) ; return TRUE; }
static Bool runOPI(Bool *rendered) { /* try to ensure that operand stack does not accumulate junk, whether opi * is run or not. Stack clean up in error case is in Postscript, as we * cannot be 100% sure of state stack is in, when error occurs. */ char *runOPI = "mark exch /HqnOPI /ProcSet resourcestatus {\n" " pop pop\n" " <<>> /HqnOPI /ProcSet findresource /HqnOPIimage get exec\n" " { cleartomark true } { cleartomark false } ifelse " "} {\n" " cleartomark false\n" "} ifelse"; OBJECT obj = OBJECT_NOTVM_NOTHING ; theTags( obj ) = OSTRING | EXECUTABLE | READ_ONLY ; theLen ( obj ) = strlen_uint16( runOPI ) ; oString( obj ) = ( uint8 * )runOPI ; execStackSizeNotChanged = FALSE ; *rendered = FALSE ; if ( push( & obj , & executionstack )) { if ( interpreter( 1 , NULL )) { if ( theStackSize( operandstack ) > EMPTY_STACK ) { OBJECT *theo = theTop( operandstack ) ; if ( oType( *theo ) != OBOOLEAN ) return error_handler( TYPECHECK ) ; *rendered = oBool( *theo ) ; pop( & operandstack ) ; } else return error_handler( STACKUNDERFLOW ) ; } else return FALSE; } return TRUE ; }
/* ---------------------------------------------------------------------------- function: myexec_() author: Andrew Cave creation date: 22-Oct-1987 last modification: ##-###-#### arguments: none . description: See PostScript reference manual page 152. ---------------------------------------------------------------------------- */ Bool myexec_(ps_context_t *pscontext) { OBJECT *theo ; OBJECT obj = OBJECT_NOTVM_NOTHING; UNUSED_PARAM(ps_context_t *, pscontext) ; if ( isEmpty( operandstack )) return error_handler( STACKUNDERFLOW ) ; theo = theTop( operandstack ) ; OCopy( obj, *theo ); pop ( &operandstack ); return setup_pending_exec(&obj, FALSE); }
/* ---------------------------------------------------------------------------- function: repeat_() author: Andrew Cave creation date: 22-Oct-1987 last modification: ##-###-#### arguments: none . description: See PostScript reference manual page 202. ---------------------------------------------------------------------------- */ Bool repeat_(ps_context_t *pscontext) { register OBJECT *o1 , *o2 ; UNUSED_PARAM(ps_context_t *, pscontext) ; if ( theStackSize( operandstack ) < 1 ) return error_handler( STACKUNDERFLOW ) ; o2 = theTop( operandstack ) ; o1 = ( & o2[ -1 ] ) ; if ( ! fastStackAccess( operandstack )) o1 = stackindex( 1 , & operandstack ) ; if ( oType(*o1) != OINTEGER ) return error_handler( TYPECHECK ) ; switch ( oType(*o2) ) { case OARRAY : case OPACKEDARRAY : break ; default: return error_handler( TYPECHECK ) ; } if ( ! oExecutable(*o2) && !object_access_override(o2) ) return error_handler( INVALIDACCESS ) ; if ( oInteger(*o1) < 0 ) return error_handler( RANGECHECK ) ; else if ( oInteger(*o1) == 0 || theLen(*o2) == 0 ) { npop( 2 , & operandstack ) ; return TRUE ; } if ( ! push( o1 , & executionstack )) return FALSE ; if ( ! push( o2 , & executionstack )) return FALSE ; if ( ! xsetup_operator( NAME_xrepeat , 3 )) return FALSE ; npop( 2 , & operandstack ) ; return TRUE ; }
/* For xaforall, the execution stack contains: 0 ONOTHING len=size of this block (3 or 5) oOp = xaforall 1 OARRAY len=elements left to deliver oArray=next element to deliver or OEXTENDED len=0 oArray = trampoline below 2 OARRAY - the proc to run For long arrays: 3 OARRAY len=0 oArray = next element to deliver 4 OINTEGER len=0 oInteger = remaining elements */ Bool xaforall(ps_context_t *pscontext) { register OBJECT *theo ; UNUSED_PARAM(ps_context_t *, pscontext) ; theo = stackindex( 1 , & executionstack ) ; if ( ! theXLen(*theo)) { npop( theLen(*theTop(executionstack)) , & executionstack ) ; return TRUE ; } if ( oType(*theo) == OEXTENDED ) { /* Long arrays */ if ( !push(oLongArray(*theo), &operandstack) ) return FALSE ; if (--oLongArrayLen(*theo) == 0) oLongArray(*theo) = NULL ; else ++oLongArray(*theo) ; } else { /* Normal arrays */ if ( ! push(oArray(*theo) , & operandstack )) return FALSE ; if ( --theLen(*theo) == 0 ) oArray(*theo) = NULL ; else ++oArray(*theo) ; } theo = stackindex( 2 , & executionstack ) ; if ( oExecutable(*theo) ) return push( theo , & executionstack ) ; else return push( theo , & operandstack ) ; }
/* ---------------------------------------------------------------------------- function: search_() author: Andrew Cave creation date: 09-Oct-1987 last modification: ##-###-#### arguments: none. description: See PostScript reference manual page 211. ---------------------------------------------------------------------------- */ Bool search_(ps_context_t *pscontext) { int32 postsize , matchsize , presize ; OBJECT *o1 , *o2 ; uint8 *str ; uint8 tags1 , tags2 ; uint8 *seek ; int32 stringsize ; OBJECT newobject = OBJECT_NOTVM_NOTHING ; UNUSED_PARAM(ps_context_t *, pscontext) ; if ( theStackSize( operandstack ) < 1 ) return error_handler( STACKUNDERFLOW ) ; /* Check types. */ o1 = stackindex( 1 , & operandstack ) ; o2 = theTop( operandstack ) ; tags1 = theTags(*o1) ; tags2 = theTags(*o2) ; if ( oType(*o1) != OSTRING || oType(*o2) != OSTRING ) return error_handler( TYPECHECK ) ; /* Check access requirements. */ if ( (!oCanRead(*o1) && !object_access_override(o1)) || (!oCanRead(*o2) && !object_access_override(o2)) ) return error_handler( INVALIDACCESS ) ; /* Extract the location of seek & string, and their lengths. */ seek = oString(*o2) ; str = oString(*o1) ; matchsize = theLen(*o2) ; stringsize = theLen(*o1) ; /* Remove the trivial cases. */ if ( stringsize == 0 ) { Copy(o2, &fnewobj) ; return TRUE ; } if ( matchsize == 0 ) { theTags( newobject ) = tags1 ; theLen( newobject ) = 0 ; oString( newobject ) = NULL ; SETGLOBJECTTO(newobject, oGlobalValue(*o1)); if ( ! push2(&newobject, &tnewobj, &operandstack) ) return FALSE ; theTags(*o2) = tags1 ; SETGLOBJECTTO(*o2, oGlobalValue(*o1)); return TRUE ; } postsize = stringsize - matchsize ; presize = 0 ; /* Compare sub-strings of string (of length match_size) with seek, until no sub-string left that is that long, or have found match. */ while ( postsize >= 0 ) { /* If matched up sub-string, then setup post, match & pre. */ if ( ! HqMemCmp( & str[ presize ] , matchsize , seek , matchsize )) { theTags( newobject ) = tags1 ; theLen( newobject ) = ( uint16 )presize ; oString( newobject ) = ( presize != 0 ? str : NULL ) ; SETGLOBJECTTO(newobject, oGlobalValue(*o1)); if ( ! push2(&newobject, &tnewobj, &operandstack) ) return FALSE ; theTags(*o2) = tags1 ; theLen(*o2) = ( uint16 )matchsize ; oString(*o2) = str + presize ; SETGLOBJECTTO(*o2, oGlobalValue(*o1)); theLen(*o1) = ( uint16 )postsize ; oString(*o1) = ( postsize != 0 ? str + presize + matchsize : NULL ) ; return TRUE ; } /* Otherwise look at next sub-string. */ ++presize ; --postsize ; } /* No match occurred, so push the boolean false. */ Copy(o2, &fnewobj) ; return TRUE ; }
/* ---------------------------------------------------------------------------- function: anchorsearch_() author: Andrew Cave creation date: 09-Oct-1987 last modification: ##-###-#### arguments: none. description: See PostScript reference manual page 116. ---------------------------------------------------------------------------- */ Bool anchorsearch_(ps_context_t *pscontext) { int32 stringsize , postsize , matchsize ; OBJECT *o1 , *o2 ; uint8 tags1 , tags2 ; uint8 *str , *seek ; UNUSED_PARAM(ps_context_t *, pscontext) ; if ( theStackSize( operandstack ) < 1 ) return error_handler( STACKUNDERFLOW ) ; /* Check types. */ o1 = stackindex( 1 , & operandstack ) ; o2 = theTop( operandstack ) ; tags1 = theTags(*o1) ; tags2 = theTags(*o2) ; if ( oType(*o1) != OSTRING || oType(*o2) != OSTRING ) return error_handler( TYPECHECK ) ; /* Check access requirements. */ if ( (!oCanRead(*o1) && !object_access_override(o1)) || (!oCanRead(*o2) && !object_access_override(o2)) ) return error_handler( INVALIDACCESS ) ; /* Extract the locations of seek & string, and their lengths.*/ seek = oString(*o2) ; str = oString(*o1) ; matchsize = theLen(*o2) ; stringsize = theLen(*o1) ; /* Remove the trivial cases. */ postsize = stringsize - matchsize ; if ( postsize < 0 ) { Copy(o2, &fnewobj) ; return TRUE ; } if ( matchsize == 0 ) { if ( ! push( & tnewobj , & operandstack )) return FALSE ; theTags(*o2) = tags1 ; SETGLOBJECTTO(*o2, oGlobalValue(*o1)); return TRUE ; } /* Compare initial sub-string of string (of length match_size) with seek. If initial sub-string matches, then setup post & match, and boolean true. */ if ( HqMemCmp( str , matchsize , seek , matchsize) == 0 ) { if ( ! push( & tnewobj , & operandstack )) return FALSE ; theTags(*o2) = tags1 ; theLen(*o2) = ( uint16 )matchsize ; oString(*o2) = str ; SETGLOBJECTTO(*o2, oGlobalValue(*o1)); theLen(*o1) = ( uint16 )postsize ; oString(*o1) = ( postsize != 0 ? str + matchsize : NULL ) ; return TRUE ; } /* Else no match occurred, so push boolean false. */ Copy(o2, &fnewobj) ; return TRUE ; }
/* ---------------------------------------------------------------------------- function: forall_() author: Andrew Cave creation date: 22-Oct-1987 last modification: ##-###-#### arguments: none . description: See PostScript reference manual page 161. ---------------------------------------------------------------------------- */ Bool forall_(ps_context_t *pscontext) { int32 which, number, type ; OBJECT *o1, *o2, *accessobj ; UNUSED_PARAM(ps_context_t *, pscontext) ; if ( theStackSize( operandstack ) < 1 ) return error_handler( STACKUNDERFLOW ) ; o2 = theTop( operandstack ) ; switch ( oType(*o2) ) { case OARRAY : case OPACKEDARRAY : break ; default: return error_handler( TYPECHECK ) ; } number = 3 ; accessobj = o1 = stackindex(1, &operandstack) ; type = oXType(*o1) ; switch ( type ) { case ODICTIONARY : accessobj = oDict(*o1) ; oInteger(inewobj) = DICT_ALLOC_LEN(accessobj); if ( ! push( & inewobj , & executionstack )) return FALSE ; which = NAME_xdforall ; ++number ; break ; case OSTRING : which = NAME_xsforall ; break ; case OLONGSTRING : oInteger(inewobj) = 0 ; if ( ! push( & inewobj , & executionstack )) return FALSE ; which = NAME_xlsforall ; ++number ; break ; case OLONGARRAY : case OLONGPACKEDARRAY : /* The trampoline must be pushed too, as it is modified by xaforall */ if ( ! push( oArray(*o1) , & executionstack ) || /* length */ ! push( oArray(*o1)+1 , & executionstack )) /* subarray */ return FALSE ; number+=2; /* drop through */ case OARRAY : case OPACKEDARRAY : which = NAME_xaforall ; break ; default: return error_handler( TYPECHECK ) ; } if ( (!oCanRead(*accessobj) && !object_access_override(accessobj)) || (!oCanExec(*o2) && !object_access_override(o2)) ) { while ( number-- > 3 ) pop( & executionstack ) ; return error_handler( INVALIDACCESS ) ; } if ( ! push( o2 , & executionstack )) return FALSE ; if ( ! push( o1 , & executionstack )) return FALSE ; switch ( type ) { case OLONGARRAY: case OLONGPACKEDARRAY: /* point the pushed OEXTENDED at the pushed trampoline below it */ o1 = theTop(executionstack) ; oArray(*o1) = stackindex( 3 , & executionstack ) ; break ; } if ( ! xsetup_operator( which , number )) return FALSE ; npop( 2 , & operandstack ) ; return TRUE ; }
Bool externalfilter_(ps_context_t *pscontext) { OBJECT *o1, *o2 ; int32 dev_number, name_length ; uint8 *filter_name ; UNUSED_PARAM(ps_context_t *, pscontext) ; HQTRACE( debug_filters , ( "Welcome to externalfilter" )) ; /* externalfilter is always called with two args on the stack, even if the second one isn't used */ if ( theStackSize( operandstack ) < 1 ) return error_handler( STACKUNDERFLOW ) ; o1 = theTop( operandstack ) ; /* integer code or dictionary */ switch ( oType(*o1) ) { case OINTEGER: dev_number = oInteger(*o1); break ; case ODICTIONARY: o2 = stackindex( 1, &operandstack ) ; /* filter name */ return filter_external_define( o1 , o2 ); /* device to be added */ default: return error_handler(TYPECHECK) ; } if ( dev_number == -3 ) { /* resourceforall */ pop( &operandstack ) ; return filter_external_forall(&operandstack); } o2 = stackindex(1, &operandstack ) ; /* filter name */ switch ( oType(*o2) ) { case ONAME: filter_name = theICList(oName(*o2)) ; name_length = theINLen(oName(*o2)) ; break ; case OSTRING: /* undocumented - but they allow strings as an argument */ filter_name = oString(*o2) ; name_length = theLen(*o2) ; break ; default: return error_handler( TYPECHECK ) ; } switch ( dev_number ) { case -2: /* findresource */ if ( filter_external_exists(filter_name, name_length) ) { Copy(o1, &tnewobj) ; } else { Copy(o1, &fnewobj) ; } return TRUE ; case -1: /* undefineresource */ npop(2, &operandstack) ; return filter_external_undefine(filter_name, name_length); } return error_handler(RANGECHECK) ; }
/* ---------------------------------------------------------------------------- function: execstack_() author: Andrew Cave creation date: 22-Oct-1987 last modification: ##-###-#### arguments: none . description: See PostScript reference manual page 152. ---------------------------------------------------------------------------- */ Bool execstack_(ps_context_t *pscontext) { register OBJECT *o1 ; int32 esize, realrun ; corecontext_t *corecontext = pscontext->corecontext ; if ( isEmpty( operandstack )) return error_handler( STACKUNDERFLOW ) ; o1 = theTop( operandstack ) ; switch ( oType(*o1) ) { case OARRAY : case OPACKEDARRAY : break ; default: return error_handler( TYPECHECK ) ; } if ( !oCanWrite(*o1) && !object_access_override(o1) ) return error_handler( INVALIDACCESS ) ; esize = theStackSize( executionstack) ; if ( theLen(*o1) <= esize ) return error_handler( RANGECHECK ) ; for ( realrun = 0 ; realrun <= 1 ; ++realrun ) { register OBJECT *olist = oArray(*o1) ; int32 glmode = oGlobalValue(*o1) ; int32 i, realcount = 0; /* shuts lint up */ Bool realtype = FALSE ; if ( realrun ) { /* Check if saved. */ if ( ! check_asave(olist, theLen(*o1), glmode, corecontext) ) return FALSE ; } /* Copy the elements of the execution stack into the array. */ for ( i = 0, olist += esize ; i <= esize ; ++i, --olist ) { register OBJECT *theo = stackindex( i , & executionstack ) ; if ( realtype ) { /* Check OBJECTS for illegal LOCAL --> GLOBAL */ if ( glmode ) if ( illegalLocalIntoGlobal(theo, corecontext) ) return error_handler( INVALIDACCESS ) ; if ( realrun ) { Copy( olist , theo ) ; } ++realcount ; if ( realcount == 4 ) realtype = FALSE ; } else { if ( realrun ) { theTags(*olist) = OOPERATOR | EXECUTABLE ; theLen(*olist) = 1 ; } switch ( oType(*theo) ) { case ONOTHING : if ( realrun ) { HQASSERT(theINameNumber(theIOpName(oOp(*theo))) >= 0 && theINameNumber(theIOpName(oOp(*theo))) < OPS_COUNTED , "execstack_ creating segv operator" ) ; oOp(*olist) = & system_ops[theINameNumber(theIOpName(oOp(*theo)))]; } break ; case OMARK : if ( realrun ) oOp(*olist) = & system_ops[NAME_stopped]; break ; case ONULL : switch ( theLen(*theo)) { case ISINTERPRETEREXIT : /* not the best of things to return, but what else? */ if ( realrun ) oOp(*olist) = & system_ops[NAME_exit]; break; case ISPATHFORALL : realcount = 0 ; realtype = TRUE ; if ( realrun ) oOp(*olist) = & system_ops[NAME_pathforall]; break ; case ISPROCEDURE : /* No executed effect - flush is the only NOP I can think of */ if ( realrun ) oOp(*olist) = & system_ops[NAME_flush] ; /* or yield */ break ; default: HQFAIL("Unknown ONULL variant found on execstack") ; } break ; default: /* Check OBJECTS for illegal LOCAL --> GLOBAL */ if ( glmode ) if ( illegalLocalIntoGlobal(theo, corecontext) ) return error_handler( INVALIDACCESS ) ; if ( realrun ) { Copy( olist , theo ) ; } break ; } } } } /* Set up a new sub-array. */ theLen(*o1) = CAST_SIGNED_TO_UINT16(esize + 1) ; return TRUE ; }
static Bool dothestop(ps_context_t *pscontext, Bool super) { execStackSizeNotChanged = FALSE ; while ( ! isEmpty( executionstack )) { register OBJECT *o1 = theTop(executionstack) ; int32 *tptr ; FILELIST *flptr ; switch ( oType(*o1) ) { case OMARK : /* Represents a stopped mark */ if ( ! super || theLen(*o1)) { mm_context_t *mmc = ps_core_context(pscontext)->mm_context; if ( theLen(*o1)) { allow_interrupt = FALSE; /* superstop disables interrupt */ clear_interrupts(); } /* Reset allocation cost after error handling. */ if ( mmc != NULL) /* this can run before MM init */ mm_set_allocation_cost(mmc, mm_cost_normal); pop( & executionstack ) ; return push( & tnewobj , & operandstack ) ; } pop( & executionstack ) ; break ; case ONULL : switch ( theLen(*o1)) { case ISINTERPRETEREXIT : /* indicate that we're in a stopped context by changing the object's value */ oInteger(*o1) = super ? NAME_superstop : NAME_stop ; return TRUE; case ISPATHFORALL : tptr = oOther(*o1) ; path_free_list(thePathOf(*(PATHFORALL *)tptr), mm_pool_temp) ; free_forallpath( tptr ) ; npop( 4 , & executionstack ) ; break ; } pop( & executionstack ) ; break ; case OFILE : /* Represents a run object - if length is special value */ currfileCache = NULL ; if ( IsRunFile ( o1 )) { flptr = oFile(*o1) ; if ( isIOpenFileFilter( o1 , flptr )) (void)(*theIMyCloseFile( flptr ))( flptr, CLOSE_EXPLICIT ) ; } pop( & executionstack ) ; break ; default: pop( & executionstack ) ; } } return quit_(pscontext) ; }
/* ---------------------------------------------------------------------------- function: filter_() author: Paul Attridge creation date: 26-Jun-1991 last modification: ##-###-#### arguments: none . description: See PostScript reference manual second edition page 416. ---------------------------------------------------------------------------- */ Bool filter_(ps_context_t *pscontext) { FILELIST *flptr ; OBJECT nameo = OBJECT_NOTVM_NOTHING ; OBJECT fileo = OBJECT_NOTVM_NOTHING ; uint8 *filter_name ; int32 name_length ; int32 find_error ; #if defined( ASSERT_BUILD ) int32 stack_size ; #endif UNUSED_PARAM(ps_context_t *, pscontext) ; if ( theStackSize( operandstack ) < 1 ) return error_handler( STACKUNDERFLOW ) ; Copy(&nameo, theTop(operandstack)) ; if ( oType(nameo) == ONAME ) { filter_name = theICList(oName(nameo)) ; name_length = theINLen(oName(nameo)) ; } else if ( oType(nameo) == OSTRING ) { /* undocumented - but they allow strings as an argument */ filter_name = oString(nameo) ; name_length = theLen(nameo) ; } else return error_handler( TYPECHECK ) ; /* find the filter name in the external or standard filter table */ flptr = filter_external_find(filter_name, name_length, &find_error, TRUE) ; if ( flptr == NULL ) { if ( find_error != NOT_AN_ERROR) return error_handler( find_error ); flptr = filter_standard_find(filter_name, name_length) ; if ( flptr == NULL ) return error_handler( UNDEFINED ) ; } /* sanity check */ HQASSERT(isIFilter(flptr), "Not a filter") ; /* Create our own copy of this filter - reusing a previous (dead) one if * possible; otherwise will actually alloc a new one. */ pop(&operandstack) ; /* Don't want name on stack during filter init */ #if defined( ASSERT_BUILD ) /* The init routine removes the arguments it needs, including the underlying source/target from the stack. Check that it actually did remove something. */ stack_size = theStackSize(operandstack) ; #endif if ( ! filter_create_object(flptr, &fileo, NULL, &operandstack) ) { (void)push(&nameo, &operandstack) ; /* Restore name for error reporting */ return FALSE ; } HQASSERT(theStackSize(operandstack) <= stack_size - 1, "Filter init routine should have removed underlying source/target") ; return push(&fileo, &operandstack) ; }
bool OrSpans::isPayloadAvailable() { SpansPtr theTop(top()); return (theTop && theTop->isPayloadAvailable()); }
/* ---------------------------------------------------------------------------- function: for_() author: Andrew Cave creation date: 22-Oct-1987 last modification: ##-###-#### arguments: none . description: See PostScript reference manual page 160. The manual does not define correct behaviour when increment is zero, so we emulate behaviour observed in (Level 2 and 3) Adobe RIPs, which is to finish without looping if initial < limit, and loop forever otherwise, pushing initial on each iteration. ---------------------------------------------------------------------------- */ Bool for_(ps_context_t *pscontext) { register int32 inc , current , ilimit ; register OBJECT *o1 , *o2 , *o3 , *o4 ; int32 loop ; SYSTEMVALUE args[ 3 ] ; UNUSED_PARAM(ps_context_t *, pscontext) ; if ( theStackSize( operandstack ) < 3 ) return error_handler( STACKUNDERFLOW ) ; o4 = theTop( operandstack ) ; o3 = ( & o4[ -1 ] ) ; o2 = ( & o4[ -2 ] ) ; o1 = ( & o4[ -3 ] ) ; if ( ! fastStackAccess( operandstack )) { o3 = stackindex( 1 , & operandstack ) ; o2 = stackindex( 2 , & operandstack ) ; o1 = stackindex( 3 , & operandstack ) ; } switch ( oType(*o4) ) { case OARRAY : case OPACKEDARRAY : break ; default: return error_handler( TYPECHECK ) ; } if ( ! oCanExec(*o4) && !object_access_override(o4) ) return error_handler( INVALIDACCESS ) ; if ( oType(*o1) == OINTEGER && oType(*o2) == OINTEGER && oType(*o3) == OINTEGER ) { current = oInteger(*o1) ; inc = oInteger(*o2) ; ilimit = oInteger(*o3) ; /* Tests indicate we should loop forever iff inc == 0 && current >= ilimit */ if (( inc > 0 ) ? ( current > ilimit ) : ( current < ilimit )) { npop( 4 , & operandstack ) ; return TRUE ; } if ( ! push4( o1, o2 , o3 , o4 , & executionstack )) return FALSE ; if ( ! xsetup_operator( NAME_xfastfori , 5 )) return FALSE ; if ( ! push( o4 , & executionstack )) return FALSE ; npop( 3 , & operandstack ) ; HQASSERT(oInteger(*o1) == current, "current changed mysteriously") ; return TRUE ; } /* Slow default case. */ if ( !object_get_numeric(o1, &args[0]) || !object_get_numeric(o2, &args[1]) || !object_get_numeric(o3, &args[2]) ) return FALSE ; if ( oType(*o1) == OINTEGER && oType(*o2) == OINTEGER && intrange(args[2])) { if ( ! push4( o1 , o2 , o3 , o4 , & executionstack )) return FALSE ; if ( ! xsetup_operator( NAME_xfori , 5 )) return FALSE ; } else { for ( loop = 0 ; loop < 3 ; ++loop ) if ( ! stack_push_real(args[loop], &executionstack) ) return FALSE ; if ( ! push( o4 , & executionstack )) return FALSE ; if ( ! xsetup_operator( NAME_xforr , 5 )) return FALSE ; } npop( 4 , & operandstack ) ; return TRUE ; }