163
163
code = num_params(oppath, 2, uxy);
164
164
if (code >= 0) { /* Aperture is a single pixel. */
168
gs_transform(igs, uxy[0], uxy[1], &dxy);
169
fr.p.x = fixed_floor(float2fixed(dxy.x));
170
fr.p.y = fixed_floor(float2fixed(dxy.y));
171
fr.q.x = fr.p.x + fixed_1;
172
fr.q.y = fr.p.y + fixed_1;
173
code = gx_clip_to_rectangle(igs, &fr);
168
gs_transform(igs, uxy[0], uxy[1], &dxy);
169
fr.p.x = fixed_floor(float2fixed(dxy.x));
170
fr.p.y = fixed_floor(float2fixed(dxy.y));
171
fr.q.x = fr.p.x + fixed_1;
172
fr.q.y = fr.p.y + fixed_1;
173
code = gx_clip_to_rectangle(igs, &fr);
175
175
} else if (code == e_stackunderflow) {
176
/* If 0 elements, definitely a stackunderflow; otherwise, */
177
/* only 1 number, also a stackunderflow. */
176
/* If 0 elements, definitely a stackunderflow; otherwise, */
177
/* only 1 number, also a stackunderflow. */
179
179
} else { /* Aperture is a user path. */
180
/* We have to set the clipping path without disturbing */
181
/* the current path. */
182
gx_path *ipath = igs->path;
180
/* We have to set the clipping path without disturbing */
181
/* the current path. */
182
gx_path *ipath = igs->path;
185
gx_path_init_local(&save, imemory);
186
gx_path_assign_preserve(&save, ipath);
188
code = upath_append(oppath, i_ctx_p, false);
190
code = gx_clip_to_path(igs);
191
gx_path_assign_free(igs->path, &save);
185
gx_path_init_local(&save, imemory);
186
gx_path_assign_preserve(&save, ipath);
188
code = upath_append(oppath, i_ctx_p, false);
190
code = gx_clip_to_path(igs);
191
gx_path_assign_free(igs->path, &save);
198
198
/* Install the hit detection device. */
199
199
gx_set_device_color_1(igs);
200
200
gx_device_init((gx_device *) phdev, (const gx_device *)&gs_hit_device,
202
202
phdev->width = phdev->height = max_int;
203
203
gx_device_fill_in_procs(phdev);
204
204
gx_set_device_only(igs, phdev);
537
536
make_real_new(next + 3, bbox.q.y);
539
538
if ((code = name_enter_string(pgs->memory, "setbbox", next)) < 0)
541
540
r_set_attrs(next, a_executable | l_new);
546
/* Patch the path in the gstate to set up the enumerator. */
547
gx_path *save_path = pgs->path;
550
gs_path_enum_copy_init(&penum, pgs, false);
551
pgs->path = save_path;
552
while ((op = gs_path_enum_next(&penum, pts)) != 0) {
561
ml:make_real_new(next, pts[0].x);
562
make_real_new(next + 1, pts[0].y);
567
make_real_new(next, pts[0].x);
568
make_real_new(next + 1, pts[0].y);
569
make_real_new(next + 2, pts[1].x);
570
make_real_new(next + 3, pts[1].y);
571
make_real_new(next + 4, pts[2].x);
572
make_real_new(next + 5, pts[2].y);
575
case gs_pe_closepath:
579
return_error(e_unregistered);
581
if ((code = name_enter_string(pgs->memory, opstr, next)) < 0)
583
r_set_attrs(next, a_executable);
545
/* Patch the path in the gstate to set up the enumerator. */
546
gx_path *save_path = pgs->path;
549
gs_path_enum_copy_init(&penum, pgs, false);
550
pgs->path = save_path;
551
while ((op = gs_path_enum_next(&penum, pts)) != 0) {
560
ml:make_real_new(next, pts[0].x);
561
make_real_new(next + 1, pts[0].y);
566
make_real_new(next, pts[0].x);
567
make_real_new(next + 1, pts[0].y);
568
make_real_new(next + 2, pts[1].x);
569
make_real_new(next + 3, pts[1].y);
570
make_real_new(next + 4, pts[2].x);
571
make_real_new(next + 5, pts[2].y);
574
case gs_pe_closepath:
578
return_error(e_unregistered);
580
if ((code = name_enter_string(pgs->memory, opstr, next)) < 0)
582
r_set_attrs(next, a_executable);
592
590
zgetpath(i_ctx_t *i_ctx_p)
675
673
if (r_has_type(oppath, t__invalid))
676
return_error(e_stackunderflow);
674
return_error(e_stackunderflow);
677
675
if (!r_is_array(oppath))
678
return_error(e_typecheck);
676
return_error(e_typecheck);
679
677
check_read(*oppath);
681
679
/****** ROUND tx AND ty ******/
683
681
if ( r_size(oppath) == 2 &&
684
array_get(imemory, oppath, 1, &opcodes) >= 0 &&
682
array_get(imemory, oppath, 1, &opcodes) >= 0 &&
685
683
r_has_type(&opcodes, t_string)
686
) { /* 1st element is operands, 2nd is operators */
684
) { /* 1st element is operands, 2nd is operators */
693
691
array_get(imemory, oppath, 0, &operands);
694
692
code = num_array_format(&operands);
699
opp = opcodes.value.bytes;
700
ocount = r_size(&opcodes);
704
if (opx > UPATH_REPEAT)
705
repcount = opx - UPATH_REPEAT;
706
else if (opx > UPATH_MAX_OP)
707
return_error(e_rangecheck);
708
else { /* operator */
709
const up_data_t data = up_data[opx];
711
*pnargs = 0; /* in case of error */
712
if (upath_compat && opx == upath_op_ucache) {
713
/* CPSI does not complain about incorrect ucache
714
placement, even though PLRM3 says it's illegal. */
715
ups = ups > UPS_UCACHE ? ups : data.state_after;
717
if (!(ups & data.states_before))
718
return_error(e_typecheck);
719
ups = data.state_after;
723
byte opargs = data.num_args;
727
(*pnargs)++; /* in case of error */
728
code = num_array_get(imemory, &operands, format, i++, op);
731
r_set_type_attrs(op, t_integer, 0);
734
r_set_type_attrs(op, t_real, 0);
737
return_error(e_typecheck);
740
code = (*up_ops[opx])(i_ctx_p);
697
opp = opcodes.value.bytes;
698
ocount = r_size(&opcodes);
702
if (opx > UPATH_REPEAT)
703
repcount = opx - UPATH_REPEAT;
704
else if (opx > UPATH_MAX_OP)
705
return_error(e_rangecheck);
706
else { /* operator */
707
const up_data_t data = up_data[opx];
709
*pnargs = 0; /* in case of error */
710
if (upath_compat && opx == upath_op_ucache) {
711
/* CPSI does not complain about incorrect ucache
712
placement, even though PLRM3 says it's illegal. */
713
ups = ups > UPS_UCACHE ? ups : data.state_after;
715
if (!(ups & data.states_before))
716
return_error(e_typecheck);
717
ups = data.state_after;
721
byte opargs = data.num_args;
725
(*pnargs)++; /* in case of error */
726
code = num_array_get(imemory, &operands, format, i++, op);
729
r_set_type_attrs(op, t_integer, 0);
732
r_set_type_attrs(op, t_real, 0);
735
return_error(e_typecheck);
738
code = (*up_ops[opx])(i_ctx_p);
748
746
} else { /* Ordinary executable array. */
749
const ref *arp = oppath;
750
uint ocount = r_size(oppath);
756
for (; index < ocount; index++) {
763
array_get(imemory, arp, index, &rup);
764
switch (r_type(&rup)) {
772
if (!r_has_attr(&rup, a_executable) ||
773
dict_find(systemdict, &rup, &defp) <= 0 ||
774
r_btype(defp) != t_operator)
775
return_error(e_typecheck); /* all errors = typecheck */
779
xop:if (!r_has_attr(defp, a_executable))
780
return_error(e_typecheck);
781
oproc = real_opproc(defp);
782
for (opx = 0; opx <= UPATH_MAX_OP; opx++)
783
if (oproc == up_ops[opx])
785
if (opx > UPATH_MAX_OP)
786
return_error(e_typecheck);
788
if (argcount != data.num_args)
789
return_error(e_typecheck);
790
if (upath_compat && opx == upath_op_ucache) {
791
/* CPSI does not complain about incorrect ucache
792
placement, even though PLRM3 says it's illegal. */
793
ups = ups > UPS_UCACHE ? ups : data.state_after;
795
if (!(ups & data.states_before))
796
return_error(e_typecheck);
797
ups = data.state_after;
799
code = (*up_ops[opx])(i_ctx_p);
801
if (code == e_nocurrentpoint)
747
const ref *arp = oppath;
748
uint ocount = r_size(oppath);
754
for (; index < ocount; index++) {
761
array_get(imemory, arp, index, &rup);
762
switch (r_type(&rup)) {
770
if (!r_has_attr(&rup, a_executable) ||
771
dict_find(systemdict, &rup, &defp) <= 0 ||
772
r_btype(defp) != t_operator)
773
return_error(e_typecheck); /* all errors = typecheck */
777
xop:if (!r_has_attr(defp, a_executable))
778
return_error(e_typecheck);
779
oproc = real_opproc(defp);
780
for (opx = 0; opx <= UPATH_MAX_OP; opx++)
781
if (oproc == up_ops[opx])
783
if (opx > UPATH_MAX_OP)
784
return_error(e_typecheck);
786
if (argcount != data.num_args)
787
return_error(e_typecheck);
788
if (upath_compat && opx == upath_op_ucache) {
789
/* CPSI does not complain about incorrect ucache
790
placement, even though PLRM3 says it's illegal. */
791
ups = ups > UPS_UCACHE ? ups : data.state_after;
793
if (!(ups & data.states_before))
794
return_error(e_typecheck);
795
ups = data.state_after;
797
code = (*up_ops[opx])(i_ctx_p);
799
if (code == e_nocurrentpoint)
802
800
return_error(e_rangecheck); /* CET 11-22 */
808
return_error(e_typecheck);
813
return_error(e_typecheck); /* leftover args */
806
return_error(e_typecheck);
811
return_error(e_typecheck); /* leftover args */
816
814
if (ups < UPS_SETBBOX)
817
return_error(e_typecheck); /* no setbbox */
815
return_error(e_typecheck); /* no setbbox */
818
816
if (ups == UPS_SETBBOX && upath_compat) {
820
* In CPSI compatibility mode, an empty path with a setbbox also
821
* does a moveto (but only if the path is empty). Since setbbox
822
* was the last operator, its operands are still on the o-stack.
825
return zmoveto(i_ctx_p);
818
* In CPSI compatibility mode, an empty path with a setbbox also
819
* does a moveto (but only if the path is empty). Since setbbox
820
* was the last operator, its operands are still on the o-stack.
823
return zmoveto(i_ctx_p);