bool ParticleChannelInt::SetCount(int n)
{
	if (n < 0) return false;
	if (isGlobal()) _globalCount() = n;
	else _data().SetCount(n);
	return true;
}
Exemplo n.º 2
0
QSObject QSRegExpClass::fetchValue( const QSObject *objPtr,
				    const QSMember &mem ) const
{
    if ( mem.type() != QSMember::Custom )
	return QSWritableClass::fetchValue( objPtr, mem );

    QRegExp *re = regExp( objPtr );
    switch ( mem.index() ) {
    case Valid:
	return createBoolean( re->isValid() );
    case Empty:
	return createBoolean( re->isEmpty() );
    case MLength:
	return createNumber( re->matchedLength() );
    case Source:
	return createString( source(objPtr) );
    case Global:
	return createBoolean( isGlobal(objPtr) );
    case IgnoreCase:
	return createBoolean( isIgnoreCase(objPtr) );
    case CTexts: {
 	QSArray array( env() );
 	QStringList ct = re->capturedTexts();
 	QStringList::ConstIterator it = ct.begin();
 	int i = 0;
 	for ( ; it != ct.end(); ++it, ++i )
 	    array.put( QString::number( i ), createString( *it ) );
	array.put( QString::fromLatin1("length"), createNumber( i ) );
 	return array;
    }
    default:
	return createUndefined();
    }
}
bool ParticleChannelInt::Spawn(Tab<int>& spawnTable)
{
	SysUtil::NeedToImplementLater(); // optimize the implementation

	int i, checkCount = min(spawnTable.Count(), Count());

	if (isGlobal())
	{
		int newCount = 0;
		for(i=0; i<checkCount; i++)
			if (spawnTable[i] > 0) newCount += spawnTable[i];
		_globalCount() = newCount;
	}
	else
	{
		Tab<int> oldData(data());
		int j, k, newCount = 0;
		for(i=0; i<checkCount; i++)
			if (spawnTable[i] > 0) newCount += spawnTable[i];
		_data().SetCount(newCount);
		for(i=0, j=0; i<checkCount; i++)
			for(k=0; k<spawnTable[i]; k++)
				_data(j++) = oldData[i];
	}
	return true;
}
int ParticleChannelInt::Delete(BitArray& toRemove)
{	
	int checkCount = min(toRemove.GetSize(), Count());

	if (isGlobal())
	{
		// find number of set bit in the "count" range
		int numRemove = 0;
		for(int i=0; i<checkCount; i++)
			if (toRemove[i] != 0) numRemove++;
		_globalCount() -= numRemove;
		return globalCount();
	}
	else
	{
		int i, j;
		for (i = j = 0; i < data().Count(); i++) {
			if (i < checkCount && toRemove[i] != 0)
				continue;
			if (i != j)	_data(j) = data(i);
			j++;
		}
		if (j < data().Count())
			_data().SetCount(j);
		return data().Count();
	}
}
int ParticleChannelInt::GetValue() const
{
	if (isGlobal()) return globalValue();
	if (data().Count() <= 0) return 0;
	DbgAssert(data().Count()>0);
	return data(0);
}
Exemplo n.º 6
0
QString cs8Variable::documentation( bool withPrefix, bool forCOutput )
{
    QString out;
    QString prefix = withPrefix ? "///" : "";
    if ( m_description.isEmpty() )
        return QString();

    QStringList list = m_description.split( "\n" );

    //qDebug() << "documentation(): " << m_name << ":" << m_description;
    bool inCodeSection = false;
    bool firstLine = true;
    foreach( QString str, list )
    {
        if ( str.contains( "<code>" ) )
        {
            inCodeSection = true;
            out += prefix + "<br>\n";
        }
        if ( str.contains( "</code>" ) )
        {
            inCodeSection = false;
            out += prefix + "<br>\n";
        }
        out += (firstLine ? "" : prefix) + str + ( inCodeSection ? "<br>" : "" ) + "\n";
        firstLine = false;
    }
    //qDebug() << "processed: " << out;
    if ( !isGlobal() )
        return prefix + (forCOutput ? "@param " : "\\param ") + name() + " " + out + "\n";
    else
        return prefix+out;
}
Exemplo n.º 7
0
void MapSection::postParse(const INIConfigSection& section,
		ValidationList& validation) {
	// parse rotations
	rotations_set.clear();
	tile_sets.clear();
	std::string str = rotations.getValue();
	std::stringstream ss;
	ss << str;
	std::string elem;
	while (ss >> elem) {
		int r = stringToRotation(elem);
		if (r != -1) {
			rotations_set.insert(r);
			tile_sets.insert(getTileSet(r));
		} else {
			validation.error("Invalid rotation '" + elem + "'!");
		}
	}

	// check if required options were specified
	if (!isGlobal()) {
		world.require(validation, "You have to specify a world ('world')!");
		texture_dir.require(validation, "You have to specify a texture directory ('texture_dir')!");
	}
}
IObject*  ParticleChannelInt::Clone() const
{
	ParticleChannelInt* newChannel = (ParticleChannelInt*)CreateInstance(REF_TARGET_CLASS_ID, ParticleChannelInt_Class_ID);
	newChannel->CloneChannelCore((IParticleChannel*)this);
	newChannel->_globalCount() = globalCount();
	newChannel->_isGlobal() = isGlobal();
	newChannel->_globalValue() = globalValue();
	newChannel->_data() = data();	
	return newChannel;
}
void ParticleChannelInt::SetValue(int value)
{
	if (!isGlobal())
	{
		_isGlobal() = true;
		_globalCount() = data().Count();
		_data().Resize(0);
	}
	_globalValue() = value;
}
Exemplo n.º 10
0
QSObject QSRegExpClass::toStringScript( QSEnv *env )
{
    QSObject that = env->thisValue();
    Q_ASSERT(that.objectType() == env->regexpClass());
    QString pattern = QString::fromLatin1("/") + source(&that) + QString::fromLatin1("/");
    if (isIgnoreCase(&that))
	pattern += 'i';
    if (isGlobal(&that))
	pattern += 'g';
    return env->createString(pattern);
}
Exemplo n.º 11
0
void ParticleChannelInt::SetValue(int index, int value)
{
	if (isGlobal())
	{
		if (value == globalValue()) return; // nothing to change
		_isGlobal() = false;
		_data().SetCount(globalCount());
		for(int i=0; i<globalCount(); i++)
			_data(i) = globalValue();
	}
	DbgAssert((index>=0) && (index<data().Count()));
	_data(index) = value;
}
Exemplo n.º 12
0
WebSettingsPrivate::~WebSettingsPrivate()
{
    if (!isGlobal()) {
        size_t pos = WebSettings::pageGroupSettings(m_webCoreSettingsState->pageGroupName)->d->m_pageSettings.find(this);
        WebSettings::pageGroupSettings(m_webCoreSettingsState->pageGroupName)->d->m_pageSettings.remove(pos);
    }

    delete m_webCoreSettingsState;
    delete m_olympiaSettingsState;
    m_webCoreSettingsState = 0;
    m_olympiaSettingsState = 0;

    m_page = 0; // FIXME: We don't own this so perhaps it should be a RefPtr?
}
Exemplo n.º 13
0
void WorldSection::postParse(const INIConfigSection& section,
		ValidationList& validation) {
	if (default_zoom.isLoaded() && default_zoom.getValue() < 0)
		validation.error("The default zoom level must be bigger or equal to 0 ('default_zoom').");

	// validate the world croppping
	bool crop_rectangular = min_x.isLoaded() || max_x.isLoaded() || min_z.isLoaded() || max_z.isLoaded();
	bool crop_circular = center_x.isLoaded() || center_z.isLoaded() || radius.isLoaded();

	if (crop_rectangular && crop_circular) {
		validation.error("You can not use both world cropping types at the same time!");
	} else if (crop_rectangular) {
		if (min_x.isLoaded() && max_x.isLoaded() && min_x.getValue() > max_x.getValue())
			validation.error("min_x must be smaller than or equal to max_x!");
		if (min_z.isLoaded() && max_z.isLoaded() && min_z.getValue() > max_z.getValue())
			validation.error("min_z must be smaller than or equal to max_z!");
	} else if (crop_circular) {
		std::string message = "You have to specify crop_center_x, crop_center_z "
				"and crop_radius for circular world cropping!";
		center_x.require(validation, message)
			&& center_z.require(validation, message)
			&& radius.require(validation, message);

		world_crop.setCenter(mc::BlockPos(center_x.getValue(), center_z.getValue(), 0));
		world_crop.setRadius(radius.getValue());
	}

	if (min_y.isLoaded() && max_y.isLoaded() && min_y.getValue() > max_y.getValue())
		validation.error("min_y must be smaller than or equal to max_y!");

	world_crop.setCropUnpopulatedChunks(crop_unpopulated_chunks.getValue());
	if (block_mask.isLoaded()) {
		try {
			world_crop.loadBlockMask(block_mask.getValue());
		} catch (std::invalid_argument& exception) {
			validation.error(std::string("There is a problem parsing the block mask: ")
				+ exception.what());
		}
	}

	// check if required options were specified
	if (!isGlobal()) {
		input_dir.require(validation, "You have to specify an input directory ('input_dir')!");
	}
}
Exemplo n.º 14
0
DataHandler* AnyDimHandler::copy( unsigned short newParentDepth,
	unsigned short copyRootDepth,
	bool toGlobal, unsigned int n ) const
{
	if ( toGlobal ) {
		if ( !isGlobal() ) {
			cout << "Warning: AnyDimHandler::copy: Cannot copy from nonGlob    al to global\n";
			return 0;
		}
	}

	// Don't allow copying that would remove an array.
	for ( unsigned int i = 0; i < dims_.size(); ++i )
		if ( copyRootDepth > dims_[i].depth )
			return 0;

	if ( n > 1 ) {
		DimInfo temp = {n, newParentDepth + 1, 0 };
		vector< DimInfo > newDims;
		newDims.push_back( temp );
		for ( unsigned int i = 0; i < dims_.size(); ++i ) {
			newDims.push_back( dims_[i] );
			newDims.back().depth += 1 + newParentDepth - copyRootDepth;
		}
		AnyDimHandler* ret = new AnyDimHandler( dinfo(), 
			newDims, 
			1 + pathDepth() + newParentDepth - copyRootDepth, toGlobal );
		if ( data_ )  {
			ret->assign( data_, end_ - start_ );
		}
		return ret;
	} else {
		AnyDimHandler* ret = new AnyDimHandler( this ); 
		if ( !ret->changeDepth( 
				pathDepth() + 1 + newParentDepth - copyRootDepth
			) 
		) {
			delete ret;
			return 0;
		}
		return ret; 
	}
	return 0;
}
Exemplo n.º 15
0
void Element::putTargetsInDigest( 
				unsigned int srcNum, const MsgFuncBinding& mfb, 
				const FuncOrder& fo, 
			   vector< vector< bool > >& targetNodes )
