diff options
author | Emilio Cobos Álvarez <emilio@crisal.io> | 2020-11-25 14:55:58 +0100 |
---|---|---|
committer | Emilio Cobos Álvarez <emilio@crisal.io> | 2020-11-25 17:25:49 +0100 |
commit | 01cbe4468358d843ef86e3e9a1e8ce2bb4fef95e (patch) | |
tree | 92004612b710a8be4aed7d67a428aaa499d9765b /src/codegen/mod.rs | |
parent | 7792d633c78d4ad39979e09a6215b656f7ec31f2 (diff) |
dyngen: Handle variadic functions.
Right now trying to generate a dynamic library with variadic functions
panics because we don't account for the extra `...` in the arguments.
Keeping the current interface for variadic functions is tricky, as we
cannot "wrap" a variadic function (VaList[1] is nightly-only).
However, we don't need to. We're already exposing the libloading error,
so exposing the function pointer field as public is just fine and allows
consumers to call the variadic function.
At that point the can_call() / CheckFoo libraries become pointless (you
can just do library.function.is_ok() or such), so we can simplify the
code as well removing those.
[1]: https://doc.rust-lang.org/std/ffi/struct.VaList.html
Diffstat (limited to 'src/codegen/mod.rs')
-rw-r--r-- | src/codegen/mod.rs | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/src/codegen/mod.rs b/src/codegen/mod.rs index 64f95f4c..754c2c8b 100644 --- a/src/codegen/mod.rs +++ b/src/codegen/mod.rs @@ -3808,6 +3808,7 @@ impl CodeGenerator for Function { result.dynamic_items().push( ident, abi, + signature.is_variadic(), args, args_identifiers, ret, @@ -4107,11 +4108,8 @@ pub(crate) fn codegen( if let Some(ref lib_name) = context.options().dynamic_library_name { let lib_ident = context.rust_ident(lib_name); - let check_struct_ident = - context.rust_ident(format!("Check{}", lib_name)); - let dynamic_items_tokens = result - .dynamic_items() - .get_tokens(lib_ident, check_struct_ident); + let dynamic_items_tokens = + result.dynamic_items().get_tokens(lib_ident); result.push(dynamic_items_tokens); } |