int main(int argc, char* argv[]) { if(argc < 3) { puts("Usage:\n\n\tprefab_compiler output_filename prefab_src_file_1 prefab_src_file_2 ...\n"); return 1; } const char* output_filename = argv[1]; FILE* output_file = fopen(output_filename, "wb"); if(output_filename == 0) { fprintf(stderr, "Could not open output file \"%s\" for writing", output_filename); return 2; } PrefabContainer prefabs; for(int i = 2; i < argc; ++i) { processSourceFile(argv[i], prefabs); } saveOutput(output_file, prefabs); fclose(output_file); return 0; }
/* * Constructs a Superconductor_Messages as a child of 'parent', with the * name 'name' and widget flags set to 'f'. * * The dialog will by default be modeless, unless you set 'modal' to * TRUE to construct a modal dialog. */ Superconductor_Messages::Superconductor_Messages( SCMessageList* sl, QWidget* parent, const char* name, bool modal, WFlags fl ) : QDialog( parent, name, modal, fl ) { if ( sl ) strings = sl; if ( !name ) setName( "Superconductor_Messages" ); layout = new QGridLayout( this, 2, 2 ); // layout->setAutoAdd( TRUE ); layout->setResizeMode( QLayout::FreeResize ); listBox = new QListBox( this, "listBox" ); listBox->setGeometry( QRect( 10, 10, 291, 461 ) ); listBox->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)7, 0, 0, listBox->sizePolicy().hasHeightForWidth() ) ); listBox->setSelectionMode( QListBox::NoSelection ); listBox->setVariableWidth( TRUE ); languageChange(); resize( QSize(314, 480).expandedTo(minimumSizeHint()) ); clearWState( WState_Polished ); save = new QPushButton( "Save", this ); closeButton = new QPushButton( "Close", this ); layout->addMultiCellWidget( listBox, 0, 0, 0, 1 ); layout->addWidget( save, 1, 0 ); layout->addWidget( closeButton, 1, 1 ); connect( save, SIGNAL( clicked() ), this, SLOT( saveOutput() ) ); connect( closeButton, SIGNAL( clicked() ), this, SLOT( closeDialog() ) ); }
static void MAMACALLTYPE listenerMsgCb (mamaSubscription subscription, mamaMsg msg, void * closure, void * itemClosure) { mamaCaptureSourceList* context = (mamaCaptureSourceList*)closure; const char* subSource = NULL; const char* subSymbol = NULL; const char* subTransport = NULL; if (context == NULL ) { mama_log (MAMA_LOG_LEVEL_FINE, "listenerMsgCb: Null pointer exception"); return; } mamaSubscription_getSource (subscription, &subSource); mamaSubscription_getSubscSymbol (subscription, &subSymbol); mamaTransport_getName (context->myTransport, &subTransport); if (!gShuttingDown) saveOutput(*gCapture, subSource, subTransport, subSymbol,msg); /*DEBUG OUTPUT mama_log (MAMA_LOG_LEVEL_NORMAL, "Capture [%p], Source [%s], Tport [%s] , Symbol [%s]", context->capture, subSource, subTransport , subSymbol); */ }
CComponenetSelectorDialog::CComponenetSelectorDialog(QWidget *parent, enum OUTPUT_TYPE outputType) : QDialog(parent), m_eOutputMode(outputType) { label = new QLabel(tr("Component List:")); saveButton = new QPushButton(tr("&Save")); cancelButton = new QPushButton(tr("&Cancel")); listWidget = new QListWidget(); // buttonBox = new QDialogButtonBox(Qt::Vertical); int nCount = CONFIGURATOR_API::getNumberOfAvailableComponents(); for (int idx = 0; idx < nCount; idx++) { listWidget->addItem(const_cast<char*>(CONFIGURATOR_API::getComponentName(idx))); } QVBoxLayout *extensionLayout = new QVBoxLayout; extensionLayout->setMargin(0); QHBoxLayout *topLeftLayout = new QHBoxLayout; topLeftLayout->addWidget(label); QVBoxLayout *leftLayout = new QVBoxLayout; leftLayout->addLayout(topLeftLayout); QGridLayout *mainLayout = new QGridLayout; //mainLayout->setSizeConstraint(QLayout::SetFixedSize); mainLayout->addLayout(leftLayout, 0, 0); mainLayout->addWidget(listWidget, 0, 0, 1, 2); mainLayout->addWidget(saveButton, 1, 0); mainLayout->addWidget(cancelButton, 1, 1); /*mainLayout->setRowStretch(0, 1); mainLayout->setRowStretch(1, 1); mainLayout->setRowStretch(2, 1);*/ extensionLayout->addWidget(listWidget); setLayout(mainLayout); if (m_eOutputMode == QML_OUTPUT) { setWindowTitle(tr("Select component for QML generation")); } else if (m_eOutputMode == DOCBOOK_OUTPUT) { setWindowTitle(tr("Select component for DocBook generation")); } else if (m_eOutputMode == DOJO_OUTPUT) { setWindowTitle(tr("Select component for Dojo generation")); } connect(saveButton, SIGNAL(pressed()), this, SLOT(saveOutput())); connect(cancelButton, SIGNAL(pressed()), this, SLOT(reject())); }
KonsolePreviewer::KonsolePreviewer(const QString & title, QWidget *parent, const QString& projectType, const QString& packagePath) : QDockWidget(title, parent), m_textEdit(0), m_projectType(projectType), m_packagePath(packagePath) { QVBoxLayout *layout = new QVBoxLayout(); KToolBar *toolBar = new KToolBar(this, true, true); KAction *clear = KStandardAction::clear(this, SLOT(clearOutput()), this); KAction *save = KStandardAction::save(this, SLOT(saveOutput()), this); //we want those only for the kwin scripts if (m_projectType == "KWin/Script") { KAction *execute = new KAction(this); execute->setText("Execute"); execute->setIcon(KIcon("system-run")); connect(execute, SIGNAL(triggered(bool)), this, SLOT(executeKWinScript())); //add it to toolbar toolBar->addAction(execute); }
int main(int argc, char *argv[]) { FILE *fp = NULL; char buffer[80], tok1[SIZE], tok2[SIZE], tok3[SIZE], tok4[SIZE], tok5[SIZE] = ""; int num, i, cnt = 0, s, templc, changeflag = 0, startflag=0, endflag=0; char c; char icls[5]; int opcode, length = 0; fp=fopen(argv[1], "r"); do { c = fgetc(fp); if(c=='\n') cnt++; }while(c!=EOF); fp=fopen(argv[1], "r"); do { strcpy(tok1, ""); strcpy(tok2, ""); strcpy(tok3, ""); strcpy(tok4, ""); strcpy(tok5, ""); fgets(buffer, 80, fp); changeflag = 0; num = sscanf(buffer, "%s%s%s%s%s%s", tok1, tok2, tok3, tok4, tok5, temp); if(tok2[strlen(tok2)-1]==',') tok2[strlen(tok2)-1]='\0'; if(tok3[strlen(tok3)-1]==',') tok3[strlen(tok3)-1]='\0'; sprintf(temp, "%d:\t\t", lc); strcat(opfile, temp); switch(num) { default: errorflag++; sprintf(temp, "Line %d:\tInvalid number of mnemonics found.\n", ln+1); strcat(errorLog, temp); break; case 1: fetchFromMot(tok1, icls, &opcode, &length); if(strcmp(tok1, "START")==0) { lc = 0; changeflag++; startflag++; } if(opcode==-1) { errorflag++; sprintf(temp, "Line %d:\tUndefined mnemonic '%s'.\n", ln+1, tok1); strcat(errorLog, temp); } generateIntermediate(temp, icls, opcode); strcat(opfile, temp); if(strcmp(tok1, "LTORG")==0 || strcmp(tok1, "END")==0) { for(i=0;i<litPtr;i++) { if(littable[i].address==-1) { strcat(opfile, "\n"); sprintf(temp, "%d:\t\t", lc); strcat(opfile, temp); addToLiteralTable(littable[i].lname, &opcode, 1); generateIntermediate(temp, "LIT", opcode); strcat(opfile, temp); lc++; } } changeflag++; if(strcmp(tok1, "END")==0) endflag++; addToPoolTable(); } length=0; break; case 2: fetchFromMot(tok1, icls, &opcode, &length); if(strcmp(tok1, "START")==0) { lc = atoi(tok2); changeflag++; startflag++; generateIntermediate(temp, icls, opcode); strcat(opfile, temp); sprintf(temp, ", "); strcat(opfile, temp); generateIntermediate(temp, "CONST", atoi(tok2)); strcat(opfile, temp); } else if(strcmp(tok1, "ORIGIN")==0) { for(i=0;i<symPtr;i++) { if(strcmp(symtable[i].sname, tok2)==0) { lc = symtable[i].address; break; } } changeflag++; generateIntermediate(temp, icls, opcode); strcat(opfile, temp); sprintf(temp, ", "); strcat(opfile, temp); generateIntermediate(temp, "SYM", i+1); strcat(opfile, temp); } length=0; break; case 4: if(strcmp(tok1, "ORIGIN")==0) { for(i=0;i<symPtr;i++) { if(strcmp(symtable[i].sname, tok2)==0) { if(strcmp(tok3, "+")==0) s = 1; else if(strcmp(tok3, "+")==0) s = -1; lc = symtable[i].address + (s * atoi(tok4)); break; } } fetchFromMot(tok1, icls, &opcode, &length); generateIntermediate(temp, icls, opcode); strcat(opfile, temp); strcat(opfile, ", "); generateIntermediate(temp, "SYM", i+1); strcat(opfile, temp); sprintf(temp, " %s (CONST, %s)", tok3, tok4); strcat(opfile, temp); length=0; changeflag++; break; } addToSymbolTable(tok1, &opcode, 1); strcpy(tok1, tok2); strcpy(tok2, tok3); strcpy(tok3, tok4); case 3: fetchFromMot(tok1, icls, &opcode, &length); if(strcmp(icls,"IS")==0) { generateIntermediate(temp, icls, opcode); strcat(opfile, temp); strcat(opfile, ", "); if(strcmp(tok1, "BC")!=0) fetchFromReg(tok2, &opcode); else if(strcmp(tok1, "BC")==0) fetchCondition(tok2, &opcode); sprintf(temp, "0%d", opcode); strcat(opfile, temp); strcat(opfile, ", "); if(tok3[0] == '=') { addToLiteralTable(tok3, &opcode, 0); generateIntermediate(temp, "LIT", opcode); strcat(opfile, temp); } else { addToSymbolTable(tok3, &opcode, 0); generateIntermediate(temp, "SYM", opcode); strcat(opfile, temp); } changeflag++; } fetchFromMot(tok2, icls, &opcode, &length); if(strcmp(tok2, "DS")==0) { generateIntermediate(temp, icls, opcode); strcat(opfile, temp); strcat(opfile, ", "); addToSymbolTable(tok1, &opcode, 1); length = atoi(tok3); generateIntermediate(temp, "SYM", opcode); strcat(opfile, temp); changeflag++; } else if(strcmp(tok2, "DC")==0) { generateIntermediate(temp, icls, opcode); strcat(opfile, temp); strcat(opfile, ", "); addToSymbolTable(tok1, &opcode, 1); length = 1; generateIntermediate(temp, "SYM", opcode); strcat(opfile, temp); changeflag++; } else if(strcmp(tok2, "EQU")==0) { for(i=0;i<symPtr;i++) { if(strcmp(symtable[i].sname, tok3)==0) { templc = lc; lc = symtable[i].address; addToSymbolTable(tok1, &opcode, 1); lc = templc; } break; } fetchFromMot(tok2, icls, &opcode, &length); generateIntermediate(temp, icls, opcode); strcat(opfile, temp); strcat(opfile, ", "); generateIntermediate(temp, "SYM", i+1); strcat(opfile, temp); length=0; changeflag++; } break; case 5: if(strcmp(tok2, "EQU")==0) { for(i=0;i<symPtr;i++) { if(strcmp(symtable[i].sname, tok3)==0) { templc = lc; if(strcmp(tok4, "+")==0) s = 1; else if(strcmp(tok4, "-")==0) s = -1; lc = symtable[i].address + (s * atoi(tok5)); addToSymbolTable(tok1, &opcode, 1); lc = templc; break; } } if(i==symPtr || symtable[i].address == -1) { errorflag++; sprintf(temp, "Line %d:\tEQU needs to be backward reference.\n", ln+1); strcat(errorLog, temp); } fetchFromMot(tok2, icls, &opcode, &length); generateIntermediate(temp, icls, opcode); strcat(opfile, temp); strcat(opfile, ", "); generateIntermediate(temp, "SYM", i+1); strcat(opfile, temp); sprintf(temp, " %s (CONST, %s)", tok4, tok5); strcat(opfile, temp); changeflag++; length=0; } break; } if(changeflag==0) { errorflag++; sprintf(temp, "Line %d:\tCould not parse statement\n", ln+1); strcat(errorLog, temp); } strcat(opfile, "\n"); lc = lc + length; ln++; }while(cnt!=ln); for(i=0;i<symPtr;i++) { if(symtable[i].address==-1) { errorflag++; sprintf(temp, "%s:\tUndefined symbol '%s'\n", argv[1], symtable[i].sname); strcat(errorLog, temp); } } if(!(startflag==1 && endflag==1)) { errorflag++; sprintf(temp, "%s:\tThere should be exactly one START and one END symbol\n", argv[1]); strcat(errorLog, temp); } if(errorflag==0) { printf("%s", opfile); saveOutput(argv[1]); } else { printf("%d error(s) found\n", errorflag); printf("%s", errorLog); } fclose(fp); return 0; }
/// @todo change it!!! void JPetOutputHandler::saveAndCloseOutput(JPetParamManager& manager, JPetTreeHeader* fHeader, JPetStatistics* fStatistics, std::map<std::string, std::unique_ptr<JPetStatistics>>& fSubTasksStatistics) { saveOutput(manager, fHeader, fStatistics, fSubTasksStatistics); fWriter.closeFile(); }