1 /* -*-C-*- 2 3 Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 4 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 5 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Massachusetts 6 Institute of Technology 7 8 This file is part of MIT/GNU Scheme. 9 10 MIT/GNU Scheme is free software; you can redistribute it and/or modify 11 it under the terms of the GNU General Public License as published by 12 the Free Software Foundation; either version 2 of the License, or (at 13 your option) any later version. 14 15 MIT/GNU Scheme is distributed in the hope that it will be useful, but 16 WITHOUT ANY WARRANTY; without even the implied warranty of 17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 General Public License for more details. 19 20 You should have received a copy of the GNU General Public License 21 along with MIT/GNU Scheme; if not, write to the Free Software 22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, 23 USA. 24 25 */ 26 27 /* Primitive declarations. 28 Note that the following cannot be changed without changing 29 findprim.c. 30 */ 31 32 #ifndef SCM_PRIM_H 33 #define SCM_PRIM_H 34 35 typedef SCHEME_OBJECT (*primitive_procedure_t) (void); 36 37 extern primitive_procedure_t * Primitive_Procedure_Table; 38 extern int * Primitive_Arity_Table; 39 extern int * Primitive_Count_Table; 40 extern const char ** Primitive_Name_Table; 41 extern const char ** Primitive_Documentation_Table; 42 extern unsigned long MAX_PRIMITIVE; 43 44 extern SCHEME_OBJECT declare_primitive 45 (const char *, primitive_procedure_t, int, int, const char *); 46 47 extern SCHEME_OBJECT install_primitive 48 (const char *, primitive_procedure_t, int, int, const char *); 49 50 extern SCHEME_OBJECT Prim_unimplemented (void); 51 52 #define PRIMITIVE_NUMBER(primitive) (OBJECT_DATUM (primitive)) 53 54 #define MAKE_PRIMITIVE_OBJECT(index) (MAKE_OBJECT (TC_PRIMITIVE, (index))) 55 56 #define IMPLEMENTED_PRIMITIVE_P(prim) \ 57 ((Primitive_Procedure_Table[(PRIMITIVE_NUMBER (prim))]) \ 58 != Prim_unimplemented) 59 60 #define NUMBER_OF_PRIMITIVES() (MAX_PRIMITIVE) 61 62 #define PRIMITIVE_ARITY(prim) \ 63 (Primitive_Arity_Table [PRIMITIVE_NUMBER (prim)]) 64 65 #define PRIMITIVE_DOCUMENTATION(prim) \ 66 (Primitive_Documentation_Table[(PRIMITIVE_NUMBER (prim))]) 67 68 #define PRIMITIVE_NAME(prim) \ 69 (Primitive_Name_Table[(PRIMITIVE_NUMBER (prim))]) 70 71 #define PRIMITIVE_N_PARAMETERS(prim) (PRIMITIVE_ARITY (prim)) 72 73 #define PRIMITIVE_N_ARGUMENTS(prim) \ 74 (((PRIMITIVE_ARITY (prim)) == LEXPR_PRIMITIVE_ARITY) \ 75 ? GET_LEXPR_ACTUALS \ 76 : (PRIMITIVE_ARITY (prim))) 77 78 #endif /* SCM_PRIM_H */ 79