[cffi-devel] cffi changes are generating deprecation warning in cl-gd now

Jeff Cunningham jeffrey at jkcunningham.com
Mon Jan 27 23:42:24 UTC 2014


Hi;

A short while ago I started noticing this error message showing up

;; STYLE-WARNING:
;;    bare references to struct types are deprecated. Please use 
(:POINTER (:STRUCT CL-GD::GD-IMAGE))
;;    or (:STRUCT CL-GD::GD-IMAGE) instead.

It took me awhile to extract a simple demo case, but I've narrowed it 
down to the WITH-THICKNESS macro call I believe.
I'm not sure which list would be best for this question, so I 
cross-posted it.

Here's a test case.

(ql:quickload "cl-gd")
(use-package :cl-gd)

(let* ((x1 -86)
        (x2 529)
        (y1 -0.13)
        (y2 1.16)
        (xv '(0.0 1.0 2.0 3.0 4.0))
        (yv '(0.99 0.12 0.66 0.24 0.075)))
   (with-image* (500 250)
     (allocate-color 255 255 255)
     (let ((c (allocate-color 0 0 255)))
       (with-transformation (:x1 x1 :x2 x2 :y1 y1 :y2 y2)
         (with-thickness (1)
           (mapl #'(lambda (x y)
                     (when (and (cdr x) (cdr y))
                       (draw-line (car x) (car y) (cadr x) (cadr y) 
:color c))) xv yv))
         (write-image-to-file "test.png" :if-exists :supersede)))))

If you take out the with-thickness macro call the message disappears.

I played around with that macro but don't really understand enough about 
the intricacies of cffi to fix it.
Does anyone have any ideas? Here's the macro in question:

(defmacro with-thickness ((thickness &key (image '*default-image*)) 
&body body)
   "Executes BODY with the current line width of IMAGE set to
THICKNESS. The image's previous line width is guaranteed to be
restored before the macro exits. Note that the line width is measured
in pixels and is not affected by WITH-TRANSFORMATION."
   (cl-gd::with-unique-names (old-thickness)
     ;; we rebind everything so we have left-to-right evaluation
     (cl-gd::with-rebinding (thickness image)
       `(let ((,old-thickness (thickness ,image)))
          (unwind-protect
              (progn
                (setf (thickness ,image) ,thickness))
            , at body)
          (setf (thickness ,image) ,old-thickness)))))


Much obliged.

--Jeff Cunningham




More information about the cffi-devel mailing list