1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
use std::borrow::Cow;
use std::ffi::CStr;
use std::fmt;
use crate::{raw, Il2CppType, WrapRaw};
#[repr(transparent)]
pub struct ParameterInfo(raw::ParameterInfo);
unsafe impl Send for ParameterInfo {}
unsafe impl Sync for ParameterInfo {}
impl ParameterInfo {
pub fn name(&self) -> Cow<'_, str> {
let name = self.raw().name;
assert!(!name.is_null());
unsafe { CStr::from_ptr(name) }.to_string_lossy()
}
pub fn position(&self) -> usize {
self.raw().position as _
}
pub fn ty(&self) -> &Il2CppType {
unsafe { Il2CppType::wrap_ptr(self.raw().parameter_type) }.unwrap()
}
}
impl fmt::Debug for ParameterInfo {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("ParameterInfo")
.field("name", &self.name())
.field("position", &self.position())
.field("ty", &self.ty())
.finish()
}
}
impl fmt::Display for ParameterInfo {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{} {}", self.ty(), self.name())
}
}
unsafe impl WrapRaw for ParameterInfo {
type Raw = raw::ParameterInfo;
}