forked from gtk-rs/gir
-
Notifications
You must be signed in to change notification settings - Fork 0
/
env.rs
58 lines (53 loc) · 1.5 KB
/
env.rs
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
52
53
54
55
56
57
58
use crate::{
analysis,
config::{gobjects::GStatus, Config},
library::*,
version::Version,
};
use std::cell::RefCell;
#[derive(Debug)]
pub struct Env {
pub library: Library,
pub config: Config,
pub namespaces: analysis::namespaces::Info,
pub symbols: RefCell<analysis::symbols::Info>,
pub class_hierarchy: analysis::class_hierarchy::Info,
pub analysis: analysis::Analysis,
}
impl Env {
#[inline]
pub fn type_(&self, tid: TypeId) -> &Type {
self.library.type_(tid)
}
pub fn type_status(&self, name: &str) -> GStatus {
self.config
.objects
.get(name)
.map(|o| o.status)
.unwrap_or_default()
}
pub fn type_status_sys(&self, name: &str) -> GStatus {
self.config
.objects
.get(name)
.map(|o| o.status)
.unwrap_or(GStatus::Generate)
}
pub fn is_totally_deprecated(&self, deprecated_version: Option<Version>) -> bool {
match deprecated_version {
Some(version) if version <= self.config.min_cfg_version => {
self.config.deprecate_by_min_version
}
_ => false,
}
}
pub fn is_too_low_version(&self, version: Option<Version>) -> bool {
match version {
Some(version) => version <= self.config.min_cfg_version,
_ => false,
}
}
pub fn main_sys_crate_name(&self) -> &str {
&self.namespaces[MAIN_NAMESPACE].sys_crate_name
}
}