mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
Move entirety of llvm namespace to wpi namespace.
During shared library loading, a different libLLVM can be pulled in, causing llvm symbols from dependent libraries to resolve to that library instead of this one. This has been seen in the wild with the Mesa OpenGL implementation in JavaFX applications (see wpilibsuite/shuffleboard#361). This is clearly a very breaking change. For some level of backwards compatibility, a namespace alias from llvm to wpi is performed in the "llvm" headers. Unfortunately, forward declarations of llvm classes will still break, but compilers seem to generate clear error messages in those cases ("namespace alias 'llvm' not allowed here, assuming 'wpi'"). This change also moves all the wpiutil headers to a single "wpi" subdirectory from the previously split "llvm", "support", "tcpsockets", and "udpsockets". Shim headers will be added for backwards compatibility in a later commit.
This commit is contained in:
@@ -7,10 +7,10 @@
|
||||
|
||||
#include "SmartDashboard/SmartDashboard.h"
|
||||
|
||||
#include <llvm/StringMap.h>
|
||||
#include <networktables/NetworkTable.h>
|
||||
#include <networktables/NetworkTableInstance.h>
|
||||
#include <support/mutex.h>
|
||||
#include <wpi/StringMap.h>
|
||||
#include <wpi/mutex.h>
|
||||
|
||||
#include "HLUsageReporting.h"
|
||||
#include "SmartDashboard/Sendable.h"
|
||||
@@ -34,7 +34,7 @@ class Singleton {
|
||||
static Singleton& GetInstance();
|
||||
|
||||
std::shared_ptr<nt::NetworkTable> table;
|
||||
llvm::StringMap<SmartDashboardData> tablesToData;
|
||||
wpi::StringMap<SmartDashboardData> tablesToData;
|
||||
wpi::mutex tablesToDataMutex;
|
||||
|
||||
private:
|
||||
@@ -61,7 +61,7 @@ void SmartDashboard::init() { Singleton::GetInstance(); }
|
||||
* @param key the key to search for
|
||||
* @return true if the table as a value assigned to the given key
|
||||
*/
|
||||
bool SmartDashboard::ContainsKey(llvm::StringRef key) {
|
||||
bool SmartDashboard::ContainsKey(wpi::StringRef key) {
|
||||
return Singleton::GetInstance().table->ContainsKey(key);
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ std::vector<std::string> SmartDashboard::GetKeys(int types) {
|
||||
*
|
||||
* @param key the key to make persistent
|
||||
*/
|
||||
void SmartDashboard::SetPersistent(llvm::StringRef key) {
|
||||
void SmartDashboard::SetPersistent(wpi::StringRef key) {
|
||||
Singleton::GetInstance().table->GetEntry(key).SetPersistent();
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ void SmartDashboard::SetPersistent(llvm::StringRef key) {
|
||||
*
|
||||
* @param key the key name
|
||||
*/
|
||||
void SmartDashboard::ClearPersistent(llvm::StringRef key) {
|
||||
void SmartDashboard::ClearPersistent(wpi::StringRef key) {
|
||||
Singleton::GetInstance().table->GetEntry(key).ClearPersistent();
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ void SmartDashboard::ClearPersistent(llvm::StringRef key) {
|
||||
*
|
||||
* @param key the key name
|
||||
*/
|
||||
bool SmartDashboard::IsPersistent(llvm::StringRef key) {
|
||||
bool SmartDashboard::IsPersistent(wpi::StringRef key) {
|
||||
return Singleton::GetInstance().table->GetEntry(key).IsPersistent();
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ bool SmartDashboard::IsPersistent(llvm::StringRef key) {
|
||||
* @param key the key name
|
||||
* @param flags the flags to set (bitmask)
|
||||
*/
|
||||
void SmartDashboard::SetFlags(llvm::StringRef key, unsigned int flags) {
|
||||
void SmartDashboard::SetFlags(wpi::StringRef key, unsigned int flags) {
|
||||
Singleton::GetInstance().table->GetEntry(key).SetFlags(flags);
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ void SmartDashboard::SetFlags(llvm::StringRef key, unsigned int flags) {
|
||||
* @param key the key name
|
||||
* @param flags the flags to clear (bitmask)
|
||||
*/
|
||||
void SmartDashboard::ClearFlags(llvm::StringRef key, unsigned int flags) {
|
||||
void SmartDashboard::ClearFlags(wpi::StringRef key, unsigned int flags) {
|
||||
Singleton::GetInstance().table->GetEntry(key).ClearFlags(flags);
|
||||
}
|
||||
|
||||
@@ -130,7 +130,7 @@ void SmartDashboard::ClearFlags(llvm::StringRef key, unsigned int flags) {
|
||||
* @param key the key name
|
||||
* @return the flags, or 0 if the key is not defined
|
||||
*/
|
||||
unsigned int SmartDashboard::GetFlags(llvm::StringRef key) {
|
||||
unsigned int SmartDashboard::GetFlags(wpi::StringRef key) {
|
||||
return Singleton::GetInstance().table->GetEntry(key).GetFlags();
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ unsigned int SmartDashboard::GetFlags(llvm::StringRef key) {
|
||||
*
|
||||
* @param key the key name
|
||||
*/
|
||||
void SmartDashboard::Delete(llvm::StringRef key) {
|
||||
void SmartDashboard::Delete(wpi::StringRef key) {
|
||||
Singleton::GetInstance().table->Delete(key);
|
||||
}
|
||||
|
||||
@@ -152,7 +152,7 @@ void SmartDashboard::Delete(llvm::StringRef key) {
|
||||
* @param keyName the key
|
||||
* @param value the value
|
||||
*/
|
||||
void SmartDashboard::PutData(llvm::StringRef key, Sendable* data) {
|
||||
void SmartDashboard::PutData(wpi::StringRef key, Sendable* data) {
|
||||
if (data == nullptr) {
|
||||
wpi_setGlobalWPIErrorWithContext(NullParameter, "value");
|
||||
return;
|
||||
@@ -194,7 +194,7 @@ void SmartDashboard::PutData(Sendable* value) {
|
||||
* @param keyName the key
|
||||
* @return the value
|
||||
*/
|
||||
Sendable* SmartDashboard::GetData(llvm::StringRef key) {
|
||||
Sendable* SmartDashboard::GetData(wpi::StringRef key) {
|
||||
auto& inst = Singleton::GetInstance();
|
||||
std::lock_guard<wpi::mutex> lock(inst.tablesToDataMutex);
|
||||
auto data = inst.tablesToData.find(key);
|
||||
@@ -216,7 +216,7 @@ Sendable* SmartDashboard::GetData(llvm::StringRef key) {
|
||||
* @param value the value
|
||||
* @return False if the table key already exists with a different type
|
||||
*/
|
||||
bool SmartDashboard::PutValue(llvm::StringRef keyName,
|
||||
bool SmartDashboard::PutValue(wpi::StringRef keyName,
|
||||
std::shared_ptr<nt::Value> value) {
|
||||
return Singleton::GetInstance().table->GetEntry(keyName).SetValue(value);
|
||||
}
|
||||
@@ -228,7 +228,7 @@ bool SmartDashboard::PutValue(llvm::StringRef keyName,
|
||||
* @param defaultValue The default value to set if key doesn't exist.
|
||||
* @returns False if the table key exists with a different type
|
||||
*/
|
||||
bool SmartDashboard::SetDefaultValue(llvm::StringRef key,
|
||||
bool SmartDashboard::SetDefaultValue(wpi::StringRef key,
|
||||
std::shared_ptr<nt::Value> defaultValue) {
|
||||
return Singleton::GetInstance().table->GetEntry(key).SetDefaultValue(
|
||||
defaultValue);
|
||||
@@ -241,7 +241,7 @@ bool SmartDashboard::SetDefaultValue(llvm::StringRef key,
|
||||
* @param keyName the key
|
||||
* @param value the object to retrieve the value into
|
||||
*/
|
||||
std::shared_ptr<nt::Value> SmartDashboard::GetValue(llvm::StringRef keyName) {
|
||||
std::shared_ptr<nt::Value> SmartDashboard::GetValue(wpi::StringRef keyName) {
|
||||
return Singleton::GetInstance().table->GetEntry(keyName).GetValue();
|
||||
}
|
||||
|
||||
@@ -255,7 +255,7 @@ std::shared_ptr<nt::Value> SmartDashboard::GetValue(llvm::StringRef keyName) {
|
||||
* @param value the value
|
||||
* @return False if the table key already exists with a different type
|
||||
*/
|
||||
bool SmartDashboard::PutBoolean(llvm::StringRef keyName, bool value) {
|
||||
bool SmartDashboard::PutBoolean(wpi::StringRef keyName, bool value) {
|
||||
return Singleton::GetInstance().table->GetEntry(keyName).SetBoolean(value);
|
||||
}
|
||||
|
||||
@@ -265,7 +265,7 @@ bool SmartDashboard::PutBoolean(llvm::StringRef keyName, bool value) {
|
||||
* @param defaultValue the default value to set if key doesn't exist.
|
||||
* @returns False if the table key exists with a different type
|
||||
*/
|
||||
bool SmartDashboard::SetDefaultBoolean(llvm::StringRef key, bool defaultValue) {
|
||||
bool SmartDashboard::SetDefaultBoolean(wpi::StringRef key, bool defaultValue) {
|
||||
return Singleton::GetInstance().table->GetEntry(key).SetDefaultBoolean(
|
||||
defaultValue);
|
||||
}
|
||||
@@ -278,7 +278,7 @@ bool SmartDashboard::SetDefaultBoolean(llvm::StringRef key, bool defaultValue) {
|
||||
* @param keyName the key
|
||||
* @return the value
|
||||
*/
|
||||
bool SmartDashboard::GetBoolean(llvm::StringRef keyName, bool defaultValue) {
|
||||
bool SmartDashboard::GetBoolean(wpi::StringRef keyName, bool defaultValue) {
|
||||
return Singleton::GetInstance().table->GetEntry(keyName).GetBoolean(
|
||||
defaultValue);
|
||||
}
|
||||
@@ -293,7 +293,7 @@ bool SmartDashboard::GetBoolean(llvm::StringRef keyName, bool defaultValue) {
|
||||
* @param value the value
|
||||
* @return False if the table key already exists with a different type
|
||||
*/
|
||||
bool SmartDashboard::PutNumber(llvm::StringRef keyName, double value) {
|
||||
bool SmartDashboard::PutNumber(wpi::StringRef keyName, double value) {
|
||||
return Singleton::GetInstance().table->GetEntry(keyName).SetDouble(value);
|
||||
}
|
||||
|
||||
@@ -304,7 +304,7 @@ bool SmartDashboard::PutNumber(llvm::StringRef keyName, double value) {
|
||||
* @param defaultValue The default value to set if key doesn't exist.
|
||||
* @returns False if the table key exists with a different type
|
||||
*/
|
||||
bool SmartDashboard::SetDefaultNumber(llvm::StringRef key,
|
||||
bool SmartDashboard::SetDefaultNumber(wpi::StringRef key,
|
||||
double defaultValue) {
|
||||
return Singleton::GetInstance().table->GetEntry(key).SetDefaultDouble(
|
||||
defaultValue);
|
||||
@@ -318,7 +318,7 @@ bool SmartDashboard::SetDefaultNumber(llvm::StringRef key,
|
||||
* @param keyName the key
|
||||
* @return the value
|
||||
*/
|
||||
double SmartDashboard::GetNumber(llvm::StringRef keyName, double defaultValue) {
|
||||
double SmartDashboard::GetNumber(wpi::StringRef keyName, double defaultValue) {
|
||||
return Singleton::GetInstance().table->GetEntry(keyName).GetDouble(
|
||||
defaultValue);
|
||||
}
|
||||
@@ -333,7 +333,7 @@ double SmartDashboard::GetNumber(llvm::StringRef keyName, double defaultValue) {
|
||||
* @param value the value
|
||||
* @return False if the table key already exists with a different type
|
||||
*/
|
||||
bool SmartDashboard::PutString(llvm::StringRef keyName, llvm::StringRef value) {
|
||||
bool SmartDashboard::PutString(wpi::StringRef keyName, wpi::StringRef value) {
|
||||
return Singleton::GetInstance().table->GetEntry(keyName).SetString(value);
|
||||
}
|
||||
|
||||
@@ -343,8 +343,8 @@ bool SmartDashboard::PutString(llvm::StringRef keyName, llvm::StringRef value) {
|
||||
* @param defaultValue the default value to set if key doesn't exist.
|
||||
* @returns False if the table key exists with a different type
|
||||
*/
|
||||
bool SmartDashboard::SetDefaultString(llvm::StringRef key,
|
||||
llvm::StringRef defaultValue) {
|
||||
bool SmartDashboard::SetDefaultString(wpi::StringRef key,
|
||||
wpi::StringRef defaultValue) {
|
||||
return Singleton::GetInstance().table->GetEntry(key).SetDefaultString(
|
||||
defaultValue);
|
||||
}
|
||||
@@ -357,8 +357,8 @@ bool SmartDashboard::SetDefaultString(llvm::StringRef key,
|
||||
* @param keyName the key
|
||||
* @return the value
|
||||
*/
|
||||
std::string SmartDashboard::GetString(llvm::StringRef keyName,
|
||||
llvm::StringRef defaultValue) {
|
||||
std::string SmartDashboard::GetString(wpi::StringRef keyName,
|
||||
wpi::StringRef defaultValue) {
|
||||
return Singleton::GetInstance().table->GetEntry(keyName).GetString(
|
||||
defaultValue);
|
||||
}
|
||||
@@ -374,8 +374,8 @@ std::string SmartDashboard::GetString(llvm::StringRef keyName,
|
||||
* std::vector<bool> is special-cased in C++. 0 is false, any
|
||||
* non-zero value is true.
|
||||
*/
|
||||
bool SmartDashboard::PutBooleanArray(llvm::StringRef key,
|
||||
llvm::ArrayRef<int> value) {
|
||||
bool SmartDashboard::PutBooleanArray(wpi::StringRef key,
|
||||
wpi::ArrayRef<int> value) {
|
||||
return Singleton::GetInstance().table->GetEntry(key).SetBooleanArray(value);
|
||||
}
|
||||
|
||||
@@ -386,8 +386,8 @@ bool SmartDashboard::PutBooleanArray(llvm::StringRef key,
|
||||
* @param defaultValue the default value to set if key doesn't exist.
|
||||
* @returns False if the table key exists with a different type
|
||||
*/
|
||||
bool SmartDashboard::SetDefaultBooleanArray(llvm::StringRef key,
|
||||
llvm::ArrayRef<int> defaultValue) {
|
||||
bool SmartDashboard::SetDefaultBooleanArray(wpi::StringRef key,
|
||||
wpi::ArrayRef<int> defaultValue) {
|
||||
return Singleton::GetInstance().table->GetEntry(key).SetDefaultBooleanArray(
|
||||
defaultValue);
|
||||
}
|
||||
@@ -411,7 +411,7 @@ bool SmartDashboard::SetDefaultBooleanArray(llvm::StringRef key,
|
||||
* non-zero value is true.
|
||||
*/
|
||||
std::vector<int> SmartDashboard::GetBooleanArray(
|
||||
llvm::StringRef key, llvm::ArrayRef<int> defaultValue) {
|
||||
wpi::StringRef key, wpi::ArrayRef<int> defaultValue) {
|
||||
return Singleton::GetInstance().table->GetEntry(key).GetBooleanArray(
|
||||
defaultValue);
|
||||
}
|
||||
@@ -423,8 +423,8 @@ std::vector<int> SmartDashboard::GetBooleanArray(
|
||||
* @param value The value that will be assigned.
|
||||
* @return False if the table key already exists with a different type
|
||||
*/
|
||||
bool SmartDashboard::PutNumberArray(llvm::StringRef key,
|
||||
llvm::ArrayRef<double> value) {
|
||||
bool SmartDashboard::PutNumberArray(wpi::StringRef key,
|
||||
wpi::ArrayRef<double> value) {
|
||||
return Singleton::GetInstance().table->GetEntry(key).SetDoubleArray(value);
|
||||
}
|
||||
|
||||
@@ -436,7 +436,7 @@ bool SmartDashboard::PutNumberArray(llvm::StringRef key,
|
||||
* @returns False if the table key exists with a different type
|
||||
*/
|
||||
bool SmartDashboard::SetDefaultNumberArray(
|
||||
llvm::StringRef key, llvm::ArrayRef<double> defaultValue) {
|
||||
wpi::StringRef key, wpi::ArrayRef<double> defaultValue) {
|
||||
return Singleton::GetInstance().table->GetEntry(key).SetDefaultDoubleArray(
|
||||
defaultValue);
|
||||
}
|
||||
@@ -456,7 +456,7 @@ bool SmartDashboard::SetDefaultNumberArray(
|
||||
* use GetValue() instead.
|
||||
*/
|
||||
std::vector<double> SmartDashboard::GetNumberArray(
|
||||
llvm::StringRef key, llvm::ArrayRef<double> defaultValue) {
|
||||
wpi::StringRef key, wpi::ArrayRef<double> defaultValue) {
|
||||
return Singleton::GetInstance().table->GetEntry(key).GetDoubleArray(
|
||||
defaultValue);
|
||||
}
|
||||
@@ -468,8 +468,8 @@ std::vector<double> SmartDashboard::GetNumberArray(
|
||||
* @param value The value that will be assigned.
|
||||
* @return False if the table key already exists with a different type
|
||||
*/
|
||||
bool SmartDashboard::PutStringArray(llvm::StringRef key,
|
||||
llvm::ArrayRef<std::string> value) {
|
||||
bool SmartDashboard::PutStringArray(wpi::StringRef key,
|
||||
wpi::ArrayRef<std::string> value) {
|
||||
return Singleton::GetInstance().table->GetEntry(key).SetStringArray(value);
|
||||
}
|
||||
|
||||
@@ -481,7 +481,7 @@ bool SmartDashboard::PutStringArray(llvm::StringRef key,
|
||||
* @returns False if the table key exists with a different type
|
||||
*/
|
||||
bool SmartDashboard::SetDefaultStringArray(
|
||||
llvm::StringRef key, llvm::ArrayRef<std::string> defaultValue) {
|
||||
wpi::StringRef key, wpi::ArrayRef<std::string> defaultValue) {
|
||||
return Singleton::GetInstance().table->GetEntry(key).SetDefaultStringArray(
|
||||
defaultValue);
|
||||
}
|
||||
@@ -501,7 +501,7 @@ bool SmartDashboard::SetDefaultStringArray(
|
||||
* use GetValue() instead.
|
||||
*/
|
||||
std::vector<std::string> SmartDashboard::GetStringArray(
|
||||
llvm::StringRef key, llvm::ArrayRef<std::string> defaultValue) {
|
||||
wpi::StringRef key, wpi::ArrayRef<std::string> defaultValue) {
|
||||
return Singleton::GetInstance().table->GetEntry(key).GetStringArray(
|
||||
defaultValue);
|
||||
}
|
||||
@@ -513,7 +513,7 @@ std::vector<std::string> SmartDashboard::GetStringArray(
|
||||
* @param value The value that will be assigned.
|
||||
* @return False if the table key already exists with a different type
|
||||
*/
|
||||
bool SmartDashboard::PutRaw(llvm::StringRef key, llvm::StringRef value) {
|
||||
bool SmartDashboard::PutRaw(wpi::StringRef key, wpi::StringRef value) {
|
||||
return Singleton::GetInstance().table->GetEntry(key).SetRaw(value);
|
||||
}
|
||||
|
||||
@@ -524,8 +524,8 @@ bool SmartDashboard::PutRaw(llvm::StringRef key, llvm::StringRef value) {
|
||||
* @param defaultValue The default value to set if key doesn't exist.
|
||||
* @returns False if the table key exists with a different type
|
||||
*/
|
||||
bool SmartDashboard::SetDefaultRaw(llvm::StringRef key,
|
||||
llvm::StringRef defaultValue) {
|
||||
bool SmartDashboard::SetDefaultRaw(wpi::StringRef key,
|
||||
wpi::StringRef defaultValue) {
|
||||
return Singleton::GetInstance().table->GetEntry(key).SetDefaultRaw(
|
||||
defaultValue);
|
||||
}
|
||||
@@ -544,8 +544,8 @@ bool SmartDashboard::SetDefaultRaw(llvm::StringRef key,
|
||||
* @note This makes a copy of the raw contents. If the overhead of this is a
|
||||
* concern, use GetValue() instead.
|
||||
*/
|
||||
std::string SmartDashboard::GetRaw(llvm::StringRef key,
|
||||
llvm::StringRef defaultValue) {
|
||||
std::string SmartDashboard::GetRaw(wpi::StringRef key,
|
||||
wpi::StringRef defaultValue) {
|
||||
return Singleton::GetInstance().table->GetEntry(key).GetRaw(defaultValue);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user