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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#![allow(non_camel_case_types)]
#![allow(non_upper_case_globals)]
use glk_sys::giblorb_create_map;
use crate::types::strid_t;
use crate::util::unhandled;
pub use glk_sys::giblorb_map_t;
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
pub struct giblorb_err(pub u32);
impl giblorb_err {
pub const None: Self = Self(0);
pub const CompileTime: Self = Self(1);
pub const Alloc: Self = Self(2);
pub const Read: Self = Self(3);
pub const NotAMap: Self = Self(4);
pub const Format: Self = Self(5);
pub const NotFound: Self = Self(6);
}
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
pub struct giblorb_method(pub u32);
impl giblorb_method {
pub const DontLoad: Self = Self(0);
pub const Memory: Self = Self(1);
pub const FilePos: Self = Self(2);
}
pub trait Handlers {
fn giblorb_set_resource_map(&mut self, _file: strid_t) -> giblorb_err {
unhandled("giblorb_set_resource_map");
giblorb_err::None
}
fn giblorb_get_resource_map(&mut self) -> *mut giblorb_map_t {
unhandled("giblorb_get_resource_map");
0 as *mut giblorb_map_t
}
}
pub fn create_map(file: strid_t) -> Result<*mut giblorb_map_t, giblorb_err> {
let mut ret = 0 as *mut giblorb_map_t;
let err = unsafe {
giblorb_err(giblorb_create_map(
file,
&mut ret as *mut *mut giblorb_map_t,
))
};
if err != giblorb_err::None {
Err(err)
} else {
Ok(ret)
}
}