#ifndef Lisp_private_h
#define Lisp_private_h
#include <X11/Xos.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#if defined(X_POSIX_C_SOURCE)
#define _POSIX_C_SOURCE X_POSIX_C_SOURCE
#include <setjmp.h>
#undef _POSIX_C_SOURCE
#else
#include <setjmp.h>
#endif
#include <unistd.h>
#include <sys/time.h>
#include "lisp/internal.h"
#include "lisp/core.h"
#ifdef DEBUGGER
#include "lisp/debugger.h"
#endif
#include "lisp/helper.h"
#include "lisp/string.h"
#include "lisp/struct.h"
#define STRTBLSZ 23
#define MULTIPLE_VALUES_LIMIT 127
#define MAX_STACK_DEPTH 16384
#define FEATURES \
(lisp__data.features->data.atom->a_object ? \
(LispObj *)lisp__data.features->data.atom->property->value : \
NIL)
#define PACK lisp__data.packlist
#define PACKAGE lisp__data.package->data.atom->property->value
#define MOD lisp__data.modlist
#define COD lisp__data.codlist
#define RUN lisp__data.runlist
#define RES lisp__data.reslist
#define DBG lisp__data.dbglist
#define BRK lisp__data.brklist
#define PRO lisp__data.prolist
#define SINPUT lisp__data.input
#define SOUTPUT lisp__data.output
#define STANDARD_INPUT \
lisp__data.standard_input->data.atom->property->value
#define STANDARD_OUTPUT \
lisp__data.standard_output->data.atom->property->value
#define STANDARDSTREAM(file, desc, flags) \
LispNewStandardStream(file, desc, flags)
typedef struct _LispStream LispStream;
typedef struct _LispBlock LispBlock;
typedef struct _LispOpaque LispOpaque;
typedef struct _LispModule LispModule;
typedef struct _LispProperty LispProperty;
typedef struct _LispObjList LispObjList;
typedef struct _LispStringHash LispStringHash;
typedef struct _LispCharInfo LispCharInfo;
typedef struct _LispNormalArgs {
int num_symbols;
LispObj **symbols;
} LispNormalArgs;
typedef struct _LispOptionalArgs {
int num_symbols;
LispObj **symbols;
LispObj **defaults;
LispObj **sforms;
} LispOptionalArgs;
typedef struct _LispKeyArgs {
int num_symbols;
LispObj **symbols;
LispObj **defaults;
LispObj **sforms;
LispObj **keys;
} LispKeyArgs;
typedef struct _LispAuxArgs {
int num_symbols;
LispObj **symbols;
LispObj **initials;
} LispAuxArgs;
typedef struct _LispArgList {
LispNormalArgs normals;
LispOptionalArgs optionals;
LispKeyArgs keys;
LispObj *rest;
LispAuxArgs auxs;
int num_arguments;
char *description;
} LispArgList;
typedef enum _LispDocType_t {
LispDocVariable,
LispDocFunction,
LispDocStructure,
LispDocType,
LispDocSetf
} LispDocType_t;
struct _LispProperty {
unsigned int refcount;
LispPackage *package;
LispObj *value;
union {
LispObj *function;
LispBuiltin *builtin;
} fun;
LispArgList *alist;
LispObj *properties;
LispObj *setf;
LispArgList *salist;
struct {
LispObj *definition;
#define STRUCT_NAME -3
#define STRUCT_CHECK -2
#define STRUCT_CONSTRUCTOR -1
int function;
} structure;
};
struct _LispAtom {
hash_key *key;
struct _LispAtom *next;
unsigned int dyn : 1;
unsigned int a_object : 1;
unsigned int a_function : 1;
unsigned int a_builtin : 1;
unsigned int a_compiled : 1;
unsigned int a_property : 1;
unsigned int a_defsetf : 1;
unsigned int a_defstruct : 1;
unsigned int ext : 1;
unsigned int unreadable : 1;
unsigned int watch : 1;
unsigned int constant : 1;
LispObj *object;
int offset;
LispObj *package;
LispObj *function;
LispObj *name;
LispProperty *property;
LispObj *documentation[5];
};
struct _LispObjList {
LispObj **pairs;
int length;
int space;
};
struct _LispPackage {
LispObjList glb;
LispObjList use;
hash_table *atoms;
};
struct _LispOpaque {
hash_key *desc;
LispOpaque *next;
int type;
};
typedef enum _LispBlockType {
LispBlockNone,
LispBlockTag,
LispBlockCatch,
LispBlockClosure,
LispBlockProtect,
LispBlockBody
} LispBlockType;
struct _LispBlock {
LispBlockType type;
LispObj *tag;
jmp_buf jmp;
int stack;
int protect;
int block_level;
#ifdef DEBUGGER
int debug_level;
int debug_step;
#endif
};
struct _LispModule {
LispModule *next;
void *handle;
LispModuleData *data;
};
typedef struct _LispUngetInfo {
char buffer[16];
int offset;
} LispUngetInfo;
struct _LispMac {
struct {
LispObj **values;
int base;
int length;
int space;
} stack;
struct {
LispObj **values;
Atom_id *names;
int lex;
int head;
int length;
int space;
} env;
struct {
LispObj **values;
int count;
} returns;
struct {
LispObj **objects;
int length;
int space;
} protect;
LispObj *package;
LispPackage *pack;
LispObj *keyword;
LispPackage *key;
LispObj *lisp;
LispObj *savepackage;
LispPackage *savepack;
struct {
int block_level;
int block_size;
LispObj *block_ret;
LispBlock **block;
} block;
sigjmp_buf jmp;
struct {
unsigned int expandbits : 3;
unsigned int immutablebits : 1;
unsigned int timebits : 1;
unsigned int count;
long gctime;
int average;
} gc;
hash_table *strings;
hash_table *opqs;
int opaque;
LispObj *standard_input, *input, *input_list;
LispObj *standard_output, *output, *output_list;
LispObj *error_stream;
LispUngetInfo **unget;
int iunget, nunget;
int eof;
int interactive;
int errexit;
struct {
int index;
int level;
int space;
void **mem;
} mem;
LispModule *module;
LispObj *modules;
char *prompt;
LispObj *features;
LispObj *modlist;
LispObj *packlist;
LispObj *codlist;
LispObj *runlist[3];
LispObj *reslist[3];
#ifdef DEBUGGER
LispObj *dbglist;
LispObj *brklist;
#endif
LispObj *prolist;
#ifdef SIGNALRETURNSINT
int (*sigint)(int);
int (*sigfpe)(int);
#else
void (*sigint)(int);
void (*sigfpe)(int);
#endif
int destroyed;
int running;
int ignore_errors;
LispObj *error_condition;
int debugging;
#ifdef DEBUGGER
int debug_level;
int debug_step;
int debug_break;
LispDebugState debug;
#endif
};
struct _LispCharInfo {
char **names;
};
void LispUseArgList(LispArgList*);
void LispFreeArgList(LispArgList*);
LispArgList *LispCheckArguments(LispFunType, LispObj*, char*, int);
LispObj *LispListProtectedArguments(LispArgList*);
LispObj *LispGetDoc(LispObj*);
LispObj *LispGetVar(LispObj*);
#ifdef DEBUGGER
void *LispGetVarAddr(LispObj*);
#endif
LispObj *LispAddVar(LispObj*, LispObj*);
LispObj *LispSetVar(LispObj*, LispObj*);
void LispUnsetVar(LispObj*);
LispObj *LispNewStandardStream(LispFile*, LispObj*, int);
LispObj *LispNewPackage(LispObj*, LispObj*);
void LispUsePackage(LispObj*);
void LispExportSymbol(LispObj*);
void LispImportSymbol(LispObj*);
hash_key *LispGetAtomKey(char*, int);
char *LispGetAtomString(char*, int);
LispObj *LispReverse(LispObj *list);
char *LispIntToOpaqueType(int);
void LispPrint(LispObj*, LispObj*, int);
LispBlock *LispBeginBlock(LispObj*, LispBlockType);
#define BLOCKJUMP(block) \
lisp__data.stack.length = (block)->stack; \
lisp__data.protect.length = (block)->protect; \
longjmp((block)->jmp, 1)
void LispEndBlock(LispBlock*);
void LispBlockUnwind(LispBlock*);
void LispUpdateResults(LispObj*, LispObj*);
void LispTopLevel(void);
LispAtom *LispDoGetAtom(char *str, int);
LispObj *LispGetAtomProperty(LispAtom*, LispObj*);
LispObj *LispPutAtomProperty(LispAtom*, LispObj*, LispObj*);
LispObj *LispRemAtomProperty(LispAtom*, LispObj*);
LispObj *LispReplaceAtomPropertyList(LispAtom*, LispObj*);
LispObj *LispSymbolFunction(LispObj*);
LispObj *LispSymbolName(LispObj*);
void LispSetAtomCompiledProperty(LispAtom*, LispObj*);
void LispRemAtomCompiledProperty(LispAtom*);
void LispSetAtomFunctionProperty(LispAtom*, LispObj*, LispArgList*);
void LispRemAtomFunctionProperty(LispAtom*);
void LispSetAtomBuiltinProperty(LispAtom*, LispBuiltin*, LispArgList*);
void LispRemAtomBuiltinProperty(LispAtom*);
void LispSetAtomSetfProperty(LispAtom*, LispObj*, LispArgList*);
void LispRemAtomSetfProperty(LispAtom*);
void LispSetAtomStructProperty(LispAtom*, LispObj*, int);
void LispRemAtomStructProperty(LispAtom*);
void LispProclaimSpecial(LispObj*, LispObj*, LispObj*);
void LispDefconstant(LispObj*, LispObj*, LispObj*);
void LispAddDocumentation(LispObj*, LispObj*, LispDocType_t);
void LispRemDocumentation(LispObj*, LispDocType_t);
LispObj *LispGetDocumentation(LispObj*, LispDocType_t);
void LispMoreReturns(void);
void LispMoreProtects(void);
extern int LispArgList_t;
extern LispCharInfo LispChars[256];
extern void LispSignal(int);
void LispDisableInterrupts(void);
void LispEnableInterrupts(void);
#define DISABLE_INTERRUPTS() LispDisableInterrupts()
#define ENABLE_INTERRUPTS() LispEnableInterrupts()
extern LispMac lisp__data;
#endif