Skip to main content

ParameterView

Struct ParameterView 

Source
pub struct ParameterView<'g> { /* private fields */ }
Expand description

A parameter of a MethodView.

Implementations§

Source§

impl<'g> ParameterView<'g>

Source

pub fn name(&self) -> &'g str

The parameter’s name.

Examples found in repository?
examples/game_info.rs (line 61)
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}
Source

pub fn ty(&self) -> Option<&'g Il2CppType>

The parameter’s type from the binary’s type table; byref is set for ref / out parameters.

Source

pub fn type_name(&self) -> String

A C#-like type name, e.g. ref int.

Examples found in repository?
examples/game_info.rs (line 61)
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}

Trait Implementations§

Source§

impl<'g> Clone for ParameterView<'g>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'g> Copy for ParameterView<'g>

Source§

impl<'g, 'ʄ> Facet<'ʄ> for ParameterView<'g>
where 'g: 'ʄ, 'ʄ: 'g,

Available on crate feature reflect only.
Source§

const SHAPE: &'static Shape

The shape of this type, including: whether it’s a Struct, an Enum, something else? Read more

Auto Trait Implementations§

§

impl<'g> Forget for ParameterView<'g>

§

impl<'g> Freeze for ParameterView<'g>

§

impl<'g> Move for ParameterView<'g>

§

impl<'g> RefUnwindSafe for ParameterView<'g>

§

impl<'g> Send for ParameterView<'g>
where &'g Game: Send, &'g ParameterDefinition: Send,

§

impl<'g> Sync for ParameterView<'g>
where RawVecInner: Sync, RawTable<(&'static str, (usize, usize))>: Sync, BoxRaw<Il2CppType>: Sync, RawTable<(String, i32)>: Sync,

§

impl<'g> Unpin for ParameterView<'g>

§

impl<'g> UnsafeUnpin for ParameterView<'g>

§

impl<'g> UnwindSafe for ParameterView<'g>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.