Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workaround for variadic API function support #2458

Merged
merged 2 commits into from
Apr 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions crates/libs/bindgen/src/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,13 +207,11 @@ fn gen_link(gen: &Gen, signature: &Signature, cfg: &Cfg) -> TokenStream {

let return_type = gen.return_sig(signature);

// TODO: blocked on https://github.com/rust-lang/rust/issues/110505
// let vararg = if signature.vararg {
// "...".into()
// } else {
// quote! {}
// };
let vararg = quote! {};
let vararg = if gen.sys && signature.vararg {
"...".into()
} else {
quote! {}
};

if gen.std || !gen.namespace.starts_with("Windows.") {
let library = library.trim_end_matches(".dll");
Expand All @@ -222,15 +220,15 @@ fn gen_link(gen: &Gen, signature: &Signature, cfg: &Cfg) -> TokenStream {
#[link(name = #library)]
extern #abi {
#link_name
pub fn #ident(#(#params),* #vararg) #return_type;
pub fn #ident(#(#params,)* #vararg) #return_type;
}
}
} else if let Some(library) = gen.reader.method_def_static_lib(signature.def) {
quote! {
#[link(name = #library, kind = "static")]
extern #abi {
#link_name
pub fn #ident(#(#params),* #vararg) #return_type;
pub fn #ident(#(#params,)* #vararg) #return_type;
}
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion crates/libs/sys/src/Windows/Wdk/Storage/FileSystem/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -922,7 +922,7 @@
#[cfg(feature = "Win32_Foundation")]
::windows_targets::link!("ntdll.dll" "system" #[doc = "*Required features: `\"Wdk_Storage_FileSystem\"`, `\"Win32_Foundation\"`*"] fn RtlInitializeSid(sid : super::super::super::Win32::Foundation:: PSID, identifierauthority : *const SID_IDENTIFIER_AUTHORITY, subauthoritycount : u8) -> super::super::super::Win32::Foundation:: NTSTATUS);
#[cfg(feature = "Win32_Foundation")]
::windows_targets::link!("ntdll.dll" "cdecl" #[doc = "*Required features: `\"Wdk_Storage_FileSystem\"`, `\"Win32_Foundation\"`*"] fn RtlInitializeSidEx(sid : super::super::super::Win32::Foundation:: PSID, identifierauthority : *const SID_IDENTIFIER_AUTHORITY, subauthoritycount : u8) -> super::super::super::Win32::Foundation:: NTSTATUS);
::windows_targets::link!("ntdll.dll" "cdecl" #[doc = "*Required features: `\"Wdk_Storage_FileSystem\"`, `\"Win32_Foundation\"`*"] fn RtlInitializeSidEx(sid : super::super::super::Win32::Foundation:: PSID, identifierauthority : *const SID_IDENTIFIER_AUTHORITY, subauthoritycount : u8, ...) -> super::super::super::Win32::Foundation:: NTSTATUS);
#[cfg(all(feature = "Wdk_Foundation", feature = "Win32_Foundation"))]
::windows_targets::link!("ntoskrnl.exe" "system" #[doc = "*Required features: `\"Wdk_Storage_FileSystem\"`, `\"Wdk_Foundation\"`, `\"Win32_Foundation\"`*"] fn RtlInitializeUnicodePrefix(prefixtable : *mut UNICODE_PREFIX_TABLE) -> ());
#[cfg(all(feature = "Wdk_Foundation", feature = "Win32_Foundation"))]
Expand Down
6 changes: 3 additions & 3 deletions crates/libs/sys/src/Windows/Wdk/System/SystemServices/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,9 @@
#[cfg(feature = "Win32_Foundation")]
::windows_targets::link!("ntoskrnl.exe" "system" #[doc = "*Required features: `\"Wdk_System_SystemServices\"`, `\"Win32_Foundation\"`*"] fn CmUnRegisterCallback(cookie : i64) -> super::super::super::Win32::Foundation:: NTSTATUS);
::windows_targets::link!("ntoskrnl.exe" "system" #[doc = "*Required features: `\"Wdk_System_SystemServices\"`*"] fn DbgBreakPointWithStatus(status : u32) -> ());
::windows_targets::link!("ntdll.dll" "cdecl" #[doc = "*Required features: `\"Wdk_System_SystemServices\"`*"] fn DbgPrint(format : ::windows_sys::core::PCSTR) -> u32);
::windows_targets::link!("ntdll.dll" "cdecl" #[doc = "*Required features: `\"Wdk_System_SystemServices\"`*"] fn DbgPrintEx(componentid : u32, level : u32, format : ::windows_sys::core::PCSTR) -> u32);
::windows_targets::link!("ntdll.dll" "cdecl" #[doc = "*Required features: `\"Wdk_System_SystemServices\"`*"] fn DbgPrintReturnControlC(format : ::windows_sys::core::PCSTR) -> u32);
::windows_targets::link!("ntdll.dll" "cdecl" #[doc = "*Required features: `\"Wdk_System_SystemServices\"`*"] fn DbgPrint(format : ::windows_sys::core::PCSTR, ...) -> u32);
::windows_targets::link!("ntdll.dll" "cdecl" #[doc = "*Required features: `\"Wdk_System_SystemServices\"`*"] fn DbgPrintEx(componentid : u32, level : u32, format : ::windows_sys::core::PCSTR, ...) -> u32);
::windows_targets::link!("ntdll.dll" "cdecl" #[doc = "*Required features: `\"Wdk_System_SystemServices\"`*"] fn DbgPrintReturnControlC(format : ::windows_sys::core::PCSTR, ...) -> u32);
::windows_targets::link!("ntdll.dll" "system" #[doc = "*Required features: `\"Wdk_System_SystemServices\"`*"] fn DbgPrompt(prompt : ::windows_sys::core::PCSTR, response : ::windows_sys::core::PSTR, length : u32) -> u32);
#[cfg(feature = "Win32_Foundation")]
::windows_targets::link!("ntdll.dll" "system" #[doc = "*Required features: `\"Wdk_System_SystemServices\"`, `\"Win32_Foundation\"`*"] fn DbgQueryDebugFilterState(componentid : u32, level : u32) -> super::super::super::Win32::Foundation:: NTSTATUS);
Expand Down
18 changes: 9 additions & 9 deletions crates/libs/sys/src/Windows/Win32/Devices/AllJoyn/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,24 +332,24 @@
::windows_targets::link!("msajapi.dll" "system" #[doc = "*Required features: `\"Win32_Devices_AllJoyn\"`*"] fn alljoyn_message_isglobalbroadcast(msg : alljoyn_message) -> i32);
::windows_targets::link!("msajapi.dll" "system" #[doc = "*Required features: `\"Win32_Devices_AllJoyn\"`*"] fn alljoyn_message_issessionless(msg : alljoyn_message) -> i32);
::windows_targets::link!("msajapi.dll" "system" #[doc = "*Required features: `\"Win32_Devices_AllJoyn\"`*"] fn alljoyn_message_isunreliable(msg : alljoyn_message) -> i32);
::windows_targets::link!("msajapi.dll" "cdecl" #[doc = "*Required features: `\"Win32_Devices_AllJoyn\"`*"] fn alljoyn_message_parseargs(msg : alljoyn_message, signature : ::windows_sys::core::PCSTR) -> QStatus);
::windows_targets::link!("msajapi.dll" "cdecl" #[doc = "*Required features: `\"Win32_Devices_AllJoyn\"`*"] fn alljoyn_message_parseargs(msg : alljoyn_message, signature : ::windows_sys::core::PCSTR, ...) -> QStatus);
::windows_targets::link!("msajapi.dll" "system" #[doc = "*Required features: `\"Win32_Devices_AllJoyn\"`*"] fn alljoyn_message_setendianess(endian : i8) -> ());
::windows_targets::link!("msajapi.dll" "system" #[doc = "*Required features: `\"Win32_Devices_AllJoyn\"`*"] fn alljoyn_message_tostring(msg : alljoyn_message, str : ::windows_sys::core::PCSTR, buf : usize) -> usize);
::windows_targets::link!("msajapi.dll" "system" #[doc = "*Required features: `\"Win32_Devices_AllJoyn\"`*"] fn alljoyn_msgarg_array_create(size : usize) -> alljoyn_msgarg);
::windows_targets::link!("msajapi.dll" "system" #[doc = "*Required features: `\"Win32_Devices_AllJoyn\"`*"] fn alljoyn_msgarg_array_element(arg : alljoyn_msgarg, index : usize) -> alljoyn_msgarg);
::windows_targets::link!("msajapi.dll" "cdecl" #[doc = "*Required features: `\"Win32_Devices_AllJoyn\"`*"] fn alljoyn_msgarg_array_get(args : alljoyn_msgarg, numargs : usize, signature : ::windows_sys::core::PCSTR) -> QStatus);
::windows_targets::link!("msajapi.dll" "cdecl" #[doc = "*Required features: `\"Win32_Devices_AllJoyn\"`*"] fn alljoyn_msgarg_array_set(args : alljoyn_msgarg, numargs : *mut usize, signature : ::windows_sys::core::PCSTR) -> QStatus);
::windows_targets::link!("msajapi.dll" "cdecl" #[doc = "*Required features: `\"Win32_Devices_AllJoyn\"`*"] fn alljoyn_msgarg_array_set_offset(args : alljoyn_msgarg, argoffset : usize, numargs : *mut usize, signature : ::windows_sys::core::PCSTR) -> QStatus);
::windows_targets::link!("msajapi.dll" "cdecl" #[doc = "*Required features: `\"Win32_Devices_AllJoyn\"`*"] fn alljoyn_msgarg_array_get(args : alljoyn_msgarg, numargs : usize, signature : ::windows_sys::core::PCSTR, ...) -> QStatus);
::windows_targets::link!("msajapi.dll" "cdecl" #[doc = "*Required features: `\"Win32_Devices_AllJoyn\"`*"] fn alljoyn_msgarg_array_set(args : alljoyn_msgarg, numargs : *mut usize, signature : ::windows_sys::core::PCSTR, ...) -> QStatus);
::windows_targets::link!("msajapi.dll" "cdecl" #[doc = "*Required features: `\"Win32_Devices_AllJoyn\"`*"] fn alljoyn_msgarg_array_set_offset(args : alljoyn_msgarg, argoffset : usize, numargs : *mut usize, signature : ::windows_sys::core::PCSTR, ...) -> QStatus);
::windows_targets::link!("msajapi.dll" "system" #[doc = "*Required features: `\"Win32_Devices_AllJoyn\"`*"] fn alljoyn_msgarg_array_signature(values : alljoyn_msgarg, numvalues : usize, str : ::windows_sys::core::PCSTR, buf : usize) -> usize);
::windows_targets::link!("msajapi.dll" "system" #[doc = "*Required features: `\"Win32_Devices_AllJoyn\"`*"] fn alljoyn_msgarg_array_tostring(args : alljoyn_msgarg, numargs : usize, str : ::windows_sys::core::PCSTR, buf : usize, indent : usize) -> usize);
::windows_targets::link!("msajapi.dll" "system" #[doc = "*Required features: `\"Win32_Devices_AllJoyn\"`*"] fn alljoyn_msgarg_clear(arg : alljoyn_msgarg) -> ());
::windows_targets::link!("msajapi.dll" "system" #[doc = "*Required features: `\"Win32_Devices_AllJoyn\"`*"] fn alljoyn_msgarg_clone(destination : alljoyn_msgarg, source : alljoyn_msgarg) -> ());
::windows_targets::link!("msajapi.dll" "system" #[doc = "*Required features: `\"Win32_Devices_AllJoyn\"`*"] fn alljoyn_msgarg_copy(source : alljoyn_msgarg) -> alljoyn_msgarg);
::windows_targets::link!("msajapi.dll" "system" #[doc = "*Required features: `\"Win32_Devices_AllJoyn\"`*"] fn alljoyn_msgarg_create() -> alljoyn_msgarg);
::windows_targets::link!("msajapi.dll" "cdecl" #[doc = "*Required features: `\"Win32_Devices_AllJoyn\"`*"] fn alljoyn_msgarg_create_and_set(signature : ::windows_sys::core::PCSTR) -> alljoyn_msgarg);
::windows_targets::link!("msajapi.dll" "cdecl" #[doc = "*Required features: `\"Win32_Devices_AllJoyn\"`*"] fn alljoyn_msgarg_create_and_set(signature : ::windows_sys::core::PCSTR, ...) -> alljoyn_msgarg);
::windows_targets::link!("msajapi.dll" "system" #[doc = "*Required features: `\"Win32_Devices_AllJoyn\"`*"] fn alljoyn_msgarg_destroy(arg : alljoyn_msgarg) -> ());
::windows_targets::link!("msajapi.dll" "system" #[doc = "*Required features: `\"Win32_Devices_AllJoyn\"`*"] fn alljoyn_msgarg_equal(lhv : alljoyn_msgarg, rhv : alljoyn_msgarg) -> i32);
::windows_targets::link!("msajapi.dll" "cdecl" #[doc = "*Required features: `\"Win32_Devices_AllJoyn\"`*"] fn alljoyn_msgarg_get(arg : alljoyn_msgarg, signature : ::windows_sys::core::PCSTR) -> QStatus);
::windows_targets::link!("msajapi.dll" "cdecl" #[doc = "*Required features: `\"Win32_Devices_AllJoyn\"`*"] fn alljoyn_msgarg_get(arg : alljoyn_msgarg, signature : ::windows_sys::core::PCSTR, ...) -> QStatus);
::windows_targets::link!("msajapi.dll" "system" #[doc = "*Required features: `\"Win32_Devices_AllJoyn\"`*"] fn alljoyn_msgarg_get_array_element(arg : alljoyn_msgarg, index : usize, element : *mut alljoyn_msgarg) -> ());
::windows_targets::link!("msajapi.dll" "system" #[doc = "*Required features: `\"Win32_Devices_AllJoyn\"`*"] fn alljoyn_msgarg_get_array_elementsignature(arg : alljoyn_msgarg, index : usize) -> ::windows_sys::core::PCSTR);
::windows_targets::link!("msajapi.dll" "system" #[doc = "*Required features: `\"Win32_Devices_AllJoyn\"`*"] fn alljoyn_msgarg_get_array_numberofelements(arg : alljoyn_msgarg) -> usize);
Expand All @@ -376,15 +376,15 @@
::windows_targets::link!("msajapi.dll" "system" #[doc = "*Required features: `\"Win32_Devices_AllJoyn\"`*"] fn alljoyn_msgarg_get_uint8_array(arg : alljoyn_msgarg, length : *mut usize, ay : *mut u8) -> QStatus);
::windows_targets::link!("msajapi.dll" "system" #[doc = "*Required features: `\"Win32_Devices_AllJoyn\"`*"] fn alljoyn_msgarg_get_variant(arg : alljoyn_msgarg, v : alljoyn_msgarg) -> QStatus);
::windows_targets::link!("msajapi.dll" "system" #[doc = "*Required features: `\"Win32_Devices_AllJoyn\"`*"] fn alljoyn_msgarg_get_variant_array(arg : alljoyn_msgarg, signature : ::windows_sys::core::PCSTR, length : *mut usize, av : *mut alljoyn_msgarg) -> QStatus);
::windows_targets::link!("msajapi.dll" "cdecl" #[doc = "*Required features: `\"Win32_Devices_AllJoyn\"`*"] fn alljoyn_msgarg_getdictelement(arg : alljoyn_msgarg, elemsig : ::windows_sys::core::PCSTR) -> QStatus);
::windows_targets::link!("msajapi.dll" "cdecl" #[doc = "*Required features: `\"Win32_Devices_AllJoyn\"`*"] fn alljoyn_msgarg_getdictelement(arg : alljoyn_msgarg, elemsig : ::windows_sys::core::PCSTR, ...) -> QStatus);
::windows_targets::link!("msajapi.dll" "system" #[doc = "*Required features: `\"Win32_Devices_AllJoyn\"`*"] fn alljoyn_msgarg_getkey(arg : alljoyn_msgarg) -> alljoyn_msgarg);
::windows_targets::link!("msajapi.dll" "system" #[doc = "*Required features: `\"Win32_Devices_AllJoyn\"`*"] fn alljoyn_msgarg_getmember(arg : alljoyn_msgarg, index : usize) -> alljoyn_msgarg);
::windows_targets::link!("msajapi.dll" "system" #[doc = "*Required features: `\"Win32_Devices_AllJoyn\"`*"] fn alljoyn_msgarg_getnummembers(arg : alljoyn_msgarg) -> usize);
::windows_targets::link!("msajapi.dll" "system" #[doc = "*Required features: `\"Win32_Devices_AllJoyn\"`*"] fn alljoyn_msgarg_gettype(arg : alljoyn_msgarg) -> alljoyn_typeid);
::windows_targets::link!("msajapi.dll" "system" #[doc = "*Required features: `\"Win32_Devices_AllJoyn\"`*"] fn alljoyn_msgarg_getvalue(arg : alljoyn_msgarg) -> alljoyn_msgarg);
::windows_targets::link!("msajapi.dll" "system" #[doc = "*Required features: `\"Win32_Devices_AllJoyn\"`*"] fn alljoyn_msgarg_hassignature(arg : alljoyn_msgarg, signature : ::windows_sys::core::PCSTR) -> i32);
::windows_targets::link!("msajapi.dll" "cdecl" #[doc = "*Required features: `\"Win32_Devices_AllJoyn\"`*"] fn alljoyn_msgarg_set(arg : alljoyn_msgarg, signature : ::windows_sys::core::PCSTR) -> QStatus);
::windows_targets::link!("msajapi.dll" "cdecl" #[doc = "*Required features: `\"Win32_Devices_AllJoyn\"`*"] fn alljoyn_msgarg_set_and_stabilize(arg : alljoyn_msgarg, signature : ::windows_sys::core::PCSTR) -> QStatus);
::windows_targets::link!("msajapi.dll" "cdecl" #[doc = "*Required features: `\"Win32_Devices_AllJoyn\"`*"] fn alljoyn_msgarg_set(arg : alljoyn_msgarg, signature : ::windows_sys::core::PCSTR, ...) -> QStatus);
::windows_targets::link!("msajapi.dll" "cdecl" #[doc = "*Required features: `\"Win32_Devices_AllJoyn\"`*"] fn alljoyn_msgarg_set_and_stabilize(arg : alljoyn_msgarg, signature : ::windows_sys::core::PCSTR, ...) -> QStatus);
::windows_targets::link!("msajapi.dll" "system" #[doc = "*Required features: `\"Win32_Devices_AllJoyn\"`*"] fn alljoyn_msgarg_set_bool(arg : alljoyn_msgarg, b : i32) -> QStatus);
::windows_targets::link!("msajapi.dll" "system" #[doc = "*Required features: `\"Win32_Devices_AllJoyn\"`*"] fn alljoyn_msgarg_set_bool_array(arg : alljoyn_msgarg, length : usize, ab : *mut i32) -> QStatus);
::windows_targets::link!("msajapi.dll" "system" #[doc = "*Required features: `\"Win32_Devices_AllJoyn\"`*"] fn alljoyn_msgarg_set_double(arg : alljoyn_msgarg, d : f64) -> QStatus);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -921,8 +921,8 @@
::windows_targets::link!("setupapi.dll" "system" #[doc = "*Required features: `\"Win32_Devices_DeviceAndDriverInstallation\"`, `\"Win32_Foundation\"`, `\"Win32_System_Diagnostics_Debug\"`*"] fn SetupVerifyInfFileA(infname : ::windows_sys::core::PCSTR, altplatforminfo : *const SP_ALTPLATFORM_INFO_V2, infsignerinfo : *mut SP_INF_SIGNER_INFO_V2_A) -> super::super::Foundation:: BOOL);
#[cfg(all(feature = "Win32_Foundation", feature = "Win32_System_Diagnostics_Debug"))]
::windows_targets::link!("setupapi.dll" "system" #[doc = "*Required features: `\"Win32_Devices_DeviceAndDriverInstallation\"`, `\"Win32_Foundation\"`, `\"Win32_System_Diagnostics_Debug\"`*"] fn SetupVerifyInfFileW(infname : ::windows_sys::core::PCWSTR, altplatforminfo : *const SP_ALTPLATFORM_INFO_V2, infsignerinfo : *mut SP_INF_SIGNER_INFO_V2_W) -> super::super::Foundation:: BOOL);
::windows_targets::link!("setupapi.dll" "cdecl" #[doc = "*Required features: `\"Win32_Devices_DeviceAndDriverInstallation\"`*"] fn SetupWriteTextLog(logtoken : u64, category : u32, flags : u32, messagestr : ::windows_sys::core::PCSTR) -> ());
::windows_targets::link!("setupapi.dll" "cdecl" #[doc = "*Required features: `\"Win32_Devices_DeviceAndDriverInstallation\"`*"] fn SetupWriteTextLogError(logtoken : u64, category : u32, logflags : u32, error : u32, messagestr : ::windows_sys::core::PCSTR) -> ());
::windows_targets::link!("setupapi.dll" "cdecl" #[doc = "*Required features: `\"Win32_Devices_DeviceAndDriverInstallation\"`*"] fn SetupWriteTextLog(logtoken : u64, category : u32, flags : u32, messagestr : ::windows_sys::core::PCSTR, ...) -> ());
::windows_targets::link!("setupapi.dll" "cdecl" #[doc = "*Required features: `\"Win32_Devices_DeviceAndDriverInstallation\"`*"] fn SetupWriteTextLogError(logtoken : u64, category : u32, logflags : u32, error : u32, messagestr : ::windows_sys::core::PCSTR, ...) -> ());
::windows_targets::link!("setupapi.dll" "system" #[doc = "*Required features: `\"Win32_Devices_DeviceAndDriverInstallation\"`*"] fn SetupWriteTextLogInfLine(logtoken : u64, flags : u32, infhandle : *const ::core::ffi::c_void, context : *const INFCONTEXT) -> ());
#[cfg(feature = "Win32_Foundation")]
::windows_targets::link!("newdev.dll" "system" #[doc = "*Required features: `\"Win32_Devices_DeviceAndDriverInstallation\"`, `\"Win32_Foundation\"`*"] fn UpdateDriverForPlugAndPlayDevicesA(hwndparent : super::super::Foundation:: HWND, hardwareid : ::windows_sys::core::PCSTR, fullinfpath : ::windows_sys::core::PCSTR, installflags : u32, brebootrequired : *mut super::super::Foundation:: BOOL) -> super::super::Foundation:: BOOL);
Expand Down
Loading