Skip to content

Commit

Permalink
bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
kennykerr committed Nov 28, 2024
1 parent c424c9c commit 35db6e3
Show file tree
Hide file tree
Showing 8 changed files with 810 additions and 810 deletions.
112 changes: 56 additions & 56 deletions crates/samples/components/json_validator_winrt/src/bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,62 @@
clippy::all
)]

#[repr(transparent)]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct JsonValidator(windows_core::IUnknown);
windows_core::imp::interface_hierarchy!(
JsonValidator,
windows_core::IUnknown,
windows_core::IInspectable
);
impl JsonValidator {
pub fn Validate(
&self,
value: &windows_core::HSTRING,
) -> windows_core::Result<windows_core::HSTRING> {
let this = self;
unsafe {
let mut result__ = core::mem::zeroed();
(windows_core::Interface::vtable(this).Validate)(
windows_core::Interface::as_raw(this),
core::mem::transmute_copy(value),
&mut result__,
)
.map(|| core::mem::transmute(result__))
}
}
pub fn CreateInstance(schema: &windows_core::HSTRING) -> windows_core::Result<JsonValidator> {
Self::IJsonValidatorFactory(|this| unsafe {
let mut result__ = core::mem::zeroed();
(windows_core::Interface::vtable(this).CreateInstance)(
windows_core::Interface::as_raw(this),
core::mem::transmute_copy(schema),
&mut result__,
)
.and_then(|| windows_core::Type::from_abi(result__))
})
}
fn IJsonValidatorFactory<R, F: FnOnce(&IJsonValidatorFactory) -> windows_core::Result<R>>(
callback: F,
) -> windows_core::Result<R> {
static SHARED: windows_core::imp::FactoryCache<JsonValidator, IJsonValidatorFactory> =
windows_core::imp::FactoryCache::new();
SHARED.call(callback)
}
}
impl windows_core::RuntimeType for JsonValidator {
const SIGNATURE: windows_core::imp::ConstBuffer =
windows_core::imp::ConstBuffer::for_class::<Self, IJsonValidator>();
}
unsafe impl windows_core::Interface for JsonValidator {
type Vtable = <IJsonValidator as windows_core::Interface>::Vtable;
const IID: windows_core::GUID = <IJsonValidator as windows_core::Interface>::IID;
}
impl windows_core::RuntimeName for JsonValidator {
const NAME: &'static str = "Sample.JsonValidator";
}
unsafe impl Send for JsonValidator {}
unsafe impl Sync for JsonValidator {}
windows_core::imp::define_interface!(
IJsonValidator,
IJsonValidator_Vtbl,
Expand Down Expand Up @@ -116,59 +172,3 @@ pub struct IJsonValidatorFactory_Vtbl {
*mut *mut core::ffi::c_void,
) -> windows_core::HRESULT,
}
#[repr(transparent)]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct JsonValidator(windows_core::IUnknown);
windows_core::imp::interface_hierarchy!(
JsonValidator,
windows_core::IUnknown,
windows_core::IInspectable
);
impl JsonValidator {
pub fn Validate(
&self,
value: &windows_core::HSTRING,
) -> windows_core::Result<windows_core::HSTRING> {
let this = self;
unsafe {
let mut result__ = core::mem::zeroed();
(windows_core::Interface::vtable(this).Validate)(
windows_core::Interface::as_raw(this),
core::mem::transmute_copy(value),
&mut result__,
)
.map(|| core::mem::transmute(result__))
}
}
pub fn CreateInstance(schema: &windows_core::HSTRING) -> windows_core::Result<JsonValidator> {
Self::IJsonValidatorFactory(|this| unsafe {
let mut result__ = core::mem::zeroed();
(windows_core::Interface::vtable(this).CreateInstance)(
windows_core::Interface::as_raw(this),
core::mem::transmute_copy(schema),
&mut result__,
)
.and_then(|| windows_core::Type::from_abi(result__))
})
}
fn IJsonValidatorFactory<R, F: FnOnce(&IJsonValidatorFactory) -> windows_core::Result<R>>(
callback: F,
) -> windows_core::Result<R> {
static SHARED: windows_core::imp::FactoryCache<JsonValidator, IJsonValidatorFactory> =
windows_core::imp::FactoryCache::new();
SHARED.call(callback)
}
}
impl windows_core::RuntimeType for JsonValidator {
const SIGNATURE: windows_core::imp::ConstBuffer =
windows_core::imp::ConstBuffer::for_class::<Self, IJsonValidator>();
}
unsafe impl windows_core::Interface for JsonValidator {
type Vtable = <IJsonValidator as windows_core::Interface>::Vtable;
const IID: windows_core::GUID = <IJsonValidator as windows_core::Interface>::IID;
}
impl windows_core::RuntimeName for JsonValidator {
const NAME: &'static str = "Sample.JsonValidator";
}
unsafe impl Send for JsonValidator {}
unsafe impl Sync for JsonValidator {}
Original file line number Diff line number Diff line change
Expand Up @@ -8,42 +8,6 @@
clippy::all
)]

