Emit consistent stub signatures on unsupported platforms
@@ -51,14 +51,12 @@ impl Function {
link = "onecoreuap";
}
- if cfg!(windows) {
+ let body = if cfg!(windows) {
if signature.has_query_interface() {
let leading_params = &signature.params[..signature.params.len() - 2];
- let params = signature.gen_win32_params(leading_params, gen);
let args = leading_params.iter().map(|p| p.gen_win32_abi_arg());
quote! {
- pub unsafe fn #name<#constraints T: ::windows::Interface>(#params) -> ::windows::Result<T> {
#[link(name = #link)]
extern "system" {
pub fn #name(#(#abi_params),*) #abi_return_type;
@@ -66,10 +64,8 @@ impl Function {
let mut result__ = ::std::option::Option::None;
#name(#(#args,)* &<T as ::windows::Interface>::IID, ::windows::Abi::set_abi(&mut result__)).and_some(result__)
}
- }
} else {
quote! {
- pub unsafe fn #name<#constraints>(#params) #return_type {
#[link(name = #link)]
extern "system" {
pub fn #name(#(#abi_params),*) #abi_return_type;
@@ -77,11 +73,24 @@ impl Function {
#name(#(#args),*)
}
}
+ } else {
+ quote! {
+ unimplemented!("Unsupported target OS");
+ }
+ };
+
+ if signature.has_query_interface() {
+ let leading_params = &signature.params[..signature.params.len() - 2];
+ let params = signature.gen_win32_params(leading_params, gen);
+ quote! {
+ pub unsafe fn #name<#constraints T: ::windows::Interface>(#params) -> ::windows::Result<T> {
+ #body
+ }
}
} else {
quote! {
pub unsafe fn #name<#constraints>(#params) #return_type {
- panic!("Unsupported target OS");
+ #body
}
}
}
