skeleton for method

This commit is contained in:
Jean-Marie Mineau 2023-10-04 14:30:07 +02:00
parent e084dd1b8b
commit 0a112802cd
Signed by: histausse
GPG key ID: B66AEEDA9B645AD2
4 changed files with 66 additions and 2 deletions

View file

@ -1,5 +1,5 @@
- enum
- method - method
- anotation
- code - code
- edditable format - edditable format
- sanity checks - sanity checks

View file

@ -6,6 +6,7 @@ pub mod apk;
pub mod class; pub mod class;
pub mod dex_id; pub mod dex_id;
pub mod field; pub mod field;
pub mod method;
pub mod method_handle; pub mod method_handle;
pub mod scalar; pub mod scalar;
pub mod value; pub mod value;
@ -14,6 +15,7 @@ pub use apk::*;
pub use class::*; pub use class::*;
pub use dex_id::*; pub use dex_id::*;
pub use field::*; pub use field::*;
pub use method::*;
pub use method_handle::*; pub use method_handle::*;
pub use scalar::*; pub use scalar::*;
pub use value::*; pub use value::*;
@ -186,6 +188,8 @@ fn androscalpel(_py: Python, m: &PyModule) -> PyResult<()> {
m.add_class::<DexArray>()?; m.add_class::<DexArray>()?;
m.add_class::<IdAnnotation>()?; m.add_class::<IdAnnotation>()?;
m.add_class::<FieldVisibility>()?; m.add_class::<FieldVisibility>()?;
m.add_class::<Method>()?;
m.add_class::<Field>()?;
m.add_class::<Class>()?; m.add_class::<Class>()?;
m.add_class::<Apk>()?; m.add_class::<Apk>()?;
Ok(()) Ok(())

View file

@ -0,0 +1,60 @@
//! Representation of a method.
use pyo3::prelude::*;
use crate::IdMethod;
/// Represent a method.
#[pyclass]
#[derive(Debug, Clone)]
pub struct Method {
/// The structure used to reference this method.
#[pyo3(get, set)]
pub descriptor: IdMethod,
/* TODO: ACCESS FLAG
/// The field visibility
#[pyo3(get, set)]
pub visibility: FieldVisibility,
/// If the field is defined for the class globally
#[pyo3(get, set)]
pub is_static: bool,
/// If the field is immutable after construction
#[pyo3(get, set)]
pub is_final: bool,
/// For thread safety
#[pyo3(get, set)]
pub is_volatile: bool,
/// If the field should **not** be saved by default serialization
#[pyo3(get, set)]
pub is_transient: bool,
/// If the field is not defined in the source code
#[pyo3(get, set)]
pub is_synthetic: bool,
/// If the field is an enumerated value
#[pyo3(get, set)]
pub is_enum: bool,
*/
/// The code of the method
pub code: (),
}
#[pymethods]
impl Method {
#[new]
pub fn new(descriptor: IdMethod) -> Self {
Self {
descriptor,
code: (),
}
}
pub fn __str__(&self) -> String {
self.__repr__()
}
pub fn __repr__(&self) -> String {
let name: String = (&self.descriptor.name).into();
let ty: String = self.descriptor.proto.__str__();
format!("Method({name}, {ty})")
}
}

View file

@ -4,4 +4,4 @@ source venv_maturin/bin/activate
cd androscalpel cd androscalpel
maturin develop maturin develop
cd .. cd ..
python test.py python -i test.py