/* This symbol must always be defined when compiling for Motif.  This is to
 * ensure that the correct set of Xt header files are used (ie those in
 * /usr/include/Xm rather than the X11 Release 4 ones in /usr/include/X11).
 * All the R4 Xt headers check for this symbol; if it is defined, they give
 * an error.
 */

#ifndef _MOTIF_XT
#define _MOTIF_XT
#endif


#ifdef REV_INFO
#ifndef lint
static char SCCSID[] = "OSF/Motif: @(#)UilSymDef.h	2.2 90/01/09";
#endif /* lint */
#endif /* REV_INFO */

/******************************************************************************
*******************************************************************************
*
*  (c) Copyright 1989, 1990, OPEN SOFTWARE FOUNDATION, INC.
*  (c) Copyright 1989, DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS.
*  ALL RIGHTS RESERVED
*  
*  	THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY BE USED
*  AND COPIED ONLY IN ACCORDANCE WITH THE TERMS OF SUCH LICENSE AND
*  WITH THE INCLUSION OF THE ABOVE COPYRIGHT NOTICE.  THIS SOFTWARE OR
*  ANY OTHER COPIES THEREOF MAY NOT BE PROVIDED OR OTHERWISE MADE
*  AVAILABLE TO ANY OTHER PERSON.  NO TITLE TO AND OWNERSHIP OF THE
*  SOFTWARE IS HEREBY TRANSFERRED.
*  
*  	THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE WITHOUT
*  NOTICE AND SHOULD NOT BE CONSTRUED AS A COMMITMENT BY OPEN SOFTWARE
*  FOUNDATION, INC. OR ITS THIRD PARTY SUPPLIERS  
*  
*  	OPEN SOFTWARE FOUNDATION, INC. AND ITS THIRD PARTY SUPPLIERS,
*  ASSUME NO RESPONSIBILITY FOR THE USE OR INABILITY TO USE ANY OF ITS
*  SOFTWARE .   OSF SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
*  KIND, AND OSF EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES, INCLUDING
*  BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
*  FITNESS FOR A PARTICULAR PURPOSE.
*  
*  Notice:  Notwithstanding any other lease or license that may pertain to,
*  or accompany the delivery of, this computer software, the rights of the
*  Government regarding its use, reproduction and disclosure are as set
*  forth in Section 52.227-19 of the FARS Computer Software-Restricted
*  Rights clause.
*  
*  (c) Copyright 1989, 1990, Open Software Foundation, Inc.  Unpublished - all
*  rights reserved under the Copyright laws of the United States.
*  
*  RESTRICTED RIGHTS NOTICE:  Use, duplication, or disclosure by the
*  Government is subject to the restrictions as set forth in subparagraph
*  (c)(1)(ii) of the Rights in Technical Data and Computer Software clause
*  at DFARS 52.227-7013.
*  
*  Open Software Foundation, Inc.
*  11 Cambridge Center
*  Cambridge, MA   02142
*  (617)621-8700
*  
*  RESTRICTED RIGHTS LEGEND:  This computer software is submitted with
*  "restricted rights."  Use, duplication or disclosure is subject to the
*  restrictions as set forth in NASA FAR SUP 18-52.227-79 (April 1985)
*  "Commercial Computer Software- Restricted Rights (April 1985)."  Open
*  Software Foundation, Inc., 11 Cambridge Center, Cambridge, MA  02142.  If
*  the contract contains the Clause at 18-52.227-74 "Rights in Data General"
*  then the "Alternate III" clause applies.
*  
*  (c) Copyright 1989, 1990, Open Software Foundation, Inc.
*  ALL RIGHTS RESERVED 
*  
*  
* Open Software Foundation is a trademark of The Open Software Foundation, Inc.
* OSF is a trademark of Open Software Foundation, Inc.
* OSF/Motif is a trademark of Open Software Foundation, Inc.
* Motif is a trademark of Open Software Foundation, Inc.
* DEC is a registered trademark of Digital Equipment Corporation
* DIGITAL is a registered trademark of Digital Equipment Corporation
* X Window System is a trademark of the Massachusetts Institute of Technology
*
*******************************************************************************
******************************************************************************/

/*
**++
**  FACILITY:
**
**      User Interface Language Compiler (UIL)
**
**  ABSTRACT:
**
**      This include file defines the interface to the UIL symbol table.
**
**--
**/

#ifndef UilSymDef_h
#define UilSymDef_h

/*
**
**  INCLUDE FILES
**
**/


/*
**  Hash table size
*/

#define sym_k_hash_table_limit	127

/* 
**  Symbol tags.  These values are used in the tag field of every object header
**  to identify the type of the entry.
*/

#define sym_k_error_entry		(127)
    /*	An error entry is used when compilation errors are detected in the  */
    /*	source program.  Its use reduces cascading errors caused by missing */
    /*	information and allows the compilation to continue and thus	    */
    /*	additional errors may be detected				    */
#define sym_k_value_entry		1
    /*	A value entry contains information about a UIL literal value	    */
    /*	(integer, string, compound string, xbitmapfile, argument, color,    */
    /*	icon, etc.).  The b_type field is used to determine the datatype of */
    /*	this value.							    */
#define sym_k_name_entry		2
    /*	A name entry corresponds to a name (identifier) used in the UIL	    */
    /*	source.								    */
