I have this rust method:
/* Define a python method on a given module */
pub fn method(data: *mut Struct_ppyData, module: ~str, method: ~str, callback: PyCFunction, flags: Method, help: ~str) {
let mbytes = module.to_c_str().with_mut_ref(|a: * mut c_char| { a });
let fbytes = method.to_c_str().with_mut_ref(|b: * mut c_char| { b });
let dbytes = help.to_c_str().with_mut_ref(|c: * mut c_char| { c });
println!("Incoming! {} {} {}\n", module, method, help);
println!("Invoking! {} {} {}\n", mbytes, fbytes, dbytes);
let cflags = flags as c_int;
unsafe {
ppy_method(data, mbytes, fbytes, callback, cflags, dbytes);
}
}
And the output I get is:
Incoming! yyy xxx A callback.
Invoking! 0x7f85084077d0 0x7f85084077d0 0x7f85084077d0
What? That's what the ffi c call sees too:
Received a value
Pointer: 7f85084077d0
length: 11
--------> value: A callback.
Received a value
Pointer: 7f85084077d0
length: 11
--------> value: A callback.
Received a value
Pointer: 7f85084077d0
length: 11
--------> value: A callback.
Why on earth are the values of mbytes, fbytes and dbytes all the same? O_o