Nathan Baker wrote:
> Hey,
> 
> We are writing an application that gets data from a C library, passes
> it through our Ruby framework and over the network, and then sends
> those data back down into the C library. We don't actually want to
> manipulate the data in Ruby, but we do want to be able to store them in
> an opaque blob and have them marshal correctly and arrive intact. It is
> also worth noting that we are trying to produce a generic framework, so
> we want to make no assumptions about the sort of data we might be
> getting from C.
> 
> What is the best way to do this? We tried the naive approach, using
> Data_Wrap_Struct to pass the data into Ruby and then Data_Get_Struct to
> move the data back down to C, but then when we tried to serialize it
> using Marshal.dump, it failed (no marshal_dump is defined for class
> Object).
> 
> Is there a relatively painless way to wrap data and pass them to Ruby
> in such a way that these data can then be serialized over the network?

If it's an opaque blob, then it sounds like String is the best class to 
hold your data. The C->ruby part is just rb_str_new() (or rb_str_new2(), 
if the data is null terminated). Any reason this won't work in your case?

-- 
       vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407