#define sym_k_widget_entry		3
    /*	A widget entry represents a widget declaration.  It points off to   */
    /*	the arguments, callbacks, and controls lists for the widget.	    */
#define sym_k_control_entry		4
    /*	A control entry hangs off a list entry and identifes an object	    */
    /*	(widget or gadget) that is controlled.  It also contains the	    */
    /*	managed/unmanaged information.					    */
#define sym_k_forward_ref_entry		5
    /*	forward reference entries are a linked listed of objects	    */
    /*	(widgets/gadgets) that were not defined at the time of the	    */
    /*	reference.  After all objects have been seen, then this list is	    */
    /*	traversed and all objects in it should now be defined and the	    */
    /*	specified pointers can be filled-in.				    */
#define sym_k_external_def_entry	6
    /*	An external definition entry identifies a name that has been	    */
    /*	imported and thus in not declared within this source module.	    */
#define sym_k_argument_entry		7
    /*	An argument entry hangs off a list entry and identifies an object   */
    /*	argument.  It contains informtation about the argument name and	    */
    /*	argument value.							    */
#define sym_k_callback_entry		8
    /*	An calllback entry hangs off a list entry and identifies an object  */
    /*	callback.  It contains informtation about the callback name,	    */
    /*	callback procedure, and callback tag.				    */
#define sym_k_module_entry		9
    /*	A module entry contains information specified on the module	    */
    /*	statement.							    */
#define sym_k_proc_def_entry		10
    /*	A procedure definition entry is created for each procedure listed   */
    /*	in a procedure section.  I contains informaion on the number and    */
    /*	types of the arguments.						    */
#define sym_k_proc_ref_entry		11
    /*	A procedure reference entry contains information about a the use of */
    /*	a procedure (e.g. as a callback).  It also stores the tag to be	    */
    /*	passed to the procedure.					    */
#define sym_k_list_entry		12
    /*	A list entry is a typed list of other symbol table entries. It	    */
    /*	contains a count and a pointer to the next entry on the list via    */
    /*	the obj_header.az_next field.					    */
#define sym_k_free_entry		13
    /*	Free entries are only used when the symbol table is allocated in    */
    /*	large pages (when the symbol BUFFER_ALLOCATION is TRUE).  They	    */
    /*	should never occur when using the UIL callable interface.	    */
#define sym_k_identifier_entry		14
    /*	identifier entry tag is used for diagnostic messages only	    */
#define sym_k_color_item_entry		15
    /*	entry describing a color.					    */
#define sym_k_gadget_entry		16
    /*	A gadget entry represents a gadget declaration.  It points off to   */
    /*	the arguments, callbacks, and controls lists for the gadget. Since  */
    /*	the structures for widget and gadgets are the same, the		    */
    /*	datastructure for gadgets is really a sym_k_widget_entry_type.	    */
#define sym_k_root_entry		17
    /*	An entry used to group all the other entries together.  It is	    */
    /*	returned in the parse_tree_root field of the compilation descriptor */
    /*	when using the callable interface.				    */
#define sym_k_parent_list_entry		18
    /*	This is a list of parents of a widget.  It is used to check for	    */
    /*	constraints provided by the parent that may be used on this widget. */
#define sym_k_nested_list_entry		19
    /*  This entry occurs as a list entry for a nested list. It occupies    */
    /*  the correct position in the list for the reference to a list, and   */
    /*  points to the actual list entry.                                    */
#define sym_k_include_file_entry	20
    /*	An include file entry is used to describe the contents of an	    */
    /*	include file.  It is needed only maintain information about the	    */
    /*	source file from which this parse tree was generated.  It is not    */
    /*	used by UIL directly.						    */
#define sym_k_section_entry		21
    /*	A section entry is used to describe the contents of an source file. */
    /*	It is needed only maintain information about the structure of	    */
    /*	source file from which this parse tree was generated.  It is not    */
    /*	used by UIL directly.						    */
    /*									    */
#define sym_k_def_obj_entry		22
    /*	This entry corresponds to the default object clause on the module   */
    /*	declaration it is used to store source information about the file   */
    /*	from which this parse tree was generated.   It is not used by UIL   */
    /*	directly.							    */
#define sym_k_comment_entry		23
    /*	A comment entry is used only to store source information about the  */
    /*	file that generated this parse tree.  It is not used by UIL	    */
    /*	directly.							    */
#define sym_k_val_forward_ref_entry		24
    /*	val forward reference entries are a linked listed of values	    */
    /*	that were not defined at the time of the			    */
    /*	reference.  After all values have been seen, then this list is	    */
    /*	traversed and all values in it should now be defined and the	    */
    /*	specified pointers can be filled-in.				    */
#define sym_k_max_entry			24
    /*	this is the largest possible value for an entry constant.	    */


/*
**    Common attribute masks -- These values are used in the b_flags field of
**    the object_header.
*/

#define		sym_m_private		(1 << 0)
    /*	This item is private to this source module and thus need not be	    */
    /*	output into the UID file.					    */
#define		sym_m_exported		(1 << 1)
    /*	This is an exported definition and must be put in the UID file.	    */
#define		sym_m_imported		(1 << 2)
    /*	This item is a reference external to this source module and thus    */
    /*	will be resolved at runtime by searching the resourec hierarchy.    */
