I'm in the process of working on haskell bindings for a native library with a pretty complex interface. It has a lot of structs as part of its interface, and I've been working on building interfaces to them with hsc2hs
and the bindings-DSL
package for helping automate struct bindings.
One problem I've run into, though, is with structs that contain multidimensional arrays. The bindings-DSL
documentation describes macros for binding to a structure like
struct with_array {
char v[5];
struct test *array_pointer;
struct test proper_array[10];
};
with macros like
#starttype struct with_array
#array_field v , CChar
#field array_pointer , Ptr <test>
#array_field proper_array , <test>
#stoptype
But this library has many structs with multidimensional arrays as fields, more like
struct with_multidimensional_array {
int whatever;
struct something big_array[10][25][500];
};
The #array_field
macro seems to only handle the first dimension of the array. Is it the case that bindings-DSL
just doesn't have a macro for handling multidimensional arrays?
I'd really like a macro for binding a (possibly-multidimensional) array to a StorableArray
of arbitrary indexes. Seems like the necessary information is possible in the macros bindings-DSL
provides - there's just no macro for this.
Has anyone added macros to bindings-DSL
? Has anyone added a macro for this to bindings-DSL
? Am I way past what I should be doing with hsc2hs
, and there's some other tool that would help me do what I want in a more succinct way?
StorableArray
with aStorable
instance specifically for that field, and just use the#field
macro. This seems sane, in the absence of any better solution. – Carl