add annotations for methods and parameters
This commit is contained in:
parent
cf55766653
commit
224d1efdba
4 changed files with 160 additions and 14 deletions
|
|
@ -21,7 +21,7 @@ pub struct AnnotationDirectoryItem {
|
|||
pub field_annotations: Vec<FieldAnnotation>,
|
||||
/// List of method annotation. The method annotations must be sorted by
|
||||
/// increasing order of [`crate::MethodAnnotation.method_idx`].
|
||||
pub method_annotation: Vec<MethodAnnotation>,
|
||||
pub method_annotations: Vec<MethodAnnotation>,
|
||||
/// List of associated method parameter annotation. The parameter annotations
|
||||
/// must be sorted by increasing order of [`crate::ParameterAnnotation.parameter_size`].
|
||||
pub parameter_annotations: Vec<ParameterAnnotation>,
|
||||
|
|
@ -32,7 +32,7 @@ impl AnnotationDirectoryItem {
|
|||
self.field_annotations.len() as u32
|
||||
}
|
||||
pub fn annotated_methods_size_field(&self) -> u32 {
|
||||
self.method_annotation.len() as u32
|
||||
self.method_annotations.len() as u32
|
||||
}
|
||||
pub fn parameter_annotations_field(&self) -> u32 {
|
||||
self.parameter_annotations.len() as u32
|
||||
|
|
@ -49,7 +49,7 @@ impl Serializable for AnnotationDirectoryItem {
|
|||
for item in &self.field_annotations {
|
||||
item.serialize(output)?;
|
||||
}
|
||||
for item in &self.method_annotation {
|
||||
for item in &self.method_annotations {
|
||||
item.serialize(output)?;
|
||||
}
|
||||
for item in &self.parameter_annotations {
|
||||
|
|
@ -66,9 +66,9 @@ impl Serializable for AnnotationDirectoryItem {
|
|||
for _ in 0..fields_size {
|
||||
field_annotations.push(FieldAnnotation::deserialize(input)?);
|
||||
}
|
||||
let mut method_annotation = vec![];
|
||||
let mut method_annotations = vec![];
|
||||
for _ in 0..annotated_methods_size {
|
||||
method_annotation.push(MethodAnnotation::deserialize(input)?);
|
||||
method_annotations.push(MethodAnnotation::deserialize(input)?);
|
||||
}
|
||||
let mut parameter_annotations = vec![];
|
||||
for _ in 0..annotated_parameters_size {
|
||||
|
|
@ -78,7 +78,7 @@ impl Serializable for AnnotationDirectoryItem {
|
|||
Ok(Self {
|
||||
class_annotations_off,
|
||||
field_annotations,
|
||||
method_annotation,
|
||||
method_annotations,
|
||||
parameter_annotations,
|
||||
})
|
||||
}
|
||||
|
|
@ -93,7 +93,7 @@ impl Serializable for AnnotationDirectoryItem {
|
|||
.map(|val| val.size())
|
||||
.sum::<usize>()
|
||||
+ self
|
||||
.method_annotation
|
||||
.method_annotations
|
||||
.iter()
|
||||
.map(|val| val.size())
|
||||
.sum::<usize>()
|
||||
|
|
@ -108,25 +108,28 @@ impl Serializable for AnnotationDirectoryItem {
|
|||
/// <https://source.android.com/docs/core/runtime/dex-format#field-annotation>
|
||||
#[derive(Serializable, Debug, Clone, PartialEq, Eq)]
|
||||
pub struct FieldAnnotation {
|
||||
/// Index of the field annotated in `field_ids`
|
||||
pub field_idx: u32,
|
||||
/// Offset to a [`AnnotationSetItem`]
|
||||
pub annotation_off: u32,
|
||||
pub annotations_off: u32,
|
||||
}
|
||||
|
||||
/// <https://source.android.com/docs/core/runtime/dex-format#method-annotation>
|
||||
#[derive(Serializable, Debug, Clone, PartialEq, Eq)]
|
||||
pub struct MethodAnnotation {
|
||||
/// Index of the method annotated in `method_ids`
|
||||
pub method_idx: u32,
|
||||
/// Offset to a [`AnnotationSetItem`]
|
||||
pub annotation_off: u32,
|
||||
pub annotations_off: u32,
|
||||
}
|
||||
|
||||
/// <https://source.android.com/docs/core/runtime/dex-format#parameter-annotation>
|
||||
#[derive(Serializable, Debug, Clone, PartialEq, Eq)]
|
||||
pub struct ParameterAnnotation {
|
||||
pub field_idx: u32,
|
||||
/// Index of the method whose parameters are annotated in `method_ids`
|
||||
pub method_idx: u32,
|
||||
/// Offset of a [`AnnotationSetRefList`]
|
||||
pub annotation_off: u32,
|
||||
pub annotations_off: u32,
|
||||
}
|
||||
|
||||
/// <https://source.android.com/docs/core/runtime/dex-format#set-ref-list>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue