Exemple #1
0
        void addConflictingUpdates() {
            BSONObj first = BSON("_id" << "asdfasdfasdf");
            addOp("i", first);

            BSONObj filter = BSON("_id" << "asdfasdfasdf" << "sp" << BSON("$size" << 2));
            // Test an op with no version, op is ignored and replication continues (code assumes
            // version 1)
            addOp("u", BSON("$push" << BSON("sp" << 42)), &filter, NULL, 0);
            // The following line generates an fassert because it's version 2
            //addOp("u", BSON("$push" << BSON("sp" << 42)), &filter, NULL, 2);
        }
Exemple #2
0
void addGCompound(GObject compound, GObject gobj) {
   if (compound->type != GCOMPOUND) {
      error("add: First argument is not a GCompound");
   }
   addVector(compound->u.compoundRep.contents, gobj);
   addOp(compound, gobj);
}
Exemple #3
0
        void addUpdates() {
            BSONObj id = BSON("_id" << "123456something");
            addOp("i", id);

            addOp("u", BSON("$set" << BSON("requests.1000001_2" << BSON(
                    "id" << "1000001_2" <<
                    "timestamp" << 1334813340))), &id);

            addOp("u", BSON("$set" << BSON("requests.1000002_2" << BSON(
                    "id" << "1000002_2" <<
                    "timestamp" << 1334813368))), &id);

            addOp("u", BSON("$set" << BSON("requests.100002_1" << BSON(
                    "id" << "100002_1" <<
                    "timestamp" << 1334810820))), &id);
        }
//Produção Simple_Exp'
ExpressionNode* simpleExpressionLinha(ExpressionNode* addExpE){
    printf("Simple_Exp'\n");
     if (lookaheadPertenceFirst(Add_Op) == 1){
          int addOpVar = addOp();
          ExpressionNode* addExpD = simpleExpression();
          if(addExpD == NULL) return NULL; else
          return new AddOpNode(addOpVar,addExpE,addExpD );
     }else return addExpE;

}
Exemple #5
0
void Viewer::mousePressEvent(QMouseEvent* event) {

  lastMouseX = event->x();
  lastMouseY = event->y();

  if (currentMode == Mode::POSITION) {
    // We can do nothing, since we don't have to keep stack
    return;
  }

  auto buttonsDown = qApp->mouseButtons();
  auto clickedButton = event->button();
  bool holdingOther = (buttonsDown & ~clickedButton);

  if (clickedButton == Qt::LeftButton && holdingOther) {
    // Do not allow picking while holding other buttons
    return;
  }

  if (clickedButton == Qt::LeftButton) {
    // We can pick now: Only holding left button
    auto id = findPickId(event->x(), event->y());
    id = sceneRoot->getJointForId(id);

    if (id > 0 && pickedIds.find(id) == pickedIds.end()) {
      // Not in the set: Add to set
      pickedIds.insert(id);
    }
    else {
      pickedIds.erase(id);
    }
    update();
  }
  else if (pickedIds.size() > 0) {
    OpStackEntry stackEntry;
    for (auto& p : opMap) {
      auto id = p.first;
      // Store current state initially
      Op op;
      if (opMap.find(id) != opMap.end()) {
        op = opMap[id];
      }
      stackEntry.insert({id, op});
    }
    addOp(std::move(stackEntry));
  }
}
Exemple #6
0
  void expression () {
   
    std::cout << "\nIn expression\n";

    primary ();

    nextToken = getNextToken();

    if (nextToken == scanner::PlusOp || nextToken == scanner::MinusOp) {

        addOp ();
        expression ();

    }

    std::cout << "\nEnd expression\n";

  }
