[squeak-dev] Re: [Pharo-project] FFI and capturing external program input in Squeak/Pharo

Javier Pimás elpochodelagente at gmail.com
Mon Jun 20 22:51:53 UTC 2011


Hi! It's nice to hear this. As Mariano said, I started to work in something
like this some months ago, but I couldn't make something useful yet because
I don't have much free time. I can give you a hand if you need. I don't know
about OS Process, but I have some experience with FFI, so I'll look for some
examples. I also have some questions,

- how did you implement the parser, by hand or with a framework?
- did you implement a preprocessor or used the output of something like CPP?
- what about the output of the parser, do you create an AST?

Regards,
             Javier

On Fri, Jun 17, 2011 at 1:34 PM, Dave Mason <dmason at 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 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.
>
> Finally is there a way to get external variables such as 'extern int
> errno;' ?
>
> Thanks in advance!
>
> ../Dave
>
>


-- 
Javier Pimás
Ciudad de Buenos Aires
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20110620/6e1361f6/attachment.htm


More information about the Squeak-dev mailing list