/*
 * Copyright (c) 2004, The Tendra Project <http://www.ten15.org/>
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice unmodified, this list of conditions, and the following
 *    disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 *
 *  		 Crown Copyright (c) 1997
 *
 *  This TenDRA(r) Computer Program is subject to Copyright
 *  owned by the United Kingdom Secretary of State for Defence
 *  acting through the Defence Evaluation and Research Agency
 *  (DERA).  It is made available to Recipients with a
 *  royalty-free licence for its use, reproduction, transfer
 *  to other parties and amendment for any purpose not excluding
 *  product development provided that any such use et cetera
 *  shall be deemed to be acceptance of the following conditions:-
 *
 *      (1) Its Recipients shall ensure that this Notice is
 *      reproduced upon any copies or amended versions of it;
 *
 *      (2) Any amended version of it shall be clearly marked to
 *      show both the nature of and the organisation responsible
 *      for the relevant amendment or amendments;
 *
 *      (3) Its onward transfer from a recipient to another
 *      party shall be deemed to be that party's acceptance of
 *      these conditions;
 *
 *      (4) DERA gives no warranty or assurance as to its
 *      quality or suitability for any purpose and DERA accepts
 *      no liability whatsoever in relation to any use to which
 *      it may be put.
 *
 * $TenDRA: tendra/src/utilities/calculus/cmd_ops.h,v 1.4 2005/01/29 17:20:28 stefanf Exp $
 */

/*
 *    AUTOMATICALLY GENERATED FROM ALGEBRA calculus (VERSION 1.2)
 *    BY calculus (VERSION 1.3)
 */

#ifndef CMD_OPS_H_INCLUDED
#define	CMD_OPS_H_INCLUDED

/* Operations for union COMMAND */

#define	TAG_cmd(P)				(CHECK_NULL (P)->ag_tag)


/* Operations for component line of union COMMAND */

#define	cmd_line(P)				(CHECK_NULL (P) + 1)


/* Operations for field simple of union COMMAND */

#define	cmd_simple_tag				0u
#define	IS_cmd_simple(P)				(CHECK_NULL (P)->ag_tag == 0)

#define	cmd_simple_text(P)				(CHECK_TAG ((P), 0) + 2)

#define MAKE_cmd_simple(line_, text_, calculus_cmd)\
	{\
		calculus *x186_ = GEN_calculus ( 3, TYPEID_cmd );\
		x186_->ag_tag = 0;\
		COPY_int (x186_ + 1, (line_));\
		COPY_string (x186_ + 2, (text_));\
		(calculus_cmd) = x186_;\
	}

#define	DECONS_cmd_simple(line_, text_, calculus_cmd)\
	{\
		calculus *x187_ = CHECK_TAG ((calculus_cmd), 0);\
		(line_) = DEREF_int (x187_ + 1);\
		(text_) = DEREF_string (x187_ + 2);\
	}

#define	DESTROY_cmd_simple(destroyer_, line_, text_, calculus_cmd)\
	{\
		calculus *x188_ = CHECK_TAG ((calculus_cmd), 0);\
		(line_) = DEREF_int (x188_ + 1);\
		(text_) = DEREF_string (x188_ + 2);\
		(destroyer_) (x188_, 3u);\
	}


/* Operations for field compound of union COMMAND */

#define	cmd_compound_tag				1u
#define	IS_cmd_compound(P)				(CHECK_NULL (P)->ag_tag == 1)

#define	cmd_compound_seq(P)				(CHECK_TAG ((P), 1) + 2)

#define MAKE_cmd_compound(line_, seq_, calculus_cmd)\
	{\
		calculus *x189_ = GEN_calculus ( 3, TYPEID_cmd );\
		x189_->ag_tag = 1;\
		COPY_int (x189_ + 1, (line_));\
		COPY_list (x189_ + 2, (seq_));\
		(calculus_cmd) = x189_;\
	}

#define	DECONS_cmd_compound(line_, seq_, calculus_cmd)\
	{\
		calculus *x190_ = CHECK_TAG ((calculus_cmd), 1);\
		(line_) = DEREF_int (x190_ + 1);\
		(seq_) = DEREF_list (x190_ + 2);\
	}

