📄 lisp.h
字号:
#ifndef XMARKBIT#define XMARKBIT(a) ((a) & MARKBIT)#endif#ifndef XSETMARKBIT#define XSETMARKBIT(a,b) ((a) = ((a) & ~MARKBIT) | (b))#endif#ifndef XMARK#define XMARK(a) ((a) |= MARKBIT)#endif#ifndef XUNMARK#define XUNMARK(a) ((a) &= ~MARKBIT)#endif#endif /* NO_UNION_TYPE */#ifndef NO_UNION_TYPE#define XTYPE(a) ((enum Lisp_Type) (a).u.type)#define XSETTYPE(a, b) ((a).u.type = (char) (b))/* Use XFASTINT for fast retrieval and storage of integers known to be positive. This takes advantage of the fact that Lisp_Int is 0. */#define XFASTINT(a) ((a).i)#ifdef EXPLICIT_SIGN_EXTEND/* Make sure we sign-extend; compilers have been known to fail to do so. */#define XINT(a) (((a).i << 8) >> 8)#else#define XINT(a) ((a).s.val)#endif /* EXPLICIT_SIGN_EXTEND */#define XUINT(a) ((a).u.val)#define XPNTR(a) ((a).u.val)#define XSETINT(a, b) ((a).s.val = (int) (b))#define XSETUINT(a, b) ((a).s.val = (int) (b))#define XSETPNTR(a, b) ((a).s.val = (int) (b))#define XSET(var, vartype, ptr) \ (((var).s.type = ((char) (vartype))), ((var).s.val = ((int) (ptr))))/* During garbage collection, XGCTYPE must be used for extracting types so that the mark bit is ignored. XMARKBIT access the markbit. Markbits are used only in particular slots of particular structure types. Other markbits are always zero. Outside of garbage collection, all mark bits are always zero. */#define XGCTYPE(a) ((a).gu.type)#define XMARKBIT(a) ((a).gu.markbit)#define XSETMARKBIT(a,b) (XMARKBIT(a) = (b))#define XMARK(a) (XMARKBIT(a) = 1)#define XUNMARK(a) (XMARKBIT(a) = 0)#endif NO_UNION_TYPE#define XCONS(a) ((struct Lisp_Cons *) XPNTR(a))#define XBUFFER(a) ((struct buffer *) XPNTR(a))#define XVECTOR(a) ((struct Lisp_Vector *) XPNTR(a))#define XSUBR(a) ((struct Lisp_Subr *) XPNTR(a))#define XSTRING(a) ((struct Lisp_String *) XPNTR(a))#define XSYMBOL(a) ((struct Lisp_Symbol *) XPNTR(a))#define XFUNCTION(a) ((Lisp_Object (*)()) XPNTR(a))#define XMARKER(a) ((struct Lisp_Marker *) XPNTR(a))#define XOBJFWD(a) ((Lisp_Object *) XPNTR(a))#define XINTPTR(a) ((int *) XPNTR(a))#define XWINDOW(a) ((struct window *) XPNTR(a))#define XPROCESS(a) ((struct Lisp_Process *) XPNTR(a))#define XSETCONS(a, b) XSETPNTR(a, (int) (b))#define XSETBUFFER(a, b) XSETPNTR(a, (int) (b))#define XSETVECTOR(a, b) XSETPNTR(a, (int) (b))#define XSETSUBR(a, b) XSETPNTR(a, (int) (b))#define XSETSTRING(a, b) XSETPNTR(a, (int) (b))#define XSETSYMBOL(a, b) XSETPNTR(a, (int) (b))#define XSETFUNCTION(a, b) XSETPNTR(a, (int) (b))#define XSETMARKER(a, b) XSETPNTR(a, (int) (b))#define XSETOBJFWD(a, b) XSETPNTR(a, (int) (b))#define XSETINTPTR(a, b) XSETPNTR(a, (int) (b))#define XSETWINDOW(a, b) XSETPNTR(a, (int) (b))#define XSETPROCESS(a, b) XSETPNTR(a, (int) (b))/* In a cons, the markbit of the car is the gc mark bit */struct Lisp_Cons { Lisp_Object car, cdr; };/* Like a cons, but records info on where the text lives that it was read from *//* This is not really in use now */struct Lisp_Buffer_Cons { Lisp_Object car, cdr; struct buffer *buffer; int bufpos; };/* In a string or vector, the sign bit of the `size' is the gc mark bit */struct Lisp_String { int size; unsigned char data[1]; };struct Lisp_Vector { int size; struct Lisp_Vector *next; Lisp_Object contents[1]; };/* In a symbol, the markbit of the plist is used as the gc mark bit */struct Lisp_Symbol { struct Lisp_String *name; Lisp_Object value; Lisp_Object function; Lisp_Object plist; struct Lisp_Symbol *next; /* -> next symbol in this obarray bucket */ };struct Lisp_Subr { Lisp_Object (*function) (); short min_args, max_args; char *symbol_name; char *prompt; char *doc; };/* In a marker, the markbit of the chain field is used as the gc mark bit */struct Lisp_Marker { struct buffer *buffer; Lisp_Object chain; int bufpos; };/* Data type checking */#ifdef NULL#undef NULL#endif#define NULL(x) (XFASTINT (x) == XFASTINT (Qnil))/* #define LISTP(x) (XTYPE ((x)) == Lisp_Cons)*/#define CONSP(x) (XTYPE ((x)) == Lisp_Cons)#define EQ(x, y) (XFASTINT (x) == XFASTINT (y))#define CHECK_LIST(x, i) \ { if ((XTYPE ((x)) != Lisp_Cons) && !NULL (x)) x = wrong_type_argument (Qlistp, (x)); }#define CHECK_STRING(x, i) \ { if (XTYPE ((x)) != Lisp_String) x = wrong_type_argument (Qstringp, (x)); }#define CHECK_CONS(x, i) \ { if (XTYPE ((x)) != Lisp_Cons) x = wrong_type_argument (Qconsp, (x)); }#define CHECK_SYMBOL(x, i) \ { if (XTYPE ((x)) != Lisp_Symbol) x = wrong_type_argument (Qsymbolp, (x)); }#define CHECK_VECTOR(x, i) \ { if (XTYPE ((x)) != Lisp_Vector) x = wrong_type_argument (Qvectorp, (x)); }#define CHECK_BUFFER(x, i) \ { if (XTYPE ((x)) != Lisp_Buffer) x = wrong_type_argument (Qbufferp, (x)); }#define CHECK_WINDOW(x, i) \ { if (XTYPE ((x)) != Lisp_Window) x = wrong_type_argument (Qwindowp, (x)); }#define CHECK_PROCESS(x, i) \ { if (XTYPE ((x)) != Lisp_Process) x = wrong_type_argument (Qprocessp, (x)); }#define CHECK_NUMBER(x, i) \ { if (XTYPE ((x)) != Lisp_Int) x = wrong_type_argument (Qintegerp, (x)); }#define CHECK_MARKER(x, i) \ { if (XTYPE ((x)) != Lisp_Marker) x = wrong_type_argument (Qmarkerp, (x)); }#define CHECK_NUMBER_COERCE_MARKER(x, i) \ { if (XTYPE ((x)) == Lisp_Marker) XFASTINT (x) = marker_position (x); \ else if (XTYPE ((x)) != Lisp_Int) x = wrong_type_argument (Qinteger_or_marker_p, (x)); }#ifdef VIRT_ADDR_VARIES/* For machines like APOLLO where text and data can go anywhere in virtual memory. */#define CHECK_IMPURE(obj) \ { extern int pure[]; \ if ((PNTR_COMPARISON_TYPE) XPNTR (obj) < (PNTR_COMPARISON_TYPE) ((char *) pure + PURESIZE) \ && (PNTR_COMPARISON_TYPE) XPNTR (obj) >= (PNTR_COMPARISON_TYPE) pure) \ pure_write_error (); }#else /* not VIRT_ADDR_VARIES */#ifdef PNTR_COMPARISON_TYPE/* when PNTR_COMPARISON_TYPE is not the default (unsigned int) */#define CHECK_IMPURE(obj) \ { extern int my_edata; \ if ((PNTR_COMPARISON_TYPE) XPNTR (obj) < (PNTR_COMPARISON_TYPE) &my_edata) \ pure_write_error (); }#else /* not VIRT_ADDRESS_VARIES, not PNTR_COMPARISON_TYPE */#define CHECK_IMPURE(obj) \ { extern int my_edata; \ if (XPNTR (obj) < (unsigned int) &my_edata) \ pure_write_error (); }#endif PNTR_COMPARISON_TYPE#endif VIRT_ADDRESS_VARIES/* Cast pointers to this type to compare them. Some machines want int. */#ifndef PNTR_COMPARISON_TYPE#define PNTR_COMPARISON_TYPE unsigned int#endif/* Define a built-in function for calling from Lisp. `lname' should be the name to give the function in Lisp, as a null-terminated C string. `fnname' should be the name of the function in C. By convention, it starts with F. `sname' should be the name for the C constant structure that records information on this function for internal use. By convention, it should be the same as `fnname' but with S instead of F. It's too bad that C macros can't compute this from `fnname'. `minargs' should be a number, the minimum number of arguments allowed. `maxargs' should be a number, the maximum number of arguments allowed, or else MANY or UNEVALLED. MANY means pass a vector of evaluated arguments, in the form of an integer number-of-arguments followed by the address of a vector of Lisp_Objects which contains the argument values. UNEVALLED means pass the list of unevaluated arguments `prompt' says how to read arguments for an interactive call. This can be zero or a C string. Zero means that interactive calls are not allowed. A string is interpreted in a hairy way: it should contain one line for each argument to be read, terminated by \n. The first character of the line controls the type of parsing: s -- read a string. S -- read a symbol. k -- read a key sequence and return it as a string. a -- read a function name (symbol) with completion. C -- read a command name (symbol) with completion. v -- read a variable name (symbol) with completion. b -- read a buffer name (a string) with completion. B -- buffer name, may be existing buffer or may not be. f -- read a file name, file must exist. F -- read a file name, file need not exist. n -- read a number. c -- read a character and return it as a number. p -- use the numeric value of the prefix argument. P -- use raw value of prefix - can be nil, -, (NUMBER) or NUMBER. x -- read a Lisp object from the minibuffer. X -- read a Lisp form from the minibuffer and use its value. A null string means call interactively with no arguments. `doc' is documentation for the user.*/#define DEFUN(lname, fnname, sname, minargs, maxargs, prompt, doc) \ Lisp_Object fnname (); \ struct Lisp_Subr sname = {fnname, minargs, maxargs, lname, prompt, 0}; \ Lisp_Object fnname/* defsubr (Sname); is how we define the symbol for function `name' at start-up time. */extern void defsubr ();#define MANY -2#define UNEVALLED -1/* Macros we use to define forwarded Lisp variables. These are used in the syms_of_FILENAME functions. */#define DEFVARLISP(lname, vname, doc) defvar_lisp (lname, vname)#define DEFVARBOOL(lname, vname, doc) defvar_bool (lname, vname)#define DEFVARINT(lname, vname, doc) defvar_int (lname, vname)#define DEFVARPERBUFFER(lname, vname, doc) \ defvar_per_buffer (lname, vname)#define DEFVAR_LISP(lname, vname, doc) defvar_lisp (lname, vname)#define DEFVAR_LISP_NOPRO(lname, vname, doc) defvar_lisp_nopro (lname, vname)#define DEFVAR_BOOL(lname, vname, doc) defvar_bool (lname, vname)#define DEFVAR_INT(lname, vname, doc) defvar_int (lname, vname)#define DEFVAR_PER_BUFFER(lname, vname, doc) \ defvar_per_buffer (lname, vname)/* Structure for recording Lisp call stack for backtrace purposes */struct specbinding { Lisp_Object symbol, old_value; Lisp_Object (*func) (); Lisp_Object unused; /* Dividing by 16 is faster than by 12 */ };extern struct specbinding *specpdl;extern struct specbinding *specpdl_ptr;extern int specpdl_size;struct handler { Lisp_Object handler; Lisp_Object var; int poll_suppress_count; /* No error should exit a piece of code in which polling is suppressed. */ struct catchtag *tag; struct handler *next; };extern struct handler *handlerlist;/* Check quit-flag and quit if it is non-nil. */#define QUIT \ if (!NULL (Vquit_flag) && NULL (Vinhibit_quit)) \ { Vquit_flag = Qnil; Fsignal (Qquit, Qnil); }/* Nonzero if ought to quit now. */#define QUITP (!NULL (Vquit_flag) && NULL (Vinhibit_quit))/* 1 if CH is upper case. */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -