unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* C Struct Interface
@ 2010-07-12  2:20 Noah Lavine
  2010-07-13 21:18 ` Andy Wingo
  0 siblings, 1 reply; 2+ messages in thread
From: Noah Lavine @ 2010-07-12  2:20 UTC (permalink / raw)
  To: guile-devel

Hello,

I'm trying to use Scheme structures, as defined in struct.c and
struct.h, and I have a question about the interface.

It seems from the code that scm_c_make_structv(vtable, ntail, ninit,
inits) is the main function for creating structs. I'm assuming that
ntail is the number of elements in the tail array of the struct, ninit
is the total number of elements I want to init, and inits is an array
containing the initial values. Is this correct?

Also, if I make a struct in this way, can I then do
SCM_STRUCT_SLOT_REF(struct, n) to get at it, where n=0 is the first
slot?

Thanks,
Noah



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: C Struct Interface
  2010-07-12  2:20 C Struct Interface Noah Lavine
@ 2010-07-13 21:18 ` Andy Wingo
  0 siblings, 0 replies; 2+ messages in thread
From: Andy Wingo @ 2010-07-13 21:18 UTC (permalink / raw)
  To: Noah Lavine; +Cc: guile-devel

Hello,

On Mon 12 Jul 2010 04:20, Noah Lavine <noah.b.lavine@gmail.com> writes:

> It seems from the code that scm_c_make_structv(vtable, ntail, ninit,
> inits) is the main function for creating structs. I'm assuming that
> ntail is the number of elements in the tail array of the struct

Yes. Avoid tail arrays if you can, they are confusing and a bad interface.

> ninit
> is the total number of elements I want to init, and inits is an array
> containing the initial values. Is this correct?

Yep. 

> Also, if I make a struct in this way, can I then do
> SCM_STRUCT_SLOT_REF(struct, n) to get at it, where n=0 is the first
> slot?

You can indeed, though this does no bounds checking.

Sorry for the undocumented state of things; patches to fix that most
welcome! ;)

Andy
-- 
http://wingolog.org/



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-07-13 21:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-12  2:20 C Struct Interface Noah Lavine
2010-07-13 21:18 ` Andy Wingo

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).