skeleton for method
This commit is contained in:
parent
e084dd1b8b
commit
0a112802cd
4 changed files with 66 additions and 2 deletions
2
TODO.md
2
TODO.md
|
|
@ -1,5 +1,5 @@
|
|||
- enum
|
||||
- method
|
||||
- anotation
|
||||
- code
|
||||
- edditable format
|
||||
- sanity checks
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ pub mod apk;
|
|||
pub mod class;
|
||||
pub mod dex_id;
|
||||
pub mod field;
|
||||
pub mod method;
|
||||
pub mod method_handle;
|
||||
pub mod scalar;
|
||||
pub mod value;
|
||||
|
|
@ -14,6 +15,7 @@ pub use apk::*;
|
|||
pub use class::*;
|
||||
pub use dex_id::*;
|
||||
pub use field::*;
|
||||
pub use method::*;
|
||||
pub use method_handle::*;
|
||||
pub use scalar::*;
|
||||
pub use value::*;
|
||||
|
|
@ -186,6 +188,8 @@ fn androscalpel(_py: Python, m: &PyModule) -> PyResult<()> {
|
|||
m.add_class::<DexArray>()?;
|
||||
m.add_class::<IdAnnotation>()?;
|
||||
m.add_class::<FieldVisibility>()?;
|
||||
m.add_class::<Method>()?;
|
||||
m.add_class::<Field>()?;
|
||||
m.add_class::<Class>()?;
|
||||
m.add_class::<Apk>()?;
|
||||
Ok(())
|
||||
|
|
|
|||
60
androscalpel/src/method.rs
Normal file
60
androscalpel/src/method.rs
Normal 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})")
|
||||
}
|
||||
}
|
||||
2
test.sh
2
test.sh
|
|
@ -4,4 +4,4 @@ source venv_maturin/bin/activate
|
|||
cd androscalpel
|
||||
maturin develop
|
||||
cd ..
|
||||
python test.py
|
||||
python -i test.py
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue