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, On Sat, Jan 23, 2016 at 1:12 PM, Eliot Miranda <[hidden email]> wrote:
|
Yay!
|
In reply to this post by Mariano Martinez Peck
super!
Stef Le 25/1/16 23:27, Mariano Martinez Peck
a écrit :
|
In reply to this post by Mariano Martinez Peck
On Tue, Jan 26, 2016 at 8:34 AM, Craig Latta <[hidden email]> wrote:
Yeah, exactly. It is automate that and the result can be stored as "init" methods (one per platform) in the shared pools directly. Also, it will take care of initializing them (searching the correct init method for the current platform) at startup. Note that I called the project FFICHeaderExtractor and not FFICConstantsExtractor. If time allows, I would also like to get info from structs: sizeof and how they are defined internally. That would be yet another feature to let more things to be done via FFI. See https://github.com/marianopeck/FFICHeaderExtractor/issues/1 But that would require some more effort!
|
In reply to this post by stepharo
Hi Mariano, I just saw your comment in OSSUnixSystemAccessor >> getcwd and wondered if there's a feasible plan for errno? What if the VM provided a known accessor function around the global/macro/whatever errno is defined as? On 26 January 2016 at 08:15, stepharo <[hidden email]> wrote:
|
On Fri, Mar 18, 2016 at 10:06 AM, Damien Pollet <[hidden email]> wrote:
Hi Damien, Unfortunately, that comment you read there happens not only for getcwd() but for every function that writes into errno. I already sent this to the mailing list and was discussed [1]. I have also chatted with Esteban about this, and Eliot said in VW VM they have something like this. To conclude, we lack such a support from FFI backend. We hope to add that at some point. Maybe Ronie will have some time to play with this?
|
Free forum by Nabble | Edit this page |