From: Bryce D. <bd...@us...> - 2002-11-01 15:24:34
|
Update of /cvsroot/bochs/bochs/gui In directory usw-pr-cvs1:/tmp/cvs-serv16662/gui Modified Files: siminterface.cc siminterface.h textconfig.cc wxmain.cc Log Message: - fix wxWindows on win32, which was broken when we added plugin support. - add a new global struct bx_startup_flags which stores argc,argv and when necessary, the WinMain arguments hInstance, hPrevInstance, etc. The new struct is defined in gui/siminterface.h because it is needed in both the main.cc code and in wxmain.cc and textconfig.cc (which don't include bochs.h). - rename main() to bxmain() and create new main() and WinMain(). main() and WinMain() just fill in the bx_startup_flags and then call bxmain(). Only one is defined at a time, of course. - so far, WinMain is ONLY used when compiling with wxWindows on win32. It may be useful in other contexts as well, but I don't want to enable it in any other situation without some serious testing of different configurations. - modified: main.cc gui/siminterface.cc gui/siminterface.h gui/textconfig.cc gui/wxmain.cc Index: siminterface.cc =================================================================== RCS file: /cvsroot/bochs/bochs/gui/siminterface.cc,v retrieving revision 1.80 retrieving revision 1.81 diff -u -d -r1.80 -r1.81 --- siminterface.cc 27 Oct 2002 21:25:33 -0000 1.80 +++ siminterface.cc 1 Nov 2002 15:19:40 -0000 1.81 @@ -693,9 +693,6 @@ int bx_real_sim_c::begin_simulation (int argc, char *argv[]) { -#ifdef __GNUC__ -#warning does the config interface actually need to pass these args into bx_begin_simulation?? None of them is actually doing it. -#endif return bx_begin_simulation (argc, argv); } Index: siminterface.h =================================================================== RCS file: /cvsroot/bochs/bochs/gui/siminterface.h,v retrieving revision 1.82 retrieving revision 1.83 diff -u -d -r1.82 -r1.83 --- siminterface.h 29 Oct 2002 22:26:31 -0000 1.82 +++ siminterface.h 1 Nov 2002 15:19:43 -0000 1.83 @@ -1247,3 +1247,26 @@ BOCHSAPI extern void bx_init_siminterface (); BOCHSAPI extern int bx_init_main (int argc, char *argv[]); + +#ifdef __WXMSW__ +// Just to provide HINSTANCE, etc. in files that have not included bochs.h. +// I don't like this at all, but I don't see a way around it. +#include <windows.h> +#endif + +// define structure to hold data that is passed into our main function. +typedef struct BOCHSAPI { + // standard argc,argv + int argc; + char **argv; +#ifdef __WXMSW__ + // these are only used when compiling with wxWindows. This gives us a + // place to store the data that was passed to WinMain. + HINSTANCE hInstance; + HINSTANCE hPrevInstance; + LPSTR m_lpCmdLine; + int nCmdShow; +#endif +} bx_startup_flags_t; + +extern bx_startup_flags_t BOCHSAPI bx_startup_flags; Index: textconfig.cc =================================================================== RCS file: /cvsroot/bochs/bochs/gui/textconfig.cc,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- textconfig.cc 29 Oct 2002 20:17:05 -0000 1.1 +++ textconfig.cc 1 Nov 2002 15:19:47 -0000 1.2 @@ -406,8 +406,7 @@ bx_config_interface_init (); return 0; case BX_CI_START_SIMULATION: { - char *myargv[] = {"manufactured-argv"}; - SIM->begin_simulation (1, myargv); + SIM->begin_simulation (bx_startup_flags.argc, bx_startup_flags.argv); // we don't expect it to return, but if it does, quit SIM->quit_sim(1); break; Index: wxmain.cc =================================================================== RCS file: /cvsroot/bochs/bochs/gui/wxmain.cc,v retrieving revision 1.73 retrieving revision 1.74 diff -u -d -r1.73 -r1.74 --- wxmain.cc 26 Oct 2002 13:22:47 -0000 1.73 +++ wxmain.cc 1 Nov 2002 15:19:48 -0000 1.74 @@ -158,12 +158,22 @@ { switch (command) { - case CI_START: { + case CI_START: //fprintf (stderr, "wxmain.cc: start\n"); - char *argv[] = {"manufactured-argv"}; - wxEntry (1, argv); +#ifdef __WXMSW__ + // on Windows only, wxEntry needs some data that is passed into WinMain. + // So, in main.cc we define WinMain and fill in the bx_startup_flags + // structure with the data, so that when we're ready to call wxEntry + // it has access to the data. + wxEntry ( + bx_startup_flags.hInstance, + bx_startup_flags.hPrevInstance, + bx_startup_flags.m_lpCmdLine, + bx_startup_flags.nCmdShow); +#else + wxEntry (bx_startup_flags.argc, bx_startup_flags.argv); +#endif break; - } case CI_RUNTIME_CONFIG: fprintf (stderr, "wxmain.cc: runtime config not implemented\n"); break; @@ -1477,9 +1487,7 @@ static jmp_buf context; // this must not go out of scope. maybe static not needed if (setjmp (context) == 0) { SIM->set_quit_context (&context); - int argc=1; - char *argv[] = {"bochs"}; - SIM->begin_simulation (argc, argv); + SIM->begin_simulation (bx_startup_flags.argc, bx_startup_flags.argv); wxLogDebug ("in SimThread, SIM->begin_simulation() exited normally"); } else { wxLogDebug ("in SimThread, SIM->begin_simulation() exited by longjmp"); |