Hello, I'm looking to formulate the inputs and analyze the outputs of a C program using Clojure. I can both create and manipulate the native data structures in Clojure using Vertigo[1], and for the JNA interop clj-native[2] seems to be the way to go. In all the examples of clj-native I have seen so far, the native data structures are defined in C, and you just call a constructor function from Clojure with the required inputs. While this is certainly an acceptable solution, I'm wondering if it would be possible to combine the two libraries, so I can keep as much of the work in Clojure as possible.
In JNA one can define C structs in Java by extending the com.sun.jna.Structure class, and then pass them by value or reference by adding inner classes that implement Structure.ByReference or ByValue. The way clj-native works is by doing all sorts of black magic with ASM to create these classes automatically for you. With Vertigo on the other hand I can convert a Clojure data structure to a ByteBuffer where the data resides in its native order. I can also get the pointer to that data structure by calling com.sun.jna.Native/getDirectedBufferPointer on that, but unfortunately I think there's no way to pass this on to the native functions defined via clj-native. I feel like there should somehow be a way to give this ByteBuffer to clj-native and have it do what it does for the natively defined structs, but I can't figure this thing out. So I'm looking for advice on how to accomplish this, or for someone to tell me that this is a bad idea and I can move on and use clj-native the way I think it was supposed be used. I have very little experience with either JNA/C so it's entirely possible I'm missing something quite simple. Thank you. [1] https://github.com/ztellman/vertigo [2] https://github.com/bagucode/clj-native -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.