Skip to content

Commit

Permalink
TypeHandlers: fix warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
adriweb committed Aug 6, 2024
1 parent dae6c2e commit b13d5e8
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 5 deletions.
2 changes: 2 additions & 0 deletions src/TypeHandlers/STH_DataAppVar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ namespace tivars::TypeHandlers
data_t STH_DataAppVar::makeDataFromString(const std::string& str, const options_t& options, const TIVarFile* _ctx)
{
(void)options;
(void)_ctx;

const bool formatOk = regex_match(str, std::regex("^([0-9a-fA-F]{2})+$"));

Expand All @@ -40,6 +41,7 @@ namespace tivars::TypeHandlers
std::string STH_DataAppVar::makeStringFromData(const data_t& data, const options_t& options, const TIVarFile* _ctx)
{
(void)options;
(void)_ctx;

const size_t byteCount = data.size();
if (byteCount < 2)
Expand Down
3 changes: 3 additions & 0 deletions src/TypeHandlers/STH_ExactFraction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ namespace tivars::TypeHandlers
data_t STH_ExactFraction::makeDataFromString(const std::string& str, const options_t& options, const TIVarFile* _ctx)
{
(void)options;
(void)_ctx;

throw std::runtime_error("Unimplemented");

Expand All @@ -27,6 +28,8 @@ namespace tivars::TypeHandlers

std::string STH_ExactFraction::makeStringFromData(const data_t& data, const options_t& options, const TIVarFile* _ctx)
{
(void)_ctx;

if (data.size() != dataByteCount)
{
throw std::invalid_argument("Invalid data array. Needs to contain " + std::to_string(dataByteCount) + " bytes");
Expand Down
3 changes: 3 additions & 0 deletions src/TypeHandlers/STH_ExactFractionPi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ namespace tivars::TypeHandlers
data_t STH_ExactFractionPi::makeDataFromString(const std::string& str, const options_t& options, const TIVarFile* _ctx)
{
(void)options;
(void)_ctx;

throw std::runtime_error("Unimplemented");

Expand All @@ -27,6 +28,8 @@ namespace tivars::TypeHandlers

std::string STH_ExactFractionPi::makeStringFromData(const data_t& data, const options_t& options, const TIVarFile* _ctx)
{
(void)_ctx;

if (data.size() != dataByteCount)
{
throw std::invalid_argument("Invalid data array. Needs to contain " + std::to_string(dataByteCount) + " bytes");
Expand Down
3 changes: 3 additions & 0 deletions src/TypeHandlers/STH_ExactPi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ namespace tivars::TypeHandlers
data_t STH_ExactPi::makeDataFromString(const std::string& str, const options_t& options, const TIVarFile* _ctx)
{
(void)options;
(void)_ctx;

throw std::runtime_error("Unimplemented");

Expand All @@ -27,6 +28,8 @@ namespace tivars::TypeHandlers

std::string STH_ExactPi::makeStringFromData(const data_t& data, const options_t& options, const TIVarFile* _ctx)
{
(void)_ctx;

if (data.size() != dataByteCount)
{
throw std::invalid_argument("Invalid data array. Needs to contain " + std::to_string(dataByteCount) + " bytes");
Expand Down
2 changes: 2 additions & 0 deletions src/TypeHandlers/STH_ExactRadical.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ namespace tivars::TypeHandlers
data_t STH_ExactRadical::makeDataFromString(const std::string& str, const options_t& options, const TIVarFile* _ctx)
{
(void)options;
(void)_ctx;

throw std::runtime_error("Unimplemented");

Expand All @@ -31,6 +32,7 @@ namespace tivars::TypeHandlers
std::string STH_ExactRadical::makeStringFromData(const data_t& data, const options_t& options, const TIVarFile* _ctx)
{
(void)options;
(void)_ctx;

if (data.size() != dataByteCount)
{
Expand Down
2 changes: 2 additions & 0 deletions src/TypeHandlers/STH_FP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ namespace tivars::TypeHandlers
data_t STH_FP::makeDataFromString(const std::string& str, const options_t& options, const TIVarFile* _ctx)
{
(void)options;
(void)_ctx;

data_t data(dataByteCount);
bool beforePoint = true, noDigits = true, zero = true;
Expand Down Expand Up @@ -106,6 +107,7 @@ namespace tivars::TypeHandlers
{
bool scientific = false;
(void)options;
(void)_ctx;

if (data.size() != dataByteCount)
{
Expand Down
12 changes: 7 additions & 5 deletions src/TypeHandlers/STH_PythonAppVar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ namespace tivars::TypeHandlers
data_t STH_PythonAppVar::makeDataFromString(const std::string& str, const options_t& options, const TIVarFile* _ctx)
{
(void)options;
(void)_ctx;

const size_t length = str.size() + 4 + 1;

Expand All @@ -31,20 +32,21 @@ namespace tivars::TypeHandlers
data_t data(2 + length);
data[0] = (uint8_t)(length & 0xFF);
data[1] = (uint8_t)((length >> 8) & 0xFF);
memcpy(&data[2], &ID_CODE, sizeof(ID_CODE));
memcpy(&data[2+sizeof(ID_CODE)], &str[0], str.size());
memcpy(&data[2], &STH_PythonAppVar::ID_CODE, sizeof(STH_PythonAppVar::ID_CODE));
memcpy(&data[2+sizeof(STH_PythonAppVar::ID_CODE)], &str[0], str.size());

return data;
}

std::string STH_PythonAppVar::makeStringFromData(const data_t& data, const options_t& options, const TIVarFile* _ctx)
{
(void)options;
(void)_ctx;

const size_t byteCount = data.size();
const size_t lengthDat = byteCount - 2;

if (byteCount < 2 + sizeof(ID_CODE))
if (byteCount < 2 + sizeof(STH_PythonAppVar::ID_CODE))
{
throw std::invalid_argument("Invalid data array. Need at least 6 bytes, got " + std::to_string(lengthDat));
}
Expand All @@ -56,8 +58,8 @@ namespace tivars::TypeHandlers
throw std::invalid_argument("Invalid data array. Expected " + std::to_string(lengthExp) + " bytes, got " + std::to_string(lengthDat));
}

if (memcmp(ID_CODE, &(data[2]), strlen(ID_CODE)) != 0
&& memcmp(ID_SCRIPT, &(data[2]), strlen(ID_SCRIPT)) != 0)
if (memcmp(STH_PythonAppVar::ID_CODE, &(data[2]), strlen(STH_PythonAppVar::ID_CODE)) != 0
&& memcmp(STH_PythonAppVar::ID_SCRIPT, &(data[2]), strlen(STH_PythonAppVar::ID_SCRIPT)) != 0)
{
throw std::invalid_argument("Invalid data array. Magic header 'PYCD' or 'PYSC' not found");
}
Expand Down
3 changes: 3 additions & 0 deletions src/TypeHandlers/TH_GDB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,7 @@ namespace tivars::TypeHandlers
data_t TH_GDB::makeDataFromString(const std::string& str, const options_t& options, const TIVarFile* _ctx)
{
(void)options;
(void)_ctx;

GDB gdb{};
from_json(json::parse(str), gdb);
Expand Down Expand Up @@ -466,6 +467,8 @@ namespace tivars::TypeHandlers

std::string TH_GDB::makeStringFromData(const data_t& data, const options_t& options, const TIVarFile* _ctx)
{
(void)_ctx;

const size_t dataSizeActual = data.size();
if (dataSizeActual < dataByteCountMinimum)
{
Expand Down
2 changes: 2 additions & 0 deletions src/TypeHandlers/TH_GenericAppVar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ namespace tivars::TypeHandlers

std::string TH_GenericAppVar::makeStringFromData(const data_t& data, const options_t& options, const TIVarFile* _ctx)
{
(void)_ctx;

if (data.size() < 2)
{
throw std::invalid_argument("Invalid data array. Needs to contain at least 2 bytes");
Expand Down
2 changes: 2 additions & 0 deletions src/TypeHandlers/TH_TempEqu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@ namespace tivars::TypeHandlers
{
(void)str;
(void)options;
(void)_ctx;

throw std::runtime_error("Unimplemented");
}

std::string TH_TempEqu::makeStringFromData(const data_t& data, const options_t& options, const TIVarFile* _ctx)
{
(void)options;
(void)_ctx;

if (data.size() < 2)
{
Expand Down
2 changes: 2 additions & 0 deletions src/TypeHandlers/TH_Tokenized.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ namespace tivars::TypeHandlers

data_t TH_Tokenized::makeDataFromString(const std::string& str, const options_t& options, const TIVarFile* _ctx)
{
(void)_ctx;
data_t data;

const bool deindent = has_option(options, "deindent") && options.at("deindent") == 1;
Expand Down Expand Up @@ -133,6 +134,7 @@ namespace tivars::TypeHandlers

std::string TH_Tokenized::makeStringFromData(const data_t& data, const options_t& options, const TIVarFile* _ctx)
{
(void)_ctx;
const size_t dataSize = data.size();

const bool fromRawBytes = has_option(options, "fromRawBytes") && options.at("fromRawBytes") == 1;
Expand Down

0 comments on commit b13d5e8

Please sign in to comment.