[plt-scheme] Eli Barzilay's new FFI stuff
On Sat, 7 Aug 2004 19:22:54 -0400, Eli Barzilay <eli at barzilay.org> wrote:
> Well, you can edit foreign.ss and disable all pointer tags, or wait
> for me... I'll send you a message when I get to it.
Cool, thanks.
> On Aug 7, Christopher Armstrong wrote:
> > typedef struct {
> > SuperStruct_HEAD // There is also an actual SuperStruct, which is
> > what I'm using
> > int foo;
> > } FooBar;
>
> This seems like an unnecessary hack if what I said above is correct.
> So the fact that there is a library that does that makes me worried
> that there might be a problem.
I'll talk to the implementors and see why they did it this way. Maybe
just for the bit of convenience of not having to cast to the
super-struct before accessing its fields.
> > [Sigh, now I'm even hearing stuff about how there could be padding
> > differences even without including other structs. This is frikkin'
> > depressing. I'll just try to keep doing it the way I'm doing it and
> > see if I run into problems.]
>
> Well, if it is only alignment padding, then libffi will do things
> right.
Ok, I'm just going to ignore this issue until it bites [argh, I just
typed "bytes" -- too much C] me, then. ;-)
> > Well, how else can I extract the string from that struct?
>
> You can convert the whole struct to a byte string (which doesn't add
> any overhead), then look in that string beyond the header. I'll need
> to see if there is any other way to do this.
:-( Well, it'll have to do for now. Hmm, I'm getting some error about
"undefined identifier: type:" when I try to use (ptr-ref the-string
(_bytes o N)) for this purpose. Is that a bug in the _bytes macro?
> > I admit I don't understand the interaction between the GC and your
> > FFI; but isn't it only the scheme-encapsulation of the pointer
> > object returned from (mystring-sval-pointer mystring) that needs to
> > be GC-watched, not the actual pointer itself?
>
> But this scheme pointer object does contain a pointer, so the GC will
> want to account for what that pointer points to.
Oh. Ok. Well I'll leave solving that up to you :-)
--
Twisted | Christopher Armstrong: International Man of Twistery
Radix | Release Manager, Twisted Project
---------+ http://radix.twistedmatrix.com