Skip to content

Commit

Permalink
tests and samples
Browse files Browse the repository at this point in the history
  • Loading branch information
kennykerr committed Oct 29, 2024
1 parent f74f860 commit 94c1cb3
Show file tree
Hide file tree
Showing 25 changed files with 576 additions and 597 deletions.
1 change: 0 additions & 1 deletion crates/samples/components/json_validator_winrt/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ serde_json = {version = "1.0", default-features = false }
[dependencies.windows]
workspace = true
features = [
"implement",
"Win32_System_WinRT",
]

Expand Down
146 changes: 73 additions & 73 deletions crates/samples/components/json_validator_winrt/src/bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,41 @@ pub struct IJsonValidator_Vtbl {
*mut core::mem::MaybeUninit<windows_core::HSTRING>,
) -> windows_core::HRESULT,
}
pub trait IJsonValidator_Impl: Sized + windows_core::IUnknownImpl {
fn Validate(
&self,
value: &windows_core::HSTRING,
) -> windows_core::Result<windows_core::HSTRING>;
}
impl windows_core::RuntimeName for IJsonValidator {
const NAME: &'static str = "Sample.IJsonValidator";
}
impl IJsonValidator_Vtbl {
pub const fn new<Identity: IJsonValidator_Impl, const OFFSET: isize>() -> IJsonValidator_Vtbl {
unsafe extern "system" fn Validate<Identity: IJsonValidator_Impl, const OFFSET: isize>(
this: *mut core::ffi::c_void,
value: core::mem::MaybeUninit<windows_core::HSTRING>,
result__: *mut core::mem::MaybeUninit<windows_core::HSTRING>,
) -> windows_core::HRESULT {
let this: &Identity = &*((this as *const *const ()).offset(OFFSET) as *const Identity);
match IJsonValidator_Impl::Validate(this, core::mem::transmute(&value)) {
Ok(ok__) => {
result__.write(core::mem::transmute_copy(&ok__));
core::mem::forget(ok__);
windows_core::HRESULT(0)
}
Err(err) => err.into(),
}
}
Self {
base__: windows_core::IInspectable_Vtbl::new::<Identity, IJsonValidator, OFFSET>(),
Validate: Validate::<Identity, OFFSET>,
}
}
pub fn matches(iid: &windows_core::GUID) -> bool {
iid == &<IJsonValidator as windows_core::Interface>::IID
}
}
windows_core::imp::define_interface!(
IJsonValidatorFactory,
IJsonValidatorFactory_Vtbl,
Expand All @@ -43,6 +78,44 @@ pub struct IJsonValidatorFactory_Vtbl {
*mut *mut core::ffi::c_void,
) -> windows_core::HRESULT,
}
pub trait IJsonValidatorFactory_Impl: Sized + windows_core::IUnknownImpl {
fn CreateInstance(&self, schema: &windows_core::HSTRING)
-> windows_core::Result<JsonValidator>;
}
impl windows_core::RuntimeName for IJsonValidatorFactory {
const NAME: &'static str = "Sample.IJsonValidatorFactory";
}
impl IJsonValidatorFactory_Vtbl {
pub const fn new<Identity: IJsonValidatorFactory_Impl, const OFFSET: isize>(
) -> IJsonValidatorFactory_Vtbl {
unsafe extern "system" fn CreateInstance<
Identity: IJsonValidatorFactory_Impl,
const OFFSET: isize,
>(
this: *mut core::ffi::c_void,
schema: core::mem::MaybeUninit<windows_core::HSTRING>,
result__: *mut *mut core::ffi::c_void,
) -> windows_core::HRESULT {
let this: &Identity = &*((this as *const *const ()).offset(OFFSET) as *const Identity);
match IJsonValidatorFactory_Impl::CreateInstance(this, core::mem::transmute(&schema)) {
Ok(ok__) => {
result__.write(core::mem::transmute_copy(&ok__));
core::mem::forget(ok__);
windows_core::HRESULT(0)
}
Err(err) => err.into(),
}
}
Self {
base__: windows_core::IInspectable_Vtbl::new::<Identity, IJsonValidatorFactory, OFFSET>(
),
CreateInstance: CreateInstance::<Identity, OFFSET>,
}
}
pub fn matches(iid: &windows_core::GUID) -> bool {
iid == &<IJsonValidatorFactory as windows_core::Interface>::IID
}
}
#[repr(transparent)]
#[derive(PartialEq, Eq, Debug, Clone)]
pub struct JsonValidator(windows_core::IUnknown);
Expand Down Expand Up @@ -99,76 +172,3 @@ impl windows_core::RuntimeName for JsonValidator {
}
unsafe impl Send for JsonValidator {}
unsafe impl Sync for JsonValidator {}
pub trait IJsonValidator_Impl: Sized + windows_core::IUnknownImpl {
fn Validate(
&self,
value: &windows_core::HSTRING,
) -> windows_core::Result<windows_core::HSTRING>;
}
impl windows_core::RuntimeName for IJsonValidator {
const NAME: &'static str = "Sample.IJsonValidator";
}
impl IJsonValidator_Vtbl {
pub const fn new<Identity: IJsonValidator_Impl, const OFFSET: isize>() -> IJsonValidator_Vtbl {
unsafe extern "system" fn Validate<Identity: IJsonValidator_Impl, const OFFSET: isize>(
this: *mut core::ffi::c_void,
value: core::mem::MaybeUninit<windows_core::HSTRING>,
result__: *mut core::mem::MaybeUninit<windows_core::HSTRING>,
) -> windows_core::HRESULT {
let this: &Identity = &*((this as *const *const ()).offset(OFFSET) as *const Identity);
match IJsonValidator_Impl::Validate(this, core::mem::transmute(&value)) {
Ok(ok__) => {
result__.write(core::mem::transmute_copy(&ok__));
core::mem::forget(ok__);
windows_core::HRESULT(0)
}
Err(err) => err.into(),
}
}
Self {
base__: windows_core::IInspectable_Vtbl::new::<Identity, IJsonValidator, OFFSET>(),
Validate: Validate::<Identity, OFFSET>,
}
}
pub fn matches(iid: &windows_core::GUID) -> bool {
iid == &<IJsonValidator as windows_core::Interface>::IID
}
}
pub trait IJsonValidatorFactory_Impl: Sized + windows_core::IUnknownImpl {
fn CreateInstance(&self, schema: &windows_core::HSTRING)
-> windows_core::Result<JsonValidator>;
}
impl windows_core::RuntimeName for IJsonValidatorFactory {
const NAME: &'static str = "Sample.IJsonValidatorFactory";
}
impl IJsonValidatorFactory_Vtbl {
pub const fn new<Identity: IJsonValidatorFactory_Impl, const OFFSET: isize>(
) -> IJsonValidatorFactory_Vtbl {
unsafe extern "system" fn CreateInstance<
Identity: IJsonValidatorFactory_Impl,
const OFFSET: isize,
>(
this: *mut core::ffi::c_void,
schema: core::mem::MaybeUninit<windows_core::HSTRING>,
result__: *mut *mut core::ffi::c_void,
) -> windows_core::HRESULT {
let this: &Identity = &*((this as *const *const ()).offset(OFFSET) as *const Identity);
match IJsonValidatorFactory_Impl::CreateInstance(this, core::mem::transmute(&schema)) {
Ok(ok__) => {
result__.write(core::mem::transmute_copy(&ok__));
core::mem::forget(ok__);
windows_core::HRESULT(0)
}
Err(err) => err.into(),
}
}
Self {
base__: windows_core::IInspectable_Vtbl::new::<Identity, IJsonValidatorFactory, OFFSET>(
),
CreateInstance: CreateInstance::<Identity, OFFSET>,
}
}
pub fn matches(iid: &windows_core::GUID) -> bool {
iid == &<IJsonValidatorFactory as windows_core::Interface>::IID
}
}
1 change: 0 additions & 1 deletion crates/samples/windows/bits/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ publish = false
[dependencies.windows]
workspace = true
features = [
"implement",
"Win32_System_Com",
"Win32_Networking_BackgroundIntelligentTransferService",
]
Expand Down
1 change: 0 additions & 1 deletion crates/samples/windows/core_app/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ publish = false
[dependencies.windows]
workspace = true
features = [
"implement",
"ApplicationModel_Core",
"UI_Core",
"Win32_Storage_Packaging_Appx",
Expand Down
1 change: 0 additions & 1 deletion crates/tests/misc/async/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ doctest = false
[dependencies.windows]
workspace = true
features = [
"implement",
"Storage_Streams",
"System_Threading",
"Win32_Foundation",
Expand Down
1 change: 0 additions & 1 deletion crates/tests/misc/component/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ workspace = true
[dependencies.windows]
workspace = true
features = [
"implement",
"Foundation",
"Win32_System_WinRT",
]
Expand Down
Loading

0 comments on commit 94c1cb3

Please sign in to comment.