summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmamut.lisp20
1 files changed, 12 insertions, 8 deletions
diff --git a/cmamut.lisp b/cmamut.lisp
index 17b01c2..7017a93 100644
--- a/cmamut.lisp
+++ b/cmamut.lisp
@@ -261,6 +261,7 @@
(spec-functions spec))))
(remove-duplicates (concatenate 'list consts enums composite functions) :test #'equal))))
+; TODO: Export only the transformed symbols
(defun to-file (code filename pkg-name shared-object)
(with-open-file (f filename
:direction :output
@@ -270,15 +271,18 @@
(*print-level* nil)
(*print-pretty* t)
(*package* (find-package +target-package+)))
- (when shared-object
- (format f
- "(COMMON-LISP:LET ((LOADED? COMMON-LISP:NIL))~& (SB-ALIEN:LOAD-SHARED-OBJECT ~s)~& (COMMON-LISP:SETF LOADED? COMMON-LISP:T))~&"
- shared-object))
(when pkg-name
- (format f "(COMMON-LISP:DEFPACKAGE #:~a)~&" (string-upcase pkg-name))
- (format f "(COMMON-LISP:IN-PACKAGE #:~a)~&" (string-upcase pkg-name)))
- (format f "~{~s~&~}" code)
- (do-symbols (s *package*) (format f "(COMMON-LISP:EXPORT '~s)~&" s)))))
+ (format f "(COMMON-LISP:DEFPACKAGE #:~a~& (:EXPORT" (string-upcase pkg-name))
+ (do-symbols (s *package*) (format f "~& #:~s" s))
+ (format f "))~&(COMMON-LISP:IN-PACKAGE #:~a)~&" (string-upcase pkg-name)))
+ (when shared-object
+ (let ((loaded? (intern "LOADED?" +target-package+)))
+ (format f
+ "~s~&"
+ `(let ((,loaded? nil))
+ (sb-alien:load-shared-object ,shared-object)
+ (setf ,loaded? t)))))
+ (format f "~{~s~&~}" code))))
(defun filter-directories (search-directories raw-spec)
(remove-if (lambda (x)