-
Notifications
You must be signed in to change notification settings - Fork 494
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support additional
VARIANT
types (#2892)
- Loading branch information
Showing
6 changed files
with
180 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
crates/libs/bindgen/src/rust/extensions/mod/Win32/System/Com/IDispatch.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
impl From<IDispatch> for ::windows_core::VARIANT { | ||
fn from(value: IDispatch) -> Self { | ||
unsafe { | ||
Self::from_raw(::windows_core::imp::VARIANT { | ||
Anonymous: ::windows_core::imp::VARIANT_0 { | ||
Anonymous: ::windows_core::imp::VARIANT_0_0 { | ||
vt: 9, | ||
wReserved1: 0, | ||
wReserved2: 0, | ||
wReserved3: 0, | ||
Anonymous: ::windows_core::imp::VARIANT_0_0_0 { pdispVal: ::std::mem::transmute(value) }, | ||
}, | ||
}, | ||
}) | ||
} | ||
} | ||
} | ||
|
||
impl From<IDispatch> for ::windows_core::PROPVARIANT { | ||
fn from(value: IDispatch) -> Self { | ||
unsafe { | ||
Self::from_raw(::windows_core::imp::PROPVARIANT { | ||
Anonymous: ::windows_core::imp::PROPVARIANT_0 { | ||
Anonymous: ::windows_core::imp::PROPVARIANT_0_0 { | ||
vt: 9, | ||
wReserved1: 0, | ||
wReserved2: 0, | ||
wReserved3: 0, | ||
Anonymous: ::windows_core::imp::PROPVARIANT_0_0_0 { pdispVal: ::std::mem::transmute(value) }, | ||
}, | ||
}, | ||
}) | ||
} | ||
} | ||
} | ||
|
||
impl TryFrom<&::windows_core::VARIANT> for IDispatch { | ||
type Error = ::windows_core::Error; | ||
fn try_from(from: &::windows_core::VARIANT) -> ::windows_core::Result<Self> { | ||
let from = from.as_raw(); | ||
unsafe { | ||
if from.Anonymous.Anonymous.vt == 9 && !from.Anonymous.Anonymous.Anonymous.pdispVal.is_null() { | ||
let dispatch: &IDispatch = std::mem::transmute(&from.Anonymous.Anonymous.Anonymous.pdispVal); | ||
Ok(dispatch.clone()) | ||
} else { | ||
Err(::windows_core::Error::from_hresult(::windows_core::imp::TYPE_E_TYPEMISMATCH)) | ||
} | ||
} | ||
} | ||
} | ||
|
||
impl TryFrom<&::windows_core::PROPVARIANT> for IDispatch { | ||
type Error = ::windows_core::Error; | ||
fn try_from(from: &::windows_core::PROPVARIANT) -> ::windows_core::Result<Self> { | ||
let from = from.as_raw(); | ||
unsafe { | ||
if from.Anonymous.Anonymous.vt == 9 && !from.Anonymous.Anonymous.Anonymous.pdispVal.is_null() { | ||
let dispatch: &IDispatch = std::mem::transmute(&from.Anonymous.Anonymous.Anonymous.pdispVal); | ||
Ok(dispatch.clone()) | ||
} else { | ||
Err(::windows_core::Error::from_hresult(::windows_core::imp::TYPE_E_TYPEMISMATCH)) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,4 +12,5 @@ path = "../../libs/windows" | |
features = [ | ||
"Foundation", | ||
"Win32_Foundation", | ||
"Win32_System_Com_Events", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters