summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuan Manuel Tomás <jtomas1815@gmail.com>2023-07-24 16:16:21 -0300
committerJuan Manuel Tomás <jtomas1815@gmail.com>2023-07-24 16:16:21 -0300
commitdeca718bea1610759128688e5975bf58c6f11c36 (patch)
treedbba3ea6dd46ff72e3b7ea8f58ab3d10bca03078
parent26431ac7e12541c70bdb30fd880f3b83e76051ce (diff)
downloadcmamut-deca718bea1610759128688e5975bf58c6f11c36.tar.gz
cmamut-deca718bea1610759128688e5975bf58c6f11c36.zip
Export symbols within the defpackage form
-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)