/* $Id: message.h,v 1.5 2009/02/27 15:19:50 kiesling Exp $ */

/*
  This file is part of Ctalk.
  Copyright © 2005-2009 Robert Kiesling, ctalk@ctalklang.org.
  Permission is granted to copy this software provided that this copyright
  notice is included in all source code modules.

  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software Foundation, 
  Inc., 51 Franklin St., Fifth Floor, Boston, MA 02110-1301 USA.
*/

#ifndef _MESSAGE_H
#define _MESSAGE_H

/*
 *  Attributes for messages.
 */

#define OBJ_IS_INSTANCE_VAR       (1 << 0)
#define VALUE_OBJ_IS_INSTANCE_VAR (1 << 1)
#define OBJ_IS_CLASS_VAR          (1 << 2)
#define VALUE_OBJ_IS_CLASS_VAR    (1 << 3)
#define METHOD_PROTOTYPE_MESSAGE  (1 << 4)
#define CVAR_AGGREGATE_TOK        (1 << 5)
#define TOK_OBJ_IS_CREATED_PARAM  (1 << 6)
#define TOK_VALUE_OBJ_IS_RECEIVER (1 << 7)
#define TOK_VALUE_OBJ_IS_SUPERCLASS (1 << 8)
#define TOK_IS_METHOD_ARG         (1 << 9)
#define TOK_IS_TYPECAST_EXPR      (1 << 10)

/*
 *  When changing this, also change in ctalklib, ctldjgpp, and object.h. 
 */
#define GNUC_PACKED_STRUCT (defined(__linux__) && defined(__i386__) && \
			    defined(__GNUC__) && (__GNUC__ >= 3))

/* When changing this definition, ensure that copy_message ()
   is still valid. */

typedef struct _message MESSAGE;

struct _message {
  int sig;
  char *name;
  char *value;
  OBJECT *value_obj;
  OBJECT *obj;
  int tokentype; 
  int evaled;
  int output;
  int error_line;
  int error_column;
  int attrs;
  OBJECT *receiver_obj;
  struct _message *receiver_msg;
  char pad[12];
#if GNUC_PACKED_STRUCT
} __attribute__ ((packed));
#else
};
#endif
/* } MESSAGE; */

#define M_OBJ_IS_VAR(m) (((m) -> attrs & OBJ_IS_INSTANCE_VAR) || \
   ((m) -> attrs & OBJ_IS_CLASS_VAR))
#define M_VALUE_OBJ_IS_VAR(m) (((m) -> attrs & VALUE_OBJ_IS_INSTANCE_VAR) || \
   ((m) -> attrs & VALUE_OBJ_IS_CLASS_VAR))
#define M_VALUE_OBJ_IS_SUPERCLASS(m) ((m) -> attrs & TOK_VALUE_OBJ_IS_SUPERCLASS)

#endif   /* _MESSAGE_H */


