[squeak-dev] FFI and capturing external program input in
dmason at mason-rose.ca
Fri Jun 17 16:34:10 UTC 2011
I'm working on making a clean interface layer on top of FFI (and
possibly Alien and NativeBoost).
It will look something like:
FFIParse createFFI: #System category: 'My-Category' library: 'System'.
System parseSystemHeader: 'sys/resource.h'.
rusage := System struct: #rusage.
System getrusage: 0 with: rusage.
Transcript show: 'Used ';
show: rusage ru_utime tv_sec;
show: rusage ru_utime tv_usec;
show: ' seconds of user CPU time';
System parseSystemHeaer: 'unistd.h';
pid := System getpid
I have a very compact, almost compete C header parser but I need to be
able to get the output from
popen("echo \"#include <unistd.h>\"|gcc -E -","r")
or equivalent. The popen is easy enough to get at through FFI, but is
there a way to connect either the FILE* or the file descriptor up to
some ReadStream. In the worst case, I could probably use FFI to call
fread(3) but is there a better way?
I'd also appreciate any simple examples of using FFI, especially with
Finally is there a way to get external variables such as 'extern int
Thanks in advance!
More information about the Squeak-dev