1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
#!/bin/sh
exec rep "$0" "$@"
!#
;; build-dispatch
;; $Id: build-dispatch,v 1.2 2004/04/23 18:43:09 eich Exp $
;; $XFree86: $
;; Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
;; Permission is hereby granted, free of charge, to any person
;; obtaining a copy of this software and associated documentation files
;; (the "Software"), to deal in the Software without restriction,
;; including without limitation the rights to use, copy, modify, merge,
;; publish, distribute, sublicense, and/or sell copies of the Software,
;; and to permit persons to whom the Software is furnished to do so,
;; subject to the following conditions:
;; The above copyright notice and this permission notice shall be
;; included in all copies or substantial portions of the Software.
;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
;; NONINFRINGEMENT. IN NO EVENT SHALL THE THE ABOVE LISTED COPYRIGHT
;; HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
;; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
;; DEALINGS IN THE SOFTWARE.
;; Except as contained in this notice, the name(s) of the above
;; copyright holders shall not be used in advertising or otherwise to
;; promote the sale, use or other dealings in this Software without
;; prior written authorization.
;; This lisp script is used to build the C dispatch table from the
;; .defs file. It currently uses my (jsh's) rep interpreter. The
;; created file is checked into cvs, so it only needs to be run when
;; the .defs file is touched
(structure ()
(open rep
rep.regexp)
(defmacro @ args `(format standard-output ,@args))
(define stubs '())
(define (strip-args s)
(mapcar (lambda (x)
(and (string-match "[ \t\n*]+([a-zA-Z0-9_]+)$" x)
(expand-last-match "\\1")))
(string-split "," s)))
(@ "/* dri_dispatch.h -- built automatically, DO NOT EDIT\n $%s$\n $%s$ */\n\n" "Id" "XFree86: ")
(condition-case nil
(while t
(let* ((form (read standard-input))
(args (unless (string= (nth 3 form) "void")
(strip-args (nth 3 form))))
(internal (>= (nth 2 form) 0))
(alias (nth 4 form))
(prefix (if (eq (nth 0 form) 'void)
"_VOID \("
(format nil " \(%s, " (nth 0 form)))))
(when (or internal (not alias))
(@ "DEFUN_%s%s%s,\n (%s),\n (%s)\)\n\n"
(if internal "LOCAL" "EXTERN")
prefix
(nth 1 form)
(if (string= (nth 3 form) "void")
(if internal "void *rend" "")
(if internal (format nil "void *rend, %s" (nth 3 form)) (nth 3 form)))
(mapconcat identity args ", ")))
(when alias
(@ "DEFUN_ALIAS%s%s, %s,\n (%s),\n (%s)\)\n\n"
prefix (nth 1 form) alias (nth 3 form)
(mapconcat identity args ", ")))
(when internal
(setq stubs (cons form stubs)))))
(end-of-stream))
(setq stubs (nreverse stubs))
(@ "#define INDIRECT_DISPATCH_INIT(d,p) \\\n")
(@ "do { \\\n")
(setq stubs (sort stubs (lambda (a b)
(< (nth 2 a) (nth 2 b)))))
(let loop ((rest stubs))
(when rest
(let ((form (car rest)))
(@ " (d)[%s] = (void *) &p ## %s; \\\n" (nth 2 form) (nth 1 form)))
(loop (cdr rest))))
(@ "} while (0)\n"))
|