// targetNodes[srcDataId][node]
{
	const Msg* msg = Msg::getMsg( mfb.mid );
	vector< vector < Eref > > erefs;
	if ( msg->e1() == this )
		msg->targets( erefs );
	else if ( msg->e2() == this )
		msg->sources( erefs );
	else
		assert( 0 );

	if ( Shell::numNodes() > 1 )
		filterOffNodeTargets( 
						localDataStart(), 
						localDataStart() + numLocalData(),
						isGlobal(), Shell::myNode(), 
						erefs, targetNodes );

	for ( unsigned int j = 0; j < erefs.size(); ++j ) {
		vector< MsgDigest >& md = 
			msgDigest_[ msgBinding_.size() * j + srcNum ];
		// k->func(); erefs[ j ];
		if ( md.size() == 0 || md.back().func != fo.func() ) {
			md.push_back( MsgDigest( fo.func(), erefs[j] ) );
			/*
			if ( md.back().targets.size() > 0 )
				cout << "putTargetsInDigest: " << md.back().targets[0] << 
					", eref = " << erefs[j][0] << endl;
			else
				cout << "putTargetsInDigest: empty\n";
			*/
		} else {
			md.back().targets.insert( md.back().targets.end(), 
					erefs[ j ].begin(),
					erefs[ j ].end() );
		}
	}
}
Exemplo n.º 16
0
bool QualifiedNameId::isEqualTo(const Name *other) const
{
    const QualifiedNameId *q = other->asQualifiedNameId();
    if (! q)
        return false;
    else if (isGlobal() != q->isGlobal())
        return false;
    else {
        const unsigned count = nameCount();
        if (count != q->nameCount())
            return false;
        for (unsigned i = 0; i < count; ++i) {
            Name *l = nameAt(i);
            Name *r = q->nameAt(i);
            if (! l->isEqualTo(r))
                return false;
        }
    }
    return true;
}
Exemplo n.º 17
0
int ParticleChannelInt::Delete(int start, int num)
{
	if (start < 0) {
		num += start;
		start = 0;
	}
	if (num <= 0)	return Count();

	if (isGlobal())
	{
		if (start < globalCount())
		{
			if ((start+num) >= globalCount()) _globalCount() = start;
			else _globalCount() -= num;
		}
		return globalCount();
	}
	else
		return _data().Delete(start,num);
}
Exemplo n.º 18
0
bool ParticleChannelInt::AppendNum(int num)
{
	if (num <= 0)	return true;

	if (isGlobal())
	{
		_globalCount() += num;
		return true;
	}

	int oldCount = data().Count();
	int newCount = oldCount + num;

	if (_data().Resize(newCount) == 0) return false;
	_data().SetCount(newCount);

	for(int i=oldCount; i<newCount; i++)
		_data(i) = 0;

	return true;
}
Exemplo n.º 19
0
DataHandler* TwoDimHandler::copy( 
	unsigned short newParentDepth,
	unsigned short copyRootDepth,
	bool toGlobal, unsigned int n ) const
{
	if ( toGlobal ) {
		if ( !isGlobal() ) {
			cout << "Warning: TwoDimHandler::copy: Cannot copy from nonGlob    al to global\n";
			return 0;
		}
	}
	if ( copyRootDepth > dims_[0].depth || copyRootDepth >= dims_[1].depth)
		return 0;

	if ( n > 1 ) {
		DimInfo temp = {n, newParentDepth + 1, 0 };
		vector< DimInfo > newDims;
		newDims.push_back( temp );
		newDims.push_back( dims_[0] );
		newDims.back().depth += 1 + newParentDepth - copyRootDepth;
		newDims.push_back( dims_[1] );
		newDims.back().depth += 1 + newParentDepth - copyRootDepth;
		AnyDimHandler* ret = new AnyDimHandler( dinfo(), 
			newDims, 
			1 + pathDepth() + newParentDepth - copyRootDepth, toGlobal );
		if ( data_ )  {
			ret->assign( data_, end_ - start_ );
		}
		return ret;
	} else {
		TwoDimHandler* ret = new TwoDimHandler( this );
		if ( !ret->changeDepth( pathDepth() + 1 + newParentDepth - copyRootDepth ) ) {
			delete ret;
			return 0;
		}
		return ret;
	}
	return 0;
}
Exemplo n.º 20
0
IOResult ParticleChannelInt::Save(ISave* isave) const
{
	ULONG nb;
	IOResult res;
	int num;

	isave->BeginChunk(IParticleChannel::kChunkCount);
	num = data().Count();
	if ((res = isave->Write(&num, sizeof(int), &nb)) != IO_OK) return res;
	isave->EndChunk();

	if (num > 0)
	{
		isave->BeginChunk(IParticleChannel::kChunkData);
		if ((res = isave->Write(data().Addr(0), sizeof(int)*num, &nb)) != IO_OK) return res;
		isave->EndChunk();
	}

	isave->BeginChunk(IParticleChannel::kChunkGlobalCount);
	num = globalCount();
	if ((res = isave->Write(&num, sizeof(int), &nb)) != IO_OK) return res;
	isave->EndChunk();

	isave->BeginChunk(IParticleChannel::kChunkGlobalValue);
	int v = globalValue();
	if ((res = isave->Write(&v, sizeof(int), &nb)) != IO_OK) return res;
	isave->EndChunk();

	Interface_ID id;
	isave->BeginChunk(IParticleChannel::kChunkReadID);
	id = GetReadID();
	if ((res = isave->Write(&id, sizeof(Interface_ID), &nb)) != IO_OK) return res;
	isave->EndChunk();

	isave->BeginChunk(IParticleChannel::kChunkWriteID);
	id = GetWriteID();
	if ((res = isave->Write(&id, sizeof(Interface_ID), &nb)) != IO_OK) return res;
	isave->EndChunk();

	isave->BeginChunk(IParticleChannel::kChunkTransferable);
	bool isTransferable = IsTransferable();
	if ((res = isave->Write(&isTransferable, sizeof(bool), &nb)) != IO_OK) return res;
	isave->EndChunk();

	isave->BeginChunk(IParticleChannel::kChunkPrivate);
	bool isPrivate = IsPrivateChannel();
	if ((res = isave->Write(&isPrivate, sizeof(bool), &nb)) != IO_OK) return res;
	isave->EndChunk();

	isave->BeginChunk(IParticleChannel::kChunkActionHandle);
	ULONG handle = m_creatorHandle;
	if ((res = isave->Write(&handle, sizeof(ULONG), &nb)) != IO_OK) return res;
	isave->EndChunk();

	isave->BeginChunk(IParticleChannel::kChunkValue1);
	bool isg = isGlobal();
	if ((res = isave->Write(&isg, sizeof(bool), &nb)) != IO_OK) return res;
	isave->EndChunk();

	return IO_OK;
}
Exemplo n.º 21
0
std::string MarkerSection::getPrettyName() const {
	if (isGlobal())
		return "Global marker section";
	return "Marker section '" + getSectionName() + "'";
}
Exemplo n.º 22
0
std::string WorldSection::getPrettyName() const {
	if (isGlobal())
		return "Global world section";
	return "World section '" + getSectionName() + "'";
}
Exemplo n.º 23
0
void KNotify::notify(const QString &event, const QString &fromApp, const QString &text, QString sound, QString file, int present, int level,
                     int winId, int eventId)
{
    // kdDebug() << "event=" << event << " fromApp=" << fromApp << " text=" << text << " sound=" << sound <<
    //    " file=" << file << " present=" << present << " level=" << level <<  " winId=" << winId << " eventId=" << eventId << endl;
    if(d->inStartup)
    {
        d->startupEvents += "(" + event + ":" + fromApp + ")";
    }

    QString commandline;
    KConfig *eventsFile = NULL;
    KConfig *configFile = NULL;

    // check for valid events
    if(!event.isEmpty())
    {

        // get config file
        if(d->events.contains(fromApp))
        {
            eventsFile = d->events[fromApp];
        }
        else
        {
            eventsFile = new KConfig(locate("data", fromApp + "/eventsrc"), true, false);
            d->events.insert(fromApp, eventsFile);
        }
        if(d->configs.contains(fromApp))
        {
            configFile = d->configs[fromApp];
        }
        else
        {
            configFile = new KConfig(fromApp + ".eventsrc", true, false);
            d->configs.insert(fromApp, configFile);
        }

        if(!eventsFile->hasGroup(event) && isGlobal(event))
        {
            eventsFile = d->globalEvents;
            configFile = d->globalConfig;
        }

        eventsFile->setGroup(event);
        configFile->setGroup(event);

        // get event presentation
        if(present == -1)
            present = configFile->readNumEntry("presentation", -1);
        if(present == -1)
            present = eventsFile->readNumEntry("default_presentation", 0);

        // get sound file name
        if(present & KNotifyClient::Sound)
        {
            QString theSound = configFile->readPathEntry("soundfile");
            if(theSound.isEmpty())
                theSound = eventsFile->readPathEntry("default_sound");
            if(!theSound.isEmpty())
                sound = theSound;
        }

        // get log file name
        if(present & KNotifyClient::Logfile)
        {
            QString theFile = configFile->readPathEntry("logfile");
            if(theFile.isEmpty())
                theFile = eventsFile->readPathEntry("default_logfile");
            if(!theFile.isEmpty())
                file = theFile;
        }

        // get default event level
        if(present & KNotifyClient::Messagebox)
            level = eventsFile->readNumEntry("level", 0);

        // get command line
        if(present & KNotifyClient::Execute)
        {
            commandline = configFile->readPathEntry("commandline");
            if(commandline.isEmpty())
                commandline = eventsFile->readPathEntry("default_commandline");
        }
    }

    // emit event
    if(present & KNotifyClient::Sound) // && QFile(sound).isReadable()
        notifyBySound(sound, fromApp, eventId);

    if(present & KNotifyClient::Execute)
        notifyByExecute(commandline, event, fromApp, text, winId, eventId);

    if(present & KNotifyClient::Logfile) // && QFile(file).isWritable()
        notifyByLogfile(text, file);

    if(present & KNotifyClient::Stderr)
        notifyByStderr(text);

    if(present & KNotifyClient::Taskbar)
        notifyByTaskbar(checkWinId(fromApp, winId));

    if(present & KNotifyClient::PassivePopup)
        notifyByPassivePopup(text, fromApp, eventsFile, checkWinId(fromApp, winId));
    else if(present & KNotifyClient::Messagebox)
        notifyByMessagebox(text, level, checkWinId(fromApp, winId));

    QByteArray qbd;
    QDataStream ds(qbd, IO_WriteOnly);
    ds << event << fromApp << text << sound << file << present << level << winId << eventId;
    emitDCOPSignal("notifySignal(QString,QString,QString,QString,QString,int,int,int,int)", qbd);
}
Exemplo n.º 24
0
bool ParticleChannelInt::IsGlobal() const
{
	return isGlobal();
}
Exemplo n.º 25
0
int ParticleChannelInt::GetValue(int index) const
{
	if (isGlobal()) return globalValue();
	DbgAssert((index>=0) && (index<data().Count()));
	return data(index);
}
void UnusedGlobalVarOptimizer::visit(ShPtr<Variable> var) {
	if (isGlobal(var)) {
		usedGlobalVars.insert(var);
	}
}
Exemplo n.º 27
0
bool Variable::put(types::InternalType* _pIT, int _iLevel)
{
    if (isGlobal() && isGlobalVisible(_iLevel))
    {
        setGlobalValue(_pIT);
        return true;
    }

    if (empty() || top()->m_iLevel < _iLevel)
    {
        //create a new level
        last = new ScopedVariable(_iLevel, _pIT);
        stack.push(last);
        _pIT->IncreaseRef();
    }
    else
    {
        //update current level
        types::InternalType* pIT = top()->m_pIT;
        if (pIT != _pIT)
        {
            //check macro redefinition
            if (_pIT->isMacro())
            {
                int iFuncProt = ConfigVariable::getFuncprot();
                if (iFuncProt != 0)
                {
                    bool bEquals = true;
                    if (pIT && pIT->isCallable())
                    {
                        if (pIT->isMacroFile())
                        {
                            types::MacroFile* pMF = pIT->getAs<types::MacroFile>();
                            bEquals = *pMF->getMacro() == *_pIT;
                        }
                        else if (pIT->isMacro())
                        {
                            types::Macro* pM = pIT->getAs<types::Macro>();
                            bEquals = *pM == *_pIT;
                        }
                    }

                    if (bEquals == false)
                    {
                        if (iFuncProt == 2)
                        {
                            return false;
                        }

                        if (ConfigVariable::getWarningMode())
                        {
                            wchar_t pwstFuncName[1024];
                            os_swprintf(pwstFuncName, 1024, L"%-24ls", name.getName().c_str());
                            char* pstFuncName = wide_string_to_UTF8(pwstFuncName);

                            sciprint(_("Warning : redefining function: %s. Use funcprot(0) to avoid this message"), pstFuncName);
                            sciprint("\n");
                            FREE(pstFuncName);
                        }
                    }
                }
            }

            // _pIT may contained in pIT
            // so increases ref of _pIT before kill pIT
            top()->m_pIT = _pIT;
            _pIT->IncreaseRef();
            pIT->DecreaseRef();
            pIT->killMe();
        }
    }

    return true;
}
Exemplo n.º 28
0
const pyglobal* pybase::asGlobal() const {
	assert(isGlobal());
	return (reinterpret_cast<const pyglobal*>(this));
}
Exemplo n.º 29
0
void ParticleChannelInt::ZeroCount()
{
	if (isGlobal()) _globalCount() = 0;
	else _data().ZeroCount();
}
Exemplo n.º 30
0
int ParticleChannelInt::Count() const
{
	if (isGlobal()) return globalCount();
	return data().Count();
}