From 01eab6425e46a235ec0345b3316bdba33581fdd4 Mon Sep 17 00:00:00 2001 From: NatsuDrag9 Date: Fri, 8 Jun 2018 10:31:50 +0530 Subject: Builds and runs from ldmicro.cpp. No further testing is required. --- ldmicro/ldmicro.cpp | 253 +++++++++++++++++++++++++++++----------------------- 1 file changed, 139 insertions(+), 114 deletions(-) (limited to 'ldmicro/ldmicro.cpp') diff --git a/ldmicro/ldmicro.cpp b/ldmicro/ldmicro.cpp index 955b23b..e3d152e 100644 --- a/ldmicro/ldmicro.cpp +++ b/ldmicro/ldmicro.cpp @@ -139,64 +139,64 @@ PlcProgram Prog; // Compile the program to a hex file for the target micro. Get the output // file name if necessary, then call the micro-specific compile routines. //----------------------------------------------------------------------------- -static void CompileProgram(BOOL compileAs) -{ - if(compileAs || strlen(CurrentCompileFile)==0) { - OPENFILENAME ofn; - - memset(&ofn, 0, sizeof(ofn)); - ofn.lStructSize = sizeof(ofn); - ofn.parentWindow = NULL; - ofn.lpstrTitle = _("Compile To"); - if(Prog.mcu && Prog.mcu->whichIsa == ISA_ANSIC) { - ofn.lpstrFilter = C_PATTERN; - ofn.lpstrDefExt = "c"; - } else if(Prog.mcu && Prog.mcu->whichIsa == ISA_INTERPRETED) { - ofn.lpstrFilter = INTERPRETED_PATTERN; - ofn.lpstrDefExt = "int"; - } else { - ofn.lpstrFilter = HEX_PATTERN; - ofn.lpstrDefExt = "hex"; - } - ofn.lpstrFile = CurrentCompileFile; - ofn.nMaxFile = sizeof(CurrentCompileFile); - ofn.Flags = OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT; - - if(!GetSaveFileName(&ofn)) - return; - - // hex output filename is stored in the .ld file - ProgramChangedNotSaved = TRUE; - } - - if(!GenerateIntermediateCode()) return; - - if(Prog.mcu == NULL) { - Error(_("Must choose a target microcontroller before compiling.")); - return; - } - - if(UartFunctionUsed() && Prog.mcu->uartNeeds.rxPin == 0) { - Error(_("UART function used but not supported for this micro.")); - return; - } +// static void CompileProgram(BOOL compileAs) +// { +// if(compileAs || strlen(CurrentCompileFile)==0) { +// OPENFILENAME ofn; + +// memset(&ofn, 0, sizeof(ofn)); +// ofn.lStructSize = sizeof(ofn); +// ofn.parentWindow = NULL; +// ofn.lpstrTitle = _("Compile To"); +// if(Prog.mcu && Prog.mcu->whichIsa == ISA_ANSIC) { +// ofn.lpstrFilter = C_PATTERN; +// ofn.lpstrDefExt = "c"; +// } else if(Prog.mcu && Prog.mcu->whichIsa == ISA_INTERPRETED) { +// ofn.lpstrFilter = INTERPRETED_PATTERN; +// ofn.lpstrDefExt = "int"; +// } else { +// ofn.lpstrFilter = HEX_PATTERN; +// ofn.lpstrDefExt = "hex"; +// } +// ofn.lpstrFile = CurrentCompileFile; +// ofn.nMaxFile = sizeof(CurrentCompileFile); +// ofn.Flags = OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT; + +// if(!GetSaveFileName(&ofn)) +// return; + +// // hex output filename is stored in the .ld file +// ProgramChangedNotSaved = TRUE; +// } + +// if(!GenerateIntermediateCode()) return; + +// if(Prog.mcu == NULL) { +// Error(_("Must choose a target microcontroller before compiling.")); +// return; +// } + +// if(UartFunctionUsed() && Prog.mcu->uartNeeds.rxPin == 0) { +// Error(_("UART function used but not supported for this micro.")); +// return; +// } - if(PwmFunctionUsed() && Prog.mcu->pwmNeedsPin == 0) { - Error(_("PWM function used but not supported for this micro.")); - return; - } +// if(PwmFunctionUsed() && Prog.mcu->pwmNeedsPin == 0) { +// Error(_("PWM function used but not supported for this micro.")); +// return; +// } - switch(Prog.mcu->whichIsa) { - case ISA_AVR: CompileAvr(CurrentCompileFile); break; - case ISA_PIC16: CompilePic16(CurrentCompileFile); break; - case ISA_ANSIC: CompileAnsiC(CurrentCompileFile); break; - case ISA_INTERPRETED: CompileInterpreted(CurrentCompileFile); break; - case ISA_ARDUINO: CompileArduino(CurrentCompileFile); break; - - default: oops(); - } -// IntDumpListing("t.pl"); -} +// switch(Prog.mcu->whichIsa) { +// case ISA_AVR: CompileAvr(CurrentCompileFile); break; +// case ISA_PIC16: CompilePic16(CurrentCompileFile); break; +// case ISA_ANSIC: CompileAnsiC(CurrentCompileFile); break; +// case ISA_INTERPRETED: CompileInterpreted(CurrentCompileFile); break; +// case ISA_ARDUINO: CompileArduino(CurrentCompileFile); break; + +// default: oops(); +// } +// // IntDumpListing("t.pl"); +// } //----------------------------------------------------------------------------- // If the program has been modified then give the user the option to save it @@ -1027,6 +1027,31 @@ static void CompileProgram(BOOL compileAs) // return RegisterClassEx(&wc); // } +void Activate_App (GtkApplication* app, gpointer user_data){ + MainWindow = gtk_application_window_new (app); + gtk_window_set_default_size (GTK_WINDOW (MainWindow), 600, 400); + + // Title bar + UpdateMainWindowTitleBar(); + + // Splitting the window + MakeMainWindowControls(); + + // Calling the Simulation functions + + StartSimulation(); + SetMenusEnabled(true, true, false, + true, false, false, false, + true, true, true); + // ToggleSimulationMode(); + // GenerateIoListDontLoseSelection(); + StopSimulation(); + + // Displaying the window + gtk_widget_show_all(MainWindow); + +} + //----------------------------------------------------------------------------- // Entry point into the program. //----------------------------------------------------------------------------- @@ -1035,64 +1060,64 @@ int main(int argc, char** argv) /// Check if we're running in non-interactive mode; in that case we should /// load the file, compile, and exit. - if(argc >= 2) { - RunningInBatchMode = TRUE; - - char *err = - "Bad command line arguments: run 'ldmicro /c src.ld dest.hex'"; - - if (argc < 4) - { - printf("throwing error...\n"); - Error(err); - exit(-1); - } - - char *source = (char*)malloc(strlen(argv[2]) + strlen(argv[3]) + 2); - sprintf(source, "%s %s", argv[2], argv[3]); - - while(isspace(*source)) { - source++; - } - if(*source == '\0') - { - Error(err); - free(source); - exit(-1); - } - - char *dest = source; - while(!isspace(*dest) && *dest) { - dest++; - } - if(*dest == '\0') - { - Error(err); - free(source); - exit(-1); - } - *dest = '\0'; dest++; - while(isspace(*dest)) { - dest++; - } - - if(*dest == '\0') - { - Error(err); - free(source); - exit(-1); - } - - if(!LoadProjectFromFile(source)) { - Error("Couldn't open '%s', running non-interactively.\n", source); - free(source); - exit(-1); - } - strcpy(CurrentCompileFile, dest); - GenerateIoList(-1); - CompileProgram(FALSE); - exit(0); - } + // if(argc >= 2) { + // RunningInBatchMode = TRUE; + + // char *err = + // "Bad command line arguments: run 'ldmicro /c src.ld dest.hex'"; + + // if (argc < 4) + // { + // printf("throwing error...\n"); + // Error(err); + // exit(-1); + // } + + // char *source = (char*)malloc(strlen(argv[2]) + strlen(argv[3]) + 2); + // sprintf(source, "%s %s", argv[2], argv[3]); + + // while(isspace(*source)) { + // source++; + // } + // if(*source == '\0') + // { + // Error(err); + // free(source); + // exit(-1); + // } + + // char *dest = source; + // while(!isspace(*dest) && *dest) { + // dest++; + // } + // if(*dest == '\0') + // { + // Error(err); + // free(source); + // exit(-1); + // } + // *dest = '\0'; dest++; + // while(isspace(*dest)) { + // dest++; + // } + + // if(*dest == '\0') + // { + // Error(err); + // free(source); + // exit(-1); + // } + + // if(!LoadProjectFromFile(source)) { + // Error("Couldn't open '%s', running non-interactively.\n", source); + // free(source); + // exit(-1); + // } + // strcpy(CurrentCompileFile, dest); + // GenerateIoList(-1); + // CompileProgram(FALSE); + // exit(0); + // } GtkApplication *app; int status; -- cgit