Mercurial > hg > xemacs-beta
annotate lisp/cl-compat.el @ 5038:9410323e4b0d
major dynarr fixes
-------------------- ChangeLog entries follow: --------------------
src/ChangeLog addition:
2010-02-20 Ben Wing <ben@xemacs.org>
* device-x.c (Fx_get_resource):
* dynarr.c:
* dynarr.c (Dynarr_realloc):
* dynarr.c (Dynarr_newf):
* dynarr.c (Dynarr_lisp_realloc):
* dynarr.c (Dynarr_lisp_newf):
* dynarr.c (Dynarr_resize):
* dynarr.c (Dynarr_insert_many):
* dynarr.c (Dynarr_delete_many):
* dynarr.c (Dynarr_memory_usage):
* dynarr.c (stack_like_free):
* file-coding.c (coding_reader):
* file-coding.c (gzip_convert):
* gutter.c (output_gutter):
* lisp.h:
* lisp.h (Dynarr_declare):
* lisp.h (DYNARR_SET_LISP_IMP):
* lisp.h (CHECK_NATNUM):
* profile.c (create_timing_profile_table):
* redisplay-output.c (sync_rune_structs):
* redisplay-output.c (sync_display_line_structs):
* redisplay-output.c (redisplay_output_window):
* redisplay.c:
* redisplay.c (get_display_block_from_line):
* redisplay.c (add_ichar_rune_1):
* redisplay.c (ensure_modeline_generated):
* redisplay.c (generate_displayable_area):
* redisplay.c (regenerate_window):
* redisplay.c (update_line_start_cache):
* signal.c:
* signal.c (check_quit):
Lots of rewriting of dynarr code.
(1) Lots of documentation added. Also fix places that
referenced a now-bogus internals node concerning redisplay
critical sections.
(2) Rename:
Dynarr_add_lisp_string -> Dynarr_add_ext_lisp_string
Dynarr_set_length -> Dynarr_set_lengthr ("restricted")
Dynarr_increment -> Dynarr_incrementr
Dynarr_resize_if -> Dynarr_resize_to_add
(3) New functions:
Dynarr_elsize = dy->elsize_
Dynarr_set_length(): Set length, resizing as necessary
Dynarr_set_length_and_zero(): Set length, resizing as necessary,
zeroing out new elements
Dynarr_increase_length(), Dynarr_increase_length_and_zero():
Optimization of Dynarr_set_length(), Dynarr_set_length_and_zero()
when size is known to increase
Dynarr_resize_to_fit(): Resize as necessary to fit a given length.
Dynarr_set(): Set element at a given position, increasing length
as necessary and setting any newly created positions to 0
(4) Use Elemcount, Bytecount.
(5) Rewrite many macros as inline functions.
author | Ben Wing <ben@xemacs.org> |
---|---|
date | Sat, 20 Feb 2010 03:46:22 -0600 |
parents | 8b50bee3c88c |
children | 2a54dfbe434f 308d34e9f07d |
rev | line source |
---|---|
613 | 1 ;;; cl-compat.el --- Common Lisp extensions for XEmacs Lisp (compatibility) |
209 | 2 |
3 ;; Copyright (C) 1993 Free Software Foundation, Inc. | |
4 | |
5 ;; Author: Dave Gillespie <daveg@synaptics.com> | |
6 ;; Version: 2.02 | |
7 ;; Keywords: extensions | |
8 | |
9 ;; This file is part of XEmacs. | |
10 | |
11 ;; XEmacs is free software; you can redistribute it and/or modify it | |
12 ;; under the terms of the GNU General Public License as published by | |
13 ;; the Free Software Foundation; either version 2, or (at your option) | |
14 ;; any later version. | |
15 | |
16 ;; XEmacs is distributed in the hope that it will be useful, but | |
17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
19 ;; General Public License for more details. | |
20 | |
21 ;; You should have received a copy of the GNU General Public License | |
22 ;; along with XEmacs; see the file COPYING. If not, write to the Free | |
23 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | |
24 ;; 02111-1307, USA. | |
25 | |
2153 | 26 ;;; Synched up with: FSF 21.3. |
209 | 27 |
28 ;;; Commentary: | |
29 | |
30 ;; These are extensions to Emacs Lisp that provide a degree of | |
31 ;; Common Lisp compatibility, beyond what is already built-in | |
32 ;; in Emacs Lisp. | |
33 ;; | |
34 ;; This package was written by Dave Gillespie; it is a complete | |
35 ;; rewrite of Cesar Quiroz's original cl.el package of December 1986. | |
36 ;; | |
37 ;; This package works with Emacs 18, Emacs 19, and XEmacs/Lucid Emacs 19. | |
38 ;; | |
39 ;; Bug reports, comments, and suggestions are welcome! | |
40 | |
41 ;; This file contains emulations of internal routines of the older | |
42 ;; CL package which users may have called directly from their code. | |
43 ;; Use (require 'cl-compat) to get these routines. | |
44 | |
45 ;; See cl.el for Change Log. | |
46 | |
47 | |
48 ;;; Code: | |
49 | |
50 ;; Require at load-time, but not when compiling cl-compat. | |
51 (or (featurep 'cl) (require 'cl)) | |
52 | |
53 | |
54 ;;; Keyword routines not supported by new package. | |
55 | |
56 (defmacro defkeyword (x &optional doc) | |
57 (list* 'defconst x (list 'quote x) (and doc (list doc)))) | |
58 | |
59 (defun keyword-of (sym) | |
4793
8b50bee3c88c
Remove attempted support for 1996-era emacs without self-quoting keywords.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4678
diff
changeset
|
60 (or (keywordp sym) (keywordp (read (format ":%s" sym))))) |
209 | 61 |
62 ;;; Routines for parsing keyword arguments. | |
63 | |
64 (defun build-klist (arglist keys &optional allow-others) | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
2153
diff
changeset
|
65 (let ((res (multiple-value-call 'mapcar* 'cons (unzip-lists arglist)))) |
209 | 66 (or allow-others |
67 (let ((bad (set-difference (mapcar 'car res) keys))) | |
68 (if bad (error "Bad keywords: %s not in %s" bad keys)))) | |
69 res)) | |
70 | |
71 (defun extract-from-klist (klist key &optional def) | |
72 (let ((res (assq key klist))) (if res (cdr res) def))) | |
73 | |
74 (defun keyword-argument-supplied-p (klist key) | |
75 (assq key klist)) | |
76 | |
77 (defun elt-satisfies-test-p (item elt klist) | |
78 (let ((test-not (cdr (assq ':test-not klist))) | |
79 (test (cdr (assq ':test klist))) | |
80 (key (cdr (assq ':key klist)))) | |
81 (if key (setq elt (funcall key elt))) | |
82 (if test-not (not (funcall test-not item elt)) | |
83 (funcall (or test 'eql) item elt)))) | |
84 | |
4678
b5e1d4f6b66f
Make #'floor, #'ceiling, #'round, #'truncate conform to Common Lisp.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4677
diff
changeset
|
85 ;; The rounding functions in C now have all the functionality this package |
b5e1d4f6b66f
Make #'floor, #'ceiling, #'round, #'truncate conform to Common Lisp.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4677
diff
changeset
|
86 ;; used to: |
b5e1d4f6b66f
Make #'floor, #'ceiling, #'round, #'truncate conform to Common Lisp.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4677
diff
changeset
|
87 (loop |
b5e1d4f6b66f
Make #'floor, #'ceiling, #'round, #'truncate conform to Common Lisp.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4677
diff
changeset
|
88 for symbol in '(floor ceiling round truncate) |
b5e1d4f6b66f
Make #'floor, #'ceiling, #'round, #'truncate conform to Common Lisp.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4677
diff
changeset
|
89 do (defalias (intern (format "cl-%s" symbol)) symbol)) |
209 | 90 |
91 (defun safe-idiv (a b) | |
92 (let* ((q (/ (abs a) (abs b))) | |
93 (s (* (signum a) (signum b)))) | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
2153
diff
changeset
|
94 (values q (- a (* s q b)) s))) |
209 | 95 |
96 ;; Internal routines. | |
97 | |
98 (defun pair-with-newsyms (oldforms) | |
99 (let ((newsyms (mapcar (function (lambda (x) (gensym))) oldforms))) | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
2153
diff
changeset
|
100 (values (mapcar* 'list newsyms oldforms) newsyms))) |
209 | 101 |
102 (defun zip-lists (evens odds) | |
103 (mapcan 'list evens odds)) | |
104 | |
105 (defun unzip-lists (list) | |
106 (let ((e nil) (o nil)) | |
107 (while list | |
108 (setq e (cons (car list) e) o (cons (cadr list) o) list (cddr list))) | |
4677
8f1ee2d15784
Support full Common Lisp multiple values in C.
Aidan Kehoe <kehoea@parhasard.net>
parents:
2153
diff
changeset
|
109 (values (nreverse e) (nreverse o)))) |
209 | 110 |
111 (defun reassemble-argslists (list) | |
112 (let ((n (apply 'min (mapcar 'length list))) (res nil)) | |
113 (while (>= (setq n (1- n)) 0) | |
114 (setq res (cons (mapcar (function (lambda (x) (elt x n))) list) res))) | |
115 res)) | |
116 | |
117 (defun duplicate-symbols-p (list) | |
118 (let ((res nil)) | |
119 (while list | |
120 (if (memq (car list) (cdr list)) (setq res (cons (car list) res))) | |
121 (setq list (cdr list))) | |
122 res)) | |
123 | |
124 | |
125 ;;; Setf internals. | |
126 | |
127 (defun setnth (n list x) | |
128 (setcar (nthcdr n list) x)) | |
129 | |
130 (defun setnthcdr (n list x) | |
131 (setcdr (nthcdr (1- n) list) x)) | |
132 | |
133 (defun setelt (seq n x) | |
134 (if (consp seq) (setcar (nthcdr n seq) x) (aset seq n x))) | |
135 | |
136 | |
137 ;;; Functions omitted: case-clausify, check-do-stepforms, check-do-endforms, | |
138 ;;; extract-do-inits, extract-do[*]-steps, select-stepping-forms, | |
139 ;;; elt-satisfies-if[-not]-p, with-keyword-args, mv-bind-clausify, | |
140 ;;; all names with embedded `$'. | |
141 | |
142 | |
143 (provide 'cl-compat) | |
144 | |
2153 | 145 ;;; arch-tag: 9996bb4f-aaf5-4592-b436-bf64759a3163 |
209 | 146 ;;; cl-compat.el ends here |