summaryrefslogtreecommitdiff
path: root/src/codegen/mod.rs
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2017-10-10 12:41:38 -0500
committerGitHub <noreply@github.com>2017-10-10 12:41:38 -0500
commitc744e684470f6b54c4f77ce9ba27f7ce74df892d (patch)
tree344b3d0c2b80089c3ccbd1607e8dfd094d514ade /src/codegen/mod.rs
parent5dbdadc5cc1d15e23d804b4d0ce80cae90338ef7 (diff)
parent9b95ce6a76d32a1c152bd3719d6cf46dd872b630 (diff)
Auto merge of #1065 - liranringel:thiscall, r=fitzgen
Add support for the thiscall ABI Fixes https://github.com/rust-lang-nursery/rust-bindgen/issues/541 The thiscall ABI is experimental, so in order to use it nightly is required and also the following statement: `#![feature(abi_thiscall)]` That's a problem because the `tests_expectations` crate (in the tests folder) tries to compile it (and stable is required).
Diffstat (limited to 'src/codegen/mod.rs')
-rw-r--r--src/codegen/mod.rs22
1 files changed, 19 insertions, 3 deletions
diff --git a/src/codegen/mod.rs b/src/codegen/mod.rs
index 94a62b97..6d8e8a9d 100644
--- a/src/codegen/mod.rs
+++ b/src/codegen/mod.rs
@@ -1959,6 +1959,10 @@ impl MethodCodegen for Method {
_ => panic!("How in the world?"),
};
+ if let (Abi::ThisCall, false) = (signature.abi(), ctx.options().rust_features().thiscall_abi()) {
+ return;
+ }
+
// Do not generate variadic methods, since rust does not allow
// implementing them, and we don't do a good job at it anyway.
if signature.is_variadic() {
@@ -3072,9 +3076,17 @@ impl TryToRustTy for FunctionSig {
let arguments = utils::fnsig_arguments(ctx, &self);
let abi = self.abi();
- Ok(quote! {
- unsafe extern #abi fn ( #( #arguments ),* ) #ret
- })
+ match abi {
+ Abi::ThisCall if !ctx.options().rust_features().thiscall_abi() => {
+ warn!("Skipping function with thiscall ABI that isn't supported by the configured Rust target");
+ Ok(quote::Tokens::new())
+ }
+ _ => {
+ Ok(quote! {
+ unsafe extern #abi fn ( #( #arguments ),* ) #ret
+ })
+ }
+ }
}
}
@@ -3146,6 +3158,10 @@ impl CodeGenerator for Function {
}
let abi = match signature.abi() {
+ Abi::ThisCall if !ctx.options().rust_features().thiscall_abi() => {
+ warn!("Skipping function with thiscall ABI that isn't supported by the configured Rust target");
+ return;
+ }
Abi::Unknown(unknown_abi) => {
panic!(
"Invalid or unknown abi {:?} for function {:?} ({:?})",