#include <windows.h>
#include <spdlog/spdlog.h>
#include <stdexcept>
#include <stdio.h>
#include <r3/binders/static_mem.h>
#include <r3/binders/stubexcept.h>

// Error reporting and such
extern "C" void r3_noop(void*, void*) {}

extern "C" int r3_main(HINSTANCE hInstance, HINSTANCE hPrevInstance,
                       LPSTR *cmdline, int showCmd);

GHStubException::GHStubException(const char *msg) : std::exception(msg) {
  SPDLOG_ERROR("{}", msg);
}

int main(int argc, char **argv) {
  try {
    gh_init_data_segment();

    r3_main(GetModuleHandle(NULL), NULL, argv, SW_SHOW);
  } catch (const std::exception &e) {
    SPDLOG_ERROR("Unhandled exception: {}", e.what());
  }
  return 0;
}