parse ufunction into ClassMethod
This commit is contained in:
parent
77df17392c
commit
46a5b9bb0e
|
@ -93,40 +93,79 @@ impl ClassField {
|
|||
}
|
||||
|
||||
impl ClassMethod {
|
||||
pub fn from_ufunction(value: UFunction) -> anyhow::Result<Self> {
|
||||
todo!()
|
||||
pub fn from_ufunction(func: UFunction) -> anyhow::Result<Self> {
|
||||
let name = func.get_name().context("could not get function name")?;
|
||||
let full_name = func
|
||||
.get_full_name()
|
||||
.context("could not get full function name")?;
|
||||
|
||||
let params = func
|
||||
.iter_children()
|
||||
.filter_map(|field| match AnyField::from_field(field) {
|
||||
AnyField::Property(prop) => Some(prop),
|
||||
_ => None,
|
||||
})
|
||||
.map(|prop| -> anyhow::Result<Option<ClassField>> {
|
||||
let param = ClassField {
|
||||
offset: *prop.offset() as u32,
|
||||
size: *prop.element_size() as u32,
|
||||
name: prop.get_name().context("failed to get property name")?,
|
||||
flags: *prop.property_flags(),
|
||||
ty: if let Ok(ty) = resolve_type(prop) {
|
||||
ty
|
||||
} else {
|
||||
log::warn!("skipping field {} with offset 0x{:x}", prop, prop.offset());
|
||||
return Ok(None);
|
||||
},
|
||||
};
|
||||
|
||||
Ok(Some(param))
|
||||
})
|
||||
.fold_ok(Vec::new(), |mut acc, field| {
|
||||
acc.extend(field);
|
||||
acc
|
||||
})?;
|
||||
|
||||
Ok(ClassMethod {
|
||||
name,
|
||||
full_name,
|
||||
flags: *func.function_flags(),
|
||||
parameters: params,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl Package {
|
||||
pub fn process(self) -> anyhow::Result<ProcessedPackage> {
|
||||
self.children.par_iter().filter_map(|&object| {
|
||||
match AnyObject::from_object(object) {
|
||||
AnyObject::Field(field) => match AnyField::from_field(field) {
|
||||
AnyField::Enum(my_enum) => {}
|
||||
AnyField::Struct(my_struct) => match AnyStruct::from_struct(my_struct) {
|
||||
my_struct @ AnyStruct::Class(_)
|
||||
| my_struct @ AnyStruct::ScriptStruct(_) => {}
|
||||
self.children
|
||||
.par_iter()
|
||||
.filter_map(|&object| -> Option<UnrealType> {
|
||||
match AnyObject::from_object(object) {
|
||||
AnyObject::Field(field) => match AnyField::from_field(field) {
|
||||
AnyField::Enum(my_enum) => {}
|
||||
AnyField::Struct(my_struct) => match AnyStruct::from_struct(my_struct) {
|
||||
my_struct @ AnyStruct::Class(_)
|
||||
| my_struct @ AnyStruct::ScriptStruct(_) => {}
|
||||
_ => {}
|
||||
},
|
||||
_ => {}
|
||||
},
|
||||
_ => {}
|
||||
},
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
todo!()
|
||||
});
|
||||
todo!()
|
||||
});
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
fn resolve_type(prop: UProperty) -> anyhow::Result<Type> {
|
||||
let ty = match AnyField::from(prop.clone()) {
|
||||
let ty = match AnyProperty::from_prop(prop.clone()) {
|
||||
numeric @ AnyProperty::Numeric(_) => match numeric.as_any_numeric_property().unwrap() {
|
||||
any_type::AnyNumericProperty::U8(prop) => match prop.uenum() {
|
||||
Some(enm) => Type::Enum {
|
||||
underlying: Box::new(Type::Primitive(PrimitiveType::U8)),
|
||||
enum_type: *enm,
|
||||
enum_type: enm.as_uobject().object_ref(),
|
||||
},
|
||||
None => Type::Primitive(PrimitiveType::U8),
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue