apply auto-fixes

This commit is contained in:
Kadir Yamamoto
2023-03-17 18:59:33 +09:00
parent 5606e3a9c7
commit 53ac62fb36
6 changed files with 20 additions and 21 deletions
+3 -3
View File
@@ -1,5 +1,5 @@
use crate::primitives::{
ICLRMetaHost, ICLRRuntimeInfo, ICorRuntimeHost, IUnknown, Interface, _AppDomain, _Assembly,
ICLRMetaHost, ICLRRuntimeInfo, ICorRuntimeHost, IUnknown, Interface, _AppDomain,
_MethodInfo, _StringWriter, wrap_method_arguments, GUID, HRESULT,
};
use std::{ffi::c_void, ptr};
@@ -149,7 +149,7 @@ impl Clr {
let context = self.output_context.as_ref().unwrap();
let mut dispatchable: &*mut IUnknown = unsafe {
let dispatchable: &*mut IUnknown = unsafe {
std::mem::transmute(
context
.redirected_stdout
@@ -219,7 +219,7 @@ impl Clr {
let create_interface: CreateInterface =
unsafe { std::mem::transmute(self.create_interface) };
let mut host: *mut ICLRMetaHost = ICLRMetaHost::new(create_interface)?;
let host: *mut ICLRMetaHost = ICLRMetaHost::new(create_interface)?;
return Ok(host);
}
+5 -6
View File
@@ -7,8 +7,7 @@ use windows::{
VT_ARRAY, VT_BSTR, VT_UI1, VT_VARIANT,
},
Ole::{
SafeArrayAccessData, SafeArrayCreate, SafeArrayCreateVector, SafeArrayGetDim,
SafeArrayGetLBound, SafeArrayGetUBound, SafeArrayPutElement, SafeArrayUnaccessData,
SafeArrayAccessData, SafeArrayCreate, SafeArrayCreateVector, SafeArrayGetUBound, SafeArrayPutElement, SafeArrayUnaccessData,
},
},
};
@@ -19,7 +18,7 @@ pub fn prepare_assembly(bytes: &[u8]) -> Result<*mut SAFEARRAY, String> {
lLbound: 0,
};
let mut safe_array_ptr: *mut SAFEARRAY = unsafe { SafeArrayCreate(VT_UI1, 1, &mut bounds) };
let safe_array_ptr: *mut SAFEARRAY = unsafe { SafeArrayCreate(VT_UI1, 1, &mut bounds) };
let mut pv_data: *mut c_void = ptr::null_mut();
match unsafe { SafeArrayAccessData(safe_array_ptr, &mut pv_data) } {
@@ -56,7 +55,7 @@ pub fn empty_array() -> *mut SAFEARRAY {
}
pub fn wrap_string_in_variant(string: &str) -> VARIANT {
let mut inner = BSTR::from(string);
let inner = BSTR::from(string);
VARIANT {
Anonymous: VARIANT_0 {
@@ -80,7 +79,7 @@ pub fn wrap_strings_in_array(strings: &[String]) -> Result<VARIANT, String> {
inner.push(BSTR::from(string).into_raw())
}
let mut safe_array_ptr: *mut SAFEARRAY =
let safe_array_ptr: *mut SAFEARRAY =
unsafe { SafeArrayCreateVector(VT_BSTR, 0, inner.len() as u32) };
for i in 0..inner.len() {
@@ -113,7 +112,7 @@ pub fn wrap_strings_in_array(strings: &[String]) -> Result<VARIANT, String> {
}
pub fn wrap_method_arguments(arguments: Vec<VARIANT>) -> Result<*mut SAFEARRAY, String> {
let mut variant_array_ptr: *mut SAFEARRAY =
let variant_array_ptr: *mut SAFEARRAY =
unsafe { SafeArrayCreateVector(VT_VARIANT, 0, arguments.len() as u32) };
for i in 0..arguments.len() {
+1 -1
View File
@@ -93,7 +93,7 @@ pub struct _AppDomainVtbl {
impl _AppDomain {
pub fn load_library(&self, library: &str) -> Result<*mut _Assembly, String> {
let mut library_buffer = BSTR::from(library);
let library_buffer = BSTR::from(library);
let mut library_ptr: *mut _Assembly = ptr::null_mut();
+5 -5
View File
@@ -1,5 +1,5 @@
use crate::primitives::{
itype::_Type, IUnknown, IUnknownVtbl, Interface, _MethodInfo, empty_array,
itype::_Type, IUnknown, IUnknownVtbl, Interface, _MethodInfo,
wrap_method_arguments, wrap_strings_in_array, GUID, HRESULT,
};
use std::{
@@ -11,7 +11,7 @@ use windows::{
core::BSTR,
Win32::System::{
Com::{SAFEARRAY, VARIANT, VT_UNKNOWN},
Ole::{SafeArrayCreateVector, SafeArrayGetElement, SafeArrayGetLBound, SafeArrayGetUBound},
Ole::{SafeArrayCreateVector, SafeArrayGetElement, SafeArrayGetUBound},
},
};
@@ -98,7 +98,7 @@ impl _Assembly {
if signature.ends_with("Main(System.String[])") {
let args_variant = wrap_strings_in_array(args)?;
let mut method_args = wrap_method_arguments(vec![args_variant])?;
let method_args = wrap_method_arguments(vec![args_variant])?;
return unsafe { (*entrypoint).invoke(method_args, None) };
}
@@ -198,7 +198,7 @@ impl _Assembly {
}
pub fn create_instance(&self, name: &str) -> Result<VARIANT, String> {
let mut dw = BSTR::from(name);
let dw = BSTR::from(name);
let mut instance: VARIANT = VARIANT::default();
let hr = unsafe { (*self).CreateInstance(dw.into_raw() as *mut _, &mut instance) };
@@ -214,7 +214,7 @@ impl _Assembly {
}
pub fn get_type(&self, name: &str) -> Result<*mut _Type, String> {
let mut dw = BSTR::from(name);
let dw = BSTR::from(name);
let mut type_ptr: *mut _Type = ptr::null_mut();
let hr = unsafe { (*self).GetType_2(dw.into_raw() as *mut _, &mut type_ptr) };
+1 -1
View File
@@ -9,7 +9,7 @@ use windows::{
core::BSTR,
Win32::System::{
Com::{SAFEARRAY, VARIANT, VT_UNKNOWN},
Ole::{SafeArrayCreateVector, SafeArrayGetLBound, SafeArrayGetUBound},
Ole::{SafeArrayCreateVector},
},
};
+5 -5
View File
@@ -10,7 +10,7 @@ use windows::{
core::BSTR,
Win32::System::{
Com::{SAFEARRAY, VARIANT, VT_UNKNOWN},
Ole::{SafeArrayCreateVector, SafeArrayGetElement, SafeArrayGetLBound, SafeArrayGetUBound},
Ole::{SafeArrayCreateVector, SafeArrayGetElement, SafeArrayGetUBound},
},
};
@@ -192,7 +192,7 @@ impl _Type {
}
pub fn get_method(&self, name: &str) -> Result<*mut _MethodInfo, String> {
let mut dw = BSTR::from(name);
let dw = BSTR::from(name);
let mut method_ptr: *mut _MethodInfo = ptr::null_mut();
let hr = unsafe { (*self).GetMethod_6(dw.into_raw() as *mut _, &mut method_ptr) };
@@ -295,9 +295,9 @@ impl _Type {
flags: BindingFlags,
args: *mut SAFEARRAY,
) -> Result<VARIANT, String> {
let mut method_name = BSTR::from(method.clone());
let mut binder: *mut c_void = ptr::null_mut();
let mut named_params = empty_array();
let method_name = BSTR::from(method.clone());
let binder: *mut c_void = ptr::null_mut();
let named_params = empty_array();
let mut return_ptr: *mut VARIANT = ptr::null_mut();
let hr = unsafe {