Пример #1
0
HostRef* JPObjectType::getInstanceValue(jobject c, jfieldID fid, JPTypeName& tgtType) 
{
	TRACE_IN("JPObjectType::getInstanceValue");
	JPCleaner cleaner;
	jobject r = JPEnv::getJava()->GetObjectField(c, fid);
	cleaner.addLocal(r);

	jvalue v;
	v.l = r;
	
	JPTypeName name = JPJni::getClassName(v.l);
	JPType* type = JPTypeManager::getType(name);
	return type->asHostObject(v);

	TRACE_OUT;
}
Пример #2
0
HostRef* JPObjectType::invokeStatic(jclass claz, jmethodID mth, jvalue* val)
{
	TRACE_IN("JPObjectType::invokeStatic");
	JPCleaner cleaner;
	
	jobject res = JPEnv::getJava()->CallStaticObjectMethodA(claz, mth, val);
	cleaner.addLocal(res);

	jvalue v;
	v.l = res;

	JPTypeName name = JPJni::getClassName(v.l);
	JPType* type = JPTypeManager::getType(name);
	return type->asHostObject(v);

	TRACE_OUT;
}
Пример #3
0
HostRef* JPClass::asHostObject(jvalue obj) 
{
	TRACE_IN("JPClass::asPyObject");
	if (obj.l == NULL)
	{
		return JPEnv::getHost()->getNone();
	}

	JPTypeName name = JPJni::getClassName(obj.l);
	if (name.getType() ==JPTypeName::_array)
	{
		JPType* arrayType = JPTypeManager::getType(name);
		return arrayType->asHostObject(obj);
	}
	
	return JPEnv::getHost()->newObject(new JPObject(name, obj.l));
	TRACE_OUT;
}
Пример #4
0
HostRef* JPObjectType::invoke(jobject claz, jclass clazz, jmethodID mth, jvalue* val)
{
	TRACE_IN("JPObjectType::invoke");
	JPCleaner cleaner;

	jobject res = JPEnv::getJava()->CallNonvirtualObjectMethodA(claz, clazz, mth, val);
	cleaner.addLocal(res);

	jvalue v;
	v.l = res;

	JPTypeName name = JPJni::getClassName(v.l);
	JPType* type = JPTypeManager::getType(name);
	HostRef* ref = type->asHostObject(v);
	TRACE1("Successfulyl converted to host reference");
	return ref;
	
	TRACE_OUT;
}
Пример #5
0
HostRef* JPObjectType::getArrayItem(jarray a, int ndx)
{
	TRACE_IN("JPObjectType::getArrayItem");
	jobjectArray array = (jobjectArray)a;	
	JPCleaner cleaner;
	
	jobject obj = JPEnv::getJava()->GetObjectArrayElement(array, ndx);
	cleaner.addLocal(obj);
	
	if (obj == NULL)
	{
		return JPEnv::getHost()->getNone();
	}
	
	jvalue v;
	v.l = obj;

	JPTypeName name = JPJni::getClassName(v.l);
	JPType* t = JPTypeManager::getType(name);
	
	return t->asHostObject(v);
	TRACE_OUT;
}
Пример #6
0
vector<HostRef*> JPObjectType::getArrayRange(jarray a, int start, int length)
{
	jobjectArray array = (jobjectArray)a;	
	JPCleaner cleaner;
	
	vector<HostRef*> res;
	
	jvalue v;
	for (int i = 0; i < length; i++)
	{
		v.l = JPEnv::getJava()->GetObjectArrayElement(array, i+start);
		cleaner.addLocal(v.l);

		JPTypeName name = JPJni::getClassName(v.l);
		JPType* t = JPTypeManager::getType(name);
		
		HostRef* pv = t->asHostObject(v);		

		res.push_back(pv);
	}
	
	return res;  
}