Subject:
[ruby-ffi] attach_function syntax when input args are pointers to contain return values
From:
Rob Marshall
Date:
1/31/13 2:21 PM
To:
ruby-ffi@googlegroups.com

Hi,

My guess is that this has been asked before, but I didn't find it...not exactly sure what to search for...

Anyway, I am trying to attach functions that return :void but use the input parameters to hold the return values. e.g. A function that gets a value and returns it as a string and length. So say my C-function declaration is:

void GetMyString(const long reference, char *buffer, int *size)

My guess, and I'm sure it doesn't work because I tried it, was to do:

buffer = FFI::MemoryPointer.new(:char, 256)
size = FFI::MemoryPointer.new(:int,1)
attach_function :GetMyString, [ :long, buffer, size ], :void

I got a "can't resolve type" error when I tried that.

What's the correct way to do it?

Thanks,

Rob

--
 
---
You received this message because you are subscribed to the Google Groups "ruby-ffi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ruby-ffi+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.