[hal] Move JNI helpers and sim namespace to hal namespace (#2543)

This commit is contained in:
Peter Johnson
2020-06-26 17:12:55 -07:00
committed by GitHub
parent 3cbec411c7
commit 8a80f97c06
60 changed files with 158 additions and 91 deletions

View File

@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
@@ -11,6 +11,8 @@
#include "edu_wpi_first_hal_sim_mockdata_AccelerometerDataJNI.h"
#include "mockdata/AccelerometerData.h"
using namespace hal;
extern "C" {
/*

View File

@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2019 FIRST. All Rights Reserved. */
/* Copyright (c) 2019-2020 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
@@ -14,6 +14,7 @@
static_assert(sizeof(jbyte) * 4 == sizeof(HAL_AddressableLEDData));
using namespace hal;
using namespace wpi::java;
extern "C" {

View File

@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
@@ -11,6 +11,8 @@
#include "edu_wpi_first_hal_sim_mockdata_AnalogGyroDataJNI.h"
#include "mockdata/AnalogGyroData.h"
using namespace hal;
extern "C" {
/*

View File

@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
@@ -11,6 +11,8 @@
#include "edu_wpi_first_hal_sim_mockdata_AnalogInDataJNI.h"
#include "mockdata/AnalogInData.h"
using namespace hal;
extern "C" {
/*

View File

@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
@@ -11,6 +11,8 @@
#include "edu_wpi_first_hal_sim_mockdata_AnalogOutDataJNI.h"
#include "mockdata/AnalogOutData.h"
using namespace hal;
extern "C" {
/*

View File

@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
@@ -11,6 +11,8 @@
#include "edu_wpi_first_hal_sim_mockdata_AnalogTriggerDataJNI.h"
#include "mockdata/AnalogTriggerData.h"
using namespace hal;
extern "C" {
/*

View File

@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018-2019 FIRST. All Rights Reserved. */
/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
@@ -17,13 +17,15 @@
#include "hal/handles/UnlimitedHandleResource.h"
#include "mockdata/NotifyListener.h"
using namespace hal;
using namespace hal::sim;
using namespace wpi::java;
using namespace sim;
static hal::UnlimitedHandleResource<SIM_JniHandle, BufferCallbackStore,
hal::HAL_HandleEnum::SimulationJni>*
callbackHandles;
namespace hal {
namespace sim {
void InitializeBufferStore() {
static hal::UnlimitedHandleResource<SIM_JniHandle, BufferCallbackStore,
@@ -32,6 +34,7 @@ void InitializeBufferStore() {
callbackHandles = &cb;
}
} // namespace sim
} // namespace hal
void BufferCallbackStore::create(JNIEnv* env, jobject obj) {
m_call = JGlobal<jobject>(env, obj);

View File

@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018-2019 FIRST. All Rights Reserved. */
/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
@@ -17,6 +17,7 @@
#include "hal/handles/UnlimitedHandleResource.h"
#include "mockdata/NotifyListener.h"
namespace hal {
namespace sim {
class BufferCallbackStore {
public:
@@ -43,3 +44,4 @@ SIM_JniHandle AllocateBufferCallback(JNIEnv* env, jint index, jobject callback,
void FreeBufferCallback(JNIEnv* env, SIM_JniHandle handle, jint index,
FreeBufferCallbackFunc freeCallback);
} // namespace sim
} // namespace hal

View File

@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018-2019 FIRST. All Rights Reserved. */
/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
@@ -17,13 +17,15 @@
#include "hal/handles/UnlimitedHandleResource.h"
#include "mockdata/NotifyListener.h"
using namespace hal;
using namespace hal::sim;
using namespace wpi::java;
using namespace sim;
static hal::UnlimitedHandleResource<SIM_JniHandle, CallbackStore,
hal::HAL_HandleEnum::SimulationJni>*
callbackHandles;
namespace hal {
namespace sim {
void InitializeStore() {
static hal::UnlimitedHandleResource<SIM_JniHandle, CallbackStore,
@@ -32,6 +34,7 @@ void InitializeStore() {
callbackHandles = &cb;
}
} // namespace sim
} // namespace hal
void CallbackStore::create(JNIEnv* env, jobject obj) {
m_call = JGlobal<jobject>(env, obj);

View File

@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018-2019 FIRST. All Rights Reserved. */
/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
@@ -17,6 +17,7 @@
#include "hal/handles/UnlimitedHandleResource.h"
#include "mockdata/NotifyListener.h"
namespace hal {
namespace sim {
class CallbackStore {
public:
@@ -64,3 +65,4 @@ void FreeChannelCallback(JNIEnv* env, SIM_JniHandle handle, jint index,
void FreeCallbackNoIndex(JNIEnv* env, SIM_JniHandle handle,
FreeCallbackNoIndexFunc freeCallback);
} // namespace sim
} // namespace hal

View File

@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018-2019 FIRST. All Rights Reserved. */
/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
@@ -17,13 +17,15 @@
#include "hal/handles/UnlimitedHandleResource.h"
#include "mockdata/NotifyListener.h"
using namespace hal;
using namespace hal::sim;
using namespace wpi::java;
using namespace sim;
static hal::UnlimitedHandleResource<SIM_JniHandle, ConstBufferCallbackStore,
hal::HAL_HandleEnum::SimulationJni>*
callbackHandles;
namespace hal {
namespace sim {
void InitializeConstBufferStore() {
static hal::UnlimitedHandleResource<SIM_JniHandle, ConstBufferCallbackStore,
@@ -32,6 +34,7 @@ void InitializeConstBufferStore() {
callbackHandles = &cb;
}
} // namespace sim
} // namespace hal
void ConstBufferCallbackStore::create(JNIEnv* env, jobject obj) {
m_call = JGlobal<jobject>(env, obj);

View File

@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018-2019 FIRST. All Rights Reserved. */
/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
@@ -17,6 +17,7 @@
#include "hal/handles/UnlimitedHandleResource.h"
#include "mockdata/NotifyListener.h"
namespace hal {
namespace sim {
class ConstBufferCallbackStore {
public:
@@ -44,3 +45,4 @@ SIM_JniHandle AllocateConstBufferCallback(
void FreeConstBufferCallback(JNIEnv* env, SIM_JniHandle handle, jint index,
FreeConstBufferCallbackFunc freeCallback);
} // namespace sim
} // namespace hal

View File

@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
@@ -11,6 +11,8 @@
#include "edu_wpi_first_hal_sim_mockdata_DIODataJNI.h"
#include "mockdata/DIOData.h"
using namespace hal;
extern "C" {
/*

View File

@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
@@ -11,6 +11,8 @@
#include "edu_wpi_first_hal_sim_mockdata_DigitalPWMDataJNI.h"
#include "mockdata/DigitalPWMData.h"
using namespace hal;
extern "C" {
/*

View File

@@ -16,6 +16,7 @@
#include "mockdata/DriverStationData.h"
#include "mockdata/MockHooks.h"
using namespace hal;
using namespace wpi::java;
extern "C" {

View File

@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2019 FIRST. All Rights Reserved. */
/* Copyright (c) 2019-2020 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
@@ -11,6 +11,8 @@
#include "edu_wpi_first_hal_sim_mockdata_DutyCycleDataJNI.h"
#include "mockdata/DutyCycleData.h"
using namespace hal;
extern "C" {
/*

View File

@@ -11,6 +11,8 @@
#include "edu_wpi_first_hal_sim_mockdata_EncoderDataJNI.h"
#include "mockdata/EncoderData.h"
using namespace hal;
extern "C" {
/*

View File

@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
@@ -13,6 +13,8 @@
#include "edu_wpi_first_hal_sim_mockdata_I2CDataJNI.h"
#include "mockdata/I2CData.h"
using namespace hal;
extern "C" {
/*

View File

@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
@@ -11,6 +11,8 @@
#include "edu_wpi_first_hal_sim_mockdata_PCMDataJNI.h"
#include "mockdata/PCMData.h"
using namespace hal;
extern "C" {
/*

View File

@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
@@ -11,6 +11,8 @@
#include "edu_wpi_first_hal_sim_mockdata_PDPDataJNI.h"
#include "mockdata/PDPData.h"
using namespace hal;
extern "C" {
/*

View File

@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
@@ -11,6 +11,8 @@
#include "edu_wpi_first_hal_sim_mockdata_PWMDataJNI.h"
#include "mockdata/PWMData.h"
using namespace hal;
extern "C" {
/*

View File

@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
@@ -11,6 +11,8 @@
#include "edu_wpi_first_hal_sim_mockdata_RelayDataJNI.h"
#include "mockdata/RelayData.h"
using namespace hal;
extern "C" {
/*

View File

@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
@@ -11,6 +11,8 @@
#include "edu_wpi_first_hal_sim_mockdata_RoboRioDataJNI.h"
#include "mockdata/RoboRioData.h"
using namespace hal;
extern "C" {
/*

View File

@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
@@ -11,6 +11,8 @@
#include "edu_wpi_first_hal_sim_mockdata_SPIAccelerometerDataJNI.h"
#include "mockdata/SPIAccelerometerData.h"
using namespace hal;
extern "C" {
/*

View File

@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
@@ -14,6 +14,8 @@
#include "edu_wpi_first_hal_sim_mockdata_SPIDataJNI.h"
#include "mockdata/SPIData.h"
using namespace hal;
extern "C" {
/*

View File

@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2019 FIRST. All Rights Reserved. */
/* Copyright (c) 2019-2020 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
@@ -20,6 +20,7 @@
#include "edu_wpi_first_hal_sim_mockdata_SimDeviceDataJNI.h"
#include "mockdata/SimDeviceData.h"
using namespace hal;
using namespace wpi::java;
static JClass simDeviceInfoCls;
@@ -259,6 +260,7 @@ void CallbackJNI::FreeCallback(JNIEnv* env, int32_t uid) {
store->Free(env);
}
namespace hal {
namespace sim {
bool InitializeSimDeviceDataJNI(JNIEnv* env) {
@@ -295,6 +297,7 @@ void FreeSimDeviceDataJNI(JNIEnv* env) {
}
} // namespace sim
} // namespace hal
extern "C" {

View File

@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2019 FIRST. All Rights Reserved. */
/* Copyright (c) 2019-2020 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
@@ -9,7 +9,9 @@
#include <jni.h>
namespace hal {
namespace sim {
bool InitializeSimDeviceDataJNI(JNIEnv* env);
void FreeSimDeviceDataJNI(JNIEnv* env);
} // namespace sim
} // namespace hal

View File

@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018-2019 FIRST. All Rights Reserved. */
/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
@@ -31,6 +31,7 @@ static jmethodID bufferCallbackCallback;
static jmethodID constBufferCallbackCallback;
static jmethodID spiReadAutoReceiveBufferCallbackCallback;
namespace hal {
namespace sim {
jint SimOnLoad(JavaVM* vm, void* reserved) {
jvm = vm;
@@ -104,6 +105,7 @@ jmethodID GetSpiReadAutoReceiveBufferCallback() {
return spiReadAutoReceiveBufferCallbackCallback;
}
} // namespace sim
} // namespace hal
extern "C" {
/*

View File

@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018-2019 FIRST. All Rights Reserved. */
/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
@@ -12,6 +12,7 @@
typedef HAL_Handle SIM_JniHandle;
namespace hal {
namespace sim {
JavaVM* GetJVM();
@@ -20,3 +21,4 @@ jmethodID GetBufferCallback();
jmethodID GetConstBufferCallback();
jmethodID GetSpiReadAutoReceiveBufferCallback();
} // namespace sim
} // namespace hal

View File

@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018-2019 FIRST. All Rights Reserved. */
/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
@@ -17,13 +17,15 @@
#include "hal/handles/UnlimitedHandleResource.h"
#include "mockdata/NotifyListener.h"
using namespace hal;
using namespace hal::sim;
using namespace wpi::java;
using namespace sim;
static hal::UnlimitedHandleResource<
SIM_JniHandle, SpiReadAutoReceiveBufferCallbackStore,
hal::HAL_HandleEnum::SimulationJni>* callbackHandles;
namespace hal {
namespace sim {
void InitializeSpiBufferStore() {
static hal::UnlimitedHandleResource<SIM_JniHandle,
@@ -33,6 +35,7 @@ void InitializeSpiBufferStore() {
callbackHandles = &cb;
}
} // namespace sim
} // namespace hal
void SpiReadAutoReceiveBufferCallbackStore::create(JNIEnv* env, jobject obj) {
m_call = JGlobal<jobject>(env, obj);

View File

@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018-2019 FIRST. All Rights Reserved. */
/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
@@ -18,6 +18,7 @@
#include "mockdata/NotifyListener.h"
#include "mockdata/SPIData.h"
namespace hal {
namespace sim {
class SpiReadAutoReceiveBufferCallbackStore {
public:
@@ -45,3 +46,4 @@ SIM_JniHandle AllocateSpiBufferCallback(
void FreeSpiBufferCallback(JNIEnv* env, SIM_JniHandle handle, jint index,
FreeSpiBufferCallbackFunc freeCallback);
} // namespace sim
} // namespace hal