Skip to content

Commit

Permalink
Mother-package
Browse files Browse the repository at this point in the history
  • Loading branch information
borodust committed Dec 9, 2016
1 parent aa7346a commit 533b469
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 11 deletions.
3 changes: 2 additions & 1 deletion cl-bodge.asd
Original file line number Diff line number Diff line change
Expand Up @@ -283,4 +283,5 @@
:license "MIT"
:depends-on (cl-bodge/engine cl-bodge/utils cl-bodge/events cl-bodge/host
cl-bodge/graphics cl-bodge/audio cl-bodge/physics
cl-bodge/resources cl-bodge/assets cl-bodge/scenegraph))
cl-bodge/resources cl-bodge/assets cl-bodge/scenegraph)
:components ((:file "packages")))
3 changes: 1 addition & 2 deletions engine/packages.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,7 @@

(defpackage :cl-bodge.engine
(:nicknames :ge.ng)
(:use :cl-bodge.utils :cl-bodge.concurrency :cl-bodge.memory :cl-bodge.math
:cl :bordeaux-threads :cl-muth)
(:use :cl-bodge.utils :cl :bordeaux-threads :cl-muth)
(:export system
enable
disable
Expand Down
18 changes: 18 additions & 0 deletions packages.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
(in-package :cl-bodge.asdf)



(ge.util:reexporting (:cl-bodge.animation
:cl-bodge.assets
:cl-bodge.audio
:cl-bodge.audio.resources
:cl-bodge.engine
:cl-bodge.event
:cl-bodge.graphics
:cl-bodge.graphics.resources
:cl-bodge.host
:cl-bodge.physics
:cl-bodge.resources
:cl-bodge.scene) :cl-bodge
(defpackage :cl-bodge
(:nicknames :ge)))
25 changes: 17 additions & 8 deletions utils/utils.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -213,11 +213,20 @@
(defmacro reexporting ((&rest from-packages) into-package &body body)
(with-gensyms (p sym fn)
`(eval-when (:compile-toplevel :load-toplevel :execute)
(flet ((for-each-exported-symbol (,fn)
(dolist (,p ',from-packages)
(loop for ,sym being the external-symbol in ,p do
(funcall ,fn ,sym ,into-package)))))
(when (find-package ,into-package)
(for-each-exported-symbol #'unexport))
,@body
(for-each-exported-symbol #'export)))))
(labels ((accessiblep (,sym)
(find-symbol (symbol-name ,sym) ,into-package))
(unexport-if-accessible (,sym)
(when (accessiblep ,sym)
(unexport ,sym ,into-package)))
(import-export (,sym)
(unless (accessiblep ,sym)
(import ,sym ,into-package))
(export ,sym ,into-package))
(for-each-exported-symbol (,fn)
(dolist (,p ',from-packages)
(loop for ,sym being the external-symbol in ,p do
(funcall ,fn ,sym)))))
(when (find-package ,into-package)
(for-each-exported-symbol #'unexport-if-accessible))
,@body
(for-each-exported-symbol #'import-export)))))

0 comments on commit 533b469

Please sign in to comment.