guile-user
[Top][All Lists]
Advanced

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

Re: C structures


From: Kjetil S. Matheussen
Subject: Re: C structures
Date: Wed, 4 Jan 2006 13:10:23 -0800 (PST)


Leonardo Lopes Pereira:

I would like to know if is there any way to convert C structs to any type of 
Guile data.


SND has some neat features for doing that:
http://ccrma.stanford.edu/software/snd/

Example:

(load-from-path "eval-c.scm")
#<unspecified>

(define-ec-struct <test>
  <int> data
  <int-*> datas
  <something-else-*> somethingelse)
#<unspecified>

(define test (<test> #:data 1
                     #:datas '(2 3 4)))
#<unspecified>

(-> test data)
1

(-> test data 5)
#<unspecified>

(-> test data)
5

(-> test datas)
(2 3 4)

(-> test datas '(9 2 3 4))
#<unspecified>

(-> test datas)
(9 2 3 4)

I think there are direct support for chars, floats, ints, floats, doubles, strings and SCMs. Everything else is treated as pointers.



--




reply via email to

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