/**
     * Function WriteRescueLibrary
     * Writes out the rescue library. Called after successful PerformAction()s. If this fails,
     * undo the actions.
     * @return True on success.
     */
    static bool WriteRescueLibrary( SCH_EDIT_FRAME *aEditFrame, PROJECT* aProject )
    {

        if( !save_library( m_library_fn.GetFullPath(), m_rescue_lib.get(), aEditFrame ) )
            return false;
        return insert_library( aProject, m_rescue_lib.get(), 0 );
    }
Beispiel #2
0
int main()
{
	FILE* strin		= fopen("input.txt", "r");
	FILE* strout	= stdout;
		  strlog	= fopen("compiler_log.txt", "w");
		  strerr	= strout;
	FILE* strcode	= fopen("code.txt", "w");
	FILE* start_lib = fopen("START_LIB.txt", "r");

	save_library(strcode, start_lib);
	
	token** token_stream = (token**) calloc(1, sizeof(token*));
	
	
	VERIFY(token_stream == NULL,	-1,			"MAIN(): Calloc fail, token_stream hasn't been initialized");
	int stream_size = 0;
	int ret = tokenize_stream(strin, token_stream, &stream_size);
	tree_head* syntax_tree = NULL;
	VERIFY_RET("MAIN(): Tokenize fail");


	fprintf(strlog, "Size = %d\n", stream_size);
	
	ret = get_pgm(*token_stream, &syntax_tree);

	VERIFY_RET("MAIN(): Tree build fail");
	//tree_dump(strout, syntax_tree);


	ret = tree_optimize(strout, syntax_tree);
	VERIFY_RET("MAIN(): Optimization fail");

	ret = build_pgm(syntax_tree -> root, strcode);
	VERIFY_RET("MAIN(): Build fail");

	printf(">>>[%08x]\n", *token_stream);
	printf("%c\n", *(int*)((*token_stream + 1) -> value));
	
	free(*token_stream);
	free(token_stream);
	head_destr(syntax_tree, TREE_DESTR_ALL);

	fclose(strin);
	fclose(strout);
	fclose(strerr);
	fclose(strlog);

	//system("CPUV4.exe \"code.txt\"");

	return 0;

}
Beispiel #3
-1
Collection::Collection() :
  _current_library(0),
  _stdout(stdout)
{

  actionGroup = new QActionGroup(this);

  statusBar();

  QWidget::setWindowTitle( "Qt Papers" );

  QMenu* fileMenu = new QMenu("&File", this);    

  libraryOpen = addChoice("libraryOpen", "Open Library");
  libraryOpen->setStatusTip("Open a library");
  libraryOpen->setEnabled(true);
  libraryOpen->setIcon(QIcon(":/images/libopen.png"));
  connect(libraryOpen, SIGNAL(triggered()), this, SLOT(open_library()));
  fileMenu->addAction(libraryOpen);

  libraryNew = addChoice("libraryNew", "New Library");
  libraryNew->setStatusTip("Create a new library");
  libraryNew->setEnabled(true);
  libraryNew->setIcon(QIcon(":/images/document2.png"));
  connect(libraryNew, SIGNAL(triggered()), this, SLOT(new_library()));
  fileMenu->addAction(libraryNew);


  librarySave = addChoice("librarySave", "Save Library");
  librarySave->setStatusTip("Save the library");
  librarySave->setEnabled(true);
  librarySave->setIcon(QIcon(":/images/save.png"));
  connect(librarySave, SIGNAL(triggered()), this, SLOT(save_library()));
  fileMenu->addAction(librarySave);

  libraryDelete = addChoice("libraryDelete", "Delete Library");
  libraryDelete->setStatusTip("Delete library");
  libraryDelete->setEnabled(true);
  libraryDelete->setIcon(QIcon(":/images/libremove.png"));
  connect(libraryDelete, SIGNAL(triggered()), this, SLOT(delete_library()));
  fileMenu->addAction(libraryDelete);

  libraryImport = addChoice("libraryImport", "Import Library");
  libraryImport->setStatusTip("Import library");
  libraryImport->setEnabled(true);
  libraryImport->setIcon(QIcon(":/images/import.png"));
  connect(libraryImport, SIGNAL(triggered()), this, SLOT(scan_directory_and_import_papers()));

  fileMenu->addAction(libraryImport);

  preferences = addChoice("preferences", "Preferences");
  preferences->setStatusTip("Preferences");
  preferences->setEnabled(true);
  preferences->setIcon(QIcon(":/images/pref.png"));
  connect(preferences, SIGNAL(triggered()), this, SLOT(modify_preferences()));
  fileMenu->addAction(preferences);
  
  exit = addChoice("exit", "Exit");
  exit->setStatusTip("Exit");
  exit->setEnabled(true);
  exit->setIcon(QIcon(":/images/exit.png"));
  connect(exit, SIGNAL(triggered()), qApp, SLOT(closeAllWindows()));
  fileMenu->addAction(exit);

  QMenu* paperMenu = new QMenu("&Paper", this);    
  paperImport = addChoice("paperImport", "Import Paper");
  paperImport->setStatusTip("Import a paper");
  paperImport->setEnabled(false);
  paperImport->setIcon(QIcon(":/images/import.png"));

  paperScanDirectory = addChoice("paperScanDirectory", "Paper Scan");
  paperScanDirectory->setIcon(QIcon(":/images/scan.png"));
  paperScanDirectory->setStatusTip("Scan for papers.");
  paperScanDirectory->setEnabled(true);

  talkImport = addChoice("talkImport", "Import Talk");
  talkImport->setStatusTip("Import a talk");
  talkImport->setEnabled(false);

  paperNew = addChoice("paperNew", "New Paper");
  paperNew->setStatusTip("New paper");
  paperNew->setEnabled(true);
  paperNew->setIcon(QIcon(":/images/new.png"));

  paperDelete = addChoice("paperDelete", "Delete Paper");
  paperDelete->setStatusTip("Delete paper");
  paperDelete->setIcon(QIcon(":/images/remove.png"));
  paperDelete->setEnabled(false);

  paperEdit = addChoice("paperEdit", "Edit Paper");
  paperEdit->setStatusTip("Edit paper");
  paperEdit->setEnabled(false);
  paperEdit->setIcon(QIcon(":/images/edit.png"));

  paperOpen = addChoice("paperOpen", "Open Paper");
  paperOpen->setStatusTip("Open paper");
  paperOpen->setEnabled(false);
  paperOpen->setIcon(QIcon(":/images/open.png"));

  talkNew = addChoice("talkNew", "New Talk");
  talkNew->setStatusTip("New talk");
  talkNew->setEnabled(false);

  connect(paperNew, SIGNAL(triggered()), this, SLOT(new_paper()));
  connect(paperEdit, SIGNAL(triggered()), this, SLOT(edit_paper()));
  connect(paperDelete, SIGNAL(triggered()), this, SLOT(delete_paper()));
  connect(paperOpen, SIGNAL(triggered()), this, SLOT(open_paper()));
  connect(paperImport, SIGNAL(triggered()), this, SLOT(import_paper()));
  // need to implement this

  paperMenu->addAction(paperNew);
  paperMenu->addAction(paperImport);
  paperMenu->addAction(paperEdit);
  paperMenu->addAction(paperDelete);
  paperMenu->addAction(paperOpen);
  paperMenu->addAction(paperScanDirectory);
  paperMenu->addAction(talkNew);
  paperMenu->addAction(talkImport);




  QMenu* helpMenu = new QMenu("&Help", this);    
  showAbout = addChoice("showAbout","About");
  showAbout->setStatusTip("About");
  showAbout->setEnabled(true);
  showAbout->setIcon(QIcon(":/images/about.png"));
  connect(showAbout, SIGNAL(triggered()), this, SLOT(about()));
  helpMenu->addAction(showAbout);

  //Add a menu bar
  menuBar()->addMenu(fileMenu);
  menuBar()->addMenu(paperMenu);
  menuBar()->addMenu(helpMenu);

  //button to trigger find box
  paperFind = new QAction("Find Paper",this);
  paperFind->setStatusTip("Find paper");
  paperFind->setEnabled(true);
  paperFind->setIcon(QIcon(":/images/find.png"));
  connect(paperFind, SIGNAL(triggered()), this, SLOT(find_paper()));

  //add a tool bar
  QPushButton * find_clear = new QPushButton();
  find_clear->setStatusTip("Find paper");
  find_clear->setEnabled(true);
  find_clear->setIcon(QIcon(":/images/clear.png"));
  connect(find_clear, SIGNAL(clicked()), this, SLOT(reset_find()));

  QLabel * find = new QLabel();
  find->setText("Find: ");
  find->setLayoutDirection(Qt::LeftToRight);
  QLabel * in = new QLabel();
  in->setText(" in ");
  _find_edit = new QLineEdit;
  _find_edit->setFixedSize(_find_edit->sizeHint());
  _find_edit->setLayoutDirection(Qt::LeftToRight);
  connect(_find_edit, SIGNAL(returnPressed()), this, SLOT(find_paper()));

  _find_type = new QComboBox();
  QStringList find_names;
  find_names << "Author" << "Title" << "Abstract" << "Any";
  _find_type->insertItems(0,find_names);
  _find_type->setLayoutDirection(Qt::LeftToRight);
  find->setBuddy(_find_edit);
  paperToolBar = addToolBar(tr("Paper"));
  paperToolBar->setLayoutDirection(Qt::RightToLeft);
  paperToolBar->addAction(paperFind);
  paperToolBar->addWidget(_find_type);
  paperToolBar->addWidget(in);
  paperToolBar->addWidget(find_clear);
  paperToolBar->addWidget(_find_edit);
  paperToolBar->addWidget(find);
  paperToolBar->addAction(paperDelete);
  paperToolBar->addAction(paperEdit);
  paperToolBar->addAction(paperNew);
  paperToolBar->addAction(paperOpen);
  paperToolBar->addAction(paperImport);
  paperToolBar->addAction(paperScanDirectory);

  _rss_box = new RssWidget;
  connect(_rss_box, SIGNAL(urlChanged(const QUrl& )), 
	  this, SLOT(check_url(const QUrl& )));

  QAction * rssForward  = new QAction("rssForward",this);
  rssForward->setStatusTip("Forward");
  rssForward->setEnabled(true);
  rssForward->setIcon(QIcon(":/images/forward.png"));
  connect(rssForward, SIGNAL(triggered()), _rss_box, SLOT(forward()));
  paperToolBar->addAction(rssForward);

  QAction * rssBack  = new QAction("rssBack",this);
  rssBack->setStatusTip("Back");
  rssBack->setEnabled(true);
  rssBack->setIcon(QIcon(":/images/back.png"));
  connect(rssBack, SIGNAL(triggered()), _rss_box, SLOT(back()));
  paperToolBar->addAction(rssBack);

  //Set up a central widget that will have a layout in it

  _library_list = new LibraryList(this,this);
  QFont font;
  font.setBold(true);
  font.setCapitalization(QFont::SmallCaps);
  _library_list->setFont(font);
  connect(_library_list, SIGNAL(itemClicked( QListWidgetItem *)), this, SLOT(select_library(QListWidgetItem *)));
  
  
  _abstract_box = new QTextBrowser();
  _abstract_box->setAlignment(Qt::AlignJustify);
  _abstract_box->setFontWeight(QFont::DemiBold);
  _abstract_box->setPlainText("No Paper Selected");
  _paper_list = new PaperList(this,this);

  QStringList sl;
  // The following seems like a non-intuitive operator
  // overload but that is how they do it...
  sl << "Author" << "Title" << "Date";
  _paper_list->setColumnCount(3);
  _paper_list->setHorizontalHeaderLabels(sl);
  _paper_list->setAlternatingRowColors(true);
  _paper_list->horizontalHeader()->setStretchLastSection(true);
  _paper_list->verticalHeader()->hide();
  //  _paper_list->setSortingEnabled(true);
  //need to make the paper_list its own class for drag and drop
  //  _paper_list->setAcceptDrops(true);

  connect(_paper_list, SIGNAL(cellClicked(int , int )), 
	  this, SLOT(select_paper(int, int)));
  //  update_paper_list();
  

  _top_layout = new QSplitter();  
  _top_layout->addWidget(_library_list);
  _top_layout->addWidget(_paper_list);
  _top_layout->setStretchFactor(0,1);
  _top_layout->setStretchFactor(1,3);
  _top_layout->setContentsMargins(0,0,5,0);
  _top_layout->setOrientation(Qt::Horizontal);

  _bot_layout = new QSplitter();  
  _bot_layout->addWidget(_abstract_box);
  _bot_layout->addWidget(_rss_box);
  _bot_layout->setContentsMargins(0,0,0,0);
  _bot_layout->setStretchFactor(0,1);
  _bot_layout->setStretchFactor(1,3);
  _bot_layout->setOrientation(Qt::Horizontal);

  _total_layout = new QSplitter();
  _total_layout->addWidget(_top_layout);
  _total_layout->addWidget(_bot_layout);
  _total_layout->setStretchFactor(0,1);
  _total_layout->setStretchFactor(1,3);
  _total_layout->setOrientation(Qt::Vertical);

  //this splitter window is my central widget
  setCentralWidget(_total_layout);


  QPalette  palette;
  palette.setColor(QPalette::Background,Qt::white);
  centralWidget()->setPalette(palette);
  centralWidget()->setAutoFillBackground(true);
  centralWidget()->setWindowOpacity(0.8);
  centralWidget()->setMinimumSize(300, 200);
  setMinimumSize(700, 500);

  readSettings();
}