Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Moved errors back into package cl-devil and renamed the error enum an…

…d base class.
  • Loading branch information...
commit fc314d2d13f6d5b13dd29035e178029cf2360ec7 1 parent 85dc3ec
@Ralith Ralith authored Josh Marchán committed
Showing with 41 additions and 72 deletions.
  1. +1 −1  cl-devil.asd
  2. +37 −2 il.lisp
  3. +1 −1  ilu.lisp
  4. +0 −37 internal.lisp
  5. +2 −31 package.lisp
View
2  cl-devil.asd
@@ -5,7 +5,7 @@
:depends-on (#:cffi #:alexandria)
:components
((:file "package")
- (:file "internal")
+ (:file "internal" :depends-on ("package"))
(:file "il" :depends-on ("package" "internal"))
(:file "ilu" :depends-on ("package" "internal" "il"))
(:file "ilut" :depends-on ("package" "internal" "il"))
View
39 il.lisp
@@ -75,7 +75,42 @@
(:bgr32 #x0405)
(:bgra32 #x0406))
-;;; See internal.lisp for error enum
+(define-condition error (cl:error)
+ ((enum-value :initarg :enum-value :reader enum-value)))
+(macrolet ((deferrs (&rest keys)
+ `(progn
+ (defcenum error-enum ,@keys)
+ ,@(loop for (key value) in keys collecting
+ (let ((symbol (intern (symbol-name key))))
+ `(define-condition ,symbol (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)))
(defcenum mode
(:file-overwrite #x0620)
@@ -176,7 +211,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) %il:error)
+(defcfun ("ilGetError" get-error) error-enum)
(defcfun ("ilKeyColour" key-color) :void (red :float) (green :float) (blue :float) (alpha :float))
(defcfun ("ilGetPalette" get-palette) :pointer)
View
2  ilu.lisp
@@ -78,7 +78,7 @@
(width :uint) (height :uint) (depth :uint))
(deferrwrap enlarge-canvas (width height depth))
(defcfun ("iluErrorString" error-string) :string
- (error %il:error))
+ (error il::error-enum))
(defcfun ("iluFlipImage" %flip-image) :boolean)
(deferrwrap flip-image)
(defcfun ("iluGammaCorrect" %gamma-correct) :boolean (gamma :float))
View
37 internal.lisp
@@ -1,42 +1,5 @@
(in-package :%il)
-(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)))
-
(defmacro maybe-error (call)
`(if ,call
(values)
View
33 package.lisp
@@ -1,38 +1,10 @@
(defpackage #:%cl-devil-internal
(:nicknames #:%il)
- (:use #:cl #:cffi #:alexandria)
+ (:use #:cl #:alexandria)
(:shadow #:error)
(:export
#:maybe-error
- #: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))
+ #:deferrwrap))
(defpackage #:cl-devil
(:nicknames #:il)
@@ -85,7 +57,6 @@
#:TEX-IMAGE
;; Errors from internal
#:error
- #:devil-error
#:no-error
#:invalid-enum
#:out-of-memory
Please sign in to comment.
Something went wrong with that request. Please try again.