// NOTE: Loading mods from paths as `bind_winit` is cdylib which cannot be
// linked as a Rust dependency
#[path = "../src/event.rs"]
mod event;
#[path = "../src/event_loop.rs"]
mod event_loop;
#[path = "../src/util.rs"]
mod util;

use event::WindowEvent;
use event_loop::{
    EventAction, EventActions, InitAction, InitActions, WindowId, event_loop_new, run_app,
};
use util::CVec;

fn main() {
    let event_loop = event_loop_new();
    extern "C" fn init() -> InitActions {
        InitActions {
            fst: InitAction::CreateWindow,
            rest: CVec::from_vec(vec![]),
        }
    }
    extern "C" fn on_window_event(window_id: WindowId, event: WindowEvent) -> EventActions {
        dbg!(window_id, &event);
        let actions = match event {
            WindowEvent::CloseRequested => vec![EventAction::Exit],
            _ => vec![],
        };
        EventActions::from_vec(actions)
    }
    run_app(event_loop, init, on_window_event);
}