зеркало из https://github.com/microsoft/com-rs.git
Address warnings, ran cargo fmt
This commit is contained in:
Родитель
7038c9d186
Коммит
e02f59e463
|
@ -1,7 +1,7 @@
|
|||
use proc_macro2::TokenStream as HelperTokenStream;
|
||||
use quote::quote;
|
||||
use std::collections::HashMap;
|
||||
use syn::{Fields, Ident, ItemStruct};
|
||||
use syn::{Ident, ItemStruct};
|
||||
|
||||
/// As an aggregable COM object, you need to have an inner non-delegating IUnknown vtable.
|
||||
/// All IUnknown calls to this COM object will delegate to the IUnknown interface pointer
|
||||
|
@ -17,7 +17,7 @@ pub fn generate(
|
|||
let base_fields = co_class::com_struct::gen_base_fields(base_interface_idents);
|
||||
let ref_count_field = co_class::com_struct::gen_ref_count_field();
|
||||
let user_fields = co_class::com_struct::gen_user_fields(struct_item);
|
||||
let aggregate_fields = co_class::com_struct::gen_aggregate_fields(aggr_map);
|
||||
let aggregate_fields = co_class::com_struct::gen_aggregate_fields(aggr_map);
|
||||
|
||||
// COM Fields for an aggregable coclass.
|
||||
let non_delegating_iunknown_field_ident = macro_utils::non_delegating_iunknown_field_ident();
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use proc_macro2::TokenStream as HelperTokenStream;
|
||||
use quote::quote;
|
||||
use std::collections::HashMap;
|
||||
use syn::{Fields, Ident, ItemStruct};
|
||||
use syn::{Ident, ItemStruct};
|
||||
|
||||
/// Generates the methods that the com struct needs to have. These include:
|
||||
/// allocate: To initialise the vtables, including the non_delegatingegating_iunknown one.
|
||||
|
@ -141,10 +141,12 @@ fn gen_allocate_fn(
|
|||
) -> HelperTokenStream {
|
||||
let struct_ident = &struct_item.ident;
|
||||
|
||||
let base_inits = co_class::com_struct_impl::gen_allocate_base_inits(struct_ident, base_interface_idents);
|
||||
let base_inits =
|
||||
co_class::com_struct_impl::gen_allocate_base_inits(struct_ident, base_interface_idents);
|
||||
|
||||
// Allocate function signature
|
||||
let allocate_parameters = co_class::com_struct_impl::gen_allocate_function_parameters_signature(struct_item);
|
||||
let allocate_parameters =
|
||||
co_class::com_struct_impl::gen_allocate_function_parameters_signature(struct_item);
|
||||
|
||||
// Syntax for instantiating the fields of the struct.
|
||||
let base_fields = co_class::com_struct_impl::gen_allocate_base_fields(base_interface_idents);
|
||||
|
@ -152,7 +154,7 @@ fn gen_allocate_fn(
|
|||
let user_fields = co_class::com_struct_impl::gen_allocate_user_fields(struct_item);
|
||||
let aggregate_fields = co_class::com_struct_impl::gen_allocate_aggregate_fields(aggr_map);
|
||||
|
||||
// Aggregable COM struct specific fields
|
||||
// Aggregable COM struct specific fields
|
||||
let iunknown_to_use_field_ident = macro_utils::iunknown_to_use_field_ident();
|
||||
let non_delegating_iunknown_field_ident = macro_utils::non_delegating_iunknown_field_ident();
|
||||
let non_delegating_iunknown_offset = base_interface_idents.len();
|
||||
|
@ -207,4 +209,4 @@ fn gen_allocate_fn(
|
|||
Box::new(out)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,10 +27,9 @@ pub fn generate(
|
|||
)
|
||||
}
|
||||
|
||||
|
||||
fn gen_non_delegating_iunknown_drop() -> HelperTokenStream {
|
||||
let non_delegating_iunknown_field_ident = macro_utils::non_delegating_iunknown_field_ident();
|
||||
quote!(
|
||||
Box::from_raw(self.#non_delegating_iunknown_field_ident as *mut <dyn com::IUnknown as com::ComInterface>::VTable)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ pub fn generate(
|
|||
let base_fields = gen_base_fields(base_interface_idents);
|
||||
let ref_count_field = gen_ref_count_field();
|
||||
let user_fields = gen_user_fields(struct_item);
|
||||
let aggregate_fields = gen_aggregate_fields(aggr_map);
|
||||
let aggregate_fields = gen_aggregate_fields(aggr_map);
|
||||
|
||||
quote!(
|
||||
#[repr(C)]
|
||||
|
|
|
@ -48,7 +48,7 @@ pub fn gen_allocate_fn(
|
|||
println!("Allocating new VTable for {}", stringify!(#struct_ident));
|
||||
|
||||
#base_inits
|
||||
|
||||
|
||||
let out = #struct_ident {
|
||||
#base_fields
|
||||
#ref_count_field
|
||||
|
@ -77,7 +77,6 @@ pub fn gen_allocate_aggregate_fields(aggr_map: &HashMap<Ident, Vec<Ident>>) -> H
|
|||
});
|
||||
|
||||
quote!(#(#aggregate_inits,)*)
|
||||
|
||||
}
|
||||
|
||||
// User field input as parameters to the allocate function.
|
||||
|
@ -113,7 +112,10 @@ pub fn gen_allocate_base_fields(base_interface_idents: &[Ident]) -> HelperTokenS
|
|||
}
|
||||
|
||||
// Initialise VTables with the correct adjustor thunks, through the vtable! macro.
|
||||
pub fn gen_allocate_base_inits(struct_ident: &Ident, base_interface_idents: &[Ident]) -> HelperTokenStream {
|
||||
pub fn gen_allocate_base_inits(
|
||||
struct_ident: &Ident,
|
||||
base_interface_idents: &[Ident],
|
||||
) -> HelperTokenStream {
|
||||
let mut offset_count: usize = 0;
|
||||
let base_inits = base_interface_idents.iter().map(|base| {
|
||||
let vtable_var_ident = format_ident!("{}_vtable", base.to_string().to_lowercase());
|
||||
|
|
Загрузка…
Ссылка в новой задаче