/* $Id: Symbol,v 1.10 2009/01/04 15:32:25 kiesling Exp $ -*-c-*-*/

/*
  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 library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 2 of the License, or (at your option) any later version.

  This library 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
  Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public
  License along with this library; if not, write to the Free Software
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
*/

/*
 *    Symbol class.
 */

Object class Symbol;

/*
 *  As long as Symbol class only handles memory locations,
 *  this implementation should be sufficient.  However,
 *  the library should talk care that a generic pointer
 *  in the argument's value is formatted correctly as a
 *  hexadecimal number.
 */

Symbol instanceMethod = set_value (void *v) {
  OBJECT *rcvr_val, *arg_val;
  rcvr_val = self value;
  arg_val = v value;

  strcpy (rcvr_val -> __o_value, arg_val -> __o_value);

  return self;
}

/*
 *  Create a new String here so Symbol class doesn't (so far) 
 *  need to duplicate the Character and String methods.  
 *  If we call within an argument, then finding Object : name, 
 *  the VM will still push the parent Symbol object and cause 
 *  a stack walkback to look for a Character/String/Magnitude 
 *  method.
 *
 *  This is only a little more abstracted than a Key : getName
 *  method anyway.
 *
 */
Symbol instanceMethod name (void) {
  OBJECT *rcvr_val;
  returnObjectClass String;
  rcvr_val = self value;
  if (rcvr_val -> __o_p_obj) {
    methodReturnString (rcvr_val -> __o_p_obj -> __o_name);
  } else {
    methodReturnString (__ctalk_self_internal () -> __o_name);
  }
}
