Hi Dave,<br><br><div class="gmail_quote">On Fri, Jun 17, 2011 at 9:34 AM, Dave Mason <span dir="ltr">&lt;<a href="mailto:dmason@mason-rose.ca">dmason@mason-rose.ca</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
I&#39;m working on making a clean interface layer on top of FFI (and possibly Alien and NativeBoost).<br>
<br>
It will look something like:<br>
<br>
        FFIParse createFFI: #System category: &#39;My-Category&#39; library: &#39;System&#39;.<br>
        System parseSystemHeader: &#39;sys/resource.h&#39;.<br>
        rusage := System struct: #rusage.<br>
        System getrusage: 0 with: rusage.<br>
        Transcript show: &#39;Used &#39;;<br>
                         show: rusage ru_utime tv_sec;<br>
                         show: &#39;.&#39;;<br>
                         show: rusage ru_utime tv_usec;<br>
                         show: &#39; seconds of user CPU time&#39;;<br>
                         cr.<br>
        System parseSystemHeaer: &#39;unistd.h&#39;;<br>
                sleep: 5.<br>
        pid := System getpid<br>
<br>
I have a very compact, almost compete C header parser </blockquote><div><br></div><div>This is in Smalltalk right?  How is it implemented?  Haver you published it yet?  Are you planning to publish it open source or keep it private?</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">but I need to be able to get the output from<br>
        popen(&quot;echo \&quot;#include &lt;unistd.h&gt;\&quot;|gcc -E -&quot;,&quot;r&quot;) </blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
or equivalent. </blockquote><div><br></div><div>OSProcess would work. Also system would work.</div><div><br></div><div>self system: &#39;echo \&quot;#include &lt;unistd.h&gt;\&quot;|gcc -E - &gt;outfile.i&#39;.</div><div>
(FileStream oldFileNamed: &#39;outfile.i&#39;) contentsOfEntireFile</div><div><br></div><div><br></div><div>But if you have a complete C header parser why can&#39;t you implement inclusion yourself?  Wy do you need gcc to preprocess?  You should be able to do everything that the preprocessor does yourself.</div>
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"> 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?<br>

<br>
I&#39;d also appreciate any simple examples of using FFI, especially with ExternalStructure subclasses.<br>
<br>
Finally is there a way to get external variables such as &#39;extern int errno;&#39; ?<br></blockquote><div><br></div><div>Not conveniently yet, but its doable.  Note that errno is an interesting example because typically it is completely different in a -pthreads compilation (thread-local) to a single-threaded compilation (global variable).</div>
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
Thanks in advance!<br></blockquote><div><br></div><div>best,</div><div>Eliot</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><font color="#888888">
<br>
../Dave<br>
<br>
</font></blockquote></div><br>