Beispiel #1
0
void JPArray::setRange(int start, int stop, vector<HostRef*>& val)
{
	JPCleaner cleaner;
	
	JPType* compType = m_Class->getComponentType();
	
	if(stop < start)
	{
		std::stringstream out;
		out << "Slice start (" << start << ") is greater than stop ("
			<< stop << ")";
		RAISE(JPypeException, out.str());
	}

	unsigned int len = stop-start;
	size_t plength = val.size();
	
	if (len != plength)
	{
		std::stringstream out;
		out << "Slice assignment must be of equal lengths : " << len << " != " << plength;
		RAISE(JPypeException, out.str());
	}

	for (size_t i = 0; i < plength; i++)
	{
		HostRef* v = val[i];
		if ( compType->canConvertToJava(v)<= _explicit)
		{
			RAISE(JPypeException, "Unable to convert.");
		}
	}	
			
	compType->setArrayRange(m_Object, start, stop-start, val);
}	
Beispiel #2
0
void JPArray::setRange(int start, int stop, PyObject* sequence)
{
	JPType* compType = m_Class->getComponentType();

	unsigned int len = stop-start;
	// check bounds of sequence which is to be assigned
	HostRef* ptr = new HostRef(sequence);
	unsigned int plength = JPEnv::getHost()->getSequenceLength(ptr);
	delete ptr;
	if (len != plength)
	{
		std::stringstream out;
		out << "Slice assignment must be of equal lengths : " << len << " != " << plength;
		RAISE(JPypeException, out.str());
	}

	compType->setArrayRange(m_Object, start, len, sequence);
}