mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
SCRIPT namespace replacements
This commit is contained in:
committed by
Peter Johnson
parent
ae6c043632
commit
9aca8e0fd6
@@ -7,18 +7,18 @@
|
||||
struct SomeClass {
|
||||
static constexpr auto s_constant = 2_s;
|
||||
static constexpr auto ms_constant1 = 20_ms;
|
||||
static constexpr units::second_t ms_constant2 = 50_ms;
|
||||
static constexpr units::millisecond_t ms_constant3 = 0.20_s;
|
||||
static constexpr wpi::units::second_t ms_constant2 = 50_ms;
|
||||
static constexpr wpi::units::millisecond_t ms_constant3 = 0.20_s;
|
||||
|
||||
bool checkDefaultByName1(units::second_t period = ms_constant1);
|
||||
bool checkDefaultByName2(units::second_t period = ms_constant2);
|
||||
bool checkDefaultByNum1(units::second_t period = 50_ms);
|
||||
bool checkDefaultByNum2(units::second_t period = 0.5_s);
|
||||
bool checkDefaultByName1(wpi::units::second_t period = ms_constant1);
|
||||
bool checkDefaultByName2(wpi::units::second_t period = ms_constant2);
|
||||
bool checkDefaultByNum1(wpi::units::second_t period = 50_ms);
|
||||
bool checkDefaultByNum2(wpi::units::second_t period = 0.5_s);
|
||||
|
||||
units::second_t ms2s(units::millisecond_t ms);
|
||||
units::millisecond_t s2ms(units::second_t s);
|
||||
wpi::units::second_t ms2s(wpi::units::millisecond_t ms);
|
||||
wpi::units::millisecond_t s2ms(wpi::units::second_t s);
|
||||
|
||||
static constexpr units::foot_t five_ft = 5_ft;
|
||||
static constexpr wpi::units::foot_t five_ft = 5_ft;
|
||||
|
||||
units::meter_t ft2m(units::foot_t f);
|
||||
wpi::units::meter_t ft2m(wpi::units::foot_t f);
|
||||
};
|
||||
@@ -8,46 +8,46 @@ SEMIWRAP_PYBIND11_MODULE(m)
|
||||
initWrapper(m);
|
||||
}
|
||||
|
||||
bool SomeClass::checkDefaultByName1(units::second_t period)
|
||||
bool SomeClass::checkDefaultByName1(wpi::units::second_t period)
|
||||
{
|
||||
if (period != SomeClass::ms_constant1) {
|
||||
throw std::runtime_error(units::to_string(period));
|
||||
throw std::runtime_error(wpi::units::to_string(period));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SomeClass::checkDefaultByName2(units::second_t period)
|
||||
bool SomeClass::checkDefaultByName2(wpi::units::second_t period)
|
||||
{
|
||||
if (period != SomeClass::ms_constant2) {
|
||||
throw std::runtime_error(units::to_string(period));
|
||||
throw std::runtime_error(wpi::units::to_string(period));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SomeClass::checkDefaultByNum1(units::second_t period)
|
||||
bool SomeClass::checkDefaultByNum1(wpi::units::second_t period)
|
||||
{
|
||||
if (period != 50_ms) {
|
||||
throw std::runtime_error(units::to_string(period));
|
||||
throw std::runtime_error(wpi::units::to_string(period));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SomeClass::checkDefaultByNum2(units::second_t period)
|
||||
bool SomeClass::checkDefaultByNum2(wpi::units::second_t period)
|
||||
{
|
||||
if (period != 50_ms) {
|
||||
throw std::runtime_error(units::to_string(period));
|
||||
throw std::runtime_error(wpi::units::to_string(period));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
units::meter_t SomeClass::ft2m(units::foot_t f) {
|
||||
wpi::units::meter_t SomeClass::ft2m(wpi::units::foot_t f) {
|
||||
return f;
|
||||
}
|
||||
|
||||
units::second_t SomeClass::ms2s(units::millisecond_t ms) {
|
||||
wpi::units::second_t SomeClass::ms2s(wpi::units::millisecond_t ms) {
|
||||
return ms;
|
||||
}
|
||||
|
||||
units::millisecond_t SomeClass::s2ms(units::second_t s) {
|
||||
wpi::units::millisecond_t SomeClass::s2ms(wpi::units::second_t s) {
|
||||
return s;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user