Native method registry java.lang.Class wtf

This commit is contained in:
vegowotenks 2024-09-09 15:43:26 +02:00
parent 3282694b32
commit b4c428685f
9 changed files with 987 additions and 40 deletions

View file

@ -763,6 +763,24 @@ impl Into<String> for &AbstractTypeKind {
}
}
impl From<&str> for AbstractTypeKind {
fn from(value: &str) -> Self {
match value.chars().nth(0).unwrap() {
'V' => AbstractTypeKind::Void(),
'B' => AbstractTypeKind::Byte(),
'C' => AbstractTypeKind::Char(),
'D' => AbstractTypeKind::Double(),
'F' => AbstractTypeKind::Float(),
'I' => AbstractTypeKind::Int(),
'J' => AbstractTypeKind::Long(),
'S' => AbstractTypeKind::Short(),
'Z' => AbstractTypeKind::Boolean(),
'L' => todo!(),
_ => todo!(),
}
}
}
#[derive(Debug, Eq, PartialEq, Clone, Hash)]
pub struct AbstractTypeDescription {
pub array_level: u8,
@ -786,6 +804,28 @@ impl Into<String> for &AbstractTypeDescription {
}
impl AbstractTypeDescription {
pub fn super_component(&self) -> Self {
AbstractTypeDescription {
array_level: 0,
kind: self.kind.clone()
}
}
pub fn component(&self) -> Self {
AbstractTypeDescription {
array_level: self.array_level - 1,
kind: self.kind.clone()
}
}
pub fn array(&self) -> Self {
AbstractTypeDescription {
array_level: self.array_level + 1,
kind: self.kind.clone()
}
}
pub fn parse_full(s: &str) -> Result<Self, Error> {
let (c, parsed) = Self::parse_first(s)?;