diff --git a/README.md b/README.md index 88adb28..fc5d0fa 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,18 @@ You write a Nim module and use some macros to generate a .st file on the side containing the Smalltalk glue code. When you compile the Nim code the .st file is automatically generated. You then file that into the image. -See full example in tests directory. +See full example in tests directory. Here is how to try it: + +- Install Nim, latest. See nim-lang.org. +- Clone squeaknim, its just a single source file really. +- Install FFI into your Squeak/Nim image. Old one. +- Compile the Test1.nim file using "nim c Test1.nim". Should give you Test1.st and libTest1.so/dll. +- Make sure the compiled libTest1.so/dll is loadable by the VM (copy to working dir for example) +- File in Test1.st that was generated. +- File in Test1-Test.st that has a SUnit test for the above glue code. +- Run in SUnit. Bask in green glory, or cry. + +The FFI should be the "good old" one - via Configurations in Pharo seems to work fine. Via SqueakMap worked in Squeak 5, I think I had to use "head". ## Squeak FFI @@ -19,7 +30,7 @@ What follows is a text written by Sean DeNigris describing the FFI. You can also see the code in the client image of course, with tests and class comments etc. -## How does FFI work? +### How does FFI work? Technically what happens is: @@ -146,7 +157,7 @@ Caveats - If you crash Squeak when it is running the garbage collector, then you know your FFI code is leaking bits into object memory [2] -What do I need to use FFI with Squeak? +### What do I need to use FFI with Squeak? You need the FFI plugin, which is included with most VM's as of Squeak 3.6 or so. @@ -154,12 +165,12 @@ or so. You can also build the plugin yourself. See VMMaker. References: -[1] http://wiki.squeak.org/squeak/1414 -[2] http://wiki.squeak.org/squeak/2424 -[3] http://wiki.squeak.org/squeak/5716 -[4] http://wiki.squeak.org/squeak/2426 -[5] http://forum.world.st/squeak-dev-Alien-Squeak-FFI-issues-on-Snow-Leopard-td85608.html -[6] http://wiki.squeak.org/squeak/5846 -[7] http://forum.world.st/FFI-Callbacks-td54056.html#a54073 -[8] http://forum.world.st/Security-td99624.html#a99635: +1 http://wiki.squeak.org/squeak/1414 +2 http://wiki.squeak.org/squeak/2424 +3 http://wiki.squeak.org/squeak/5716 +4 http://wiki.squeak.org/squeak/2426 +5 http://forum.world.st/squeak-dev-Alien-Squeak-FFI-issues-on-Snow-Leopard-td85608.html +6 http://wiki.squeak.org/squeak/5846 +7 http://forum.world.st/FFI-Callbacks-td54056.html#a54073 +8 http://forum.world.st/Security-td99624.html#a99635: