Hi Dave,<br><br><div class="gmail_quote">On Fri, Jun 17, 2011 at 9:34 AM, Dave Mason <span dir="ltr"><<a href="mailto:dmason@mason-rose.ca">dmason@mason-rose.ca</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
I'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: 'My-Category' library: 'System'.<br>
System parseSystemHeader: 'sys/resource.h'.<br>
rusage := System struct: #rusage.<br>
System getrusage: 0 with: rusage.<br>
Transcript show: 'Used ';<br>
show: rusage ru_utime tv_sec;<br>
show: '.';<br>
show: rusage ru_utime tv_usec;<br>
show: ' seconds of user CPU time';<br>
cr.<br>
System parseSystemHeaer: 'unistd.h';<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("echo \"#include <unistd.h>\"|gcc -E -","r") </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: 'echo \"#include <unistd.h>\"|gcc -E - >outfile.i'.</div><div>
(FileStream oldFileNamed: 'outfile.i') contentsOfEntireFile</div><div><br></div><div><br></div><div>But if you have a complete C header parser why can'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'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 'extern int errno;' ?<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>