[plt-scheme] Questions about modules, compilation, namespaces, planet and ffi

From: Eli Barzilay (eli at barzilay.org)
Date: Sun May 8 22:13:02 EDT 2005

[Sorry for not replying when you first posted this...]

On May  5, Bruno Deferrari wrote:
> 
> * The first one: mzscheme crashes when loading this lib (it only
>   happens with this lib, an only from mzscheme, on mred it loads it
>   without crashing).  I'm running plt-scheme 299.100.
> 
> [...]
> ; gdb output
> #0  0x49c157a5 in __pthread_unlock () from /lib/libpthread.so.0
> [...]

This seems like some threading issue.  I can't say more so I won't...


> * The second one: I have problems with callbacks, I cant get them to
>   work.  This code for example, I hava a callback thats going to be
>   called when the window is rezised (resize-cb), but when that
>   happens, the program stops with an error.
> 
> ...
> (define (resize-cb ee) ; the func called when the win is resized
>   (display "a\n"))
> ...
> (ecore-evas-callback-resize-set ee resize-cb) ; I set the callback
> ...
> (ecore-main-loop-begin) ; I start the main loop
> 
>   Then when I resize the window resize-cb gets called, and after it
>   prints "a" it stops giving the following error:
> 
> Scheme->C: expects argument of type <non-void-C-type>; given #<ctype>

That's a known problem, and I'll fix it at some point.  The problem is
that it tries to convert the void result to a Scheme value, but there
is no void value to convert.  The naive temporary solution is to
simply use _int for the return value of the callback function -- the
calling C code doesn't expect a return value so there's no harm done.
A slightly better temporary solution is to create a new _void type
that `translates' any Scheme object to a 0 _int value.  Obviously, the
fix in the C code should be simple but I want to see what's the right
way to do this with libffi (in case there is some weird platform where
a void return value means different code from an int return value).


On May  8, Bruno Deferrari wrote:
> Well, after looking at foreign.c I found that on ffi_do_callback the
> return value's type isn't compared with _void before calling
> scheme_to_c.  If the type is _void, scheme_to_c will always fail.

... and from the above explanation:

> Is this whats wrong??

Probably, and will require some care in making it work with _void by
avoiding the scheme_to_c call completely.

> or is it simply wrong to have a _void return type on callbacks??

That's the way things currently stand, but it should be fixed.

-- 
          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                  http://www.barzilay.org/                 Maze is Life!



Posted on the users mailing list.