Beispiel #1
0
NamespaceDetails::Extra* NamespaceDetails::allocExtra(OperationContext* txn,
        StringData ns,
        NamespaceIndex& ni,
        int nindexessofar) {
    // Namespace details must always be changed under an exclusive DB lock
    const NamespaceString nss(ns);
    invariant(txn->lockState()->isDbLockedForMode(nss.db(), MODE_X));

    int i = (nindexessofar - NIndexesBase) / NIndexesExtra;
    verify(i >= 0 && i <= 1);

    Namespace fullns(ns);
    Namespace extrans(fullns.extraName(i));  // throws UserException if ns name too long

    massert(10350, "allocExtra: base ns missing?", this);
    massert(10351, "allocExtra: extra already exists", ni.details(extrans) == 0);

    Extra temp;
    temp.init();

    ni.add_ns(txn, extrans, reinterpret_cast<NamespaceDetails*>(&temp));
    Extra* e = reinterpret_cast<NamespaceDetails::Extra*>(ni.details(extrans));

    long ofs = e->ofsFrom(this);
    if (i == 0) {
        verify(_extraOffset == 0);
        *txn->recoveryUnit()->writing(&_extraOffset) = ofs;
        verify(extra() == e);
    } else {
        Extra* hd = extra();
        verify(hd->next(this) == 0);
        hd->setNext(txn, ofs);
    }
    return e;
}
int main()
{
	int i;
	for(i = 2; i * i < maxn; i++)
	{
		if(num[i] == 1)
			continue;
		for(int j = i; i * j < maxn; j++)
			if(num[i*j] != 1)
				num[i*j] = 1;
			else				
				continue;			
	}
	for(i = 1; i < maxn; i++)
		if(num[i] == 0 && num[extra(i)] <= 0)
				num[i] = -1;
	int nt = 0;
	for(i = 1; i < maxn; i++)
		num[i] = (num[i] == -1) ? ++nt : nt;
	int T;
	scanf("%d", &T);
	for(i = 1; i <= T; i++)
	{
		int l, r;
		scanf("%d%d", &l, &r);
		int tot = num[r] - num[l];
		if(jd(l) && jd(extra(l)))
			tot++;			
		printf("Case #%d: %d\n", i, tot);
	}
	return 0;
}
Beispiel #3
0
void Enemy::dropLoot() {
	for(int i = 0; i < Game::randomInt(1,3); i++) {
		std::shared_ptr<Pickup> treasure(new Pickup(world(), Pickup::Treasure));
		treasure->x = x;
		treasure->y = y;
		treasure->dx = dx + Game::randomDouble(-2,2);
		treasure->dy = dy + Game::randomDouble(-2,2);
		treasure->add();
	}
	
	if(Game::randomInt(0, 14) == 0) {
		Pickup::PickupType t = Game::randomInt(0,1) == 0 ? Pickup::Health : Pickup::Goop;
		std::shared_ptr<Pickup> extra(new Pickup(world(), t));
		extra->x = x;
		extra->y = y;
		extra->dx = dx + Game::randomDouble(-2,2);
		extra->dy = dy + Game::randomDouble(-2,2);
		extra->add();
	}
	
	
	if(Game::randomInt(0, 7) == 0) {
		Pickup::PickupType t = Game::randomInt(0,1) == 0 ? Pickup::Bombs : Pickup::Mines;
		std::shared_ptr<Pickup> extra(new Pickup(world(), t));
		extra->x = x;
		extra->y = y;
		extra->dx = dx + Game::randomDouble(-2,2);
		extra->dy = dy + Game::randomDouble(-2,2);
		extra->add();
	}
}
Beispiel #4
0
// Try to find a binary symbol (statically linked resource) within the library.
// (This is used to retrieve the compiled-in versions of .lua script files.) If
// found, data and *len get set accordingly, otherwise they'll be (NULL, 0).
// Caution: The matching depends on some naming conventions, and so far has only
// been tested for MinGW. Also: have a look at objwrap.lua and its comments.
char *getBinarySymbol(const char *path, size_t *len, char *buffer, size_t size) {
	if (!len) {
		error("%s(): you must pass a 'len' pointer!", __func__);
		return NULL;
	}
	*len = 0;
	char *data = NULL;	// _start symbol (beginning of data resource)
	char *end = NULL;	// _end symbol (end of data resource)

	// pattern is the search string (slightly modified pathname)
	// that we'll be looking for in our binary's symbols
	char pattern[PATH_MAX];

	strncpy(pattern, strip_pwd(path), sizeof(pattern));

	// convert pattern to our symbol name prefix convention
	// (which simply replaces any non-alphanumerical chars with '_')
	unsigned int i = strlen(pattern);
	while (i-- > 0) {
		if ('a' <= pattern[i] && pattern[i] <= 'z') continue;
		if ('A' <= pattern[i] && pattern[i] <= 'Z') continue;
		if ('0' <= pattern[i] && pattern[i] <= '9') continue;
		pattern[i] = '_';
	}
#ifdef RELAXED_NAME_CHECKING
	// append "binary" to the pattern, and allow partial matching later (ignore path)
	//strcat(pattern, "_binary_");
#endif
	extra("%s('%s') pattern:'%s'", __func__, path, pattern);

	char temp[PATH_MAX + 32];
	snprintf(temp, sizeof(temp), "%s_binary_obj_data_end", pattern);
	end = getExportedSymbolByName(lcfr_globals.libhandle, temp);
	extra("end symbol: %s = %p", temp, end);
	snprintf(temp, sizeof(temp), "%s_binary_obj_data_start", pattern);
	data = getExportedSymbolByName(lcfr_globals.libhandle, temp);
	extra("start symbol: %s = %p", temp, data);

	// we simply calculate *len (instead of relying on the XXX_size symbol)
	if (data && end) {
		*len = (end - data);
		debug("%s('%s') %s, start:%p, end:%p, size:%d",
			  __func__, pattern, temp, data, end, *len);
		if (buffer && size)
			snprintf(buffer, size, "%s", temp);
	}
	return (*len > 0) ? data : NULL;
}
Beispiel #5
0
static inline std::string makeExtraData(unsigned char* sps, int spss, unsigned char* pps, int ppss)
{
    const int total = (spss + 4 + ppss + 4) * 4 + 100;
    std::string extra(total, '\0');

    // skip NAL unit type
    extra[0] = 0x1;
    extra[1] = sps[1];
    extra[2] = sps[2];
    extra[3] = sps[3];
    extra[4] = 0xfc | (4 - 1);

    int sz = 5;
    uint16_t num;

    extra[sz++] = 0xe0 | 1;

    memcpy(&extra[sz + 2], sps, spss);
    num = htons(spss);
    memcpy(&extra[sz], &num, sizeof(uint16_t));
    sz += spss + 2;

    extra[sz++] = 1;

    memcpy(&extra[sz + 2], pps, ppss);
    num = htons(ppss);
    memcpy(&extra[sz], &num, sizeof(uint16_t));
    sz += ppss + 2;

    extra.resize(sz);
    return extra;
}
uint8_t DGbob::configure(AVDMGenericVideoStream *in)
{
        _in=in;
#define PX(x) &(_param->x)
  
     diaMenuEntry menuField[2]={{0,QT_TR_NOOP("Top"),NULL},
                             {1,QT_TR_NOOP("Bottom"),NULL}
                          };
  
     diaMenuEntry menuMode[3]={{0,QT_TR_NOOP("Keep nb of frames and fps"),NULL},
                            {1,QT_TR_NOOP("Double nb of frames and fps"),NULL},
                            {2,QT_TR_NOOP("Double nb of frames (slow motion)"),NULL}
                          };
                          
    diaElemMenu     menu1(PX(order),QT_TR_NOOP("_Field order:"), 2,menuField);
    diaElemMenu     menu2(PX(mode),QT_TR_NOOP("_Mode:"), 3,menuMode);
    diaElemUInteger threshold(PX(thresh),QT_TR_NOOP("_Threshold:"),0,255);
    diaElemToggle  extra(PX(ap),QT_TR_NOOP("_Extra"),QT_TR_NOOP("Extra check, avoid using it"));
    
      diaElem *elems[4]={&menu1,&menu2,&threshold ,&extra};
   if(diaFactoryRun(QT_TR_NOOP("DGBob"),4,elems))
  {
                update();
                return 1;
        }
        return 0;
        
}
Beispiel #7
0
void CoreDict::readProperty( const String &prop, Item &item )
{
   if( m_blessed )
   {
      Item *method;

      if ( ( method = find( prop ) ) != 0 )
      {
         item = *method->dereference();
         item.methodize( this );  // may fail but it's ok
         return;
      }
   }

   // try to find a generic method
   VMachine *vm = VMachine::getCurrent();
   if( vm != 0 )
   {
      CoreClass* cc = vm->getMetaClass( FLC_ITEM_DICT );
      uint32 id;
      if ( cc == 0 || ! cc->properties().findKey( prop, id ) )
      {
         String extra( "Dictionary." );
         extra.A( prop );
         throw new AccessError( ErrorParam( e_prop_acc, __LINE__ ).extra( extra ) );
      }
      item = *cc->properties().getValue( id );
      item.methodize( this );
   }

}
Beispiel #8
0
void WorldSession::HandleMoveKnockBackAck(WorldPacket & recvData)
{
    sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_MOVE_KNOCK_BACK_ACK");

    static MovementStatusElements const unkVal = MSEExtraFloat;
    ExtraMovementStatusElement extra(&unkVal);
    
    MovementInfo movementInfo;
    GetPlayer()->ReadMovementInfo(recvData, &movementInfo, &extra);

    Unit* mover = _player->m_mover;
    ASSERT(mover != NULL);                      // there must always be a mover

    if (mover->GetGUID() != movementInfo.guid)
        return;

    _player->m_movementInfo = movementInfo;

    WorldPacket data;
    if (!_player->m_movementInfo.hasFallData ||
        !_player->m_movementInfo.hasFallDirection)
        data.Initialize(SMSG_MOVE_UPDATE, recvData.size());
    else
    {
        return;
        /*data.Initialize(SMSG_MOVE_UPDATE_KNOCK_BACK, recvData.size());*/
    }

    _player->WriteMovementInfo(data);
    _player->SendMessageToSet(&data, false);
}
Beispiel #9
0
void tables_creator::visit(const byte_vector_field_instruction *inst,
                           void *pIndex) {
  create_current_ << "  " << inst->name() << " BLOB"
                  << extra(inst, "BLOB", pIndex) << "\n";
  parameters_.push_back(inst->name());
  num_columns_++;
}
Beispiel #10
0
QSize K3b::MsfEdit::sizeHint() const
{
    if (d->cachedSizeHint.isEmpty()) {
        ensurePolished();

        const QFontMetrics fm(fontMetrics());
        int h = lineEdit()->sizeHint().height();
        int w = fm.width( lineEdit()->inputMask() );
        w += 2; // cursor blinking space

        QStyleOptionSpinBox opt;
        initStyleOption(&opt);
        QSize hint(w, h);
        QSize extra(35, 6);
        opt.rect.setSize(hint + extra);
        extra += hint - style()->subControlRect(QStyle::CC_SpinBox, &opt,
                                                QStyle::SC_SpinBoxEditField, this).size();
        // get closer to final result by repeating the calculation
        opt.rect.setSize(hint + extra);
        extra += hint - style()->subControlRect(QStyle::CC_SpinBox, &opt,
                                                QStyle::SC_SpinBoxEditField, this).size();
        hint += extra;

        opt.rect = rect();
        d->cachedSizeHint = style()->sizeFromContents(QStyle::CT_SpinBox, &opt, hint, this)
                            .expandedTo(QApplication::globalStrut());
    }
    return d->cachedSizeHint;
}
TEST(parse_tx_extra, handles_invalid_padding_only)
{
  std::vector<uint8_t> extra(2, 0);
  extra[1] = 42;
  std::vector<cryptonote::tx_extra_field> tx_extra_fields;
  ASSERT_FALSE(cryptonote::parse_tx_extra(extra, tx_extra_fields));
}
Beispiel #12
0
static bool processFile(Output* output, BuildContext* builder, UpdateFileIterator& fileit, UpdateStatistics& stats, const char* path)
{
	FileStream in(path, "rb");
	if (!in) return true;

	DataFileHeader header;
	if (!read(in, header) || memcmp(header.magic, kDataFileHeaderMagic, strlen(kDataFileHeaderMagic)) != 0)
	{
		output->error("Warning: data file %s has an out of date format, rebuilding\n", path);
		return true;
	}

	DataChunkHeader chunk;

	while (read(in, chunk))
	{
		std::unique_ptr<char[]> extra(new (std::nothrow) char[chunk.extraSize]);
		std::unique_ptr<char[]> index(new (std::nothrow) char[chunk.indexSize]);
		std::unique_ptr<char[]> data(new (std::nothrow) char[chunk.compressedSize + chunk.uncompressedSize]);

		if (!extra || !index || !data || !read(in, extra.get(), chunk.extraSize) || !read(in, index.get(), chunk.indexSize) || !read(in, data.get(), chunk.compressedSize))
		{
			output->error("Error reading data file %s: malformed chunk\n", path);
			return false;
		}

		char* uncompressed = data.get() + chunk.compressedSize;

		processChunkData(output, builder, fileit, stats, chunk, uncompressed, data, index, extra);
	}

	return true;
}
    QSize minimumSizeHint() const
    {
        if (cachedMinimumSizeHint.isEmpty()) {
            ensurePolished();

            const QFontMetrics fm(fontMetrics());
            int h = lineEdit()->minimumSizeHint().height();
            int w = fm.width(BitcoinUnits::format(BitcoinUnits::FROST, BitcoinUnits::maxMoney(), false, BitcoinUnits::separatorAlways));
            w += 2; // cursor blinking space

            QStyleOptionSpinBox opt;
            initStyleOption(&opt);
            QSize hint(w, h);
            QSize extra(35, 6);
            opt.rect.setSize(hint + extra);
            extra += hint - style()->subControlRect(QStyle::CC_SpinBox, &opt, QStyle::SC_SpinBoxEditField, this).size();
            // get closer to final result by repeating the calculation
            opt.rect.setSize(hint + extra);
            extra += hint - style()->subControlRect(QStyle::CC_SpinBox, &opt, QStyle::SC_SpinBoxEditField, this).size();
            hint += extra;
            hint.setHeight(h);

            opt.rect = rect();

            cachedMinimumSizeHint = style()->sizeFromContents(QStyle::CT_SpinBox, &opt, hint, this).expandedTo(QApplication::globalStrut());
        }
        return cachedMinimumSizeHint;
    }
