Changes HAL Port from a pointer to a handle (#93)

HAL Port is using a special handle, where the module and pin are bit
shifted straight into the handle. This is one of the few special cases
we have, but for the way port is used it is much cleaner and uses much
less memory.  Plus it is generic and not specific to one type.
This commit is contained in:
Thad House
2016-06-05 15:23:58 -07:00
committed by Peter Johnson
parent 5a82f73d9b
commit fc515f4572
44 changed files with 288 additions and 233 deletions

View File

@@ -18,46 +18,46 @@ extern "C" {
/*
* Class: edu_wpi_first_wpilibj_hal_JNIWrapper
* Method: getPortWithModule
* Signature: (BB)J
* Signature: (BB)I
*/
JNIEXPORT jlong JNICALL
JNIEXPORT jint JNICALL
Java_edu_wpi_first_wpilibj_hal_JNIWrapper_getPortWithModule(
JNIEnv* env, jclass, jbyte module, jbyte pin) {
// FILE_LOG(logDEBUG) << "Calling JNIWrapper getPortWithModlue";
// FILE_LOG(logDEBUG) << "Module = " << (jint)module;
// FILE_LOG(logDEBUG) << "Pin = " << (jint)pin;
void* port = getPortWithModule(module, pin);
// FILE_LOG(logDEBUG) << "Port Ptr = " << port;
return (jlong)port;
HalPortHandle port = getPortWithModule(module, pin);
// FILE_LOG(logDEBUG) << "Port Handle = " << port;
return (jint)port;
}
/*
* Class: edu_wpi_first_wpilibj_hal_JNIWrapper
* Method: getPort
* Signature: (BB)J
* Signature: (B)I
*/
JNIEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_JNIWrapper_getPort(
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_JNIWrapper_getPort(
JNIEnv* env, jclass, jbyte pin) {
// FILE_LOG(logDEBUG) << "Calling JNIWrapper getPortWithModlue";
// FILE_LOG(logDEBUG) << "Module = " << (jint)module;
// FILE_LOG(logDEBUG) << "Pin = " << (jint)pin;
void* port = getPort(pin);
// FILE_LOG(logDEBUG) << "Port Ptr = " << port;
return (jlong)port;
HalPortHandle port = getPort(pin);
// FILE_LOG(logDEBUG) << "Port Handle = " << port;
return (jint)port;
}
/*
* Class: edu_wpi_first_wpilibj_hal_JNIWrapper
* Method: freePort
* Signature: (J)V
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_JNIWrapper_freePort(
JNIEnv* env, jclass, jlong id) {
JNIEnv* env, jclass, jint id) {
// FILE_LOG(logDEBUG) << "Calling JNIWrapper getPortWithModlue";
// FILE_LOG(logDEBUG) << "Module = " << (jint)module;
// FILE_LOG(logDEBUG) << "Pin = " << (jint)pin;
freePort((void*)id);
// FILE_LOG(logDEBUG) << "Port Ptr = " << port;
freePort((HalPortHandle)id);
// FILE_LOG(logDEBUG) << "Port Handle = " << port;
}
} // extern "C"