chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] SWIG pointers and Chicken


From: felix winkelmann
Subject: Re: [Chicken-users] SWIG pointers and Chicken
Date: Mon, 13 Dec 2004 07:58:10 +0100

On Sun, 12 Dec 2004 18:17:36 +0000, Joel Reymont <address@hidden> wrote:
> Folks,
> 
> Has anyone used SWIG with Chicken?
> 
> This is the structure that I'm trying to wrap:
> 
> struct Packet
> {
>         unsigned char* data;
> };
> 
> It wraps correctly and I'm able to retrieve the data member but... The
> type is <SWIG-pointer> which is neither pointer nor tagged-pointer. I
> can't use the functions from the lolevel unit to access the individual
> bytes pointed to by the data member.
> 
> How do I convert from SWIG-pointer to pointer or tagged-pointer in Chicken?
> 

Here's a fix for lolevel (it really should also handle swig-ptrs):

diff -c /home/fwinkel/stuff/chicken/lolevel.scm\~
/home/fwinkel/stuff/chicken/lolevel.scm
*** /home/fwinkel/stuff/chicken/lolevel.scm~    2004-11-23 07:21:12.000000000 
+0100
--- /home/fwinkel/stuff/chicken/lolevel.scm     2004-12-13 07:51:02.039751944 
+0100
***************
*** 138,143 ****
--- 138,144 ----
  (define (##sys#check-pointer ptr loc)
    (unless (and (##core#inline "C_blockp" ptr)
               (or (##core#inline "C_pointerp" ptr)
+                  (##core#inline "C_swigpointerp" ptr)
                   (##core#inline "C_taggedpointerp" ptr) ) )
      (##sys#signal-hook #:type-error loc "bad argument type - not a
pointer" ptr) ) )
  

On the other hand, most procedures accepting pointers should
also get along with swig-ptrs.


cheers,
felix




reply via email to

[Prev in Thread] Current Thread [Next in Thread]