This is the code from which the error message was thrown:

(define-values (callback-set! callback)
  (letrec ([signature/raw
            (foreign-lambda* c-string ([nonnull-ihandle handle]
[iname/upcase name])
              "C_return(iupClassCallbackGetFormat(handle->iclass, name));")]
           [set/pointer!
            (foreign-lambda c-pointer "IupSetCallback" nonnull-ihandle
iname/upcase c-pointer)]
           [get/pointer
            (foreign-lambda c-pointer "IupGetCallback" nonnull-ihandle
iname/upcase)]
           [sigils
            (irregex "([bifdsvh]*)(?:=([bifdvh]))?")]
           [callback-set!
            (lambda (handle name proc)
              (let* ([sig
                      (cond
                        [(irregex-match sigils (or (signature/raw handle
name) ""))
                         => (lambda (groups)
                              (string-append
                                (or (irregex-match-substring groups 2) "i")
                                (irregex-match-substring groups 1)))]
                        [else
                         (error 'callback-set! "callback has bad signature"
handle name)])]

Looking up iupClassCallbackGetFormat here:

http://webserver2.tecgraf.puc-rio.br/iup/doxygen/group__iclass.html#ga5733bfa0e0889ec4e4293c2a57205650

it looks like the cb-draw callback has format "iiiiiiC", which doesn't
match the sigil regex. I take it that means callbacks with a Canvas*
argument are unsupported in chicken-iup?

martin

On Wed, Oct 14, 2015 at 12:51 AM, Martin DeMello <[email protected]>
wrote:

> Hi,
>
> I'm trying to port the chessboard example from IUP to chicken. The C code
> is here:
>
> http://webserver2.tecgraf.puc-rio.br/iup/examples/C/cells_checkboard.c
>
> I'm stuck when trying to add a draw callback - it crashes with
>
> Error: (callback-set!) callback has bad signature
>
> The code is here:
> https://gist.github.com/martindemello/2f8ba4ccfebed3bd4650 or below:
>
> (use iup)
>
> (define (nlines self) 8)
> (define (ncols self) 8)
> (define (height self line) 50)
> (define (width self col) 50)
>
> (define (draw self i j xmin xmax ymin ymax canvas) 'default)
>
> (define dlg
>   (dialog
>     (vbox
>       (cells name: "Chessboard"
>              height-cb: height
>              width-cb: width
>              nlines-cb: nlines
>              ncols-cb: ncols
>              draw-cb: draw)
>       (button title: 'E&xit
>               expand: 'Yes
>               tip: "Close button"
>               action: (lambda (self) 'close)))
>     title: 'IUP))
>
> (show dlg)
> (main-loop)
> (destroy! dlg)
> (exit 0)
>
> martin
>
_______________________________________________
Chicken-users mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/chicken-users

Reply via email to