unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* FFI kick start
@ 2008-10-14  9:43 john
  2008-10-14 19:29 ` Linas Vepstas
  2008-10-14 19:47 ` Andy Wingo
  0 siblings, 2 replies; 3+ messages in thread
From: john @ 2008-10-14  9:43 UTC (permalink / raw)
  To: guile-user

Hi guilers...

I am trying to get to grips with manually wrapping C functions but
need some pointers. I have a C function:

packedEncode *initializeEncode(char *pdu, int size)

with:

typedef struct {
  char *pdu;
  ...

} packedEncode;

It takes a pointer to some storage (char *pdu) which will be mutated
by other wrapped C functions and finally retrieved. I am running into
segfault problems when it comes to mutating the data from C and then
trying to access it. I would really appreciate some pointers or some
boiler plate code for handling this type of function to get me
rolling.

TIA,

John.




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

* Re: FFI kick start
  2008-10-14  9:43 FFI kick start john
@ 2008-10-14 19:29 ` Linas Vepstas
  2008-10-14 19:47 ` Andy Wingo
  1 sibling, 0 replies; 3+ messages in thread
From: Linas Vepstas @ 2008-10-14 19:29 UTC (permalink / raw)
  To: john; +Cc: guile-user

2008/10/14 john <jptmoore@gmail.com>:
> Hi guilers...
>
> I would really appreciate some pointers or some
> boiler plate code for handling this type of function to get me
> rolling.

I found that
http://www.gnu.org/software/guile/manual/html_node/The-Complete-Example.html

was enough to get me going.

Alternately, take a look at the source code for "gnotime";
it wraps a bunch of OO-style objects in a simple way,
with just a small amount of guile code.

--linas




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

* Re: FFI kick start
  2008-10-14  9:43 FFI kick start john
  2008-10-14 19:29 ` Linas Vepstas
@ 2008-10-14 19:47 ` Andy Wingo
  1 sibling, 0 replies; 3+ messages in thread
From: Andy Wingo @ 2008-10-14 19:47 UTC (permalink / raw)
  To: john; +Cc: guile-user

On Tue 14 Oct 2008 11:43, john <jptmoore@gmail.com> writes:

> I am trying to get to grips with manually wrapping C functions but
> need some pointers. I have a C function:
>
> packedEncode *initializeEncode(char *pdu, int size)

You need to create a smob type for the packedEncode data structure. Make
sure that if C has a reference to it, that Scheme does also. Check the
section of the manual about "SMOBs".

Andy
-- 
http://wingolog.org/




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

end of thread, other threads:[~2008-10-14 19:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-14  9:43 FFI kick start john
2008-10-14 19:29 ` Linas Vepstas
2008-10-14 19:47 ` 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).