-
Notifications
You must be signed in to change notification settings - Fork 513
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f69ba3d
commit 41d2e99
Showing
11 changed files
with
387 additions
and
163 deletions.
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
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 |
---|---|---|
@@ -1,13 +1,21 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010"> | ||
<Type Name="windows_result::error::Error"> | ||
<Expand> | ||
<ExpandedItem>code</ExpandedItem> | ||
<Item Name="[info]">info</Item> | ||
<ExpandedItem>(HRESULT)code.__0.__0,hr</ExpandedItem> | ||
<Item Name="[code]">(HRESULT)code.__0.__0</Item> | ||
<Item Name="[info]">info.ptr</Item> | ||
</Expand> | ||
</Type> | ||
|
||
<Type Name="windows_result::hresult::HRESULT"> | ||
<DisplayString>{(HRESULT)__0}</DisplayString> | ||
</Type> | ||
|
||
<Type Name="windows_result::error::error_info::ErrorInfo"> | ||
<DisplayString>ErrorInfo</DisplayString> | ||
<Expand> | ||
<Item Name="[object]">*(void**)&ptr</Item> | ||
</Expand> | ||
</Type> | ||
</AutoVisualizer> |
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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
use super::*; | ||
|
||
#[repr(transparent)] | ||
pub struct BasicString(*const u16); | ||
|
||
impl BasicString { | ||
pub fn is_empty(&self) -> bool { | ||
self.len() == 0 | ||
} | ||
|
||
pub fn len(&self) -> usize { | ||
if self.0.is_null() { | ||
0 | ||
} else { | ||
unsafe { SysStringLen(self.0) as usize } | ||
} | ||
} | ||
|
||
pub fn as_wide(&self) -> &[u16] { | ||
let len = self.len(); | ||
if len != 0 { | ||
unsafe { core::slice::from_raw_parts(self.as_ptr(), len) } | ||
} else { | ||
&[] | ||
} | ||
} | ||
|
||
pub fn as_ptr(&self) -> *const u16 { | ||
if !self.is_empty() { | ||
self.0 | ||
} else { | ||
const EMPTY: [u16; 1] = [0]; | ||
EMPTY.as_ptr() | ||
} | ||
} | ||
} | ||
|
||
impl Default for BasicString { | ||
fn default() -> Self { | ||
Self(core::ptr::null_mut()) | ||
} | ||
} | ||
|
||
impl Drop for BasicString { | ||
fn drop(&mut self) { | ||
if !self.0.is_null() { | ||
unsafe { SysFreeString(self.0) } | ||
} | ||
} | ||
} |
Oops, something went wrong.