Exemple #7
0
bool Parser::ParseProgram(Program* prog) {
    if (!expectAndEat(spv::MagicNumber)) {
        return false;
    }

    prog->Version = getAndEat();
    std::cout << "Version: " << prog->Version << std::endl;

    prog->GeneratorMagic = getAndEat();
    std::cout << "Generator Magic: " << prog->GeneratorMagic << std::endl;

    prog->IDBound = getAndEat();
    std::cout << "ID Bound: " << prog->IDBound << std::endl;

    prog->InstructionSchema = getAndEat();
    std::cout << "Instruction Schema: " << prog->InstructionSchema << std::endl;
    std::cout << "=================================================" << std::endl;

    int instructionIndex = 0;

    prog->NextOp = readInstruction();

    do {
        SOp op = prog->NextOp;
        std::cout << std::setw(3) << instructionIndex << ": " << writeOp(op);
        instructionIndex++;
        if (!end()) {
            prog->NextOp = readInstruction();
        }
        else {
            prog->NextOp = SOp{ Op::OpNop, nullptr };
        }

        LUTHandlerMethods[op.Op]((void*)op.Memory, prog);

        if (prog->InFunction && prog->CurrentFunction->InBlock) {
            addOp(prog, op);
        }

    } while (prog->NextOp.Op != Op::OpNop);

    return true;
}
Exemple #8
0
void ServerState::loadOps() {
    DLOG(INFO) << "Loading ops.";
    string contents = floadFile("./ops.json");
    json_error_t jserror;
    json_t* root = json_loads(contents.c_str(), 0, &jserror);
    if (!json_is_array(root)) {
        LOG(WARNING) << "Failed to parse the ops list json. Error: " << &jserror.text;
        return;
    }
    opList.clear();
    size_t size = json_array_size(root);
    for (size_t i = 0; i < size; ++i) {
        json_t* jop = json_array_get(root, i);
        if (!json_is_string(jop)) {
            LOG(WARNING) << "Failed to parse an op value because it was not a string.";
            continue;
        }
        string op = json_string_value(jop);
        addOp(op);
    }
    json_decref(root);
}
//! [1]
ImageComposer::ImageComposer()
{
    sourceButton = new QToolButton;
    sourceButton->setIconSize(resultSize);

    operatorComboBox = new QComboBox;
    addOp(QPainter::CompositionMode_SourceOver, tr("SourceOver"));
    addOp(QPainter::CompositionMode_DestinationOver, tr("DestinationOver"));
    addOp(QPainter::CompositionMode_Clear, tr("Clear"));
    addOp(QPainter::CompositionMode_Source, tr("Source"));
    addOp(QPainter::CompositionMode_Destination, tr("Destination"));
    addOp(QPainter::CompositionMode_SourceIn, tr("SourceIn"));
    addOp(QPainter::CompositionMode_DestinationIn, tr("DestinationIn"));
    addOp(QPainter::CompositionMode_SourceOut, tr("SourceOut"));
    addOp(QPainter::CompositionMode_DestinationOut, tr("DestinationOut"));
    addOp(QPainter::CompositionMode_SourceAtop, tr("SourceAtop"));
    addOp(QPainter::CompositionMode_DestinationAtop, tr("DestinationAtop"));
    addOp(QPainter::CompositionMode_Xor, tr("Xor"));
//! [1]

//! [2]
    destinationButton = new QToolButton;
    destinationButton->setIconSize(resultSize);

    equalLabel = new QLabel(tr("="));

    resultLabel = new QLabel;
    resultLabel->setMinimumWidth(resultSize.width());
//! [2]

//! [3]
    connect(sourceButton, SIGNAL(clicked()), this, SLOT(chooseSource()));
    connect(operatorComboBox, SIGNAL(activated(int)),
            this, SLOT(recalculateResult()));
    connect(destinationButton, SIGNAL(clicked()),
            this, SLOT(chooseDestination()));
//! [3]

//! [4]
    QGridLayout *mainLayout = new QGridLayout;
    mainLayout->addWidget(sourceButton, 0, 0, 3, 1);
    mainLayout->addWidget(operatorComboBox, 1, 1);
    mainLayout->addWidget(destinationButton, 0, 2, 3, 1);
    mainLayout->addWidget(equalLabel, 1, 3);
    mainLayout->addWidget(resultLabel, 0, 4, 3, 1);
    mainLayout->setSizeConstraint(QLayout::SetFixedSize);
    setLayout(mainLayout);
//! [4]

//! [5]
    resultImage = QImage(resultSize, QImage::Format_ARGB32_Premultiplied);

    loadImage(":/images/butterfly.png", &sourceImage, sourceButton);
    loadImage(":/images/checker.png", &destinationImage, destinationButton);

    setWindowTitle(tr("Image Composition"));
}
Exemple #10
0
 void addUniqueIndex() {
     addOp("i", BSON("ns" << ns() << "key" << BSON("x" << 1) << "name" << "x1" << "unique" << true), 0, "unittests.system.indexes");
     addInserts(2);
 }
Exemple #11
0
 void addVersionedInserts(int expected) {
     for (int i=0; i < expected; i++) {
         addOp("i", BSON("_id" << i << "x" << 789), NULL, NULL, i);
     }
 }
Exemple #12
0
 void addInserts(int expected) {
     for (int i=0; i<expected; i++) {
         addOp("i", BSON("_id" << i << "x" << 789));
     }
 }
Exemple #13
0
		TypeVisitor& TypeVisitor::addOp(impl::Value op, impl::Value v, const std::string& fn) {
			if (ts->type_id.count(fn)) ts->addConv(id, ts->type_id[fn]);

			return addOp(op, v);
		}
Exemple #14
0
void fillOpTable(Context *context){
    addOp(context, "+", &op_Plus);
    addOp(context, "-", &op_Minus);
    addOp(context, "*", &op_Mul);
    addOp(context, "/", &op_Div);
    addOp(context, "==", &op_Eq);
    addOp(context, "help", &op_Help);
    addOp(context, "define", &op_Define);
    addOp(context, "lambda", &op_Fn);
    addOp(context, "alias", &op_Alias);
    addOp(context, "deffn", &op_DefFn);
    addOp(context, "print", &op_Print);
    addOp(context, "import", &op_Import);
    addOp(context, "if", &op_If);
    addOp(context, "id", &op_Quote);
    addOp(context, "length", &op_Length);
    addOp(context, "cons", &op_Cons);
    addOp(context, "slice", &op_Slice);
    addOp(context, "[]", &op_Elem);
    addOp(context, "list", &op_List);
    addOp(context, "comment", &op_Comment);
    addOp(context, "assert", &op_Assert);
}