Esempio n. 1
0
void ArrayInstanceImp::setLength(unsigned newLength, ExecState *exec)
{
    if(newLength <= storageLength)
    {
        resizeStorage(newLength);
    }

    if(newLength < length)
    {
        ReferenceList sparseProperties;

        _prop.addSparseArrayPropertiesToReferenceList(sparseProperties, Object(this));

        ReferenceListIterator it = sparseProperties.begin();
        while(it != sparseProperties.end())
        {
            Reference ref = it++;
            bool ok;
            unsigned index = ref.getPropertyName(exec).toArrayIndex(&ok);
            if(ok && index > newLength)
            {
                ref.deleteValue(exec);
            }
        }
    }

    length = newLength;
}
Esempio n. 2
0
vector<NetworkID> GameFactory::GetIDObjectTypes(unsigned char type) noexcept
{
	vector<NetworkID> result;
	ReferenceList::iterator it;

	cs.StartSession();

	result.reserve(typecount[type]);
	ReferenceList copy = instances;

	cs.EndSession();

	for (it = copy.begin(); it != copy.end(); ++it)
		if (it->second & type)
			result.emplace_back(it->first->GetNetworkID());

	return result;
}
vector<FactoryObject> GameFactory::GetObjectTypes(unsigned char type) noexcept
{
	vector<FactoryObject> result;
	ReferenceList::iterator it;

	cs.StartSession();

	result.reserve(typecount[type]);
	ReferenceList copy = instances;

	cs.EndSession();

	for (it = copy.begin(); it != copy.end(); ++it)
		if (it->second & type)
			result.push_back(FactoryObject(it->first));

	return result;
}
Esempio n. 4
0
unsigned ArrayInstanceImp::pushUndefinedObjectsToEnd(ExecState *exec)
{
    ValueImp *undefined = UndefinedImp::staticUndefined;

    unsigned o = 0;

    for(unsigned i = 0; i != storageLength; ++i)
    {
        ValueImp *v = storage[i];
        if(v && v != undefined)
        {
            if(o != i)
                storage[o] = v;
            o++;
        }
    }

    ReferenceList sparseProperties;
    _prop.addSparseArrayPropertiesToReferenceList(sparseProperties, Object(this));
    unsigned newLength = o + sparseProperties.length();

    if(newLength > storageLength)
    {
        resizeStorage(newLength);
    }

    ReferenceListIterator it = sparseProperties.begin();
    while(it != sparseProperties.end())
    {
        Reference ref = it++;
        storage[o] = ref.getValue(exec).imp();
        ObjectImp::deleteProperty(exec, ref.getPropertyName(exec));
        o++;
    }

    if(newLength != storageLength)
        memset(storage + o, 0, sizeof(ValueImp *) * (storageLength - o));

    return o;
}
Esempio n. 5
0
vector<FactoryObject> GameFactory::GetObjectTypes(unsigned char type) noexcept
{
	vector<FactoryObject> result;
	ReferenceList::iterator it;

	cs.StartSession();

	result.reserve(typecount[type]);
	ReferenceList copy = instances;

	cs.EndSession();

	for (it = copy.begin(); it != copy.end(); ++it)
		if (it->second & type)
			try
			{
				result.emplace_back(FactoryObject(it->first.get(), it->second));
			}
			catch (...) { continue; }

	return result;
}