QSize KisAbstractSliderSpinBox::sizeHint() const
{
    const Q_D(KisAbstractSliderSpinBox);
    QStyleOptionSpinBox spinOpts = spinBoxOptions();

    QFontMetrics fm(font());
    //We need at least 50 pixels or things start to look bad
    int w = qMax(fm.width(QString::number(d->maximum)), 50);
    QSize hint(w, d->edit->sizeHint().height() + 3);

    //Getting the size of the buttons is a pain as the calcs require a rect
    //that is "big enough". We run the calc twice to get the "smallest" buttons
    //This code was inspired by QAbstractSpinBox
    QSize extra(35, 6);
    spinOpts.rect.setSize(hint + extra);
    extra += hint - style()->subControlRect(QStyle::CC_SpinBox, &spinOpts,
                                            QStyle::SC_SpinBoxEditField, this).size();

    spinOpts.rect.setSize(hint + extra);
    extra += hint - style()->subControlRect(QStyle::CC_SpinBox, &spinOpts,
                                            QStyle::SC_SpinBoxEditField, this).size();
    hint += extra;

    spinOpts.rect = rect();
    return style()->sizeFromContents(QStyle::CT_SpinBox, &spinOpts, hint, 0)
            .expandedTo(QApplication::globalStrut());

}
status_t MPEG2TSExtractor::queueDiscontinuityForSeek(int64_t actualSeekTimeUs) {
    // Signal discontinuity
    sp<AMessage> extra(new AMessage);
    extra->setInt64(IStreamListener::kKeyMediaTimeUs, actualSeekTimeUs);
    mParser->signalDiscontinuity(ATSParser::DISCONTINUITY_TIME, extra);

    // After discontinuity, impl should only have discontinuities
    // with the last being what we queued. Dequeue them all here.
    for (size_t i = 0; i < mSourceImpls.size(); ++i) {
        const sp<AnotherPacketSource> &impl = mSourceImpls.itemAt(i);
        sp<ABuffer> buffer;
        status_t err;
        while (impl->hasBufferAvailable(&err)) {
            if (err != OK) {
                return err;
            }
            err = impl->dequeueAccessUnit(&buffer);
            // If the source contains anything but discontinuity, that's
            // a programming mistake.
            CHECK(err == INFO_DISCONTINUITY);
        }
    }

    // Feed until we have a buffer for each source.
    for (size_t i = 0; i < mSourceImpls.size(); ++i) {
        const sp<AnotherPacketSource> &impl = mSourceImpls.itemAt(i);
        sp<ABuffer> buffer;
        status_t err = feedUntilBufferAvailable(impl);
        if (err != OK) {
            return err;
        }
    }

    return OK;
}
Beispiel #16
0
void	ConvexTriangleCallback::SetTimeStepAndCounters(float collisionMarginTriangle,const DispatcherInfo& dispatchInfo)
{
	m_dispatchInfoPtr = &dispatchInfo;
	m_collisionMarginTriangle = collisionMarginTriangle;

	//recalc aabbs
	CollisionObject* convexBody = (CollisionObject* )m_convexProxy->m_clientObject;
	CollisionObject* triBody = (CollisionObject* )m_triangleProxy.m_clientObject;

	SimdTransform convexInTriangleSpace;
	convexInTriangleSpace = triBody->m_worldTransform.inverse() * convexBody->m_worldTransform;

	CollisionShape* convexShape = static_cast<CollisionShape*>(convexBody->m_collisionShape);
	//CollisionShape* triangleShape = static_cast<CollisionShape*>(triBody->m_collisionShape);

	convexShape->GetAabb(convexInTriangleSpace,m_aabbMin,m_aabbMax);

	float extraMargin = collisionMarginTriangle;//CONVEX_DISTANCE_MARGIN;//+0.1f;

	SimdVector3 extra(extraMargin,extraMargin,extraMargin);

	m_aabbMax += extra;
	m_aabbMin -= extra;
	
}
Beispiel #17
0
void update(team *overall, batsman *team1, bowler *team2, matchinfo *info) { /*it is main updater function*/
	char a[4];
	char *e = "%s";
	int v, x;
	system("clear");
	start(overall);
	in_the_ground(team1);
	warming_up(team2);
	move(10, 11);
	printf("\e[1menter name of batsman on stike: " ANSI_COLOR_RESET);
	move(45, 11);
	scanf(e, name);
	onstrike = send_batsman(team1, name);
	move(10, 12);
	printf("\e[1menter name of batsman off strike:"  ANSI_COLOR_RESET);
	move(45, 12);
	scanf(e, name);
	offstrike = send_batsman(team1, name);
	taking_guard(onstrike);
	taking_guard(offstrike);
	move(10, 13);
	printf("\e[1menter name of bowler: "  ANSI_COLOR_RESET);
	move(35, 13);		
	scanf(e, name);	
	bowling = give_bowl(team2, name);
	shining_bowl(bowling);
	x = 27;
	while((overall->balls != (info->overs * 6)) && (overall->wickets != 10)) {
		move(0, 26);     	
		printf("\e[1menter runs made , wicket(w), wide(y), noball(n), extra(e) end inning(esc)"  ANSI_COLOR_RESET);
		move(0, x);		
		scanf("%s", a);
		x = 27;
		if(a[0] == 27)
			break;
		input(a);
		if(wrong) {
			move(0, 28);
			printf("\e[1mINVALIND INPUT:"  ANSI_COLOR_RESET);
			x = 29;
			wrong = 0;
			continue;
		}
		else if(ab[0] == '\0')
			add_runs_with_no_extra(team1, team2, overall, info);
		else {			
			if(ab[0] == 'y' || ab[0] == 'n' || ab[0] == 'e') {
				add_runs_with_extra(team1, team2, overall, info);
			}
			else {
				move(0,28);
				printf("\e[1mbowled(b), caught(c), lbw(l), run out(r), retired hurt(h), heatwicket(t), time out(o)"  ANSI_COLOR_RESET);
				move(0, 29);
				wicket(team1, team2, overall, info);			
			}
		}
		if((overall->innings == 2) && overall->target <= 0) 
			break;			
	}
Beispiel #18
0
	virtual void Execute(const DataObject &object)
	{
		wxASSERT(3 <= object.numItems());

		wxInt32 tile, corner;
		boost::tie(tile, corner) = Utility::decodeSel(object.read<wxInt32>());
		wxInt32 player = object.read<wxInt32>(1);
		const HashString& type = object.read<HashString>(2);

		bool found = false;

		// First, see if there are even any extra objects here.
		PlayerGame::CornerObjectArray extras =
			playerGame(player).getCornerObjects(shExtra);
		PlayerGame::CornerObjectArray::const_iterator it, itEnd = extras.end();
		for(it = extras.begin(); it != itEnd; ++it)
		{
			CornerObjectPtr extra = (*it);
			if(true == extra->onTileCorner(std::make_pair(tile, corner)))
			{
				// Remove it.
				playerGame(player).removeCornerObject(shExtra, extra);
				found = true;
			}
		}

		if(true == found)
		{
			// If they have an extra, find the object that was built.
			CornerObjectPtr obj;
			const PlayerGame::CornerObjectArray& objects =
				playerGame(player).getCornerObjects(type);
			itEnd = objects.end();
			for(it = objects.begin(); it != itEnd; ++it)
			{
				CornerObjectPtr object = (*it);
				if(true == object->onTileCorner(std::make_pair(tile, corner)))
				{
					obj = object;
					break;
				}
			}
			wxASSERT(obj);

			// Add a new extra to replace the old one.
			wxInt32 turn = gameData<wxInt32>(shTurn);

			CornerObjectPtr extra(new ExtraObject(player, turn, CR_SIZE,
				GetGame(), tile, corner, obj));
			obj->below(extra);
			playerGame(player).addCornerObject(shExtra, extra);

			AggregatorObjectPtr aggregate(new AggregatorObject);
			aggregate->add(extra);

			Controller::get().Transmit(shEventGameObjects, aggregate);
		}
	}
Beispiel #19
0
void WorldSession::HandleSetCollisionHeightAck(WorldPacket& recvPacket)
{
    TC_LOG_DEBUG("network", "CMSG_MOVE_SET_COLLISION_HEIGHT_ACK");

    static MovementStatusElements const heightElement = MSEExtraFloat;
    Movement::ExtraMovementStatusElement extra(&heightElement);
    MovementInfo movementInfo;
    GetPlayer()->ReadMovementInfo(recvPacket, &movementInfo, &extra);
}
TEST(parse_tx_extra, handles_padding_only_max_size)
{
  std::vector<uint8_t> extra(TX_EXTRA_NONCE_MAX_COUNT, 0);
  std::vector<cryptonote::tx_extra_field> tx_extra_fields;
  ASSERT_TRUE(cryptonote::parse_tx_extra(extra, tx_extra_fields));
  ASSERT_EQ(1, tx_extra_fields.size());
  ASSERT_EQ(typeid(cryptonote::tx_extra_padding), tx_extra_fields[0].type());
  ASSERT_EQ(TX_EXTRA_NONCE_MAX_COUNT, boost::get<cryptonote::tx_extra_padding>(tx_extra_fields[0]).size);
}
Beispiel #21
0
void WorldSession::HandleSetCollisionHeightAck(WorldPacket& recvPacket)
{
	sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_MOVE_SET_COLLISION_HEIGHT_ACK");

	static MovementStatusElements const heightElement = MSEExtraFloat;
	Movement::ExtraMovementStatusElement extra(&heightElement);
	MovementInfo movementInfo;
	GetPlayer()->ReadMovementInfo(recvPacket, &movementInfo, &extra);
}
TEST(parse_tx_extra, handles_pub_key_only)
{
  const uint8_t extra_arr[] = {1, 30, 208, 98, 162, 133, 64, 85, 83, 112, 91, 188, 89, 211, 24, 131, 39, 154, 22, 228,
    80, 63, 198, 141, 173, 111, 244, 183, 4, 149, 186, 140, 230};
  std::vector<uint8_t> extra(&extra_arr[0], &extra_arr[0] + sizeof(extra_arr));
  std::vector<cryptonote::tx_extra_field> tx_extra_fields;
  ASSERT_TRUE(cryptonote::parse_tx_extra(extra, tx_extra_fields));
  ASSERT_EQ(1, tx_extra_fields.size());
  ASSERT_EQ(typeid(cryptonote::tx_extra_pub_key), tx_extra_fields[0].type());
}
TEST(parse_tx_extra, handles_padding_only_size_2)
{
  const uint8_t extra_arr[] = {0, 0};
  std::vector<uint8_t> extra(&extra_arr[0], &extra_arr[0] + sizeof(extra_arr));
  std::vector<cryptonote::tx_extra_field> tx_extra_fields;
  ASSERT_TRUE(cryptonote::parse_tx_extra(extra, tx_extra_fields));
  ASSERT_EQ(1, tx_extra_fields.size());
  ASSERT_EQ(typeid(cryptonote::tx_extra_padding), tx_extra_fields[0].type());
  ASSERT_EQ(2, boost::get<cryptonote::tx_extra_padding>(tx_extra_fields[0]).size);
}
Beispiel #24
0
QRectF ModelItem::boundingRect() const
{
    const QRectF &r = rect();
    const qreal &rx = r.x();
    const qreal &ry = r.y();
    const qreal &rw = r.width();
    const qreal &rh = r.height();

    const qreal &adjust = extra();
    return QRectF(rx-adjust, ry-adjust, rw+2*adjust, rh+2*adjust);
}
Beispiel #25
0
void parseargs(int argc, char *argv[])
{
	if (argc != 2 && argc != 3)
		goto usage;

#define extra(str) (argc == 3 && strcmp(argv[2], str) == 0)
#define noextra(cond) if (!(cond) && argc == 3) goto usage;
	if (strcmp(argv[1], "windowOnly") == 0) {
		noextra(FALSE);
		windowonly = TRUE;
		return;
	} else if (strcmp(argv[1], "drawingArea") == 0) {
		drawingarea = TRUE;
		viewport = extra("viewport");
		noextra(viewport);
		return;
	} else if (strcmp(argv[1], "layout") == 0) {
		binwin = extra("drawbin");
		drawsig = binwin || extra("draw");
		override = extra("override");
Beispiel #26
0
 void getDatabaseNames( vector< string > &names) {
     verify(Lock::isRW());
     // create a cursor on the tokumx directory and search for <database>.ns keys
     storage::DirectoryCursor c(storage::env, cc().txn().db_txn());
     getDatabaseNamesExtra extra(names);
     int r = 0;
     while (r == 0) {
         r = c.dbc()->c_getf_next(c.dbc(), 0, getDatabaseNamesCallback, &extra);
         if (r != 0 && r != DB_NOTFOUND)
             storage::handle_ydb_error(r);
     }
 }
Beispiel #27
0
QNetworkReply* 
lastfm::Track::updateNowPlaying( int duration ) const
{
    QMap<QString, QString> map = params("updateNowPlaying");
    map["duration"] = QString::number( duration );
    if ( !album().isNull() ) map["album"] = album();
    map["context"] = extra("playerId");

    qDebug() << map;

    return ws::post(map);
}
TEST(parse_tx_extra, handles_extra_nonce_only)
{
  const uint8_t extra_arr[] = {2, 1, 42};
  std::vector<uint8_t> extra(&extra_arr[0], &extra_arr[0] + sizeof(extra_arr));
  std::vector<cryptonote::tx_extra_field> tx_extra_fields;
  ASSERT_TRUE(cryptonote::parse_tx_extra(extra, tx_extra_fields));
  ASSERT_EQ(1, tx_extra_fields.size());
  ASSERT_EQ(typeid(cryptonote::tx_extra_nonce), tx_extra_fields[0].type());
  cryptonote::tx_extra_nonce extra_nonce = boost::get<cryptonote::tx_extra_nonce>(tx_extra_fields[0]);
  ASSERT_EQ(1, extra_nonce.nonce.size());
  ASSERT_EQ(42, extra_nonce.nonce[0]);
}
Beispiel #29
0
QSize DAbstractSliderSpinBox::sizeHint() const
{
    const Q_D(DAbstractSliderSpinBox);

    QStyleOptionSpinBox spinOpts = spinBoxOptions();
    QFont ft(font());

    if (d->style == DAbstractSliderSpinBoxPrivate::STYLE_NOQUIRK)
    {
        // Some styles use bold font in progressbars
        // unfortunately there is no reliable way to check for that
        ft.setBold(true);
    }

    QFontMetrics fm(ft);
    QSize hint(fm.boundingRect(d->prefix + QString::number(d->maximum) + d->suffix).size());
    hint += QSize(0, 2);

    switch (d->style)
    {
        case DAbstractSliderSpinBoxPrivate::STYLE_FUSION:
            hint += QSize(8, 8);
            break;
        case DAbstractSliderSpinBoxPrivate::STYLE_PLASTIQUE:
            hint += QSize(8, 0);
            break;
        case DAbstractSliderSpinBoxPrivate::STYLE_BREEZE:
            hint += QSize(2, 0);
            break;
        case DAbstractSliderSpinBoxPrivate::STYLE_NOQUIRK:
            // almost all "modern" styles have a margin around controls
            hint += QSize(6, 6);
            break;
        default:
            break;
    }

    // Getting the size of the buttons is a pain as the calcs require a rect
    // that is "big enough". We run the calc twice to get the "smallest" buttons
    // This code was inspired by QAbstractSpinBox
    QSize extra(1000, 0);
    spinOpts.rect.setSize(hint + extra);
    extra += hint - style()->subControlRect(QStyle::CC_SpinBox, &spinOpts,
                                            QStyle::SC_SpinBoxEditField, this).size();
    spinOpts.rect.setSize(hint + extra);
    extra += hint - style()->subControlRect(QStyle::CC_SpinBox, &spinOpts,
                                            QStyle::SC_SpinBoxEditField, this).size();
    hint += extra;

    spinOpts.rect.setSize(hint);
    return style()->sizeFromContents(QStyle::CT_SpinBox, &spinOpts, hint)
                                     .expandedTo(QApplication::globalStrut());
}
Beispiel #30
0
// (extra ['any ..]) -> any
any doExtra(any ex) {
   any x, y, cls, key;

   TheKey = Env.key;
   if ((y = extra(val(This)))  &&  num(y) != 1) {
      cls = Env.cls,  Env.cls = TheCls;
      key = Env.key,  Env.key = TheKey;
      x = evExpr(y, cdr(ex));
      Env.key = key,  Env.cls = cls;
      return x;
   }
   err(ex, TheKey, "Bad extra");
}