sdk-builder: cleanup
This commit is contained in:
parent
01feff8cf5
commit
6f8a49dc32
|
@ -335,14 +335,6 @@ pub mod rust {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// returns the absolute path of a type with the assumption that all
|
|
||||||
/// packages are children of the path `crate::sdk`
|
|
||||||
fn get_type_path(&self, key: &ObjectRef) -> Option<String> {
|
|
||||||
let pkg = &self.sdk.packages.get(&key.package)?.name;
|
|
||||||
self.get_type_name(key)
|
|
||||||
.map(|name| format!("crate::sdk::{pkg}::{name}"))
|
|
||||||
}
|
|
||||||
|
|
||||||
/// returns the precached, prefixed and cannonicalized (for this
|
/// returns the precached, prefixed and cannonicalized (for this
|
||||||
/// language, Rust) `Ident` for this object-ref
|
/// language, Rust) `Ident` for this object-ref
|
||||||
fn get_type_ident(&self, key: &ObjectRef) -> Option<Ident> {
|
fn get_type_ident(&self, key: &ObjectRef) -> Option<Ident> {
|
||||||
|
@ -481,71 +473,6 @@ pub mod rust {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn type_name(&self, ty: &Type) -> anyhow::Result<String> {
|
|
||||||
let type_name = match ty {
|
|
||||||
Type::Ptr(inner) | Type::Ref(inner) => {
|
|
||||||
format!(
|
|
||||||
"::core::option::Option<NonNull<{}>>",
|
|
||||||
self.type_name(&inner)?
|
|
||||||
)
|
|
||||||
}
|
|
||||||
Type::WeakPtr(inner) => {
|
|
||||||
format!(
|
|
||||||
"crate::engine::TWeakObjectPtr<{}>",
|
|
||||||
self.get_type_path(inner)
|
|
||||||
.context("type name was not cached.")?
|
|
||||||
)
|
|
||||||
}
|
|
||||||
Type::SoftPtr(inner) => {
|
|
||||||
format!(
|
|
||||||
"crate::engine::TSoftObjectPtr<{}>",
|
|
||||||
self.get_type_path(inner)
|
|
||||||
.context("type name was not cached.")?
|
|
||||||
)
|
|
||||||
}
|
|
||||||
Type::LazyPtr(inner) => {
|
|
||||||
format!(
|
|
||||||
"crate::engine::TLazyObjectPtr<{}>",
|
|
||||||
self.get_type_path(inner)
|
|
||||||
.context("type name was not cached.")?
|
|
||||||
)
|
|
||||||
}
|
|
||||||
Type::AssetPtr(inner) => format!(
|
|
||||||
"crate::engine::TAssetPtr<{}>",
|
|
||||||
self.get_type_path(inner)
|
|
||||||
.context("type name was not cached.")?
|
|
||||||
),
|
|
||||||
Type::Array(inner) => {
|
|
||||||
format!("crate::engine::TArray<{}>", self.type_name(&inner)?)
|
|
||||||
}
|
|
||||||
Type::Primitive(prim) => {
|
|
||||||
format!("{prim}")
|
|
||||||
}
|
|
||||||
Type::RawArray { ty, len } => {
|
|
||||||
format!("[{}; {}]", self.type_name(&ty)?, len)
|
|
||||||
}
|
|
||||||
Type::Name => "crate::engine::FName".to_string(),
|
|
||||||
Type::String => "crate::engine::FString".to_string(),
|
|
||||||
Type::Text => "crate::engine::FText".to_string(),
|
|
||||||
Type::Enum { enum_type, .. } => self
|
|
||||||
.get_type_path(enum_type)
|
|
||||||
.context("type name was not cached.")?,
|
|
||||||
Type::Class(class) => {
|
|
||||||
format!(
|
|
||||||
"::core::option::Option<{}>",
|
|
||||||
self.get_type_path(class)
|
|
||||||
.context("type name was not cached.")?
|
|
||||||
)
|
|
||||||
}
|
|
||||||
Type::Struct(class) => self
|
|
||||||
.get_type_path(class)
|
|
||||||
.context("type name was not cached.")?
|
|
||||||
.clone(),
|
|
||||||
};
|
|
||||||
|
|
||||||
Ok(type_name)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn generate_enum(&self, enum0: &Enum) -> anyhow::Result<TokenStream> {
|
fn generate_enum(&self, enum0: &Enum) -> anyhow::Result<TokenStream> {
|
||||||
let name = self
|
let name = self
|
||||||
.get_type_ident(&enum0.obj_ref)
|
.get_type_ident(&enum0.obj_ref)
|
||||||
|
@ -1006,7 +933,7 @@ pub mod rust {
|
||||||
.map(|ty| {
|
.map(|ty| {
|
||||||
(
|
(
|
||||||
self.get_type_package_path(&ty.obj_ref()).unwrap(),
|
self.get_type_package_path(&ty.obj_ref()).unwrap(),
|
||||||
self.get_type_name(&ty.obj_ref()).unwrap(),
|
self.get_type_ident(&ty.obj_ref()).unwrap(),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.map(|(super_path, super_name)| {
|
.map(|(super_path, super_name)| {
|
||||||
|
|
Loading…
Reference in a new issue