Skip to content

Commit

Permalink
Add getData/setData to mock dummy handle
Browse files Browse the repository at this point in the history
This is to remain compatible with recent changes to PiMock
  • Loading branch information
aarongreig committed Jul 15, 2024
1 parent 167ddf9 commit 65b4431
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions source/mock/ur_mock_helpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "ur_api.h"

#include <atomic>
#include <cassert>
#include <cstddef>
#include <string>
#include <unordered_map>
Expand All @@ -36,6 +37,16 @@ struct dummy_handle_t_ {
std::vector<unsigned char> MStorage;
unsigned char *MData = nullptr;
size_t MSize;

template <typename T> T getDataAs() {
assert(MStorage.size() >= sizeof(T));
return *reinterpret_cast<T *>(MStorage.data());
}

template <typename T> T setDataAs(T Val) {
assert(MStorage.size() >= sizeof(T));
return *reinterpret_cast<T *>(MStorage.data()) = Val;
}
};

using dummy_handle_t = dummy_handle_t_ *;
Expand Down

0 comments on commit 65b4431

Please sign in to comment.