Skip to content

Commit b20d2bf

Browse files
authored
Merge pull request #2 from CoolBitX-Technology/chore/fix-duplicate-symbol-with-mmkv
🚨 [CW-24278] fix: add MGL prefix to avoid duplicate symbol errors
2 parents 14d540b + bffb963 commit b20d2bf

File tree

4 files changed

+25
-25
lines changed

4 files changed

+25
-25
lines changed

packages/react-native-quick-crypto/android/src/main/cpp/cpp-adapter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ class CryptoCppAdapter : public jni::HybridClass<CryptoCppAdapter> {
3030
auto object = jsi::Object::createFromHostObject(runtime, hostObject);
3131
runtime.global().setProperty(runtime, "__QuickCryptoProxy",
3232
std::move(object));
33-
// Adds the PropNameIDCache object to the Runtime. If the Runtime gets destroyed, the Object gets destroyed and the cache gets invalidated.
34-
auto propNameIdCache = std::make_shared<InvalidateCacheOnDestroy>(runtime);
33+
// Adds the MGLPropNameIDCache object to the Runtime. If the Runtime gets destroyed, the Object gets destroyed and the cache gets invalidated.
34+
auto propNameIdCache = std::make_shared<MGLInvalidateCacheOnDestroy>(runtime);
3535
runtime.global().setProperty(
3636
runtime,
3737
"rnqcArrayBufferPropNameIdCache",

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

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ enum class Prop {
3939
Float64Array, // "Float64Array"
4040
};
4141

42-
class PropNameIDCache {
42+
class MGLPropNameIDCache {
4343
public:
4444
const jsi::PropNameID &get(jsi::Runtime &runtime, Prop prop) {
4545
auto key = reinterpret_cast<uintptr_t>(&runtime);
@@ -65,16 +65,16 @@ class PropNameIDCache {
6565
jsi::PropNameID createProp(jsi::Runtime &runtime, Prop prop);
6666
};
6767

68-
PropNameIDCache propNameIDCache;
68+
MGLPropNameIDCache propNameIDCache;
6969

70-
InvalidateCacheOnDestroy::InvalidateCacheOnDestroy(jsi::Runtime &runtime) {
70+
MGLInvalidateCacheOnDestroy::MGLInvalidateCacheOnDestroy(jsi::Runtime &runtime) {
7171
key = reinterpret_cast<uintptr_t>(&runtime);
7272
}
73-
InvalidateCacheOnDestroy::~InvalidateCacheOnDestroy() {
73+
MGLInvalidateCacheOnDestroy::~MGLInvalidateCacheOnDestroy() {
7474
propNameIDCache.invalidate(key);
7575
}
7676

77-
MGLTypedArrayKind getTypedArrayKindForName(const std::string &name);
77+
MGLTypedArrayKind MGLgetTypedArrayKindForName(const std::string &name);
7878

7979
MGLTypedArrayBase::MGLTypedArrayBase(jsi::Runtime &runtime, size_t size,
8080
MGLTypedArrayKind kind)
@@ -101,7 +101,7 @@ MGLTypedArrayKind MGLTypedArrayBase::getKind(jsi::Runtime &runtime) const {
101101
.getProperty(runtime, propNameIDCache.get(runtime, Prop::Name))
102102
.asString(runtime)
103103
.utf8(runtime);
104-
return getTypedArrayKindForName(constructorName);
104+
return MGLgetTypedArrayKindForName(constructorName);
105105
}
106106

107107
size_t MGLTypedArrayBase::size(jsi::Runtime &runtime) const {
@@ -147,7 +147,7 @@ jsi::ArrayBuffer MGLTypedArrayBase::getBuffer(jsi::Runtime &runtime) const {
147147
}
148148
}
149149

150-
bool isTypedArray(jsi::Runtime &runtime, const jsi::Object &jsObj) {
150+
bool MGLisTypedArray(jsi::Runtime &runtime, const jsi::Object &jsObj) {
151151
auto jsVal =
152152
runtime.global()
153153
.getProperty(runtime, propNameIDCache.get(runtime, Prop::ArrayBuffer))
@@ -164,7 +164,7 @@ bool isTypedArray(jsi::Runtime &runtime, const jsi::Object &jsObj) {
164164
}
165165
}
166166

167-
MGLTypedArrayBase getTypedArray(jsi::Runtime &runtime,
167+
MGLTypedArrayBase MGLgetTypedArray(jsi::Runtime &runtime,
168168
const jsi::Object &jsObj) {
169169
auto jsVal =
170170
runtime.global()
@@ -182,7 +182,7 @@ MGLTypedArrayBase getTypedArray(jsi::Runtime &runtime,
182182
}
183183
}
184184

185-
std::vector<uint8_t> arrayBufferToVector(jsi::Runtime &runtime,
185+
std::vector<uint8_t> MGLarrayBufferToVector(jsi::Runtime &runtime,
186186
jsi::Object &jsObj) {
187187
if (!jsObj.isArrayBuffer(runtime)) {
188188
throw std::runtime_error("Object is not an ArrayBuffer");
@@ -197,7 +197,7 @@ std::vector<uint8_t> arrayBufferToVector(jsi::Runtime &runtime,
197197
return std::vector<uint8_t>(dataBlock, dataBlock + blockSize);
198198
}
199199

200-
void arrayBufferUpdate(jsi::Runtime &runtime, jsi::ArrayBuffer &buffer,
200+
void MGLarrayBufferUpdate(jsi::Runtime &runtime, jsi::ArrayBuffer &buffer,
201201
std::vector<uint8_t> data, size_t offset) {
202202
uint8_t *dataBlock = buffer.data(runtime);
203203
size_t blockSize = buffer.size(runtime);
@@ -257,7 +257,7 @@ uint8_t* MGLTypedArray<T>::data(jsi::Runtime &runtime) {
257257
return getBuffer(runtime).data(runtime) + byteOffset(runtime);
258258
}
259259

260-
const jsi::PropNameID &PropNameIDCache::getConstructorNameProp(
260+
const jsi::PropNameID &MGLPropNameIDCache::getConstructorNameProp(
261261
jsi::Runtime &runtime, MGLTypedArrayKind kind) {
262262
switch (kind) {
263263
case MGLTypedArrayKind::Int8Array:
@@ -281,7 +281,7 @@ const jsi::PropNameID &PropNameIDCache::getConstructorNameProp(
281281
}
282282
}
283283

284-
jsi::PropNameID PropNameIDCache::createProp(jsi::Runtime &runtime, Prop prop) {
284+
jsi::PropNameID MGLPropNameIDCache::createProp(jsi::Runtime &runtime, Prop prop) {
285285
auto create = [&](const std::string &propName) {
286286
return jsi::PropNameID::forUtf8(runtime, propName);
287287
};
@@ -337,7 +337,7 @@ std::unordered_map<std::string, MGLTypedArrayKind> nameToKindMap = {
337337
{"Float64Array", MGLTypedArrayKind::Float64Array},
338338
};
339339

340-
MGLTypedArrayKind getTypedArrayKindForName(const std::string &name) {
340+
MGLTypedArrayKind MGLgetTypedArrayKindForName(const std::string &name) {
341341
return nameToKindMap.at(name);
342342
}
343343

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,13 @@ struct typedArrayTypeMap<MGLTypedArrayKind::Float64Array> {
6969
typedef double type;
7070
};
7171

72-
// Instance of this class will invalidate PropNameIDCache when destructor is called.
72+
// Instance of this class will invalidate MGLPropNameIDCache when destructor is called.
7373
// Attach this object to global in specific jsi::Runtime to make sure lifecycle of
7474
// the cache object is connected to the lifecycle of the js runtime
75-
class InvalidateCacheOnDestroy : public jsi::HostObject {
75+
class MGLInvalidateCacheOnDestroy : public jsi::HostObject {
7676
public:
77-
explicit InvalidateCacheOnDestroy(jsi::Runtime &runtime);
78-
virtual ~InvalidateCacheOnDestroy();
77+
explicit MGLInvalidateCacheOnDestroy(jsi::Runtime &runtime);
78+
virtual ~MGLInvalidateCacheOnDestroy();
7979
virtual jsi::Value get(jsi::Runtime &, const jsi::PropNameID &name) {
8080
return jsi::Value::null();
8181
}
@@ -123,13 +123,13 @@ class MGLTypedArrayBase : public jsi::Object {
123123
friend class MGLTypedArray;
124124
};
125125

126-
bool isTypedArray(jsi::Runtime &runtime, const jsi::Object &jsObj);
127-
MGLTypedArrayBase getTypedArray(jsi::Runtime &runtime,
126+
bool MGLisTypedArray(jsi::Runtime &runtime, const jsi::Object &jsObj);
127+
MGLTypedArrayBase MGLgetTypedArray(jsi::Runtime &runtime,
128128
const jsi::Object &jsObj);
129129

130-
std::vector<uint8_t> arrayBufferToVector(jsi::Runtime &runtime,
130+
std::vector<uint8_t> MGLarrayBufferToVector(jsi::Runtime &runtime,
131131
jsi::Object &jsObj);
132-
void arrayBufferUpdate(jsi::Runtime &runtime, jsi::ArrayBuffer &buffer,
132+
void MGLarrayBufferUpdate(jsi::Runtime &runtime, jsi::ArrayBuffer &buffer,
133133
std::vector<uint8_t> data, size_t offset);
134134

135135
template <MGLTypedArrayKind T>

packages/react-native-quick-crypto/ios/QuickCryptoModule.mm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ - (void)setBridge:(RCTBridge *)bridge {
4141
auto object = jsi::Object::createFromHostObject(runtime, hostObject);
4242
runtime.global().setProperty(runtime, "__QuickCryptoProxy", std::move(object));
4343

44-
// Adds the PropNameIDCache object to the Runtime. If the Runtime gets
44+
// Adds the MGLPropNameIDCache object to the Runtime. If the Runtime gets
4545
// destroyed, the Object gets destroyed and the cache gets invalidated.
46-
auto propNameIdCache = std::make_shared<InvalidateCacheOnDestroy>(runtime);
46+
auto propNameIdCache = std::make_shared<MGLInvalidateCacheOnDestroy>(runtime);
4747
runtime.global().setProperty(
4848
runtime,
4949
"rnqcArrayBufferPropNameIdCache",

0 commit comments

Comments
 (0)