/* Copyright (C) 1989, 1992 Aladdin Enterprises. All rights reserved.
Distributed by Free Software Foundation, Inc.
This file is part of Ghostscript.
Ghostscript is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY. No author or distributor accepts responsibility
to anyone for the consequences of using it or for whether it serves any
particular purpose or works at all, unless he says so in writing. Refer
to the Ghostscript General Public License for full details.
Everyone is granted permission to copy, modify and redistribute
Ghostscript, but only under the conditions described in the Ghostscript
General Public License. A copy of this license is supposed to have been
given to you along with Ghostscript so you can know your rights and
responsibilities. It should be in a file named COPYING. Among other
things, the copyright notice and this notice must be preserved on all
/* Initialize internally known objects for Ghostscript interpreter */
#define INCLUDE_ERROR_NAMES /* see errors.h */
#include "save.h" /* for alloc_refs */
/* Implementation parameters. */
/* The size of systemdict can be set in the makefile. */
# define SYSTEMDICT_SIZE 449 /* a nice prime (?) number */
#define systemdict_size SYSTEMDICT_SIZE
#define op_array_table_size 100 /* arbitrary */
/* Standard dictionaries */
/* The operator tables */
op_def_ptr
*op_def_table
;
ref op_array_table
; /* t_array, definitions of `operator' procedures */
ushort
*op_array_nx_table
; /* name indices for same */
/* Enter a name and value into systemdict */
initial_enter_name(const char *nstr
, ref
*pref
)
if ( dict_put(&systemdict
, &nref
, pref
) )
lprintf("dict_put failed!\n"),
/* Initialize objects other than operators */
/* Initialize the standard objects */
make_tv(&vmark
, t_mark
, intval
, 0);
make_tv(&vnull
, t_null
, intval
, 0);
/* Create the system dictionary */
dict_create(systemdict_size
, &systemdict
);
dstack
[1] = dstack
[0]; /* just during initialization */
/* Initialize the predefined names other than operators */
initial_enter_name("mark", &vmark
);
initial_enter_name("null", &vnull
);
/* Create other system-known names */
name_enter("errordict", &name_errordict
);
name_enter("ErrorNames", &name_ErrorNames
);
/* Create the error name table */
{ int n
= sizeof(gs_error_names
) / sizeof(char _ds
*) - 1;
make_tasv(&era
, t_array
, a_read
+ a_execute
, n
, refs
,
alloc_refs(n
, "obj_init(ErrorNames)"));
for ( i
= 0; i
< n
; i
++ )
name_enter((char *)gs_error_names
[i
], era
.value
.refs
+ i
);
dict_put(&systemdict
, &name_ErrorNames
, &era
);
/* Optional devices and .ps files are handled in gconfig.c. */
/* Initialize the operators */
#define oper_(defs) defs[],
/* Non-graphics operators */
zarith_op_defs
[], zarray_op_defs
[], zcontrol_op_defs
[],
zdict_op_defs
[], zfile_op_defs
[], zfileio_op_defs
[],
zfilter_op_defs
[], zgeneric_op_defs
[],
zmath_op_defs
[], zmisc_op_defs
[], zpacked_op_defs
[], zprops_op_defs
[],
zrelbit_op_defs
[], zstack_op_defs
[], zstring_op_defs
[],
ztype_op_defs
[], zvmem_op_defs
[],
zchar_op_defs
[], zcolor_op_defs
[], zdevice_op_defs
[],
zfont_op_defs
[], zfont1_op_defs
[], zfont2_op_defs
[],
zgstate_op_defs
[], zht_op_defs
[],
zmatrix_op_defs
[], zpaint_op_defs
[], zpath_op_defs
[],
#define oper_(defs) defs,
private op_def_ptr op_defs_all
[] = {
/* Non-graphics operators */
zarith_op_defs
, zarray_op_defs
, zcontrol_op_defs
,
zdict_op_defs
, zfile_op_defs
, zfileio_op_defs
,
zfilter_op_defs
, zgeneric_op_defs
,
zmath_op_defs
, zmisc_op_defs
, zpacked_op_defs
, zprops_op_defs
,
zrelbit_op_defs
, zstack_op_defs
, zstring_op_defs
,
ztype_op_defs
, zvmem_op_defs
,
zchar_op_defs
, zcolor_op_defs
, zdevice_op_defs
,
zfont_op_defs
, zfont1_op_defs
, zfont2_op_defs
,
zgstate_op_defs
, zht_op_defs
,
zmatrix_op_defs
, zpaint_op_defs
, zpath_op_defs
,
/* Run the initialization procedures of the individual operator files. */
for ( tptr
= op_defs_all
; *tptr
!= 0; tptr
++ )
{ for ( def
= *tptr
; def
->oname
!= 0; def
++ ) ;
((void (*)(P0()))(def
->proc
))();
/* Initialize the operator table. */
/* Do a first pass just to count the operators. */
for ( tptr
= op_defs_all
; *tptr
!= 0; tptr
++ )
for ( def
= *tptr
; def
->oname
!= 0; count
++, def
++ )
/* Do a second pass to construct the operator table, */
/* and enter the operators in systemdict. */
op_def_table
= (op_def_ptr
*)alloc(count
, sizeof(op_def_ptr
),
"op_init(op_def_table)");
for ( tptr
= op_defs_all
; *tptr
!= 0; tptr
++ )
for ( def
= *tptr
; (nstr
= def
->oname
) != 0; count
++, def
++ )
make_oper(&oper
, count
, (dummy_op_proc_p
)(def
->proc
));
interp_fix_op(&oper
); /* optimize if possible */
/* The first character of the name is a digit */
/* giving the minimum acceptable number of operands. */
/* For now, we just skip over it. */
/* Don't enter internal operators into systemdict. */
initial_enter_name(nstr
, &oper
);
op_def_table
[count
] = def
;
/* Allocate the table for `operator' procedures. */
alloc_refs(op_array_table_size
, "op_array table");
make_tasv(&op_array_table
, t_array
, a_read
+a_execute
,
op_array_table_size
, refs
, tbody
);
refset_null(tbody
, op_array_table_size
);
(ushort
*)alloc(op_array_table_size
, sizeof(ushort
),
/* Initialize variables that hold name constants. */
init_names(register const names_def _ds
*pnd
)
{ for ( ; pnd
->vname
!= 0; pnd
++ )
name_enter(pnd
->vname
, pnd
->pvref
);