Hi guys,
OK, I have a first working version and so I wanted to share it with you.
I have not yet the time to start writing the doc since I just finished the first pass on the code. Tomorrow I will start with the doc. But I thought some of you may be interested in taking a look even without formal "doc" (and some feedback/iteration may avoid re-writing docs..).
If you have no clue what I am talking about, then this summary is for you:
----------
When we use FFI to call a certain library it's quite common that we need to pass as argument certain constants (for example, SIGKILL to kill()). These constants are defined in C header files and can even change it's value in different paltforms.
These constants also are sometimes defined by the C preprocessor and so there is not way to get those values from FFI. If you don't have the value of those constants, you cannot make the FFI call.
----------
I have tested the tool in OSX and CentOS using latest Pharo 5.0. It won't work in Windows right now. As usual, all classes and methods have comments and there are enough tests.
At the end, I decided the C program will output a very naive Smalltalk literal array kind of thingy. The tool then parses that output and directly creates a init method (which is compiled into the SharedPool class) for that platform which is then called automatically at startup (only if initialization is needed).
As for real examples, I started to write constants for libc: signal.h (to use kill()) , wait.h (to use wait() famility), fcntl.h (to use ... xxx()) , and errno.h. You can take a look to the package 'FFICHeaderExtractor-LibC'.
Note that for running the tests you need 'cc' findable by path in OSX and 'gcc' in Unix.
To load the code in a latest Pharo 5.0, execute:
Metacello new
baseline: 'FFICHeaderExtractor';
repository: 'github://marianopeck/FFICHeaderExtractor:master/repository';
load.
Any feedback is appreciated.
I will start writing the doc now.
BTW: Big thanks to Eliot Miranda which helped me answering noob questions and providing useful code and guidelines.
Best,