1 ;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*-
2 ;;;; *************************************************************************
3 ;;;; FILE IDENTIFICATION
5 ;;;; Name: cmucl-compat.sql
6 ;;;; Purpose: Compatiblity library for CMUCL functions
7 ;;;; Programmer: Kevin M. Rosenberg
8 ;;;; Date Started: Feb 2002
10 ;;;; $Id: cmucl-compat.lisp,v 1.2 2002/10/14 04:09:02 kevin Exp $
12 ;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg
14 ;;;; CLSQL users are granted the rights to distribute and use this software
15 ;;;; as governed by the terms of the Lisp Lesser GNU Public License
16 ;;;; (http://opensource.franz.com/preamble.html), also known as the LLGPL.
17 ;;;; *************************************************************************
19 (declaim (optimize (debug 3) (speed 3) (safety 1) (compilation-speed 0)))
22 (defpackage :cmucl-compat
26 #:make-sequence-of-type
30 (in-package :cmucl-compat)
33 (defmacro required-argument ()
34 `(ext:required-argument))
37 (defun required-argument ()
38 (error "~&A required keyword argument was not supplied"))
41 (defmacro shrink-vector (vec len)
42 `(lisp::shrink-vector ,vec ,len))
45 (defmacro shrink-vector (vec len)
46 `(sb-kernel::shrink-vector ,vec ,len))
49 (defmacro shrink-vector (vec len)
50 "Shrinks a vector. Optimized if vector has a fill pointer.
51 Needs to be a macro to overwrite value of VEC."
52 (let ((new-vec (gensym)))
54 ((adjustable-array-p ,vec)
55 (adjust-array ,vec ,len))
56 ((typep ,vec 'simple-array)
57 (let ((,new-vec (make-array ,len :element-type
58 (array-element-type ,vec))))
61 (setf (aref ,new-vec i) (aref ,vec i)))
62 (setq ,vec ,new-vec)))
64 (setf (fill-pointer ,vec) ,len)
67 (error "Unable to shrink vector ~S which is type-of ~S" ,vec (type-of ,vec)))
73 (defun make-sequence-of-type (type length)
74 "Returns a sequence of the given TYPE and LENGTH."
75 (declare (fixnum length))
79 ((bit-vector simple-bit-vector)
80 (make-array length :element-type '(mod 2)))
81 ((string simple-string base-string simple-base-string)
85 ((array simple-array vector)
87 (make-array length :element-type (cadr type))
90 (make-sequence-of-type (result-type-or-lose type t) length))))
94 (if (fboundp 'lisp::make-sequence-of-type)
95 (defun make-sequence-of-type (type len)
96 (lisp::make-sequence-of-type type len))
97 (defun make-sequence-of-type (type len)
98 (system::make-sequence-of-type type len)))
101 (defun make-sequence-of-type (type len)
102 (sb-impl::make-sequence-of-type type len))
105 (defun result-type-or-lose (type nil-ok)
106 (unless (or type nil-ok)
107 (error "NIL output type invalid for this sequence function"))
111 ((string simple-string base-string simple-base-string)
118 (error "~S is a bad type specifier for sequence functions." type))
122 (defun result-type-or-lose (type nil-ok)
123 (lisp::result-type-or-lose type nil-ok))
126 (defun result-type-or-lose (type nil-ok)
127 (sb-impl::result-type-or-lose type nil-ok))