#define		sym_m_reference		(1 << 3)
#define		sym_m_builtin		(1 << 4)
    /*	This item is builtin as oppose to a userdefined item.		    */
#define		sym_m_obj_is_gadget	(1 << 5)
    /*	This object is a gadget as oppose to a widget.			    */


/*
**	Output states - order is important
*/

#define		sym_k_not_processed	0
#define		sym_k_queued		1
#define		sym_k_emitted		2



/* 
**  Header for each symbol entry
*/

typedef struct _sym_entry_header_type
{
    char                b_tag;
	/* type of entry The values of this field ia a sym_k_XXX_entry as   */
	/* defined above.						    */
    char		b_type;
	/*  generic subtype field usage depends on value of b_tag field	    */
	/*  above (sym_k_value_entry -> b_type is a sym_k_XXX_value as	    */
	/*  defined in UilSymGen.h, sym_k_list_entry -> b_type is a	    */
	/*  sym_k_XXX_list as defined below, sym_k_widget_entry -> b_type   */
	/*  is a sym_k_XXX_object as defined in UilSymGen.h,		    */
	/*  sym_k_section_entry -> b_type is a sym_k_XXX_section as defined */
	/*  below).							    */
	/*								    */
    unsigned short	w_node_size;
	/*  size of the node in longwords				    */
    int			user_data;
	/* not used directly by the compiler.  It is for use by		    */
	/* applications making use of callable UIL only.		    */

    /*
    ** Fields to save source information about the symbol:  We currently save
    ** five things.  The source record where the symbol "begins" (begins is in
    ** quotes because this may point to just white space before the actual
    ** symbol), the position (character) within that record where the symbol
    ** begins, the source record where the symbol ends, the position within
    ** that record that symbol really begins (i.e. no white space or anything),
    ** and the position where the symbol definition ends.
    */

    struct _src_source_record_type  *az_begin_rec;
	/* Source record where symbol starts				    */
    struct _src_source_record_type  *az_end_rec;
	/* Source record where symbol ends				    */
    unsigned char	b_begin_pos;
	/* Starting position within the start record			    */
    unsigned char	b_src_pos;
	/* Starting position within the end record			    */
    unsigned char	b_end_pos;
	/* Ending position within the end record			    */
    unsigned char	b_modified;
	/* This node has been modified					    */
    unsigned char	b_child_mod;
	/* A child of this node has been modified			    */


    /*
    **	The following two field create a linked list of all entries in the UIL
    **	symbol table.  This chain of entries hangs off the sym_root_entry_type.
    */
    struct _sym_entry_header_type    *next_entry;
    struct _sym_entry_header_type    *prev_entry;

} sym_entry_header_type;



/*
**  Common view of a symbol entry
*/

typedef struct  
{
    sym_entry_header_type   header;
	/* common part of all symbol entries.				    */
    char                    b_value[ 1 ];
	/* information specific to each different entry type.		    */
} sym_entry_type;



/*
**  Free entry, when an entry is on the free node list.
*/

typedef struct _sym_free_entry_type
{
    sym_entry_header_type	header;
	/* common header						    */
    sym_entry_type 		* az_next;
	/* next free entry						    */
} sym_free_entry_type;

#define sym_k_free_entry_size (sizeof(sym_free_entry_type))



/*
**  Name entry 
*/

/*	Flags for name entries						    */

#define		sym_m_referenced 	(1 << 0)
       /* Used in the b_flags field of a name entry.  Set if this name is   */
       /* reference elsewhere in this UIL source module.		    */
       
typedef struct _sym_name_entry_type
{
    sym_entry_header_type	header;
	/* common header						    */
    sym_entry_type 		*az_object;
	/* pointer to the object entry with this name			    */
    struct _sym_name_entry_type	*az_next_name_entry;
	/* next name on hash chain					    */
    struct _sym_name_entry_type *az_prev_name_entry;
	/* prev name on hash chain					    */
    unsigned char		b_flags;
	/* flags (possible value is sym_m_referenced as declared above)	    */
    char			c_text[ 1 ];
	/* text of the name						    */
} sym_name_entry_type;

/*
**  Size of the fixed part of a name entry
*/

#define sym_k_name_entry_size (sizeof( sym_name_entry_type)- \
			       sizeof( char[ 1 ]) )


/*
**  Value entry 
*/

/*
**  Types of values are included in UilSymGen.h
*/

/*
**  Charsets supported by UIL -- These values are used in the b_charset field
**  of the a value_entry.  The values match codes in dec std 169.
*/

#define sym_k_charset_dec_mcs		0
#define sym_k_charset_iso_latin1	1
#define sym_k_charset_iso_latin2	2
#define sym_k_charset_iso_arabic	3
#define sym_k_charset_iso_greek		4
#define sym_k_charset_dec_hebrew	5
#define sym_k_charset_iso_hebrew	6
#define sym_k_charset_jis_katakana	32
#define sym_k_charset_dec_tech		33
#define sym_k_charset_dec_kanji		64
#define sym_k_charset_dec_hanzi		65
#define sym_k_userdefined_charset	127
       /*  If a value entry (string or compound string) has this value then */
       /*  the the charset information is stored in the value entry pointed */
       /*  to by the az_charset_value field of the value_entry.		    */
#define sym_k_default_charset		sym_k_charset_iso_latin1



