Skip to content

Commit 0f315f3

Browse files
authored
Merge pull request #3 from CoolBitX-Technology/fix/duplicate-symbol-errors
🚨 fix: fix `nameToKindMap` and `propNameIDCache` duplicate symbol errors
2 parents b20d2bf + 74d4004 commit 0f315f3

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

packages/react-native-quick-crypto/cpp/JSIUtils/MGLTypedArray.cpp

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,13 @@ class MGLPropNameIDCache {
6565
jsi::PropNameID createProp(jsi::Runtime &runtime, Prop prop);
6666
};
6767

68-
MGLPropNameIDCache propNameIDCache;
68+
MGLPropNameIDCache MGLpropNameIDCache;
6969

7070
MGLInvalidateCacheOnDestroy::MGLInvalidateCacheOnDestroy(jsi::Runtime &runtime) {
7171
key = reinterpret_cast<uintptr_t>(&runtime);
7272
}
7373
MGLInvalidateCacheOnDestroy::~MGLInvalidateCacheOnDestroy() {
74-
propNameIDCache.invalidate(key);
74+
MGLpropNameIDCache.invalidate(key);
7575
}
7676

7777
MGLTypedArrayKind MGLgetTypedArrayKindForName(const std::string &name);
@@ -83,7 +83,7 @@ MGLTypedArrayBase::MGLTypedArrayBase(jsi::Runtime &runtime, size_t size,
8383
runtime.global()
8484
.getProperty(
8585
runtime,
86-
propNameIDCache.getConstructorNameProp(runtime, kind))
86+
MGLpropNameIDCache.getConstructorNameProp(runtime, kind))
8787
.asObject(runtime)
8888
.asFunction(runtime)
8989
.callAsConstructor(runtime, {static_cast<double>(size)})
@@ -96,37 +96,37 @@ MGLTypedArrayBase::MGLTypedArrayBase(jsi::Runtime &runtime,
9696
MGLTypedArrayKind MGLTypedArrayBase::getKind(jsi::Runtime &runtime) const {
9797
auto constructorName =
9898
this->getProperty(runtime,
99-
propNameIDCache.get(runtime, Prop::Constructor))
99+
MGLpropNameIDCache.get(runtime, Prop::Constructor))
100100
.asObject(runtime)
101-
.getProperty(runtime, propNameIDCache.get(runtime, Prop::Name))
101+
.getProperty(runtime, MGLpropNameIDCache.get(runtime, Prop::Name))
102102
.asString(runtime)
103103
.utf8(runtime);
104104
return MGLgetTypedArrayKindForName(constructorName);
105105
}
106106

107107
size_t MGLTypedArrayBase::size(jsi::Runtime &runtime) const {
108-
return getProperty(runtime, propNameIDCache.get(runtime, Prop::Length))
108+
return getProperty(runtime, MGLpropNameIDCache.get(runtime, Prop::Length))
109109
.asNumber();
110110
}
111111

112112
size_t MGLTypedArrayBase::length(jsi::Runtime &runtime) const {
113-
return getProperty(runtime, propNameIDCache.get(runtime, Prop::Length))
113+
return getProperty(runtime, MGLpropNameIDCache.get(runtime, Prop::Length))
114114
.asNumber();
115115
}
116116

117117
size_t MGLTypedArrayBase::byteLength(jsi::Runtime &runtime) const {
118-
return getProperty(runtime, propNameIDCache.get(runtime, Prop::ByteLength))
118+
return getProperty(runtime, MGLpropNameIDCache.get(runtime, Prop::ByteLength))
119119
.asNumber();
120120
}
121121

122122
size_t MGLTypedArrayBase::byteOffset(jsi::Runtime &runtime) const {
123-
return getProperty(runtime, propNameIDCache.get(runtime, Prop::ByteOffset))
123+
return getProperty(runtime, MGLpropNameIDCache.get(runtime, Prop::ByteOffset))
124124
.asNumber();
125125
}
126126

127127
bool MGLTypedArrayBase::hasBuffer(jsi::Runtime &runtime) const {
128128
auto buffer =
129-
getProperty(runtime, propNameIDCache.get(runtime, Prop::Buffer));
129+
getProperty(runtime, MGLpropNameIDCache.get(runtime, Prop::Buffer));
130130
return buffer.isObject() && buffer.asObject(runtime).isArrayBuffer(runtime);
131131
}
132132

