conget_xsb_i.h

00001 /* File:      conget_xsb_i.h
00002 ** Author(s): ??
00003 ** Contact:   xsb-contact@cs.sunysb.edu
00004 ** 
00005 ** Copyright (C) The Research Foundation of SUNY, 1986, 1993-1999
00006 ** Copyright (C) ECRC, Germany, 1990
00007 ** 
00008 ** XSB is free software; you can redistribute it and/or modify it under the
00009 ** terms of the GNU Library General Public License as published by the Free
00010 ** Software Foundation; either version 2 of the License, or (at your option)
00011 ** any later version.
00012 ** 
00013 ** XSB is distributed in the hope that it will be useful, but WITHOUT ANY
00014 ** WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00015 ** FOR A PARTICULAR PURPOSE.  See the GNU Library General Public License for
00016 ** more details.
00017 ** 
00018 ** You should have received a copy of the GNU Library General Public License
00019 ** along with XSB; if not, write to the Free Software Foundation,
00020 ** Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00021 **
00022 ** $Id: conget_xsb_i.h,v 1.4 2005/07/18 21:54:08 crojo Exp $
00023 ** 
00024 */
00025 
00026 static inline Integer conget(Cell string)
00027 {
00028   int value;
00029   Psc psc, str_psc;
00030   Pair sym;
00031 
00032   if (!isstring(string))
00033     xsb_abort("[CONGET] Non-string in the first argument");
00034 
00035   psc = (Psc)flags[CURRENT_MODULE];
00036   sym = insert(string_val(string), 0, psc, &value);
00037   str_psc = pair_psc(sym);
00038 
00039   if (get_type(str_psc) == T_PRED || get_type(str_psc) == T_DYNA)
00040     xsb_abort("[conget] Cannot get data from predicate.\n");
00041 
00042   return (Integer)get_data(str_psc);
00043 }
00044 
00045 
00046 static inline xsbBool conset(Cell string, Integer newval)
00047 {
00048   int value;
00049   Psc psc, str_psc;
00050   Pair sym;
00051 
00052   if (!isstring(string))
00053     xsb_abort("[CONSET] Non-string in the first argument");
00054   psc = (Psc)flags[CURRENT_MODULE];
00055   sym = insert(string_val(string), 0, psc, &value);
00056   str_psc = pair_psc(sym);
00057 
00058   if (get_type(str_psc) == T_PRED || get_type(str_psc) == T_DYNA)
00059     xsb_abort("[conget] Cannot set data of predicate.\n");
00060 
00061   set_data(str_psc, (Psc) newval);
00062   return TRUE;
00063 }

Generated on Wed Jul 26 13:30:40 2006 for XSB by  doxygen 1.4.5