/*
**  This structure defines an element in a color table.  A color table contains
**  an array of such elements.
*/

typedef struct	
{
    unsigned char	b_letter;
	/* letter for this color					    */
    unsigned char	b_index;
	/* index for this color						    */
    unsigned short	w_desc_offset;
	/* descriptor offset at in context				    */
    struct _sym_value_entry_type    *az_color;
	/* pointer to the value entry for this color			    */

} sym_color_element;


/*
**  This structure defines the data for an icon.
*/

typedef struct	
{
    unsigned short	w_height;
	/* height in pixels of the icon					    */
    unsigned short	w_width;
	/* width in pixels of the icon					    */
    struct _sym_value_entry_type    *az_color_table;
	/* pointer to the value entry for the color table		    */
    struct _sym_value_entry_type    *az_rows;
	/* pointer to the list of icon rows				    */

} sym_icon_element;


/*
**	Auxiliary sym_k_flags for values stored in b_aux_flags field
*/

#define		sym_m_table_entry	(1 << 0)
    /* This item is a component of table				    */
#define		sym_m_right_to_left	(1 << 1)
    /* right to left character string					    */
#define		sym_m_separate		(1 << 2)
    /* add CDA separator to end of string				    */
#define		sym_m_sixteen_bit	sym_m_separate
    /* character set is 16-bit						    */
#define		sym_m_exp_eval		(1 << 3)
    /* if set, indicates that expression has already been evaluated	    */

/*
**	Types of colors - stored in b_arg_type
*/

#define	sym_k_unspecified_color	0
#define	sym_k_background_color	1
       /* This color should displayed in the background on a monochrome	    */
       /* display.							    */
#define	sym_k_foreground_color	2
       /* This color should displayed in the foreground on a monochrome	    */
       /* display.							    */

/*
**	value sets defining expression operators
*/
#define sym_k_unspecified_op	0
#define sym_k_not_op		1 
#define sym_k_unary_plus_op	2
#define sym_k_unary_minus_op	3
#define sym_k_float_op		4
#define sym_k_integer_op	5
#define sym_k_last_unary_op	5

#define sym_k_multiply_op	6
#define sym_k_divide_op		7
#define sym_k_add_op		8
#define sym_k_subtract_op	9
#define sym_k_left_shift_op	10
#define sym_k_right_shift_op	11
#define sym_k_and_op		12
#define sym_k_xor_op		13
#define sym_k_or_op		14
#define sym_k_cat_op		15
#define sym_k_last_binary_op	15
#define sym_k_assign_op		16	/* az_exp_op1 points to the value node
					   whose value is assigned to this
					   value node. */
#define sym_k_coerce_op		17	/* az_exp_op1 points to the value node
					   whose value is to be coerced to the
					   data type of this node. */
#define sym_k_last_special_op	17


typedef struct _sym_value_entry_type
{
    sym_entry_header_type   header;
	/* common header						    */
    unsigned char	    b_type;
	/* b_type distinguishes usage.  Possible values are sym_k_XXX_value */
	/* as defined in UilSymGen.h					    */
    unsigned short	    b_flags;
	/* b_flags holds private and immediate information		    */
    unsigned short          w_length;
	/* length for variable length types				    */
    char		    output_state;
	/* output_state (only byte is needed)				    */
    unsigned char	    b_table_count;
	/* number of strings in table, colors in a color table, or fonts in */
	/* a font table.						    */
    unsigned char	    b_aux_flags;
	/* auxiliary flags						    */
    unsigned char	    b_arg_type;
	/* type of argument value or monochrome treatment of a color	    */
    unsigned char	    b_data_offset;
	/* offset of bits in context for an icon			    */
    unsigned char	    b_pixel_type;
	/* pixel size encoding of an icon				    */
    unsigned char	    b_charset;
	/* character set of a string					    */
    unsigned char	    b_max_index;
	/* max index in a color table					    */
    unsigned char	    b_expr_opr;
	/* operator for an expression value node			    */
    unsigned int	    l_circular_ref_chk;
	/* field to mark when checking for circular references		    */
    unsigned char	    b_enum_name;
	/* names enumeration set for an enumeration value		    */

    long int    	resource_id;
	/* resource id for private values.				    */
    sym_name_entry_type	    *az_name;
	/* pointer to the name entry for the value.			    */

/* Union for different kinds of nodes pointing to other value nodes	    */
    union _sym_value_entry_subvalues
	{
	struct
	    {
	    struct _sym_value_entry_type    * az_charset_value;
	        /* pointer to value entry describing a userdefined charset. */
	        /* Valid only when b_charset == sym_k_userdefined_charset   */
	    struct _sym_value_entry_type    * az_next_table_value;
	        /* next element for tables.				    */
	    struct _sym_value_entry_type    *az_first_table_value;
	        /* pointer to first table entry (font, string, etc.) if     */
	        /* value is a table.					    */
	    } tables;
	struct
	    {
	    struct _sym_value_entry_type	* az_exp_op1;
	    struct _sym_value_entry_type	* az_exp_op2;
	        /* pointer to the one or two value operands of an	    */
	        /* expression value node. Special operands have an          */
	        /* explicitly state semantic.                               */
	    } expops;
	} subvalues;

/* Union for the actual value of a value node				    */
    union _sym_value_entry_value_union
    {
      	int             l_integer;
	    /* value if an integer. Also used for evaluated compound        */
	    /* strings. No compound string declaration is provided, so that */
	    /* inclusion of toolkit .h files can be avoided.                */
        double		d_real;
	    /* value if a double float.					    */
	char		c_value[ 1 ];
	    /* value of string.						    */
	sym_color_element	z_color[ 1 ];	
	    /* value if color table.					    */
	sym_icon_element	z_icon;
	    /* value if icon						    */
    } value;
} sym_value_entry_type;


