// Copyright (C) 1996 DIMACS Center, Rutgers, The State University of New Jersey
// Author(s): Jonathan Berry
// This software is copyrighted by the DIMACS Center at Rutgers, The State
// University of New Jersey.  IT IS PROVIDED AS IS, AND THE AUTHORS, DIMACS, AND
// RUTGERS, THE STATE UNIVERSITY OF NEW JERSEY  DISCLAIM
// ALL LIABILITY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
// DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY
// DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.  THIS SOFTWARE
// IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE
// NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
// MODIFICATIONS.
// The authors hereby grant permission to use, copy, modify, distribute,
// and license this software and its documentation for any purpose, provided
// that existing copyright notices are retained in all copies and that this
// notice is included verbatim in any distributions. No written agreement,
// license, or royalty fee is required for any of the authorized uses.
// Modifications to this software may be copyrighted by their authors
// and need not follow the licensing terms described here, provided that
// the new terms are clearly indicated on the first page of each file where
// they apply.
// Last File Update: 7-Aug-1997
// 
#ifndef LINK_STK_H
#define LINK_STK_H
#include <stk.h>
#include <LINK/basic/general.h>
class Graph;
class GraphObject;
extern "C" {
PRIMITIVE STk_slot_ref(SCM, SCM);
PRIMITIVE STk_slot_set(SCM, SCM, SCM);
#define INSTANCEP(x) TYPEP(x, tc_instance)
};
#define STRING(s)    ((String) ((s)->storage_as.string.data))
#define SYMBOL(s)    ((String) ((s)->storage_as.symbol.pname))
#define VAL(x) STk_slot_ref(x, val_scm)
#define CXXWRAPPERP(x)	TYPEP(x,tc_CXXwrapper)
#define NCXXWRAPPERP(x)	NTYPEP(x,tc_CXXwrapper)
#define CXXw_TYPEP(x, t)  (TYPEP(x, tc_CXXwrapper) && (EXTID(x) == t))
#define CXXw_NTYPEP(x, t) (!CXXw_TYPEP(x,t))
#define CXX_TYPEP(x, t)(INSTANCEP(x) && \
		        TYPEP(VAL(x), tc_CXXwrapper) && \
			(EXTID(VAL(x)) == t))
#define CXX_NTYPEP(x, t) (!CXX_TYPEP(x,t))
#define CLASSDATA(x) (EXTDATA(VAL(x)))
//#define CLASSDATA(x) ((*(VAL(x))).storage_as.extension.data)
#define LINK_DYNAMIC		0
#define LINK_STATIC		1
#define LINK_OVL		1
#define LINK_NEW		0
#define OUTPUT_IS_LIST		1
extern int tc_CXXwrapper;
extern SCM val_scm;
extern Tcl_HashTable listTable;
SCM STk_make_CXXwrapper(int, char *, void *, int);
int STk_new_CXXwrapper_id(char *, char *,
			  void (*)(SCM x, SCM port, int mode),
                          void (*)(SCM x),
                          void (*)(SCM x));
void STk_add_new_cpp_primitive(char *fct_name, int fct_type, 
			struct obj * (*fct_ptr)(...));
PRIMITIVE my_copy_tree(SCM l);
PRIMITIVE my_examine_tree(SCM l);
void      my_STk_release_cell(SCM l);
void 	  initListTable();
void 	  deleteListTable();
PRIMITIVE STk_init_CXXwrapper(void);
PRIMITIVE MakeIntCmd(SCM num);	// given STk INTEGER, return a wrapped C++ int
void STk_gc_unprotect(SCM location);
void defineNewMethod(char *);
void addZeroArgMethod(char *, char *, int);
void addOneArgMethod(char *, char *, char *, int);
void addTwoArgMethod(char *, char *, char *, char *, int);
void addThreeArgMethod(char *, char *, char *, char *, char *, int);
void addFourArgMethod(char *, char *, char *, char *, char *, char*, int);
void addArbMethod(char *, char *, char *, int);
void addListMethod(char *, char *, int ov);
void addIntListMethod(char *, char *, char *, int ov);
void addBooleanMethod(char *, char *, char *, int);
char* 		getName(SCM);
GraphObject* 	getGraphObject(SCM);
Graph* 		getGraph(SCM);
SCM             wrapGraph(Graph *);  // defined in graph_Graph_Methods.cpp
#endif
