G: *struct {
   allocator: Allocator;
};

#program_export max_memory: u64 = 4 * mem.Gigabyte;
#program_export state_size: u64 = size_of(type_of(G.*));

#program_export init :: (state: *void, allocator: Allocator, full_reset: bool) {
   G = state.(type_of(G));
   G.allocator = allocator;
   if !full_reset return;
}

#program_export setup :: () {
}

#program_export teardown :: () {
}

#program_export frame :: () -> reload.Status {
   print("doing nothing for one second...\n");
   sleep_milliseconds(1000);
   return .none;
}


#import "Basic";

mem :: #import "jc/memory";

DISABLE_HOT_RELOADING :: false;

#if DISABLE_HOT_RELOADING {
   // @note(judah): dumb workaround because module parameters are weird
   reload :: struct { Status :: (#import "jx/reload"(disabled = true)).Status; };

   main :: () {
      system_allocator := context.allocator;

      state := alloc(xx state_size);
      init(state, system_allocator, true);

      setup();

      while true {
         status := frame();
         if status == .quit break;
      }

      teardown();
   }
}
else {
   reload :: #import "jc/meta/reload";
   #poke_name reload frame;
   #poke_name reload init;
   #poke_name reload setup;
   #poke_name reload teardown;

   #poke_name reload build_options;

   // Use the default build options
   build_options :: () => reload.Simple_Build_Options.{};
}