/*
**  Define the fixed size of the value entry structure
*/   

#define sym_k_value_entry_size (sizeof(sym_value_entry_type) - \
				sizeof(union _sym_value_entry_value_union) )



/*
**  Comment entry
*/

typedef struct _sym_comment_entry_type
{
    sym_entry_header_type	header;
	/* common entry header.						    */
    char			c_text[ 1 ];
	/* text of the comment.						    */
} sym_comment_entry_type;


/*
**  Size of the fixed part of a comment entry
*/

#define sym_k_comment_entry_size (sizeof( sym_comment_entry_type)- \
			       sizeof( char[ 1 ]) )



/* 
**  Common header for each "object" entry.  This header is shared by all
**  widget, gadget, list, argument, callback, and control node types.  It
**  always appears immediately following the standard entry header field.  Also
**  defined here is a prototype node for these types of "object" entries.
*/

typedef struct
{
    sym_name_entry_type		* az_name;
	/* pointer to the name entry that holds the object name.	    */
    sym_entry_type		* az_reference;
	/* pointer to the entry that references this object.		    */
    sym_entry_type		* az_next;
	/* pointer to next entry in a list, if this entry is linked under a */
	/* list entry.							    */
    sym_comment_entry_type	* az_comment;
	/* pointer to comment entry associated with this object.	    */
    sym_entry_type		* az_back;
	/* back pointer to "parent" of this object object		    */
    unsigned short		b_flags;
	/* object flags.						    */
    unsigned char		v_filler [2];
	/* longword alignment						    */
} sym_obj_header_type;

typedef struct
{
    sym_entry_header_type	header;
	/* common entry header						    */
    sym_obj_header_type		obj_header;
	/* common object header						    */
} sym_obj_entry_type;



/*
**  List entry
*/

/*
**  The types of lists, values for the header.b_type field of a list entry.
*/

#define 	sym_k_error_list		sym_k_error_entry
#define 	sym_k_callback_list		sym_k_callback_entry
#define 	sym_k_argument_list		sym_k_argument_entry
#define 	sym_k_control_list		sym_k_control_entry
#define		sym_k_proc_ref_list		sym_k_proc_ref_entry

typedef struct _sym_list_entry_type
{
    sym_entry_header_type   header;
	/* common header						    */
    sym_obj_header_type     obj_header;
	/* common header for objects					    */
    unsigned short	    w_count;
	/* number of elements in the list.				    */
    unsigned short	    w_gadget_count;
	/* number of gadgets in the list.				    */
} sym_list_entry_type;

/*
**  Define the size of the list structure
*/   

#define sym_k_list_entry_size (sizeof(sym_list_entry_type))



/*
**  Nested List entry
*/

/*
**  A nested list entry appears in a list as the entry specifying a reference
**  to another list (a nested list reference). It has its b_type field set
**  to the list type (necessarily the same type as the list it is contained
**  in, and the list it points to). The az_next field locates the next list
**  element, as usual. The az_list field points to the list entry for the
**  list which is referenced.
*/

typedef struct _sym_nested_list_entry_type
{
    sym_entry_header_type   header;
	/* common header						    */
    sym_obj_header_type     obj_header;
	/* common header for objects					    */
    sym_list_entry_type	    *az_list;
	/* pointer to the referenced list                                   */
} sym_nested_list_entry_type;

/*
**  Define the size of the nested_list structure
*/   

#define sym_k_nested_list_entry_size (sizeof(sym_nested_list_entry_type))



/*
**  Argument entry
*/

typedef struct _sym_argument_entry_type
{
    sym_entry_header_type	header;
	/* common entry header						    */
    sym_obj_header_type		obj_header;
	/* common object header						    */
    sym_value_entry_type	* az_arg_name;
	/* pointer to the value entry containing the argument name.	    */
    sym_value_entry_type	* az_arg_value;
	/* pointer to the value entry containing the argument value.	    */
} sym_argument_entry_type;

#define sym_k_argument_entry_size (sizeof(sym_argument_entry_type))


/*
**  Procedure Definition Entry
*/

typedef struct
{
    sym_entry_header_type	header;
	/* common header.						    */
    sym_name_entry_type		*az_name;
	/* pointer to the name entry of the procedure.			    */
    unsigned char		v_arg_checking;
	/* should argument type be checked.				    */
    unsigned char		b_arg_count;
	/* number of arguments.						    */
    unsigned char		b_arg_type;
	/* The type of single argument (tag) for this procedure.  It should */
	/* be a sym_k_XXX_value as defined in UilSymGen.h.		    */
    unsigned char		b_flags;
	/* class of procedure (only private is supported for now).	    */
} sym_proc_def_entry_type;

#define sym_k_proc_def_entry_size (sizeof( sym_proc_def_entry_type))


/*
**  Procedure Reference Entry
*/