windows_core::imp::define_interface!(
IJsonValidator,
IJsonValidator_Vtbl,
0xe09cb12b_b13c_5139_8c99_6140bf80deb9
);
impl windows_core::RuntimeType for IJsonValidator {
const SIGNATURE: windows_core::imp::ConstBuffer =
windows_core::imp::ConstBuffer::for_interface::<Self>();
}
#[repr(C)]
pub struct IJsonValidator_Vtbl {
pub base__: windows_core::IInspectable_Vtbl,
pub Validate: unsafe extern "system" fn(
*mut core::ffi::c_void,
*mut core::ffi::c_void,
*mut *mut core::ffi::c_void,
) -> windows_core::HRESULT,
}
windows_core::imp::define_interface!(
IJsonValidatorFactory,
IJsonValidatorFactory_Vtbl,
0x1cf4464e_ae9e_55d5_9539_0af4d8fc35aa
);
impl windows_core::RuntimeType for IJsonValidatorFactory {
const SIGNATURE: windows_core::imp::ConstBuffer =
windows_core::imp::ConstBuffer::for_interface::<Self>();
}
#[repr(C)]
pub struct IJsonValidatorFactory_Vtbl {
pub base__: windows_core::IInspectable_Vtbl,
pub CreateInstance: unsafe extern "system" fn(
*mut core::ffi::c_void,
*mut core::ffi::c_void,
*mut *mut core::ffi::c_void,
) -> windows_core::HRESULT,
}
#[repr(transparent)]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct JsonValidator(windows_core::IUnknown);
Expand Down Expand Up @@ -100,3 +64,39 @@ impl windows_core::RuntimeName for JsonValidator {
}
unsafe impl Send for JsonValidator {}
unsafe impl Sync for JsonValidator {}
windows_core::imp::define_interface!(
IJsonValidator,
IJsonValidator_Vtbl,
0xe09cb12b_b13c_5139_8c99_6140bf80deb9
);
impl windows_core::RuntimeType for IJsonValidator {
const SIGNATURE: windows_core::imp::ConstBuffer =
windows_core::imp::ConstBuffer::for_interface::<Self>();
}
#[repr(C)]
pub struct IJsonValidator_Vtbl {
pub base__: windows_core::IInspectable_Vtbl,
pub Validate: unsafe extern "system" fn(
*mut core::ffi::c_void,
*mut core::ffi::c_void,
*mut *mut core::ffi::c_void,
) -> windows_core::HRESULT,
}
windows_core::imp::define_interface!(
IJsonValidatorFactory,
IJsonValidatorFactory_Vtbl,
0x1cf4464e_ae9e_55d5_9539_0af4d8fc35aa
);
impl windows_core::RuntimeType for IJsonValidatorFactory {
const SIGNATURE: windows_core::imp::ConstBuffer =
windows_core::imp::ConstBuffer::for_interface::<Self>();
}
#[repr(C)]
pub struct IJsonValidatorFactory_Vtbl {
pub base__: windows_core::IInspectable_Vtbl,
pub CreateInstance: unsafe extern "system" fn(
*mut core::ffi::c_void,
*mut core::ffi::c_void,
*mut *mut core::ffi::c_void,
) -> windows_core::HRESULT,
}
Loading

0 comments on commit 35db6e3

Please sign in to comment.