Skip to content

Commit

Permalink
chore: deps: update mmkv to 1.3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
cinit committed Nov 24, 2023
1 parent f71bf77 commit c2b9e8f
Show file tree
Hide file tree
Showing 3 changed files with 136 additions and 77 deletions.
2 changes: 1 addition & 1 deletion libs/mmkv/MMKV
Submodule MMKV updated 64 files
+1 −1 Android/MMKV/gradle.properties
+1 −1 Android/MMKV/mmkv/build.gradle
+23 −7 Android/MMKV/mmkv/src/main/cpp/flutter-bridge.cpp
+58 −6 Android/MMKV/mmkv/src/main/cpp/native-bridge.cpp
+112 −8 Android/MMKV/mmkv/src/main/java/com/tencent/mmkv/MMKV.java
+104 −0 Android/MMKV/mmkv/src/main/java/dalvik/annotation/optimization/FastNative.java
+3 −3 Android/MMKV/mmkvdemo/build.gradle
+133 −0 Android/MMKV/mmkvdemo/src/main/java/com/tencent/mmkvdemo/MainActivity.java
+2 −2 Android/MMKV/mmkvdemo/src/main/java/com/tencent/mmkvdemo/SQLiteKV.java
+26 −0 CHANGELOG.md
+27 −4 Core/CodedInputData.cpp
+5 −1 Core/CodedInputData.h
+12 −0 Core/CodedOutputData.cpp
+6 −0 Core/CodedOutputData.h
+7 −0 Core/MMBuffer.cpp
+3 −0 Core/MMBuffer.h
+76 −13 Core/MMKV.cpp
+40 −12 Core/MMKV.h
+1 −1 Core/MMKVPredef.h
+5 −4 Core/MMKV_Android.cpp
+191 −11 Core/MMKV_IO.cpp
+43 −27 Core/MMKV_OSX.cpp
+10 −4 Core/MMKV_OSX.h
+19 −5 Core/MemoryFile.cpp
+3 −3 Core/MemoryFile.h
+2 −2 Core/MemoryFile_Android.cpp
+9 −5 Core/MemoryFile_Win32.cpp
+11 −0 Core/MiniPBCoder.cpp
+3 −0 Core/MiniPBCoder.h
+8 −0 Core/MiniPBCoder_OSX.cpp
+5 −0 Core/ThreadLock.cpp
+4 −0 Core/ThreadLock.h
+2 −2 MMKV.podspec
+2 −2 MMKVAppExtension.podspec
+1 −1 MMKVCore.podspec
+2 −2 MMKVWatchExtension.podspec
+79 −1 POSIX/Python/demo.py
+8 −4 POSIX/Python/libmmkv_python.cpp
+716 −1 POSIX/demo/demo.cpp
+24 −7 POSIX/golang/golang-bridge.cpp
+5 −2 POSIX/golang/golang-bridge.h
+30 −4 POSIX/golang/mmkv.go
+84 −2 POSIX/golang/test/main.go
+3 −3 README.md
+2 −2 README_CN.md
+9 −7 Script/formatCode.py
+23 −0 Win32/Win32Demo/Win32Demo.cpp
+21 −0 flutter/CHANGELOG.md
+3 −3 flutter/README.md
+1 −1 flutter/android/build.gradle
+8 −8 flutter/example/ios/Podfile.lock
+56 −3 flutter/example/lib/main.dart
+43 −43 flutter/example/pubspec.lock
+25 −5 flutter/ios/Classes/flutter-bridge.mm
+2 −2 flutter/ios/mmkvflutter.podspec
+37 −11 flutter/lib/mmkv.dart
+52 −44 flutter/pubspec.lock
+2 −2 flutter/pubspec.yaml
+14 −6 iOS/MMKV/MMKV.xcodeproj/project.pbxproj
+53 −0 iOS/MMKV/MMKV/AutoCleanInfo.hpp
+33 −0 iOS/MMKV/MMKV/MMKV.h
+130 −17 iOS/MMKV/MMKV/libMMKV.mm
+253 −0 iOS/MMKVDemo/MMKVDemo/ViewController.mm
+237 −0 iOS/MMKVDemo/MMKVMacDemo/ViewController.mm
9 changes: 8 additions & 1 deletion libs/mmkv/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,14 @@ android {
val main by getting
main.apply {
manifest.srcFile("AndroidManifest.xml")
java.setSrcDirs(listOf("MMKV/Android/MMKV/mmkv/src/main/java"))
java {
setSrcDirs(listOf("MMKV/Android/MMKV/mmkv/src/main/java"))
// it seems that FastNative.class is already included in the SDK 34
(this as com.android.build.gradle.api.AndroidSourceDirectorySet).apply {
// AGP kts DSK still not having a way to exclude files?
filter.exclude("**/FastNative.java")
}
}
aidl.setSrcDirs(listOf("MMKV/Android/MMKV/mmkv/src/main/aidl"))
res.setSrcDirs(listOf("MMKV/Android/MMKV/mmkv/src/main/res"))
assets.setSrcDirs(listOf("MMKV/Android/MMKV/mmkv/src/main/assets"))
Expand Down
202 changes: 127 additions & 75 deletions libs/mmkv/native-bridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,8 @@ static void onContentChangedByOuterProcess(const std::string &mmapID) {
}
}

MMKV_JNI jlong getMMKVWithID(JNIEnv *env, jobject, jstring mmapID, jint mode, jstring cryptKey, jstring rootPath) {
MMKV_JNI jlong getMMKVWithID(JNIEnv *env, jobject, jstring mmapID, jint mode, jstring cryptKey, jstring rootPath,
jlong expectedCapacity) {
MMKV *kv = nullptr;
if (!mmapID) {
return (jlong) kv;
Expand All @@ -307,19 +308,19 @@ MMKV_JNI jlong getMMKVWithID(JNIEnv *env, jobject, jstring mmapID, jint mode, js
if (crypt.length() > 0) {
if (rootPath) {
string path = jstring2string(env, rootPath);
kv = MMKV::mmkvWithID(str, DEFAULT_MMAP_SIZE, (MMKVMode) mode, &crypt, &path);
kv = MMKV::mmkvWithID(str, DEFAULT_MMAP_SIZE, (MMKVMode) mode, &crypt, &path, expectedCapacity);
} else {
kv = MMKV::mmkvWithID(str, DEFAULT_MMAP_SIZE, (MMKVMode) mode, &crypt, nullptr);
kv = MMKV::mmkvWithID(str, DEFAULT_MMAP_SIZE, (MMKVMode) mode, &crypt, nullptr, expectedCapacity);
}
done = true;
}
}
if (!done) {
if (rootPath) {
string path = jstring2string(env, rootPath);
kv = MMKV::mmkvWithID(str, DEFAULT_MMAP_SIZE, (MMKVMode) mode, nullptr, &path);
kv = MMKV::mmkvWithID(str, DEFAULT_MMAP_SIZE, (MMKVMode) mode, nullptr, &path, expectedCapacity);
} else {
kv = MMKV::mmkvWithID(str, DEFAULT_MMAP_SIZE, (MMKVMode) mode, nullptr, nullptr);
kv = MMKV::mmkvWithID(str, DEFAULT_MMAP_SIZE, (MMKVMode) mode, nullptr, nullptr, expectedCapacity);
}
}

Expand Down Expand Up @@ -1013,81 +1014,132 @@ MMKV_JNI jboolean disableAutoExpire(JNIEnv *env, jobject instance) {
return (jboolean) false;
}

MMKV_JNI void enableCompareBeforeSet(JNIEnv *env, jobject instance) {
MMKV *kv = getMMKV(env, instance);
if (kv) {
kv->enableCompareBeforeSet();
}
}

MMKV_JNI void disableCompareBeforeSet(JNIEnv *env, jobject instance) {
MMKV *kv = getMMKV(env, instance);
if (kv) {
kv->disableCompareBeforeSet();
}
}

MMKV_JNI bool isCompareBeforeSetEnabled(JNIEnv *env, jobject instance) {
MMKV *kv = getMMKV(env, instance);
if (kv) {
return kv->isCompareBeforeSetEnabled();
}
return false;
}

MMKV_JNI bool isEncryptionEnabled(JNIEnv *env, jobject instance) {
MMKV *kv = getMMKV(env, instance);
if (kv) {
return kv->isEncryptionEnabled();
}
return false;
}

MMKV_JNI bool isExpirationEnabled(JNIEnv *env, jobject instance) {
MMKV *kv = getMMKV(env, instance);
if (kv) {
return kv->isExpirationEnabled();
}
return false;
}

MMKV_JNI void clearAllWithKeepingSpace(JNIEnv *env, jobject instance) {
MMKV *kv = getMMKV(env, instance);
if (kv) {
kv->clearAll(true);
}
}

} // namespace mmkv

static JNINativeMethod g_methods[] = {
{"onExit", "()V", (void *) mmkv::onExit},
{"cryptKey", "()Ljava/lang/String;", (void *) mmkv::cryptKey},
{"onExit", "()V", (void *) mmkv::onExit},
{"cryptKey", "()Ljava/lang/String;", (void *) mmkv::cryptKey},
# ifndef MMKV_DISABLE_CRYPT
{"reKey", "(Ljava/lang/String;)Z", (void *) mmkv::reKey},
{"checkReSetCryptKey", "(Ljava/lang/String;)V", (void *) mmkv::checkReSetCryptKey},
{"reKey", "(Ljava/lang/String;)Z", (void *) mmkv::reKey},
{"checkReSetCryptKey", "(Ljava/lang/String;)V", (void *) mmkv::checkReSetCryptKey},
# endif
{"pageSize", "()I", (void *) mmkv::pageSize},
{"mmapID", "()Ljava/lang/String;", (void *) mmkv::mmapID},
{"version", "()Ljava/lang/String;", (void *) mmkv::version},
{"lock", "()V", (void *) mmkv::lock},
{"unlock", "()V", (void *) mmkv::unlock},
{"tryLock", "()Z", (void *) mmkv::tryLock},
{"allKeys", "(JZ)[Ljava/lang/String;", (void *) mmkv::allKeys},
{"removeValuesForKeys", "([Ljava/lang/String;)V", (void *) mmkv::removeValuesForKeys},
{"clearAll", "()V", (void *) mmkv::clearAll},
{"trim", "()V", (void *) mmkv::trim},
{"close", "()V", (void *) mmkv::close},
{"clearMemoryCache", "()V", (void *) mmkv::clearMemoryCache},
{"sync", "(Z)V", (void *) mmkv::sync},
{"isFileValid", "(Ljava/lang/String;Ljava/lang/String;)Z", (void *) mmkv::isFileValid},
{"ashmemFD", "()I", (void *) mmkv::ashmemFD},
{"ashmemMetaFD", "()I", (void *) mmkv::ashmemMetaFD},
//{"jniInitialize", "(Ljava/lang/String;Ljava/lang/String;I)V", (void *) mmkv::jniInitialize},
{"jniInitialize", "(Ljava/lang/String;Ljava/lang/String;IZ)V", (void *) mmkv::jniInitialize_2},
{"getMMKVWithID", "(Ljava/lang/String;ILjava/lang/String;Ljava/lang/String;)J", (void *) mmkv::getMMKVWithID},
{"getMMKVWithIDAndSize", "(Ljava/lang/String;IILjava/lang/String;)J", (void *) mmkv::getMMKVWithIDAndSize},
{"getDefaultMMKV", "(ILjava/lang/String;)J", (void *) mmkv::getDefaultMMKV},
{"getMMKVWithAshmemFD", "(Ljava/lang/String;IILjava/lang/String;)J", (void *) mmkv::getMMKVWithAshmemFD},
{"encodeBool", "(JLjava/lang/String;Z)Z", (void *) mmkv::encodeBool},
{"encodeBool_2", "(JLjava/lang/String;ZI)Z", (void *) mmkv::encodeBool_2},
{"decodeBool", "(JLjava/lang/String;Z)Z", (void *) mmkv::decodeBool},
{"encodeInt", "(JLjava/lang/String;I)Z", (void *) mmkv::encodeInt},
{"encodeInt_2", "(JLjava/lang/String;II)Z", (void *) mmkv::encodeInt_2},
{"decodeInt", "(JLjava/lang/String;I)I", (void *) mmkv::decodeInt},
{"encodeLong", "(JLjava/lang/String;J)Z", (void *) mmkv::encodeLong},
{"encodeLong_2", "(JLjava/lang/String;JI)Z", (void *) mmkv::encodeLong_2},
{"decodeLong", "(JLjava/lang/String;J)J", (void *) mmkv::decodeLong},
{"encodeFloat", "(JLjava/lang/String;F)Z", (void *) mmkv::encodeFloat},
{"encodeFloat_2", "(JLjava/lang/String;FI)Z", (void *) mmkv::encodeFloat_2},
{"decodeFloat", "(JLjava/lang/String;F)F", (void *) mmkv::decodeFloat},
{"encodeDouble", "(JLjava/lang/String;D)Z", (void *) mmkv::encodeDouble},
{"encodeDouble_2", "(JLjava/lang/String;DI)Z", (void *) mmkv::encodeDouble_2},
{"decodeDouble", "(JLjava/lang/String;D)D", (void *) mmkv::decodeDouble},
{"encodeString", "(JLjava/lang/String;Ljava/lang/String;)Z", (void *) mmkv::encodeString},
{"encodeString_2", "(JLjava/lang/String;Ljava/lang/String;I)Z", (void *) mmkv::encodeString_2},
{"decodeString", "(JLjava/lang/String;Ljava/lang/String;)Ljava/lang/String;", (void *) mmkv::decodeString},
{"encodeSet", "(JLjava/lang/String;[Ljava/lang/String;)Z", (void *) mmkv::encodeSet},
{"encodeSet_2", "(JLjava/lang/String;[Ljava/lang/String;I)Z", (void *) mmkv::encodeSet_2},
{"decodeStringSet", "(JLjava/lang/String;)[Ljava/lang/String;", (void *) mmkv::decodeStringSet},
{"encodeBytes", "(JLjava/lang/String;[B)Z", (void *) mmkv::encodeBytes},
{"encodeBytes_2", "(JLjava/lang/String;[BI)Z", (void *) mmkv::encodeBytes_2},
{"decodeBytes", "(JLjava/lang/String;)[B", (void *) mmkv::decodeBytes},
{"containsKey", "(JLjava/lang/String;)Z", (void *) mmkv::containsKey},
{"count", "(JZ)J", (void *) mmkv::count},
{"totalSize", "(J)J", (void *) mmkv::totalSize},
{"actualSize", "(J)J", (void *) mmkv::actualSize},
{"removeValueForKey", "(JLjava/lang/String;)V", (void *) mmkv::removeValueForKey},
{"valueSize", "(JLjava/lang/String;Z)I", (void *) mmkv::valueSize},
{"setLogLevel", "(I)V", (void *) mmkv::setLogLevel},
{"setCallbackHandler", "(ZZ)V", (void *) mmkv::setCallbackHandler},
{"createNB", "(I)J", (void *) mmkv::createNB},
{"destroyNB", "(JI)V", (void *) mmkv::destroyNB},
{"writeValueToNB", "(JLjava/lang/String;JI)I", (void *) mmkv::writeValueToNB},
{"setWantsContentChangeNotify", "(Z)V", (void *) mmkv::setWantsContentChangeNotify},
{"checkContentChangedByOuterProcess", "()V", (void *) mmkv::checkContentChanged},
{"checkProcessMode", "(J)Z", (void *) mmkv::checkProcessMode},
{"backupOneToDirectory", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Z", (void *) mmkv::backupOne},
{"restoreOneMMKVFromDirectory", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Z", (void *) mmkv::restoreOne},
{"backupAllToDirectory", "(Ljava/lang/String;)J", (void *) mmkv::backupAll},
{"restoreAllFromDirectory", "(Ljava/lang/String;)J", (void *) mmkv::restoreAll},
{"enableAutoKeyExpire", "(I)Z", (void *) mmkv::enableAutoExpire},
{"disableAutoKeyExpire", "()Z", (void *) mmkv::disableAutoExpire},
{"pageSize", "()I", (void *) mmkv::pageSize},
{"mmapID", "()Ljava/lang/String;", (void *) mmkv::mmapID},
{"version", "()Ljava/lang/String;", (void *) mmkv::version},
{"lock", "()V", (void *) mmkv::lock},
{"unlock", "()V", (void *) mmkv::unlock},
{"tryLock", "()Z", (void *) mmkv::tryLock},
{"allKeys", "(JZ)[Ljava/lang/String;", (void *) mmkv::allKeys},
{"removeValuesForKeys", "([Ljava/lang/String;)V", (void *) mmkv::removeValuesForKeys},
{"clearAll", "()V", (void *) mmkv::clearAll},
{"trim", "()V", (void *) mmkv::trim},
{"close", "()V", (void *) mmkv::close},
{"clearMemoryCache", "()V", (void *) mmkv::clearMemoryCache},
{"sync", "(Z)V", (void *) mmkv::sync},
{"isFileValid", "(Ljava/lang/String;Ljava/lang/String;)Z", (void *) mmkv::isFileValid},
{"ashmemFD", "()I", (void *) mmkv::ashmemFD},
{"ashmemMetaFD", "()I", (void *) mmkv::ashmemMetaFD},
//{"jniInitialize", "(Ljava/lang/String;Ljava/lang/String;I)V", (void *) mmkv::jniInitialize},
{"jniInitialize", "(Ljava/lang/String;Ljava/lang/String;IZ)V", (void *) mmkv::jniInitialize_2},
{"getMMKVWithID", "(Ljava/lang/String;ILjava/lang/String;Ljava/lang/String;J)J", (void *) mmkv::getMMKVWithID},
{"getMMKVWithIDAndSize", "(Ljava/lang/String;IILjava/lang/String;)J", (void *) mmkv::getMMKVWithIDAndSize},
{"getDefaultMMKV", "(ILjava/lang/String;)J", (void *) mmkv::getDefaultMMKV},
{"getMMKVWithAshmemFD", "(Ljava/lang/String;IILjava/lang/String;)J", (void *) mmkv::getMMKVWithAshmemFD},
{"encodeBool", "(JLjava/lang/String;Z)Z", (void *) mmkv::encodeBool},
{"encodeBool_2", "(JLjava/lang/String;ZI)Z", (void *) mmkv::encodeBool_2},
{"decodeBool", "(JLjava/lang/String;Z)Z", (void *) mmkv::decodeBool},
{"encodeInt", "(JLjava/lang/String;I)Z", (void *) mmkv::encodeInt},
{"encodeInt_2", "(JLjava/lang/String;II)Z", (void *) mmkv::encodeInt_2},
{"decodeInt", "(JLjava/lang/String;I)I", (void *) mmkv::decodeInt},
{"encodeLong", "(JLjava/lang/String;J)Z", (void *) mmkv::encodeLong},
{"encodeLong_2", "(JLjava/lang/String;JI)Z", (void *) mmkv::encodeLong_2},
{"decodeLong", "(JLjava/lang/String;J)J", (void *) mmkv::decodeLong},
{"encodeFloat", "(JLjava/lang/String;F)Z", (void *) mmkv::encodeFloat},
{"encodeFloat_2", "(JLjava/lang/String;FI)Z", (void *) mmkv::encodeFloat_2},
{"decodeFloat", "(JLjava/lang/String;F)F", (void *) mmkv::decodeFloat},
{"encodeDouble", "(JLjava/lang/String;D)Z", (void *) mmkv::encodeDouble},
{"encodeDouble_2", "(JLjava/lang/String;DI)Z", (void *) mmkv::encodeDouble_2},
{"decodeDouble", "(JLjava/lang/String;D)D", (void *) mmkv::decodeDouble},
{"encodeString", "(JLjava/lang/String;Ljava/lang/String;)Z", (void *) mmkv::encodeString},
{"encodeString_2", "(JLjava/lang/String;Ljava/lang/String;I)Z", (void *) mmkv::encodeString_2},
{"decodeString", "(JLjava/lang/String;Ljava/lang/String;)Ljava/lang/String;", (void *) mmkv::decodeString},
{"encodeSet", "(JLjava/lang/String;[Ljava/lang/String;)Z", (void *) mmkv::encodeSet},
{"encodeSet_2", "(JLjava/lang/String;[Ljava/lang/String;I)Z", (void *) mmkv::encodeSet_2},
{"decodeStringSet", "(JLjava/lang/String;)[Ljava/lang/String;", (void *) mmkv::decodeStringSet},
{"encodeBytes", "(JLjava/lang/String;[B)Z", (void *) mmkv::encodeBytes},
{"encodeBytes_2", "(JLjava/lang/String;[BI)Z", (void *) mmkv::encodeBytes_2},
{"decodeBytes", "(JLjava/lang/String;)[B", (void *) mmkv::decodeBytes},
{"containsKey", "(JLjava/lang/String;)Z", (void *) mmkv::containsKey},
{"count", "(JZ)J", (void *) mmkv::count},
{"totalSize", "(J)J", (void *) mmkv::totalSize},
{"actualSize", "(J)J", (void *) mmkv::actualSize},
{"removeValueForKey", "(JLjava/lang/String;)V", (void *) mmkv::removeValueForKey},
{"valueSize", "(JLjava/lang/String;Z)I", (void *) mmkv::valueSize},
{"setLogLevel", "(I)V", (void *) mmkv::setLogLevel},
{"setCallbackHandler", "(ZZ)V", (void *) mmkv::setCallbackHandler},
{"createNB", "(I)J", (void *) mmkv::createNB},
{"destroyNB", "(JI)V", (void *) mmkv::destroyNB},
{"writeValueToNB", "(JLjava/lang/String;JI)I", (void *) mmkv::writeValueToNB},
{"setWantsContentChangeNotify", "(Z)V", (void *) mmkv::setWantsContentChangeNotify},
{"checkContentChangedByOuterProcess", "()V", (void *) mmkv::checkContentChanged},
{"checkProcessMode", "(J)Z", (void *) mmkv::checkProcessMode},
{"backupOneToDirectory", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Z", (void *) mmkv::backupOne},
{"restoreOneMMKVFromDirectory", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Z", (void *) mmkv::restoreOne},
{"backupAllToDirectory", "(Ljava/lang/String;)J", (void *) mmkv::backupAll},
{"restoreAllFromDirectory", "(Ljava/lang/String;)J", (void *) mmkv::restoreAll},
{"enableAutoKeyExpire", "(I)Z", (void *) mmkv::enableAutoExpire},
{"disableAutoKeyExpire", "()Z", (void *) mmkv::disableAutoExpire},
{"nativeEnableCompareBeforeSet", "()V", (void *) mmkv::enableCompareBeforeSet},
{"disableCompareBeforeSet", "()V", (void *) mmkv::disableCompareBeforeSet},
{"isCompareBeforeSetEnabled", "()Z", (void *) mmkv::isCompareBeforeSetEnabled},
{"isEncryptionEnabled", "()Z", (void *) mmkv::isEncryptionEnabled},
{"isExpirationEnabled", "()Z", (void *) mmkv::isExpirationEnabled},
{"clearAllWithKeepingSpace", "()V", (void *) mmkv::clearAllWithKeepingSpace},
};

static int registerNativeMethods(JNIEnv *env, jclass cls) {
Expand Down

0 comments on commit c2b9e8f

Please sign in to comment.