typedef struct
{
    sym_entry_header_type	header;
	/* common header.						    */
    sym_obj_header_type		obj_header;
	/* common object header.					    */
    sym_proc_def_entry_type	*az_proc_def;
	/* pointer to the procedure definition entry for the procedure to   */
	/* be called.							    */
    sym_value_entry_type	*az_arg_value;
	/* pointer to the value entry for the argument to be passed as the  */
	/* callback tag to the procedure.				    */
} sym_proc_ref_entry_type;

#define sym_k_proc_ref_entry_size (sizeof( sym_proc_ref_entry_type))


/*
**  These values are passed from the grammar to the semantic action routines
**  (SAR) to identify how the procedure is used.
*/
#define sym_k_callback_proc	1
    /*	The procedure was used as a callback routine.			    */
#define sym_k_object_proc	2
    /*	The procedure was used as a creation routine for a user defined	    */
    /*	widget,								    */


/*
**  Callback entry
*/

typedef struct _sym_callback_entry_type
{
    sym_entry_header_type	header;
	/* common entry header.						    */
    sym_obj_header_type		obj_header;
	/* common object header.					    */
    sym_value_entry_type	* az_call_reason_name;
	/* pointer to the value entry containing the reason (callback) name */
    sym_proc_ref_entry_type	* az_call_proc_ref;
	/* pointer to the procedure reference to be invoked for this	    */
	/* callback reason.						    */
    sym_list_entry_type		* az_call_proc_ref_list;
	/* list entry of procedure references when multiple callbacks are   */
	/* used for the callback.					    */
} sym_callback_entry_type;

#define sym_k_callback_entry_size (sizeof(sym_callback_entry_type))


/*
**  Parent list for widgets and gadgets
**
**  This list contains pointers to each of the widgets and gadgets that
**  reference the current widget in their control list.  This information is
**  required in order to check constraint arguments.
*/

typedef struct _sym_parent_list_type
{
    sym_entry_header_type           header;
	/* common entry header						    */
    struct _sym_widget_entry_type   * parent;
	/* pointer to a widget entry that references the originating widget */
	/* in its controls list.					    */
    struct _sym_parent_list_type    * next;
	/* pointer to next parent list entry.				    */
} sym_parent_list_type;

#define sym_k_parent_list_size (sizeof(sym_parent_list_type))



/*
**  Widget entry and Gadget entry
**
**	Gadgets have the same form as a widget.  They are distinguished
**	simply by the setting of sym_m_obj_is_gadget in obj_header.b_flags .
*/

/*    Include the literal definitions for widgets.			    */

#include "UilSymGen.h"


/*    widget and gadget node structure.					    */

typedef struct _sym_widget_entry_type
{
    sym_entry_header_type	header;
	/* common entry header						    */
    sym_obj_header_type		obj_header;
	/* common object header						    */
    sym_list_entry_type		* az_callbacks;
	/* pointer to a list entry of type sym_k_callback_list which	    */
	/* contains the callbacks for this widget.			    */
    sym_list_entry_type		* az_arguments;
	/* pointer to a list entry of type sym_k_argument_list which	    */
	/* contains the arguments for this widget.			    */
    sym_list_entry_type		* az_controls;
	/* pointer to a list entry of type sym_k_controls_list which	    */
	/* contains the widgets that are children (are controlled by) this  */
	/* widget.							    */
    sym_proc_ref_entry_type	* az_create_proc;
	/* for user_defined widgets this points to the procedure reference  */
	/* entry that specifies the creation routine for the widget.	    */
    sym_parent_list_type	* parent_list;
	/* pointer to a parent list entry that links all objects which	    */
	/* reference this object in there controls lists.  It is used to    */
	/* traverse through the parents to verify that all contraint	    */
	/* arguments specified on this widget are really inherited from one */
	/* of its parents.						    */
    int				output_state;
	/* Used when generating the UID file.  Possible values:		    */
	/* sym_k_queued, sym_k_emitted, sym_k_not_processed. (only a byte   */
	/* is needed).							    */
    long int			resource_id;
	/* The resource id if the object is private.  This is used when	    */
	/* generating the UID file.					    */
} sym_widget_entry_type;

#define sym_k_widget_entry_size (sizeof(sym_widget_entry_type))



/*
**  Control entry
*/

/*
**  Control flags -- These are additional values that may occur in the b_flags
**  field for control entries. NOTE: Must not overlap common flags defined
**  above.
*/	

#define	sym_m_def_in_progress	(1 << 6)
    /*	used in all lists.						    */
#define	sym_m_managed		(1 << 7)
    /*	This bit is set when the controlled object is to be managed.	    */
#define sym_m_obj_is_reference  (1 << 8)
#define sym_m_forward_ref	(1 << 9)
    /*  This bit is set if the item is a forward reference not yet resolved*/



/*    Control node structure.						    */

typedef struct _sym_control_entry_type
{
    sym_entry_header_type	header;
	/* common entry header						    */
    sym_obj_header_type		obj_header;
	/* common object header						    */
    sym_widget_entry_type	* az_con_obj;
	/* pointer to the widget entry that is controlled by this widget.   */
} sym_control_entry_type;

#define sym_k_control_entry_size (sizeof(sym_control_entry_type))



/*
**  External Definition Entry
*/

