X-Git-Url: https://git.distorted.org.uk/~mdw/sod/blobdiff_plain/1c1a9bf16b17e504b000c30b4653e34ddc6845d1..fae90f24a2c96dc8531adeeaba190a17b1044650:/doc/list-exports.lisp diff --git a/doc/list-exports.lisp b/doc/list-exports.lisp old mode 100644 new mode 100755 index eab4d54..65514d4 --- a/doc/list-exports.lisp +++ b/doc/list-exports.lisp @@ -1,7 +1,15 @@ +#! /bin/sh +":"; CL_SOURCE_REGISTRY=$(pwd)/build/src/:; export CL_SOURCE_REGISTRY +":"; exec cl-launch -X -l "sbcl cmucl" -s asdf -i "(sod-exports::main)" -- "$0" "$@" || exit 1 + (cl:defpackage #:sod-exports - (:use #:common-lisp)) + (:use #:common-lisp + #+cmu #:mop + #+sbcl #:sb-mop)) (cl:in-package #:sod-exports) +(eval-when (:compile-toplevel :load-toplevel :execute) + (mapc #'asdf:load-system '(:sod :sod-frontend))) (defun symbolicate (&rest things) (intern (apply #'concatenate 'string (mapcar #'string things)))) @@ -103,10 +111,10 @@ (defun specialized-on-p (func arg what) (some (lambda (method) - (let ((spec (nth arg (sb-mop:method-specializers method)))) - (and (typep spec 'sb-mop:eql-specializer) - (eql (sb-mop:eql-specializer-object spec) what)))) - (sb-mop:generic-function-methods func))) + (let ((spec (nth arg (method-specializers method)))) + (and (typep spec 'eql-specializer) + (eql (eql-specializer-object spec) what)))) + (generic-function-methods func))) (defun categorize (symbol) (let ((things nil)) @@ -191,7 +199,7 @@ (let ((done (make-hash-table))) (labels ((walk-up (class) (unless (gethash class done) - (dolist (super (sb-mop:class-direct-superclasses class)) + (dolist (super (class-direct-superclasses class)) (push class (gethash super subs)) (walk-up super)) (setf (gethash class done) t)))) @@ -205,7 +213,7 @@ (pretty-symbol-name (class-name class) package)) (remove super - (sb-mop:class-direct-superclasses this)))) + (class-direct-superclasses this)))) (dolist (sub (sort (copy-list (gethash this subs)) #'string< :key #'class-name)) (walk-down sub this (1+ depth))))) @@ -252,8 +260,8 @@ (deep-compare (la lb) (loop (typesw (null (return nil))) (focus (car it) - (typesw (sb-mop:eql-specializer - (focus (sb-mop:eql-specializer-object it) + (typesw (eql-specializer + (focus (eql-specializer-object it) (typesw (keyword (compare (string< left right))) (symbol @@ -277,9 +285,10 @@ (defun analyse-generic-functions (package) (setf package (find-package package)) (flet ((function-name-core (name) - (etypecase name - (symbol name) - ((cons (eql setf) t) (cadr name))))) + (typecase name + (symbol (values name t)) + ((cons (eql setf) t) (values (cadr name) t)) + (t (values nil nil))))) (let ((methods (make-hash-table)) (functions (make-hash-table)) (externs (make-hash-table))) @@ -289,7 +298,7 @@ (flet ((dofunc (func) (when (typep func 'generic-function) (setf (gethash func functions) t) - (dolist (method (sb-mop:generic-function-methods func)) + (dolist (method (generic-function-methods func)) (setf (gethash method methods) t))))) (dofunc (and (fboundp symbol) (fdefinition symbol))) (dofunc (ignore-errors (fdefinition (list 'setf symbol))))) @@ -297,13 +306,14 @@ (let ((class (find-class symbol nil))) (when class (dolist - (func (sb-mop:specializer-direct-generic-functions class)) - (let ((name (function-name-core - (sb-mop:generic-function-name func)))) - (when (or (not (eq (symbol-package name) package)) - (gethash name externs)) + (func (specializer-direct-generic-functions class)) + (multiple-value-bind (name knownp) + (function-name-core (generic-function-name func)) + (when (and knownp + (or (not (eq (symbol-package name) package)) + (gethash name externs))) (setf (gethash func functions) t) - (dolist (method (sb-mop:specializer-direct-methods class)) + (dolist (method (specializer-direct-methods class)) (setf (gethash method methods) t))))))))) (let ((funclist nil)) (maphash (lambda (func value) @@ -317,9 +327,9 @@ (if (eq core-a core-b) (and (atom a) (consp b)) (string< core-a core-b)))) - :key #'sb-mop:generic-function-name)) + :key #'generic-function-name)) (dolist (function funclist) - (let ((name (sb-mop:generic-function-name function))) + (let ((name (generic-function-name function))) (etypecase name (symbol (format t "~A~%" (pretty-symbol-name name package))) @@ -327,9 +337,9 @@ (format t "(setf ~A)~%" (pretty-symbol-name (cadr name) package))))) (dolist (method (sort (copy-list - (sb-mop:generic-function-methods function)) + (generic-function-methods function)) #'order-specializers - :key #'sb-mop:method-specializers)) + :key #'method-specializers)) (when (gethash method methods) (format t "~2T~{~A~^ ~}~%" (mapcar @@ -339,13 +349,13 @@ (let ((name (class-name spec))) (if (eq name t) "t" (pretty-symbol-name name package)))) - (sb-mop:eql-specializer - (let ((obj (sb-mop:eql-specializer-object spec))) + (eql-specializer + (let ((obj (eql-specializer-object spec))) (format nil "(eql ~A)" (if (symbolp obj) (pretty-symbol-name obj package) obj)))))) - (sb-mop:method-specializers method)))))))))) + (method-specializers method)))))))))) (defun check-slot-names (package) (setf package (find-package package)) @@ -358,8 +368,8 @@ (offenders (mapcan (lambda (class) (let* ((slot-names - (mapcar #'sb-mop:slot-definition-name - (sb-mop:class-direct-slots class))) + (mapcar #'slot-definition-name + (class-direct-slots class))) (exported (remove-if (lambda (sym) (and (not (exported-symbol-p sym)) @@ -436,7 +446,11 @@ (report-symbols (mapcar #'file-name (list optparse)) "OPTPARSE") (report-symbols (mapcar #'file-name (list utilities)) "SOD-UTILITIES")))) -#+interactive -(with-open-file (*standard-output* #p"doc/SYMBOLS" :direction :output - :if-exists :supersede :if-does-not-exist :create) - (report-project-symbols)) +(defun main () + (with-open-file (*standard-output* #p"doc/SYMBOLS" + :direction :output + :if-exists :supersede + :if-does-not-exist :create) + (report-project-symbols))) + +#+interactive (main)