Skip to content

Commit b296cee

Browse files
rozeleJunielKatarn
andauthored
Use uint8_t const in IBlobPersistor.h (#10276)
* Use uint8_t const in IBlobPersistor.h Some versions of clang will not compile when the array_view data for CryptographicBuffer::CreateFromByteArray is not `uint8_t const`. This change switches the callsites to use uint8_t const where needed. * Change files * Fix Blob test comparison Co-authored-by: Julio C. Rocha <julio.rocha@microsoft.com>
1 parent f3d8a0c commit b296cee

7 files changed

Lines changed: 132 additions & 126 deletions

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "prerelease",
3+
"comment": "Use uint8_t const in IBlobPersistor.h",
4+
"packageName": "react-native-windows",
5+
"email": "erozell@outlook.com",
6+
"dependentChangeType": "patch"
7+
}

vnext/Shared/Modules/BlobModule.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ vector<module::CxxModule::Method> BlobModule::getMethods() {
139139
auto size = blob[sizeKey].getInt();
140140
auto socketID = jsArgAsInt(args, 1);
141141

142-
winrt::array_view<uint8_t> data;
142+
winrt::array_view<uint8_t const> data;
143143
try {
144144
data = persistor->ResolveMessage(std::move(blobId), offset, size);
145145
} catch (const std::exception &e) {
@@ -169,7 +169,7 @@ vector<module::CxxModule::Method> BlobModule::getMethods() {
169169
auto type = part[typeKey].asString();
170170
if (blobKey == type) {
171171
auto blob = part[dataKey];
172-
winrt::array_view<uint8_t> bufferPart;
172+
winrt::array_view<uint8_t const> bufferPart;
173173
try {
174174
bufferPart = persistor->ResolveMessage(
175175
blob[blobIdKey].asString(), blob[offsetKey].asInt(), blob[sizeKey].asInt());
@@ -216,7 +216,7 @@ vector<module::CxxModule::Method> BlobModule::getMethods() {
216216

217217
#pragma region IBlobPersistor
218218

219-
winrt::array_view<uint8_t> MemoryBlobPersistor::ResolveMessage(string &&blobId, int64_t offset, int64_t size) {
219+
winrt::array_view<uint8_t const> MemoryBlobPersistor::ResolveMessage(string &&blobId, int64_t offset, int64_t size) {
220220
if (size < 1)
221221
return {};
222222

@@ -233,7 +233,7 @@ winrt::array_view<uint8_t> MemoryBlobPersistor::ResolveMessage(string &&blobId,
233233
if (endBound > bytes.size() || offset >= static_cast<int64_t>(bytes.size()) || offset < 0)
234234
throw std::out_of_range("Offset or size out of range");
235235

236-
return winrt::array_view<uint8_t>(bytes.data() + offset, bytes.data() + endBound);
236+
return winrt::array_view<uint8_t const>(bytes.data() + offset, bytes.data() + endBound);
237237
}
238238

239239
void MemoryBlobPersistor::RemoveMessage(string &&blobId) noexcept {

vnext/Shared/Modules/BlobModule.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class MemoryBlobPersistor final : public IBlobPersistor {
3030
public:
3131
#pragma region IBlobPersistor
3232

33-
winrt::array_view<uint8_t> ResolveMessage(std::string &&blobId, int64_t offset, int64_t size) override;
33+
winrt::array_view<uint8_t const> ResolveMessage(std::string &&blobId, int64_t offset, int64_t size) override;
3434

3535
void RemoveMessage(std::string &&blobId) noexcept override;
3636

vnext/Shared/Modules/FileReaderModule.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ std::vector<module::CxxModule::Method> FileReaderModule::getMethods() {
7171
auto offset = blob["offset"].asInt();
7272
auto size = blob["size"].asInt();
7373

74-
winrt::array_view<uint8_t> bytes;
74+
winrt::array_view<uint8_t const> bytes;
7575
try {
7676
bytes = blobPersistor->ResolveMessage(std::move(blobId), offset, size);
7777
} catch (const std::exception &e) {
@@ -116,7 +116,7 @@ std::vector<module::CxxModule::Method> FileReaderModule::getMethods() {
116116
auto offset = blob["offset"].asInt();
117117
auto size = blob["size"].asInt();
118118

119-
winrt::array_view<uint8_t> bytes;
119+
winrt::array_view<uint8_t const> bytes;
120120
try {
121121
bytes = blobPersistor->ResolveMessage(std::move(blobId), offset, size);
122122
} catch (const std::exception &e) {

vnext/Shared/Modules/IBlobPersistor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ struct IBlobPersistor {
1818
/// When an entry for blobId cannot be found.
1919
/// </exception>
2020
///
21-
virtual winrt::array_view<uint8_t> ResolveMessage(std::string &&blobId, int64_t offset, int64_t size) = 0;
21+
virtual winrt::array_view<uint8_t const> ResolveMessage(std::string &&blobId, int64_t offset, int64_t size) = 0;
2222

2323
virtual void RemoveMessage(std::string &&blobId) noexcept = 0;
2424

vnext/Shared/Networking/WinRTHttpResource.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ fire_and_forget WinRTHttpResource::PerformSendRequest(HttpRequestMessage &&reque
249249
for (auto &byte : bytes) {
250250
byteVector.push_back(static_cast<uint8_t>(byte.asInt()));
251251
}
252-
auto view = winrt::array_view<uint8_t>{byteVector};
252+
auto view = winrt::array_view<uint8_t const>{byteVector};
253253
auto buffer = CryptographicBuffer::CreateFromByteArray(view);
254254
content = HttpBufferContent{std::move(buffer)};
255255
} else if (!data["string"].empty()) {

0 commit comments

Comments
 (0)