typedef struct _sym_external_def_entry_type
{
    sym_entry_header_type	header;	
	/* common header						    */
    struct _sym_external_def_entry_type	*az_next_object;
	/* pointer next external definition entry.			    */
    sym_name_entry_type		*az_name;
	/* pointer to the name entry for the external object.		    */
} sym_external_def_entry_type;

#define sym_k_external_def_entry_size (sizeof( sym_external_def_entry_type))


/*
**  Forward Reference Entry
*/

typedef struct _sym_forward_ref_entry_type
{
    sym_entry_header_type	header;
	/* common header.  The b_type field holds the object type.	    */
    struct _sym_forward_ref_entry_type	*az_next_ref;
	/* pointer to the next forward reference entry.			    */
    char			*a_update_location;
	/* address of the longword field in the referencing entry that	    */
	/* needs to be updated with the address of the widget entry that    */
	/* this forward reference entry was created for.  When this forward */
	/* reference entry is processed in UilP2Reslv.c, then the widget    */
	/* named in the az_name field will be defined and it can be	    */
	/* assigned directly into the a_update_location.		    */
    sym_name_entry_type		*az_name;
	/* pointer to the name entry for the widget being referenced before */
	/* it has been defined.						    */
    sym_widget_entry_type	*parent;
	/* pointer to the widget entry of the parent of the forward	    */
	/* referenced object.						    */
} sym_forward_ref_entry_type;

#define sym_k_forward_ref_entry_size (sizeof( sym_forward_ref_entry_type))


/*
**  Forward Reference Entry
*/

#define sym_k_patch_add		1
#define sym_k_bind_value_name	2

typedef struct _sym_val_forward_ref_entry_type
{
    sym_entry_header_type	header;
	/* common header.  The b_type field holds the expected value type.  */
    struct _sym_val_forward_ref_entry_type	*az_next_ref;
	/* pointer to the next forward reference entry.			    */
    char			*a_update_location;
	/* address of the longword field in the referencing entry that	    */
	/* needs to be updated with the address of the value entry that     */
	/* this forward reference entry was created for.  When this forward */
	/* reference entry is processed in UilP2Reslv.c, then the value     */
	/* named in the az_name field will be defined and it can be	    */
	/* assigned directly into the a_update_location.		    */
    sym_name_entry_type		*az_name;
	/* pointer to the name entry for the value being referenced before  */
	/* it has been defined.						    */
    unsigned char		fwd_ref_flags;
	/* flags used to indicate how to process entry on forward reference */
	/* chain.							    */
} sym_val_forward_ref_entry_type;

#define sym_k_val_forward_ref_entry_size (sizeof( sym_val_forward_ref_entry_type))


/*
**  Default object entry.  Pointed to from the module entry.  The first one in
**  the list contains source information for the "OBJECTS = " text.  The 'next'
**  field is a pointer to a list which contains the data on the actual clauses.
*/

typedef struct _sym_def_obj_entry_type
{
    sym_entry_header_type	header;
	/* common header						    */
    struct _sym_def_obj_entry_type  *next;
	/* pointer to next default object entry in the list.		    */
    char			b_object_info;
    char			b_variant_info;
} sym_def_obj_entry_type;

#define sym_k_def_obj_entry_size (sizeof( sym_def_obj_entry_type))



/*
**  Module entry (only 1 per compilation)
*/

typedef struct _sym_module_entry_type
{
    sym_entry_header_type	header;
	/* common header						    */
    sym_name_entry_type 	*az_name;
	/* pointer to the name entry containing the module name.	    */
    sym_value_entry_type 	*az_version;
	/* pointer to the value entry containing version string for the	    */
	/* module (version clause).					    */
    sym_value_entry_type	*az_character_set;
	/* pointer to the value entry containing the default character set  */
	/* information for the module (character set clause).		    */
    sym_value_entry_type	*az_case_sense;
	/* pointer to the value entry containing the value of the module    */
	/* case sensitivity clause.					    */
    sym_def_obj_entry_type	*az_def_obj;
	/* pointer to the default object type specified in the module	    */
	/* default object variant clause.				    */
} sym_module_entry_type;

#define sym_k_module_entry_size (sizeof( sym_module_entry_type))


/*
**	Section entry
*/

/*
** Posiblilities for header.b_type when header.b_tag is sym_k_section_entry.
*/

#define sym_k_list_section	1
	/* list section							    */
#define sym_k_procedure_section	2
	/* procedure section						    */
#define sym_k_value_section	3
	/* value section						    */
#define sym_k_identifier_section 4
	/* identifier section						    */
#define sym_k_object_section	5
	/* widget/gadget section					    */
#define sym_k_include_section	6
	/* include directive						    */
#define sym_k_section_tail	7
	/* This section has no corresponding UIL construct and exists only  */
	/* to aid in saving source information				    */



typedef struct _sym_section_entry_type
{
    sym_entry_header_type	header;
	/* common header						    */
    struct _sym_section_entry_type *prev_section;
	/* previous section "LIST".					    */
    sym_entry_type		*next;
	/* pointer to the entry for the next section _OR_ next child.	    */
    sym_entry_type		*entries;
	/* points to entries in the section _OR_ the entry in the symbol    */
	/* table for this child.					    */
} sym_section_entry_type;

#define sym_k_section_entry_size (sizeof (sym_section_entry_type))


/*
**  Include file entry
*/