#define	DESTROY_cmd_compound(destroyer_, line_, seq_, calculus_cmd)\
	{\
		calculus *x191_ = CHECK_TAG ((calculus_cmd), 1);\
		(line_) = DEREF_int (x191_ + 1);\
		(seq_) = DEREF_list (x191_ + 2);\
		(destroyer_) (x191_, 3u);\
	}


/* Operations for field loop of union COMMAND */

#define	cmd_loop_tag				2u
#define	IS_cmd_loop(P)				(CHECK_NULL (P)->ag_tag == 2)

#define	cmd_loop_control(P)				(CHECK_TAG ((P), 2) + 2)
#define	cmd_loop_body(P)				(CHECK_TAG ((P), 2) + 3)

#define MAKE_cmd_loop(line_, control_, body_, calculus_cmd)\
	{\
		calculus *x192_ = GEN_calculus ( 4, TYPEID_cmd );\
		x192_->ag_tag = 2;\
		COPY_int (x192_ + 1, (line_));\
		COPY_string (x192_ + 2, (control_));\
		COPY_cmd (x192_ + 3, (body_));\
		(calculus_cmd) = x192_;\
	}

#define	DECONS_cmd_loop(line_, control_, body_, calculus_cmd)\
	{\
		calculus *x193_ = CHECK_TAG ((calculus_cmd), 2);\
		(line_) = DEREF_int (x193_ + 1);\
		(control_) = DEREF_string (x193_ + 2);\
		(body_) = DEREF_cmd (x193_ + 3);\
	}

#define	DESTROY_cmd_loop(destroyer_, line_, control_, body_, calculus_cmd)\
	{\
		calculus *x194_ = CHECK_TAG ((calculus_cmd), 2);\
		(line_) = DEREF_int (x194_ + 1);\
		(control_) = DEREF_string (x194_ + 2);\
		(body_) = DEREF_cmd (x194_ + 3);\
		(destroyer_) (x194_, 4u);\
	}


/* Operations for field cond of union COMMAND */

#define	cmd_cond_tag				3u
#define	IS_cmd_cond(P)				(CHECK_NULL (P)->ag_tag == 3)

#define	cmd_cond_control(P)				(CHECK_TAG ((P), 3) + 2)
#define	cmd_cond_true_code(P)				(CHECK_TAG ((P), 3) + 3)
#define	cmd_cond_false_code(P)				(CHECK_TAG ((P), 3) + 4)

#define MAKE_cmd_cond(line_, control_, true_code_, false_code_, calculus_cmd)\
	{\
		calculus *x195_ = GEN_calculus ( 5, TYPEID_cmd );\
		x195_->ag_tag = 3;\
		COPY_int (x195_ + 1, (line_));\
		COPY_string (x195_ + 2, (control_));\
		COPY_cmd (x195_ + 3, (true_code_));\
		COPY_cmd (x195_ + 4, (false_code_));\
		(calculus_cmd) = x195_;\
	}

#define	DECONS_cmd_cond(line_, control_, true_code_, false_code_, calculus_cmd)\
	{\
		calculus *x196_ = CHECK_TAG ((calculus_cmd), 3);\
		(line_) = DEREF_int (x196_ + 1);\
		(control_) = DEREF_string (x196_ + 2);\
		(true_code_) = DEREF_cmd (x196_ + 3);\
		(false_code_) = DEREF_cmd (x196_ + 4);\
	}

#define	DESTROY_cmd_cond(destroyer_, line_, control_, true_code_, false_code_, calculus_cmd)\
	{\
		calculus *x197_ = CHECK_TAG ((calculus_cmd), 3);\
		(line_) = DEREF_int (x197_ + 1);\
		(control_) = DEREF_string (x197_ + 2);\
		(true_code_) = DEREF_cmd (x197_ + 3);\
		(false_code_) = DEREF_cmd (x197_ + 4);\
		(destroyer_) (x197_, 5u);\
	}


#endif
