void Environment::addDefaultFunctions() {
  // void printInt(int);
  FunType::PtrType printInt(new FunType("printInt"));
  printInt->args.push_back(AbsPtrType(new IntType()));
  printInt->ret_type = AbsPtrType(new VoidType());
  insertFunction(printInt);

  // void printString(string);
  FunType::PtrType printString(new FunType("printString"));
  printString->args.push_back(AbsPtrType(new StringType()));
  printString->ret_type = AbsPtrType(new VoidType());
  insertFunction(printString);

  // void error();
  FunType::PtrType error(new FunType("error"));
  error->ret_type = AbsPtrType(new VoidType());
  insertFunction(error);

  // int readInt();
  FunType::PtrType readInt(new FunType("readInt"));
  readInt->ret_type = AbsPtrType(new IntType());
  insertFunction(readInt);

  // string readString();
  FunType::PtrType readString(new FunType("readString"));
  readString->ret_type = AbsPtrType(new StringType());
  insertFunction(readString);
};
/// Constructor
UserFitFunctionDialog::UserFitFunctionDialog(QWidget *parent)
    : QDialog(parent) {
  ui.setupUi(this);

  ui.btnAdd->setEnabled(false);

  connect(ui.btnAdd, SIGNAL(clicked()), this, SLOT(addFunction()));
  connect(ui.btnMultiply, SIGNAL(clicked()), this, SLOT(multiplyFunction()));
  connect(ui.btnInsert, SIGNAL(clicked()), this, SLOT(insertFunction()));
  connect(ui.treeFunctions, SIGNAL(itemSelectionChanged()), this,
          SLOT(functionSelectionChanged()));
}
Exemple #3
0
void XYFitCurveDock::showFunctions() {
	QMenu menu;
	FunctionsWidget functions(&menu);
	connect(&functions, SIGNAL(functionSelected(QString)), this, SLOT(insertFunction(QString)));
	connect(&functions, SIGNAL(functionSelected(QString)), &menu, SLOT(close()));

	QWidgetAction* widgetAction = new QWidgetAction(this);
	widgetAction->setDefaultWidget(&functions);
	menu.addAction(widgetAction);

	QPoint pos(-menu.sizeHint().width()+uiGeneralTab.tbFunctions->width(),-menu.sizeHint().height());
	menu.exec(uiGeneralTab.tbFunctions->mapToGlobal(pos));
}
Exemple #4
0
void LambdaLifting::runOnFunction(Function *F) {
  auto M = F->parent();
  for (auto BB : *F) {
    for (auto V : *BB) {
      if (auto B = dyn_cast<MallocInst>(V)) {
        if (auto Fn = dyn_cast<Function>(B->val())) {
          Fn->setName("lambda");
          auto It = std::find(M->begin(), M->end(), F);
          assert(It != M->end() && "Function parent not set");
          M->insertFunction(It, Fn);
          auto K = F->context();
          auto Sym = UnresolvedValue::get(Fn->getName(), UnType::get(K));
          B->setVal(Sym);
        }
      }
    }
  }
}
MatrixValuesDialog::MatrixValuesDialog( ScriptingEnv *env, QWidget* parent, Qt::WFlags fl )
: QDialog( parent, fl ), scripted(env)
{
    setName( "MatrixValuesDialog" );
	setWindowTitle( tr( "QtiPlot - Set Matrix Values" ) );
	setSizeGripEnabled(true);
    setAttribute(Qt::WA_DeleteOnClose);

	QGridLayout *gl1 = new QGridLayout();
    gl1->addWidget(new QLabel(tr("For row (i)")), 0, 0);
	startRow = new QSpinBox();
	startRow->setRange(1, INT_MAX);
    gl1->addWidget(startRow, 0, 1);
	gl1->addWidget(new QLabel(tr("to")), 0, 2);
	endRow =  new QSpinBox();
	endRow->setRange(1, INT_MAX);
	gl1->addWidget(endRow, 0, 3);
	gl1->addWidget(new QLabel(tr("For col (j)")), 1, 0);
	startCol = new QSpinBox();
	startCol->setRange(1, INT_MAX);
	gl1->addWidget(startCol, 1, 1);
	gl1->addWidget(new QLabel(tr("to")), 1, 2);
	endCol = new QSpinBox();
	endCol->setRange(1, INT_MAX);
	gl1->addWidget(endCol, 1, 3);

	functions = new QComboBox(false);
	btnAddFunction = new QPushButton(tr( "Add &Function" ));
	btnAddCell = new QPushButton(tr( "Add Ce&ll" ));

	QHBoxLayout *hbox1 = new QHBoxLayout();
	hbox1->addWidget(functions);
	hbox1->addWidget(btnAddFunction);
	hbox1->addWidget(btnAddCell);

	QVBoxLayout *vbox1 = new QVBoxLayout();
    vbox1->addLayout(gl1);
	vbox1->addLayout(hbox1);
	QGroupBox *gb = new QGroupBox();
    gb->setLayout(vbox1);
    gb->setSizePolicy(QSizePolicy (QSizePolicy::Preferred, QSizePolicy::Preferred));

	explain = new QTextEdit();
	explain->setReadOnly(true);
	explain->setSizePolicy(QSizePolicy (QSizePolicy::Preferred, QSizePolicy::Preferred));
    QPalette palette = explain->palette();
    palette.setColor(QPalette::Active, QPalette::Base, Qt::lightGray);
    explain->setPalette(palette);

	QHBoxLayout *hbox2 = new QHBoxLayout();
	hbox2->addWidget(explain);
	hbox2->addWidget(gb);

	QHBoxLayout *hbox3 = new QHBoxLayout();

	commands = new ScriptEdit( scriptEnv);
	commands->setTabStopWidth(((ApplicationWindow *)parent)->d_notes_tab_length);
    commands->setFont(((ApplicationWindow *)parent)->d_notes_font);
	commands->setFocus();
	hbox3->addWidget(commands);

	QVBoxLayout *vbox2 = new QVBoxLayout();
	btnApply = new QPushButton(tr( "&Apply" ));
    vbox2->addWidget(btnApply);
	btnCancel = new QPushButton(tr( "&Close" ));
    vbox2->addWidget(btnCancel);
    vbox2->addStretch();

	hbox3->addLayout(vbox2);

	QVBoxLayout* vbox3 = new QVBoxLayout(this);
	vbox3->addLayout(hbox2);
#ifdef SCRIPTING_PYTHON
	boxMuParser = NULL;
	if (scriptEnv->name() != QString("muParser")){
		boxMuParser = new QCheckBox(tr("Use built-in muParser (much faster)"));
		boxMuParser->setChecked(true);
		vbox3->addWidget(boxMuParser);
	}
#endif
	vbox3->addWidget(new QLabel(tr( "Cell(i,j)=" )));
	vbox3->addLayout(hbox3);

	functions->insertStringList(scriptEnv->mathFunctions(), -1);
	insertExplain(0);

	connect(btnAddCell, SIGNAL(clicked()), this, SLOT(addCell()));
	connect(btnAddFunction, SIGNAL(clicked()), this, SLOT(insertFunction()));
	connect(btnApply, SIGNAL(clicked()), this, SLOT(apply()));
	connect(btnCancel, SIGNAL(clicked()), this, SLOT(close()));
	connect(functions, SIGNAL(activated(int)), this, SLOT(insertExplain(int)));
}
Exemple #6
0
void FunctionLookup::insertUpdateFunctions(XPath2MemoryManager *memMgr)
{
  // Update functions
  //   fn:put
  insertFunction(new (memMgr) FuncFactoryTemplate<FunctionPut>(memMgr));
}
setColValuesDialog::setColValuesDialog( ScriptingEnv *env, QWidget* parent,  const char* name, bool modal, WFlags fl )
    : QDialog( parent, name, modal, fl )
{
  scriptEnv = env;
    if ( !name )
	setName( "setColValuesDialog" );
    setCaption( tr( "QtiPlot - Set column values" ) );
    setFocusPolicy( QDialog::StrongFocus );
	
	QHBox *hbox1=new QHBox (this, "hbox1"); 
	hbox1->setSpacing (5);
	
	QVBox *box1=new QVBox (hbox1, "box2"); 
	box1->setSpacing (5);

	explain = new QTextEdit(box1, "explain" );
	explain->setReadOnly (true);
	explain->setPaletteBackgroundColor(QColor(197, 197, 197));
	
	colNameLabel = new QLabel(box1, "colNameLabel" );

	QVBox *box2=new QVBox (hbox1, "box2"); 
	box2->setMargin(5);
	box2->setFrameStyle (QFrame::Box);

	QHBox *hbox2=new QHBox (box2, "hbox2"); 
	hbox2->setMargin(5);
	hbox2->setSpacing (5);
	
	QLabel *TextLabel1 = new QLabel(hbox2, "TextLabel1" );
    TextLabel1->setText( tr( "For row (i)" ) );
	
	start = new QSpinBox(hbox2, "start" );
   
    QLabel *TextLabel2 = new QLabel(hbox2, "TextLabel2" );
    TextLabel2->setText( tr( "to" ) );

    end = new QSpinBox(hbox2, "end" );

    start->setMinValue(1);
    end->setMinValue(1);
    if (sizeof(int)==2)
	 { // 16 bit signed integer
	 start->setMaxValue(0x7fff);
	 end->setMaxValue(0x7fff);
	 }
    else
	 { // 32 bit signed integer
	 start->setMaxValue(0x7fffffff);
	 end->setMaxValue(0x7fffffff);
	 }
  
	QButtonGroup *GroupBox0 = new QButtonGroup(2,QGroupBox::Horizontal,tr( "" ),box2, "GroupBox0" );
	GroupBox0->setLineWidth(0);
	GroupBox0->setFlat(true);

    functions = new QComboBox( FALSE, GroupBox0, "functions" );
	
	PushButton3 = new QPushButton(GroupBox0, "PushButton3" );
    PushButton3->setText( tr( "Add function" ) );
    
    boxColumn = new QComboBox( FALSE, GroupBox0, "boxColumn" );
   
    PushButton4 = new QPushButton(GroupBox0, "PushButton4" );
    PushButton4->setText( tr( "Add column" ) );

	QHBox *hbox6=new QHBox (GroupBox0, "hbox6"); 
	hbox6->setSpacing (5);

	buttonPrev = new QPushButton( hbox6, "buttonPrev" );
	buttonPrev->setText("&<<");

	buttonNext = new QPushButton( hbox6, "buttonNext" );
	buttonNext->setText("&>>");

	addCellButton = new QPushButton(GroupBox0, "addCellButton" );
    addCellButton->setText( tr( "Add cell" ) );

	QHBox *hbox3=new QHBox (this, "hbox3"); 
	hbox3->setSpacing (5);
	
	commandes = new ScriptEdit( env, hbox3, "commandes" );
    commandes->setGeometry( QRect(10, 100, 260, 70) );
	commandes->setFocus();
	
	QVBox *box3=new QVBox (hbox3,"box3"); 
	box3->setSpacing (5);
	
    btnOk = new QPushButton(box3, "btnOk" );
    btnOk->setText( tr( "OK" ) );

	btnApply = new QPushButton(box3, "btnApply" );
    btnApply->setText( tr( "Apply" ) );

    btnCancel = new QPushButton( box3, "btnCancel" );
    btnCancel->setText( tr( "Cancel" ) );
	
	QVBoxLayout* layout = new QVBoxLayout(this,5,5, "hlayout3");
    layout->addWidget(hbox1);
	layout->addWidget(hbox3);

setFunctions();
insertExplain(0);

connect(PushButton3, SIGNAL(clicked()),this, SLOT(insertFunction()));
connect(PushButton4, SIGNAL(clicked()),this, SLOT(insertCol()));
connect(addCellButton, SIGNAL(clicked()),this, SLOT(insertCell()));
connect(btnOk, SIGNAL(clicked()),this, SLOT(accept()));
connect(btnApply, SIGNAL(clicked()),this, SLOT(apply()));
connect(btnCancel, SIGNAL(clicked()),this, SLOT(close()));
connect(functions, SIGNAL(activated(int)),this, SLOT(insertExplain(int)));
connect(buttonPrev, SIGNAL(clicked()), this, SLOT(prevColumn()));
connect(buttonNext, SIGNAL(clicked()), this, SLOT(nextColumn()));
}
FunctionCallGraph::Graph::EdgeIterator
FunctionCallGraph::insertCall(const Function::Ptr &source, const Function::Ptr &target, EdgeType type, size_t edgeCount) {
    return insertCall(insertFunction(source), insertFunction(target), type, edgeCount);
}
SetColValuesDialog::SetColValuesDialog( ScriptingEnv *env, QWidget* parent, Qt::WFlags fl )
    : QDialog( parent, fl ), scripted(env)
{
    setName( "SetColValuesDialog" );
	setWindowTitle( tr( "QtiPlot - Set column values" ) );
	setSizeGripEnabled(true);

	QHBoxLayout *hbox1 = new QHBoxLayout();
	hbox1->addWidget(new QLabel(tr("For row (i)")));
	start = new QSpinBox();
	start->setMinValue(1);
	hbox1->addWidget(start);

	hbox1->addWidget(new QLabel(tr("to")));

	end = new QSpinBox();
	end->setMinValue(1);
	hbox1->addWidget(end);

	if (sizeof(int)==2)
	{ // 16 bit signed integer
		start->setMaxValue(0x7fff);
		end->setMaxValue(0x7fff);
	}
	else
	{ // 32 bit signed integer
		start->setMaxValue(0x7fffffff);
		end->setMaxValue(0x7fffffff);
	}

	QGridLayout *gl1 = new QGridLayout();
	functions = new QComboBox(false);
	gl1->addWidget(functions, 0, 0);
	btnAddFunction = new QPushButton(tr( "Add function" ));
	gl1->addWidget(btnAddFunction, 0, 1);
	boxColumn = new QComboBox(false);
	gl1->addWidget(boxColumn, 1, 0);
	btnAddCol = new QPushButton(tr( "Add column" ));
	gl1->addWidget(btnAddCol, 1, 1);

	QHBoxLayout *hbox3 = new QHBoxLayout();
	hbox3->addStretch();
	buttonPrev = new QPushButton("&<<");
	hbox3->addWidget(buttonPrev);
	buttonNext = new QPushButton("&>>");
	hbox3->addWidget(buttonNext);
	gl1->addLayout(hbox3, 2, 0);
	addCellButton = new QPushButton(tr( "Add cell" ));
	gl1->addWidget(addCellButton, 2, 1);

	QGroupBox *gb = new QGroupBox();
	QVBoxLayout *vbox1 = new QVBoxLayout();
	vbox1->addLayout(hbox1);
	vbox1->addLayout(gl1);
	gb->setLayout(vbox1);
	gb->setSizePolicy(QSizePolicy (QSizePolicy::Preferred, QSizePolicy::Preferred));

	explain = new QTextEdit();
	explain->setReadOnly (true);
	explain->setSizePolicy(QSizePolicy (QSizePolicy::Preferred, QSizePolicy::Preferred));
	QPalette palette = explain->palette();
	palette.setColor(QPalette::Active, QPalette::Base, Qt::lightGray);
	explain->setPalette(palette);

	QHBoxLayout *hbox2 = new QHBoxLayout();
	hbox2->addWidget(explain);
	hbox2->addWidget(gb);

	commands = new ScriptEdit( scriptEnv);

	QVBoxLayout *vbox2 = new QVBoxLayout();
	btnApply = new QPushButton(tr( "&Apply" ));
	vbox2->addWidget(btnApply);
	btnCancel = new QPushButton(tr( "&Close" ));
	vbox2->addWidget(btnCancel);
	vbox2->addStretch();

	QHBoxLayout *hbox4 = new QHBoxLayout();
	hbox4->addWidget(commands);
	hbox4->addLayout(vbox2);

	QVBoxLayout* vbox3 = new QVBoxLayout();
	vbox3->addLayout(hbox2);
#ifdef SCRIPTING_PYTHON
	boxMuParser = NULL;
	if (env->name() != QString("muParser")){
		boxMuParser = new QCheckBox(tr("Use built-in muParser (much faster)"));
		boxMuParser->setChecked(true);
		vbox3->addWidget(boxMuParser);
	}
#endif

	colNameLabel = new QLabel();
	vbox3->addWidget(colNameLabel);
	vbox3->addLayout(hbox4);

	setLayout(vbox3);
	setFocusProxy (commands);
	commands->setFocus();

	functions->insertStringList(scriptEnv->mathFunctions(), -1);
	if (functions->count() > 0)
		insertExplain(0);

	connect(btnAddFunction, SIGNAL(clicked()),this, SLOT(insertFunction()));
	connect(btnAddCol, SIGNAL(clicked()),this, SLOT(insertCol()));
	connect(addCellButton, SIGNAL(clicked()),this, SLOT(insertCell()));
	connect(btnApply, SIGNAL(clicked()),this, SLOT(apply()));
	connect(btnCancel, SIGNAL(clicked()),this, SLOT(close()));
	connect(functions, SIGNAL(activated(int)),this, SLOT(insertExplain(int)));
	connect(buttonPrev, SIGNAL(clicked()), this, SLOT(prevColumn()));
	connect(buttonNext, SIGNAL(clicked()), this, SLOT(nextColumn()));
}
void FunctionListModel::setupModelData()
{
 beginResetModel();
  if (rootItem)
    delete rootItem;

  QVector<QVariant> rootData(FUNCTION_LIST_MAX_COLUMN);
  rootData[FUNCTION_LIST_COLUMN_NAME]=tr("Method") ;
  rootData[FUNCTION_LIST_COLUMN_DESCRIPTION]=tr("Prototype") ;
  rootData[FUNCTION_LIST_COLUMN_STATISTIC]=tr("Coverage") ;
  rootData[FUNCTION_LIST_COLUMN_FILE_NAME]=tr("File") ;
  rootData[FUNCTION_LIST_COLUMN_ABSOLUTE_FILE_NAME]=tr("Absolute Path") ;
  rootData[FUNCTION_LIST_COLUMN_POSITION]=tr("Position");
  rootData[FUNCTION_LIST_COLUMN_FILE_NAME_REF]=tr("File (Reference)") ;
  rootData[FUNCTION_LIST_COLUMN_ABSOLUTE_FILE_NAME_REF]=tr("Absolute Path (Reference)") ;
  rootData[FUNCTION_LIST_COLUMN_POSITION_REF]=tr("Position (Reference)");
  rootData[FUNCTION_LIST_COLUMN_DIFFERENCE]=tr("Modifications");
  rootItem = new TreeList(rootData);

  if (csmes_p)
  {
    const SourceFiles sources_all= csmes_p->Sources(CSMes::NON_EMPTY) + csmes_p->SourcesReference(CSMes::NON_EMPTY) ;
    SourceFiles sources;

    for (SourceFiles::const_iterator itsrc=sources_all.begin();itsrc!=sources_all.end();++itsrc)
    {
      if (sources.contains(*itsrc))
        continue;

      sources.append(*itsrc);
      QVector<FunctionInfo> FunctionsInfo = csmes_p->FunctionInfoSource(QString(),*itsrc);
      QVector<FunctionInfo>::const_iterator itfct;
      for (itfct=FunctionsInfo.begin();itfct!=FunctionsInfo.end();++itfct)
      {
        insertFunction(
            (*itfct).getScopedName(),
            (*itfct).getPrototype(),
            *itsrc,
            (*itfct).startLineOrg() ,
            (*itfct).endLineOrg() ,
            (*itfct).startLinePre() ,
            (*itfct).startColumnPre() ,
            (*itfct).endLinePre() ,
            (*itfct).endColumnPre(),
            false
            );
      }

      QVector<FunctionInfo> FunctionsInfoReference = csmes_p->FunctionInfoSourceReference(QString(),*itsrc);
      for (itfct=FunctionsInfoReference.begin();itfct!=FunctionsInfoReference.end();++itfct)
      {
        insertFunction(
            (*itfct).getScopedName(),
            (*itfct).getPrototype(),
            *itsrc,
            (*itfct).startLineOrg() ,
            (*itfct).endLineOrg() ,
            (*itfct).startLinePre() ,
            (*itfct).startColumnPre() ,
            (*itfct).endLinePre() ,
            (*itfct).endColumnPre(),
            true
            );
      }
    }

  }
  rootItem->squeeze();
  endResetModel();
}
int main (void)
{
  printf
  ("cdemoin1 - Demonstrating select, insert and update on a subtype table\n");
  /* Initializing the environment in the Object mode*/

  OCIEnvCreate((OCIEnv **) &envhp, OCI_OBJECT, (dvoid *)0,
    (dvoid * (*)(dvoid *, size_t)) 0, (dvoid * (*)(dvoid *, dvoid *, size_t))0,
    (void (*)(dvoid *, dvoid *)) 0, (size_t) 0, (dvoid **) 0 );

  OCIHandleAlloc (envhp, (dvoid **)&errhp, OCI_HTYPE_ERROR, (size_t)0, 
    (dvoid **)0);

  OCIHandleAlloc(envhp, (dvoid **)&svrhp, OCI_HTYPE_SERVER, (size_t)0,
    (dvoid **)0);

  status = OCIServerAttach(svrhp, errhp, (text *)database,
    (sb4)strlen((char *)database), OCI_DEFAULT);

  if (status != OCI_SUCCESS)
  {
    printf("OCIServerAttach failed \n");
  }
  else
    printf("OCIServerAttach - Success \n");

  OCIHandleAlloc(envhp, (dvoid **)&svchp, OCI_HTYPE_SVCCTX, (size_t)0, 
    (dvoid **)0);
  OCIAttrSet(svchp, OCI_HTYPE_SVCCTX, (dvoid *)svrhp, (ub4)0, OCI_ATTR_SERVER, 
    errhp);

  OCIHandleAlloc(envhp, (dvoid **)&sesnhp, OCI_HTYPE_SESSION, (size_t)0, 
    (dvoid **)0);

  OCIAttrSet(sesnhp, OCI_HTYPE_SESSION, (dvoid *)username, 
    (ub4)strlen((char *)username), OCI_ATTR_USERNAME, errhp);

  OCIAttrSet(sesnhp, OCI_HTYPE_SESSION, (dvoid*)password,
    (ub4)strlen((char *)password), OCI_ATTR_PASSWORD, errhp);

  printf("Connecting as %s/%s@%s\n",username,password,database);

  status = OCISessionBegin(svchp, errhp, sesnhp, OCI_CRED_RDBMS, OCI_DEFAULT);
  if (status != OCI_SUCCESS)
  {
    printf("Connection  failed \n");
  }
  else
    printf("Connection - Success \n");

  OCIAttrSet(svchp, OCI_HTYPE_SVCCTX, sesnhp, (ub4)0, OCI_ATTR_SESSION, errhp);

  /* Calling function to get an array of REFs to populate the varray */
  getRef(); 

  /* Function to insert an instance of the subtype into a supertype table */
  insertFunction();
 
  /* Function to modify the data of an inherited object */
  modifyFunction();  

  /* Function to display data from the table */
  selectFunction();  

  /* Free the allocated handles */
  cleanup();

  printf("cdemoin1 - Done\n");
  return 1;
} /* End of main() */