Beispiel #1
0
void convert__long_array(long& java_value, long& cxx_value, const CXXTypeHierarchy cxx_type_hierarchy, const converter_t& converter_type, std::stack<long>& converter_stack)
{
	JNIContext *jni = JNIContext::sharedInstance();

	if (converter_type == CONVERT_TO_JAVA)
	{
		jni->pushLocalFrame();
		cxx_converter item_converter = get_converter(converter_stack);
		std::vector<long> *cxx_vector = (std::vector<long> *) cxx_value;
		int count = cxx_vector->size();
		long java_array[count];
		int item_idx = 0;
		for(std::vector<long>::iterator it = cxx_vector->begin(); it != cxx_vector->end(); ++it)
		{
			long item = (long) *it;
			java_array[item_idx++] = item;
		}
		java_value = (long) jni->createLongArray(*java_array, count);
		java_value = (long) jni->popLocalFrame((jobject) java_value);
	}
	else if (converter_type == CONVERT_TO_CXX)
	{
		jni->pushLocalFrame();
		cxx_converter item_converter = get_converter(converter_stack);
		std::vector<long> *cxx_vector = new std::vector<long>();
		int count = (int) jni->getArrayLength((jarray) java_value);
		long * java_array = jni->getLongArray((jlongArray) java_value);
		for (int idx = 0 ; idx < count; idx++)
		{
			long item = (long) java_array[idx];
			cxx_vector->push_back(item);
		}
		cxx_value = (long) cxx_vector;
		jni->popLocalFrame();
	}
}