Permalink
Browse files

Moved error code to its own package.

  • Loading branch information...
1 parent d6ccb5b commit 14d72beb79b8badee5309457fc45275dc2ff11f8 @Ralith Ralith committed with Josh Marchán Jan 18, 2010
Showing with 74 additions and 53 deletions.
  1. +4 −3 cl-devil.asd
  2. +2 −46 il.lisp
  3. +68 −4 package.lisp
View
@@ -5,8 +5,9 @@
:depends-on (:cffi :anaphora :alexandria)
:components
((:file "package")
- (:file "il" :depends-on ("package"))
- (:file "ilu" :depends-on ("package" "il"))
- (:file "ilut" :depends-on ("package" "il"))
+ (:file "internal")
+ (:file "il" :depends-on ("package" "internal"))
+ (:file "ilu" :depends-on ("package" "internal" "il"))
+ (:file "ilut" :depends-on ("package" "internal" "il"))
(:file "utilities" :depends-on ("package" "il"))))
View
48 il.lisp
@@ -75,42 +75,7 @@
(:bgr32 #x0405)
(:bgra32 #x0406))
-(define-condition devil-error (cl:error)
- ((enum-value :initarg :enum-value :reader enum-value)))
-(macrolet ((deferrs (&rest keys)
- `(progn
- (defcenum error ,@keys)
- ,@(loop for (key value) in keys collecting
- (let ((symbol (intern (symbol-name key))))
- `(define-condition ,symbol (devil-error) ()
- (:default-initargs :enum-value ,key)))))))
- (deferrs
- (:no-error #x0000)
- (:invalid-enum #x0501)
- (:out-of-memory #x0502)
- (:format-not-supported #x0503)
- (:internal-error #x0504)
- (:invalid-value #x0505)
- (:illegal-operation #x0506)
- (:illegal-file-value #x0507)
- (:invalid-file-header #x0508)
- (:invalid-param #x0509)
- (:could-not-open-file #x050A)
- (:invalid-extension #x050B)
- (:file-already-exists #x050C)
- (:out-format-same #x050D)
- (:stack-overflow #x050E)
- (:stack-underflow #x050F)
- (:invalid-conversion #x0510)
- (:bad-dimensions #x0511)
- (:file-read-error #x0512)
- (:file-write-error #x0512)
- (:lib-gif-error #x05E1)
- (:lib-jpeg-error #x05E2)
- (:lib-png-error #x05E3)
- (:lib-tiff-error #x05E4)
- (:lib-mng-error #x05E5)
- (:unknown-error #x05FF)))
+;;; See internal.lisp for error enum
(defcenum mode
(:file-overwrite #x0620)
@@ -158,15 +123,6 @@
`(with-foreign-string (,var (if (pathnamep ,value) (namestring ,value) ,value))
,@body)))
-(defmacro maybe-error (call)
- `(if ,call
- (values)
- (cl:error (make-condition (find-symbol (symbol-name (get-error)) (find-package :il))))))
-
-(defmacro deferrwrap (name &optional args)
- `(defun ,name ,args
- (maybe-error (,(symbolicate "%" (symbol-name name)) ,@args))))
-
(defcfun ("ilInit" init) :void)
(defcfun ("ilShutDown" shutdown) :void)
(defcfun ("ilGenImages" %gen-images) :void (num :int) (images :pointer))
@@ -220,7 +176,7 @@
(deferrwrap overlay-image (source x y z))
(defcfun ("ilBlit" %blit) :boolean (source :uint) (dest-x :int) (dest-y :int) (dest-z :int) (src-x :int) (src-y :int) (src-z :int) (width :uint) (height :uint) (depth :uint))
(deferrwrap blit (source dest-x dest-y dest-z src-x src-y src-z width height depth))
-(defcfun ("ilGetError" get-error) error)
+(defcfun ("ilGetError" get-error) %il:error)
(defcfun ("ilKeyColour" key-color) :void (red :float) (green :float) (blue :float) (alpha :float))
(defcfun ("ilGetPalette" get-palette) :pointer)
View
@@ -1,7 +1,41 @@
+(defpackage #:%cl-devil-internal
+ (:nicknames #:%il)
+ (:use #:cl #:cffi #:alexandria)
+ (:shadow #:error)
+ (:export
+ #:deferrwrap
+ #:error
+ #:devil-error
+ #:no-error
+ #:invalid-enum
+ #:out-of-memory
+ #:format-not-supported
+ #:internal-error
+ #:invalid-value
+ #:illegal-operation
+ #:illegal-file-value
+ #:invalid-file-header
+ #:invalid-param
+ #:could-not-open-file
+ #:invalid-extension
+ #:file-already-exists
+ #:out-format-same
+ #:stack-overflow
+ #:stack-underflow
+ #:invalid-conversion
+ #:bad-dimensions
+ #:file-read-error
+ #:file-write-error
+ #:lib-gif-error
+ #:lib-jpeg-error
+ #:lib-png-error
+ #:lib-tiff-error
+ #:lib-mng-error
+ #:unknown-error))
(defpackage #:cl-devil
(:nicknames #:il)
- (:use #:cl #:cffi #:anaphora #:alexandria)
+ (:use #:cl #:cffi #:anaphora #:%il)
(:shadow #:load #:error)
(:export
#:with-bound-image
@@ -28,7 +62,6 @@
#:GEN-IMAGES
#:GEN-IMAGE
#:GET-DATA
- #:GET-ERROR
#:GET-INTEGER
#:GET-PALETTE
#:REGISTER-PALETTE
@@ -49,10 +82,40 @@
#:SET-PIXELS
#:SHUTDOWN
#:TEX-IMAGE
+ ;; Errors from internal
+ #:error
+ #:devil-error
+ #:no-error
+ #:invalid-enum
+ #:out-of-memory
+ #:format-not-supported
+ #:internal-error
+ #:invalid-value
+ #:illegal-operation
+ #:illegal-file-value
+ #:invalid-file-header
+ #:invalid-param
+ #:could-not-open-file
+ #:invalid-extension
+ #:file-already-exists
+ #:out-format-same
+ #:stack-overflow
+ #:stack-underflow
+ #:invalid-conversion
+ #:bad-dimensions
+ #:file-read-error
+ #:file-write-error
+ #:lib-gif-error
+ #:lib-jpeg-error
+ #:lib-png-error
+ #:lib-tiff-error
+ #:lib-mng-error
+ #:unknown-error
))
(defpackage #:ilu
- (:use #:cl #:cffi)
+ (:use #:cl #:cffi #:%il)
+ (:shadow #:error)
(:export
:init
:alienify
@@ -92,7 +155,8 @@
))
(defpackage #:ilut
- (:use #:cl #:cffi)
+ (:use #:cl #:cffi #:%il)
+ (:shadow #:error)
(:export
#:CONVERT-TO-SDL-SURFACE
#:DISABLE

0 comments on commit 14d72be

Please sign in to comment.