pub struct MethodView<'g> { /* private fields */ }Implementations§
Source§impl<'g> MethodView<'g>
impl<'g> MethodView<'g>
pub fn definition(&self) -> &'g MethodDefinition
Sourcepub fn name(&self) -> &'g str
pub fn name(&self) -> &'g str
Examples found in repository?
examples/game_info.rs (line 50)
12fn main() -> hao_il2cpp::Result<()> {
13 let mut args = std::env::args().skip(1);
14 let dir = args
15 .next()
16 .expect("usage: game_info <game folder> [type name] [method name]");
17 let game = Game::open(dir)?;
18
19 let Some(type_name) = args.next() else {
20 println!(
21 "{} types in {} assemblies:",
22 game.types().count(),
23 game.image_names().count()
24 );
25 for name in game.image_names() {
26 println!(" {}", name);
27 }
28 return Ok(());
29 };
30
31 let Some(ty) = game.find_type(&type_name) else {
32 println!("no type named {}; similar names:", type_name);
33 for t in game
34 .types()
35 .filter(|t| {
36 t.name()
37 .contains(type_name.rsplit('.').next().unwrap_or(&type_name))
38 })
39 .take(10)
40 {
41 println!(" {}", t.full_name());
42 }
43 return Ok(());
44 };
45
46 // With a method name, break every matching overload into its parts, to show
47 // that names, return types and parameters are each available separately.
48 if let Some(method_name) = args.next() {
49 let mut found = false;
50 for method in ty.methods().filter(|m| m.name() == method_name) {
51 found = true;
52 println!("{}.{}", ty.full_name(), method.name());
53 println!(" static: {}", method.is_static());
54 println!(" returns: {}", method.return_type_name());
55 let parameters: Vec<_> = method.parameters().collect();
56 if parameters.is_empty() {
57 println!(" params: (none)");
58 } else {
59 println!(" params:");
60 for (i, parameter) in parameters.iter().enumerate() {
61 println!(" {}: {} {}", i, parameter.type_name(), parameter.name());
62 }
63 }
64 println!();
65 }
66 if !found {
67 println!("no method named {} on {}", method_name, ty.full_name());
68 }
69 return Ok(());
70 }
71
72 print!("// {}\nclass {}", ty.image_name(), ty.full_name());
73 if let Some(base) = ty.base_type_name() {
74 print!(" : {}", base);
75 }
76 println!("\n{{");
77 for field in ty.fields() {
78 println!(" {};", field);
79 }
80 for method in ty.methods() {
81 println!(" {};", method);
82 }
83 for nested in ty.nested_types() {
84 println!(" class {}", nested.name());
85 }
86 println!("}}");
87 Ok(())
88}Sourcepub fn is_static(&self) -> bool
pub fn is_static(&self) -> bool
Examples found in repository?
examples/game_info.rs (line 53)
12fn main() -> hao_il2cpp::Result<()> {
13 let mut args = std::env::args().skip(1);
14 let dir = args
15 .next()
16 .expect("usage: game_info <game folder> [type name] [method name]");
17 let game = Game::open(dir)?;
18
19 let Some(type_name) = args.next() else {
20 println!(
21 "{} types in {} assemblies:",
22 game.types().count(),
23 game.image_names().count()
24 );
25 for name in game.image_names() {
26 println!(" {}", name);
27 }
28 return Ok(());
29 };
30
31 let Some(ty) = game.find_type(&type_name) else {
32 println!("no type named {}; similar names:", type_name);
33 for t in game
34 .types()
35 .filter(|t| {
36 t.name()
37 .contains(type_name.rsplit('.').next().unwrap_or(&type_name))
38 })
39 .take(10)
40 {
41 println!(" {}", t.full_name());
42 }
43 return Ok(());
44 };
45
46 // With a method name, break every matching overload into its parts, to show
47 // that names, return types and parameters are each available separately.
48 if let Some(method_name) = args.next() {
49 let mut found = false;
50 for method in ty.methods().filter(|m| m.name() == method_name) {
51 found = true;
52 println!("{}.{}", ty.full_name(), method.name());
53 println!(" static: {}", method.is_static());
54 println!(" returns: {}", method.return_type_name());
55 let parameters: Vec<_> = method.parameters().collect();
56 if parameters.is_empty() {
57 println!(" params: (none)");
58 } else {
59 println!(" params:");
60 for (i, parameter) in parameters.iter().enumerate() {
61 println!(" {}: {} {}", i, parameter.type_name(), parameter.name());
62 }
63 }
64 println!();
65 }
66 if !found {
67 println!("no method named {} on {}", method_name, ty.full_name());
68 }
69 return Ok(());
70 }
71
72 print!("// {}\nclass {}", ty.image_name(), ty.full_name());
73 if let Some(base) = ty.base_type_name() {
74 print!(" : {}", base);
75 }
76 println!("\n{{");
77 for field in ty.fields() {
78 println!(" {};", field);
79 }
80 for method in ty.methods() {
81 println!(" {};", method);
82 }
83 for nested in ty.nested_types() {
84 println!(" class {}", nested.name());
85 }
86 println!("}}");
87 Ok(())
88}pub fn return_type(&self) -> Option<&'g Il2CppType>
Sourcepub fn return_type_name(&self) -> String
pub fn return_type_name(&self) -> String
Examples found in repository?
examples/game_info.rs (line 54)
12fn main() -> hao_il2cpp::Result<()> {
13 let mut args = std::env::args().skip(1);
14 let dir = args
15 .next()
16 .expect("usage: game_info <game folder> [type name] [method name]");
17 let game = Game::open(dir)?;
18
19 let Some(type_name) = args.next() else {
20 println!(
21 "{} types in {} assemblies:",
22 game.types().count(),
23 game.image_names().count()
24 );
25 for name in game.image_names() {
26 println!(" {}", name);
27 }
28 return Ok(());
29 };
30
31 let Some(ty) = game.find_type(&type_name) else {
32 println!("no type named {}; similar names:", type_name);
33 for t in game
34 .types()
35 .filter(|t| {
36 t.name()
37 .contains(type_name.rsplit('.').next().unwrap_or(&type_name))
38 })
39 .take(10)
40 {
41 println!(" {}", t.full_name());
42 }
43 return Ok(());
44 };
45
46 // With a method name, break every matching overload into its parts, to show
47 // that names, return types and parameters are each available separately.
48 if let Some(method_name) = args.next() {
49 let mut found = false;
50 for method in ty.methods().filter(|m| m.name() == method_name) {
51 found = true;
52 println!("{}.{}", ty.full_name(), method.name());
53 println!(" static: {}", method.is_static());
54 println!(" returns: {}", method.return_type_name());
55 let parameters: Vec<_> = method.parameters().collect();
56 if parameters.is_empty() {
57 println!(" params: (none)");
58 } else {
59 println!(" params:");
60 for (i, parameter) in parameters.iter().enumerate() {
61 println!(" {}: {} {}", i, parameter.type_name(), parameter.name());
62 }
63 }
64 println!();
65 }
66 if !found {
67 println!("no method named {} on {}", method_name, ty.full_name());
68 }
69 return Ok(());
70 }
71
72 print!("// {}\nclass {}", ty.image_name(), ty.full_name());
73 if let Some(base) = ty.base_type_name() {
74 print!(" : {}", base);
75 }
76 println!("\n{{");
77 for field in ty.fields() {
78 println!(" {};", field);
79 }
80 for method in ty.methods() {
81 println!(" {};", method);
82 }
83 for nested in ty.nested_types() {
84 println!(" class {}", nested.name());
85 }
86 println!("}}");
87 Ok(())
88}Sourcepub fn parameters(&self) -> impl Iterator<Item = ParameterView<'g>> + 'g
pub fn parameters(&self) -> impl Iterator<Item = ParameterView<'g>> + 'g
Examples found in repository?
examples/game_info.rs (line 55)
12fn main() -> hao_il2cpp::Result<()> {
13 let mut args = std::env::args().skip(1);
14 let dir = args
15 .next()
16 .expect("usage: game_info <game folder> [type name] [method name]");
17 let game = Game::open(dir)?;
18
19 let Some(type_name) = args.next() else {
20 println!(
21 "{} types in {} assemblies:",
22 game.types().count(),
23 game.image_names().count()
24 );
25 for name in game.image_names() {
26 println!(" {}", name);
27 }
28 return Ok(());
29 };
30
31 let Some(ty) = game.find_type(&type_name) else {
32 println!("no type named {}; similar names:", type_name);
33 for t in game
34 .types()
35 .filter(|t| {
36 t.name()
37 .contains(type_name.rsplit('.').next().unwrap_or(&type_name))
38 })
39 .take(10)
40 {
41 println!(" {}", t.full_name());
42 }
43 return Ok(());
44 };
45
46 // With a method name, break every matching overload into its parts, to show
47 // that names, return types and parameters are each available separately.
48 if let Some(method_name) = args.next() {
49 let mut found = false;
50 for method in ty.methods().filter(|m| m.name() == method_name) {
51 found = true;
52 println!("{}.{}", ty.full_name(), method.name());
53 println!(" static: {}", method.is_static());
54 println!(" returns: {}", method.return_type_name());
55 let parameters: Vec<_> = method.parameters().collect();
56 if parameters.is_empty() {
57 println!(" params: (none)");
58 } else {
59 println!(" params:");
60 for (i, parameter) in parameters.iter().enumerate() {
61 println!(" {}: {} {}", i, parameter.type_name(), parameter.name());
62 }
63 }
64 println!();
65 }
66 if !found {
67 println!("no method named {} on {}", method_name, ty.full_name());
68 }
69 return Ok(());
70 }
71
72 print!("// {}\nclass {}", ty.image_name(), ty.full_name());
73 if let Some(base) = ty.base_type_name() {
74 print!(" : {}", base);
75 }
76 println!("\n{{");
77 for field in ty.fields() {
78 println!(" {};", field);
79 }
80 for method in ty.methods() {
81 println!(" {};", method);
82 }
83 for nested in ty.nested_types() {
84 println!(" class {}", nested.name());
85 }
86 println!("}}");
87 Ok(())
88}Sourcepub fn parameter_type_names(&self) -> Vec<String>
pub fn parameter_type_names(&self) -> Vec<String>
The types of the parameters, e.g. ["string", "string"].
Trait Implementations§
Source§impl<'g> Clone for MethodView<'g>
impl<'g> Clone for MethodView<'g>
impl<'g> Copy for MethodView<'g>
Auto Trait Implementations§
impl<'g> Freeze for MethodView<'g>
impl<'g> RefUnwindSafe for MethodView<'g>
impl<'g> Send for MethodView<'g>
impl<'g> Sync for MethodView<'g>
impl<'g> Unpin for MethodView<'g>
impl<'g> UnsafeUnpin for MethodView<'g>
impl<'g> UnwindSafe for MethodView<'g>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more