@@ -139,7 +139,7 @@ std::vector<uint8_t> MGLTypedArrayBase::toVector(jsi::Runtime &runtime) {
139139

140140
jsi::ArrayBuffer MGLTypedArrayBase::getBuffer(jsi::Runtime &runtime) const {
141141
auto buffer =
142-
getProperty(runtime, propNameIDCache.get(runtime, Prop::Buffer));
142+
getProperty(runtime, MGLpropNameIDCache.get(runtime, Prop::Buffer));
143143
if (buffer.isObject() && buffer.asObject(runtime).isArrayBuffer(runtime)) {
144144
return buffer.asObject(runtime).getArrayBuffer(runtime);
145145
} else {
@@ -150,9 +150,9 @@ jsi::ArrayBuffer MGLTypedArrayBase::getBuffer(jsi::Runtime &runtime) const {
150150
bool MGLisTypedArray(jsi::Runtime &runtime, const jsi::Object &jsObj) {
151151
auto jsVal =
152152
runtime.global()
153-
.getProperty(runtime, propNameIDCache.get(runtime, Prop::ArrayBuffer))
153+
.getProperty(runtime, MGLpropNameIDCache.get(runtime, Prop::ArrayBuffer))
154154
.asObject(runtime)
155-
.getProperty(runtime, propNameIDCache.get(runtime, Prop::IsView))
155+
.getProperty(runtime, MGLpropNameIDCache.get(runtime, Prop::IsView))
156156
.asObject(runtime)
157157
.asFunction(runtime)
158158
.callWithThis(runtime, runtime.global(),
@@ -168,9 +168,9 @@ MGLTypedArrayBase MGLgetTypedArray(jsi::Runtime &runtime,
168168
const jsi::Object &jsObj) {
169169
auto jsVal =
170170
runtime.global()
171-
.getProperty(runtime, propNameIDCache.get(runtime, Prop::ArrayBuffer))
171+
.getProperty(runtime, MGLpropNameIDCache.get(runtime, Prop::ArrayBuffer))
172172
.asObject(runtime)
173-
.getProperty(runtime, propNameIDCache.get(runtime, Prop::IsView))
173+
.getProperty(runtime, MGLpropNameIDCache.get(runtime, Prop::IsView))
174174
.asObject(runtime)
175175
.asFunction(runtime)
176176
.callWithThis(runtime, runtime.global(),
@@ -192,7 +192,7 @@ std::vector<uint8_t> MGLarrayBufferToVector(jsi::Runtime &runtime,
192192
uint8_t *dataBlock = jsArrayBuffer.data(runtime);
193193
size_t blockSize =
194194
jsArrayBuffer
195-
.getProperty(runtime, propNameIDCache.get(runtime, Prop::ByteLength))
195+
.getProperty(runtime, MGLpropNameIDCache.get(runtime, Prop::ByteLength))
196196
.asNumber();
197197
return std::vector<uint8_t>(dataBlock, dataBlock + blockSize);
198198
}
@@ -325,7 +325,7 @@ jsi::PropNameID MGLPropNameIDCache::createProp(jsi::Runtime &runtime, Prop prop)
325325
}
326326
}
327327

328-
std::unordered_map<std::string, MGLTypedArrayKind> nameToKindMap = {
328+
std::unordered_map<std::string, MGLTypedArrayKind> MGLnameToKindMap = {
329329
{"Int8Array", MGLTypedArrayKind::Int8Array},
330330
{"Int16Array", MGLTypedArrayKind::Int16Array},
331331
{"Int32Array", MGLTypedArrayKind::Int32Array},
@@ -338,7 +338,7 @@ std::unordered_map<std::string, MGLTypedArrayKind> nameToKindMap = {
338338
};
339339

340340
MGLTypedArrayKind MGLgetTypedArrayKindForName(const std::string &name) {
341-
return nameToKindMap.at(name);
341+
return MGLnameToKindMap.at(name);
342342
}
343343

344344
template class MGLTypedArray<MGLTypedArrayKind::Int8Array>;

0 commit comments

Comments
 (0)