linting cleanup
This commit is contained in:
parent
08149329e1
commit
211605c20c
42
src/lib.rs
42
src/lib.rs
|
@ -22,7 +22,6 @@ pub mod sdk {
|
||||||
};
|
};
|
||||||
|
|
||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
use itertools::any;
|
|
||||||
use rayon::prelude::{IntoParallelRefIterator, ParallelIterator};
|
use rayon::prelude::{IntoParallelRefIterator, ParallelIterator};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
@ -35,8 +34,8 @@ pub mod sdk {
|
||||||
UObjectPropertyBaseTrait, UObjectTrait, UPropertyTrait, UStructNonConst,
|
UObjectPropertyBaseTrait, UObjectTrait, UPropertyTrait, UStructNonConst,
|
||||||
UStructPropertyTrait, UStructTrait,
|
UStructPropertyTrait, UStructTrait,
|
||||||
},
|
},
|
||||||
AnyProp, EFunctionFlags, EPropertyFlags, UAnyType, UClass, UEnum, UFunction, UObject,
|
EFunctionFlags, EPropertyFlags, UAnyType, UClass, UEnum, UFunction, UObject,
|
||||||
UProperty, UScriptStruct, UStruct,
|
UScriptStruct, UStruct,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -45,17 +44,12 @@ pub mod sdk {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ClassCache {
|
impl ClassCache {
|
||||||
|
#[allow(dead_code)]
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self {
|
||||||
classes: Mutex::new(HashMap::new()),
|
classes: Mutex::new(HashMap::new()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn cache_class(&self, class: UClass) -> anyhow::Result<()> {
|
|
||||||
let name = class.get_full_name()?;
|
|
||||||
self.classes.lock().unwrap().insert(name, class);
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FindClass for ClassCache {
|
impl FindClass for ClassCache {
|
||||||
|
@ -89,8 +83,7 @@ pub mod sdk {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Package<'a> {
|
pub struct Package {
|
||||||
sdk: &'a Sdk,
|
|
||||||
package: UObject,
|
package: UObject,
|
||||||
objects: Vec<UObject>,
|
objects: Vec<UObject>,
|
||||||
dependencies: Vec<UObject>,
|
dependencies: Vec<UObject>,
|
||||||
|
@ -103,10 +96,9 @@ pub mod sdk {
|
||||||
pub package_dependencies: Vec<UObject>,
|
pub package_dependencies: Vec<UObject>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Package<'a> {
|
impl Package {
|
||||||
pub fn new(sdk: &'a Sdk, package: UObject, objects: Vec<UObject>) -> Self {
|
pub fn new(package: UObject, objects: Vec<UObject>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
sdk,
|
|
||||||
package,
|
package,
|
||||||
objects,
|
objects,
|
||||||
dependencies: Vec::new(),
|
dependencies: Vec::new(),
|
||||||
|
@ -168,7 +160,7 @@ pub mod sdk {
|
||||||
|
|
||||||
let super_struct = if let Some(spr) = *strct.super_field() && spr != strct {
|
let super_struct = if let Some(spr) = *strct.super_field() && spr != strct {
|
||||||
if spr.package_object() != self.package {
|
if spr.package_object() != self.package {
|
||||||
log::info!("encountered external dependency");
|
log::warn!("encountered external dependency");
|
||||||
// TODO: return dependency on strct.package_object()
|
// TODO: return dependency on strct.package_object()
|
||||||
}
|
}
|
||||||
Some(spr)
|
Some(spr)
|
||||||
|
@ -178,6 +170,7 @@ pub mod sdk {
|
||||||
|
|
||||||
Ok(Class {
|
Ok(Class {
|
||||||
is_class,
|
is_class,
|
||||||
|
size: *strct.property_size() as u32,
|
||||||
name,
|
name,
|
||||||
super_class: super_struct,
|
super_class: super_struct,
|
||||||
fields,
|
fields,
|
||||||
|
@ -303,7 +296,7 @@ pub mod sdk {
|
||||||
&self,
|
&self,
|
||||||
strct: UStruct,
|
strct: UStruct,
|
||||||
) -> anyhow::Result<(Vec<ClassField>, Vec<ClassMethod>)> {
|
) -> anyhow::Result<(Vec<ClassField>, Vec<ClassMethod>)> {
|
||||||
log::info!("{} children:", strct.get_full_name_or_default());
|
log::debug!("{} children:", strct.get_full_name_or_default());
|
||||||
|
|
||||||
let mut fields = Vec::new();
|
let mut fields = Vec::new();
|
||||||
let mut methods = Vec::new();
|
let mut methods = Vec::new();
|
||||||
|
@ -316,7 +309,7 @@ pub mod sdk {
|
||||||
any_type::AnyField::Property(prop) => {
|
any_type::AnyField::Property(prop) => {
|
||||||
match Self::find_type(any_type::AnyProperty::from_prop(prop)) {
|
match Self::find_type(any_type::AnyProperty::from_prop(prop)) {
|
||||||
Ok(ty) => {
|
Ok(ty) => {
|
||||||
log::info!("field: {ty:?}: {prop}");
|
log::debug!("field: {ty:?}: {prop}");
|
||||||
fields.push(
|
fields.push(
|
||||||
ClassField {
|
ClassField {
|
||||||
offset: *prop.offset() as u32,
|
offset: *prop.offset() as u32,
|
||||||
|
@ -331,7 +324,7 @@ pub mod sdk {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
strt @ any_type::AnyField::Struct(_) if let Some(any_type::AnyStruct::Function(func)) = strt.as_any_struct() => {
|
strt @ any_type::AnyField::Struct(_) if let Some(any_type::AnyStruct::Function(func)) = strt.as_any_struct() => {
|
||||||
log::info!("function: {func}");
|
log::debug!("function: {func}");
|
||||||
|
|
||||||
if let Ok(method) = Self::process_function(func) {
|
if let Ok(method) = Self::process_function(func) {
|
||||||
methods.push(method);
|
methods.push(method);
|
||||||
|
@ -367,7 +360,7 @@ pub mod sdk {
|
||||||
any_type::AnyField::Property(prop) => {
|
any_type::AnyField::Property(prop) => {
|
||||||
match Self::find_type(any_type::AnyProperty::from_prop(prop)) {
|
match Self::find_type(any_type::AnyProperty::from_prop(prop)) {
|
||||||
Ok(ty) => {
|
Ok(ty) => {
|
||||||
log::info!("field: {ty:?}: {prop}");
|
log::debug!("field: {ty:?}: {prop}");
|
||||||
if let Some(kind) = if prop
|
if let Some(kind) = if prop
|
||||||
.property_flags()
|
.property_flags()
|
||||||
.contains(EPropertyFlags::ReturnParm)
|
.contains(EPropertyFlags::ReturnParm)
|
||||||
|
@ -473,15 +466,11 @@ pub mod sdk {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Sdk {
|
pub struct Sdk {}
|
||||||
cache: ClassCache,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Sdk {
|
impl Sdk {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self {}
|
||||||
cache: ClassCache::new(),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn package_objects(&self) -> Vec<Package> {
|
pub fn package_objects(&self) -> Vec<Package> {
|
||||||
|
@ -512,7 +501,7 @@ pub mod sdk {
|
||||||
|
|
||||||
sorted_objects
|
sorted_objects
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|(package, objects)| Package::new(self, package, objects))
|
.map(|(package, objects)| Package::new(package, objects))
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -692,6 +681,7 @@ pub mod sdk {
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Class {
|
pub struct Class {
|
||||||
pub is_class: bool,
|
pub is_class: bool,
|
||||||
|
pub size: u32,
|
||||||
pub name: String,
|
pub name: String,
|
||||||
pub super_class: Option<UStruct>,
|
pub super_class: Option<UStruct>,
|
||||||
pub fields: Vec<ClassField>,
|
pub fields: Vec<ClassField>,
|
||||||
|
|
Loading…
Reference in a new issue