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 |
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 |
In reply to this post by Dave Mason-3
On Fri, Jun 17, 2011 at 6:34 PM, Dave Mason <[hidden email]> wrote: I'm working on making a clean interface layer on top of FFI (and possibly Alien and NativeBoost). 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 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;' ? -- Mariano http://marianopeck.wordpress.com |
In reply to this post by Dave Mason-3
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 <[hidden email]> wrote: I'm working on making a clean interface layer on top of FFI (and possibly Alien and NativeBoost). -- Javier Pimás Ciudad de Buenos Aires |
Hi Javier,
On 2011-Jun-20, at 18:51 , Javier Pimás wrote: > 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. That would be great. FFI, Alien, and NativeBoost evidence an itch... but actual uses that depend on the code seem to be harder to find. I get the impression that many potential users have devolved to writing their own purpose-built plugins. > I also have some questions, > > - how did you implement the parser, by hand or with a framework? By hand. It doesn't handle all of C, but that part you will find in include files. > - did you implement a preprocessor or used the output of something > like CPP? I'm using CPP at the moment. The only serious downside that I see is that lots of C headers pre-date the introduction of enums into C, so constants are often #defined rather than being part of an enum. So I may end up adding a pre-processor to recover these constants. > - what about the output of the parser, do you create an AST? No, I directly build the data structures I need to generate the FFI interfaces. > On Fri, Jun 17, 2011 at 1:34 PM, Dave Mason <[hidden email]> > wrote: > I'm working on making a clean interface layer on top of FFI (and > possibly Alien and NativeBoost). |
Free forum by Nabble | Edit this page |