FFI, Ogg Vorbis, and char[]
Bert Freudenberg
bert at isg.cs.uni-magdeburg.de
Mon Nov 25 10:32:04 UTC 2002
On Sun, 24 Nov 2002, Jason Dufair wrote:
> Bert Freudenberg wrote:
>
> >#( ...
> > (header 'char' 282)
> > ... )
> >
> >
> Heh. Talk about a case of RTFM. Sorry I overlooked that.
Actually it's more like RTFC. I discovered this by looking in
ExternalStructure>>compileFields:withAccessors:. And I think giving the
size in bytes is misleading, it should be multiple of the base type's
size. That is, when I give it an (stuff 'int' 3) it should skip
12 bytes. Andreas?
> If I have something declared in a C header as, for example, char**, can
> FFI handle pointers to pointers?
Of course, but you have to dereference it yourself. See the hostname
lookup snippet I sent, it doeas exactly this.
> I need to pass a file pointer in to a foreign function. Is there some
> way to get a file pointer in Smalltalk?
Not easily, that's hidden in the FilePlugin. You could open your files via
FFI, too. Or you might read the FilePlugin code and find a way to access
the actual file data.
> struct alloc_chain{
> void *ptr;
> struct alloc_chain *next;
> };
>
> fields
> ^#(
> ('ptr' 'void*')
> ('next' 'AllocChain'))
>
> sends Squeak out to lunch. I've tried declaring 'next' as 'void*', but
> I'm not sure if that will work. Any ideas?
I think that should read ('next' AllocChain*) because it is a pointer.
-- Bert
More information about the Squeak-dev
mailing list
|