1 /* cslread.h                      Copyright (C) Codemist Ltd, 1989-2008 */
2 
3 /*
4  * Header defining the structure of the package system for use by
5  * intern and its friends.
6  */
7 
8 
9 
10 /**************************************************************************
11  * Copyright (C) 2008, Codemist Ltd.                     A C Norman       *
12  *                                                                        *
13  * Redistribution and use in source and binary forms, with or without     *
14  * modification, are permitted provided that the following conditions are *
15  * met:                                                                   *
16  *                                                                        *
17  *     * Redistributions of source code must retain the relevant          *
18  *       copyright notice, this list of conditions and the following      *
19  *       disclaimer.                                                      *
20  *     * Redistributions in binary form must reproduce the above          *
21  *       copyright notice, this list of conditions and the following      *
22  *       disclaimer in the documentation and/or other materials provided  *
23  *       with the distribution.                                           *
24  *                                                                        *
25  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS    *
26  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT      *
27  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS      *
28  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE         *
29  * COPYRIGHT OWNERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,   *
30  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,   *
31  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS  *
32  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND *
33  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR  *
34  * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF     *
35  * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH   *
36  * DAMAGE.                                                                *
37  *************************************************************************/
38 
39 
40 
41 /* Signature: 6e75b9b5 28-Feb-2010 */
42 
43 #ifndef header_read_h
44 #define header_read_h 1
45 
46 typedef struct Package
47 {
48     Header header;
49     Lisp_Object packageid;  /* 'package as type of this struct */
50     Lisp_Object internals;  /* either vector or list of vectors */
51     Lisp_Object vinternals; /* number of 16K vectors in this package */
52     Lisp_Object ninternals; /* number of symbols in this package */
53     Lisp_Object pkgflags;   /* place to put randomish flags etc */
54 #ifdef COMMON
55 /*
56  * Standard Lisp can have a much simpler setup than Common Lisp here
57  */
58     Lisp_Object externals;  /* vector or list of vectors */
59     Lisp_Object vexternals; /* number of vectors in above */
60     Lisp_Object nexternals; /* number of symbols involved */
61     Lisp_Object name;       /* name of this package */
62     Lisp_Object nicknames;  /* list of nicknames */
63     Lisp_Object use_list;   /* list of things that this package uses */
64     Lisp_Object used_by_list;      /* list of packages that use this one */
65     Lisp_Object shadowing_symbols; /* magic to cope with name clashes */
66 #endif
67 } Package;
68 
69 /*
70  * The following macros are coded the way they are so as to encourage the
71  * C compiler into using the address modes I want...
72  * Rationalize at your peril!
73  */
74 #define packhdr_(p)   (*(Header *)     ((char *)(p) + (0 - TAG_VECTOR)))
75 #define packid_(p)    (*(Lisp_Object *)((char *)(p) + (CELL - TAG_VECTOR)))
76 #define packint_(p)   (*(Lisp_Object *)((char *)(p) + (2*CELL - TAG_VECTOR)))
77 #define packvint_(p)  (*(Lisp_Object *)((char *)(p) + (3*CELL - TAG_VECTOR)))
78 #define packnint_(p)  (*(Lisp_Object *)((char *)(p) + (4*CELL - TAG_VECTOR)))
79 #define packflags_(p) (*(Lisp_Object *)((char *)(p) + (5*CELL - TAG_VECTOR)))
80 #ifdef COMMON
81 #define packext_(p)   (*(Lisp_Object *)((char *)(p) + (6*CELL - TAG_VECTOR)))
82 #define packvext_(p)  (*(Lisp_Object *)((char *)(p) + (7*CELL - TAG_VECTOR)))
83 #define packnext_(p)  (*(Lisp_Object *)((char *)(p) + (8*CELL - TAG_VECTOR)))
84 #define packname_(p)  (*(Lisp_Object *)((char *)(p) + (9*CELL - TAG_VECTOR)))
85 #define packnick_(p)  (*(Lisp_Object *)((char *)(p) + (10*CELL - TAG_VECTOR)))
86 #define packuses_(p)  (*(Lisp_Object *)((char *)(p) + (11*CELL - TAG_VECTOR)))
87 #define packused_(p)  (*(Lisp_Object *)((char *)(p) + (12*CELL - TAG_VECTOR)))
88 #define packshade_(p) (*(Lisp_Object *)((char *)(p) + (13*CELL - TAG_VECTOR)))
89 #endif
90 
91 #define CP  qvalue(current_package)
92 
93 #ifdef COMMON
94 #  define ESCAPE_CHAR '\\'
95 #else
96 #  define ESCAPE_CHAR '!'
97 #endif
98 
99 #define NO_PREFIX           'x'
100 
101 extern CSLbool is_constituent(int c);
102 extern Lisp_Object intern(int len, CSLbool escaped);
103 extern Lisp_Object iintern(Lisp_Object str, int32_t h, Lisp_Object p,
104                            int str_is_ok /* NOT a bool */);
105 extern Lisp_Object find_package(char *name, int len);
106 extern Lisp_Object read_from_vector(char *v);
107 
108 #ifndef MAX_PROMPT_LENGTH
109 #  define MAX_PROMPT_LENGTH 256
110 #endif
111 extern char prompt_string[MAX_PROMPT_LENGTH];
112 
113 /* These two are now specified in LispObject units not bytes */
114 #define INIT_OBVECI_SIZE      4096
115 #define INIT_OBVECX_SIZE      4096
116 
117 #endif /* header_read_h */
118 
119 /* end of cslread.h */
120