parse ufunction into ClassMethod
This commit is contained in:
parent
77df17392c
commit
46a5b9bb0e
|
@ -93,14 +93,53 @@ impl ClassField {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ClassMethod {
|
impl ClassMethod {
|
||||||
pub fn from_ufunction(value: UFunction) -> anyhow::Result<Self> {
|
pub fn from_ufunction(func: UFunction) -> anyhow::Result<Self> {
|
||||||
todo!()
|
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 {
|
impl Package {
|
||||||
pub fn process(self) -> anyhow::Result<ProcessedPackage> {
|
pub fn process(self) -> anyhow::Result<ProcessedPackage> {
|
||||||
self.children.par_iter().filter_map(|&object| {
|
self.children
|
||||||
|
.par_iter()
|
||||||
|
.filter_map(|&object| -> Option<UnrealType> {
|
||||||
match AnyObject::from_object(object) {
|
match AnyObject::from_object(object) {
|
||||||
AnyObject::Field(field) => match AnyField::from_field(field) {
|
AnyObject::Field(field) => match AnyField::from_field(field) {
|
||||||
AnyField::Enum(my_enum) => {}
|
AnyField::Enum(my_enum) => {}
|
||||||
|
@ -121,12 +160,12 @@ impl Package {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn resolve_type(prop: UProperty) -> anyhow::Result<Type> {
|
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() {
|
numeric @ AnyProperty::Numeric(_) => match numeric.as_any_numeric_property().unwrap() {
|
||||||
any_type::AnyNumericProperty::U8(prop) => match prop.uenum() {
|
any_type::AnyNumericProperty::U8(prop) => match prop.uenum() {
|
||||||
Some(enm) => Type::Enum {
|
Some(enm) => Type::Enum {
|
||||||
underlying: Box::new(Type::Primitive(PrimitiveType::U8)),
|
underlying: Box::new(Type::Primitive(PrimitiveType::U8)),
|
||||||
enum_type: *enm,
|
enum_type: enm.as_uobject().object_ref(),
|
||||||
},
|
},
|
||||||
None => Type::Primitive(PrimitiveType::U8),
|
None => Type::Primitive(PrimitiveType::U8),
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue