Fix a few more mistakes from slices

This commit is contained in:
Alex Crichton 2018-02-16 19:19:31 -08:00
parent 0970fa2998
commit 9e7a4e7e60
3 changed files with 4 additions and 4 deletions

View File

@ -1031,7 +1031,7 @@ impl<'a, 'b> SubContext<'a, 'b> {
", i = i, func = func, arg = name));
pass(&format!("ptr{}", i));
pass(&format!("len{}", i));
if ty.owned {
if !ty.owned {
destructors.push_str(&format!("\n\
wasm.__wbindgen_free(ptr{i}, len{i});\n\
", i = i));

View File

@ -148,7 +148,7 @@ fn bindgen_export(export: &ast::Export, into: &mut Tokens) {
let ptr = syn::Ident::from(format!("arg{}_ptr", i));
let len = syn::Ident::from(format!("arg{}_len", i));
let abi_ty = ty.abi_element();
args.push(my_quote! { #ptr: *const #abi_ty });
args.push(my_quote! { #ptr: *mut #abi_ty });
args.push(my_quote! { #len: usize });
if owned {
arg_conversions.push(my_quote! {
@ -159,7 +159,7 @@ fn bindgen_export(export: &ast::Export, into: &mut Tokens) {
} else {
arg_conversions.push(my_quote! {
let #ident = unsafe {
::std::slice::from_raw_parts(#ptr, #len)
::std::slice::from_raw_parts(#ptr as *const #abi_ty, #len)
};
});
}

View File

@ -100,7 +100,7 @@ pub const TYPE_SLICE_F64: char = '\u{71}';
pub const TYPE_JS_OWNED: char = '\u{72}';
pub const TYPE_JS_REF: char = '\u{73}';
pub const TYPE_CUSTOM_START: u32 = 0x64;
pub const TYPE_CUSTOM_START: u32 = 0x74;
pub const TYPE_CUSTOM_REF_FLAG: u32 = 1;
pub fn name_to_descriptor(name: &str) -> char {