Skip to content

Commit

Permalink
retval
Browse files Browse the repository at this point in the history
  • Loading branch information
kennykerr committed Jan 12, 2024
1 parent a88afc6 commit e7e900d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
8 changes: 8 additions & 0 deletions crates/libs/bindgen/src/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,14 @@ impl Signature {
}

fn is_retval(&self) -> bool {
// First we check whether there's an actual retval parameter.
if let Some(param) = self.params.last() {
if param.def.has_attribute("RetValAttribute") {
return true;
}
}

// Then we see if we can infer retval-like behavior more conservatively.
self.params.last().map_or(false, |param| param.is_retval())
&& self.params[..self.params.len() - 1].iter().all(|param| {
let flags = param.def.flags();
Expand Down
7 changes: 2 additions & 5 deletions crates/samples/windows/shell/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,17 @@ fn shell_execute_from_explorer(
fn find_desktop_folder_view<T: Interface>() -> Result<T> {
unsafe {
let windows: IShellWindows = CoCreateInstance(&ShellWindows, None, CLSCTX_ALL)?;
let mut dispatch = None;
let mut handle = 0;

// TODO: find out why this retval isn't kicking in
windows.FindWindowSW(
let desktop = windows.FindWindowSW(
&VARIANT::from(CSIDL_DESKTOP),
&VARIANT::default(),
SWC_DESKTOP,
&mut handle,
SWFO_NEEDDISPATCH,
&mut dispatch,
)?;

let provider: IServiceProvider = dispatch.unwrap().cast()?;
let provider: IServiceProvider = desktop.cast()?;
let browser: IShellBrowser = provider.QueryService(&SID_STopLevelBrowser)?;
let view = browser.QueryActiveShellView()?;
view.cast()
Expand Down

0 comments on commit e7e900d

Please sign in to comment.