I am much happier with my second attempt at an OCaml binding for Oracle Coherence. This way is easier to build, easier to use, and I could reuse all of the C++ code from my first attempt. See the code on GitHub.
My general strategy for this is going to be:
- Use a class (or classes) written in pure C++ to interact with Coherence
extern "C"functions first to instantiate an object from (1) and return an object pointer to OCaml, then to invoke methods via that pointer.
- From OCaml, call the function to create the object, then pass the pointer from (2) into the other C functions using the normal OCaml/C interface
- Pre- and post- grid operations implemented in OCaml
The next challenge will be to use MapListener/Continuous Query to execute code in OCaml in response to events within the grid – if possible, configuring it from the OCaml side. And then to do it with more complex data structures than simple strings.