[script] Add repeat operator.

Simple operator to repeat procedure n times.
This commit is contained in:
Chris Wilson 2008-12-10 12:26:09 +00:00
parent 738cb32745
commit 5dfaa22a57

View file

@ -3420,6 +3420,41 @@ _rel_move_to (csi_t *ctx)
return CSI_STATUS_SUCCESS;
}
static csi_status_t
_repeat (csi_t *ctx)
{
csi_array_t *proc;
csi_integer_t count;
csi_status_t status;
check (2);
status = _csi_ostack_get_procedure (ctx, 0, &proc);
if (_csi_unlikely (status))
return status;
status = _csi_ostack_get_integer (ctx, 1, &count);
if (_csi_unlikely (status))
return status;
if (_csi_unlikely (count < 0))
return _csi_error (CSI_STATUS_INVALID_SCRIPT);
proc->base.ref++;
pop (2);
while (count--) {
status = _csi_array_execute (ctx, proc);
if (_csi_unlikely (status))
break;
}
if (--proc->base.ref == 0)
csi_array_free (ctx, proc);
return status;
}
static csi_status_t
_reset_clip (csi_t *ctx)
{
@ -5489,7 +5524,7 @@ _defs[] = {
{ "radial", _radial },
{ "rand", NULL },
{ "rectangle", _rectangle },
{ "repeat", NULL },
{ "repeat", _repeat },
{ "restore", _restore },
{ "rel_curve_to", _rel_curve_to },
{ "rel_line_to", _rel_line_to },