typedef struct _sym_include_file_entry_type
{
    sym_entry_header_type	header;
	/* common header						    */
    sym_section_entry_type	*sections;
	/* pointer to a section list; this list is all of the sections that */
	/* exist in this include file.					    */
    char			file_name[255];
	/* the file name as specified in the include statement in the UIL   */
	/* source.							    */
    char			full_file_name[255];
	/* the expanded name for the include file actually opened.	    */
} sym_include_file_entry_type;

#define sym_k_include_file_entry_size (sizeof( sym_include_file_entry_type))


/*
**  Symbol table root entry (root of symbol table tree)
*/

typedef struct _sym_root_entry_type
{
    sym_entry_header_type	header;
	/* common header						    */
    struct _src_source_record_type	*src_record_list;
	/* pointer to a list of source records.				    */
    char			file_name[255];
	/* the main UIL file name as specified on the command line.	    */
    char			full_file_name[255];
	/* the expanded name for the main UIL file that was actually	    */
	/* opened.							    */
    sym_section_entry_type	*sections;
	/* pointer to section list entry.				    */
    sym_module_entry_type	*module_hdr;
	/* pointer to module header entry.				    */
    sym_entry_header_type	module_tail;
	/* pointer to a header entry that contains source information for   */
	/* the remainder of the module (module tail).			    */
    sym_entry_type		*az_entry_list_header;
	/* this is the root pointer to a doubly linked list which contains  */
	/* all entries in the symbol table.				    */
    
} sym_root_entry_type;

#define sym_k_root_entry_size (sizeof( sym_root_entry_type))


/*
**  Color Item Entry
*/

typedef struct _sym_color_item_entry_type
{
    sym_entry_header_type	header;
	/* common header						    */
    struct _sym_color_item_entry_type	*az_next;
	/* next item							    */
    unsigned char		b_letter;
	/* letter used for color					    */
    unsigned char		b_index;
	/* color table index						    */
    unsigned char		b_spare1;
    sym_value_entry_type	*az_color;
	/* name or value entry for the color.				    */
	
} sym_color_item_entry_type;

#define sym_k_color_item_entry_size (sizeof( sym_color_item_entry_type))






sym_name_entry_type	*sym_insert_name();
sym_name_entry_type	*sym_find_name();
void			sym_make_external_def();

/*
**  _sym_allocate_entry
**
**	If BUFFER_ALLOCATION is defined, then allocation is done in large
**	blocks and we divide it up as needed.  Otherwise we use XtMalloc so
**	that each allocation is individually freeable.
*/

#ifdef BUFFER_ALLOCATION
#define _sym_allocate_entry( __tag, __size, __ptr )			\
    {									\
	int			__long_size;				\
	sym_entry_type		*__entry_ptr, **__entry_ptr_ptr;	\
	external char		*sym_al_next_avail_location;		\
	external char 		*sym_al_last_location;			\
									\
	__long_size = ((__size) + 3) >> 2;				\
	__entry_ptr = (sym_entry_type *) sym_al_next_avail_location;	\
	sym_al_next_avail_location += __long_size << 2;			\
	if (sym_al_next_avail_location > sym_al_last_location)		\
	    __entry_ptr = sym_allocate_buffer( __long_size );		\
									\
	__entry_ptr->header.b_tag = (__tag);				\
	__entry_ptr->header.w_node_size = __long_size;			\
	__entry_ptr_ptr = (sym_entry_type * *) & (__ptr);		\
	(* __entry_ptr_ptr) = __entry_ptr;				\
    }

#else

#define _sym_allocate_entry( __tag, __size, __ptr )			\
    {									\
	sym_entry_type		*__entry_ptr, **__entry_ptr_ptr;	\
	external sym_entry_type	*sym_az_entry_list_header;		\
	__entry_ptr = (sym_entry_type *)XtCalloc(1,__size); 		\
	__entry_ptr->header.b_tag = (__tag);				\
	__entry_ptr->header.w_node_size = (__size); 			\
	__entry_ptr_ptr = (sym_entry_type * *) & (__ptr);		\
	(* __entry_ptr_ptr) = __entry_ptr;				\
									\
	if (sym_az_entry_list_header != NULL) {				\
 	    sym_az_entry_list_header->header.prev_entry =		\
		(sym_entry_header_type *)__entry_ptr;			\
	    }								\
									\
 	__entry_ptr->header.next_entry =				\
	    (sym_entry_header_type *)sym_az_entry_list_header;		\
 	__entry_ptr->header.prev_entry = NULL;				\
	sym_az_entry_list_header = __entry_ptr;				\
    }
#endif

/*
**  This macro copies the contents of one entry to another without disturbing
**  the the linked list of entries used to connect all symbol table entries.
*/
#define _sym_copy_entry(__dest, __src, __size)				\
    {									\
    sym_entry_type *__dest_entry = (sym_entry_type *)(__dest);		\
    void *__save_next = __dest_entry->header.next_entry;	        \
    void *__save_prev = __dest_entry->header.prev_entry;	        \
    _move (__dest, __src, __size);					\
    __dest_entry->header.next_entry = __save_next;			\
    __dest_entry->header.prev_entry = __save_prev;			\
    }



    sym_entry_type	*sym_allocate_buffer();

#endif /* UilSymDef_h */
/* DON'T ADD STUFF AFTER THIS #endif */
