[Chicken-users] ffi howto

2014-11-21 Thread chicken-users
Hello,

I need some help getting started with ffi. 

I am attempting to bind libuv to scheme code.

My chicken scheme code at http://pastebin.com/bwja0yet fails with the
following error.

The following code fails with the following:

Error: bad argument count - received 152135942 but expected 2: 0

Call history:

uv.scm:33: uv-default-loop
uv.scm:33: uv-idle-init   
uv.scm:34: uv-idle-start  
uv.scm:36: uv-default-loop
uv.scm:36: uv-run   --


I am attempting to port the following C code.

http://pastebin.com/63gP8HFT

- Omar

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] ffi howto

2014-11-21 Thread Richard

Hello Omar,

The problem with your code is that wait-for-a-while must be declared as
an external function; like so:

(define-external
  (wait_for_a_while ((c-pointer uv-idle-t) handle))
  void
  (let lp ((counter 0))
(if (= counter 1000)
(uv-idle-stop handle)
(lp (+ counter 1)

note that the name of the function must be a valid C function name, so
it cannot be dash-seperated. Also looking at the libub documentation,
the callback did not have a status argument.

An external function that is going to call such a callback function must
be declared using 'foreign-safe-lambda' instead of
'foreign-lambda'. Thus uv-run must be declared as such:

(define uv-run
  (foreign-safe-lambda int uv_run (c-pointer uv-loop-t) int))

Hope this helps and good luck,
Richard


chicken-us...@shorbaji.com writes:

 Hello,

 I need some help getting started with ffi. 

 I am attempting to bind libuv to scheme code.

 My chicken scheme code at http://pastebin.com/bwja0yet fails with the
 following error.

 The following code fails with the following:

 Error: bad argument count - received 152135942 but expected 2: 0

   Call history:

   uv.scm:33: uv-default-loop
   uv.scm:33: uv-idle-init   
   uv.scm:34: uv-idle-start  
   uv.scm:36: uv-default-loop
   uv.scm:36: uv-run   --


 I am attempting to port the following C code.

 http://pastebin.com/63gP8HFT

 - Omar

 ___
 Chicken-users mailing list
 Chicken-users@nongnu.org
 https://lists.nongnu.org/mailman/listinfo/chicken-users

-- 

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] ffi howto

2014-11-21 Thread Richard

Hello again,

I forgot something,
as uv-idle-start takes a pointer as its second argument the function
must be called with like so:
(uv-idle-start idler-ref (location wait_for_a_while))

cheers,
Richard

Richard writes:

 Hello Omar,

 The problem with your code is that wait-for-a-while must be declared as
 an external function; like so:

 (define-external
   (wait_for_a_while ((c-pointer uv-idle-t) handle))
   void
   (let lp ((counter 0))
 (if (= counter 1000)
   (uv-idle-stop handle)
   (lp (+ counter 1)

 note that the name of the function must be a valid C function name, so
 it cannot be dash-seperated. Also looking at the libub documentation,
 the callback did not have a status argument.

 An external function that is going to call such a callback function must
 be declared using 'foreign-safe-lambda' instead of
 'foreign-lambda'. Thus uv-run must be declared as such:

 (define uv-run
   (foreign-safe-lambda int uv_run (c-pointer uv-loop-t) int))

 Hope this helps and good luck,
 Richard


 chicken-us...@shorbaji.com writes:

 Hello,

 I need some help getting started with ffi. 

 I am attempting to bind libuv to scheme code.

 My chicken scheme code at http://pastebin.com/bwja0yet fails with the
 following error.

 The following code fails with the following:

 Error: bad argument count - received 152135942 but expected 2: 0

  Call history:

  uv.scm:33: uv-default-loop
  uv.scm:33: uv-idle-init   
  uv.scm:34: uv-idle-start  
  uv.scm:36: uv-default-loop
  uv.scm:36: uv-run   --


 I am attempting to port the following C code.

 http://pastebin.com/63gP8HFT

 - Omar

 ___
 Chicken-users mailing list
 Chicken-users@nongnu.org
 https://lists.nongnu.org/mailman/listinfo/chicken-users

-- 

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


[Chicken-users] Working on Geiser integration

2014-11-21 Thread Daniel Leslie
As a follow-up to my earlier inquiries regarding SLIME, I'd like to
notify those who were interested that I've opted to instead work on
Geiser support. The path to full support seems a little easier and,
IMHO, the integration with Scheme is more natural.

AFAICT, previous efforts to support Chicken in Geiser have been
abandoned and never made it much farther than launching the
interpreter. Please inform me if I am mistaken in this regard.

My efforts are here:
https://github.com/dleslie/geiser

Currently, CAPF is working, so by extension I expect ac-geiser works
as well, though I haven't tried yet. I expect to have the bulk of the
remaining work done in the next few weeks, as I have a whole lot of
free time. At the moment there's a three week old little girl wrapped
to my chest, and I've been taking the long night shifts for bottle
feeding which give me plenty of time to hack.

Take care,
-Dan

PS- I cross-posted to chicken-hackers because I believe this is
relevant to those who may be able to provide some advice in sussing
out the internals.

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users