Skip to content

Commit

Permalink
Merge branch 'custom-num'
Browse files Browse the repository at this point in the history
  • Loading branch information
solemnwarning committed Apr 7, 2024
2 parents c3c4430 + a7366fd commit 0315194
Show file tree
Hide file tree
Showing 11 changed files with 2,861 additions and 742 deletions.
5 changes: 5 additions & 0 deletions Makefile
Expand Up @@ -363,6 +363,7 @@ APP_OBJS := \
src/ConsoleBuffer.$(BUILD_TYPE).o \
src/ConsolePanel.$(BUILD_TYPE).o \
src/CustomMessageDialog.$(BUILD_TYPE).o \
src/CustomNumericType.$(BUILD_TYPE).o \
src/DataHistogramPanel.$(BUILD_TYPE).o \
src/DataType.$(BUILD_TYPE).o \
src/decodepanel.$(BUILD_TYPE).o \
Expand All @@ -376,6 +377,7 @@ APP_OBJS := \
src/Events.$(BUILD_TYPE).o \
src/FileWriter.$(BUILD_TYPE).o \
src/FillRangeDialog.$(BUILD_TYPE).o \
src/FixedSizeValueRegion.$(BUILD_TYPE).o \
src/IntelHexExport.$(BUILD_TYPE).o \
src/IntelHexImport.$(BUILD_TYPE).o \
src/IPC.$(BUILD_TYPE).o \
Expand Down Expand Up @@ -455,6 +457,7 @@ TEST_OBJS := \
src/CommentTree.$(BUILD_TYPE).o \
src/ConsoleBuffer.$(BUILD_TYPE).o \
src/CustomMessageDialog.$(BUILD_TYPE).o \
src/CustomNumericType.$(BUILD_TYPE).o \
src/DataType.$(BUILD_TYPE).o \
src/DetachableNotebook.$(BUILD_TYPE).o \
src/DiffWindow.$(BUILD_TYPE).o \
Expand All @@ -465,6 +468,7 @@ TEST_OBJS := \
src/Events.$(BUILD_TYPE).o \
src/FileWriter.$(BUILD_TYPE).o \
src/FillRangeDialog.$(BUILD_TYPE).o \
src/FixedSizeValueRegion.$(BUILD_TYPE).o \
src/IntelHexExport.$(BUILD_TYPE).o \
src/IntelHexImport.$(BUILD_TYPE).o \
src/LicenseDialog.$(BUILD_TYPE).o \
Expand Down Expand Up @@ -497,6 +501,7 @@ TEST_OBJS := \
tests/CommentsDataObject.o \
tests/CommentTree.o \
tests/ConsoleBuffer.o \
tests/CustomNumericType.o \
tests/DataType.o \
tests/DataHistogramAccumulator.o \
tests/DiffWindow.o \
Expand Down
30 changes: 24 additions & 6 deletions src/BasicDataTypes.cpp
Expand Up @@ -38,15 +38,21 @@
REHex::NAME::NAME(SharedDocumentPointer &doc, REHex::BitOffset offset, REHex::BitOffset length, REHex::BitOffset virt_offset): \
NumericDataTypeRegion(doc, offset, length, virt_offset, LABEL) {} \
\
std::string REHex::NAME::to_string(const T *data) const \
std::string REHex::NAME::load_value() const \
{ \
std::vector<unsigned char> data_buf = doc->read_data(d_offset, d_length.byte()); \
if(data_buf.size() != (size_t)(d_length.byte())) \
{ \
throw std::runtime_error("Unexpected end of file"); \
} \
const T *data = (T*)(data_buf.data()); \
char buf[128]; \
snprintf(buf, sizeof(buf), FMT, (T)(XTOH(*data))); \
\
return std::string(buf); \
} \
\
bool REHex::NAME::write_string_value(const std::string &value) \
bool REHex::NAME::store_value(const std::string &value) \
{ \
T buf; \
try { \
Expand Down Expand Up @@ -172,15 +178,21 @@ static REHex::StaticDataTypeRegistration s64be_dtr(
REHex::NAME::NAME(SharedDocumentPointer &doc, REHex::BitOffset offset, REHex::BitOffset length, REHex::BitOffset virt_offset): \
NumericDataTypeRegion(doc, offset, length, virt_offset, LABEL) {} \
\
std::string REHex::NAME::to_string(const T *data) const \
std::string REHex::NAME::load_value() const \
{ \
std::vector<unsigned char> data_buf = doc->read_data(d_offset, d_length.byte()); \
if(data_buf.size() != (size_t)(d_length.byte())) \
{ \
throw std::runtime_error("Unexpected end of file"); \
} \
const T *data = (T*)(data_buf.data()); \
char buf[128]; \
snprintf(buf, sizeof(buf), FMT, XTOH<T>(*data)); \
\
return std::string(buf); \
} \
\
bool REHex::NAME::write_string_value(const std::string &value) \
bool REHex::NAME::store_value(const std::string &value) \
{ \
if(value.length() == 0) \
{ \
Expand Down Expand Up @@ -229,15 +241,21 @@ static REHex::StaticDataTypeRegistration f32be_dtr(
REHex::NAME::NAME(SharedDocumentPointer &doc, REHex::BitOffset offset, REHex::BitOffset length, REHex::BitOffset virt_offset): \
NumericDataTypeRegion(doc, offset, length, virt_offset, LABEL) {} \
\
std::string REHex::NAME::to_string(const T *data) const \
std::string REHex::NAME::load_value() const \
{ \
std::vector<unsigned char> data_buf = doc->read_data(d_offset, d_length.byte()); \
if(data_buf.size() != (size_t)(d_length.byte())) \
{ \
throw std::runtime_error("Unexpected end of file"); \
} \
const T *data = (T*)(data_buf.data()); \
char buf[128]; \
snprintf(buf, sizeof(buf), FMT, XTOH<T>(*data)); \
\
return std::string(buf); \
} \
\
bool REHex::NAME::write_string_value(const std::string &value) \
bool REHex::NAME::store_value(const std::string &value) \
{ \
if(value.length() == 0) \
{ \
Expand Down

0 comments on commit 0315194

Please sign in to comment.