2008-05-22 15:50:10 +00:00
|
|
|
/*
|
|
|
|
---------------------------------------------------------------------------
|
|
|
|
Open Asset Import Library (ASSIMP)
|
|
|
|
---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
Copyright (c) 2006-2008, ASSIMP Development Team
|
|
|
|
|
|
|
|
All rights reserved.
|
2008-09-27 16:46:05 +00:00
|
|
|
See the disclaimer in JNIEnvironment.h for licensing and distribution
|
|
|
|
conditions.
|
2008-05-22 15:50:10 +00:00
|
|
|
---------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
2008-08-07 22:55:02 +00:00
|
|
|
/** @file Implementation of the JNI API for jAssimp */
|
2008-05-22 15:50:10 +00:00
|
|
|
|
2008-08-07 22:55:02 +00:00
|
|
|
#include "JNIEnvironment.h"
|
|
|
|
#include "JNILogger.h"
|
2008-05-22 15:50:10 +00:00
|
|
|
|
2008-08-07 22:55:02 +00:00
|
|
|
using namespace Assimp;
|
2008-05-22 15:50:10 +00:00
|
|
|
|
2008-08-07 22:55:02 +00:00
|
|
|
namespace Assimp {
|
|
|
|
namespace JNIBridge {
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2008-09-27 16:46:05 +00:00
|
|
|
void JNIEnvironment::_assimp::_NativeException::Initialize()
|
2008-08-07 22:55:02 +00:00
|
|
|
{
|
|
|
|
// get a handle to the JNI context for this thread
|
2008-09-27 16:46:05 +00:00
|
|
|
JNIEnv* pc = JNIEnvironment::Get()->GetThread()->m_pcEnv;
|
2008-08-07 22:55:02 +00:00
|
|
|
|
|
|
|
// load a handle to the class
|
|
|
|
if(!(this->Class = pc->FindClass("assimp.NativeException")))
|
|
|
|
{
|
|
|
|
// if this fails we have no exception class we could use ...
|
|
|
|
// throw an java.lang.Error instance
|
|
|
|
this->Class = pc->FindClass("java.lang.Exception");
|
|
|
|
pc->ThrowNew(this->Class,"Unable to load class assimp.NativeException (severe failure!)");
|
|
|
|
this->Class = NULL;
|
|
|
|
}
|
2008-05-22 15:50:10 +00:00
|
|
|
}
|
2008-08-07 22:55:02 +00:00
|
|
|
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
void JNIEnvironment::ThrowNativeError(const char* msg /*= NULL*/)
|
|
|
|
{
|
|
|
|
// get a handle to the JNI context for this thread
|
|
|
|
JNIEnv* pc = this->GetThread()->m_pcEnv;
|
|
|
|
|
|
|
|
// throw a new NativeException
|
|
|
|
pc->ThrowNew(this->assimp.NativeException.Class,
|
|
|
|
msg ? msg
|
|
|
|
: "An unspecified error occured in the native interface to Assimp.");
|
2008-09-27 16:46:05 +00:00
|
|
|
}
|
|
|
|
}}
|