예제 #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);
}	
예제 #2
0
파일: jp_array.cpp 프로젝트: jaheba/jpype
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);
}