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
#[macro_use]
extern crate enum_primitive;
#[macro_use]
extern crate log;
extern crate num_traits;
#[macro_use]
extern crate scoped_tls;
extern crate serde;
#[macro_use]
extern crate serde_derive;
#[macro_use]
extern crate stdweb;

macro_rules! js_unwrap {
    ($($code:tt)*) => (
        ::stdweb::unstable::TryInto::try_into(js! { return $($code)* })
            .expect(concat!("js_unwrap at ", line!(), " in ", file!()))
    )
}

macro_rules! get_from_js {
    ($name:ident -> { $js_side:expr } -> $rust_ret_type:ty) => (
        get_from_js!($name() -> { $js_side } -> $rust_ret_type);
    );
    (
        $name:ident(
            $($param_ident:ident: $param_ty:ty),*
        ) -> {
            $($js_side:tt)*
        } -> $rust_ret_type:ty
    ) => (
        pub fn $name(
            $($param_ident: $param_ty),*
        ) -> $rust_ret_type {
            js_unwrap!($($js_side)*)
        }
    )
}

pub mod game;
pub mod objects;
pub mod constants;
pub mod memory;
pub mod raw_memory;
pub mod pathfinder;
mod positions;

pub use objects::*;
pub use constants::*;
pub use positions::{LocalRoomName, LocalRoomPosition};

/// Useful for `use screeps::prelude::*;` to bring in screeps traits.
pub mod prelude {
    pub use objects::{HasPosition, HasStore, OwnedStructureProperties, RoomObjectProperties,
                      StructureProperties};
}