mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-03 03:01:44 +00:00
Miscellaneous cleanups for HAL, wpilibc, and wpilibj JNI (#589)
* Static functions in the HAL implementation were placed in the hal namespace * "using namespace" declarations in HAL/cpp/Log.h and Timer.cpp were replaced with "using" declarations for std::chrono * An extra include was removed from AnalogGyro.cpp * InterruptableSensorBase's constructor was defaulted * Newlines were added to some wpilibc integration tests for grouping * A variable in HALUtil.h was renamed to follow the style guide Supersedes #586
This commit is contained in:
committed by
Peter Johnson
parent
5e19c1881f
commit
d682295ccd
@@ -86,13 +86,13 @@ constexpr const char JNI_wpilibjPrefix[] = "edu.wpi.first.wpilibj";
|
||||
extern const char JNI_wpilibjPrefix[] = "edu.wpi.first.wpilibj";
|
||||
#endif
|
||||
|
||||
void ReportError(JNIEnv *env, int32_t status, bool do_throw) {
|
||||
void ReportError(JNIEnv *env, int32_t status, bool doThrow) {
|
||||
if (status == 0) return;
|
||||
if (status == HAL_HANDLE_ERROR) {
|
||||
ThrowHalHandleException(env, status);
|
||||
}
|
||||
const char *message = HAL_GetErrorMessage(status);
|
||||
if (do_throw && status < 0) {
|
||||
if (doThrow && status < 0) {
|
||||
llvm::SmallString<1024> buf;
|
||||
llvm::raw_svector_ostream oss(buf);
|
||||
oss << " Code: " << status << ". " << message;
|
||||
|
||||
@@ -16,13 +16,13 @@ extern JavaVM *jvm;
|
||||
|
||||
namespace frc {
|
||||
|
||||
void ReportError(JNIEnv *env, int32_t status, bool do_throw = true);
|
||||
void ReportError(JNIEnv *env, int32_t status, bool doThrow = true);
|
||||
|
||||
void ThrowError(JNIEnv *env, int32_t status, int32_t minRange, int32_t maxRange,
|
||||
int32_t requestedValue);
|
||||
|
||||
inline bool CheckStatus(JNIEnv *env, int32_t status, bool do_throw = true) {
|
||||
if (status != 0) ReportError(env, status, do_throw);
|
||||
inline bool CheckStatus(JNIEnv *env, int32_t status, bool doThrow = true) {
|
||||
if (status != 0) ReportError(env, status, doThrow);
|
||||
return status == 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ Java_edu_wpi_first_wpilibj_hal_SolenoidJNI_initializeSolenoidPort(
|
||||
|
||||
// Use solenoid channels, as we have to pick one.
|
||||
CheckStatusRange(env, status, 0, HAL_GetNumSolenoidChannels(),
|
||||
hal::getPortHandleChannel((HAL_PortHandle)id));;
|
||||
hal::getPortHandleChannel((HAL_PortHandle)id));
|
||||
return (jint)handle;
|
||||
}
|
||||
|
||||
|
||||
@@ -70,4 +70,4 @@ JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_ThreadsJNI_setCurrentT
|
||||
return (jboolean)ret;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user