bool Module::registerGroupInModule(std::string modname, RunGroup *group, bool remote) { assert(group); Module *mod = NULL; if (mods(remote).count(modname) && !remote) { mod = mods(remote)[modname]; } else { mod = new Module(modname, remote); if (mod->creation_error) { delete mod; mod = NULL; } } if (group->mod) { assert(group->mod == mod); return true; } group->mod = mod; if (!mod) return false; mod->groups.push_back(group); return true; }
Missile* UnitFactory::parseMissileBuffer( NetBuffer &netbuf ) { ObjSerial serial = netbuf.getSerial(); string file( netbuf.getString() ); string name( netbuf.getString() ); string fullname( netbuf.getString() ); int faction = netbuf.getInt32(); string mods( netbuf.getString() ); const float damage( netbuf.getFloat() ); float phasedamage = netbuf.getFloat(); float time = netbuf.getFloat(); float radialeffect = netbuf.getFloat(); float radmult = netbuf.getFloat(); float detonation_radius = netbuf.getFloat(); const string modifs( mods ); cerr<<"NETCREATE MISSILE : "<<file<<" ("<<serial<<")"<<endl; string facname = FactionUtil::GetFactionName( faction ); if ( facname.empty() ) { //Got an invalid faction number... cerr<<" Missile has an invalid faction "<<faction<<endl; faction = 0; } Missile *mis = createMissile( file.c_str(), faction, modifs, damage, phasedamage, time, radialeffect, radmult, detonation_radius, serial ); if (netbuf.version() <= 4951) mis->curr_physical_state = netbuf.getTransformation(); else netbuf.getClientState().setUnitState( mis ); mis->name = name; mis->fullname = fullname; return mis; }
static void cell(struct tbl_node *tbl, struct tbl_row *rp, int ln, const char *p, int *pos) { int i; enum tbl_cellt c; /* Handle leading vertical lines */ while (p[*pos] == ' ' || p[*pos] == '\t' || p[*pos] == '|') { if (p[*pos] == '|') { if (rp->vert < 2) rp->vert++; else mandoc_msg(MANDOCERR_TBLLAYOUT_VERT, tbl->parse, ln, *pos, NULL); } (*pos)++; } again: while (p[*pos] == ' ' || p[*pos] == '\t') (*pos)++; if (p[*pos] == '.' || p[*pos] == '\0') return; /* Parse the column position (`c', `l', `r', ...). */ for (i = 0; i < KEYS_MAX; i++) if (tolower((unsigned char)p[*pos]) == keys[i].name) break; if (i == KEYS_MAX) { mandoc_vmsg(MANDOCERR_TBLLAYOUT_CHAR, tbl->parse, ln, *pos, "%c", p[*pos]); (*pos)++; goto again; } c = keys[i].key; /* Special cases of spanners. */ if (c == TBL_CELL_SPAN) { if (rp->last == NULL) mandoc_msg(MANDOCERR_TBLLAYOUT_SPAN, tbl->parse, ln, *pos, NULL); else if (rp->last->pos == TBL_CELL_HORIZ || rp->last->pos == TBL_CELL_DHORIZ) c = rp->last->pos; } else if (c == TBL_CELL_DOWN && rp == tbl->first_row) mandoc_msg(MANDOCERR_TBLLAYOUT_DOWN, tbl->parse, ln, *pos, NULL); (*pos)++; /* Allocate cell then parse its modifiers. */ mods(tbl, cell_alloc(tbl, rp, c), ln, p, pos); }
Module::Module(std::string name_, bool remote_) { name = name_; remote = remote_; if (remote) { tester = RemoteComponentFE::createRemoteComponentFE(name, getConnection()); } else { tester = loadModuleLibrary(); } creation_error = (tester == NULL); if (creation_error) { mods(remote)[name] = NULL; return; } mods(remote)[name] = this; initialized = true; setup_run = false; }
result_t SandBox::clone(obj_ptr<SandBox_base> &retVal) { obj_ptr<SandBox> sbox = new SandBox(); sbox->m_name = m_name; sbox->wrap()->SetHiddenValue(v8::String::NewFromUtf8(Isolate::now().isolate, "_mods"), mods()->Clone()); retVal = sbox; return 0; }
result_t SandBox::clone(obj_ptr<SandBox_base> &retVal) { obj_ptr<SandBox> sbox = new SandBox(); sbox->m_name = m_name; sbox->wrap()->SetHiddenValue(holder()->NewFromUtf8("_mods"), mods()->Clone()); retVal = sbox; return 0; }
void Game::getPremiumModules(std::vector<Common::UString> &modules) { modules.clear(); Common::FileList mods(ConfigMan.getString("NWN_campaignDir")); for (Common::FileList::const_iterator m = mods.begin(); m != mods.end(); ++m) if (isPremiumModule(*m)) modules.push_back(Common::FilePath::getStem(*m)); std::sort(modules.begin(), modules.end(), Common::UString::iless()); }
static int cell(struct tbl_node *tbl, struct tbl_row *rp, int ln, const char *p, int *pos) { int i; enum tbl_cellt c; /* Parse the column position (`r', `R', `|', ...). */ for (i = 0; i < KEYS_MAX; i++) if (tolower((unsigned char)p[*pos]) == keys[i].name) break; if (KEYS_MAX == i) { TBL_MSG(tbl, MANDOCERR_TBLLAYOUT, ln, *pos); return(0); } c = keys[i].key; /* * If a span cell is found first, raise a warning and abort the * parse. FIXME: recover from this somehow? */ if (NULL == rp->first && TBL_CELL_SPAN == c) { TBL_MSG(tbl, MANDOCERR_TBLLAYOUT, ln, *pos); return(0); } (*pos)++; /* Extra check for the double-vertical. */ if (TBL_CELL_VERT == c && '|' == p[*pos]) { (*pos)++; c = TBL_CELL_DVERT; } /* Disallow adjacent spacers. */ if (rp->last && (TBL_CELL_VERT == c || TBL_CELL_DVERT == c) && (TBL_CELL_VERT == rp->last->pos || TBL_CELL_DVERT == rp->last->pos)) { TBL_MSG(tbl, MANDOCERR_TBLLAYOUT, ln, *pos - 1); return(0); } /* Allocate cell then parse its modifiers. */ return(mods(tbl, cell_alloc(tbl, rp, c), ln, p, pos)); }
static app_ref generate_ineqs(ast_manager& m, sort* s, vector<expr_ref_vector>& cs, bool mods_too) { arith_util a(m); app_ref_vector vars(m), nums(m); vars.push_back(m.mk_const(symbol("x"), s)); vars.push_back(m.mk_const(symbol("y"), s)); vars.push_back(m.mk_const(symbol("z"), s)); vars.push_back(m.mk_const(symbol("u"), s)); vars.push_back(m.mk_const(symbol("v"), s)); vars.push_back(m.mk_const(symbol("w"), s)); nums.push_back(a.mk_numeral(rational(1), s)); nums.push_back(a.mk_numeral(rational(2), s)); nums.push_back(a.mk_numeral(rational(3), s)); app* x = vars[0].get(); app* y = vars[1].get(); // app* z = vars[2].get(); // // ax <= by, ax < by, not (ax >= by), not (ax > by) // cs.push_back(mk_ineqs(x, vars[1].get(), nums)); cs.push_back(mk_ineqs(x, vars[2].get(), nums)); cs.push_back(mk_ineqs(x, vars[3].get(), nums)); cs.push_back(mk_ineqs(x, vars[4].get(), nums)); cs.push_back(mk_ineqs(x, vars[5].get(), nums)); if (mods_too) { expr_ref_vector mods(m); expr_ref zero(a.mk_numeral(rational(0), s), m); mods.push_back(m.mk_true()); for (unsigned j = 0; j < nums.size(); ++j) { mods.push_back(m.mk_eq(a.mk_mod(a.mk_add(a.mk_mul(nums[j].get(),x), y), nums[1].get()), zero)); } cs.push_back(mods); mods.resize(1); for (unsigned j = 0; j < nums.size(); ++j) { mods.push_back(m.mk_eq(a.mk_mod(a.mk_add(a.mk_mul(nums[j].get(),x), y), nums[2].get()), zero)); } cs.push_back(mods); } return app_ref(x, m); }
CVehicleModificationParams::CVehicleModificationParams( XmlNodeRef xmlVehicleData, const char* modificationName ) : m_pImpl( NULL ) { assert( modificationName != NULL ); if ( modificationName[ 0 ] == 0 ) { return; } string mods(modificationName); int start = 0; string modification = mods.Tokenize(",", start); while (!modification.empty()) { XmlNodeRef xmlModificationsGroup = xmlVehicleData->findChild( "Modifications" ); if ( ! xmlModificationsGroup ) { GameWarning("Failed to set Modification '%s' because the vehicle doesn't have any modifications", modification.c_str()); return; } XmlNodeRef xmlModification = FindModificationNodeByName( modification.c_str(), xmlModificationsGroup ); if ( ! xmlModification ) { GameWarning("Failed to set Modification '%s' because the vehicle doesn't have that modification", modification.c_str()); return; } if(m_pImpl == NULL) { m_pImpl = new Implementation(); } InitModification( xmlModification ); modification = mods.Tokenize(",", start); } }
BSONObj applyUpdateOperators( const BSONObj& from, const BSONObj& operators ) { if ( isNewUpdateFrameworkEnabled() ) { UpdateDriver::Options opts; opts.multi = false; opts.upsert = false; UpdateDriver driver( opts ); Status status = driver.parse( IndexPathSet(), operators ); if ( !status.isOK() ) { uasserted( 16838, status.reason() ); } mutablebson::Document doc( from, mutablebson::Document::kInPlaceDisabled ); status = driver.update( StringData(), &doc, NULL /* not oplogging */ ); if ( !status.isOK() ) { uasserted( 16839, status.reason() ); } return doc.getObject(); } else { ModSet mods( operators ); return mods.prepare( from, false /* not an insertion */ )->createNewFromMods(); } }
static int cell(struct tbl_node *tbl, struct tbl_row *rp, int ln, const char *p, int *pos) { int vert, i; enum tbl_cellt c; /* Handle vertical lines. */ for (vert = 0; '|' == p[*pos]; ++*pos) vert++; while (' ' == p[*pos]) (*pos)++; /* Parse the column position (`c', `l', `r', ...). */ for (i = 0; i < KEYS_MAX; i++) if (tolower((unsigned char)p[*pos]) == keys[i].name) break; if (KEYS_MAX == i) { mandoc_msg(MANDOCERR_TBLLAYOUT, tbl->parse, ln, *pos, NULL); return(0); } c = keys[i].key; /* * If a span cell is found first, raise a warning and abort the * parse. If a span cell is found and the last layout element * isn't a "normal" layout, bail. * * FIXME: recover from this somehow? */ if (TBL_CELL_SPAN == c) { if (NULL == rp->first) { mandoc_msg(MANDOCERR_TBLLAYOUT, tbl->parse, ln, *pos, NULL); return(0); } else if (rp->last) switch (rp->last->pos) { case (TBL_CELL_HORIZ): case (TBL_CELL_DHORIZ): mandoc_msg(MANDOCERR_TBLLAYOUT, tbl->parse, ln, *pos, NULL); return(0); default: break; } } /* * If a vertical spanner is found, we may not be in the first * row. */ if (TBL_CELL_DOWN == c && rp == tbl->first_row) { mandoc_msg(MANDOCERR_TBLLAYOUT, tbl->parse, ln, *pos, NULL); return(0); } (*pos)++; /* Disallow adjacent spacers. */ if (vert > 2) { mandoc_msg(MANDOCERR_TBLLAYOUT, tbl->parse, ln, *pos - 1, NULL); return(0); } /* Allocate cell then parse its modifiers. */ return(mods(tbl, cell_alloc(tbl, rp, c, vert), ln, p, pos)); }
void Ship::act() { move(); mods(); //bump(); }
void ScCodeEditor::keyPressEvent( QKeyEvent *e ) { hideMouseCursor(e); QTextCursor cursor( textCursor() ); bool cursorMoved = true; if (e == QKeySequence::MoveToNextWord) moveToNextToken( cursor, QTextCursor::MoveAnchor ); else if (e == QKeySequence::MoveToPreviousWord) moveToPreviousToken( cursor, QTextCursor::MoveAnchor ); else if (e == QKeySequence::SelectNextWord) moveToNextToken( cursor, QTextCursor::KeepAnchor ); else if (e == QKeySequence::SelectPreviousWord) moveToPreviousToken( cursor, QTextCursor::KeepAnchor ); else cursorMoved = false; if (cursorMoved) { setTextCursor( cursor ); return; } switch (e->key()) { case Qt::Key_Home: { Qt::KeyboardModifiers mods(e->modifiers()); if (mods && mods != Qt::ShiftModifier) { GenericCodeEditor::keyPressEvent(e); return; } QTextCursor::MoveMode mode = mods & Qt::ShiftModifier ? QTextCursor::KeepAnchor : QTextCursor::MoveAnchor; QTextCursor c(textCursor()); QTextBlock b(c.block()); int pos = indentedStartOfLine(b); pos += b.position(); if (c.position() == pos) c.movePosition(QTextCursor::StartOfLine, mode); else c.setPosition(pos, mode); setTextCursor(c); return; } case Qt::Key_Backtab: { QTextCursor cursor = textCursor(); insertSpaceToNextTabStop( cursor ); ensureCursorVisible(); return; } case Qt::Key_Backspace: if (mInsertMatchingTokens && !overwriteMode() && e->modifiers() == 0) if (removeMatchingTokens()) break; GenericCodeEditor::keyPressEvent(e); break; case Qt::Key_Enter: case Qt::Key_Return: { QTextBlock cursorBlock = cursor.block(); int cursorPosInBlock = cursor.position() - cursorBlock.position(); TokenIterator nextToken = TokenIterator::rightOf(cursorBlock, cursorPosInBlock); if ( nextToken.block() == cursorBlock && nextToken.type() == Token::ClosingBracket ) { cursor.beginEditBlock(); cursor.insertBlock(); cursor.insertBlock(); cursor.endEditBlock(); cursor.movePosition( QTextCursor::PreviousBlock, QTextCursor::KeepAnchor ); indent(cursor, JoinEditBlock); cursor.movePosition( QTextCursor::EndOfBlock ); } else { cursor.beginEditBlock(); cursor.insertBlock(); cursor.endEditBlock(); indent(cursor, JoinEditBlock); } cursor.setVerticalMovementX(-1); setTextCursor(cursor); break; } default: if (!overwriteMode() && insertMatchingTokens(e->text())) break; GenericCodeEditor::keyPressEvent(e); } mAutoCompleter->keyPress(e); }
BSONObj applyUpdateOperators( const BSONObj& from, const BSONObj& operators ) { ModSet mods( operators ); return mods.prepare( from, false /* not an insertion */ )->createNewFromMods(); }
void ScCodeEditor::keyPressEvent( QKeyEvent *e ) { QTextCursor cursor( textCursor() ); bool cursorMoved = true; if (e == QKeySequence::MoveToNextWord) moveToNextToken( cursor, QTextCursor::MoveAnchor ); else if (e == QKeySequence::MoveToPreviousWord) moveToPreviousToken( cursor, QTextCursor::MoveAnchor ); else if (e == QKeySequence::SelectNextWord) moveToNextToken( cursor, QTextCursor::KeepAnchor ); else if (e == QKeySequence::SelectPreviousWord) moveToPreviousToken( cursor, QTextCursor::KeepAnchor ); else cursorMoved = false; if (cursorMoved) { setTextCursor( cursor ); return; } switch (e->key()) { case Qt::Key_Home: { Qt::KeyboardModifiers mods(e->modifiers()); if (mods && mods != Qt::ShiftModifier) { GenericCodeEditor::keyPressEvent(e); return; } hideMouseCursor(); QTextCursor::MoveMode mode = mods & Qt::ShiftModifier ? QTextCursor::KeepAnchor : QTextCursor::MoveAnchor; QTextCursor c(textCursor()); QTextBlock b(c.block()); int pos = indentedStartOfLine(b); pos += b.position(); if (c.position() == pos) c.movePosition(QTextCursor::StartOfLine, mode); else c.setPosition(pos, mode); setTextCursor(c); return; } case Qt::Key_Backtab: { hideMouseCursor(); QTextCursor cursor = textCursor(); insertSpaceToNextTabStop( cursor ); ensureCursorVisible(); return; } default: { static const QString closingBrackets(")]}"); bool indentCurrentLine = e->key() == Qt::Key_Enter || e->key() == Qt::Key_Return || ( !e->text().isEmpty() && closingBrackets.contains(e->text()) ); if (indentCurrentLine) cursor.beginEditBlock(); GenericCodeEditor::keyPressEvent(e); if (indentCurrentLine) { cursor.endEditBlock(); cursor.joinPreviousEditBlock(); indent(); cursor.endEditBlock(); } } } mAutoCompleter->keyPress(e); }
void SandBox::InstallModule(std::string fname, v8::Local<v8::Value> o) { mods()->Set(holder()->NewFromUtf8(fname), o); }
result_t SandBox::remove(const char *id) { mods()->Delete(v8::String::NewFromUtf8(Isolate::now().isolate, id)); return 0; }
void SandBox::InstallModule(std::string fname, v8::Local<v8::Value> o) { mods()->Set(v8::String::NewFromUtf8(Isolate::now().isolate, fname.c_str(), v8::String::kNormalString, (int)fname.length()), o); }
BSONObj applyUpdateOperators( const BSONObj& from, const BSONObj& operators ) { ModSet mods( operators ); return mods.prepare( from )->createNewFromMods(); }
void ScCodeEditor::keyPressEvent( QKeyEvent *e ) { QTextCursor cursor( textCursor() ); bool cursorMoved = true; if (e == QKeySequence::MoveToNextWord) moveToNextToken( cursor, QTextCursor::MoveAnchor ); else if (e == QKeySequence::MoveToPreviousWord) moveToPreviousToken( cursor, QTextCursor::MoveAnchor ); else if (e == QKeySequence::SelectNextWord) moveToNextToken( cursor, QTextCursor::KeepAnchor ); else if (e == QKeySequence::SelectPreviousWord) moveToPreviousToken( cursor, QTextCursor::KeepAnchor ); else cursorMoved = false; if (cursorMoved) { setTextCursor( cursor ); return; } switch (e->key()) { case Qt::Key_Home: { Qt::KeyboardModifiers mods(e->modifiers()); if (mods && mods != Qt::ShiftModifier) { GenericCodeEditor::keyPressEvent(e); return; } hideMouseCursor(); QTextCursor::MoveMode mode = mods & Qt::ShiftModifier ? QTextCursor::KeepAnchor : QTextCursor::MoveAnchor; QTextCursor c(textCursor()); QTextBlock b(c.block()); int pos = indentedStartOfLine(b); pos += b.position(); if (c.position() == pos) c.movePosition(QTextCursor::StartOfLine, mode); else c.setPosition(pos, mode); setTextCursor(c); return; } case Qt::Key_Backtab: { hideMouseCursor(); QTextCursor cursor = textCursor(); insertSpaceToNextTabStop( cursor ); ensureCursorVisible(); return; } case Qt::Key_Enter: case Qt::Key_Return: case Qt::Key_BraceRight: case Qt::Key_BracketRight: case Qt::Key_ParenRight: { hideMouseCursor(); // Wrap superclass' implementation into an edit block, // so it can be joined with indentation later: QTextCursor cursor = textCursor(); cursor.beginEditBlock(); GenericCodeEditor::keyPressEvent(e); cursor.endEditBlock(); cursor.joinPreviousEditBlock(); indent(); cursor.endEditBlock(); cursor.setVerticalMovementX(-1); setTextCursor(cursor); break; } default: GenericCodeEditor::keyPressEvent(e); } mAutoCompleter->keyPress(e); }
result_t SandBox::remove(const char *id) { mods()->Delete(holder()->NewFromUtf8(id)); return 0; }