On Fri, Jun 17, 2011 at 6:34 PM, Dave Mason <dmason@mason-rose.ca> wrote:
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: '.';
� � � � � � � � � � � � show: rusage ru_utime tv_usec;
� � � � � � � � � � � � show: ' seconds of user CPU time';
� � � � � � � � � � � � cr.
� � � �System parseSystemHeaer: 'unistd.h';
� � � � � � � �sleep: 5.
� � � �pid := System getpid

I have a very compact, almost compete C header parser


Hi Dave. Talk to Javier Pimas and Nick Papoylias. They were both trying to do such parser I think.
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 ExternalStructure subclasses.


Sorry I cannot help. We did the OpenDBX wrapper with FFI, but we needed only one ExternalStructure. Anyway, if you want to take a look, load the packages OpenDBXDriverPharo-Dialect and OpenDBXDriverSmalltalk-Dialect from� 'http://www.squeaksource.com/DBXTalk'� and browse methods of PharoOpenDBX subclasses.

Finally is there a way to get external variables such as 'extern int errno;' ?

Thanks in advance!

../Dave




--
Mariano
http://marianopeck.wordpress.com