Skip to content

Commit

Permalink
Remove "std" writer from windows-bindgen (#3130)
Browse files Browse the repository at this point in the history
  • Loading branch information
kennykerr authored Jun 26, 2024
1 parent 707e0bb commit f69ba3d
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 31 deletions.
2 changes: 1 addition & 1 deletion crates/libs/bindgen/src/rust/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ fn gen_link(writer: &Writer, namespace: &str, signature: &metadata::Signature) -
quote! {}
};

if writer.std || !namespace.starts_with("Windows.") {
if !namespace.starts_with("Windows.") {
let library = library.trim_end_matches(".dll");

quote! {
Expand Down
3 changes: 1 addition & 2 deletions crates/libs/bindgen/src/rust/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ pub fn from_reader(
let mut writer = Writer::new(reader, output);
writer.package = config.remove("package").is_some();
writer.flatten = config.remove("flatten").is_some();
writer.std = config.remove("std").is_some();
writer.sys = writer.std || config.remove("sys").is_some();
writer.sys = config.remove("sys").is_some();
writer.implement = config.remove("implement").is_some();
writer.minimal = config.remove("minimal").is_some();
writer.no_inner_attributes = config.remove("no-inner-attributes").is_some();
Expand Down
2 changes: 0 additions & 2 deletions crates/libs/bindgen/src/rust/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ pub struct Writer {
//
// Maybe this macro is the embedable version of the IDL format?! like a more intelligient
// version of the existing interface macro...
pub std: bool, // tweaks for internal std library support
pub sys: bool, // writer sys-style bindings
pub flatten: bool, // strips out namespaces - implies !package
pub package: bool, // default is single file with no cfg - implies !flatten
Expand All @@ -33,7 +32,6 @@ impl Writer {
output: output.to_string(),
namespace: "",
implement: false,
std: false,
sys: false,
flatten: false,
package: false,
Expand Down
26 changes: 5 additions & 21 deletions crates/tests/standalone/src/b_std.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,11 @@
dead_code,
clippy::all
)]
#[link(name = "advapi32")]
extern "system" {
#[link_name = "SystemFunction036"]
pub fn RtlGenRandom(randombuffer: *mut core::ffi::c_void, randombufferlength: u32) -> BOOLEAN;
}
#[link(name = "kernel32")]
extern "system" {
pub fn CloseHandle(hobject: HANDLE) -> BOOL;
}
#[link(name = "kernel32")]
extern "system" {
pub fn GetLastError() -> WIN32_ERROR;
}
#[link(name = "user32")]
extern "cdecl" {
pub fn wsprintfA(param0: PSTR, param1: PCSTR, ...) -> i32;
}
#[link(name = "ws2_32")]
extern "system" {
pub fn socket(af: i32, r#type: WINSOCK_SOCKET_TYPE, protocol: i32) -> SOCKET;
}
windows_targets::link!("advapi32.dll" "system" "SystemFunction036" fn RtlGenRandom(randombuffer : *mut core::ffi::c_void, randombufferlength : u32) -> BOOLEAN);
windows_targets::link!("kernel32.dll" "system" fn CloseHandle(hobject : HANDLE) -> BOOL);
windows_targets::link!("kernel32.dll" "system" fn GetLastError() -> WIN32_ERROR);
windows_targets::link!("user32.dll" "cdecl" fn wsprintfA(param0 : PSTR, param1 : PCSTR, ...) -> i32);
windows_targets::link!("ws2_32.dll" "system" fn socket(af : i32, r#type : WINSOCK_SOCKET_TYPE, protocol : i32) -> SOCKET);
pub type BCRYPT_ALG_HANDLE = *mut core::ffi::c_void;
pub type BOOL = i32;
pub type BOOLEAN = u8;
Expand Down
6 changes: 1 addition & 5 deletions crates/tools/standalone/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ fn main() {
],
);

write_std(
write_sys(
&src.join("b_std.rs"),
&[
"Windows.Win32.Foundation.CloseHandle",
Expand Down Expand Up @@ -223,10 +223,6 @@ fn write_win(output: &Path, filter: &[&str]) {
riddle(output, filter, &["flatten", "minimal"]);
}

fn write_std(output: &Path, filter: &[&str]) {
riddle(output, filter, &["flatten", "std", "minimal"]);
}

fn write_no_inner_attr(output: &Path, filter: &[&str]) {
riddle(
output,
Expand Down

0 comments on commit f69ba3d

Please sign in to comment.