Re: [Chicken-users] Ref foreign type.

2009-09-22 Thread Nicholas Indy Ray
Thanks, the patch fixes the problem. Works perfectly.

Indy

On Mon, Sep 21, 2009 at 10:28 PM, Jim Ursetto zbignie...@gmail.com wrote:

 Looks like there are two issues here.  First, try applying the
 attached patch to fix a bug in c-backend.  Second, your usage is
 incorrect--ref types require an operating system pointer or a locative
 (since they can be modified)--ref is the analog of c-pointer.  For
 example, you can change your example to:

 (print
   (let-location ((c char #\c))
 ((foreign-lambda* bool (((ref char) mC))
 C_return(mC == 'c');)
 (location c

 Of course, you must then compile with csc -c++.
 Jim

 2009/9/21 Nicholas Indy Ray arel...@gmail.com:
  I've been trying to use the ref FFI type (as documented here:
  http://chicken.wiki.br/man/4/Foreign%20type%20specifiers#(ref TYPE) )
 with
  no success. Here is an example of my usage:
 
  (print
 ((foreign-lambda* bool (((ref char) mC))
   C_return(mC == 'c');)
 #\c))
 
  compiling this with csc from Chicken 4 gives me the error:
  Error: illegal foreign type `ref'
  I find this odd as in c-backend.scm:1170 in foreign-type-declaration this
  code exists:
  ((and (= 2 len)
  (eq? 'ref (car type)))
  (foreign-type-declaration (cadr type) (string-append  target)) )
 
  Implying that ref should still be supported.
  Any help with this would be greatly appreciated.
  Indy
  ___
  Chicken-users mailing list
  Chicken-users@nongnu.org
  http://lists.nongnu.org/mailman/listinfo/chicken-users
 
 

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


[Chicken-users] Ref foreign type.

2009-09-21 Thread Nicholas Indy Ray
I've been trying to use the ref FFI type (as documented here:
http://chicken.wiki.br/man/4/Foreign%20type%20specifiers#(ref TYPE) ) with
no success. Here is an example of my usage:

(print
   ((foreign-lambda* bool (((ref char) mC))
 C_return(mC == 'c');)
   #\c))

compiling this with csc from Chicken 4 gives me the error:

Error: illegal foreign type `ref'

I find this odd as in c-backend.scm:1170 in foreign-type-declaration this
code exists:

((and (= 2 len)
(eq? 'ref (car type)))
(foreign-type-declaration (cadr type) (string-append  target)) )

Implying that ref should still be supported.

Any help with this would be greatly appreciated.

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


Re: [Chicken-users] Ref foreign type.

2009-09-21 Thread Jim Ursetto
Looks like there are two issues here.  First, try applying the
attached patch to fix a bug in c-backend.  Second, your usage is
incorrect--ref types require an operating system pointer or a locative
(since they can be modified)--ref is the analog of c-pointer.  For
example, you can change your example to:

(print
   (let-location ((c char #\c))
((foreign-lambda* bool (((ref char) mC))
 C_return(mC == 'c');)
(location c

Of course, you must then compile with csc -c++.
Jim

2009/9/21 Nicholas Indy Ray arel...@gmail.com:
 I've been trying to use the ref FFI type (as documented here:
 http://chicken.wiki.br/man/4/Foreign%20type%20specifiers#(ref TYPE) ) with
 no success. Here is an example of my usage:

 (print
    ((foreign-lambda* bool (((ref char) mC))
      C_return(mC == 'c');)
    #\c))

 compiling this with csc from Chicken 4 gives me the error:
 Error: illegal foreign type `ref'
 I find this odd as in c-backend.scm:1170 in foreign-type-declaration this
 code exists:
 ((and (= 2 len)
 (eq? 'ref (car type)))
 (foreign-type-declaration (cadr type) (string-append  target)) )

 Implying that ref should still be supported.
 Any help with this would be greatly appreciated.
 Indy
 ___
 Chicken-users mailing list
 Chicken-users@nongnu.org
 http://lists.nongnu.org/mailman/listinfo/chicken-users


Index: c-backend.scm
===
--- c-backend.scm   (revision 15578)
+++ c-backend.scm   (working copy)
@@ -1277,7 +1277,7 @@
   ((const) (foreign-argument-conversion (cadr type)))
   ((enum) C_num_to_int()
   ((ref)
-   (string-append *( (foreign-type-declaration (car type) *)
+   (string-append *( (foreign-type-declaration (cadr type) *)
   )C_c_pointer_nn())
   ((instance-ref)
(string-append *( (cadr type) *)C_c_pointer_nn())
___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users