Skip to content

Commit

Permalink
Refactor core package definitions
Browse files Browse the repository at this point in the history
Coalesced all definitions of :cffi-sys into one.
Moved all packages (cffi-sys, cffi, cffi-callbacks) into package.lisp,
which now becomes the first file in the system.
Moved the compiler-macro utils to sys-utils.lisp, part of cffi-sys,
then export CONSTANT-FORM-P and CONSTANT-FORM-VALUE.
  • Loading branch information
sionescu committed Nov 8, 2022
1 parent af33f6e commit 8629618
Show file tree
Hide file tree
Showing 19 changed files with 173 additions and 562 deletions.
5 changes: 3 additions & 2 deletions cffi.asd
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@
((:module "src"
:serial t
:components
((:file "cffi-openmcl" :if-feature :openmcl)
((:file "package")
(:file "sys-utils")
(:file "cffi-openmcl" :if-feature :openmcl)
(:file "cffi-mcl" :if-feature :mcl)
(:file "cffi-sbcl" :if-feature :sbcl)
(:file "cffi-cmucl" :if-feature :cmucl)
Expand All @@ -56,7 +58,6 @@
(:file "cffi-abcl" :if-feature :abcl)
(:file "cffi-mkcl" :if-feature :mkcl)
(:file "cffi-clasp" :if-feature :clasp)
(:file "package")
(:file "utils")
(:file "libraries")
(:file "early-types")
Expand Down
38 changes: 0 additions & 38 deletions src/cffi-abcl.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -32,49 +32,11 @@
;;; JNA may be automatically loaded into the current JVM process from
;;; abcl-1.1.0-dev via the contrib mechanism.

(eval-when (:compile-toplevel :load-toplevel :execute)
(require :abcl-contrib)
(require :jna)
(require :jss))

;;; This is a preliminary version that will have to be cleaned up,
;;; optimized, etc. Nevertheless, it passes all of the relevant CFFI
;;; tests except MAKE-POINTER.HIGH. Shareable Vectors are not
;;; implemented yet.

;;;# Administrivia

(defpackage #:cffi-sys
(:use #:cl #:java)
(:import-from #:alexandria #:hash-table-values #:length= #:format-symbol)
(:export
#:canonicalize-symbol-name-case
#:foreign-pointer
#:pointerp
#:pointer-eq
#:null-pointer
#:null-pointer-p
#:inc-pointer
#:make-pointer
#:pointer-address
#:%foreign-alloc
#:foreign-free
#:with-foreign-pointer
#:%foreign-funcall
#:%foreign-funcall-pointer
#:%foreign-type-alignment
#:%foreign-type-size
#:%load-foreign-library
#:%close-foreign-library
#:native-namestring
#:%mem-ref
#:%mem-set
#:%foreign-symbol-pointer
#:%defcallback
#:%callback
#:with-pointer-to-vector-data
#:make-shareable-byte-vector))

(in-package #:cffi-sys)

;;;# Loading and Closing Foreign Libraries
Expand Down
38 changes: 0 additions & 38 deletions src/cffi-allegro.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -25,40 +25,6 @@
;;; DEALINGS IN THE SOFTWARE.
;;;

;;;# Administrivia

(defpackage #:cffi-sys
(:use #:common-lisp)
(:import-from #:alexandria #:if-let #:with-unique-names #:once-only)
(:export
#:canonicalize-symbol-name-case
#:foreign-pointer
#:pointerp
#:pointer-eq
#:null-pointer
#:null-pointer-p
#:inc-pointer
#:make-pointer
#:pointer-address
#:%foreign-alloc
#:foreign-free
#:with-foreign-pointer
#:%foreign-funcall
#:%foreign-funcall-pointer
#:%foreign-type-alignment
#:%foreign-type-size
#:%load-foreign-library
#:%close-foreign-library
#:native-namestring
#:%mem-ref
#:%mem-set
#:make-shareable-byte-vector
#:with-pointer-to-vector-data
#:%foreign-symbol-pointer
#:defcfun-helper-forms
#:%defcallback
#:%callback))

(in-package #:cffi-sys)

;;;# Mis-features
Expand Down Expand Up @@ -371,10 +337,6 @@ WITH-POINTER-TO-VECTOR-DATA."
(eval-when (:load-toplevel :execute)
(pushnew 'restore-callbacks excl:*restart-actions*))

;;; Create a package to contain the symbols for callback functions.
(defpackage #:cffi-callbacks
(:use))

(defun intern-callback (name)
(intern (format nil "~A::~A"
(if-let (package (symbol-package name))
Expand Down
32 changes: 0 additions & 32 deletions src/cffi-clasp.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -25,38 +25,6 @@
;;; DEALINGS IN THE SOFTWARE.
;;;

;;;# Administrivia

(defpackage #:cffi-sys
(:use #:common-lisp #:alexandria)
(:export
#:canonicalize-symbol-name-case
#:foreign-pointer
#:pointerp
#:pointer-eq
#:%foreign-alloc
#:foreign-free
#:with-foreign-pointer
#:null-pointer
#:null-pointer-p
#:inc-pointer
#:make-pointer
#:pointer-address
#:%mem-ref
#:%mem-set
#:%foreign-funcall
#:%foreign-funcall-pointer
#:%foreign-type-alignment
#:%foreign-type-size
#:%load-foreign-library
#:%close-foreign-library
#:native-namestring
#:make-shareable-byte-vector
#:with-pointer-to-vector-data
#:%defcallback
#:%callback
#:%foreign-symbol-pointer))

(in-package #:cffi-sys)

;;;# Mis-features
Expand Down
32 changes: 0 additions & 32 deletions src/cffi-clisp.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -26,38 +26,6 @@
;;; DEALINGS IN THE SOFTWARE.
;;;

;;;# Administrivia

(defpackage #:cffi-sys
(:use #:common-lisp #:alexandria)
(:export
#:canonicalize-symbol-name-case
#:foreign-pointer
#:pointerp
#:pointer-eq
#:null-pointer
#:null-pointer-p
#:inc-pointer
#:make-pointer
#:pointer-address
#:%foreign-alloc
#:foreign-free
#:with-foreign-pointer
#:%foreign-funcall
#:%foreign-funcall-pointer
#:%foreign-type-alignment
#:%foreign-type-size
#:%load-foreign-library
#:%close-foreign-library
#:native-namestring
#:%mem-ref
#:%mem-set
#:make-shareable-byte-vector
#:with-pointer-to-vector-data
#:%foreign-symbol-pointer
#:%defcallback
#:%callback))

(in-package #:cffi-sys)

(eval-when (:compile-toplevel :load-toplevel :execute)
Expand Down
39 changes: 0 additions & 39 deletions src/cffi-cmucl.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -25,39 +25,6 @@
;;; DEALINGS IN THE SOFTWARE.
;;;

;;;# Administrivia

(defpackage #:cffi-sys
(:use #:common-lisp #:alien #:c-call)
(:import-from #:alexandria #:once-only #:with-unique-names #:if-let)
(:export
#:canonicalize-symbol-name-case
#:foreign-pointer
#:pointerp
#:pointer-eq
#:null-pointer
#:null-pointer-p
#:inc-pointer
#:make-pointer
#:pointer-address
#:%foreign-alloc
#:foreign-free
#:with-foreign-pointer
#:%foreign-funcall
#:%foreign-funcall-pointer
#:%foreign-type-alignment
#:%foreign-type-size
#:%load-foreign-library
#:%close-foreign-library
#:native-namestring
#:%mem-ref
#:%mem-set
#:make-shareable-byte-vector
#:with-pointer-to-vector-data
#:%foreign-symbol-pointer
#:%defcallback
#:%callback))

(in-package #:cffi-sys)

;;;# Misfeatures
Expand Down Expand Up @@ -287,12 +254,6 @@ WITH-POINTER-TO-VECTOR-DATA."

(defvar *callbacks* (make-hash-table))

;;; Create a package to contain the symbols for callback functions. We
;;; want to redefine callbacks with the same symbol so the internal data
;;; structures are reused.
(defpackage #:cffi-callbacks
(:use))

;;; Intern a symbol in the CFFI-CALLBACKS package used to name the internal
;;; callback for NAME.
(eval-when (:compile-toplevel :load-toplevel :execute)
Expand Down
32 changes: 0 additions & 32 deletions src/cffi-corman.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -29,38 +29,6 @@
;;; is too funky with ASDF, crashes easily, makes it very painful to
;;; do any testing. -- luis

;;;# Administrivia

(defpackage #:cffi-sys
(:use #:common-lisp #:c-types)
(:import-from #:alexandria #:with-unique-names)
(:export
#:canonicalize-symbol-name-case
#:foreign-pointer
#:pointerp
#:pointer-eq
#:null-pointer
#:null-pointer-p
#:inc-pointer
#:make-pointer
#:pointer-address
#:%foreign-alloc
#:foreign-free
#:with-foreign-pointer
#:%foreign-funcall
#:%foreign-type-alignment
#:%foreign-type-size
#:%load-foreign-library
#:native-namestring
#:%mem-ref
#:%mem-set
;#:make-shareable-byte-vector
;#:with-pointer-to-vector-data
#:foreign-symbol-pointer
#:defcfun-helper-forms
#:%defcallback
#:%callback))

(in-package #:cffi-sys)

;;;# Misfeatures
Expand Down
42 changes: 0 additions & 42 deletions src/cffi-ecl.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -25,42 +25,6 @@
;;; DEALINGS IN THE SOFTWARE.
;;;

;;;# Administrivia

(defpackage #:cffi-sys
(:use #:common-lisp #:alexandria)
(:import-from #:si #:null-pointer-p)
(:export
#:*cffi-ecl-method*
#:canonicalize-symbol-name-case
#:foreign-pointer
#:pointerp
#:pointer-eq
#:%foreign-alloc
#:foreign-free
#:with-foreign-pointer
#:null-pointer
#:null-pointer-p
#:inc-pointer
#:make-pointer
#:pointer-address
#:%mem-ref
#:%mem-set
#:%foreign-funcall
#:%foreign-funcall-pointer
#:%foreign-funcall-varargs
#:%foreign-funcall-pointer-varargs
#:%foreign-type-alignment
#:%foreign-type-size
#:%load-foreign-library
#:%close-foreign-library
#:native-namestring
#:make-shareable-byte-vector
#:with-pointer-to-vector-data
#:%defcallback
#:%callback
#:%foreign-symbol-pointer))

(in-package #:cffi-sys)

;;;
Expand Down Expand Up @@ -403,12 +367,6 @@ WITH-POINTER-TO-VECTOR-DATA."

;;;# Callbacks

;;; Create a package to contain the symbols for callback functions.
;;; We want to redefine callbacks with the same symbol so the internal
;;; data structures are reused.
(defpackage #:cffi-callbacks
(:use))

(defvar *callbacks* (make-hash-table))

;;; Intern a symbol in the CFFI-CALLBACKS package used to name the
Expand Down
24 changes: 0 additions & 24 deletions src/cffi-gcl.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -39,30 +39,6 @@
;;; *** this port is broken ***
;;; gcl doesn't compile the rest of CFFI anyway..

;;;# Administrivia

(defpackage #:cffi-sys
(:use #:common-lisp #:alexandria)
(:export
#:canonicalize-symbol-name-case
#:pointerp
#:%foreign-alloc
#:foreign-free
#:with-foreign-ptr
#:null-ptr
#:null-ptr-p
#:inc-ptr
#:%mem-ref
#:%mem-set
#:%foreign-funcall
#:%foreign-type-alignment
#:%foreign-type-size
#:%load-foreign-library
;#:make-shareable-byte-vector
;#:with-pointer-to-vector-data
#:foreign-var-ptr
#:make-callback))

(in-package #:cffi-sys)

;;;# Mis-*features*
Expand Down

0 comments on commit 8629618

Please sign in to comment.