mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-07-30 19:41:56 +00:00
Consistently use extern "C"
This is what rustfmt favors, so let's favor it too! Closes #1042
This commit is contained in:
@@ -39,7 +39,7 @@ use throw_str;
|
||||
///
|
||||
/// ```rust,no_run
|
||||
/// #[wasm_bindgen]
|
||||
/// extern {
|
||||
/// extern "C" {
|
||||
/// fn setTimeout(closure: &Closure<FnMut()>, time: u32);
|
||||
///
|
||||
/// #[wasm_bindgen(js_namespace = console)]
|
||||
@@ -188,7 +188,7 @@ impl<T> Closure<T>
|
||||
// See crates/cli-support/src/js/closures.rs for a more information
|
||||
// about what's going on here.
|
||||
|
||||
extern fn describe<T: WasmClosure + ?Sized>() {
|
||||
extern "C" fn describe<T: WasmClosure + ?Sized>() {
|
||||
inform(CLOSURE);
|
||||
T::describe()
|
||||
}
|
||||
@@ -328,7 +328,7 @@ macro_rules! doit {
|
||||
#[inline]
|
||||
fn invoke_fn() -> u32 {
|
||||
#[allow(non_snake_case)]
|
||||
unsafe extern fn invoke<$($var: FromWasmAbi,)* R: ReturnWasmAbi>(
|
||||
unsafe extern "C" fn invoke<$($var: FromWasmAbi,)* R: ReturnWasmAbi>(
|
||||
a: usize,
|
||||
b: usize,
|
||||
$($var: <$var as FromWasmAbi>::Abi),*
|
||||
@@ -355,7 +355,7 @@ macro_rules! doit {
|
||||
|
||||
#[inline]
|
||||
fn destroy_fn() -> u32 {
|
||||
unsafe extern fn destroy<$($var: FromWasmAbi,)* R: ReturnWasmAbi>(
|
||||
unsafe extern "C" fn destroy<$($var: FromWasmAbi,)* R: ReturnWasmAbi>(
|
||||
a: usize,
|
||||
b: usize,
|
||||
) {
|
||||
@@ -379,7 +379,7 @@ macro_rules! doit {
|
||||
#[inline]
|
||||
fn invoke_fn() -> u32 {
|
||||
#[allow(non_snake_case)]
|
||||
unsafe extern fn invoke<$($var: FromWasmAbi,)* R: ReturnWasmAbi>(
|
||||
unsafe extern "C" fn invoke<$($var: FromWasmAbi,)* R: ReturnWasmAbi>(
|
||||
a: usize,
|
||||
b: usize,
|
||||
$($var: <$var as FromWasmAbi>::Abi),*
|
||||
@@ -407,7 +407,7 @@ macro_rules! doit {
|
||||
|
||||
#[inline]
|
||||
fn destroy_fn() -> u32 {
|
||||
unsafe extern fn destroy<$($var: FromWasmAbi,)* R: ReturnWasmAbi>(
|
||||
unsafe extern "C" fn destroy<$($var: FromWasmAbi,)* R: ReturnWasmAbi>(
|
||||
a: usize,
|
||||
b: usize,
|
||||
) {
|
||||
|
@@ -13,7 +13,7 @@ macro_rules! stack_closures {
|
||||
|
||||
fn into_abi(self, extra: &mut Stack) -> u32 {
|
||||
#[allow(non_snake_case)]
|
||||
unsafe extern fn invoke<$($var: FromWasmAbi,)* R: ReturnWasmAbi>(
|
||||
unsafe extern "C" fn invoke<$($var: FromWasmAbi,)* R: ReturnWasmAbi>(
|
||||
a: usize,
|
||||
b: usize,
|
||||
$($var: <$var as FromWasmAbi>::Abi),*
|
||||
@@ -50,7 +50,7 @@ macro_rules! stack_closures {
|
||||
|
||||
fn into_abi(self, extra: &mut Stack) -> u32 {
|
||||
#[allow(non_snake_case)]
|
||||
unsafe extern fn invoke<$($var: FromWasmAbi,)* R: ReturnWasmAbi>(
|
||||
unsafe extern "C" fn invoke<$($var: FromWasmAbi,)* R: ReturnWasmAbi>(
|
||||
a: usize,
|
||||
b: usize,
|
||||
$($var: <$var as FromWasmAbi>::Abi),*
|
||||
|
10
src/lib.rs
10
src/lib.rs
@@ -447,14 +447,14 @@ macro_rules! externs {
|
||||
($(fn $name:ident($($args:tt)*) -> $ret:ty;)*) => (
|
||||
#[cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))]
|
||||
#[link(wasm_import_module = "__wbindgen_placeholder__")]
|
||||
extern {
|
||||
extern "C" {
|
||||
$(fn $name($($args)*) -> $ret;)*
|
||||
}
|
||||
|
||||
$(
|
||||
#[cfg(not(all(target_arch = "wasm32", not(target_os = "emscripten"))))]
|
||||
#[allow(unused_variables)]
|
||||
unsafe extern fn $name($($args)*) -> $ret {
|
||||
unsafe extern "C" fn $name($($args)*) -> $ret {
|
||||
panic!("function not implemented on non-wasm32 targets")
|
||||
}
|
||||
)*
|
||||
@@ -554,7 +554,7 @@ impl Drop for JsValue {
|
||||
///
|
||||
/// ```ignore
|
||||
/// #[wasm_bindgen]
|
||||
/// extern {
|
||||
/// extern "C" {
|
||||
/// static console: JsValue;
|
||||
/// }
|
||||
/// ```
|
||||
@@ -816,7 +816,7 @@ pub mod __rt {
|
||||
use std::mem;
|
||||
|
||||
#[no_mangle]
|
||||
pub extern fn __wbindgen_malloc(size: usize) -> *mut u8 {
|
||||
pub extern "C" fn __wbindgen_malloc(size: usize) -> *mut u8 {
|
||||
let align = mem::align_of::<usize>();
|
||||
if let Ok(layout) = Layout::from_size_align(size, align) {
|
||||
unsafe {
|
||||
@@ -839,7 +839,7 @@ pub mod __rt {
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern fn __wbindgen_free(ptr: *mut u8, size: usize) {
|
||||
pub unsafe extern "C" fn __wbindgen_free(ptr: *mut u8, size: usize) {
|
||||
// This happens for zero-length slices, and in that case `ptr` is
|
||||
// likely bogus so don't actually send this to the system allocator
|
||||
if size == 0 {
|
||||
|
Reference in New Issue
Block a user