Skip to content

Commit 52a9adc

Browse files
committed
refactor
1 parent 20b0ff1 commit 52a9adc

File tree

3 files changed

+67
-37
lines changed

3 files changed

+67
-37
lines changed

src/imgui_c.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
2+
#[derive(Debug, Clone)]
3+
pub struct Imgui{
4+
}
5+
6+
impl Imgui{
7+
pub fn new() -> Imgui{
8+
Imgui{
9+
}
10+
}
11+
12+
#[allow(non_snake_case)]
13+
pub fn IMGUI_CHECKVERSION(&self){
14+
}
15+
16+
pub fn create_context(&self){
17+
}
18+
19+
pub fn get_io(&self){
20+
}
21+
}

src/imgui_stdweb.rs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
2+
3+
4+
#[derive(Debug, Clone)]
5+
pub struct Imgui{
6+
module: stdweb::Value
7+
}
8+
9+
10+
impl Imgui{
11+
pub fn new() -> Imgui{
12+
Imgui{
13+
module:js!{return window.Imgui;}
14+
}
15+
}
16+
17+
#[allow(non_snake_case)]
18+
pub fn IMGUI_CHECKVERSION(&self){
19+
let module = &self.module;
20+
js! {
21+
@{module}.IMGUI_CHECKVERSION();
22+
};
23+
}
24+
25+
pub fn create_context(&self){
26+
let module = &self.module;
27+
js! {
28+
return @{module}.create_context();
29+
};
30+
}
31+
32+
pub fn get_io(&self) -> stdweb::Value{
33+
let module = &self.module;
34+
let ret = js! {
35+
return @{module}.get_io();
36+
};
37+
ret
38+
}
39+
}

src/lib.rs

Lines changed: 7 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,19 @@
1-
#[cfg(not(target_arch = "wasm32"))]
2-
extern crate libc;
3-
41
#[macro_use]
52
#[cfg(all(target_arch = "wasm32"))]
63
extern crate stdweb;
74

8-
#[cfg(not(target_arch = "wasm32"))]
9-
#[derive(Debug, Clone)]
10-
pub struct Imgui{
11-
}
12-
13-
#[cfg(not(target_arch = "wasm32"))]
14-
impl Imgui{
15-
pub fn new() -> Imgui{
16-
Imgui{
17-
}
18-
}
19-
20-
#[allow(non_snake_case)]
21-
pub fn IMGUI_CHECKVERSION(&self){
22-
}
23-
}
245

256
#[cfg(all(target_arch = "wasm32"))]
26-
#[derive(Debug, Clone)]
27-
pub struct Imgui{
28-
module: stdweb::Value
29-
}
7+
pub mod imgui_stdweb;
308

319
#[cfg(all(target_arch = "wasm32"))]
32-
impl Imgui{
33-
pub fn new() -> Imgui{
34-
Imgui{
35-
module:js!{return window.Imgui;}
36-
}
37-
}
10+
pub use self::imgui_stdweb::*;
3811

39-
#[allow(non_snake_case)]
40-
pub fn IMGUI_CHECKVERSION(&self){
41-
let module = &self.module;
42-
js! {
43-
@{module}.IMGUI_CHECKVERSION();
44-
};
45-
}
46-
}
12+
#[cfg(not(target_arch = "wasm32"))]
13+
pub mod imgui_c;
14+
15+
#[cfg(not(target_arch = "wasm32"))]
16+
pub use self::imgui_c::*;
4717

4818

4919
#[cfg(test)]

0 commit comments

Comments
 (0)