source: branches/0.22.x/abcl/src/org/armedbear/lisp/BuiltInClass.java

Last change on this file was 12607, checked in by Mark Evenson, 15 years ago

URL pathnames working for OPEN for built-in schemas.

Still need to decide with URI escaping issues, as we currently rely on
the URL Stream handlers to do the right thing. And we still need to
retrofit jar pathname's use of a string to represent a URL.

Updates for URL and jar pathname design documents.

Implemented URL-PATHNAME and JAR-PATHNAME as subtypes of PATHNAME.

Adjusted ABCL-TEST-LISP to use functions provided in
"pathname-test.lisp" in "jar-file.lisp". Added one test for url
pathnames.

Constructor in Java added for a Cons by copying references from the
orignal Cons.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 16.8 KB
Line 
1/*
2 * BuiltInClass.java
3 *
4 * Copyright (C) 2003-2007 Peter Graves
5 * $Id: BuiltInClass.java 12607 2010-04-15 14:27:09Z mevenson $
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
20 *
21 * As a special exception, the copyright holders of this library give you
22 * permission to link this library with independent modules to produce an
23 * executable, regardless of the license terms of these independent
24 * modules, and to copy and distribute the resulting executable under
25 * terms of your choice, provided that you also meet, for each linked
26 * independent module, the terms and conditions of the license of that
27 * module.  An independent module is a module which is not derived from
28 * or based on this library.  If you modify this library, you may extend
29 * this exception to your version of the library, but you are not
30 * obligated to do so.  If you do not wish to do so, delete this
31 * exception statement from your version.
32 */
33
34package org.armedbear.lisp;
35
36import static org.armedbear.lisp.Lisp.*;
37
38public class BuiltInClass extends LispClass
39{
40  private BuiltInClass(Symbol symbol)
41  {
42    super(symbol);
43  }
44
45  @Override
46  public LispObject typeOf()
47  {
48    return Symbol.BUILT_IN_CLASS;
49  }
50
51  @Override
52  public LispObject classOf()
53  {
54    return StandardClass.BUILT_IN_CLASS;
55  }
56
57  @Override
58  public LispObject typep(LispObject type)
59  {
60    if (type == Symbol.BUILT_IN_CLASS)
61      return T;
62    if (type == StandardClass.BUILT_IN_CLASS)
63      return T;
64    return super.typep(type);
65  }
66
67  @Override
68  public LispObject getDescription()
69  {
70    return new SimpleString(writeToString());
71  }
72
73  @Override
74  public String writeToString()
75  {
76    StringBuilder sb = new StringBuilder("#<BUILT-IN-CLASS ");
77    sb.append(getName().writeToString());
78    sb.append('>');
79    return sb.toString();
80  }
81
82  private static BuiltInClass addClass(Symbol symbol)
83  {
84    BuiltInClass c = new BuiltInClass(symbol);
85    addClass(symbol, c);
86    return c;
87  }
88
89  public static final BuiltInClass CLASS_T              = addClass(T);
90
91  public static final BuiltInClass ARRAY                = addClass(Symbol.ARRAY);
92  public static final BuiltInClass BIGNUM               = addClass(Symbol.BIGNUM);
93  public static final BuiltInClass BASE_STRING          = addClass(Symbol.BASE_STRING);
94  public static final BuiltInClass BIT_VECTOR           = addClass(Symbol.BIT_VECTOR);
95  public static final BuiltInClass CHARACTER            = addClass(Symbol.CHARACTER);
96  public static final BuiltInClass COMPLEX              = addClass(Symbol.COMPLEX);
97  public static final BuiltInClass CONS                 = addClass(Symbol.CONS);
98  public static final BuiltInClass DOUBLE_FLOAT         = addClass(Symbol.DOUBLE_FLOAT);
99  public static final BuiltInClass ENVIRONMENT          = addClass(Symbol.ENVIRONMENT);
100  public static final BuiltInClass FIXNUM               = addClass(Symbol.FIXNUM);
101  public static final BuiltInClass FLOAT                = addClass(Symbol.FLOAT);
102  public static final BuiltInClass FUNCTION             = addClass(Symbol.FUNCTION);
103  public static final BuiltInClass HASH_TABLE           = addClass(Symbol.HASH_TABLE);
104  public static final BuiltInClass INTEGER              = addClass(Symbol.INTEGER);
105  public static final BuiltInClass JAVA_OBJECT          = addClass(Symbol.JAVA_OBJECT);
106  public static final BuiltInClass LIST                 = addClass(Symbol.LIST);
107  public static final BuiltInClass LOGICAL_PATHNAME     = addClass(Symbol.LOGICAL_PATHNAME);
108  public static final BuiltInClass MAILBOX              = addClass(Symbol.MAILBOX);
109  public static final BuiltInClass METHOD_COMBINATION   = addClass(Symbol.METHOD_COMBINATION);
110  public static final BuiltInClass MUTEX                = addClass(Symbol.MUTEX);
111  public static final BuiltInClass NIL_VECTOR           = addClass(Symbol.NIL_VECTOR);
112  public static final BuiltInClass NULL                 = addClass(Symbol.NULL);
113  public static final BuiltInClass NUMBER               = addClass(Symbol.NUMBER);
114  public static final BuiltInClass PACKAGE              = addClass(Symbol.PACKAGE);
115  public static final BuiltInClass PATHNAME             = addClass(Symbol.PATHNAME);
116  public static final BuiltInClass JAR_PATHNAME         = addClass(Symbol.JAR_PATHNAME);
117  public static final BuiltInClass URL_PATHNAME         = addClass(Symbol.URL_PATHNAME);
118  public static final BuiltInClass RANDOM_STATE         = addClass(Symbol.RANDOM_STATE);
119  public static final BuiltInClass RATIO                = addClass(Symbol.RATIO);
120  public static final BuiltInClass RATIONAL             = addClass(Symbol.RATIONAL);
121  public static final BuiltInClass READTABLE            = addClass(Symbol.READTABLE);
122  public static final BuiltInClass REAL                 = addClass(Symbol.REAL);
123  public static final BuiltInClass RESTART              = addClass(Symbol.RESTART);
124  public static final BuiltInClass SEQUENCE             = addClass(Symbol.SEQUENCE); 
125  public static final BuiltInClass SIMPLE_ARRAY         = addClass(Symbol.SIMPLE_ARRAY);
126  public static final BuiltInClass SIMPLE_BASE_STRING   = addClass(Symbol.SIMPLE_BASE_STRING);
127  public static final BuiltInClass SIMPLE_BIT_VECTOR    = addClass(Symbol.SIMPLE_BIT_VECTOR);
128  public static final BuiltInClass SIMPLE_STRING        = addClass(Symbol.SIMPLE_STRING);
129  public static final BuiltInClass SIMPLE_VECTOR        = addClass(Symbol.SIMPLE_VECTOR);
130  public static final BuiltInClass SINGLE_FLOAT         = addClass(Symbol.SINGLE_FLOAT);
131  public static final BuiltInClass STRING               = addClass(Symbol.STRING);
132  public static final BuiltInClass SYMBOL               = addClass(Symbol.SYMBOL);
133  public static final BuiltInClass THREAD               = addClass(Symbol.THREAD);
134  public static final BuiltInClass VECTOR               = addClass(Symbol.VECTOR);
135  public static final BuiltInClass STACK_FRAME          = addClass(Symbol.STACK_FRAME);
136  public static final BuiltInClass LISP_STACK_FRAME     = addClass(Symbol.LISP_STACK_FRAME);
137  public static final BuiltInClass JAVA_STACK_FRAME     = addClass(Symbol.JAVA_STACK_FRAME);
138
139
140  public static final StructureClass STRUCTURE_OBJECT =
141    (StructureClass)addClass(Symbol.STRUCTURE_OBJECT,
142             new StructureClass(Symbol.STRUCTURE_OBJECT, list(CLASS_T)));
143
144    /* All the stream classes below are being defined as structure classes
145       but won't be available as such until further action is taken:
146       the 'defstruct' internal administration is missing.
147
148       For STREAM and SYSTEM-STREAM, that bit is added in boot.lisp */
149
150  public static final LispClass STREAM =
151    addClass(Symbol.STREAM,
152             new StructureClass(Symbol.STREAM, list(STRUCTURE_OBJECT)));
153  public static final LispClass SYSTEM_STREAM =
154    addClass(Symbol.SYSTEM_STREAM,
155             new StructureClass(Symbol.SYSTEM_STREAM, list(STREAM)));
156  public static final LispClass TWO_WAY_STREAM =
157    addClass(Symbol.TWO_WAY_STREAM,
158             new StructureClass(Symbol.TWO_WAY_STREAM, list(SYSTEM_STREAM)));
159  public static final LispClass BROADCAST_STREAM =
160    addClass(Symbol.BROADCAST_STREAM,
161             new StructureClass(Symbol.BROADCAST_STREAM, list(SYSTEM_STREAM)));
162  public static final LispClass ECHO_STREAM =
163    addClass(Symbol.ECHO_STREAM,
164             new StructureClass(Symbol.ECHO_STREAM, list(SYSTEM_STREAM)));
165  public static final LispClass CASE_FROB_STREAM =
166    addClass(Symbol.CASE_FROB_STREAM,
167             new StructureClass(Symbol.CASE_FROB_STREAM, list(SYSTEM_STREAM)));
168  public static final LispClass STRING_STREAM =
169    addClass(Symbol.STRING_STREAM,
170             new StructureClass(Symbol.STRING_STREAM, list(SYSTEM_STREAM)));
171  public static final LispClass STRING_INPUT_STREAM =
172    addClass(Symbol.STRING_INPUT_STREAM,
173             new StructureClass(Symbol.STRING_INPUT_STREAM, list(STRING_STREAM)));
174  public static final LispClass STRING_OUTPUT_STREAM =
175    addClass(Symbol.STRING_OUTPUT_STREAM,
176             new StructureClass(Symbol.STRING_OUTPUT_STREAM, list(STRING_STREAM)));
177  public static final LispClass SYNONYM_STREAM =
178    addClass(Symbol.SYNONYM_STREAM,
179             new StructureClass(Symbol.SYNONYM_STREAM, list(SYSTEM_STREAM)));
180  public static final LispClass FILE_STREAM =
181    addClass(Symbol.FILE_STREAM,
182             new StructureClass(Symbol.FILE_STREAM, list(SYSTEM_STREAM)));
183  public static final LispClass JAR_STREAM =
184    addClass(Symbol.JAR_STREAM,
185             new StructureClass(Symbol.JAR_STREAM, list(SYSTEM_STREAM)));
186  public static final LispClass URL_STREAM =
187    addClass(Symbol.URL_STREAM,
188             new StructureClass(Symbol.URL_STREAM, list(SYSTEM_STREAM)));
189  public static final LispClass CONCATENATED_STREAM =
190    addClass(Symbol.CONCATENATED_STREAM,
191             new StructureClass(Symbol.CONCATENATED_STREAM, list(SYSTEM_STREAM)));
192
193
194
195    // Implementation defined streams
196  public static final LispClass SOCKET_STREAM =
197    addClass(Symbol.SOCKET_STREAM,
198             new StructureClass(Symbol.SOCKET_STREAM, list(TWO_WAY_STREAM)));
199  public static final LispClass SLIME_INPUT_STREAM =
200    addClass(Symbol.SLIME_INPUT_STREAM,
201             new StructureClass(Symbol.SLIME_INPUT_STREAM, list(STRING_STREAM)));
202  public static final LispClass SLIME_OUTPUT_STREAM =
203    addClass(Symbol.SLIME_OUTPUT_STREAM,
204             new StructureClass(Symbol.SLIME_OUTPUT_STREAM, list(STRING_STREAM)));
205
206
207
208  static
209  {
210    ARRAY.setDirectSuperclass(CLASS_T);
211    ARRAY.setCPL(ARRAY, CLASS_T);
212    BASE_STRING.setDirectSuperclass(STRING);
213    BASE_STRING.setCPL(BASE_STRING, STRING, VECTOR, ARRAY, SEQUENCE, CLASS_T);
214    BIGNUM.setDirectSuperclass(INTEGER);
215    BIGNUM.setCPL(BIGNUM, INTEGER, RATIONAL, REAL, NUMBER, CLASS_T);
216    BIT_VECTOR.setDirectSuperclass(VECTOR);
217    BIT_VECTOR.setCPL(BIT_VECTOR, VECTOR, ARRAY, SEQUENCE, CLASS_T);
218    BROADCAST_STREAM.setCPL(BROADCAST_STREAM, SYSTEM_STREAM, STREAM,
219                            STRUCTURE_OBJECT, CLASS_T);
220    CASE_FROB_STREAM.setCPL(CASE_FROB_STREAM, SYSTEM_STREAM, STREAM,
221                            STRUCTURE_OBJECT, CLASS_T);
222    CHARACTER.setDirectSuperclass(CLASS_T);
223    CHARACTER.setCPL(CHARACTER, CLASS_T);
224    CLASS_T.setCPL(CLASS_T);
225    COMPLEX.setDirectSuperclass(NUMBER);
226    COMPLEX.setCPL(COMPLEX, NUMBER, CLASS_T);
227    CONCATENATED_STREAM.setCPL(CONCATENATED_STREAM, SYSTEM_STREAM, STREAM,
228                               STRUCTURE_OBJECT, CLASS_T);
229    CONS.setDirectSuperclass(LIST);
230    CONS.setCPL(CONS, LIST, SEQUENCE, CLASS_T);
231    DOUBLE_FLOAT.setDirectSuperclass(FLOAT);
232    DOUBLE_FLOAT.setCPL(DOUBLE_FLOAT, FLOAT, REAL, NUMBER, CLASS_T);
233    ECHO_STREAM.setCPL(ECHO_STREAM, SYSTEM_STREAM, STREAM,
234                       STRUCTURE_OBJECT, CLASS_T);
235    ENVIRONMENT.setDirectSuperclass(CLASS_T);
236    ENVIRONMENT.setCPL(ENVIRONMENT, CLASS_T);
237    FIXNUM.setDirectSuperclass(INTEGER);
238    FIXNUM.setCPL(FIXNUM, INTEGER, RATIONAL, REAL, NUMBER, CLASS_T);
239    FILE_STREAM.setCPL(FILE_STREAM, SYSTEM_STREAM, STREAM,
240                       STRUCTURE_OBJECT, CLASS_T);
241    JAR_STREAM.setCPL(JAR_STREAM, SYSTEM_STREAM, STREAM,
242                      STRUCTURE_OBJECT, CLASS_T);
243    URL_STREAM.setCPL(URL_STREAM, SYSTEM_STREAM, STREAM,
244                      STRUCTURE_OBJECT, CLASS_T);
245    FLOAT.setDirectSuperclass(REAL);
246    FLOAT.setCPL(FLOAT, REAL, NUMBER, CLASS_T);
247    FUNCTION.setDirectSuperclass(CLASS_T);
248    FUNCTION.setCPL(FUNCTION, CLASS_T);
249    HASH_TABLE.setDirectSuperclass(CLASS_T);
250    HASH_TABLE.setCPL(HASH_TABLE, CLASS_T);
251    INTEGER.setDirectSuperclass(RATIONAL);
252    INTEGER.setCPL(INTEGER, RATIONAL, REAL, NUMBER, CLASS_T);
253    JAVA_OBJECT.setDirectSuperclass(CLASS_T);
254    JAVA_OBJECT.setCPL(JAVA_OBJECT, CLASS_T);
255    LIST.setDirectSuperclass(SEQUENCE);
256    LIST.setCPL(LIST, SEQUENCE, CLASS_T);
257    LOGICAL_PATHNAME.setDirectSuperclass(PATHNAME);
258    LOGICAL_PATHNAME.setCPL(LOGICAL_PATHNAME, PATHNAME, CLASS_T);
259    MAILBOX.setDirectSuperclass(CLASS_T);
260    MAILBOX.setCPL(MAILBOX, CLASS_T);
261    METHOD_COMBINATION.setDirectSuperclass(CLASS_T);
262    METHOD_COMBINATION.setCPL(METHOD_COMBINATION, CLASS_T);
263    MUTEX.setDirectSuperclass(CLASS_T);
264    MUTEX.setCPL(MUTEX, CLASS_T);
265    NIL_VECTOR.setDirectSuperclass(STRING);
266    NIL_VECTOR.setCPL(NIL_VECTOR, STRING, VECTOR, ARRAY, SEQUENCE, CLASS_T);
267    NULL.setDirectSuperclass(LIST);
268    NULL.setCPL(NULL, SYMBOL, LIST, SEQUENCE, CLASS_T);
269    NUMBER.setDirectSuperclass(CLASS_T);
270    NUMBER.setCPL(NUMBER, CLASS_T);
271    PACKAGE.setDirectSuperclass(CLASS_T);
272    PACKAGE.setCPL(PACKAGE, CLASS_T);
273    PATHNAME.setDirectSuperclass(CLASS_T);
274    PATHNAME.setCPL(PATHNAME, CLASS_T);
275    JAR_PATHNAME.setDirectSuperclass(PATHNAME);
276    JAR_PATHNAME.setCPL(JAR_PATHNAME, PATHNAME, CLASS_T);
277    URL_PATHNAME.setDirectSuperclass(PATHNAME);
278    URL_PATHNAME.setCPL(URL_PATHNAME, PATHNAME, CLASS_T);
279    RANDOM_STATE.setDirectSuperclass(CLASS_T);
280    RANDOM_STATE.setCPL(RANDOM_STATE, CLASS_T);
281    RATIO.setDirectSuperclass(RATIONAL);
282    RATIO.setCPL(RATIO, RATIONAL, REAL, NUMBER, CLASS_T);
283    RATIONAL.setDirectSuperclass(REAL);
284    RATIONAL.setCPL(RATIONAL, REAL, NUMBER, CLASS_T);
285    READTABLE.setDirectSuperclass(CLASS_T);
286    READTABLE.setCPL(READTABLE, CLASS_T);
287    REAL.setDirectSuperclass(NUMBER);
288    REAL.setCPL(REAL, NUMBER, CLASS_T);
289    RESTART.setDirectSuperclass(CLASS_T);
290    RESTART.setCPL(RESTART, CLASS_T);
291    SEQUENCE.setDirectSuperclass(CLASS_T);
292    SEQUENCE.setCPL(SEQUENCE, CLASS_T);
293    SIMPLE_ARRAY.setDirectSuperclass(ARRAY);
294    SIMPLE_ARRAY.setCPL(SIMPLE_ARRAY, ARRAY, CLASS_T);
295    SIMPLE_BASE_STRING.setDirectSuperclasses(list(BASE_STRING, SIMPLE_STRING));
296    SIMPLE_BASE_STRING.setCPL(SIMPLE_BASE_STRING, BASE_STRING, SIMPLE_STRING,
297                              STRING, VECTOR, SIMPLE_ARRAY, ARRAY, SEQUENCE,
298                              CLASS_T);
299    SIMPLE_BIT_VECTOR.setDirectSuperclasses(list(BIT_VECTOR, SIMPLE_ARRAY));
300    SIMPLE_BIT_VECTOR.setCPL(SIMPLE_BIT_VECTOR, BIT_VECTOR, VECTOR,
301                             SIMPLE_ARRAY, ARRAY, SEQUENCE, CLASS_T);
302    SIMPLE_STRING.setDirectSuperclasses(list(BASE_STRING, STRING, SIMPLE_ARRAY));
303    SIMPLE_STRING.setCPL(SIMPLE_STRING, BASE_STRING, STRING, VECTOR,
304                         SIMPLE_ARRAY, ARRAY, SEQUENCE, CLASS_T);
305    SIMPLE_VECTOR.setDirectSuperclasses(list(VECTOR, SIMPLE_ARRAY));
306    SIMPLE_VECTOR.setCPL(SIMPLE_VECTOR, VECTOR, SIMPLE_ARRAY, ARRAY, SEQUENCE,
307                         CLASS_T);
308    SINGLE_FLOAT.setDirectSuperclass(FLOAT);
309    SINGLE_FLOAT.setCPL(SINGLE_FLOAT, FLOAT, REAL, NUMBER, CLASS_T);
310    SLIME_INPUT_STREAM.setCPL(SLIME_INPUT_STREAM, STRING_STREAM, SYSTEM_STREAM,
311                              STREAM, STRUCTURE_OBJECT, CLASS_T);
312    SLIME_OUTPUT_STREAM.setCPL(SLIME_OUTPUT_STREAM, STRING_STREAM, SYSTEM_STREAM,
313                               STREAM, STRUCTURE_OBJECT, CLASS_T);
314    SOCKET_STREAM.setCPL(SOCKET_STREAM, TWO_WAY_STREAM, SYSTEM_STREAM, STREAM,
315                         STRUCTURE_OBJECT, CLASS_T);
316    STREAM.setCPL(STREAM, STRUCTURE_OBJECT, CLASS_T);
317    STRING.setDirectSuperclass(VECTOR);
318    STRING.setCPL(STRING, VECTOR, ARRAY, SEQUENCE, CLASS_T);
319    STRING_INPUT_STREAM.setCPL(STRING_INPUT_STREAM, STRING_STREAM,
320                               SYSTEM_STREAM, STREAM, STRUCTURE_OBJECT, CLASS_T);
321    STRING_OUTPUT_STREAM.setCPL(STRING_OUTPUT_STREAM, STRING_STREAM,
322                                SYSTEM_STREAM, STREAM, STRUCTURE_OBJECT, CLASS_T);
323    STRING_STREAM.setCPL(STRING_STREAM, SYSTEM_STREAM, STREAM,
324                         STRUCTURE_OBJECT, CLASS_T);
325    STRUCTURE_OBJECT.setCPL(STRUCTURE_OBJECT, CLASS_T);
326    SYMBOL.setDirectSuperclass(CLASS_T);
327    SYMBOL.setCPL(SYMBOL, CLASS_T);
328    SYNONYM_STREAM.setCPL(SYNONYM_STREAM, SYSTEM_STREAM,
329                          STREAM, STRUCTURE_OBJECT, CLASS_T);
330    SYSTEM_STREAM.setCPL(SYSTEM_STREAM, STREAM, STRUCTURE_OBJECT, CLASS_T);
331    THREAD.setDirectSuperclass(CLASS_T);
332    THREAD.setCPL(THREAD, CLASS_T);
333    TWO_WAY_STREAM.setCPL(TWO_WAY_STREAM, SYSTEM_STREAM, STREAM,
334                          STRUCTURE_OBJECT, CLASS_T);
335    VECTOR.setDirectSuperclasses(list(ARRAY, SEQUENCE));
336    VECTOR.setCPL(VECTOR, ARRAY, SEQUENCE, CLASS_T);
337    STACK_FRAME.setDirectSuperclasses(CLASS_T);
338    STACK_FRAME.setCPL(STACK_FRAME, CLASS_T);
339    LISP_STACK_FRAME.setDirectSuperclasses(STACK_FRAME);
340    LISP_STACK_FRAME.setCPL(LISP_STACK_FRAME, STACK_FRAME, CLASS_T);
341    JAVA_STACK_FRAME.setDirectSuperclasses(STACK_FRAME);
342    JAVA_STACK_FRAME.setCPL(JAVA_STACK_FRAME, STACK_FRAME, CLASS_T);
343  }
344
345  static
346  {
347    StandardClass.initializeStandardClasses();
348  }
349}
Note: See TracBrowser for help on using the repository browser.