serialization of packages
This commit is contained in:
parent
47dbb8e3d1
commit
555cbb79a2
|
@ -1,4 +1,3 @@
|
|||
use std::collections::BTreeSet;
|
||||
use std::collections::{btree_map::Entry, BTreeMap};
|
||||
|
||||
use anyhow::Context;
|
||||
|
@ -229,25 +228,57 @@ impl ClassMethod {
|
|||
|
||||
impl Package {
|
||||
pub fn process(self) -> anyhow::Result<ProcessedPackage> {
|
||||
self.children
|
||||
let types = self
|
||||
.children
|
||||
.par_iter()
|
||||
.filter_map(|&object| -> Option<UnrealType> {
|
||||
match AnyObject::from_object(object) {
|
||||
let ty = match AnyObject::from_object(object) {
|
||||
AnyObject::Field(field) => match AnyField::from_field(field) {
|
||||
AnyField::Enum(my_enum) => {}
|
||||
AnyField::Enum(my_enum) => Enum::from_uenum(my_enum),
|
||||
AnyField::Struct(my_struct) => match AnyStruct::from_struct(my_struct) {
|
||||
my_struct @ AnyStruct::Class(_)
|
||||
| my_struct @ AnyStruct::ScriptStruct(_) => {}
|
||||
_ => {}
|
||||
},
|
||||
_ => {}
|
||||
},
|
||||
_ => {}
|
||||
AnyStruct::Class(class) => Class::from_uclass(class),
|
||||
AnyStruct::ScriptStruct(strct) => Class::from_struct(strct),
|
||||
AnyStruct::Actor(actor) => Class::from_actor(actor),
|
||||
_ => {
|
||||
return None;
|
||||
}
|
||||
},
|
||||
_ => {
|
||||
return None;
|
||||
}
|
||||
},
|
||||
_ => {
|
||||
return None;
|
||||
}
|
||||
};
|
||||
|
||||
todo!()
|
||||
});
|
||||
todo!()
|
||||
match ty {
|
||||
Ok(ty) => {
|
||||
return Some(ty);
|
||||
}
|
||||
Err(err) => {
|
||||
log::error!("failed to serialize object {object:?}: {err}");
|
||||
return None;
|
||||
}
|
||||
}
|
||||
})
|
||||
.map(|ty| (ty.obj_ref(), ty))
|
||||
.collect::<BTreeMap<_, _>>();
|
||||
|
||||
let dependencies = types
|
||||
.iter()
|
||||
.flat_map(|(_, ty)| ty.get_dependent_types().into_iter().map(|obj| obj.package))
|
||||
.dedup()
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
Ok(ProcessedPackage {
|
||||
package_object: self
|
||||
.package_object
|
||||
.as_package_ref()
|
||||
.context("not actually a package object")?,
|
||||
types,
|
||||
dependencies,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ pub struct ProcessedPackage {
|
|||
/// all types extracted from this package referenced by their `ObjectRef`.
|
||||
pub types: BTreeMap<ObjectRef, UnrealType>,
|
||||
/// All other packages that types in this package depend on directly.
|
||||
pub dependencies: Vec<ObjectRef>,
|
||||
pub dependencies: Vec<PackageRef>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
|
|
Loading…
Reference in a new issue