/* $Id: Key,v 1.1.1.1 2008/11/28 17:57:26 kiesling Exp $ -*-c-*-*/

/*
  This file is part of ctalk.
  Copyright  2005 - 2008  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 Key;

Key instanceMethod setName (char *__keyNameString) {
  OBJECT *self_object;

  self_object = __ctalk_self_internal ();

  strcpy (self_object -> __o_name, __ctalk_to_c_char_ptr(ARG(0)));
  methodReturnSelf
}

Key instanceMethod setValue (OBJECT *__valueObject) {
  OBJECT *arg_object, *arg_copy;
  OBJECT *self_value_object;
  self_value_object = self value;
  arg_object = __valueObject;
  __ctalkCopyObject (OBJREF(arg_object), OBJREF(arg_copy));
   
  __objRefCntSet(OBJREF(arg_copy), self_value_object -> nrefs);
  sprintf (self_value_object->__o_value, "%#x", (unsigned int)arg_copy);
  methodReturnSelf
}

#define FMT_0XHEX(__p) "0x%p",(__p)
Key instanceMethod getValue (void) {
  OBJECT *self_object, *value_object;
  returnObjectClass Any;
  self_object = __ctalk_self_internal ();
  sscanf (self_object->instancevars->__o_value, 
	  FMT_0XHEX(&value_object));
  __objRefCntSet (OBJREF(value_object), self_object -> nrefs);
  return value_object;
}

Key instanceMethod = setEqual (OBJECT *__valueObject) {
  OBJECT *self_object, *arg_object;
  self_object = __ctalk_self_internal ();
  sprintf (self_object->instancevars->__o_value, "%#x", 
	   (unsigned int)__valueObject);
  arg_object = ARG(0);
  __objRefCntInc(OBJREF(arg_object));
  methodReturnSelf
}

Key instanceMethod getKeyObject (void) {
  methodReturnSelf
}
