unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: klaus schilling <schilling.klaus@web.de>
Cc: guile-user@gnu.org, spikegran@earthlink.net
Subject: Re: C structures
Date: Fri, 30 Dec 2005 20:45:34 +0100	[thread overview]
Message-ID: <17333.36446.227240.212484@gargle.gargle.HOWL> (raw)
In-Reply-To: <20051230131952.2b302206.leonardolopespereira@gmail.com>

Leonardo Lopes Pereira writes:
 > 
 > To be more clear. I want to be able to call a C function from guile.
 > The problem is that this function has a struct as an arg and this
 > struct has variable members. So, I need to create a list on
 > scheme/guile and convert it to a C struct that will be used as an arg
 > to that function.

one can add another smob type that actually holds a pointer to the struct.
this works well if the interface of the strcut is controlled by the C API.
Smobs also provide for garbage collection mechanism,
which is a problem in hand-woven conversions from structured C data to 
Scheme data. Most C libraries iontroducing struct arguments essentially
define the struct and functions to handle pointers of that struct,
including allocation functions , freeing functions, copying etc.
These need to be plugged into the definition of a smob type.
Jim Blandy wrote a manual for that almost 10 years ago,
coming with the guile dists.
Nowadays, the gh_ interface is deprecated, so one should
switch to scm_ interface in non-heritage projects

Klaus Schilling


_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user


  parent reply	other threads:[~2005-12-30 19:45 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-12-30 13:11 C structures Leonardo Lopes Pereira
2005-12-30 15:04 ` Neil Jerram
     [not found]   ` <20051230125804.f764063f.leonardolopespereira@gmail.com>
2005-12-31 13:14     ` Neil Jerram
2005-12-31 16:00       ` Mike Gran
2005-12-30 15:58 ` Mike Gran
2005-12-30 16:19   ` Leonardo Lopes Pereira
2005-12-30 17:01     ` Mike Gran
2005-12-30 19:45     ` klaus schilling [this message]
     [not found] <E1EsL1F-0006hc-Lg@pat.uio.no>
2006-01-04 21:10 ` Kjetil S. Matheussen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=17333.36446.227240.212484@gargle.gargle.HOWL \
    --to=schilling.klaus@web.de \
    --cc=guile-user@gnu.org \
    --cc=spikegran@earthlink.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).